Fork me on GitHub

source: svn/trunk/Examples/Analysis_Ex.cpp@ 257

Last change on this file since 257 was 227, checked in by Xavier Rouby, 16 years ago

include statements have been cleaned

File size: 3.2 KB
Line 
1#include <iostream>
2#include <fstream>
3
4#include "TString.h"
5#include "TApplication.h"
6#include "TChain.h"
7#include "TFile.h"
8#include <string>
9
10#include "ExRootTreeReader.h"
11#include "ExRootTreeWriter.h"
12#include "ExRootTreeBranch.h"
13#include "BlockClasses.h"
14#include "TSimpleArray.h"
15
16#include "Examples/interface/Analysis_Ex.h"
17using namespace std;
18
19//------------------------------------------------------------------------------
20
21int main(int argc, char *argv[])
22{
23 int appargc = 2;
24 char *appargv[] = {"Analysis_Ex", "-b"};
25 TApplication app("Analysis_Ex", &appargc, appargv);
26
27 if(argc !=3)
28 {
29 cout << " Usage: " << argv[0] << " input_file" << " [runs_list]" << endl;
30 cout << " input_list - list of files in Delphe ROOT format ('GEN, Analysis and Trigger ' trees )," << endl;
31 cout << " output file - name of the output analysis root file." << endl;
32 exit(1);
33 }
34
35 //*****************************************************************************
36 //************************Input files to the analysis**************************
37 //*****************************************************************************
38 TString inputFileList(argv[1]);
39 string buffer;
40 TChain chainGen("GEN");//generator level information
41 TChain chainRec("Analysis");//reconstructed level infomration
42 TChain chainTrig("Trigger");//trigger information
43
44 //run on the input file list of Delphe ROOT files
45 ifstream infile(inputFileList);
46 if(!infile.is_open())
47 {
48 cerr << "** ERROR: Can't open '" << inputFileList << "' for input" << endl;
49 exit(1);
50 }
51 while(1)
52 {
53 infile >> buffer;
54 if(!infile.good()) break;
55 chainGen.Add(buffer.c_str());
56 chainRec.Add(buffer.c_str());
57 chainTrig.Add(buffer.c_str());
58 }
59
60
61 //*****************************************************************************
62 //*********************Output root file of the analysis************************
63 //*****************************************************************************
64 ExRootTreeReader *treeReaderGen = new ExRootTreeReader(&chainGen);
65 ExRootTreeReader *treeReaderRec = new ExRootTreeReader(&chainRec);
66 ExRootTreeReader *treeReaderTrig = new ExRootTreeReader(&chainTrig);
67
68 //create output file containing selection information
69 string forLog = argv[2];
70 string LogName = forLog.erase(forLog.find(".root"));
71 LogName = LogName+"_cut.txt";
72 ofstream f_out(LogName.c_str(),ofstream::app);
73
74 //create the output tree
75 string outputfilename = argv[2];
76 TFile *outputFile = TFile::Open(outputfilename.c_str(), "RECREATE"); // Creates the file, but should be closed just after
77 outputFile->Close();
78
79 ExRootTreeWriter *treeWriter = new ExRootTreeWriter(outputfilename, "Analysis");
80
81 //*****************************************************************************
82 //***************************Run the analysis**********************************
83 //*****************************************************************************
84
85 Analysis_Ex *DefaultOne = new Analysis_Ex("Examples/Datacard_Analysis_Ex.dat",LogName);
86 DefaultOne->Run(treeReaderGen,treeReaderRec,treeReaderTrig,treeWriter);
87 DefaultOne->WriteOutput(LogName);
88 delete DefaultOne;
89
90 cout << "** Exiting..." << endl;
91 delete treeReaderGen;
92 delete treeReaderRec;
93 delete treeReaderTrig;
94}
95
Note: See TracBrowser for help on using the repository browser.