/* * ---- Delphes ---- * A Fast Simulator for general purpose LHC detector * S. Ovyn ~~~~ severine.ovyn@uclouvain.be * * Center for Particle Physics and Phenomenology (CP3) * Universite Catholique de Louvain (UCL) * Louvain-la-Neuve, Belgium * */ // \brief Trigger class, and some generic definitions #include "TriggerUtil.h" #include #include #include #include #include using namespace std; TriggerTable::TriggerTable() { has_been_evaluated=false; } TriggerTable& TriggerTable::operator=(TriggerTable&tt) { if (this == &tt) return *this; event_i = tt.event_i; has_been_evaluated = tt.has_been_evaluated; GlobalResult = tt.GlobalResult; for (unsigned int i=0; i> trigger_name; trigger_algorithm = temp_string_no_comment.substr( temp_string_no_comment.find(">>")+2) ; mybit.TriggerBit::GetTrigCondition(trigger_algorithm); list_of_trigger_bits.push_back(mybit); } } void TriggerTable::PrintTriggerTable(const string& LogName) { ofstream f_out(LogName.c_str(),ios::app); f_out<<"* *"<<"\n"; f_out<<"#*********************************************** *"<<"\n"; f_out<<"# Trigger conditions defined in the trigger card *"<<"\n"; f_out<<"#*********************************************** *"<<"\n"; f_out<<"* *"<<"\n"; f_out.close(); for(unsigned int i=0; i < list_of_trigger_bits.size(); i++) { list_of_trigger_bits[i].PrintTrigCondition(LogName,i+1); } f_out<<"* *"<<"\n"; f_out<<"#*********************************************************************"<<"\n"; } bool TriggerTable::GetGlobalResult(TClonesArray *branchElecTrig, TClonesArray *branchMuonTrig, TClonesArray *branchJetTrig, TClonesArray *branchTauJetTrig, TClonesArray *branchPhotonTrig, TClonesArray *branchETmisTrig, ExRootTreeBranch *branchTrigger) { TRootTrigger *elementTrigger; GlobalResult=false; for(unsigned int i=0; i < list_of_trigger_bits.size(); i++) { if(list_of_trigger_bits[i].GetResult(branchElecTrig, branchMuonTrig, branchJetTrig, branchTauJetTrig, branchPhotonTrig, branchETmisTrig)) { GlobalResult=true; int flag=i+1; elementTrigger = (TRootTrigger*) branchTrigger->NewEntry(); elementTrigger->Accepted=flag; } } if(GlobalResult) { elementTrigger = (TRootTrigger*) branchTrigger->NewEntry(); elementTrigger->Accepted=0; } return GlobalResult; } //************************************************************************* TriggerBit::TriggerBit() { } TriggerBit::~TriggerBit() { ElecValues.clear(); MuonValues.clear(); JetValues.clear(); TauJetValues.clear(); EtmisValues.clear(); GammaValues.clear(); } TriggerBit::TriggerBit(const TriggerBit& tb) { for(unsigned int i=0; iGetEntries() >= elec_size ) && (branchMuonTrig->GetEntries() >= muon_size ) && (branchJetTrig->GetEntries() >= jet_size ) && (branchTauJetTrig->GetEntries() >= taujet_size ) && (branchPhotonTrig->GetEntries() >= gamma_size ) ) { Result=true; if(elec_size!=0){ TRootElectron *electron; for(int i=0;iAt(i); if(electron->PT < ElecValues[i])Result=false;}} if(muon_size!=0){ TRootMuon *muon; for(int i=0;iAt(i); if(muon->PT < MuonValues[i])Result=false;}} if(jet_size!=0){ TRootJet *jet; for(int i=0;iAt(i); if(jet->PT < JetValues[i])Result=false;}} if(taujet_size!=0){ TRootTauJet *taujet; for(int i=0;iAt(i); if(taujet->PT < TauJetValues[i])Result=false;}} if(gamma_size!=0){ TRootPhoton *gamma; for(int i=0;iAt(i); if(gamma->PT < GammaValues[i])Result=false;}} if(etmis_size!=0){ TRootETmis *etmis = (TRootETmis*)branchETmisTrig->At(0); if(etmis->ET < EtmisValues[0])Result=false;} } return Result; } void TriggerBit::GetTrigCondition(const string& trigger_algorithm) { vector ElecSequences; vector MuonSequences; vector JetSequences; vector TauJetSequences; vector EtmisSequences; vector GammaSequences; char *result = NULL; result = strtok( (char*) trigger_algorithm.c_str(),"&"); while( result != NULL ) { if(strstr (result,"ELEC"))ElecSequences.push_back(result); if(strstr (result,"MUON"))MuonSequences.push_back(result); if(strstr (result,"JET"))JetSequences.push_back(result); if(strstr (result,"TAUJET"))TauJetSequences.push_back(result); if(strstr (result,"ETMIS"))EtmisSequences.push_back(result); if(strstr (result,"GAMMA"))GammaSequences.push_back(result); result = strtok( NULL,"&"); } ElecValues = GetCuts(ElecSequences); MuonValues = GetCuts(MuonSequences); JetValues = GetCuts(JetSequences); TauJetValues = GetCuts(TauJetSequences); EtmisValues = GetCuts(EtmisSequences); GammaValues = GetCuts(GammaSequences); } void TriggerBit::PrintTrigCondition(const string& LogName,const int i) { int elec_size = TriggerBit::ElecValues.size(); int muon_size = TriggerBit::MuonValues.size(); int jet_size = TriggerBit::JetValues.size(); int taujet_size = TriggerBit::TauJetValues.size(); int gamma_size = TriggerBit::GammaValues.size(); int etmis_size = TriggerBit::EtmisValues.size(); ofstream f_out(LogName.c_str(),ios::app); f_out <<"* *"<<"\n"; f_out << left << setw(25) <<"# Trigger bit number "<<"" << left << setw(35) < TriggerBit::GetCuts(const vector &Sequences) { vector OrderedValue; string ptVal; Int_t PtVal=0; for(unsigned int i=0; i < Sequences.size(); i++) { ptVal = Sequences[i].substr( Sequences[i].find("'")+1) ; PtVal = atoi( ptVal.c_str() ); OrderedValue.push_back(PtVal); } return OrderedValue; }