Go to the documentation of this file.00001 #include "TSpadicAnalysis.h"
00002
00003 #include <stdlib.h>
00004
00005 #include "Go4EventServer.h"
00006 #include "TGo4StepFactory.h"
00007 #include "TGo4AnalysisStep.h"
00008 #include "TSpadicControl.h"
00009 #include "TGo4Version.h"
00010 #include "TGo4Log.h"
00011
00012
00013 TSpadicAnalysis::TSpadicAnalysis() :
00014 fMbsEvent(0),
00015 fEvents(0),
00016 fLastEvent(0)
00017 {
00018 }
00019
00020
00021
00022 TSpadicAnalysis::TSpadicAnalysis(int argc, char** argv) :
00023 TGo4Analysis(argc, argv),
00024 fMbsEvent(0),
00025 fEvents(0),
00026 fLastEvent(0)
00027 {
00028 TGo4Log::Info("Create TSpadicAnalysis name: %s", argv[0]);
00029
00030 if (!TGo4Version::CheckVersion(__GO4BUILDVERSION__)) {
00031 cout << "**** Go4 version mismatch" << endl;
00032 exit(-1);
00033 }
00034
00035 TGo4StepFactory* factory = new TGo4StepFactory("Factory");
00036 factory->DefEventProcessor("SpadicProc","TSpadicProc");
00037 factory->DefOutputEvent("SpadicEvent","TSpadicEvent");
00038
00039 Text_t lmdfile[512];
00040 sprintf(lmdfile,"%s/data/test.lmd",getenv("GO4SYS"));
00041
00042 TGo4EventSourceParameter* sourcepar = new TGo4MbsFileParameter(lmdfile);
00043
00044 TGo4FileStoreParameter* storepar = new TGo4FileStoreParameter(Form("%sOutput", argv[0]));
00045 storepar->SetOverwriteMode(kTRUE);
00046
00047 TGo4AnalysisStep* step = new TGo4AnalysisStep("Analysis", factory, sourcepar, storepar);
00048
00049 step->SetSourceEnabled(kTRUE);
00050 step->SetStoreEnabled(kFALSE);
00051 step->SetProcessEnabled(kTRUE);
00052 step->SetErrorStopEnabled(kTRUE);
00053
00054
00055
00056 AddAnalysisStep(step);
00057
00058
00059
00060
00061
00062 }
00063
00064
00065 TSpadicAnalysis::~TSpadicAnalysis()
00066 {
00067 TGo4Log::Info("TSpadicAnalysis: Delete instance");
00068 }
00069
00070
00071 Int_t TSpadicAnalysis::UserPreLoop()
00072 {
00073
00074 cout << "**** TSpadicAnalysis: PreLoop" << endl;
00075
00076 fMbsEvent = dynamic_cast<TGo4MbsEvent*> (GetInputEvent("Analysis"));
00077 if(fMbsEvent) {
00078
00079 s_filhe* fileheader=fMbsEvent->GetMbsSourceHeader();
00080 if(fileheader)
00081 {
00082 cout <<"\nInput file: "<<fileheader->filhe_file << endl;
00083 cout <<"Tapelabel:\t" << fileheader->filhe_label<<endl;
00084 cout <<"UserName:\t" << fileheader->filhe_user<<endl;
00085 cout <<"RunID:\t" << fileheader->filhe_run<<endl;
00086 cout <<"Explanation: "<<fileheader->filhe_exp <<endl;
00087 cout <<"Comments: "<<endl;
00088 Int_t numlines=fileheader->filhe_lines;
00089 for(Int_t i=0; i<numlines;++i)
00090 {
00091 cout<<"\t"<<fileheader->s_strings[i].string << endl;
00092 }
00093 }
00094 }
00095 fEvents=0;
00096 fLastEvent=0;
00097 return 0;
00098 }
00099
00100 Int_t TSpadicAnalysis::UserPostLoop()
00101 {
00102
00103 TGo4Log::Info("TSpadicAnalysis: PostLoop");
00104 TGo4Log::Info("Last event #: %d Total events: %d", fLastEvent, fEvents);
00105 fMbsEvent = 0;
00106 fEvents=0;
00107 return 0;
00108 }
00109
00110
00111 Int_t TSpadicAnalysis::UserEventFunc()
00112 {
00113
00114
00115 if(fMbsEvent) {
00116 fEvents++;
00117 fLastEvent=fMbsEvent->GetCount();
00118 }
00119 if(fEvents == 1 || IsNewInputFile()) {
00120 TGo4Log::Info("First event #: %d", fLastEvent);
00121 SetNewInputFile(kFALSE);
00122 }
00123 return 0;
00124 }