#include #include #include "TString.h" #include "TApplication.h" #include "TChain.h" #include "TFile.h" #include #include "ExRootTreeReader.h" #include "ExRootTreeWriter.h" #include "ExRootTreeBranch.h" #include "BlockClasses.h" #include "TSimpleArray.h" #include "Examples/interface/Analysis_Ex.h" using namespace std; //------------------------------------------------------------------------------ int main(int argc, char *argv[]) { int appargc = 2; char *appargv[] = {"Analysis_Ex", "-b"}; TApplication app("Analysis_Ex", &appargc, appargv); if(argc !=3) { cout << " Usage: " << argv[0] << " input_file" << " [runs_list]" << endl; cout << " input_list - list of files in Delphe ROOT format ('GEN, Analysis and Trigger ' trees )," << endl; cout << " output file - name of the output analysis root file." << endl; exit(1); } //***************************************************************************** //************************Input files to the analysis************************** //***************************************************************************** TString inputFileList(argv[1]); string buffer; TChain chainGen("GEN");//generator level information TChain chainRec("Analysis");//reconstructed level infomration TChain chainTrig("Trigger");//trigger information //run on the input file list of Delphe ROOT files ifstream infile(inputFileList); if(!infile.is_open()) { cerr << "** ERROR: Can't open '" << inputFileList << "' for input" << endl; exit(1); } while(1) { infile >> buffer; if(!infile.good()) break; chainGen.Add(buffer.c_str()); chainRec.Add(buffer.c_str()); chainTrig.Add(buffer.c_str()); } //***************************************************************************** //*********************Output root file of the analysis************************ //***************************************************************************** ExRootTreeReader *treeReaderGen = new ExRootTreeReader(&chainGen); ExRootTreeReader *treeReaderRec = new ExRootTreeReader(&chainRec); ExRootTreeReader *treeReaderTrig = new ExRootTreeReader(&chainTrig); //create output file containing selection information string forLog = argv[2]; string LogName = forLog.erase(forLog.find(".root")); LogName = LogName+"_cut.txt"; ofstream f_out(LogName.c_str(),ofstream::app); //create the output tree string outputfilename = argv[2]; TFile *outputFile = TFile::Open(outputfilename.c_str(), "RECREATE"); // Creates the file, but should be closed just after outputFile->Close(); ExRootTreeWriter *treeWriter = new ExRootTreeWriter(outputfilename, "Analysis"); //***************************************************************************** //***************************Run the analysis********************************** //***************************************************************************** Analysis_Ex *DefaultOne = new Analysis_Ex("Examples/Datacard_Analysis_Ex.dat",LogName); DefaultOne->Run(treeReaderGen,treeReaderRec,treeReaderTrig,treeWriter); DefaultOne->WriteOutput(LogName); delete DefaultOne; cout << "** Exiting..." << endl; delete treeReaderGen; delete treeReaderRec; delete treeReaderTrig; }