00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TGo4StepFactory.h"
00017
00018 #include <iostream.h>
00019
00020 #include "TROOT.h"
00021 #include "TString.h"
00022
00023
00024 TGo4StepFactory::TGo4StepFactory(const char* name): TGo4EventServerFactory(name)
00025 {
00026 cout << "GO4-***> Create factory " << name << " <GO4" << endl;
00027 strcpy(fnewInputEvent,"");
00028 strcpy(fnewOutputEvent,"");
00029 strcpy(fnewProcessor,"");
00030 strcpy(fInputEventName,"for MBS");
00031 strcpy(fOutputEventName,"");
00032 strcpy(fProcessorName,"");
00033 }
00034
00035
00036 TGo4StepFactory::TGo4StepFactory() : TGo4EventServerFactory("Event Fact")
00037 {
00038 cout << "**** Create factory " << endl;
00039 }
00040
00041
00042 TGo4StepFactory::~TGo4StepFactory()
00043 {
00044 cout << "**** Delete factory " << GetName() << endl;
00045 }
00046
00047
00048 void TGo4StepFactory::DefEventProcessor(const char* Pname, const char* Pclass)
00049 {
00050 if((3*strlen(Pname)+2*strlen(Pclass)+30) > sizeof(fnewProcessor))
00051 cout << "**** " << GetName() << ": ERROR! names too long: " << Pname << " or " << Pclass << endl;
00052 else{
00053 TString ptrname=Pname;
00054 ptrname.ReplaceAll(".",1,"x",1);
00055
00056 snprintf(fnewProcessor,_STEPFACTLEN_-1, "%s * %s = new %s(\"%s\");gROOT->Add(%s);",Pclass,ptrname.Data(),Pclass,Pname,ptrname.Data());
00057 strncpy(fProcessorName,Pname,_STEPFACTLEN_-1);
00058 strncpy(fProcessorClass,Pclass,_STEPFACTLEN_-1);
00059 }
00060 }
00061
00062
00063 TGo4EventProcessor * TGo4StepFactory::CreateEventProcessor(TGo4EventProcessorParameter* par)
00064 {
00065 TGo4EventProcessor * proc = 0;
00066
00067
00068
00069 cout << "**** " << GetName() << ": Create event processor " << fProcessorName << endl;
00070 if(strlen(fnewProcessor) == 0)cout << "No event processor was specified!" << endl;
00071 else {
00072
00073 gROOT->ProcessLine(fnewProcessor);
00074
00075 proc = (TGo4EventProcessor *)gROOT->FindObject(fProcessorName);
00076
00077 gROOT->RecursiveRemove(proc);
00078 }
00079 if(proc == 0) cout << "Cannot find event processor: " << fProcessorName << endl;
00080 return proc;
00081 }
00082
00083
00084 void TGo4StepFactory::DefOutputEvent(const char* Oname, const char* Oclass)
00085 {
00086 if((3*strlen(Oname)+2*strlen(Oclass)+30) > sizeof(fnewOutputEvent))
00087 cout << "**** " << GetName() << ": ERROR! names too long: " << Oname << " or " << Oclass << endl;
00088 else{
00089 snprintf(fnewOutputEvent,_STEPFACTLEN_-1,"%s * %s = new %s(\"%s\");gROOT->Add(%s);",Oclass,Oname,Oclass,Oname,Oname);
00090 strncpy(fOutputEventName,Oname,_STEPFACTLEN_-1);
00091 strncpy(fOutputEventClass,Oclass,_STEPFACTLEN_-1);
00092 }
00093 }
00094
00095
00096 TGo4EventElement * TGo4StepFactory::CreateOutputEvent()
00097 {
00098 TGo4EventElement * Oevent = 0;
00099
00100 cout << "**** " << GetName() << ": Create output event " << fOutputEventName << endl;
00101 if(strlen(fnewOutputEvent) == 0) cout << "No output event was specified!" << endl;
00102 else {
00103 gROOT->ProcessLine(fnewOutputEvent);
00104 Oevent = (TGo4EventElement *)gROOT->FindObject(fOutputEventName);
00105 gROOT->RecursiveRemove(Oevent);
00106 }
00107 if(Oevent == 0) cout << "Cannot find output event: " << fOutputEventName << endl;
00108 return Oevent;
00109 }
00110
00111
00112 void TGo4StepFactory::DefInputEvent(const char* Iname, const char* Iclass)
00113 {
00114 if((3*strlen(Iname)+2*strlen(Iclass)+30) > sizeof(fnewInputEvent))
00115 cout << "**** " << GetName() << ": ERROR! names too long: " << Iname << " or " << Iclass << endl;
00116 else{
00117 TString ptrname=Iname;
00118 ptrname.ReplaceAll(".",1,"x",1);
00119
00120 snprintf(fnewInputEvent,_STEPFACTLEN_-1,"%s * %s = new %s(\"%s\");gROOT->Add(%s);",Iclass,ptrname.Data(),Iclass,Iname,ptrname.Data());
00121 strncpy(fInputEventName,Iname,_STEPFACTLEN_-1);
00122 strncpy(fInputEventClass,Iclass,_STEPFACTLEN_-1);
00123 }
00124 }
00125
00126
00127 TGo4EventElement * TGo4StepFactory::CreateInputEvent()
00128 {
00129 TGo4EventElement * Ievent = 0;
00130
00131 cout << "**** " << GetName() << ": Create input event " << fInputEventName << endl;
00132 if(strlen(fnewInputEvent) == 0) return (TGo4EventElement *)TGo4EventServerFactory::CreateInputEvent();
00133 else {
00134 gROOT->ProcessLine(fnewInputEvent);
00135 Ievent = (TGo4EventElement *)gROOT->FindObject(fInputEventName);
00136 gROOT->RecursiveRemove(Ievent);
00137 }
00138 if(Ievent == 0) cout << "Cannot find input event: " << fInputEventName << endl;
00139 return Ievent;
00140 }
00141
00142
00143 ClassImp(TGo4StepFactory)
00144
00145