00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TXXXAnalysis.h"
00017
00018 #include "Riostream.h"
00019 #include <time.h>
00020
00021 #include "Go4EventServer.h"
00022 #include "TGo4StepFactory.h"
00023 #include "TGo4AnalysisStep.h"
00024 #include "TXXXParam.h"
00025 #include "TXXXControl.h"
00026
00027
00028 TXXXAnalysis::TXXXAnalysis() : fUserFile(0),fMbsEvent(0){}
00029
00030
00031 TXXXAnalysis::TXXXAnalysis(const char* input, Int_t type, Int_t port, const char* output, Bool_t enable)
00032 : fUserFile(0),
00033 fMbsEvent(0),
00034 fEvents(0),
00035 fLastEvent(0)
00036 {
00037
00038
00039
00040
00041
00042
00043 TGo4MbsFileParameter* mbsfile;
00044 TGo4MbsTransportParameter* mbstrans;
00045 TGo4MbsStreamParameter* mbsstream;
00046 TGo4RevServParameter* mbsrev;
00047 TGo4MbsEventServerParameter* mbsevent;
00048 TGo4FileStoreParameter* store;
00049 TGo4EventProcessorParameter* proc;
00050
00051 TGo4StepFactory* factory;
00052 TGo4AnalysisStep* step;
00053
00054 factory = new TGo4StepFactory("Factory");
00055 store = new TGo4FileStoreParameter(output);
00056 proc = new TGo4EventProcessorParameter("ProcType",4);
00057 switch (type){
00058 case GO4EV_MBS_FILE:
00059 mbsfile = new TGo4MbsFileParameter(input);
00060 step = new TGo4AnalysisStep("Analysis",factory,mbsfile,store,proc);
00061 cout << "**** Analysis: Create file input " << input << endl;
00062 break;
00063 case GO4EV_MBS_STREAM:
00064 mbsstream = new TGo4MbsStreamParameter(input);
00065 step = new TGo4AnalysisStep("Analysis",factory,mbsstream,store,proc);
00066 cout << "**** Analysis: Create stream input " << input << endl;
00067 break;
00068 case GO4EV_MBS_TRANSPORT:
00069 mbstrans = new TGo4MbsTransportParameter(input);
00070 step = new TGo4AnalysisStep("Analysis",factory,mbstrans,store,proc);
00071 cout << "**** Analysis: Create transport input " << input << endl;
00072 break;
00073 case GO4EV_MBS_REVSERV:
00074 mbsrev = new TGo4RevServParameter(input);
00075 mbsrev->SetPort(port);
00076 step = new TGo4AnalysisStep("Analysis",factory,mbsrev,store,proc);
00077 cout << "**** Analysis: Create remote event server input " << input << " port " << port <<endl;
00078 break;
00079 case GO4EV_MBS_EVENTSERVER:
00080 mbsevent = new TGo4MbsEventServerParameter(input);
00081 step = new TGo4AnalysisStep("Analysis",factory,mbsevent,store,proc);
00082 cout << "**** Analysis: Create mbs event server input " << input << endl;
00083 break;
00084 default:
00085 step = 0;
00086 break;
00087 }
00088
00089
00090
00091 factory->DefEventProcessor("XXXProc","TXXXProc");
00092 factory->DefOutputEvent("XXXEvent","TXXXEvent");
00093
00094 store->SetOverwriteMode(kTRUE);
00095
00096 step->SetSourceEnabled(kTRUE);
00097 step->SetStoreEnabled(enable);
00098 step->SetProcessEnabled(kTRUE);
00099 step->SetErrorStopEnabled(kTRUE);
00100
00101 AddAnalysisStep(step);
00102
00103
00104
00105
00107
00108
00109
00110 fPar = new TXXXParam("Par1");
00111 AddParameter(fPar);
00112 fCtl = new TXXXControl("Control");
00113 AddParameter(fCtl);
00114 }
00115
00116 TXXXAnalysis::~TXXXAnalysis()
00117 {
00118 cout << "**** TXXXAnalysis: Delete instance" << endl;
00119 }
00120
00121
00122 Int_t TXXXAnalysis::UserPreLoop()
00123 {
00124
00125 cout << "**** TXXXAnalysis: PreLoop" << endl;
00126
00127 fMbsEvent = dynamic_cast<TGo4MbsEvent*> (GetInputEvent("Analysis"));
00128 if(fMbsEvent)
00129 {
00130
00131 s_filhe* fileheader=fMbsEvent->GetMbsSourceHeader();
00132 if(fileheader)
00133 {
00134 cout <<"\nInput file: "<<fileheader->filhe_file << endl;
00135 cout <<"Tapelabel:\t" << fileheader->filhe_label<<endl;
00136 cout <<"UserName:\t" << fileheader->filhe_user<<endl;
00137 cout <<"RunID:\t" << fileheader->filhe_run<<endl;
00138 cout <<"Explanation: "<<fileheader->filhe_exp <<endl;
00139 cout <<"Comments: "<<endl;
00140 Int_t numlines=fileheader->filhe_lines;
00141 for(Int_t i=0; i<numlines;++i)
00142 {
00143 cout<<"\t"<<fileheader->s_strings[i].string << endl;
00144 }
00145 }
00146 }
00147 fEvents=0;
00148 fLastEvent=0;
00149 return 0;
00150 }
00151
00152 Int_t TXXXAnalysis::UserPostLoop()
00153 {
00154
00155 cout << "**** TXXXAnalysis: PostLoop" << endl;
00156 cout << "Last event #: " << fLastEvent << " Total events: " << fEvents << endl;
00157 fMbsEvent = 0;
00158 fEvents=0;
00159 return 0;
00160 }
00161
00162
00163 Int_t TXXXAnalysis::UserEventFunc()
00164 {
00165
00166
00167 if(fMbsEvent)
00168 {
00169 fEvents++;
00170 fLastEvent=fMbsEvent->GetCount();
00171 }
00172 if(fEvents == 1 || IsNewInputFile())
00173 {
00174 cout << "First event #: " << fLastEvent << endl;
00175 SetNewInputFile(kFALSE);
00176 }
00177 return 0;
00178 }
00179
00180