Fork me on GitHub

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

Last change on this file since 268 was 260, checked in by severine ovyn, 16 years ago

add header

File size: 5.4 KB
Line 
1/***********************************************************************
2** **
3** /----------------------------------------------\ **
4** | Delphes, a framework for the fast simulation | **
5** | of a generic collider experiment | **
6** \----------------------------------------------/ **
7** **
8** **
9** This package uses: **
10** ------------------ **
11** FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210] **
12** Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2] **
13** FROG: [hep-ex/0901.2718v1] **
14** **
15** ------------------------------------------------------------------ **
16** **
17** Main authors: **
18** ------------- **
19** **
20** Severine Ovyn Xavier Rouby **
21** severine.ovyn@uclouvain.be xavier.rouby@cern **
22** **
23** Center for Particle Physics and Phenomenology (CP3) **
24** Universite catholique de Louvain (UCL) **
25** Louvain-la-Neuve, Belgium **
26** **
27** Copyright (C) 2008-2009, **
28** All rights reserved. **
29** **
30***********************************************************************/
31
32
33#include <iostream>
34#include <fstream>
35
36#include "TString.h"
37#include "TApplication.h"
38#include "TChain.h"
39#include "TFile.h"
40#include <string>
41
42#include "ExRootTreeReader.h"
43#include "ExRootTreeWriter.h"
44#include "ExRootTreeBranch.h"
45#include "BlockClasses.h"
46#include "TSimpleArray.h"
47
48#include "Examples/interface/Analysis_Ex.h"
49using namespace std;
50
51//------------------------------------------------------------------------------
52
53int main(int argc, char *argv[])
54{
55 int appargc = 2;
56 char *appargv[] = {"Analysis_Ex", "-b"};
57 TApplication app("Analysis_Ex", &appargc, appargv);
58
59 if(argc !=3)
60 {
61 cout << " Usage: " << argv[0] << " input_file" << " [runs_list]" << endl;
62 cout << " input_list - list of files in Delphe ROOT format ('GEN, Analysis and Trigger ' trees )," << endl;
63 cout << " output file - name of the output analysis root file." << endl;
64 exit(1);
65 }
66
67 //*****************************************************************************
68 //************************Input files to the analysis**************************
69 //*****************************************************************************
70 TString inputFileList(argv[1]);
71 string buffer;
72 TChain chainGen("GEN");//generator level information
73 TChain chainRec("Analysis");//reconstructed level infomration
74 TChain chainTrig("Trigger");//trigger information
75
76 //run on the input file list of Delphe ROOT files
77 ifstream infile(inputFileList);
78 if(!infile.is_open())
79 {
80 cerr << "** ERROR: Can't open '" << inputFileList << "' for input" << endl;
81 exit(1);
82 }
83 while(1)
84 {
85 infile >> buffer;
86 if(!infile.good()) break;
87 chainGen.Add(buffer.c_str());
88 chainRec.Add(buffer.c_str());
89 chainTrig.Add(buffer.c_str());
90 }
91
92
93 //*****************************************************************************
94 //*********************Output root file of the analysis************************
95 //*****************************************************************************
96 ExRootTreeReader *treeReaderGen = new ExRootTreeReader(&chainGen);
97 ExRootTreeReader *treeReaderRec = new ExRootTreeReader(&chainRec);
98 ExRootTreeReader *treeReaderTrig = new ExRootTreeReader(&chainTrig);
99
100 //create output file containing selection information
101 string forLog = argv[2];
102 string LogName = forLog.erase(forLog.find(".root"));
103 LogName = LogName+"_cut.txt";
104 ofstream f_out(LogName.c_str(),ofstream::app);
105
106 //create the output tree
107 string outputfilename = argv[2];
108 TFile *outputFile = TFile::Open(outputfilename.c_str(), "RECREATE"); // Creates the file, but should be closed just after
109 outputFile->Close();
110
111 ExRootTreeWriter *treeWriter = new ExRootTreeWriter(outputfilename, "Analysis");
112
113 //*****************************************************************************
114 //***************************Run the analysis**********************************
115 //*****************************************************************************
116
117 Analysis_Ex *DefaultOne = new Analysis_Ex("Examples/Datacard_Analysis_Ex.dat",LogName);
118 DefaultOne->Run(treeReaderGen,treeReaderRec,treeReaderTrig,treeWriter);
119 DefaultOne->WriteOutput(LogName);
120 delete DefaultOne;
121
122 cout << "** Exiting..." << endl;
123 delete treeReaderGen;
124 delete treeReaderRec;
125 delete treeReaderTrig;
126}
127
Note: See TracBrowser for help on using the repository browser.