Changeset 63 in svn for trunk/src/TriggerUtil.cc
- Timestamp:
- Dec 2, 2008, 9:50:08 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.