00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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;
00069 ptrname.ReplaceAll(".",1,"x",1);
00070
00071 fnewProcessor.Form("%s * %s = new %s(\"%s\");gROOT->Add(%s);",Pclass,ptrname.Data(),Pclass,Pname,ptrname.Data());
00072 fProcessorName = Pname;
00073
00074 }
00075
00076
00077 TGo4EventProcessor * TGo4StepFactory::CreateEventProcessor(TGo4EventProcessorParameter* par)
00078 {
00079 TGo4EventProcessor * proc = 0;
00080
00081
00082
00083 cout << "**** " << GetName() << ": Create event processor " << fProcessorName << endl;
00084 if(fnewProcessor.Length() == 0)cout << "No event processor was specified!" << endl;
00085 else {
00086
00087 gROOT->ProcessLine(fnewProcessor.Data());
00088
00089 proc = (TGo4EventProcessor *)gROOT->FindObject(fProcessorName.Data());
00090
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
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;
00125 ptrname.ReplaceAll(".",1,"x",1);
00126
00127 fnewInputEvent.Form("%s * %s = new %s(\"%s\");gROOT->Add(%s);",Iclass,ptrname.Data(),Iclass,Iname,ptrname.Data());
00128 fInputEventName = Iname;
00129
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