#include "TVupromQFWAnalysis.h" #include #include "Riostream.h" #include "Go4EventServer.h" #include "TGo4StepFactory.h" #include "TGo4AnalysisStep.h" #include "TGo4Version.h" //*********************************************************** TVupromQFWAnalysis::TVupromQFWAnalysis() : fMbsEvent(0), fCtl(0), fEvents(0), fLastEvent(0) { } //*********************************************************** // this constructor is called by go4analysis executable TVupromQFWAnalysis::TVupromQFWAnalysis(int argc, char** argv) : TGo4Analysis(argc, argv), fMbsEvent(0), fCtl(0), fEvents(0), fLastEvent(0) { cout << "**** Create TVupromQFWAnalysis name: " << argv[0] << endl; if (!TGo4Version::CheckVersion(__GO4BUILDVERSION__)) { cout << "**** Go4 version mismatch" << endl; exit(-1); } TGo4StepFactory* factory = new TGo4StepFactory("Factory"); factory->DefEventProcessor("VupromQFWProc","TVupromQFWProc");// object name, class name factory->DefOutputEvent("VupromQFWEvent","TVupromQFWEvent"); // object name, class name Text_t lmdfile[512]; // source file sprintf(lmdfile,"%s/data/test.lmd",getenv("GO4SYS")); // TGo4EventSourceParameter* sourcepar = new TGo4MbsTransportParameter("r3b"); TGo4EventSourceParameter* sourcepar = new TGo4MbsFileParameter(lmdfile); TGo4FileStoreParameter* storepar = new TGo4FileStoreParameter(Form("%sOutput", argv[0])); storepar->SetOverwriteMode(kTRUE); TGo4AnalysisStep* step = new TGo4AnalysisStep("Analysis", factory, sourcepar, storepar); step->SetSourceEnabled(kTRUE); step->SetStoreEnabled(kFALSE); step->SetProcessEnabled(kTRUE); step->SetErrorStopEnabled(kTRUE); // Now the first analysis step is set up. // Other steps could be created here AddAnalysisStep(step); // uncomment following line to define custom passwords for analysis server // DefineServerPasswords("VupromQFWadmin", "VupromQFWctrl", "VupromQFWview"); } //*********************************************************** TVupromQFWAnalysis::~TVupromQFWAnalysis() { cout << "**** TVupromQFWAnalysis: Delete instance" << endl; } //----------------------------------------------------------- Int_t TVupromQFWAnalysis::UserPreLoop() { // all this is optional: cout << "**** TVupromQFWAnalysis: PreLoop" << endl; // get pointer to input event (used in postloop and event function): fMbsEvent = dynamic_cast (GetInputEvent("Analysis")); // of step "Analysis" if(fMbsEvent) { // fileheader structure (lmd file only): s_filhe* fileheader=fMbsEvent->GetMbsSourceHeader(); if(fileheader) { cout <<"\nInput file: "<filhe_file << endl; cout <<"Tapelabel:\t" << fileheader->filhe_label<filhe_user<filhe_run<filhe_exp <filhe_lines; for(Int_t i=0; is_strings[i].string << endl; } } } fEvents=0; // event counter fLastEvent=0; // number of last event processed return 0; } //----------------------------------------------------------- Int_t TVupromQFWAnalysis::UserPostLoop() { // all this is optional: cout << "**** TVupromQFWAnalysis: PostLoop" << endl; cout << "Last event #: " << fLastEvent << " Total events: " << fEvents << endl; fMbsEvent = 0; // reset to avoid invalid pointer if analysis is changed in between fEvents=0; return 0; } //----------------------------------------------------------- Int_t TVupromQFWAnalysis::UserEventFunc() { // all this is optional: // This function is called once for each event after all steps. if(fMbsEvent) { fEvents++; fLastEvent=fMbsEvent->GetCount(); } if(fEvents == 1 || IsNewInputFile()) { cout << "First event #: " << fLastEvent << endl; SetNewInputFile(kFALSE); // we have to reset the newfile flag } return 0; }