00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TYYYAnalysis.h"
00017
00018 #include "Riostream.h"
00019
00020 #include "TCanvas.h"
00021 #include "TH1.h"
00022 #include "TFile.h"
00023
00024 #include "Go4EventServer.h"
00025 #include "TGo4AnalysisStep.h"
00026
00027 #include "TYYYUnpackFact.h"
00028 #include "TYYYUnpackEvent.h"
00029 #include "TYYYParameter.h"
00030 #include "TYYYRawEvent.h"
00031
00032
00033 TYYYAnalysis::TYYYAnalysis()
00034 : fUserFile(0),fRawEvent(0),fUnpackEvent(0)
00035 {
00036 cout << "Wrong constructor TYYYAnalysis()!" << endl;
00037 }
00038
00039
00040 TYYYAnalysis::TYYYAnalysis(const char* lmd, const char* out1, const char* out2)
00041 : fUserFile(0),
00042 fRawEvent(0),
00043 fUnpackEvent(0),
00044 fSize(0),
00045 fEvents(0),
00046 fLastEvent(0)
00047 {
00048
00049
00050
00051 cout << "**** TYYYAnalysis: Create" << endl;
00052
00053
00054
00055
00056 TYYYUnpackFact* factory1 = new TYYYUnpackFact("Unpack-factory");
00057 TGo4UserSourceParameter* source1 = new TGo4UserSourceParameter(lmd);
00058 TGo4FileStoreParameter* store1 = new TGo4FileStoreParameter(out1);
00059 TGo4AnalysisStep* step1 = new TGo4AnalysisStep("Unpack",factory1,source1,store1,0);
00060 store1->SetOverwriteMode(kTRUE);
00061 step1->SetSourceEnabled(kTRUE);
00062 step1->SetStoreEnabled(kFALSE);
00063 step1->SetProcessEnabled(kTRUE);
00064 step1->SetErrorStopEnabled(kTRUE);
00065 AddAnalysisStep(step1);
00066
00067
00068
00070
00071
00072
00073 fPar = new TYYYParameter("YYYPar1");
00074 fPar->frP1 = 100;
00075 fPar->frP2 = 200;
00076 AddParameter(fPar);
00077 TCanvas* mycan=new TCanvas("TestCanvas","Does this work?");
00078 mycan->Divide(2,2);
00079 AddCanvas(mycan);
00080
00081
00082 }
00083
00084
00085 TYYYAnalysis::~TYYYAnalysis()
00086 {
00087 cout << "**** TYYYAnalysis: Delete" << endl;
00088 }
00089
00090
00091
00092 Int_t TYYYAnalysis::UserPreLoop()
00093 {
00094 cout << "**** TYYYAnalysis: PreLoop" << endl;
00095
00096 fRawEvent = dynamic_cast<TYYYRawEvent*> (GetInputEvent("Unpack"));
00097 fUnpackEvent = dynamic_cast<TYYYUnpackEvent*> (GetOutputEvent("Unpack"));
00098 fEvents=0;
00099 fLastEvent=0;
00100
00101
00102
00103 fSize=(TH1D*)GetHistogram("Eventsize");
00104 if(fSize==0)
00105 {
00106 fSize = new TH1D ("Eventsize", "Read columns",160,1,160);
00107 AddHistogram(fSize);
00108 }
00109 ClearObjects("Histograms");
00110
00111 return 0;
00112 }
00113
00114 Int_t TYYYAnalysis::UserPostLoop()
00115 {
00116 cout << "**** TYYYAnalysis: PostLoop" << endl;
00117 cout << " Total events: " << fEvents << endl;
00118 TCanvas* can=GetCanvas("TestCanvas");
00119 TH1* hx=GetHistogram("Xfinal");
00120 TH1* hy=GetHistogram("Yfinal");
00121 TH1* hvx=GetHistogram("Vxfinal");
00122 TH1* hvy=GetHistogram("Vyfinal");
00123 if(can)
00124 {
00125 can->cd(1);
00126 if(hx) hx->Draw();
00127 can->cd(2);
00128 if(hy) hy->Draw();
00129 can->cd(3);
00130 if(hvx) hvx->Draw();
00131 can->cd(4);
00132 if(hvy) hvy->Draw();
00133 }
00134
00135
00136 fUnpackEvent = 0;
00137 fRawEvent = 0;
00138 fEvents=0;
00139 return 0;
00140 }
00141
00142
00143 Int_t TYYYAnalysis::UserEventFunc()
00144 {
00146 Int_t value=0;
00147 if(fRawEvent) value = fRawEvent->GetColumns();
00148 fSize->Fill(value);
00149 fEvents++;
00150 return 0;
00151 }
00152
00153