Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TGo4StepFactory.cxx

Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //        Go4 Release Package v3.04-01 (build 30401)
00003 //                      28-November-2008
00004 //---------------------------------------------------------------
00005 //   The GSI Online Offline Object Oriented (Go4) Project
00006 //   Experiment Data Processing at EE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include "TGo4StepFactory.h"
00017 
00018 #include "Riostream.h"
00019 
00020 #include "TROOT.h"
00021 #include "TString.h"
00022 
00023 #include "TGo4EventProcessor.h"
00024 #include "TGo4EventElement.h"
00025 
00026 //***********************************************************
00027 TGo4StepFactory::TGo4StepFactory() :
00028    TGo4EventServerFactory(),
00029    fnewProcessor(),
00030    fProcessorName(),
00031    fnewOutputEvent(),
00032    fOutputEventName(),
00033    fnewInputEvent(),
00034    fInputEventName()
00035 {
00036   cout << "**** Create factory " << endl;
00037 }
00038 
00039 
00040 //***********************************************************
00041 TGo4StepFactory::TGo4StepFactory(const char* name) :
00042    TGo4EventServerFactory(name),
00043    fnewProcessor(),
00044    fProcessorName(),
00045    fnewOutputEvent(),
00046    fOutputEventName(),
00047    fnewInputEvent(),
00048    fInputEventName()
00049 {
00050   cout << "GO4-*> Create factory " << name << endl;
00051   fnewInputEvent = "";
00052   fnewOutputEvent = "";
00053   fnewProcessor = "";
00054   fInputEventName = "for MBS";
00055   fOutputEventName = "";
00056   fProcessorName = "";
00057 }
00058 
00059 //***********************************************************
00060 TGo4StepFactory::~TGo4StepFactory()
00061 {
00062   cout << "GO4-*> Delete factory " << GetName() << endl;
00063 }
00064 
00065 //-----------------------------------------------------------
00066 void TGo4StepFactory::DefEventProcessor(const char* Pname, const char* Pclass)
00067 {
00068   TString ptrname=Pname;   // if processorname(eventname) matches tree subbranchname, we
00069   ptrname.ReplaceAll(".",1,"x",1); //  have to exchange dots in variable name.
00070   //cout <<"DefEventProcessor has pointername: "<<ptrname.Data() << endl;
00071   fnewProcessor.Form("%s * %s = new %s(\"%s\");gROOT->Add(%s);",Pclass,ptrname.Data(),Pclass,Pname,ptrname.Data());
00072   fProcessorName = Pname;
00073 //    fProcessorClass = Pclass;
00074 }
00075 
00076 //-----------------------------------------------------------
00077 TGo4EventProcessor * TGo4StepFactory::CreateEventProcessor(TGo4EventProcessorParameter* par)
00078 {
00079   TGo4EventProcessor * proc = 0;
00080 
00081   // par is the object specified as last argument creating the step in TAnalysis
00082   // only info we can get is an ID
00083   cout << "**** " << GetName() << ": Create event processor " << fProcessorName << endl;
00084   if(fnewProcessor.Length() == 0)cout << "No event processor was specified!" << endl;
00085   else {
00086     // create event processor by macro
00087     gROOT->ProcessLine(fnewProcessor.Data());
00088     // get pointer to event processor
00089     proc = (TGo4EventProcessor *)gROOT->FindObject(fProcessorName.Data());
00090     // remove event processor from global ROOT (otherwise delete would crash)
00091     gROOT->RecursiveRemove(proc);
00092   }
00093   if(proc == 0) cout << "Cannot find event processor: " << fProcessorName << endl;
00094   return proc;
00095 }
00096 
00097 //-----------------------------------------------------------
00098 void TGo4StepFactory::DefOutputEvent(const char* Oname, const char* Oclass)
00099 {
00100    fnewOutputEvent.Form("%s * %s = new %s(\"%s\");gROOT->Add(%s);",Oclass,Oname,Oclass,Oname,Oname);
00101    fOutputEventName = Oname;
00102 // fOutputEventClass = Oclass;
00103 }
00104 
00105 //-----------------------------------------------------------
00106 TGo4EventElement * TGo4StepFactory::CreateOutputEvent()
00107 {
00108   TGo4EventElement * Oevent = 0;
00109 
00110   cout << "**** " << GetName() << ": Create output event " << fOutputEventName << endl;
00111   if(fnewOutputEvent.Length() == 0) cout << "No output event was specified!" << endl;
00112   else {
00113    gROOT->ProcessLine(fnewOutputEvent.Data());
00114    Oevent = (TGo4EventElement *)gROOT->FindObject(fOutputEventName.Data());
00115    gROOT->RecursiveRemove(Oevent);
00116   }
00117    if(Oevent == 0) cout << "Cannot find output event: " << fOutputEventName << endl;
00118    return Oevent;
00119 }
00120 
00121 //-----------------------------------------------------------
00122 void TGo4StepFactory::DefInputEvent(const char* Iname, const char* Iclass)
00123 {
00124    TString ptrname=Iname;    // if eventname matches tree subbranchname, we
00125    ptrname.ReplaceAll(".",1,"x",1); //  have to exchange dots in variable name.
00126    //cout <<"DefInputEvent has pointername: "<<ptrname.Data() << endl;
00127    fnewInputEvent.Form("%s * %s = new %s(\"%s\");gROOT->Add(%s);",Iclass,ptrname.Data(),Iclass,Iname,ptrname.Data());
00128    fInputEventName = Iname;
00129 //    fInputEventClass = Iclass;
00130 }
00131 
00132 //-----------------------------------------------------------
00133 TGo4EventElement * TGo4StepFactory::CreateInputEvent()
00134 {
00135   TGo4EventElement * Ievent = 0;
00136 
00137   cout << "**** " << GetName() << ": Create input event " << fInputEventName << endl;
00138   if(fnewInputEvent.Length() == 0) return (TGo4EventElement *)TGo4EventServerFactory::CreateInputEvent();
00139   else {
00140    gROOT->ProcessLine(fnewInputEvent.Data());
00141    Ievent = (TGo4EventElement *)gROOT->FindObject(fInputEventName.Data());
00142    gROOT->RecursiveRemove(Ievent);
00143   }
00144    if(Ievent == 0) cout << "Cannot find input event: " << fInputEventName << endl;
00145    return Ievent;
00146 }
00147 
00148 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:09 2008 for Go4-v3.04-1 by  doxygen 1.4.2