Fork me on GitHub

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

Last change on this file since 81 was 81, checked in by uid677, 16 years ago

add exemple code

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