6 #include "IO/LCRunListener.h"
7 #include "IO/LCEventListener.h"
8 #include "IO/LCReader.h"
10 #include "EVENT/LCEvent.h"
11 #include "EVENT/LCRunHeader.h"
13 #include "StringParameters.h"
14 #include "ProcessorParameter.h"
16 #include "marlin/VerbosityLevels.h"
19 #include "marlin/MarlinConfig.h"
21 #include "streamlog/streamlog.h"
32 using namespace lcio ;
39 class XMLFixCollTypes ;
41 typedef std::map<std::string, ProcessorParameter* > ProcParamMap ;
42 typedef std::map<std::string, std::string > LCIOTypeMap ;
127 virtual const std::string &
type()
const {
return _typeName ; }
131 virtual const std::string &
name()
const {
return _processorName ; }
135 virtual const std::string &
logLevelName()
const {
return _logLevelName ; }
145 virtual void printDescription() ;
149 virtual void printDescriptionXML(std::ostream& stream=std::cout) ;
158 if( streamlog::out.
template write<T>() ) {
161 typedef ProcParamMap::iterator PMI ;
163 streamlog::out() << std::endl
164 <<
"---- " << name() <<
" - parameters: " << std::endl ;
167 for( PMI i = _map.begin() ; i != _map.end() ; i ++ ) {
169 if( ! i->second->isOptional() || i->second->valueSet() ){
170 streamlog::out.template write<T>() ;
171 streamlog::out() <<
"\t" << i->second->name()
172 <<
": " << i->second->value()
177 streamlog::out.template write<T>() ;
178 streamlog::out() <<
"-------------------------------------------------"
186 void printParameters() ;
201 std::string getLCIOInType(
const std::string& colName ) ;
205 std::string getLCIOOutType(
const std::string& colName ) ;
211 bool isInputCollectionName(
const std::string& parameterName ) ;
215 bool isOutputCollectionName(
const std::string& parameterName ) ;
228 void setReturnValue(
bool val) ;
234 void setReturnValue(
const std::string& name,
bool val ) ;
248 const std::string& description,
254 parameter, defaultVal,
262 const std::string& name,
263 const std::string& description,
264 std::string& parameter,
265 const std::string& defaultVal,
268 setLCIOInType( name , type ) ;
269 registerProcessorParameter( name, description, parameter, defaultVal, setSize ) ;
276 const std::string& name,
277 const std::string& description,
278 std::string& parameter,
279 const std::string& defaultVal,
282 setLCIOOutType( name , type ) ;
283 registerProcessorParameter( name, description, parameter, defaultVal, setSize ) ;
290 const std::string& name,
291 const std::string& description,
292 StringVec& parameter,
293 const StringVec& defaultVal,
296 setLCIOInType( name , type ) ;
297 registerProcessorParameter( name, description, parameter, defaultVal, setSize ) ;
308 const std::string& description,
314 parameter, defaultVal,
320 bool parameterSet(
const std::string& name ) ;
341 void message(
const std::string& message )
const {
344 if( streamlog::out.
template write<T>() )
345 streamlog::out() << message << std::endl ;
366 inline void message(
const std::basic_ostream<
char, std::char_traits<char> >& m)
const {
371 const std::stringstream& mess =
dynamic_cast<const std::stringstream&
>( m ) ;
373 this->
template message<T>( mess.str() ) ;
376 catch( std::bad_cast ) {}
383 std::stringstream& log()
const ;
390 setParameters( parameters ) ;
394 virtual void updateParameters();
397 virtual void setName(
const std::string & name) { _processorName = name ; }
400 virtual void setParameters( StringParameters* parameters) ;
404 virtual void baseInit() ;
407 void setFirstEvent(
bool isFirstEvent ) { _isFirstEvent = isFirstEvent ; }
416 void setLCIOInType(
const std::string& colName,
const std::string& lcioInType) ;
423 void setLCIOOutType(
const std::string& collectionName,
const std::string& lcioOutType) ;
427 const ProcParamMap& procMap() {
return _map ; }
436 std::string _typeName ;
437 std::string _processorName ;
442 LCIOTypeMap _inTypeMap ;
443 LCIOTypeMap _outTypeMap ;
445 std::string _logLevelName ;
448 mutable std::stringstream* _str ;
virtual void check(LCEvent *)
Called for every event - right after processEvent() has been called for this processor.
Definition: Processor.h:115
void message(const std::basic_ostream< char, std::char_traits< char > > &m) const
Same as message(const std::string& message) except that it allows the output of more complex messages...
Definition: Processor.h:366
virtual void processRunHeader(LCRunHeader *)
Called for every run, e.g.
Definition: Processor.h:105
virtual StringParameters * parameters()
Return parameters defined for this Processor.
Definition: Processor.h:140
This singleton class contains an instance of every available marlin processor type.
Definition: CMProcessor.h:21
void registerOptionalParameter(const std::string &name, const std::string &description, T ¶meter, const T &defaultVal, int setSize=0)
Same as registerProcessorParameter except that the parameter is optional.
Definition: Processor.h:307
virtual const std::string & name() const
Return name of this processor.
Definition: Processor.h:131
virtual const std::string & type() const
Return type name for the processor (as set in constructor).
Definition: Processor.h:127
Templated implementation of ProcessorParameter - automatically created by Processor::registerProcesso...
Definition: ProcessorParameter.h:104
void registerProcessorParameter(const std::string &name, const std::string &description, T ¶meter, const T &defaultVal, int setSize=0)
Register a steering variable for this processor - call in constructor of processor.
Definition: Processor.h:247
virtual void init()
Called at the begin of the job before anything is read.
Definition: Processor.h:100
void printParameters()
Print the parameters and their values depending on the given verbosity level.
Definition: Processor.h:155
void message(const std::string &message) const
Print message according to verbosity level of the templated parameter (one of DEBUG, MESSAGE, WARNING, ERROR ) and the global parameter "Verbosity".
Definition: Processor.h:341
const std::string & description()
Description of processor.
Definition: Processor.h:192
void registerInputCollection(const std::string &type, const std::string &name, const std::string &description, std::string ¶meter, const std::string &defaultVal, int setSize=0)
Specialization of registerProcessorParameter() for a parameter that defines an input collection - can...
Definition: Processor.h:261
virtual const std::string & logLevelName() const
Return name of the local verbosity level of this processor - "" if not set.
Definition: Processor.h:135
bool isFirstEvent()
True if first event in processEvent(evt) - use this e.g.
Definition: Processor.h:197
Processor manager singleton class.
Definition: ProcessorMgr.h:36
virtual void processEvent(LCEvent *)
Called for every event - the working horse.
Definition: Processor.h:109
Base class for Marlin processors.
Definition: Processor.h:63
void registerOutputCollection(const std::string &type, const std::string &name, const std::string &description, std::string ¶meter, const std::string &defaultVal, int setSize=0)
Specialization of registerProcessorParameter() for a parameter that defines an output collection - ca...
Definition: Processor.h:275
void registerInputCollections(const std::string &type, const std::string &name, const std::string &description, StringVec ¶meter, const StringVec &defaultVal, int setSize=0)
Specialization of registerProcessorParameter() for a parameter that defines one or several input coll...
Definition: Processor.h:289
std::string _description
Describes what the processor does.
Definition: Processor.h:435
Simple parameters class for Marlin.
Definition: StringParameters.h:34
Internal helper class that creates a new xml steering file with the parameter attributes lcioInType a...
Definition: XMLFixCollTypes.h:25
virtual void end()
Called after data processing for clean up in the inverse order of the init() method so that resources...
Definition: Processor.h:122