• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

onlinemonitor/framework/TCBMBeamtimeProc.cxx (r4864/r3805)

Go to the documentation of this file.
00001 #include "TCBMBeamtimeProc.h"
00002 
00003 #include "TGo4Log.h"
00004 #include "TSystem.h"
00005 #include "TROOT.h"
00006 
00007 TCBMBeamtimeProc::TCBMBeamtimeProc():
00008    TGo4EventProcessor(),
00009    fBeamtimeEvent(0),
00010    fMbsInput(0),
00011    fMbsTriggerNumber(0),
00012    fMbsEventNumber(0),
00013    fSubProcessors(0),
00014    fProcIterator(0)
00015 {
00016 } // streamer dummy
00017 
00018 
00019 TCBMBeamtimeProc::TCBMBeamtimeProc(const char* name) :
00020    TGo4EventProcessor(name),
00021    fBeamtimeEvent(0),
00022    fMbsInput(0),
00023    fMbsTriggerNumber(0),
00024    fMbsEventNumber(0),
00025    fSubProcessors(0),
00026    fProcIterator(0)
00027 {
00028    fSubProcessors = new TObjArray;
00029    fProcIterator = fSubProcessors->MakeIterator();
00030 }
00031 
00032 TCBMBeamtimeProc::~TCBMBeamtimeProc()
00033 {
00034 
00035    delete fProcIterator;
00036    if(fSubProcessors) fSubProcessors->Delete();
00037    delete fSubProcessors;
00038 
00039 }
00040 
00041 void TCBMBeamtimeProc::AddSubProcessor(TCBMBeamtimeProc* proc)
00042 {
00043    fSubProcessors->AddLast(proc);
00044 }
00045 
00046 void TCBMBeamtimeProc::ProcessSubevent(TGo4MbsSubEvent* subevt)
00047 {
00048    //cout << "Dummy, should be reimplemented " << endl; // but must not if this is the top beamtime event JAM
00049 }
00050 
00051 
00052 Bool_t TCBMBeamtimeProc::BuildEvent(TGo4EventElement* outevnt)
00053 {
00054    fBeamtimeEvent = dynamic_cast<TCBMBeamtimeEvent*>(outevnt);
00055    // if there is no container event as output, subclass may run in standalone mode
00056    InitEvent(outevnt); // for plain subclass mode
00057 
00058    // first need to call SetEvent of all subprocessors to set the input/output structures:
00059    fProcIterator->Reset();
00060    TCBMBeamtimeProc* proc=0;
00061    while((proc= dynamic_cast<TCBMBeamtimeProc*>( fProcIterator->Next() ) ) !=0)
00062    {
00063       proc->SetInputEvent(GetInputEvent()); //forward input to subprocessors
00064       proc->InitEvent(outevnt); // subprocessors may set own eventpointers here
00065    } // while
00066 
00067    // treat mbs input if we are in the first step:
00068    fMbsInput = dynamic_cast<TGo4MbsEvent*>(GetInputEvent());
00069 
00070 //   printf("TCBMBeamtimeProc::BuildEvent this = %p name = %s evnt = %p \n", this, GetName(), fMbsInput);
00071 
00072    if(fMbsInput)
00073    {
00074 //      if(fMbsInput->GetTrigger() > 11) {
00075 //         cout << "**** TCBMBeamtimeProc: Skip trigger event"<<endl;
00076 //         return kFALSE;
00078 
00079       fMbsTriggerNumber = fMbsInput->GetTrigger();
00080       fMbsEventNumber = fMbsInput->GetCount();
00081 
00082       TGo4MbsSubEvent* psubevt = 0;
00083       fMbsInput->ResetIterator();
00084       while((psubevt = fMbsInput->NextSubEvent()) != 0)
00085       { // loop over subevents
00086          ProcessSubevent(psubevt); // process in our own subclass, if implemented
00087          fProcIterator->Reset();
00088          while((proc = dynamic_cast<TCBMBeamtimeProc*>( fProcIterator->Next() ) ) !=0) {
00089             proc->fMbsTriggerNumber = fMbsTriggerNumber;
00090             proc->fMbsEventNumber = fMbsEventNumber;
00091 
00092             proc->ProcessSubevent(psubevt); // actions implemented in component subclass
00093          } // while proc
00094       } // whilesubevents
00095    } // mbs input
00096 
00097 
00098    // in any case, call finalize processing in all subclasses/components:
00099    // this is the way to implement actions in second step processors
00100    // for first step processors, this can be used to do actions after all subevents are done
00101    FinalizeEvent(); // process in our own subclass, if implemented
00102    fProcIterator->Reset();
00103    while((proc= dynamic_cast<TCBMBeamtimeProc*>( fProcIterator->Next() ) ) !=0)
00104       proc->FinalizeEvent(); // actions implemented in component subclass
00105 
00106 #if __GO4BUILDVERSION__ > 40500
00107    Bool_t keepinput(kFALSE), keepoutput(kFALSE);
00108 
00109    // then evaluate subprocessors if any:
00110    fProcIterator->Reset();
00111    Bool_t standalonemode=kTRUE;
00112    while((proc= dynamic_cast<TCBMBeamtimeProc*>( fProcIterator->Next() ) ) !=0)
00113    {
00114       standalonemode=kFALSE;
00115       if(proc->IsKeepInputEvent()) keepinput=kTRUE;
00116       if(proc->IsKeepOutputEvent()) keepoutput=kTRUE;
00117    } // while proc
00118    if(standalonemode)
00119       {
00120           // preserve subclass keep buffer states if running in standalone analysis:
00121             if(IsKeepInputEvent()) keepinput=kTRUE;
00122             if(IsKeepOutputEvent()) keepoutput=kTRUE;
00123       }
00124 
00125    //cout <<"   TCBMBeamtimeProc::BuildEvent - keepinput is " << keepinput<< endl;
00126    SetKeepInputEvent(keepinput);
00127    SetKeepOutputEvent(keepoutput);
00128    // if one subprocessor did keep the input or output event, all are informed about this:
00129    fProcIterator->Reset();
00130    while ((proc = dynamic_cast<TCBMBeamtimeProc*>(fProcIterator->Next()))!= 0) {
00131       proc->SetKeepInputEvent(keepinput);
00132       proc->SetKeepOutputEvent(keepoutput);
00133    }
00134 #endif
00135 
00136    return kTRUE;
00137 }
00138 
00139 #if __GO4BUILDVERSION__ < 40504
00140 
00141 // this is only for short time, with new go4 version method will be included in to framework
00142 Long_t TCBMBeamtimeProc::ExecuteScript(const char* script_name)
00143 {
00144    if (gSystem->AccessPathName(script_name)) {
00145       TGo4Log::Info("NO setup script %s found", script_name);
00146       return -1;
00147    }
00148 
00149    TGo4Log::Info("Executing setup script %s", script_name);
00150    return gROOT->ProcessLineSync(Form(".x %s", script_name));
00151 }
00152 
00153 #endif
00154 

Generated on Tue Dec 10 2013 04:52:23 for ROCsoft by  doxygen 1.7.1