GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4StepFactory.cxx
Go to the documentation of this file.
1// $Id$
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 fuer 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 "TGo4EventElement.h"
25
26//***********************************************************
32
33//***********************************************************
36{
37 TGo4Log::Debug("Create factory %s", name);
38 fnewInputEvent = "";
39 fnewOutputEvent = "";
40 fnewProcessor = "";
41 fInputEventName = "for MBS";
43 fProcessorName = "";
44}
45
46//***********************************************************
48{
49 TGo4Log::Debug("Delete factory %s", GetName());
50}
51
52//-----------------------------------------------------------
53void TGo4StepFactory::DefEventProcessor(const char *Pname, const char *Pclass)
54{
55 fnewProcessor.Form("new %s(\"%s\")", Pclass, Pname);
56 fProcessorName = Pname;
57}
58
59//-----------------------------------------------------------
61{
62 TGo4EventProcessor *proc = nullptr;
63
64 // par is the object specified as last argument creating the step in TAnalysis
65 // only info we can get is an ID
66 TGo4Log::Info("%s: Create event processor %s", GetName(), fProcessorName.Data());
67 if(fnewProcessor.IsNull())
68 TGo4Log::Error("No event processor was specified!");
69 else
70 // create event processor by macro
71 proc = (TGo4EventProcessor *) gROOT->ProcessLineFast(fnewProcessor.Data());
72 if(!proc)
73 TGo4Log::Error("Cannot create event processor: %s", fProcessorName.Data());
74 return proc;
75}
76
77//-----------------------------------------------------------
78void TGo4StepFactory::DefOutputEvent(const char *Oname, const char *Oclass)
79{
80 // need not to register object, because it is done by Go4 framework
81 fnewOutputEvent.Form("new %s(\"%s\")",Oclass,Oname);
82 fOutputEventName = Oname;
83}
84
85//-----------------------------------------------------------
87{
88 TGo4EventElement *event = nullptr;
89
90 TGo4Log::Info("%s: Create output event %s", GetName(), fOutputEventName.Data());
91
92 if(fnewOutputEvent.IsNull())
93 TGo4Log::Error("No output event was specified!");
94 else
95 event = (TGo4EventElement *) gROOT->ProcessLineFast(fnewOutputEvent.Data());
96 if(!event)
97 TGo4Log::Error("Cannot create output event: %s", fOutputEventName.Data());
98 return event;
99}
100
101//-----------------------------------------------------------
102void TGo4StepFactory::DefInputEvent(const char *Iname, const char *Iclass)
103{
104 fnewInputEvent.Form("new %s(\"%s\")", Iclass, Iname);
105 fInputEventName = Iname;
106}
107
108//-----------------------------------------------------------
110{
111 TGo4Log::Info("%s: Create input event %s", GetName(), fInputEventName.Data());
112
113 if(fnewInputEvent.IsNull())
115
116 TGo4EventElement *event = (TGo4EventElement *) gROOT->ProcessLineFast(fnewInputEvent.Data());
117 if(!event)
118 TGo4Log::Error("Cannot create input event: %s", fInputEventName.Data());
119 return event;
120}
121
122//-----------------------------------------------------------
124{
125 #ifdef _MSC_VER
126 const char *ptr_arg = "0x%x";
127 #else
128 const char *ptr_arg = "%p";
129 #endif
130
131 fnewEventSource.Form("new %s((%s*)%s)", Sclass, TGo4UserSourceParameter::Class()->GetName(), ptr_arg);
132}
133
134//-----------------------------------------------------------
136{
137 #ifdef _MSC_VER
138 const char *ptr_arg = "0x%x";
139 #else
140 const char *ptr_arg = "%p";
141 #endif
142
143 fnewEventStore.Form("new %s((%s*)%s)", Sclass, TGo4UserStoreParameter::Class()->GetName(), ptr_arg);
144}
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}
165
166//-----------------------------------------------------------
168{
169 if ((fnewEventStore.Length() > 0) && par->InheritsFrom(TGo4UserStoreParameter::Class())) {
170
171 TGo4Log::Info("%s: Create event store %s", GetName(), fnewEventStore.Data());
172
173 TString arg = TString::Format(fnewEventStore.Data(), par);
174
175 TGo4EventStore *store = (TGo4EventStore *) gROOT->ProcessLineFast(arg.Data());
176
177 if (store) return store;
178
179 TGo4Log::Error("Cannot create event store with cmd: %s", fnewEventStore.Data());
180 }
181
183}
The abstract base class for the data elements of which the unpacked events (or detector structure dat...
Basic type for all classes containing information to parametrize the event processor.
Abstract event processor.
TGo4EventStore * CreateEventStore(TGo4EventStoreParameter *par) override
TGo4EventElement * CreateInputEvent() override
TGo4EventSource * CreateEventSource(TGo4EventSourceParameter *par) override
Basic type for all classes containing information to parameterize the event source.
Basic type for all classes containing information to parametrize the event store.
The abstract interface class for the raw event store.
static void Info(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 1.
Definition TGo4Log.cxx:294
static void Debug(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 0.
Definition TGo4Log.cxx:281
static void Error(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 3.
Definition TGo4Log.cxx:320
TString fnewInputEvent
command to create new input event
virtual ~TGo4StepFactory()
destructor
void DefUserEventSource(const char *Sclass)
Configure class name for event source.
TGo4EventProcessor * CreateEventProcessor(TGo4EventProcessorParameter *par) override
Create event processor event.
TGo4EventElement * CreateOutputEvent() override
Create output event.
TString fnewProcessor
command to create new processor
TGo4StepFactory()
Default constructor.
TString fnewOutputEvent
command to create new output event
void DefEventProcessor(const char *Pname, const char *Pclass)
Configure name and class name for event processor.
void DefUserEventStore(const char *Sclass)
Configure class name for event store.
void DefInputEvent(const char *Iname, const char *Iclass)
Configure name and class name for input event.
TGo4EventStore * CreateEventStore(TGo4EventStoreParameter *par) override
Create event store.
TGo4EventElement * CreateInputEvent() override
Create input event.
TString fProcessorName
name for new processor
TGo4EventSource * CreateEventSource(TGo4EventSourceParameter *par) override
Create event source.
TString fnewEventSource
command to create new event source
TString fnewEventStore
command to create new event store
TString fInputEventName
name for new input event
void DefOutputEvent(const char *Oname, const char *Oclass)
Configure name and class name for output event.
TString fOutputEventName
name for new output event