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"
33 using namespace lcio ;
40 class XMLFixCollTypes ;
42 typedef std::map<std::string, ProcessorParameter* > ProcParamMap ;
43 typedef std::map<std::string, std::string > LCIOTypeMap ;
128 virtual const std::string &
type()
const {
return _typeName ; }
132 virtual const std::string &
name()
const {
return _processorName ; }
136 virtual const std::string &
logLevelName()
const {
return _logLevelName ; }
141 virtual std::shared_ptr<StringParameters>
parameters() {
return _parameters ; }
146 virtual void printDescription() ;
150 virtual void printDescriptionXML(std::ostream& stream=std::cout) ;
159 if( streamlog::out.
template write<T>() ) {
162 typedef ProcParamMap::iterator PMI ;
164 streamlog::out() << std::endl
165 <<
"---- " << name() <<
" - parameters: " << std::endl ;
168 for( PMI i = _map.begin() ; i != _map.end() ; i ++ ) {
170 if( ! i->second->isOptional() || i->second->valueSet() ){
171 streamlog::out.template write<T>() ;
172 streamlog::out() <<
"\t" << i->second->name()
173 <<
": " << i->second->value()
178 streamlog::out.template write<T>() ;
179 streamlog::out() <<
"-------------------------------------------------"
187 void printParameters() ;
202 std::string getLCIOInType(
const std::string& colName ) ;
206 std::string getLCIOOutType(
const std::string& colName ) ;
212 bool isInputCollectionName(
const std::string& parameterName ) ;
216 bool isOutputCollectionName(
const std::string& parameterName ) ;
224 virtual void setParameters( std::shared_ptr<StringParameters> parameters) ;
227 virtual void setName(
const std::string & processorName) { _processorName = processorName ; }
235 void setReturnValue(
bool val) ;
241 void setReturnValue(
const std::string& name,
bool val ) ;
255 const std::string& parameterDescription,
259 checkForExistingParameter( parameterName );
261 parameter, defaultVal,
269 const std::string& parameterName,
270 const std::string& parameterDescription,
271 std::string& parameter,
272 const std::string& defaultVal,
275 setLCIOInType( parameterName , collectionType ) ;
276 registerProcessorParameter( parameterName, parameterDescription, parameter, defaultVal, setSize ) ;
283 const std::string& parameterName,
284 const std::string& parameterDescription,
285 std::string& parameter,
286 const std::string& defaultVal,
289 setLCIOOutType( parameterName , collectionType ) ;
290 registerProcessorParameter( parameterName, parameterDescription, parameter, defaultVal, setSize ) ;
297 const std::string& parameterName,
298 const std::string& parameterDescription,
299 StringVec& parameter,
300 const StringVec& defaultVal,
303 setLCIOInType( parameterName , collectionType ) ;
304 registerProcessorParameter( parameterName, parameterDescription, parameter, defaultVal, setSize ) ;
315 const std::string& parameterDescription,
320 checkForExistingParameter( parameterName );
322 parameter, defaultVal,
328 bool parameterSet(
const std::string& name ) ;
336 auto paraIt = _map.find( parameterName );
337 if (paraIt != _map.end() ) {
338 std::stringstream errorMessage;
339 errorMessage <<
"Parameter " << parameterName
340 <<
" already defined for processor "
343 throw std::logic_error( errorMessage.str() );
367 if( streamlog::out.
template write<T>() )
368 streamlog::out() << m << std::endl ;
389 inline void message(
const std::basic_ostream<
char, std::char_traits<char> >& m)
const {
394 const std::stringstream& mess =
dynamic_cast<const std::stringstream&
>( m ) ;
396 this->
template message<T>( mess.str() ) ;
399 catch( std::bad_cast ) {}
406 std::stringstream& log()
const ;
412 virtual void setProcessorParameters( std::shared_ptr<StringParameters> processorParameters) {
413 setParameters( processorParameters ) ;
417 virtual void updateParameters();
421 virtual void baseInit() ;
424 void setFirstEvent(
bool firstEvent ) { _isFirstEvent = firstEvent ; }
433 void setLCIOInType(
const std::string& colName,
const std::string& lcioInType) ;
440 void setLCIOOutType(
const std::string& collectionName,
const std::string& lcioOutType) ;
444 const ProcParamMap& procMap() {
return _map ; }
452 std::string _description=
"";
453 std::string _typeName=
"";
454 std::string _processorName=
"";
455 std::shared_ptr<StringParameters> _parameters{};
458 bool _isFirstEvent =
false;
459 LCIOTypeMap _inTypeMap{};
460 LCIOTypeMap _outTypeMap{};
462 std::string _logLevelName{};
465 mutable std::stringstream* _str=NULL;
virtual void check(LCEvent *)
Called for every event - right after processEvent() has been called for this processor.
Definition: Processor.h:116
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:389
void registerProcessorParameter(const std::string ¶meterName, const std::string ¶meterDescription, T ¶meter, const T &defaultVal, int setSize=0)
Register a steering variable for this processor - call in constructor of processor.
Definition: Processor.h:254
virtual void processRunHeader(LCRunHeader *)
Called for every run, e.g.
Definition: Processor.h:106
This singleton class contains an instance of every available marlin processor type.
Definition: CMProcessor.h:21
void registerOutputCollection(const std::string &collectionType, const std::string ¶meterName, const std::string ¶meterDescription, 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:282
void message(const std::string &m) 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:364
virtual const std::string & name() const
Return name of this processor.
Definition: Processor.h:132
void registerInputCollection(const std::string &collectionType, const std::string ¶meterName, const std::string ¶meterDescription, 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:268
virtual const std::string & type() const
Return type name for the processor (as set in constructor).
Definition: Processor.h:128
Templated implementation of ProcessorParameter - automatically created by Processor::registerProcesso...
Definition: ProcessorParameter.h:106
virtual void init()
Called at the begin of the job before anything is read.
Definition: Processor.h:101
void printParameters()
Print the parameters and their values depending on the given verbosity level.
Definition: Processor.h:156
virtual std::shared_ptr< StringParameters > parameters()
Return parameters defined for this Processor.
Definition: Processor.h:141
void registerOptionalParameter(const std::string ¶meterName, const std::string ¶meterDescription, T ¶meter, const T &defaultVal, int setSize=0)
Same as registerProcessorParameter except that the parameter is optional.
Definition: Processor.h:314
const std::string & description()
Description of processor.
Definition: Processor.h:193
void registerInputCollections(const std::string &collectionType, const std::string ¶meterName, const std::string ¶meterDescription, StringVec ¶meter, const StringVec &defaultVal, int setSize=0)
Specialization of registerProcessorParameter() for a parameter that defines one or several input coll...
Definition: Processor.h:296
virtual void setName(const std::string &processorName)
Set processor name.
Definition: Processor.h:227
virtual const std::string & logLevelName() const
Return name of the local verbosity level of this processor - "" if not set.
Definition: Processor.h:136
bool isFirstEvent()
True if first event in processEvent(evt) - use this e.g.
Definition: Processor.h:198
Processor manager singleton class.
Definition: ProcessorMgr.h:36
void checkForExistingParameter(const std::string ¶meterName)
Tests whether the parameter has been registered before.
Definition: Processor.h:335
virtual void processEvent(LCEvent *)
Called for every event - the working horse.
Definition: Processor.h:110
Base class for Marlin processors.
Definition: Processor.h:64
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:123