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 "ExRootTreeReader.h"
|
---|
18 | #include "ExRootTreeWriter.h"
|
---|
19 | #include "ExRootTreeBranch.h"
|
---|
20 | #include "TriggerUtil.h"
|
---|
21 | #include "BlockClasses.h"
|
---|
22 |
|
---|
23 | #include <iostream>
|
---|
24 | #include <vector>
|
---|
25 | #include <fstream>
|
---|
26 | #include <iomanip>
|
---|
27 |
|
---|
28 |
|
---|
29 | using namespace std;
|
---|
30 |
|
---|
31 | //------------------------------------------------------------------------------
|
---|
32 | void todo(string filename) {
|
---|
33 | ifstream infile(filename.c_str());
|
---|
34 | cout << "** TODO list ..." << endl;
|
---|
35 | while(infile.good()) {
|
---|
36 | string temp;
|
---|
37 | getline(infile,temp);
|
---|
38 | cout << "*" << temp << endl;
|
---|
39 | }
|
---|
40 | cout << "** done...\n";
|
---|
41 | }
|
---|
42 |
|
---|
43 | //------------------------------------------------------------------------------
|
---|
44 |
|
---|
45 | int main(int argc, char *argv[])
|
---|
46 | {
|
---|
47 | int appargc = 2;
|
---|
48 | char *appName = "Trigger_Only";
|
---|
49 | char *appargv[] = {appName, "-b"};
|
---|
50 | TApplication app(appName, &appargc, appargv);
|
---|
51 |
|
---|
52 | if(argc != 2 && argc !=3 ) {
|
---|
53 | cout << " Usage: " << argv[0] << " input_file output_file [detector_card] [trigger_card] " << endl;
|
---|
54 | cout << " input_file - file in Delphe root format," << endl;
|
---|
55 | cout << " trigger_card - Datacard containing the trigger algorithms (optional) "<<endl;
|
---|
56 | exit(1);
|
---|
57 | }
|
---|
58 |
|
---|
59 | srand (time (NULL)); /* Initialisation du générateur */
|
---|
60 |
|
---|
61 | //read the input TROOT file
|
---|
62 | string inputFile(argv[1]);
|
---|
63 |
|
---|
64 | //create output log-file name
|
---|
65 | string forLog = inputFile;
|
---|
66 | string LogName = forLog.erase(forLog.find(".root"));
|
---|
67 | LogName = LogName+"_run.log";
|
---|
68 |
|
---|
69 | string line,buffer;
|
---|
70 | TChain chain("Analysis");
|
---|
71 | chain.Add(inputFile.c_str());
|
---|
72 | ExRootTreeReader *treeReaderT = new ExRootTreeReader(&chain);
|
---|
73 |
|
---|
74 | //read the datacard input file
|
---|
75 | string TrigDatacard("");
|
---|
76 | if(argc==3) TrigDatacard =argv[2];
|
---|
77 |
|
---|
78 | //Trigger information
|
---|
79 | TriggerTable *TRIGT = new TriggerTable();
|
---|
80 | TRIGT->TriggerCardReader(TrigDatacard.c_str());
|
---|
81 | TRIGT->PrintTriggerTable(LogName);
|
---|
82 |
|
---|
83 | TClonesArray *branchElecTrig = treeReaderT->UseBranch("Electron");
|
---|
84 | TClonesArray *branchMuonTrig = treeReaderT->UseBranch("Muon");
|
---|
85 | TClonesArray *branchJetTrig = treeReaderT->UseBranch("Jet");
|
---|
86 | TClonesArray *branchTauJetTrig = treeReaderT->UseBranch("TauJet");
|
---|
87 | TClonesArray *branchPhotonTrig = treeReaderT->UseBranch("Photon");
|
---|
88 | TClonesArray *branchETmisTrig = treeReaderT->UseBranch("ETmis");
|
---|
89 |
|
---|
90 | ExRootTreeWriter *treeWriterT = new ExRootTreeWriter(inputFile, "Trigger");
|
---|
91 | ExRootTreeBranch *branchTrigger = treeWriterT->NewBranch("TrigResult", TRootTrigger::Class());
|
---|
92 |
|
---|
93 | Long64_t entryT, allEntriesT = treeReaderT->GetEntries();
|
---|
94 | cout << "** Chain contains " << allEntriesT << " events" << endl;
|
---|
95 | for(entryT = 0; entryT < allEntriesT; ++entryT)
|
---|
96 | {
|
---|
97 | treeWriterT->Clear();
|
---|
98 | treeReaderT->ReadEntry(entryT);
|
---|
99 | TRIGT->GetGlobalResult(branchElecTrig, branchMuonTrig,branchJetTrig, branchTauJetTrig,branchPhotonTrig, branchETmisTrig,branchTrigger);
|
---|
100 | treeWriterT->Fill();
|
---|
101 | }
|
---|
102 |
|
---|
103 | treeWriterT->Write();
|
---|
104 | delete treeWriterT;
|
---|
105 |
|
---|
106 | cout << "** Exiting..." << endl;
|
---|
107 |
|
---|
108 | delete TRIGT;
|
---|
109 |
|
---|
110 | }
|
---|
111 |
|
---|