Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TXXXAnalysis.h"
00015
00016 #include <stdlib.h>
00017
00018 #include "TH1.h"
00019 #include "TFile.h"
00020 #include "TSystem.h"
00021
00022 extern "C" {
00023 #include "s_filhe_swap.h"
00024 #include "s_bufhe_swap.h"
00025 #include "f_ut_utime.h"
00026 }
00027
00028 #include "TGo4Log.h"
00029 #include "TGo4Fitter.h"
00030 #include "TGo4FitterEnvelope.h"
00031 #include "TGo4AnalysisStep.h"
00032 #include "TGo4StepFactory.h"
00033 #include "TXXXParameter.h"
00034 #include "TXXXUnpackEvent.h"
00035 #include "TXXXAnlEvent.h"
00036 #include "TGo4Version.h"
00037
00038 #include "Go4EventServer.h"
00039
00040
00041 TXXXAnalysis::TXXXAnalysis() :
00042 TGo4Analysis(),
00043 fMbsEvent(0),
00044 fRawEvent(0),
00045 fCalEvent(0)
00046 {
00047 TGo4Log::Error("Wrong constructor TXXXAnalysis()!");
00048 }
00049
00050
00051
00052 TXXXAnalysis::TXXXAnalysis(int argc, char** argv) :
00053 TGo4Analysis(argc, argv),
00054 fMbsEvent(0),
00055 fRawEvent(0),
00056 fCalEvent(0),
00057 fSize(0),
00058 fEvents(0),
00059 fLastEvent(0)
00060 {
00061 if (!TGo4Version::CheckVersion(__GO4BUILDVERSION__)) {
00062 TGo4Log::Error("Go4 version mismatch");
00063 exit(-1);
00064 }
00065
00066 TGo4Log::Info("TXXXAnalysis: Create %s", GetName());
00067
00068 TString kind, input, out1, out2;
00069
00070
00071 TGo4StepFactory* factory1 = new TGo4StepFactory("UnpackFactory");
00072 factory1->DefEventProcessor("UnpackProc", "TXXXUnpackProc");
00073 factory1->DefOutputEvent("UnpackEvent", "TXXXUnpackEvent");
00074 TGo4AnalysisStep* step1 = new TGo4AnalysisStep("Unpack",factory1,0,0,0);
00075 step1->SetErrorStopEnabled(kTRUE);
00076 AddAnalysisStep(step1);
00077
00078 step1->SetSourceEnabled(kTRUE);
00079 step1->SetStoreEnabled(kFALSE);
00080 step1->SetProcessEnabled(kTRUE);
00081
00082
00083 TGo4StepFactory* factory2 = new TGo4StepFactory("AnalysisFactory");
00084 factory2->DefInputEvent("UnpackEvent", "TXXXUnpackEvent");
00085 factory2->DefEventProcessor("AnlProc", "TXXXAnlProc");
00086 factory2->DefOutputEvent("AnlEvent", "TXXXAnlEvent");
00087 TGo4AnalysisStep* step2 = new TGo4AnalysisStep("Analysis",factory2,0,0,0);
00088 step2->SetErrorStopEnabled(kTRUE);
00089 AddAnalysisStep(step2);
00090
00091 step2->SetSourceEnabled(kFALSE);
00092 step2->SetStoreEnabled(kFALSE);
00093 step2->SetProcessEnabled(kTRUE);
00094
00095
00096
00097 fWinCon1 = MakeWinCond("wincon1", 50, 2000);
00098
00099
00100 }
00101
00102 TXXXAnalysis::~TXXXAnalysis()
00103 {
00104 TGo4Log::Info("TXXXAnalysis: Delete");
00105 }
00106
00107
00108
00109 Int_t TXXXAnalysis::UserPreLoop()
00110 {
00111 TGo4Log::Info("TXXXAnalysis: PreLoop");
00112 Print();
00113
00114 fMbsEvent = dynamic_cast<TGo4MbsEvent*> (GetInputEvent("Unpack"));
00115 fRawEvent = dynamic_cast<TXXXUnpackEvent*> (GetOutputEvent("Unpack"));
00116 fCalEvent = dynamic_cast<TXXXAnlEvent*> (GetOutputEvent("Analysis"));
00117 fEvents=0;
00118 fLastEvent=0;
00119
00120
00121
00122
00123 fSize = (TH1D*) MakeTH1('D',"Eventsize", "Event size [b]",160,1,160);
00124 return 0;
00125 }
00126
00127 Int_t TXXXAnalysis::UserPostLoop()
00128 {
00129 TGo4Log::Info("TXXXAnalysis: PostLoop");
00130 TGo4Log::Info("Last event: %d, total events: %d", fLastEvent, fEvents);
00131 if(fMbsEvent) {
00132
00133
00134
00135
00136 fMbsEvent->PrintMbsFileHeader();
00137
00138
00139 fMbsEvent->PrintMbsBufferHeader();
00140 }
00141
00142 fMbsEvent = 0;
00143 fRawEvent = 0;
00144 fCalEvent = 0;
00145 fEvents = 0;
00146 return 0;
00147 }
00148
00149
00150 Int_t TXXXAnalysis::UserEventFunc()
00151 {
00153 Int_t value = 0;
00154 Int_t count = 0;
00155 if(fMbsEvent) value = fMbsEvent->GetDlen()/2+2;
00156 fSize->Fill(value);
00157 fEvents++;
00158 if(fEvents == 1 || IsNewInputFile()) {
00159 if(fMbsEvent) {
00160 count = fMbsEvent->GetCount();
00161 TGo4Log::Info("First event #: %d", count);
00162 fMbsEvent->PrintMbsBufferHeader();
00163 }
00164 }
00165 fLastEvent = count;
00166 return 0;
00167 }