Changeset 250 in svn
- Timestamp:
- Feb 7, 2009, 1:43:05 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/interface/TriggerUtil.h
r243 r250 16 16 17 17 #include "BlockClasses.h" 18 #include "Utilities/ExRootAnalysis/interface/TSimpleArray.h" 18 19 #include "Utilities/ExRootAnalysis/interface/ExRootTreeBranch.h" 19 20 … … 24 25 public: 25 26 26 TriggerBit() ;27 TriggerBit(){}; 27 28 TriggerBit(const TriggerBit& tb); 28 29 TriggerBit& operator=(const TriggerBit& tb); … … 35 36 TClonesArray *branchPhotonTrig, TClonesArray *branchETmisTrig); 36 37 vector<float> GetCuts(const vector<string> &Sequences); 38 TSimpleArray<TRootJet> SubArrayBjets(TClonesArray *JET); 39 TSimpleArray<TRootElectron> SubArrayIElec(TClonesArray *ELEC); 40 TSimpleArray<TRootMuon> SubArrayIMuon(TClonesArray *MUON); 37 41 38 42 private: 39 43 40 44 vector<float> ElecValues; 45 vector<float> IElecValues; 41 46 vector<float> MuonValues; 47 vector<float> IMuonValues; 42 48 vector<float> JetValues; 49 vector<float> BjetValues; 43 50 vector<float> TauJetValues; 44 51 vector<float> EtmisValues; … … 58 65 59 66 void TriggerCardReader(const string& filename="data/trigger.dat"); 60 // avant, ça s'appellait TriggerReader61 // appelle la méthode TriggerBit::GetTrigCondition62 63 64 67 void PrintTriggerTable(const string& LogName); 65 // fait un cout des triggers bits, c'est toujours pratique66 // appelle la méthode TriggerBit::PriniTrigCondition67 68 68 bool GetGlobalResult(TClonesArray *branchElecTrig, TClonesArray *branchMuonTrig, 69 69 TClonesArray *branchJetTrig, TClonesArray *branchTauJetTrig, … … 71 71 72 72 void WriteResult(); 73 // sauve dans le TTree74 // ce nom est stupide, faut le changer75 73 76 74 private: 77 //bool Evaluate( int event_i );78 // boucle sur list_of_trigger_bits, comme on a dit79 // appelle la methode TriggerBit::Evaluate ou TriggerBit::GetResult (à voir)80 // renvoie la réponse globale du trigger81 // à la fin, mettre has_been_evaluated = true;82 // voir le NB ci-dessous83 75 84 76 vector<TriggerBit> list_of_trigger_bits; 85 77 bool has_been_evaluated; 86 78 bool GlobalResult; 87 int event_i;88 79 89 80 }; -
trunk/src/TriggerUtil.cc
r243 r250 27 27 TriggerTable& TriggerTable::operator=(TriggerTable&tt) { 28 28 if (this == &tt) return *this; 29 event_i = tt.event_i;30 29 has_been_evaluated = tt.has_been_evaluated; 31 30 GlobalResult = tt.GlobalResult; … … 36 35 37 36 TriggerTable::TriggerTable(const TriggerTable& tt) { 38 event_i = tt.event_i;39 37 has_been_evaluated = tt.has_been_evaluated; 40 38 GlobalResult = tt.GlobalResult; … … 47 45 ifstream trigger_file(filename.c_str()); 48 46 if( !trigger_file.good() ) { 49 cout << "ERROR: Trigger input file "<< filename << " not found. Exiting.\n"; 47 cerr << left << setw(30) <<"** ERROR: Trigger input file "<<"" 48 << right << setw(15) <<filename<<"" 49 << right << setw(24) <<"not found. Exiting... **"<<endl; 50 50 return; 51 51 } … … 111 111 112 112 //************************************************************************* 113 TriggerBit::TriggerBit() {114 }115 113 116 114 TriggerBit::~TriggerBit() { 117 115 ElecValues.clear(); 116 IElecValues.clear(); 118 117 MuonValues.clear(); 118 IMuonValues.clear(); 119 119 JetValues.clear(); 120 BjetValues.clear(); 120 121 TauJetValues.clear(); 121 122 EtmisValues.clear(); … … 127 128 ElecValues.push_back(tb.ElecValues[i]); 128 129 130 for(unsigned int i=0; i<tb.IElecValues.size(); i++) 131 IElecValues.push_back(tb.IElecValues[i]); 132 133 129 134 for(unsigned int i=0; i<tb.MuonValues.size(); i++) 130 135 MuonValues.push_back(tb.MuonValues[i]); 131 136 137 for(unsigned int i=0; i<tb.IMuonValues.size(); i++) 138 IMuonValues.push_back(tb.IMuonValues[i]); 139 132 140 for(unsigned int i=0; i<tb.JetValues.size(); i++) 133 141 JetValues.push_back(tb.JetValues[i]); 142 143 for(unsigned int i=0; i<tb.BjetValues.size(); i++) 144 BjetValues.push_back(tb.BjetValues[i]); 145 134 146 135 147 for(unsigned int i=0; i<tb.TauJetValues.size(); i++) … … 150 162 ElecValues.push_back(tb.ElecValues[i]); 151 163 164 for(unsigned int i=0; i<tb.IElecValues.size(); i++) 165 IElecValues.push_back(tb.IElecValues[i]); 166 152 167 for(unsigned int i=0; i<tb.MuonValues.size(); i++) 153 168 MuonValues.push_back(tb.MuonValues[i]); 154 169 170 for(unsigned int i=0; i<tb.IMuonValues.size(); i++) 171 IMuonValues.push_back(tb.IMuonValues[i]); 172 155 173 for(unsigned int i=0; i<tb.JetValues.size(); i++) 156 174 JetValues.push_back(tb.JetValues[i]); 175 176 for(unsigned int i=0; i<tb.BjetValues.size(); i++) 177 BjetValues.push_back(tb.BjetValues[i]); 157 178 158 179 for(unsigned int i=0; i<tb.TauJetValues.size(); i++) … … 175 196 TClonesArray *branchPhotonTrig, TClonesArray *branchETmisTrig) 176 197 { 198 199 TSimpleArray<TRootJet> bjets=SubArrayBjets(branchJetTrig); 200 TSimpleArray<TRootElectron> Ielectron=SubArrayIElec(branchElecTrig); 201 TSimpleArray<TRootMuon> Imuon=SubArrayIMuon(branchMuonTrig); 202 177 203 int elec_size = ElecValues.size(); 204 int Ielec_size = IElecValues.size(); 178 205 int muon_size = MuonValues.size(); 206 int Imuon_size = IMuonValues.size(); 179 207 int jet_size = JetValues.size(); 208 int bjet_size = BjetValues.size(); 180 209 int taujet_size = TauJetValues.size(); 181 210 int gamma_size = GammaValues.size(); … … 185 214 if( 186 215 (branchElecTrig->GetEntries() >= elec_size ) 216 && (Ielectron.GetEntries() >= Ielec_size ) 187 217 && (branchMuonTrig->GetEntries() >= muon_size ) 218 && (Imuon.GetEntries() >= Imuon_size ) 188 219 && (branchJetTrig->GetEntries() >= jet_size ) 220 && (bjets.GetEntries() >= bjet_size ) 189 221 && (branchTauJetTrig->GetEntries() >= taujet_size ) 190 222 && (branchPhotonTrig->GetEntries() >= gamma_size ) … … 198 230 if(electron->PT < ElecValues[i])Result=false;}} 199 231 232 if(Ielec_size!=0) 233 { 234 TRootElectron *i_elec; Ielectron.Reset(); 235 int i=0; 236 while((i_elec = Ielectron.Next())) 237 { 238 if(i_elec->PT < IElecValues[i])Result=false; 239 i++; 240 } 241 } 242 243 200 244 if(muon_size!=0){ 201 245 TRootMuon *muon; … … 204 248 if(muon->PT < MuonValues[i])Result=false;}} 205 249 250 if(Imuon_size!=0) 251 { 252 TRootMuon *i_muon; Imuon.Reset(); 253 int i=0; 254 while((i_muon = Imuon.Next())) 255 { 256 if(i_muon->PT < IMuonValues[i])Result=false; 257 i++; 258 } 259 } 260 206 261 if(jet_size!=0){ 207 262 TRootJet *jet; … … 209 264 jet = (TRootJet*)branchJetTrig->At(i); 210 265 if(jet->PT < JetValues[i])Result=false;}} 266 267 if(jet_size!=0){ 268 TRootJet *jet; 269 for(int i=0;i<jet_size;i++){ 270 jet = (TRootJet*)branchJetTrig->At(i); 271 if(jet->PT < JetValues[i])Result=false;}} 272 273 if(bjet_size!=0) 274 { 275 TRootJet *i_bjets; bjets.Reset(); 276 int i=0; 277 while((i_bjets = bjets.Next())) 278 { 279 if(i_bjets->PT < BjetValues[i])Result=false; 280 i++; 281 } 282 } 283 211 284 212 285 if(taujet_size!=0){ … … 234 307 235 308 vector<string> ElecSequences; 309 vector<string> IElecSequences; 236 310 vector<string> MuonSequences; 311 vector<string> IMuonSequences; 237 312 vector<string> JetSequences; 238 313 vector<string> TauJetSequences; 239 314 vector<string> EtmisSequences; 240 315 vector<string> GammaSequences; 241 242 char *result = NULL; 316 vector<string> BjetSequences; 317 318 /// char *result =NULL; 319 char * result = new char[256]; 243 320 result = strtok( (char*) trigger_algorithm.c_str(),"&"); 244 321 while( result != NULL ) 245 322 { 246 323 if(strstr (result,"ELEC"))ElecSequences.push_back(result); 324 if(strstr (result,"IElec"))IElecSequences.push_back(result); 247 325 if(strstr (result,"MUON"))MuonSequences.push_back(result); 326 if(strstr (result,"IMuon"))IMuonSequences.push_back(result); 248 327 if(strstr (result,"JET"))JetSequences.push_back(result); 249 if(strstr (result,"TAU JET"))TauJetSequences.push_back(result);328 if(strstr (result,"TAU"))TauJetSequences.push_back(result); 250 329 if(strstr (result,"ETMIS"))EtmisSequences.push_back(result); 251 330 if(strstr (result,"GAMMA"))GammaSequences.push_back(result); 331 if(strstr (result,"Bjet"))BjetSequences.push_back(result); 252 332 result = strtok( NULL,"&"); 253 333 } 334 delete result; 254 335 255 336 ElecValues = GetCuts(ElecSequences); 337 IElecValues = GetCuts(IElecSequences); 256 338 MuonValues = GetCuts(MuonSequences); 339 IMuonValues = GetCuts(IMuonSequences); 257 340 JetValues = GetCuts(JetSequences); 258 341 TauJetValues = GetCuts(TauJetSequences); 259 342 EtmisValues = GetCuts(EtmisSequences); 260 343 GammaValues = GetCuts(GammaSequences); 261 262 } 263 344 BjetValues = GetCuts(BjetSequences); 345 346 } 264 347 265 348 void TriggerBit::PrintTrigCondition(const string& LogName,const int i) 266 349 { 267 350 int elec_size = TriggerBit::ElecValues.size(); 351 int Ielec_size = TriggerBit::IElecValues.size(); 268 352 int muon_size = TriggerBit::MuonValues.size(); 353 int Imuon_size = TriggerBit::IMuonValues.size(); 269 354 int jet_size = TriggerBit::JetValues.size(); 270 355 int taujet_size = TriggerBit::TauJetValues.size(); 271 356 int gamma_size = TriggerBit::GammaValues.size(); 272 357 int etmis_size = TriggerBit::EtmisValues.size(); 358 int bjets_size = TriggerBit::BjetValues.size(); 273 359 274 360 ofstream f_out(LogName.c_str(),ios::app); … … 279 365 f_out <<"#*************************"<<"\n"; 280 366 f_out << left << setw(45) <<"* # Number of reconstructed objects required:"<<""<<right << setw(23)<<"*"<<"\n"; 281 f_out << left << setw(1) <<"*" 282 << internal << setw(10) << "Electron"<< ""<< internal << setw(10) << "Muon" << "" 283 << internal << setw(10) << "Jets" << ""<< internal << setw(10) << "Tau-jets "<< "" 284 << internal << setw(10) << "Photons" << ""<< internal << setw(10) << "ETmis "<< ""<< right << setw(9) <<"*"<<"\n"; 285 f_out << left << setw(1) <<"*" 286 << internal << setw(10) << elec_size << ""<< internal << setw(10) << muon_size << "" 287 << internal << setw(10) << jet_size << ""<< internal << setw(10) << taujet_size << "" 288 << internal << setw(10) << gamma_size<< ""<< internal << setw(10) << etmis_size << ""<< right << setw(9)<<"*"<<"\n"; 289 f_out << left << setw(45) <<"* # Values of the related thresholds: "<<""<<right << setw(25)<<"*"<<"\n"; 367 290 368 if(elec_size!=0){ 291 f_out << left << setw( 20) <<"* - Electrons: "<<"";369 f_out << left << setw(5) <<"** -"<<""<< left << setw(2) << elec_size <<""<< left << setw(20)<<"Electron(s) with p_T: "<<""; 292 370 for(int i=0;i<elec_size;i++){f_out << left << setw(5) << TriggerBit::ElecValues[i]<<"";}f_out <<"\n";} 293 371 372 if(Ielec_size!=0){ 373 f_out << left << setw(5) <<"** -"<<""<< left << setw(2) << Ielec_size <<""<< left << setw(20)<<"Isolated electron(s) with p_T: "<<""; 374 for(int i=0;i<Ielec_size;i++){f_out << left << setw(5) << TriggerBit::IElecValues[i]<<"";}f_out <<"\n";} 375 294 376 if(muon_size!=0){ 295 f_out << left << setw( 20) <<"* - Muons: "<<"";377 f_out << left << setw(5) <<"** -"<<""<< left << setw(2) << muon_size <<""<< left << setw(20)<<"Muon(s) with p_T: "<<""; 296 378 for(int i=0;i<muon_size;i++){f_out << left << setw(5) << TriggerBit::MuonValues[i]<<"";}f_out <<"\n";} 297 379 380 if(Imuon_size!=0){ 381 f_out << left << setw(5) <<"** -"<<""<< left << setw(2) << Imuon_size <<""<< left << setw(20)<<"Isolated muon(s) with p_T: "<<""; 382 for(int i=0;i<Imuon_size;i++){f_out << left << setw(5) << TriggerBit::IMuonValues[i]<<"";}f_out <<"\n";} 383 298 384 if(jet_size!=0){ 299 f_out << left << setw( 20) <<"* - Jets: "<<"";385 f_out << left << setw(5) <<"** -"<<""<< left << setw(2) << jet_size <<""<< left << setw(20)<<"Jet(s) with p_T: "<<""; 300 386 for(int i=0;i<jet_size;i++){f_out << left << setw(5) << TriggerBit::JetValues[i]<<"";}f_out <<"\n";} 301 387 302 388 if(taujet_size!=0){ 303 f_out << left << setw( 20) <<"* - Tau-jets: "<<"";389 f_out << left << setw(5) <<"** -"<<""<< left << setw(2) << taujet_size <<""<< left << setw(20)<<"Tau-jet(s) with p_T: "<<""; 304 390 for(int i=0;i<taujet_size;i++){f_out << left << setw(5) << TriggerBit::TauJetValues[i]<<"";}f_out <<"\n";} 305 391 392 if(bjets_size!=0){ 393 f_out << left << setw(5) <<"** -"<<""<< left << setw(2) << bjets_size <<""<< left << setw(20)<<"B-jet(s) with p_T: "<<""; 394 for(int i=0;i<bjets_size;i++){f_out << left << setw(5) << TriggerBit::BjetValues[i]<<"";}f_out <<"\n";} 395 306 396 if(gamma_size!=0){ 307 f_out << left << setw( 20) <<"* - Photons: "<<"";397 f_out << left << setw(5) <<"** -"<<""<< left << setw(2) << gamma_size <<""<< left << setw(20)<<"Photon(s) with p_T: "<<""; 308 398 for(int i=0;i<gamma_size;i++){f_out << left << setw(5) << TriggerBit::GammaValues[i]<<"";}f_out <<"\n";} 309 399 310 400 if(etmis_size!=0){ 311 f_out << left << setw( 20) <<"* - ETMIS: "<<"";401 f_out << left << setw(5) <<"** -"<<""<< left << setw(20)<<"Transverse missing energy with p_T: "<<""; 312 402 for(int i=0;i<etmis_size;i++){f_out << left << setw(5) << TriggerBit::EtmisValues[i]<<"";}f_out <<"\n";} 313 403 f_out <<"* *"<<"\n"; … … 328 418 } 329 419 return OrderedValue; 330 331 } 332 333 420 } 421 422 TSimpleArray<TRootJet> TriggerBit::SubArrayBjets(TClonesArray *JET) 423 { 424 TIter itJet((TCollection*)JET); 425 TRootJet *jet; 426 itJet.Reset(); 427 TSimpleArray<TRootJet> array; 428 while( (jet = (TRootJet*) itJet.Next()) ) 429 { 430 if(jet->Btag==1)array.Add(jet); 431 } 432 return array; 433 } 434 435 TSimpleArray<TRootElectron> TriggerBit::SubArrayIElec(TClonesArray *ELEC) 436 { 437 TIter itElec((TCollection*)ELEC); 438 TRootElectron *electron; 439 itElec.Reset(); 440 TSimpleArray<TRootElectron> array; 441 while( (electron = (TRootElectron*) itElec.Next()) ) 442 { 443 if(electron->IsolFlag==1)array.Add(electron); 444 } 445 return array; 446 } 447 448 TSimpleArray<TRootMuon> TriggerBit::SubArrayIMuon(TClonesArray *MUON) 449 { 450 TIter itMuon((TCollection*)MUON); 451 TRootMuon *muon; 452 itMuon.Reset(); 453 TSimpleArray<TRootMuon> array; 454 while( (muon = (TRootMuon*) itMuon.Next()) ) 455 { 456 if(muon->IsolFlag==1)array.Add(muon); 457 } 458 return array; 459 } 460 461
Note:
See TracChangeset
for help on using the changeset viewer.