5 #ifdef LCIO_MAJOR_VERSION
6 #if LCIO_VERSION_GE( 1,2)
37 #include "gearimpl/Util.h"
38 #include "gearxml/GearXML.h"
39 #include "gearimpl/GearMgrImpl.h"
44 #include "streamlog/streamlog.h"
46 using namespace lcio ;
47 using namespace marlin ;
64 ProcessorMgr::instance()->end() ;
73 int main(
int argc,
char** argv ){
85 <<
"<!-- ?xml-stylesheet type=\"text/xsl\" href=\"http://ilcsoft.desy.de/marlin/marlin.xsl\"? -->" <<
std::endl
86 <<
"<!-- ?xml-stylesheet type=\"text/xsl\" href=\"marlin.xsl\"? -->" <<
std::endl <<
std::endl;
99 char * var =
getenv(
"MARLIN_DLL" ) ;
111 if( loader.failedLoading() ){
120 const char* steeringFileName =
"none" ;
126 for(
int i = 1 ; i < argc ; i++ ) {
129 if(
string( argv[i] ).substr( 0, 2 ) ==
"--" ){
137 string param( argv[i] ) ;
139 string s( param.
substr( 2 ) ) ;
144 if( cmdlinearg.
size() != 2 ){
145 cerr <<
endl <<
"*** invalid command line option: " << argv[i] <<
endl <<
endl;
154 for_each( s.begin(), s.end(), t2 ) ;
156 if( cmdlinekey.
size() != 2 ){
157 cerr <<
endl <<
"*** invalid command line option: " << argv[i] <<
endl <<
endl;
168 cmdlineparams[ cmdlinekey[0] ][ cmdlinekey[1] ] = cmdlinearg[1] ;
170 std::string type = cmdlinekey[0] ==
"constant" ?
"constant" :
"parameter" ;
171 cout <<
"<!-- steering file " << type <<
": [ " << cmdlinekey[0] <<
"." << cmdlinekey[1] <<
" ] will be OVERWRITTEN with value: [\"" << cmdlinearg[1] <<
"\"] -->" <<
endl;
174 for(
int j = i ; j < argc-1 ; j++ ){
229 steeringFileName = argv[2] ;
242 steeringFileName = argv[1] ;
254 streamlog::out.init(
std::cout , binname ) ;
263 if( filen.
rfind(
".xml") == std::string::npos ||
264 !( filen.
rfind(
".xml")
282 if( Global::parameters == 0 ) {
284 <<
" The program has to exit - sorry ! "
289 std::string outputSteeringFile = Global::parameters->getStringVal(
"OutputSteeringFile" ) ;
291 if( outputSteeringFile.
size() > 0 ){
292 parser->
write( outputSteeringFile ) ;
301 streamlog::out.addLevelName<DEBUG>() ;
302 streamlog::out.addLevelName<DEBUG0>() ;
303 streamlog::out.addLevelName<DEBUG1>() ;
304 streamlog::out.addLevelName<DEBUG2>() ;
305 streamlog::out.addLevelName<DEBUG3>() ;
306 streamlog::out.addLevelName<DEBUG4>() ;
307 streamlog::out.addLevelName<DEBUG5>() ;
308 streamlog::out.addLevelName<DEBUG6>() ;
309 streamlog::out.addLevelName<DEBUG7>() ;
310 streamlog::out.addLevelName<DEBUG8>() ;
311 streamlog::out.addLevelName<DEBUG9>() ;
312 streamlog::out.addLevelName<MESSAGE>() ;
313 streamlog::out.addLevelName<MESSAGE0>() ;
314 streamlog::out.addLevelName<MESSAGE1>() ;
315 streamlog::out.addLevelName<MESSAGE2>() ;
316 streamlog::out.addLevelName<MESSAGE3>() ;
317 streamlog::out.addLevelName<MESSAGE4>() ;
318 streamlog::out.addLevelName<MESSAGE5>() ;
319 streamlog::out.addLevelName<MESSAGE6>() ;
320 streamlog::out.addLevelName<MESSAGE7>() ;
321 streamlog::out.addLevelName<MESSAGE8>() ;
322 streamlog::out.addLevelName<MESSAGE9>() ;
323 streamlog::out.addLevelName<WARNING>() ;
324 streamlog::out.addLevelName<WARNING0>() ;
325 streamlog::out.addLevelName<WARNING1>() ;
326 streamlog::out.addLevelName<WARNING2>() ;
327 streamlog::out.addLevelName<WARNING3>() ;
328 streamlog::out.addLevelName<WARNING4>() ;
329 streamlog::out.addLevelName<WARNING5>() ;
330 streamlog::out.addLevelName<WARNING6>() ;
331 streamlog::out.addLevelName<WARNING7>() ;
332 streamlog::out.addLevelName<WARNING8>() ;
333 streamlog::out.addLevelName<WARNING9>() ;
334 streamlog::out.addLevelName<ERROR>() ;
335 streamlog::out.addLevelName<ERROR0>() ;
336 streamlog::out.addLevelName<ERROR1>() ;
337 streamlog::out.addLevelName<ERROR2>() ;
338 streamlog::out.addLevelName<ERROR3>() ;
339 streamlog::out.addLevelName<ERROR4>() ;
340 streamlog::out.addLevelName<ERROR5>() ;
341 streamlog::out.addLevelName<ERROR6>() ;
342 streamlog::out.addLevelName<ERROR7>() ;
343 streamlog::out.addLevelName<ERROR8>() ;
344 streamlog::out.addLevelName<ERROR9>() ;
345 streamlog::out.addLevelName<SILENT>() ;
349 std::string verbosity = Global::parameters->getStringVal(
"Verbosity" ) ;
350 streamlog::logscope scope( streamlog::out ) ;
352 scope.setLevel( verbosity ) ;
359 std::string gearFile = Global::parameters->getStringVal(
"GearXMLFile" ) ;
361 if( gearFile.
size() > 0 ) {
363 gear::GearXML gearXML( gearFile ) ;
365 Global::GEAR = gearXML.createGearMgr() ;
367 streamlog_out( MESSAGE ) <<
" ---- instantiated GEAR from file " << gearFile <<
std::endl
372 streamlog_out( MESSAGE ) <<
" ---- no GEAR XML file given --------- " <<
std::endl ;
373 Global::GEAR =
new gear::GearMgrImpl ;
380 if ( (Global::parameters->getStringVals(
"LCIOInputFiles" , lcioInputFiles ) ).
size() == 0 ){
382 int maxRecord = Global::parameters->getIntVal(
"MaxRecordNumber");
383 ProcessorMgr::instance()->init() ;
385 ProcessorMgr::instance()->readDataSource(maxRecord) ;
386 ProcessorMgr::instance()->
end() ;
392 int maxRecord = Global::parameters->getIntVal(
"MaxRecordNumber") ;
393 int skipNEvents = Global::parameters->getIntVal(
"SkipNEvents");
395 bool modify = ( Global::parameters->getStringVal(
"AllowToModifyEvent") ==
"true" ) ;
399 streamlog_out( WARNING ) <<
" ******************************************************************************* \n"
400 <<
" * AllowToModifyEvent is set to 'true' * \n"
401 <<
" * => all processors can modify the input event in processEvent() !! * \n"
402 <<
" * consider setting this flag to 'false' * \n"
403 <<
" * unless you really need it... * \n"
404 <<
" * - if you need a processor that modifies the input event * \n"
405 <<
" * please implement the EventModifier interface and use the modifyEvent() * \n"
406 <<
" * method for this * \n"
407 <<
" ******************************************************************************* \n"
412 LCReader*
lcReader = LCFactory::getInstance()->createLCReader() ;
415 if( (Global::parameters->getStringVals(
"LCIOReadCollectionNames" , readColNames ) ).
size() != 0 ){
417 streamlog_out( WARNING ) <<
" *********** Parameter LCIOReadCollectionNames given - will only read the following collections: **** "
420 for(
unsigned i=0,N=readColNames.
size() ; i<N ; ++i ) {
421 streamlog_out( WARNING ) <<
" " << readColNames[i] <<
std::endl ;
423 streamlog_out( WARNING ) <<
" *************************************************************************************************** " <<
std::endl ;
425 #if LCIO_PATCHVERSION_GE( 2,4,0 )
427 lcReader->setReadCollectionNames( readColNames ) ;
431 lcReader->registerLCRunListener( ProcessorMgr::instance() ) ;
432 lcReader->registerLCEventListener( ProcessorMgr::instance() ) ;
434 ProcessorMgr::instance()->init() ;
443 lcReader->open( lcioInputFiles ) ;
446 if( skipNEvents > 0 ){
448 streamlog_out( WARNING ) <<
" --- Marlin.cc - will skip first " << skipNEvents <<
" event(s)"
451 lcReader->skipNEvents( skipNEvents ) ;
458 lcReader->readStream( maxRecord ) ;
460 catch( lcio::EndOfDataException& e){
462 streamlog_out( WARNING ) << e.what() <<
std::endl ;
467 lcReader->readStream() ;
474 <<
" **********************************************************" <<
std::endl
476 <<
" * Stop of EventProcessiong requested by processor : *" <<
std::endl
478 <<
" * will call end() method of all processors ! *" <<
std::endl
480 <<
" **********************************************************" <<
std::endl
488 <<
" **********************************************************" <<
std::endl
490 <<
" * Rewind data files requested by processor : *" <<
std::endl
492 <<
" * will rewind to beginning ! *" <<
std::endl
494 <<
" **********************************************************" <<
std::endl
503 ProcessorMgr::instance()->end() ;
514 if( Global::GEAR != 0 )
515 delete Global::GEAR ;
523 std::cerr <<
" ***********************************************\n"
524 <<
" A runtime error occured - (uncaught exception):\n"
525 <<
" " << e.
what() <<
"\n"
526 <<
" Marlin will have to be terminated, sorry.\n"
527 <<
" ***********************************************\n"
540 Global::parameters->getStringVals(
"ActiveProcessors" , activeProcessors ) ;
543 Global::parameters->getStringVals(
"ProcessorConditions" , procConds ) ;
545 bool useConditions = ( activeProcessors.
size() == procConds.
size() ) ;
548 for(
unsigned int i=0 ; i< activeProcessors.
size() ; i++ ) {
553 std::string type = p->getStringVal(
"ProcessorType") ;
556 ProcessorMgr::instance()->addActiveProcessor( type , activeProcessors[i] , p , procConds[i] ) ;
558 ProcessorMgr::instance()->addActiveProcessor( type , activeProcessors[i] , p ) ;
562 sstr <<
"Undefined processor : " << activeProcessors[i] <<
std::endl ;
563 streamlog_out( ERROR ) << sstr.
str() ;
564 throw Exception( sstr.
str() );
572 Global::parameters->getStringVals(
"ActiveProcessors" , activeProcessors ) ;
575 for(
unsigned int i=0 ; i< activeProcessors.
size() ; i++ ) {
581 streamlog_out( MESSAGE ) <<
" Parameters for processor " << activeProcessors[i]
586 std::string type = p->getStringVal(
"ProcessorType") ;
589 if( ProcessorMgr::instance()->addActiveProcessor( type , activeProcessors[i] , p ) ){
596 sstr <<
"Undefined processor : " << activeProcessors[i] <<
std::endl ;
597 streamlog_out( ERROR ) << sstr.
str() ;
598 throw Exception( sstr.
str() );
607 ProcessorMgr::instance()->dumpRegisteredProcessors() ;
612 ProcessorMgr::instance()->dumpRegisteredProcessorsXML() ;
619 <<
" runs a Marlin application " <<
std::endl
621 <<
" Running the application with a given steering file:" <<
std::endl
624 <<
" Marlin [-h/-?] \t print this help information" <<
std::endl
625 <<
" Marlin -x \t print an example steering file to stdout" <<
std::endl
626 <<
" Marlin -c steer.xml \t check the given steering file for consistency" <<
std::endl
627 <<
" Marlin -u old.xml new.xml \t consistency check with update of xml file" <<
std::endl
628 <<
" Marlin -d steer.xml flow.dot\t create a program flow diagram (see: http://www.graphviz.org)" <<
std::endl
631 <<
" To create a new default steering file from any Marlin application, run" <<
std::endl
632 <<
" Marlin -x > mysteer.xml" <<
std::endl
633 <<
" and then use either an editor or the MarlinGUI to modify the created steering file " <<
std::endl
634 <<
" to configure your application and then run it. e.g. : " <<
std::endl
636 <<
" Dynamic command line options may be specified in order to overwrite individual steering file parameters, e.g.:" <<
std::endl
637 <<
" Marlin --global.LCIOInputFiles=\"input1.slcio input2.slcio\" --global.GearXMLFile=mydetector.xml" <<
std::endl
638 <<
" --MyLCIOOutputProcessor.LCIOWriteMode=WRITE_APPEND --MyLCIOOutputProcessor.LCIOOutputFile=out.slcio steer.xml" <<
std::endl <<
std::endl
639 <<
" NOTE: Dynamic options do NOT work together with Marlin options (-x, -f) nor with the MarlinGUI" <<
std::endl
XML parser for Marlin steering files.
std::shared_ptr< StringParameters > getParameters(const std::string §ionName) const
Return the StringParameters defined for this section of the steering file.
RewindDataFilesException used to stop the current proccessing of events, rewind to the first event an...
virtual void setCmdLineParameters(const CommandLineParametersMap &cmdlineparams)=0
set command line parameters
this class is a Marlin Steering File consistency check Tool.
Processor loader - loads shared libraries with marlin processors.
void userException(int sig)
Interface for a parser of a steering file to be used with marlin.
virtual void parse()=0
Parse the input file.
StopProcessingException used to stop the current proccessing of events and call Processor::end().
void dump_information()
Dumps all information read from the steering file to stdout.
Simple parser class for Marlin.
bool saveAsDOTFile(const std::string &file)
Saves steering file in dot format.
void createProcessors(Parser &parser)
virtual void write(const std::string &fname) const =0
Write down the parsed file in a new file.
bool saveAsXMLFile(const std::string &file)
Saves the data to an XML file with the given name Returns false if error occured. ...
void listAvailableProcessors()
virtual std::shared_ptr< StringParameters > getParameters(const std::string §ionName) const =0
Return the StringParameters defined for this section of the steering file.
int main(int argc, char *argv[])
void listAvailableProcessorsXML()