@@ -46,6 +46,10 @@ public class EngineProcessor {
4646
4747 public EngineProcessor (){}
4848
49+ public EngineProcessor (OptionParser parser ) {
50+ init (parser );
51+ }
52+
4953 private ReconstructionEngine findEngine (String clazz ) {
5054 for (String k : processorEngines .keySet ()) {
5155 if (processorEngines .get (k ).getClass ().getName ().equals (clazz )) {
@@ -404,62 +408,53 @@ protected static OptionParser getParser() {
404408 return parser ;
405409 }
406410
407- public static void main (String [] args ){
408-
409- OptionParser parser = EngineProcessor .getParser ();
410- parser .parse (args );
411- parser .syncLogLevel (LOGGER );
412-
413- List <String > services = parser .getInputList ();
414-
415- String inputFile = parser .getOption ("-i" ).stringValue ();
416- String outputFile = parser .getOption ("-o" ).stringValue ();
417-
418- EngineProcessor proc = new EngineProcessor ();
411+ protected final void init (OptionParser p ) {
412+ p .syncLogLevel (LOGGER );
419413
420- int config = parser .getOption ("-c" ).intValue ();
421- int nskip = parser .getOption ("-s" ).intValue ();
422- int nevents = parser .getOption ("-n" ).intValue ();
423- String yamlFileName = parser .getOption ("-y" ).stringValue ();
414+ if (p .getOption ("-u" ).stringValue ().contains ("false" ))
415+ updateDictionary = false ;
424416
425- String update = parser .getOption ("-u" ).stringValue ();
426- if (update .contains ("false" )==true ) proc .updateDictionary = false ;
427-
428- if (!yamlFileName .equals ("0" )) {
429- proc .parseYaml (yamlFileName );
417+ // configure from YAML:
418+ if (!p .getOption ("-y" ).stringValue ().equals ("0" )) {
419+ parseYaml (p .getOption ("-y" ).stringValue ());
430420 }
431- else if (config >0 ){
432- if (config >2 ){
433- proc .initCaloDebug ();
434- } else if (config ==2 ){
435- proc .initAll ();
436- } else {
437- proc .initDefault ();
438- }
421+ // use a builtin engine list:
422+ else if (p .getOption ("-c" ).intValue () > 0 ) {
423+ if (p .getOption ("-c" ).intValue () > 2 ) initCaloDebug ();
424+ else if (p .getOption ("-c" ).intValue () == 2 ) initAll ();
425+ else initDefault ();
439426 }
427+ // command-line engine list:
440428 else {
441- for (String engine : services ){
429+ for (String engine : p . getInputList () ){
442430 System .out .println ("Adding reconstruction engine " + engine );
443- proc . addEngine (engine );
431+ addEngine (engine );
444432 }
445433 }
446434
447435 // command-line schema overrides YAML:
448- if (parser .getOption ("-S" ).stringValue () != null )
449- proc . setBanksToKeep (parser .getOption ("-S" ).stringValue ());
436+ if (p .getOption ("-S" ).stringValue () != null )
437+ setBanksToKeep (p .getOption ("-S" ).stringValue ());
450438
451439 // command-line filename for background merging overrides YAML:
452- if (parser .getOption ("-B" ).stringValue () != null )
453- proc . setBackgroundFiles (parser .getOption ("-B" ).stringValue ());
440+ if (p .getOption ("-B" ).stringValue () != null )
441+ setBackgroundFiles (p .getOption ("-B" ).stringValue ());
454442
455443 // command-line filename for post-processing overrides YAML:
456- if (parser .getOption ("-P" ).stringValue () != null ) {
457- proc . setPreloadFiles (parser .getOption ("-P" ).stringValue (),
458- parser .getOption ("-H" ).intValue ()!=0 ,
459- parser .getOption ("-R" ).intValue ()!=0 );
444+ if (p .getOption ("-P" ).stringValue () != null ) {
445+ setPreloadFiles (p .getOption ("-P" ).stringValue (),
446+ p .getOption ("-H" ).intValue ()!=0 ,
447+ p .getOption ("-R" ).intValue ()!=0 );
460448 }
461-
462- proc .processFile (inputFile ,outputFile ,nskip ,nevents );
463449 }
464450
451+ public static void main (String [] args ) {
452+ OptionParser parser = EngineProcessor .getParser ();
453+ parser .parse (args );
454+ EngineProcessor proc = new EngineProcessor (parser );
455+ proc .processFile (parser .getOption ("-i" ).stringValue (),
456+ parser .getOption ("-o" ).stringValue (),
457+ parser .getOption ("-s" ).intValue (),
458+ parser .getOption ("-n" ).intValue ());
459+ }
465460}
0 commit comments