• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

/Users/jmonk/Physics/ForIA/src/D3PD/main.cxx

Go to the documentation of this file.
00001 
00002 #include "ForIA/D3PD/D3PDConverter.hh"
00003 #include "ForIA/D3PD/RootHistogrammer.hh"
00004 
00005 #include "ForIA/EventLoop.hh"
00006 
00007 #include <string>
00008 #include <sstream>
00009 #include <iostream>
00010 #include "ForIA/D3PD/tclap/CmdLine.h"
00011 #include "ForIA/D3PD/tclap/ArgException.h"
00012 #include "ForIA/D3PD/tclap/CmdLineOutput.h"
00013 
00014 int main(int argc, char **argv){
00015   
00016   TCLAP::CmdLine cmd("FORmat Independent Analysis.  Bug reports to James Monk <jmonk@hep.ucl.ac.uk>", ' ', "0.1.0");
00017   TCLAP::ValueArg<std::string> analysesArg("a","analyses","Comma separated list of analyses to run",false,"","string");
00018   TCLAP::ValueArg<std::string> libArg("L", "load", "Comma separated list of analysis libraries to load", false, "Correlations", "string");
00019   TCLAP::ValueArg<std::string> inputArg("i", "input", "Text file listing D3PDs to run on", true, "", "string");
00020   TCLAP::ValueArg<std::string> grlArg("g", "good-runs-list", "Good runs list XML file (default: MinBias/data_minbias_7TeV_14052010.xml)", 
00021                                       false, "MinBias/data_minbias_7TeV_14052010.xml", "string");
00022   TCLAP::SwitchArg grlDisable("d", "disable-grl", "Disable the good runs list (default: enabled)", false);
00023   TCLAP::SwitchArg listAnalyses("l", "list-analyses", "List the set of analyses", false);
00024   TCLAP::ValueArg<long> nEventsArg("n", "nEvents", "Number of events to run on (default all)", false, -1, "int");
00025   TCLAP::ValueArg<std::string> outArg("o", "output", "Name of output file <string>.root", false, "ForIA", "string");
00026   cmd.add( analysesArg);
00027   cmd.add(libArg);
00028   cmd.add(listAnalyses );
00029   cmd.add(inputArg);
00030   cmd.xorAdd(grlArg, grlDisable);
00031   cmd.add(nEventsArg);
00032   cmd.add(outArg);
00033   
00034   cmd.setExceptionHandling(false);
00035   
00036   // yeesh, TCLAP exception handling is a bit convoluted!
00037   try{
00038     try{
00039       cmd.parse( argc, argv );
00040     }catch (TCLAP::ArgException &err) {
00041       if(listAnalyses.getValue()){
00042         ForIA::AnalysisFactory::loadAnalysisLibraries(libArg.getValue());
00043         ForIA::EventLoop tmp(0, 0);
00044         tmp.printAnalyses(std::cout);
00045         exit(0);
00046       }
00047       
00048       TCLAP::CmdLineOutput *cmdOut = cmd.getOutput();
00049       cmdOut->failure(cmd, err);
00050     }
00051   }catch(TCLAP::ExitException &ee){
00052     exit(ee.getExitStatus());
00053   }
00054   
00055   ForIA::D3PDConverter converter = (grlDisable.getValue()) ? 
00056   ForIA::D3PDConverter(inputArg.getValue()): ForIA::D3PDConverter(inputArg.getValue(), grlArg.getValue());
00057   
00058   ForIA::RootHistogrammer histogrammer(outArg.getValue());
00059   ForIA::EventLoop loop(&converter, &histogrammer);
00060   
00061   ForIA::AnalysisFactory::loadAnalysisLibraries(libArg.getValue());
00062   
00063   std::stringstream ss(analysesArg.getValue());
00064   std::vector<std::string> analyses;
00065   std::string analysis;
00066   while(std::getline(ss, analysis, *(","))) {
00067     loop.addAnalysis(analysis);
00068   }
00069       
00070   converter.initialise();
00071   bool success = loop.initialise();
00072   
00073   if(!success){
00074     std::cout<<"Could not initialise analyses - exiting!"<<std::endl;
00075     exit(0);
00076   }
00077   
00078   loop.run(nEventsArg.getValue());
00079   
00080   loop.finalise();
00081   
00082   histogrammer.finalise();
00083   
00084 }

Generated on Mon Jul 30 2012 16:56:35 for ForIA by  doxygen 1.7.2