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