Fork me on GitHub

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

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

add Trigger only exemple

File size: 3.4 KB
Line 
1/*
2 ---- Delphes ----
3 A Fast Simulator for general purpose LHC detector
4 S. Ovyn ~~~~ severine.ovyn@uclouvain.be
5
6 Center for Particle Physics and Phenomenology (CP3)
7 Universite Catholique de Louvain (UCL)
8 Louvain-la-Neuve, Belgium
9*/
10
11/// \file Trigger_Only.cpp
12/// \brief executable for the Trigger running
13
14#include "TChain.h"
15#include "TApplication.h"
16
17#include "Utilities/ExRootAnalysis/interface/ExRootTreeReader.h"
18#include "Utilities/ExRootAnalysis/interface/ExRootTreeWriter.h"
19#include "Utilities/ExRootAnalysis/interface/ExRootTreeBranch.h"
20
21#include "interface/TriggerUtil.h"
22
23#include <vector>
24#include <iostream>
25
26#include "Utilities/ExRootAnalysis/interface/BlockClasses.h"
27
28#include <sstream>
29#include <fstream>
30#include <iomanip>
31
32
33using namespace std;
34
35//------------------------------------------------------------------------------
36void todo(string filename) {
37 ifstream infile(filename.c_str());
38 cout << "** TODO list ..." << endl;
39 while(infile.good()) {
40 string temp;
41 getline(infile,temp);
42 cout << "*" << temp << endl;
43 }
44 cout << "** done...\n";
45}
46
47//------------------------------------------------------------------------------
48
49int main(int argc, char *argv[])
50{
51 int appargc = 2;
52 char *appName = "Trigger_Only";
53 char *appargv[] = {appName, "-b"};
54 TApplication app(appName, &appargc, appargv);
55
56 if(argc != 2 && argc !=3 ) {
57 cout << " Usage: " << argv[0] << " input_file output_file [detector_card] [trigger_card] " << endl;
58 cout << " input_file - file in Delphe root format," << endl;
59 cout << " trigger_card - Datacard containing the trigger algorithms (optional) "<<endl;
60 exit(1);
61 }
62
63 srand (time (NULL)); /* Initialisation du générateur */
64
65 //read the input TROOT file
66 string inputFile(argv[1]);
67
68 //create output log-file name
69 string forLog = inputFile;
70 string LogName = forLog.erase(forLog.find(".root"));
71 LogName = LogName+"_run.log";
72
73 string line,buffer;
74 TChain chain("Analysis");
75 chain.Add(inputFile.c_str());
76 ExRootTreeReader *treeReaderT = new ExRootTreeReader(&chain);
77
78 //read the datacard input file
79 string TrigDatacard("");
80 if(argc==3) TrigDatacard =argv[2];
81
82 //Trigger information
83 TriggerTable *TRIGT = new TriggerTable();
84 TRIGT->TriggerCardReader(TrigDatacard.c_str());
85 TRIGT->PrintTriggerTable(LogName);
86
87 TClonesArray *branchElecTrig = treeReaderT->UseBranch("Electron");
88 TClonesArray *branchMuonTrig = treeReaderT->UseBranch("Muon");
89 TClonesArray *branchJetTrig = treeReaderT->UseBranch("Jet");
90 TClonesArray *branchTauJetTrig = treeReaderT->UseBranch("TauJet");
91 TClonesArray *branchPhotonTrig = treeReaderT->UseBranch("Photon");
92 TClonesArray *branchETmisTrig = treeReaderT->UseBranch("ETmis");
93
94 ExRootTreeWriter *treeWriterT = new ExRootTreeWriter(inputFile, "Trigger");
95 ExRootTreeBranch *branchTrigger = treeWriterT->NewBranch("TrigResult", TRootTrigger::Class());
96
97 Long64_t entryT, allEntriesT = treeReaderT->GetEntries();
98 cout << "** Chain contains " << allEntriesT << " events" << endl;
99 for(entryT = 0; entryT < allEntriesT; ++entryT)
100 {
101 treeWriterT->Clear();
102 treeReaderT->ReadEntry(entryT);
103 TRIGT->GetGlobalResult(branchElecTrig, branchMuonTrig,branchJetTrig, branchTauJetTrig,branchPhotonTrig, branchETmisTrig,branchTrigger);
104 treeWriterT->Fill();
105 }
106
107 treeWriterT->Write();
108 delete treeWriterT;
109
110 cout << "** Exiting..." << endl;
111
112 delete TRIGT;
113
114}
115
Note: See TracBrowser for help on using the repository browser.