Fork me on GitHub

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

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

new header in all files

File size: 5.0 KB
RevLine 
[260]1/***********************************************************************
2** **
3** /----------------------------------------------\ **
4** | Delphes, a framework for the fast simulation | **
5** | of a generic collider experiment | **
[443]6** \------------- arXiv:0903.2225v1 ------------/ **
[260]7** **
8** **
9** This package uses: **
10** ------------------ **
[443]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] **
[260]14** FROG: [hep-ex/0901.2718v1] **
[443]15** HepMC: Comput. Phys. Commun.134 (2001) 41 **
[260]16** **
17** ------------------------------------------------------------------ **
18** **
19** Main authors: **
20** ------------- **
21** **
[443]22** Severine Ovyn Xavier Rouby **
23** severine.ovyn@uclouvain.be xavier.rouby@cern **
[260]24** **
[443]25** Center for Particle Physics and Phenomenology (CP3) **
26** Universite catholique de Louvain (UCL) **
27** Louvain-la-Neuve, Belgium **
28** **
[260]29** Copyright (C) 2008-2009, **
[443]30** All rights reserved. **
[260]31** **
32***********************************************************************/
[78]33
34/// \file Trigger_Only.cpp
35/// \brief executable for the Trigger running
36
37#include "TChain.h"
38#include "TApplication.h"
39
[227]40#include "ExRootTreeReader.h"
41#include "ExRootTreeWriter.h"
42#include "ExRootTreeBranch.h"
43#include "TriggerUtil.h"
44#include "BlockClasses.h"
[78]45
[227]46#include <iostream>
[78]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;
[274]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};
[78]62 TApplication app(appName, &appargc, appargv);
[274]63 delete [] appName;
64 delete [] appOpt;
65
[78]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
[274]89 string TrigDatacard("");
[78]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.