14 #include "streamlog/streamlog.h"
15 #include "streamlog/logbuffer.h"
31 bool operator()(
const TimeMap::value_type& v1,
const TimeMap::value_type& v2 ) {
33 return v1.second.first > v2.second.first ;
39 StopProcessingException::message = m ;
54 sstr <<
" ProcessorMgr::instance: Global::EVENTSEEDER pointer not NULL" <<
std::endl ;
55 throw Exception( sstr.
str() );
87 _map[ name ] = processor ;
93 for( ProcessorList::iterator it =
_list.
begin() ;
107 typedef ProcessorMap::iterator MI ;
111 <<
" # Example steering file for marlin #" <<
std::endl
113 <<
" ##########################################" <<
std::endl
116 std::cout <<
".begin Global ---------------------------------------" << std::endl
117 <<
" LCIOInputFiles simjob.slcio " << std::endl
119 <<
" # the active processors that are called in the given order" << std::endl
120 <<
" ActiveProcessors MyAIDAProcessor" << std::endl
121 <<
" ActiveProcessors MyTestProcessor" << std::endl
122 <<
" ActiveProcessors MyLCIOOutputProcessor" << std::endl
124 <<
" # limit the number of processed records (run+evt):" << std::endl
125 <<
" MaxRecordNumber 5001" << std::endl
127 <<
" # skip the first n events " << std::endl
128 <<
" SkipNEvents 0 " << std::endl
129 <<
" # don't call the check method of the processors if \"true\"" << std::endl
130 <<
" SupressCheck false" << std::endl
131 <<
".end -----------------------------------------------" << std::endl
137 i->second->printDescription() ;
142 typedef ProcessorMap::iterator MI ;
146 <<
" # Example steering file for marlin #" <<
std::endl
148 <<
" ##########################################-->" <<
std::endl
152 <<
"<marlin xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
153 <<
"xsi:noNamespaceSchemaLocation=\"http://ilcsoft.desy.de/marlin/marlin.xsd\">"
157 <<
" <!-- define constants here - use in steering file as ${ConstantName} --> " << std::endl
158 <<
" <!--constant name=\"DetectorModel\" value=\"ILD_l5_o1_v02\" /-->" << std::endl
159 <<
" </constants>" << std::endl
163 <<
" <!--processor name=\"MyEventSelector\"/--> " << std::endl
164 <<
" <!--if condition=\"MyEventSelector\"--> " << std::endl
165 <<
" <processor name=\"MyAIDAProcessor\"/>" << std::endl
166 <<
" <processor name=\"MyTestProcessor\"/> " << std::endl
167 <<
" <processor name=\"MyLCIOOutputProcessor\"/> " << std::endl
168 <<
" <!--/if--> " << std::endl
169 <<
" </execute>" << std::endl
173 <<
" <parameter name=\"LCIOInputFiles\"> simjob.slcio </parameter>" << std::endl
174 <<
" <!-- limit the number of processed records (run+evt): --> " << std::endl
175 <<
" <parameter name=\"MaxRecordNumber\" value=\"5001\" /> " << std::endl
176 <<
" <parameter name=\"SkipNEvents\" value=\"0\" /> " << std::endl
177 <<
" <parameter name=\"SupressCheck\" value=\"false\" /> " << std::endl
178 <<
" <parameter name=\"AllowToModifyEvent\" value=\"false\" /> " << std::endl
179 <<
" <parameter name=\"GearXMLFile\"></parameter> " << std::endl
180 <<
" <parameter name=\"Verbosity\" options=\"DEBUG0-4,MESSAGE0-4,WARNING0-4,ERROR0-4,SILENT\"> DEBUG </parameter> " << std::endl
181 <<
" <parameter name=\"RandomSeed\" value=\"1234567890\" />" << std::endl
182 <<
" <!-- optionally limit the collections that are read from the input file: --> " << std::endl
183 <<
" <!--parameter name=\"LCIOReadCollectionNames\">MCParticle PandoraPFOs</parameter-->" << std::endl
184 <<
" </global>" << std::endl
188 i->second->printDescriptionXML() ;
208 return _map[ type ] ;
233 if( processor == 0 ) {
235 sstr <<
" ProcessorMgr::registerProcessor: unknown processor with type " << processorType <<
" ! " <<
std::endl ;
236 throw Exception( sstr.
str() );
242 std::cerr <<
" ProcessorMgr::addActiveProcessor: processor " << processorName
243 <<
" already registered ! "
250 newProcessor->
setName( processorName ) ;
255 if( parameters != 0 ){
270 streamlog::logbuffer* lb =
new streamlog::logbuffer(
std::cout.rdbuf() , &
my_cout ) ;
277 streamlog::logscope scope( streamlog::out ) ; scope.setName( (*it)->name() ) ;
278 scope.setLevel( (*it)->logLevelName() ) ;
280 streamlog::logscope scope1(
my_cout ) ; scope1.setName( (*it)->name() ) ;
293 streamlog_out( WARNING4 ) <<
" ----------- " <<
std::endl
294 <<
" the following processor will modify the LCIO event : "
312 bool doConsistencyCheck = true ;
319 catch( gear::UnknownParameterException ){
321 doConsistencyCheck = false ;
326 if( doConsistencyCheck && lcioDetName != gearDetName ) {
341 streamlog_out(WARNING) <<
" ============================================================= " <<
std::endl ;
342 streamlog_out(WARNING) <<
" ProcessorMgr::processRunHeader : inconsistent detector models : " <<
std::endl ;
343 streamlog_out(WARNING) <<
" in lcio : " << lcioDetName <<
" <=> in gear file : " << gearDetName <<
std::endl ;
344 streamlog_out(WARNING) <<
" ============================================================= " <<
std::endl ;
354 streamlog::logscope scope( streamlog::out ) ; scope.setName( (*it)->name() ) ;
355 scope.setLevel( (*it)->logLevelName() ) ;
357 streamlog::logscope scope1(
my_cout ) ; scope1.setName( (*it)->name() ) ;
359 (*it)->processRunHeader( run ) ;
368 streamlog::logscope scope( streamlog::out ) ; scope.setName( (*it)->name() ) ;
370 scope.setLevel( (*it)->logLevelName() ) ;
373 streamlog::logscope scope1(
my_cout ) ; scope1.setName( (*it)->name() ) ;
393 streamlog::logscope scope( streamlog::out ) ; scope.setName( (*it)->name() ) ;
395 scope.setLevel( (*it)->logLevelName() ) ;
398 streamlog::logscope scope1(
my_cout ) ; scope1.setName( (*it)->name() ) ;
406 TimeMap::iterator itT =
tMap.
find( *it );
430 streamlog::logscope scope( streamlog::out ) ; scope.setName( (*it)->name() ) ;
432 scope.setLevel( (*it)->logLevelName() ) ;
434 streamlog::logscope scope1(
my_cout ) ; scope1.setName( (*it)->name() ) ;
438 (*it)->processEvent( evt ) ;
440 if( check ) (*it)->check( evt ) ;
445 TimeMap::iterator itT =
tMap.
find( *it ) ;
448 itT->second.second ++ ;
451 (*it)->setFirstEvent(
false ) ;
486 streamlog::logscope scope( streamlog::out ) ; scope.setName( (*it)->name() ) ;
488 scope.setLevel( (*it)->logLevelName() ) ;
490 streamlog::logscope scope1(
my_cout ) ; scope1.setName( (*it)->name() ) ;
494 (*it)->processEvent( evt ) ;
496 if( check ) (*it)->check( evt ) ;
501 TimeMap::iterator itT =
tMap.
find( *it ) ;
504 itT->second.second ++ ;
507 (*it)->setFirstEvent(
false ) ;
537 streamlog::logscope scope( streamlog::out ) ; scope.setName( (*it)->name() ) ;
538 scope.setLevel( (*it)->logLevelName() ) ;
540 streamlog::logscope scope1(
my_cout ) ; scope1.setName( (*it)->name() ) ;
545 streamlog_out(MESSAGE) <<
" --------------------------------------------------------- " <<
std::endl
546 <<
" Events skipped by processors : " <<
std::endl ;
548 unsigned nSkipped = 0 ;
551 streamlog_out(MESSAGE) <<
" " << it->first <<
": \t" << it->second <<
std::endl ;
553 nSkipped += it->second ;
555 streamlog_out(MESSAGE) <<
" Total: " << nSkipped <<
std::endl ;
556 streamlog_out(MESSAGE) <<
" --------------------------------------------------------- "
563 streamlog_out(MESSAGE) <<
" --------------------------------------------------------- " << std::endl
564 <<
" Time used by processors ( in processEvent() ) : " << std::endl
580 double tTotal = 0.0 ;
583 for( TMList::iterator itT = l.begin() ; itT != l.end() ; ++ itT ) {
588 char cName[40] =
" " ;
590 unsigned nChar = ( sName.
size() > 30 ? 30 : sName.
size() ) ;
591 for(
unsigned i=0 ; i< nChar ; i++ ) {
592 cName[i] = sName[i] ;
596 double tProc = itT->second.first / double(CLOCKS_PER_SEC) ;
600 int evtProc = itT->second.second ;
602 if( evtProc > evtTotal ){
606 streamlog_out(MESSAGE) << cName
608 <<
std::setw(12) << evtProc <<
" events ==> " ;
621 streamlog_out(MESSAGE) <<
" Total: "
623 <<
std::setw(12) << evtTotal <<
" events ==> " ;
635 streamlog_out(MESSAGE) <<
" --------------------------------------------------------- " <<
std::endl ;
virtual void readDataSource(int numEvents)
Calls readDataSource() for all Processors of type DataSourceProcessor.
std::set< std::string > getAvailableProcessorTypes()
Returns a list of all registered processors found.
Tagging interface for processors that modify the LCIO event.
static ProcessorMgr * instance()
Return the instance of this manager.
Base class for data source handlers that can read arbitrary non-LCIO input files and create LCIO even...
virtual void processEvent(LCEvent *)
void clear()
Clear all boolean values.
void setValue(const std::string &key, bool val)
Set the the boolean value for the given key.
virtual void setProcessorReturnValue(Processor *proc, bool val)
Set the return value for the given processor.
virtual const std::string & name() const
Return name of this processor.
SkipEventException used to skip the current event in Processor::processEvent.
std::map< Processor *, std::pair< double, int > > TimeMap
virtual const std::string & type() const
Return type name for the processor (as set in constructor).
virtual Processor * newProcessor()=0
Return a new instance of the processor.
streamlog::logstream my_cout
StopProcessingException used to stop the current proccessing of events and call Processor::end().
Processor * getProcessor(const std::string &type)
Return the processor that has been registered with the given type.
bool addActiveProcessor(const std::string &processorType, const std::string &processorName, std::shared_ptr< StringParameters > parameters, const std::string condition="true")
Add a processor of type processorType with name processorName to the list of active processors...
ProcMgrStopProcessing(const std::string m)
virtual void readDataSource(int numEvents)=0
User call back to read the data source and create the LCIO event and run header.
void registerProcessor(Processor *processor)
Register a processor with the given name.
virtual void setParameters(std::shared_ptr< StringParameters > parameters)
Helper function returns the ProcessorParameter for the given name.
static ProcessorEventSeeder * EVENTSEEDER
Processor * getActiveProcessor(const std::string &name)
Return the active processor with the given name.
void dumpRegisteredProcessorsXML()
Dump information of all registered processors in XML format to stdout.
void refreshSeeds(LCEvent *evt)
Create new set of seeds for registered Processors for the given event.
virtual ~ProcessorMgr()
destructor deletes ProcessorEventSeeder
static StringParameters * parameters
ProcessorList _eventModifierList
const std::string & getStringVal(const std::string &key)
virtual void modifyRunHeader(LCRunHeader *)
virtual void setName(const std::string &processorName)
Set processor name.
void dumpRegisteredProcessors()
Dump information of all registered processors to stdout.
virtual void processRunHeader(LCRunHeader *)
Processor event seeder - provides independent pseudo-randomly generated seeds for registered processo...
Processor manager singleton class.
static ProcessorMgr * _me
bool conditionIsTrue(const std::string &name)
True if the named condition (stored with addCondition) is true with the current values.
T back_inserter(T...args)
virtual void modifyEvent(LCEvent *)
static gear::GearMgr * GEAR
void removeActiveProcessor(const std::string &name)
Remove processor with name from list of active processors.
Base class for Marlin processors.
bool operator()(const TimeMap::value_type &v1, const TimeMap::value_type &v2)
LogicalExpressions _conditions
void addCondition(const std::string &name, const std::string &expression)
Add a new named logical expression formed out of [!,(,&&,||,),value], e.g.