00001 #include "TCBMSecondProc.h" 00002 00003 #include "TGo4Log.h" 00004 #include "TH1.h" 00005 #include "TH2.h" 00006 #include "TObjArray.h" 00007 00008 #include "TGo4EventErrorException.h" 00009 00010 #include "TCBMEvent.h" 00011 #include "TCBMProc.h" 00012 00013 00014 TString TCBMSecondProc::fDfltSetupScript = "second.C"; 00015 00016 TCBMSecondProc* TCBMSecondProc::fInstance = 0; 00017 00018 00019 TCBMSecondProc::TCBMSecondProc(const char* name) : 00020 TGo4EventProcessor(name), 00021 fProc() 00022 { 00023 if (fInstance==0) fInstance = this; 00024 00025 TGo4Log::Info("Create TCBMSecondProc %s", name); 00026 00027 if (ExecuteScript(fDfltSetupScript.Data()) == -1) { 00028 TGo4Log::Error("Cannot setup second analysis step with %s script", fDfltSetupScript.Data()); 00029 throw TGo4EventErrorException(this); 00030 } 00031 } 00032 00033 TCBMSecondProc::~TCBMSecondProc() 00034 { 00035 // delete all processors 00036 fProc.Delete(); 00037 00038 if (fInstance==this) fInstance = 0; 00039 00040 TGo4Log::Info("Destroy TCBMSecondProc"); 00041 } 00042 00043 void TCBMSecondProc::AddProc(TCBMProc* proc) 00044 { 00045 if ((proc==0) || (fProc.FindObject(proc)!=0)) return; 00046 00047 fProc.Add(proc); 00048 } 00049 00050 00051 Bool_t TCBMSecondProc::BuildEvent(TGo4EventElement* outevnt) 00052 { 00053 // TGo4Log::Info("Start processing!!!"); 00054 00055 TCBMEvent* cbmev = (TCBMEvent*) GetInputEvent(); 00056 00057 if (cbmev==0) 00058 throw TGo4EventErrorException(this); 00059 00060 if (!cbmev->IsValid()) return kFALSE; 00061 00062 for (Int_t n=0; n<=fProc.GetLast(); n++) { 00063 TCBMProc* proc = (TCBMProc*) fProc[n]; 00064 proc->Process(cbmev); 00065 } 00066 00067 outevnt->SetValid(kFALSE); 00068 00069 return kFALSE; 00070 }