Changeset 63 in svn
- Timestamp:
- Dec 2, 2008, 9:50:08 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Delphes.cpp
r59 r63 29 29 #include "interface/VeryForward.h" 30 30 #include "interface/JetUtils.h" 31 32 #include "Utilities/FROG/Examples/Sim_Delphes/FrogUtil.h" 31 33 32 34 #include <vector> … … 93 95 DET->Logfile(LogName); 94 96 97 95 98 //Trigger information 96 Trigger *TRIG = new Trigger(); 97 TRIG->TriggerReader("data/trigger.dat"); 99 TriggerTable *TRIGT = new TriggerTable(); 100 TRIGT->TriggerCardReader("data/trigger.dat"); 101 TRIGT->PrintTriggerTable(LogName); 102 //outputFile->Close(); 103 98 104 99 105 //Propagation of tracks in the B field … … 227 233 { 228 234 genMomentum.SetPxPyPzE(particle->Px, particle->Py, particle->Pz, particle->E); 235 //cout<<"avant "<<genMomentum.Pt()<<endl; 229 236 TRACP->Propagation(particle,genMomentum); 237 //cout<<"apres "<<genMomentum.Pt()<<endl; 230 238 float eta=fabs(genMomentum.Eta()); 231 239 switch(pid) { … … 234 242 DET->SmearElectron(genMomentum); 235 243 electron.push_back(genMomentum); 244 // cout<<"apres le smearing "<<genMomentum.Pt()<<endl; 245 236 246 elecPID.push_back(particle->PID); 237 247 break; // case pE … … 267 277 // back of the input_particles vector 268 278 input_particles.push_back(fastjet::PseudoJet(genMomentum.Px(),genMomentum.Py(),genMomentum.Pz(), genMomentum.E())); 269 279 // cout<<"on remplie avec "<<pid<<" Pt "<<genMomentum.Pt()<<" Eta "<<genMomentum.Eta()<<" Phi "<<genMomentum.Eta()<<endl; 280 270 281 genMomentumCalo.SetPxPyPzE(CaloTower.fourVector.px,CaloTower.fourVector.py,CaloTower.fourVector.pz,CaloTower.fourVector.E); 271 282 elementCalo = (TRootCalo*) branchCalo->NewEntry(); … … 300 311 301 312 } // while 302 313 // cout<<"*************"<<endl; 303 314 for(unsigned int i=0; i < electron.size(); i++) { 304 315 if(electron[i].E()!=0 && fabs(electron[i].Eta()) < DET->MAX_TRACKER && electron[i].Pt() > DET->ELEC_pt) -
trunk/interface/TriggerUtil.h
r52 r63 12 12 */ 13 13 14 /// \file SmearUtil.h15 /// \brief RESOLution class, and some generic definitions16 17 18 14 #include <vector> 19 15 #include "TLorentzVector.h" … … 24 20 using namespace std; 25 21 26 class Trigger 27 { 22 class TriggerBit { 23 28 24 public: 29 /// Constructor30 Trigger();31 25 32 vector<int> GetCuts(const vector<string> &Sequences); 26 TriggerBit(); 27 ~TriggerBit() {}; 33 28 34 void getTrigCondition(const std::string& trigger_algorithm);29 void GetTrigCondition(const std::string& trigger_algorithm); 35 30 36 void TriggerReader(const string filename="data/trigger.dat"); 31 void PrintTrigCondition(string LogName,int i); 32 33 bool GetResult() { 34 if(!has_been_evaluated) Evaluate(event_i); 35 return Result; 36 }; 37 38 private: 39 bool Evaluate(int event_i); // <- à la fin, mettre has_been_evaluated=true; 40 41 vector<float> GetCuts(const vector<string> &Sequences); 42 vector<float> ElecValues; 43 vector<float> MuonValues; 44 vector<float> JetValues; 45 vector<float> TauJetValues; 46 vector<float> EtmisValues; 47 vector<float> GammaValues; 48 bool Result; 49 int event_i; 50 bool has_been_evaluated; 51 }; 52 53 54 class TriggerTable { 55 56 public: 57 58 TriggerTable(); 59 ~TriggerTable() {}; 60 61 void TriggerCardReader(const string filename="data/trigger.dat"); 62 // avant, ça s'appellait TriggerReader 63 // appelle la méthode TriggerBit::GetTrigCondition 64 65 66 void PrintTriggerTable(string LogName); 67 // fait un cout des triggers bits, c'est toujours pratique 68 // appelle la méthode TriggerBit::PriniTrigCondition 69 70 71 bool GetGlobalResult() { 72 if (! has_been_evaluated) Evaluate(event_i); 73 return GlobalResult; 74 } 75 76 void WriteResult(); 77 // sauve dans le TTree 78 // ce nom est stupide, faut le changer 79 int event_i; 80 81 private: 82 bool Evaluate( int event_i ); 83 // boucle sur list_of_trigger_bits, comme on a dit 84 // appelle la methode TriggerBit::Evaluate ou TriggerBit::GetResult (à voir) 85 // renvoie la réponse globale du trigger 86 // à la fin, mettre has_been_evaluated = true; 87 // voir le NB ci-dessous 88 89 vector<TriggerBit> list_of_trigger_bits; 90 bool has_been_evaluated; 91 bool GlobalResult; 37 92 38 93 }; -
trunk/src/TriggerUtil.cc
r52 r63 22 22 using namespace std; 23 23 24 Trigger::Trigger() {} 24 TriggerTable::TriggerTable() { 25 has_been_evaluated=false; 26 } 25 27 26 vector<int> Trigger::GetCuts(const vector<string> &Sequences) 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) 27 104 { 28 vector<int> OrderedValue; 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; 29 160 string ptVal; 30 161 Int_t PtVal=0; … … 38 169 } 39 170 40 void Trigger::getTrigCondition(const string& trigger_algorithm) {41 42 vector<string> ElecSequences;43 vector<string> MuonSequences;44 vector<string> JetSequences;45 vector<string> TauJetSequences;46 vector<string> EtmisSequences;47 vector<string> GammaSequences;48 49 char *result = NULL;50 result = strtok( (char*) trigger_algorithm.c_str(),"&");51 while( result != NULL )52 {53 if(strstr (result,"ELEC"))ElecSequences.push_back(result);54 if(strstr (result,"MUON"))MuonSequences.push_back(result);55 if(strstr (result,"JET"))JetSequences.push_back(result);56 if(strstr (result,"TAUJET"))TauJetSequences.push_back(result);57 if(strstr (result,"ETMIS"))EtmisSequences.push_back(result);58 if(strstr (result,"GAMMA"))GammaSequences.push_back(result);59 result = strtok( NULL,"&");60 }61 62 vector<int> ElecValues = GetCuts(ElecSequences);63 vector<int> MuonValues = GetCuts(MuonSequences);64 vector<int> JetValues = GetCuts(JetSequences);65 vector<int> TauJetValues = GetCuts(TauJetSequences);66 vector<int> EtmisValues = GetCuts(EtmisSequences);67 vector<int> GammaValues = GetCuts(GammaSequences);68 171 69 }70 71 void Trigger::TriggerReader(const string filename) {72 ifstream trigger_file(filename.c_str());73 if( !trigger_file.good() ) {74 cout << "ERROR: Trigger input file "<< filename << " not found. Exiting.\n";75 return;76 }77 78 string temp_string, temp_string_no_comment, trigger_name, trigger_algorithm;79 while ( getline(trigger_file,temp_string) ) {80 string temp_string_no_comment = temp_string.substr(0,temp_string.find("#")); //remove comments81 if(temp_string_no_comment.size()<2) continue; // avoid empty lines82 istringstream temp_stream(temp_string_no_comment);83 84 temp_stream >> trigger_name;85 trigger_algorithm = temp_string_no_comment.substr( temp_string_no_comment.find(">>")+2) ;86 87 getTrigCondition(trigger_algorithm);88 }89 }90
Note:
See TracChangeset
for help on using the changeset viewer.