GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4StepFactory.cxx
Go to the documentation of this file.
1 // $Id: TGo4StepFactory.cxx 930 2013-01-24 16:10:10Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4StepFactory.h"
15 
16 #include "TClass.h"
17 #include "TROOT.h"
18 #include "TString.h"
19 
20 #include "TGo4Log.h"
21 #include "TGo4EventProcessor.h"
22 #include "TGo4EventElement.h"
25 
26 //***********************************************************
29  fnewProcessor(),
30  fProcessorName(),
31  fnewOutputEvent(),
32  fOutputEventName(),
33  fnewInputEvent(),
34  fInputEventName(),
35  fnewEventSource()
36 {
37  TGo4Log::Debug("Create factory");
38 }
39 
40 //***********************************************************
43  fnewProcessor(),
44  fProcessorName(),
45  fnewOutputEvent(),
46  fOutputEventName(),
47  fnewInputEvent(),
48  fInputEventName()
49 {
50  TGo4Log::Debug("Create factory %s", name);
51  fnewInputEvent = "";
52  fnewOutputEvent = "";
53  fnewProcessor = "";
54  fInputEventName = "for MBS";
55  fOutputEventName = "";
56  fProcessorName = "";
57 }
58 
59 //***********************************************************
61 {
62  TGo4Log::Debug("Delete factory %s", GetName());
63 }
64 
65 //-----------------------------------------------------------
66 void TGo4StepFactory::DefEventProcessor(const char* Pname, const char* Pclass)
67 {
68  fnewProcessor.Form("new %s(\"%s\")", Pclass, Pname);
69  fProcessorName = Pname;
70 }
71 
72 //-----------------------------------------------------------
74 {
75  TGo4EventProcessor * proc = 0;
76 
77  // par is the object specified as last argument creating the step in TAnalysis
78  // only info we can get is an ID
79  TGo4Log::Info("%s: Create event processor %s", GetName(), fProcessorName.Data());
80  if(fnewProcessor.Length() == 0)
81  TGo4Log::Error("No event processor was specified!");
82  else
83  // create event processor by macro
84  proc = (TGo4EventProcessor*) gROOT->ProcessLineFast(fnewProcessor.Data());
85  if(proc == 0)
86  TGo4Log::Error("Cannot create event processor: %s", fProcessorName.Data());
87  return proc;
88 }
89 
90 //-----------------------------------------------------------
91 void TGo4StepFactory::DefOutputEvent(const char* Oname, const char* Oclass)
92 {
93  // need not to register object, because it is done by Go4 framework
94  fnewOutputEvent.Form("new %s(\"%s\")",Oclass,Oname);
95  fOutputEventName = Oname;
96 }
97 
98 //-----------------------------------------------------------
100 {
101  TGo4EventElement * Oevent = 0;
102 
103  TGo4Log::Info("%s: Create output event %s", GetName(), fOutputEventName.Data());
104 
105  if(fnewOutputEvent.Length() == 0)
106  TGo4Log::Error("No output event was specified!");
107  else
108  Oevent = (TGo4EventElement*) gROOT->ProcessLineFast(fnewOutputEvent.Data());
109  if(Oevent == 0)
110  TGo4Log::Error("Cannot create output event: %s", fOutputEventName.Data());
111  return Oevent;
112 }
113 
114 //-----------------------------------------------------------
115 void TGo4StepFactory::DefInputEvent(const char* Iname, const char* Iclass)
116 {
117  fnewInputEvent.Form("new %s(\"%s\")", Iclass, Iname);
118  fInputEventName = Iname;
119 }
120 
121 //-----------------------------------------------------------
123 {
124  TGo4Log::Info("%s: Create input event %s", GetName(), fInputEventName.Data());
125 
126  if(fnewInputEvent.Length() == 0)
128 
129  TGo4EventElement* Ievent = (TGo4EventElement*) gROOT->ProcessLineFast(fnewInputEvent.Data());
130  if(Ievent == 0)
131  TGo4Log::Error("Cannot create input event: %s", fInputEventName.Data());
132  return Ievent;
133 }
134 
135 //-----------------------------------------------------------
136 void TGo4StepFactory::DefUserEventSource(const char* Sclass)
137 {
138  #ifdef WIN32
139  const char* ptr_arg = "0x%x";
140  #else
141  const char* ptr_arg = "%p";
142  #endif
143 
144  fnewEventSource.Form("new %s((%s*)%s)", Sclass, TGo4UserSourceParameter::Class()->GetName(), ptr_arg);
145 }
146 
147 //-----------------------------------------------------------
149 {
150  if ((fnewEventSource.Length()>0) && par->InheritsFrom(TGo4UserSourceParameter::Class())) {
151 
152  TGo4Log::Info("%s: Create input source %s", GetName(), fnewEventSource.Data());
153 
154  TString arg = TString::Format(fnewEventSource.Data(), par);
155 
156  TGo4EventSource* source = (TGo4EventSource*) gROOT->ProcessLineFast(arg.Data());
157 
158  if (source) return source;
159 
160  TGo4Log::Error("Cannot create event source with cmd: %s", fnewEventSource.Data());
161  }
162 
164 }
virtual TGo4EventSource * CreateEventSource(TGo4EventSourceParameter *par)
virtual TGo4EventElement * CreateInputEvent()
virtual TGo4EventSource * CreateEventSource(TGo4EventSourceParameter *par)
void DefUserEventSource(const char *Sclass)
TString fOutputEventName
void DefEventProcessor(const char *Pname, const char *Pclass)
virtual TGo4EventElement * CreateOutputEvent()
void DefOutputEvent(const char *Oname, const char *Oclass)
TString fProcessorName
TString fnewEventSource
TString fnewOutputEvent
virtual TGo4EventProcessor * CreateEventProcessor(TGo4EventProcessorParameter *par)
TString fInputEventName
virtual ~TGo4StepFactory()
void DefInputEvent(const char *Iname, const char *Iclass)
TString fnewInputEvent
virtual TGo4EventElement * CreateInputEvent()
static void Error(const char *text,...)
Definition: TGo4Log.cxx:309
static void Info(const char *text,...)
Definition: TGo4Log.cxx:283
static void Debug(const char *text,...)
Definition: TGo4Log.cxx:270