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