Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4EventServer/TGo4StepFactory.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE 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 <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;                // if processorname(eventname) matches tree subbranchname, we
00054     ptrname.ReplaceAll(".",1,"x",1); //  have to exchange dots in variable name. 
00055     //cout <<"DefEventProcessor has pointername: "<<ptrname.Data() << endl;
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   // par is the object specified as last argument creating the step in TAnalysis
00068   // only info we can get is an ID
00069   cout << "**** " << GetName() << ": Create event processor " << fProcessorName << endl;
00070   if(strlen(fnewProcessor) == 0)cout << "No event processor was specified!" << endl;
00071   else {
00072     // create event processor by macro
00073     gROOT->ProcessLine(fnewProcessor);
00074     // get pointer to event processor
00075     proc = (TGo4EventProcessor *)gROOT->FindObject(fProcessorName);
00076     // remove event processor from global ROOT (otherwise delete would crash)
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;                // if eventname matches tree subbranchname, we
00118     ptrname.ReplaceAll(".",1,"x",1); //  have to exchange dots in variable name. 
00119     //cout <<"DefInputEvent has pointername: "<<ptrname.Data() << endl;
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 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:55:54 2005 for Go4-v2.10-5 by doxygen1.2.15