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 | // \brief Trigger class, and some generic definitions
|
---|
12 |
|
---|
13 | #include "interface/TriggerUtil.h"
|
---|
14 | #include "TRandom.h"
|
---|
15 |
|
---|
16 | #include <iostream>
|
---|
17 | #include <sstream>
|
---|
18 | #include <fstream>
|
---|
19 | #include <iomanip>
|
---|
20 | #include <cstring>
|
---|
21 |
|
---|
22 | using namespace std;
|
---|
23 |
|
---|
24 | TriggerTable::TriggerTable() {
|
---|
25 | has_been_evaluated=false;
|
---|
26 | }
|
---|
27 |
|
---|
28 | void TriggerTable::TriggerCardReader(const string filename){
|
---|
29 | ifstream trigger_file(filename.c_str());
|
---|
30 | if( !trigger_file.good() ) {
|
---|
31 | cout << "ERROR: Trigger input file "<< filename << " not found. Exiting.\n";
|
---|
32 | return;
|
---|
33 | }
|
---|
34 |
|
---|
35 | TriggerBit mybit;
|
---|
36 | string temp_string, temp_string_no_comment, trigger_name, trigger_algorithm;
|
---|
37 | while ( getline(trigger_file,temp_string) ) {
|
---|
38 | string temp_string_no_comment = temp_string.substr(0,temp_string.find("#")); //remove comments
|
---|
39 | if(temp_string_no_comment.size()<2) continue; // avoid empty lines
|
---|
40 | istringstream temp_stream(temp_string_no_comment);
|
---|
41 |
|
---|
42 | temp_stream >> trigger_name;
|
---|
43 | trigger_algorithm = temp_string_no_comment.substr( temp_string_no_comment.find(">>")+2) ;
|
---|
44 |
|
---|
45 | mybit.TriggerBit::GetTrigCondition(trigger_algorithm);
|
---|
46 | list_of_trigger_bits.push_back(mybit);
|
---|
47 | }
|
---|
48 | }
|
---|
49 |
|
---|
50 |
|
---|
51 | void TriggerTable::PrintTriggerTable(string LogName) {
|
---|
52 |
|
---|
53 | ofstream f_out(LogName.c_str(),ios::app);
|
---|
54 | f_out<<"* *"<<"\n";
|
---|
55 | f_out<<"#*********************************************** *"<<"\n";
|
---|
56 | f_out<<"# Trigger conditions defined in the trigger card *"<<"\n";
|
---|
57 | f_out<<"#*********************************************** *"<<"\n";
|
---|
58 | f_out<<"* *"<<"\n";
|
---|
59 |
|
---|
60 | f_out.close();
|
---|
61 |
|
---|
62 | for(unsigned int i=0; i < list_of_trigger_bits.size(); i++) {
|
---|
63 | list_of_trigger_bits[i].PrintTrigCondition(LogName,i+1);
|
---|
64 | }
|
---|
65 | }
|
---|
66 |
|
---|
67 | //*************************************************************************
|
---|
68 |
|
---|
69 | TriggerBit::TriggerBit() {
|
---|
70 | has_been_evaluated=false;
|
---|
71 | }
|
---|
72 |
|
---|
73 | void TriggerBit::GetTrigCondition(const string& trigger_algorithm) {
|
---|
74 |
|
---|
75 | vector<string> ElecSequences;
|
---|
76 | vector<string> MuonSequences;
|
---|
77 | vector<string> JetSequences;
|
---|
78 | vector<string> TauJetSequences;
|
---|
79 | vector<string> EtmisSequences;
|
---|
80 | vector<string> GammaSequences;
|
---|
81 |
|
---|
82 | char *result = NULL;
|
---|
83 | result = strtok( (char*) trigger_algorithm.c_str(),"&");
|
---|
84 | while( result != NULL )
|
---|
85 | {
|
---|
86 | if(strstr (result,"ELEC"))ElecSequences.push_back(result);
|
---|
87 | if(strstr (result,"MUON"))MuonSequences.push_back(result);
|
---|
88 | if(strstr (result,"JET"))JetSequences.push_back(result);
|
---|
89 | if(strstr (result,"TAUJET"))TauJetSequences.push_back(result);
|
---|
90 | if(strstr (result,"ETMIS"))EtmisSequences.push_back(result);
|
---|
91 | if(strstr (result,"GAMMA"))GammaSequences.push_back(result);
|
---|
92 | result = strtok( NULL,"&");
|
---|
93 | }
|
---|
94 |
|
---|
95 | ElecValues = GetCuts(ElecSequences);
|
---|
96 | MuonValues = GetCuts(MuonSequences);
|
---|
97 | JetValues = GetCuts(JetSequences);
|
---|
98 | TauJetValues = GetCuts(TauJetSequences);
|
---|
99 | EtmisValues = GetCuts(EtmisSequences);
|
---|
100 | GammaValues = GetCuts(GammaSequences);
|
---|
101 |
|
---|
102 | }
|
---|
103 | void TriggerBit::PrintTrigCondition(string LogName,int i)
|
---|
104 | {
|
---|
105 | int elec_size = TriggerBit::ElecValues.size();
|
---|
106 | int muon_size = TriggerBit::MuonValues.size();
|
---|
107 | int jet_size = TriggerBit::JetValues.size();
|
---|
108 | int taujet_size = TriggerBit::TauJetValues.size();
|
---|
109 | int gamma_size = TriggerBit::GammaValues.size();
|
---|
110 | int etmis_size = TriggerBit::EtmisValues.size();
|
---|
111 |
|
---|
112 | ofstream f_out(LogName.c_str(),ios::app);
|
---|
113 |
|
---|
114 | f_out <<"* *"<<"\n";
|
---|
115 | f_out << left << setw(25) <<"# Trigger bit number "<<""
|
---|
116 | << left << setw(35) <<i <<""<< right << setw(10)<<"*"<<"\n";
|
---|
117 | f_out <<"#*************************"<<"\n";
|
---|
118 | f_out << left << setw(45) <<"* # Number of reconstructed objects required:"<<""<<right << setw(23)<<"*"<<"\n";
|
---|
119 | f_out << left << setw(1) <<"*"
|
---|
120 | << internal << setw(10) << "Electron"<< ""<< internal << setw(10) << "Muon" << ""
|
---|
121 | << internal << setw(10) << "Jets" << ""<< internal << setw(10) << "Tau-jets "<< ""
|
---|
122 | << internal << setw(10) << "Photons" << ""<< internal << setw(10) << "ETmis "<< ""<< right << setw(9) <<"*"<<"\n";
|
---|
123 | f_out << left << setw(1) <<"*"
|
---|
124 | << internal << setw(10) << elec_size << ""<< internal << setw(10) << muon_size << ""
|
---|
125 | << internal << setw(10) << jet_size << ""<< internal << setw(10) << taujet_size << ""
|
---|
126 | << internal << setw(10) << gamma_size<< ""<< internal << setw(10) << etmis_size << ""<< right << setw(9)<<"*"<<"\n";
|
---|
127 | f_out << left << setw(45) <<"* # Values of the related thresholds: "<<""<<right << setw(25)<<"*"<<"\n";
|
---|
128 | if(elec_size!=0){
|
---|
129 | f_out << left << setw(20) <<"* - Electrons: "<<"";
|
---|
130 | for(int i=0;i<elec_size;i++){f_out << left << setw(5) << TriggerBit::ElecValues[i]<<"";}f_out <<"\n";}
|
---|
131 |
|
---|
132 | if(muon_size!=0){
|
---|
133 | f_out << left << setw(20) <<"* - Muons: "<<"";
|
---|
134 | for(int i=0;i<muon_size;i++){f_out << left << setw(5) << TriggerBit::MuonValues[i]<<"";}f_out <<"\n";}
|
---|
135 |
|
---|
136 | if(jet_size!=0){
|
---|
137 | f_out << left << setw(20) <<"* - Jets: "<<"";
|
---|
138 | for(int i=0;i<jet_size;i++){f_out << left << setw(5) << TriggerBit::JetValues[i]<<"";}f_out <<"\n";}
|
---|
139 |
|
---|
140 | if(taujet_size!=0){
|
---|
141 | f_out << left << setw(20) <<"* - Tau-jets: "<<"";
|
---|
142 | for(int i=0;i<taujet_size;i++){f_out << left << setw(5) << TriggerBit::TauJetValues[i]<<"";}f_out <<"\n";}
|
---|
143 |
|
---|
144 | if(gamma_size!=0){
|
---|
145 | f_out << left << setw(20) <<"* - Photons: "<<"";
|
---|
146 | for(int i=0;i<gamma_size;i++){f_out << left << setw(5) << TriggerBit::GammaValues[i]<<"";}f_out <<"\n";}
|
---|
147 |
|
---|
148 | if(etmis_size!=0){
|
---|
149 | f_out << left << setw(20) <<"* - ETMIS: "<<"";
|
---|
150 | for(int i=0;i<etmis_size;i++){f_out << left << setw(5) << TriggerBit::EtmisValues[i]<<"";}f_out <<"\n";}
|
---|
151 | f_out <<"* *"<<"\n";
|
---|
152 |
|
---|
153 |
|
---|
154 |
|
---|
155 | }
|
---|
156 |
|
---|
157 | vector<float> TriggerBit::GetCuts(const vector<string> &Sequences)
|
---|
158 | {
|
---|
159 | vector<float> OrderedValue;
|
---|
160 | string ptVal;
|
---|
161 | Int_t PtVal=0;
|
---|
162 | for(unsigned int i=0; i < Sequences.size(); i++) {
|
---|
163 | ptVal = Sequences[i].substr( Sequences[i].find("'")+1) ;
|
---|
164 | PtVal = atoi( ptVal.c_str() );
|
---|
165 | OrderedValue.push_back(PtVal);
|
---|
166 | }
|
---|
167 | return OrderedValue;
|
---|
168 |
|
---|
169 | }
|
---|
170 |
|
---|
171 |
|
---|