00001 // $Id: TGo4CompositeProcessor.cxx 999 2013-07-25 11:58:59Z linev $ 00002 //----------------------------------------------------------------------- 00003 // The GSI Online Offline Object Oriented (Go4) Project 00004 // Experiment Data Processing at EE department, GSI 00005 //----------------------------------------------------------------------- 00006 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH 00007 // Planckstr. 1, 64291 Darmstadt, Germany 00008 // Contact: http://go4.gsi.de 00009 //----------------------------------------------------------------------- 00010 // This software can be used under the license agreements as stated 00011 // in Go4License.txt file which is part of the distribution. 00012 //----------------------------------------------------------------------- 00013 00014 #include "TGo4CompositeProcessor.h" 00015 00016 #include "TGo4MbsEvent.h" 00017 #include "TGo4MbsSubEvent.h" 00018 00019 00020 TGo4CompositeProcessor::TGo4CompositeProcessor(): 00021 TGo4EventProcessor(), 00022 fMbsInput(0), 00023 fMbsTriggerNumber(0), 00024 fMbsEventNumber(0), 00025 fSubProcessors() 00026 { 00027 } // streamer dummy 00028 00029 00030 TGo4CompositeProcessor::TGo4CompositeProcessor(const char* name) : 00031 TGo4EventProcessor(name), 00032 fMbsInput(0), 00033 fMbsTriggerNumber(0), 00034 fMbsEventNumber(0), 00035 fSubProcessors() 00036 { 00037 } 00038 00039 TGo4CompositeProcessor::~TGo4CompositeProcessor() 00040 { 00041 fSubProcessors.Delete(); 00042 } 00043 00044 void TGo4CompositeProcessor::AddSubProcessor(TGo4EventProcessor* proc) 00045 { 00046 if (proc!=0) fSubProcessors.AddLast(proc); 00047 } 00048 00049 void TGo4CompositeProcessor::ProcessSubevent(TGo4MbsSubEvent* subevt) 00050 { 00051 //std::cout << "Dummy, should be reimplemented " << std::endl; // but must not if this is the top beamtime event JAM 00052 } 00053 00054 00055 Bool_t TGo4CompositeProcessor::BuildEvent(TGo4EventElement* outevnt) 00056 { 00057 // if there is no container event as output, subclass may run in standalone mode 00058 InitEvent(outevnt); // for plain subclass mode 00059 00060 // first need to call SetEvent of all subprocessors to set the input/output structures: 00061 00062 for (Int_t n=0;n<=fSubProcessors.GetLast();n++) { 00063 TGo4EventProcessor* proc = (TGo4EventProcessor*) fSubProcessors[n]; 00064 proc->SetInputEvent(GetInputEvent()); //forward input to subprocessors 00065 proc->InitEvent(outevnt); // subprocessors may set own eventpointers here 00066 } // while 00067 00068 // treat mbs input if we are in the first step: 00069 fMbsInput = dynamic_cast<TGo4MbsEvent*>(GetInputEvent()); 00070 00071 // printf("TGo4CompositeProcessor::BuildEvent this = %p name = %s evnt = %p \n", this, GetName(), fMbsInput); 00072 00073 if(fMbsInput) 00074 { 00075 // if(fMbsInput->GetTrigger() > 11) { 00076 // std::cout << "**** TGo4CompositeProcessor: Skip trigger event"<< std::endl; 00077 // return kFALSE; 00079 00080 fMbsTriggerNumber = fMbsInput->GetTrigger(); 00081 fMbsEventNumber = fMbsInput->GetCount(); 00082 00083 TGo4MbsSubEvent* psubevt = 0; 00084 fMbsInput->ResetIterator(); 00085 while((psubevt = fMbsInput->NextSubEvent()) != 0) 00086 { // loop over subevents 00087 ProcessSubevent(psubevt); // process in our own subclass, if implemented 00088 00089 for (Int_t n=0;n<=fSubProcessors.GetLast();n++) { 00090 00091 TGo4CompositeProcessor* subcomp = dynamic_cast<TGo4CompositeProcessor*> (fSubProcessors[n]); 00092 00093 if (subcomp) { 00094 subcomp->fMbsTriggerNumber = fMbsTriggerNumber; 00095 subcomp->fMbsEventNumber = fMbsEventNumber; 00096 subcomp->ProcessSubevent(psubevt); // actions implemented in component subclass 00097 } 00098 } // while proc 00099 } // whilesubevents 00100 } // mbs input 00101 00102 00103 // in any case, call finalize processing in all subclasses/components: 00104 // this is the way to implement actions in second step processors 00105 // for first step processors, this can be used to do actions after all subevents are done 00106 FinalizeEvent(); // process in our own subclass, if implemented 00107 00108 for (Int_t n=0;n<=fSubProcessors.GetLast();n++) { 00109 TGo4EventProcessor* proc = (TGo4EventProcessor*) fSubProcessors[n]; 00110 proc->FinalizeEvent(); // actions implemented in component subclass 00111 } // while proc 00112 00113 return kTRUE; 00114 } 00115