Fork me on GitHub

source: svn/trunk/Examples/Trigger_Only.cpp@ 911

Last change on this file since 911 was 443, checked in by Xavier Rouby, 15 years ago

new header in all files

File size: 5.0 KB
Line 
1/***********************************************************************
2** **
3** /----------------------------------------------\ **
4** | Delphes, a framework for the fast simulation | **
5** | of a generic collider experiment | **
6** \------------- arXiv:0903.2225v1 ------------/ **
7** **
8** **
9** This package uses: **
10** ------------------ **
11** ROOT: Nucl. Inst. & Meth. in Phys. Res. A389 (1997) 81-86 **
12** FastJet algorithm: Phys. Lett. B641 (2006) [hep-ph/0512210] **
13** Hector: JINST 2:P09005 (2007) [physics.acc-ph:0707.1198v2] **
14** FROG: [hep-ex/0901.2718v1] **
15** HepMC: Comput. Phys. Commun.134 (2001) 41 **
16** **
17** ------------------------------------------------------------------ **
18** **
19** Main authors: **
20** ------------- **
21** **
22** Severine Ovyn Xavier Rouby **
23** severine.ovyn@uclouvain.be xavier.rouby@cern **
24** **
25** Center for Particle Physics and Phenomenology (CP3) **
26** Universite catholique de Louvain (UCL) **
27** Louvain-la-Neuve, Belgium **
28** **
29** Copyright (C) 2008-2009, **
30** All rights reserved. **
31** **
32***********************************************************************/
33
34/// \file Trigger_Only.cpp
35/// \brief executable for the Trigger running
36
37#include "TChain.h"
38#include "TApplication.h"
39
40#include "ExRootTreeReader.h"
41#include "ExRootTreeWriter.h"
42#include "ExRootTreeBranch.h"
43#include "TriggerUtil.h"
44#include "BlockClasses.h"
45
46#include <iostream>
47#include <vector>
48#include <fstream>
49#include <iomanip>
50
51
52using namespace std;
53
54int main(int argc, char *argv[])
55{
56 int appargc = 2;
57 char *appName= new char[20];
58 char *appOpt= new char[20];
59 sprintf(appName,"Trigger_Only");
60 sprintf(appOpt,"-b");
61 char *appargv[] = {appName,appOpt};
62 TApplication app(appName, &appargc, appargv);
63 delete [] appName;
64 delete [] appOpt;
65
66 if(argc != 2 && argc !=3 ) {
67 cout << " Usage: " << argv[0] << " input_file output_file [detector_card] [trigger_card] " << endl;
68 cout << " input_file - file in Delphe root format," << endl;
69 cout << " trigger_card - Datacard containing the trigger algorithms (optional) "<<endl;
70 exit(1);
71 }
72
73 srand (time (NULL)); /* Initialisation du générateur */
74
75 //read the input TROOT file
76 string inputFile(argv[1]);
77
78 //create output log-file name
79 string forLog = inputFile;
80 string LogName = forLog.erase(forLog.find(".root"));
81 LogName = LogName+"_run.log";
82
83 string line,buffer;
84 TChain chain("Analysis");
85 chain.Add(inputFile.c_str());
86 ExRootTreeReader *treeReaderT = new ExRootTreeReader(&chain);
87
88 //read the datacard input file
89 string TrigDatacard("");
90 if(argc==3) TrigDatacard =argv[2];
91
92 //Trigger information
93 TriggerTable *TRIGT = new TriggerTable();
94 TRIGT->TriggerCardReader(TrigDatacard.c_str());
95 TRIGT->PrintTriggerTable(LogName);
96
97 TClonesArray *branchElecTrig = treeReaderT->UseBranch("Electron");
98 TClonesArray *branchMuonTrig = treeReaderT->UseBranch("Muon");
99 TClonesArray *branchJetTrig = treeReaderT->UseBranch("Jet");
100 TClonesArray *branchTauJetTrig = treeReaderT->UseBranch("TauJet");
101 TClonesArray *branchPhotonTrig = treeReaderT->UseBranch("Photon");
102 TClonesArray *branchETmisTrig = treeReaderT->UseBranch("ETmis");
103
104 ExRootTreeWriter *treeWriterT = new ExRootTreeWriter(inputFile, "Trigger");
105 ExRootTreeBranch *branchTrigger = treeWriterT->NewBranch("TrigResult", TRootTrigger::Class());
106
107 Long64_t entryT, allEntriesT = treeReaderT->GetEntries();
108 cout << "** Chain contains " << allEntriesT << " events" << endl;
109 for(entryT = 0; entryT < allEntriesT; ++entryT)
110 {
111 treeWriterT->Clear();
112 treeReaderT->ReadEntry(entryT);
113 TRIGT->GetGlobalResult(branchElecTrig, branchMuonTrig,branchJetTrig, branchTauJetTrig,branchPhotonTrig, branchETmisTrig,branchTrigger);
114 treeWriterT->Fill();
115 }
116
117 treeWriterT->Write();
118 delete treeWriterT;
119
120 cout << "** Exiting..." << endl;
121
122 delete TRIGT;
123
124}
125
Note: See TracBrowser for help on using the repository browser.