CMS 3D CMS Logo

Functions
egHLT::trigTools Namespace Reference

Functions

template<class T , class U >
void fillHLTposition (T &obj, U &hltData, const std::vector< std::string > &filters, const trigger::TriggerEvent *trigEvt, const std::string &hltTag)
 
void filterInactiveTightLooseTriggers (std::vector< std::string > &namesToFilter, const std::vector< std::string > &activeFilters)
 
void filterInactiveTriggers (std::vector< std::string > &namesToFilter, std::vector< std::string > &activeFilters)
 
void getActiveFilters (const HLTConfigProvider &hltConfig, std::vector< std::string > &activeFilters, std::vector< std::string > &activeEleFilters, std::vector< std::string > &activeEle2LegFilters, std::vector< std::string > &activePhoFilters, std::vector< std::string > &activePho2LegFilters)
 
float getEtThresFromName (const std::string &trigName)
 
TrigCodes::TrigBitSet getFiltersPassed (const std::vector< std::pair< std::string, int > > &filters, const trigger::TriggerEvent *trigEvt, const std::string &hltTag, const TrigCodes &trigCodes)
 
std::string getL1SeedFilterOfPath (const HLTConfigProvider &hltConfig, const std::string &path)
 
std::vector< int > getMinNrObjsRequiredByFilter (const std::vector< std::string > &filterName)
 
float getSecondEtThresFromName (const std::string &trigName)
 
template<class T >
void setFiltersObjPasses (std::vector< T > &objs, const std::vector< std::string > &filters, const std::vector< std::pair< std::string, std::string > > &l1PreAndSeedFilters, const TrigCodes::TrigBitSet &evtTrigBits, const TrigCodes &trigCodes, const trigger::TriggerEvent *trigEvt, const std::string &hltTag)
 
void translateFiltersToPathNames (const HLTConfigProvider &hltConfig, const std::vector< std::string > &filters, std::vector< std::string > &paths)
 

Function Documentation

template<class T , class U >
void egHLT::trigTools::fillHLTposition ( T obj,
U &  hltData,
const std::vector< std::string > &  filters,
const trigger::TriggerEvent trigEvt,
const std::string &  hltTag 
)

Definition at line 104 of file EgHLTTrigTools.h.

References reco::deltaR(), ALCARECOTkAlBeamHalo_cff::filter, trigger::TriggerEvent::filterIndex(), trigger::TriggerEvent::filterKeys(), trigger::TriggerEvent::getObjects(), and electrons_cff::maxDeltaR.

Referenced by egHLT::OffHelper::fillHLTData(), and egHLT::OffHelper::fillHLTDataPho().

109 {
110  std::vector<TrigCodes::TrigBitSet> partTrigBits(1);
111  const double maxDeltaR=0.1;
112  for(const auto & filter : filters){
113  size_t filterNrInEvt = trigEvt->filterIndex(edm::InputTag(filter,"",hltTag));
114  //const TrigCodes::TrigBitSet filterCode = trigCodes.getCode(filters[filterNrInVec].c_str());
115  if(filterNrInEvt<trigEvt->sizeFilters()){ //filter found in event, something passes it
116  const trigger::Keys& trigKeys = trigEvt->filterKeys(filterNrInEvt); //trigger::Keys is actually a vector<uint16_t> holding the position of trigger objects in the trigger collection passing the filter
117  const trigger::TriggerObjectCollection & trigObjColl(trigEvt->getObjects());
118  for(unsigned short trigKey : trigKeys){
119  float trigObjEta = trigObjColl[trigKey].eta();
120  float trigObjPhi = trigObjColl[trigKey].phi();
121  float trigObjE = trigObjColl[trigKey].energy();
122  if (reco::deltaR(particle.superCluster()->eta(),particle.superCluster()->phi(),trigObjEta,trigObjPhi) < maxDeltaR){
123  hltData.HLTeta=trigObjEta;
124  hltData.HLTphi=trigObjPhi;
125  hltData.HLTenergy=trigObjE;
126  }//end dR<maxDeltaR trig obj match test
127  }//end loop over all objects passing filter`
128  }//end check if filter is present
129  }//end check if path has fired in the event
130 }//end loop over all filters
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:111
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:123
std::vector< TPRegexp > filters
Definition: eve_filter.cc:22
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:98
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
std::vector< size_type > Keys
void egHLT::trigTools::filterInactiveTightLooseTriggers ( std::vector< std::string > &  namesToFilter,
const std::vector< std::string > &  activeFilters 
)

Definition at line 238 of file EgHLTTrigTools.cc.

References names, split, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by EgHLTOfflineClient::beginRun(), and EgHLTOfflineSource::filterTriggers().

239 {
240  //tempory vector to store the filtered results
241  std::vector<std::string> filteredNames;
242 
243  for(auto & inputFilterNr : namesToFilter){
244  std::vector<std::string> names;
245  boost::split(names,inputFilterNr,boost::is_any_of(std::string(":")));
246  if(names.size()!=2) continue; //format incorrect, reject it
247  if(std::binary_search(activeFilters.begin(),activeFilters.end(),names[0]) &&
248  std::binary_search(activeFilters.begin(),activeFilters.end(),names[1])){ //both filters are valid
249  filteredNames.push_back(inputFilterNr);
250  }
251  }
252 
253  namesToFilter.swap(filteredNames);
254 }
const std::string names[nVars_]
double split
Definition: MVATrainer.cc:139
void egHLT::trigTools::filterInactiveTriggers ( std::vector< std::string > &  namesToFilter,
std::vector< std::string > &  activeFilters 
)

Definition at line 221 of file EgHLTTrigTools.cc.

Referenced by EgHLTOfflineSummaryClient::beginRun(), EgHLTOfflineClient::beginRun(), and EgHLTOfflineSource::filterTriggers().

222 {
223  //tempory vector to store the filtered results
224  std::vector<std::string> filteredNames;
225  /*
226  for(size_t inputFilterNr=0;inputFilterNr<namesToFilter.size();inputFilterNr++){
227  if(std::binary_search(activeFilters.begin(),activeFilters.end(),namesToFilter[inputFilterNr])){
228  filteredNames.push_back(namesToFilter[inputFilterNr]);
229  }//std::cout<<filteredNames[inputFilterNr]<<std::endl;
230  }
231  */
232  //namesToFilter.swap(activeFilters);
233  filteredNames = activeFilters;
234  namesToFilter.swap(filteredNames);
235 }
void egHLT::trigTools::getActiveFilters ( const HLTConfigProvider hltConfig,
std::vector< std::string > &  activeFilters,
std::vector< std::string > &  activeEleFilters,
std::vector< std::string > &  activeEle2LegFilters,
std::vector< std::string > &  activePhoFilters,
std::vector< std::string > &  activePho2LegFilters 
)

Definition at line 125 of file EgHLTTrigTools.cc.

References ALCARECOTkAlBeamHalo_cff::filter, filters, spr::find(), getMinNrObjsRequiredByFilter(), HLTConfigProvider::saveTagsModules(), HLTConfigProvider::size(), AlCaHLTBitMon_QueryRunRegistry::string, and HLTConfigProvider::triggerName().

Referenced by EgHLTOfflineSummaryClient::beginRun(), EgHLTOfflineClient::beginRun(), and EgHLTOfflineSource::filterTriggers().

126 {
127 
128  activeFilters.clear();
129  activeEleFilters.clear();
130  activeEle2LegFilters.clear();
131  activePhoFilters.clear();
132  activePho2LegFilters.clear();
133 
134  for(size_t pathNr=0;pathNr<hltConfig.size();pathNr++){
135  const std::string& pathName = hltConfig.triggerName(pathNr);
136 
137  if(pathName.find("HLT_")==0){ //hlt path as they all start with HLT_XXXX
138  if((pathName.find("Photon")==4 || pathName.find("Ele")==4 || pathName.find("EG")!=pathName.npos
139  || pathName.find("PAPhoton")==4 || pathName.find("PAEle")==4 || pathName.find("PASinglePhoton")==4
140  || pathName.find("HIPhoton")==4 || pathName.find("HIEle")==4 || pathName.find("HISinglePhoton")==4
141  || pathName.find("Activity")==4 || pathName.find("Physics")==4 || pathName.find("DiSC") == 4)
142  && (pathName.find("Jet")==pathName.npos && pathName.find("Muon")==pathName.npos
143  && pathName.find("Tau")==pathName.npos && pathName.find("HT")==pathName.npos
144  && pathName.find("MR")==pathName.npos && pathName.find("LEITI")==pathName.npos
145  && pathName.find("Jpsi")==pathName.npos && pathName.find("Ups")==pathName.npos ) ){//veto x-triggers
146  //std::string lastFilter;
147  const std::vector<std::string>& filters = hltConfig.saveTagsModules(pathNr);
148 
149  //std::cout<<"Number of prescale sets: "<<hltConfig.prescaleSize()<<std::endl;
150  //std::cout<<std::endl<<"Path Name: "<<pathName<<" Prescale: "<<hltConfig.prescaleValue(1,pathName)<<std::endl;
151 
152  if(!filters.empty()){
153  //std::cout<<"Path Name: "<<pathName<<std::endl;
154  //if(filters.back()=="hltBoolEnd" && filters.size()>=2){
155  std::vector< int> minNRFFCache=getMinNrObjsRequiredByFilter(filters);
156 
157  for(size_t filter=0;filter<filters.size();filter++){
158  //std::cout << filters[filter] << std::endl;
159  if(filters[filter].find("Filter")!=filters[filter].npos){//keep only modules that contain the word "Filter"
160  //std::cout<<" Module Name: "<<filters[filter]<<" filter#: "<<int(filter)<<"/"<<filters.size()<<" ncandcut: "<<trigTools::getMinNrObjsRequiredByFilter(filters[filter])<<std::endl;
161  int minNRFF=minNRFFCache[filter];
162  int minNRFFP1=-99;
163  if ( filter<filters.size()-1) minNRFFP1=minNRFFCache[filter+1];
164  if(//keep only the last filter and the last one with ncandcut==1 (for di-object triggers)
165  ( minNRFF==1 && minNRFFP1==2)
166  || (minNRFF==1 && minNRFFP1==1 && filters[filter+1].find("Mass")!=filters[filter+1].npos)
167  || (minNRFF==1 && minNRFFP1==1 && filters[filter+1].find("FEM")!=filters[filter+1].npos)
168  || (minNRFF==1 && minNRFFP1==1 && filters[filter+1].find("PFMT")!=filters[filter+1].npos)
169  || filter==filters.size()-1 ){
170  activeFilters.push_back(filters[filter]); //saves all modules with saveTags=true
171 
172  //std::cout<<" Module Name: "<<filters[filter]<<" filter#: "<<int(filter)<<"/"<<filters.size()<<" ncandcut: "<<trigTools::getMinNrObjsRequiredByFilter(filters[filter])<<std::endl;
173  if(pathName.find("Photon")!=pathName.npos || pathName.find("Activity")!=pathName.npos || pathName.find("Physics")!=pathName.npos || pathName.find("DiSC") == 4){
174  activePhoFilters.push_back(filters[filter]);//saves all "Photon" paths into photon set
175  int posPho = pathName.find("Pho")+1;
176  if( pathName.find("Pho",posPho)!=pathName.npos || pathName.find("SC",posPho)!=pathName.npos) {
177  //This saves all "x_Photon_x_Photon_x" and "x_Photon_x_SC_x" path filters into 2leg photon set
178  activePho2LegFilters.push_back(filters[filter]);
179  //std::cout<<"Pho2LegPath: "<<pathName<<std::endl;
180  }
181  }
182  if(pathName.find("Ele")!=pathName.npos || pathName.find("Activity")!=pathName.npos || pathName.find("Physics")!=pathName.npos ){
183  activeEleFilters.push_back(filters[filter]);//saves all "Ele" paths into electron set
184  int posEle = pathName.find("Ele")+1;
185  if( pathName.find("Ele",posEle)!=pathName.npos || pathName.find("SC",posEle)!=pathName.npos ){
186  if(
187  ( minNRFF==1 && minNRFFP1==2)
188  || ( minNRFF==1 && minNRFFP1==1 && filters[filter+1].find("Mass")!=filters[filter+1].npos)
189  || ( minNRFF==1 && minNRFFP1==1 && filters[filter+1].find("SC")!=filters[filter+1].npos)
190  || ( minNRFF==1 && minNRFFP1==1 && filters[filter+1].find("FEM")!=filters[filter+1].npos)
191  ){
192  //This saves all "x_Ele_x_Ele_x" and "x_Ele_x_SC_x" path filters into 2leg electron set
193  activeEle2LegFilters.push_back(filters[filter]+"::"+filters[filter+1]);
194  //std::cout<<"Ele2LegPath: "<<pathName<<std::endl;
195  }
196  }
197  }
198  }
199  }
200  }
201  //std::cout<<filters[filters.size()-2]<<std::endl;
202  //}else activeFilters.push_back(filters.back());
203  }
204  }
205  }//end hlt path check
206  }//end path loop over
207  /*for(size_t i=0;i<activeEle2LegFilters.size();i++){
208  std::cout<<"Leg1: "<<activeEle2LegFilters[i].substr(0,activeEle2LegFilters[i].find("::"))<<std::endl;
209  std::cout<<"Leg2: "<<activeEle2LegFilters[i].substr(activeEle2LegFilters[i].find("::")+2)<<std::endl<<std::endl;
210  }*/
211  std::sort(activeFilters.begin(),activeFilters.end());
212  std::sort(activeEleFilters.begin(),activeEleFilters.end());
213  std::sort(activeEle2LegFilters.begin(),activeEle2LegFilters.end());
214  std::sort(activePhoFilters.begin(),activePhoFilters.end());
215 }
unsigned int size() const
number of trigger paths in trigger table
const std::string & triggerName(unsigned int triggerIndex) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::vector< TPRegexp > filters
Definition: eve_filter.cc:22
const std::vector< std::string > & saveTagsModules(unsigned int trigger) const
std::vector< int > getMinNrObjsRequiredByFilter(const std::vector< std::string > &filterName)
float egHLT::trigTools::getEtThresFromName ( const std::string &  trigName)

Definition at line 318 of file EgHLTTrigTools.cc.

Referenced by egHLT::MonElemFuncs::addTightLooseTrigHist().

319 {
320  size_t etStrPos = trigName.find("Et");
321  while(etStrPos!=std::string::npos && trigName.find_first_of("1234567890",etStrPos)!=etStrPos+2){
322  etStrPos = trigName.find("Et",etStrPos+1);
323  }
324  if(etStrPos!=std::string::npos && trigName.find_first_of("1234567890",etStrPos)==etStrPos+2){
325  size_t endOfEtValStr = trigName.find_first_not_of("1234567890",etStrPos+2);
326 
327  std::istringstream etValStr(trigName.substr(etStrPos+2,endOfEtValStr-etStrPos-2));
328  float etVal;
329  etValStr>> etVal;
330  return etVal;
331 
332  }
333  return 0;
334 
335 }
TrigCodes::TrigBitSet egHLT::trigTools::getFiltersPassed ( const std::vector< std::pair< std::string, int > > &  filters,
const trigger::TriggerEvent trigEvt,
const std::string &  hltTag,
const TrigCodes trigCodes 
)

Definition at line 8 of file EgHLTTrigTools.cc.

References ALCARECOTkAlBeamHalo_cff::filter, trigger::TriggerEvent::filterIndex(), trigger::TriggerEvent::filterKeys(), filters, and egHLT::TrigCodes::getCode().

Referenced by egHLT::OffHelper::setTrigInfo().

13 {
14  TrigCodes::TrigBitSet evtTrigs;
15  for(auto const & filter : filters){
16  size_t filterNrInEvt = trigEvt->filterIndex(edm::InputTag(filter.first,"",hltTag));
17  const TrigCodes::TrigBitSet filterCode = trigCodes.getCode(filter.first.c_str());
18  if(filterNrInEvt<trigEvt->sizeFilters()){ //filter found in event, however this only means that something passed the previous filter
19  const trigger::Keys& trigKeys = trigEvt->filterKeys(filterNrInEvt);
20  if(static_cast<int>(trigKeys.size())>=filter.second){
21  evtTrigs |=filterCode; //filter was passed
22  }
23  }//end check if filter is present
24  }//end loop over all filters
25 
26 
27  return evtTrigs;
28 
29 }
TrigBitSet getCode(const char *descript) const
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:111
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:123
std::vector< TPRegexp > filters
Definition: eve_filter.cc:22
std::vector< size_type > Keys
std::bitset< maxNrBits_ > TrigBitSet
std::string egHLT::trigTools::getL1SeedFilterOfPath ( const HLTConfigProvider hltConfig,
const std::string &  path 
)

Definition at line 305 of file EgHLTTrigTools.cc.

References HLTConfigProvider::moduleLabels(), edm::moduleName(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by egHLT::OffHelper::setupTriggers().

306 {
307  const std::vector<std::string>& modules = hltConfig.moduleLabels(path);
308 
309  for(auto const & moduleName : modules){
310  if(moduleName.find("hltL1s")==0) return moduleName; //found l1 seed module
311  }
313  return dummy;
314 
315 }
std::string moduleName(Provenance const &provenance)
Definition: Provenance.cc:27
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
std::vector< int > egHLT::trigTools::getMinNrObjsRequiredByFilter ( const std::vector< std::string > &  filterName)

Definition at line 41 of file EgHLTTrigTools.cc.

References diMuonOutputModule_cfi::filterName, mps_fire::i, edm::pset::Registry::instance(), mag2(), AlCaHLTBitMon_QueryRunRegistry::string, and edm::Entry::toString().

Referenced by getActiveFilters(), and egHLT::OffHelper::setupTriggers().

42 {
43  std::vector<int> retVal(filterNames.size(),-2);
44  const std::string mag0("@module_label");
45  const std::string mag1("ncandcut");
46  const std::string mag2("nZcandcut");
47  const std::string mag3("MinN");
48  const std::string mag4("minN");
49 
50  std::vector<std::string> filterEntryStrings;
51  filterEntryStrings.reserve(filterNames.size());
52  for (auto const & filterName : filterNames) {
53  const edm::Entry filterEntry(mag0,filterName,true);
54  filterEntryStrings.push_back(filterEntry.toString());
55  }
56 
57  //will return out of for loop once its found it to save time
58  const edm::pset::Registry* psetRegistry = edm::pset::Registry::instance();
59  if(psetRegistry==nullptr) { retVal=std::vector<int>(filterNames.size(),-1); return retVal;}
60  for(auto & psetIt : *psetRegistry){ //loop over every pset for every module ever run
61  const std::map<std::string,edm::Entry>& mapOfPara = psetIt.second.tbl(); //contains the parameter name and value for all the parameters of the pset
62  const auto itToModLabel = mapOfPara.find(mag0);
63  if(itToModLabel!=mapOfPara.end()){
64  std::string itString=itToModLabel->second.toString();
65 
66  for ( unsigned int i=0; i<filterNames.size(); i++) {
67  if ( retVal[i] == -1 ) continue; //already done
68 
69  if(itString==filterEntryStrings[i]){ //moduleName is the filter name, we have found filter, we will now return something
70  auto itToCandCut = mapOfPara.find(mag1);
71  if(itToCandCut!=mapOfPara.end() && itToCandCut->second.typeCode()=='I') retVal[i]=itToCandCut->second.getInt32();
72  else{ //checks if nZcandcut exists and is int32, if not return -1
73  itToCandCut = mapOfPara.find(mag2);
74  if(itToCandCut!=mapOfPara.end() && itToCandCut->second.typeCode()=='I') retVal[i]=itToCandCut->second.getInt32();
75  else{ //checks if MinN exists and is int32, if not return -1
76  itToCandCut = mapOfPara.find(mag3);
77  if(itToCandCut!=mapOfPara.end() && itToCandCut->second.typeCode()=='I') retVal[i]=itToCandCut->second.getInt32();
78  else{ //checks if minN exists and is int32, if not return -1
79  itToCandCut = mapOfPara.find(mag4);
80  if(itToCandCut!=mapOfPara.end() && itToCandCut->second.typeCode()=='I') retVal[i]= itToCandCut->second.getInt32();
81  else retVal[i]=-1;
82  }
83  }
84  }
85  }
86  }
87  }
88  }
89  for ( unsigned int i=0; i<filterNames.size(); i++)
90  if ( retVal[i]==-2 ) retVal[i]=-1;
91  return retVal;
92 }
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
static Registry * instance()
Definition: Registry.cc:12
float egHLT::trigTools::getSecondEtThresFromName ( const std::string &  trigName)

Definition at line 339 of file EgHLTTrigTools.cc.

References jets_cff::isEle.

340 {//std::cout<<"What the heck is this trigName?:"<<trigName<<std::endl;
341  bool isEle=false,isPhoton=false,isEG=false,isEle2=false,isPhoton2=false,isEG2=false,isSC2=false;
342  size_t etStrPos = trigName.npos;
343  if( trigName.find("Ele")<trigName.find("Photon") && trigName.find("Ele")<trigName.find("EG") ){
344  etStrPos=trigName.find("Ele");isEle=true; }
345  else if( trigName.find("EG")<trigName.find("Photon") && trigName.find("EG")<trigName.find("Ele") ){
346  etStrPos=trigName.find("EG");isEG=true; }
347  else if( trigName.find("Photon")<trigName.find("Ele") && trigName.find("Photon")<trigName.find("EG") ){
348  etStrPos=trigName.find("Photon");isPhoton=true; }
349  //size_t etStrPos = trigName.find("Et");
350  //std::cout<<"Got Original Et spot; etStrPos="<<etStrPos<<std::endl;
351  /*while(etStrPos!=std::string::npos && trigName.find_first_of("1234567890",etStrPos)!=etStrPos+2){
352  etStrPos = trigName.find("Et",etStrPos+1);//std::cout<<"Got first Et spot; etStrPos="<<etStrPos<<std::endl;
353  }*/
354  if(etStrPos!=trigName.npos
355  && ( trigName.find("Ele",etStrPos+1)!=trigName.npos || trigName.find("EG",etStrPos+1)!=trigName.npos
356  || trigName.find("Photon",etStrPos+1)!=trigName.npos || trigName.find("SC",etStrPos+1)!=trigName.npos)){
357  if(trigName.find("Ele",etStrPos+1)<trigName.find("Photon",etStrPos+1) && trigName.find("Ele",etStrPos+1)<trigName.find("EG",etStrPos+1) && trigName.find("Ele",etStrPos+1)<trigName.find("SC",etStrPos+1) ){etStrPos=trigName.find("Ele",etStrPos+1);isEle2=true;}
358  else if(trigName.find("EG",etStrPos+1)<trigName.find("Photon",etStrPos+1) && trigName.find("EG",etStrPos+1)<trigName.find("Ele",etStrPos+1) && trigName.find("EG",etStrPos+1)<trigName.find("SC",etStrPos+1)){etStrPos=trigName.find("EG",etStrPos+1);isEG2=true;}
359  else if(trigName.find("Photon",etStrPos+1)<trigName.find("EG",etStrPos+1) && trigName.find("Photon",etStrPos+1)<trigName.find("Ele",etStrPos+1) && trigName.find("Photon",etStrPos+1)<trigName.find("SC",etStrPos+1)){etStrPos=trigName.find("Photon",etStrPos+1);isPhoton2=true;}
360  else if(trigName.find("SC",etStrPos+1)<trigName.find("EG",etStrPos+1) && trigName.find("SC",etStrPos+1)<trigName.find("Ele",etStrPos+1) && trigName.find("SC",etStrPos+1)<trigName.find("Photon",etStrPos+1)){etStrPos=trigName.find("Photon",etStrPos+1);isSC2=true;}
361  //std::cout<<"Got second Et spot; etStrPos="<<etStrPos<<std::endl;//}//get second instance. if it dne, keep first
362 
363  if(isEle2){
364  if(etStrPos!=trigName.npos && trigName.find_first_of("1234567890",etStrPos)==etStrPos+3){//std::cout<<"In if"<<std::endl;
365  size_t endOfEtValStr = trigName.find_first_not_of("1234567890",etStrPos+3);
366 
367  std::istringstream etValStr(trigName.substr(etStrPos+3,endOfEtValStr-etStrPos-3));
368  float etVal;
369  etValStr>> etVal;//std::cout<<"TrigName= "<<trigName<<" etVal= "<<etVal<<std::endl;
370  return etVal;
371  }
372  }
373  if(isEG2 || isSC2){
374  if(etStrPos!=trigName.npos && trigName.find_first_of("1234567890",etStrPos)==etStrPos+2){//std::cout<<"In if"<<std::endl;
375  size_t endOfEtValStr = trigName.find_first_not_of("1234567890",etStrPos+2);
376 
377  std::istringstream etValStr(trigName.substr(etStrPos+2,endOfEtValStr-etStrPos-2));
378  float etVal;
379  etValStr>> etVal;//std::cout<<"TrigName= "<<trigName<<" etVal= "<<etVal<<std::endl;
380  return etVal;
381  }
382  }
383 
384  if(isPhoton2){
385  if(etStrPos!=trigName.npos && trigName.find_first_of("1234567890",etStrPos)==etStrPos+6){//std::cout<<"In if"<<std::endl;
386  size_t endOfEtValStr = trigName.find_first_not_of("1234567890",etStrPos+6);
387 
388  std::istringstream etValStr(trigName.substr(etStrPos+6,endOfEtValStr-etStrPos-6));
389  float etVal;
390  etValStr>> etVal;//std::cout<<"TrigName= "<<trigName<<" etVal= "<<etVal<<std::endl;
391  return etVal;
392  }
393  }
394  }
395  else if(etStrPos!=trigName.npos){
396  if(isEle){
397  if(etStrPos!=trigName.npos && trigName.find_first_of("1234567890",etStrPos)==etStrPos+3){//std::cout<<"In if"<<std::endl;
398  size_t endOfEtValStr = trigName.find_first_not_of("1234567890",etStrPos+3);
399 
400  std::istringstream etValStr(trigName.substr(etStrPos+3,endOfEtValStr-etStrPos-3));
401  float etVal;
402  etValStr>> etVal;//std::cout<<"TrigName= "<<trigName<<" etVal= "<<etVal<<std::endl;
403  return etVal;
404  }
405  }
406  if(isEG){
407  if(etStrPos!=trigName.npos && trigName.find_first_of("1234567890",etStrPos)==etStrPos+2){//std::cout<<"In if"<<std::endl;
408  size_t endOfEtValStr = trigName.find_first_not_of("1234567890",etStrPos+2);
409 
410  std::istringstream etValStr(trigName.substr(etStrPos+2,endOfEtValStr-etStrPos-2));
411  float etVal;
412  etValStr>> etVal;//std::cout<<"TrigName= "<<trigName<<" etVal= "<<etVal<<std::endl;
413  return etVal;
414  }
415  }
416 
417  if(isPhoton){
418  if(etStrPos!=trigName.npos && trigName.find_first_of("1234567890",etStrPos)==etStrPos+6){//std::cout<<"In if"<<std::endl;
419  size_t endOfEtValStr = trigName.find_first_not_of("1234567890",etStrPos+6);
420 
421  std::istringstream etValStr(trigName.substr(etStrPos+6,endOfEtValStr-etStrPos-6));
422  float etVal;
423  etValStr>> etVal;//std::cout<<"TrigName= "<<trigName<<" etVal= "<<etVal<<std::endl;
424  return etVal;
425  }
426  }
427  }
428 
429  return 0;
430 
431 }
template<class T >
void egHLT::trigTools::setFiltersObjPasses ( std::vector< T > &  objs,
const std::vector< std::string > &  filters,
const std::vector< std::pair< std::string, std::string > > &  l1PreAndSeedFilters,
const TrigCodes::TrigBitSet evtTrigBits,
const TrigCodes trigCodes,
const trigger::TriggerEvent trigEvt,
const std::string &  hltTag 
)

Definition at line 48 of file EgHLTTrigTools.h.

References reco::deltaR(), PVValHelper::eta, ALCARECOTkAlBeamHalo_cff::filter, trigger::TriggerEvent::filterIndex(), trigger::TriggerEvent::filterKeys(), egHLT::TrigCodes::getCode(), trigger::TriggerEvent::getObjects(), and electrons_cff::maxDeltaR.

Referenced by egHLT::OffHelper::setTrigInfo().

53  {
54  std::vector<TrigCodes::TrigBitSet> partTrigBits(particles.size());
55  const double maxDeltaR=0.1;
56  for(const auto & filter : filters){
57  size_t filterNrInEvt = trigEvt->filterIndex(edm::InputTag(filter,"",hltTag));
58  const TrigCodes::TrigBitSet filterCode = trigCodes.getCode(filter.c_str());
59 
60  if(filterNrInEvt<trigEvt->sizeFilters()){ //filter found in event, something passes it
61  const trigger::Keys& trigKeys = trigEvt->filterKeys(filterNrInEvt); //trigger::Keys is actually a vector<uint16_t> holding the position of trigger objects in the trigger collection passing the filter
62  const trigger::TriggerObjectCollection & trigObjColl(trigEvt->getObjects());
63  for(size_t partNr=0;partNr<particles.size();partNr++){
64  for(unsigned short trigKey : trigKeys){
65  float trigObjEta = trigObjColl[trigKey].eta();
66  float trigObjPhi = trigObjColl[trigKey].phi();
67  if (reco::deltaR(particles[partNr].eta(),particles[partNr].phi(),trigObjEta,trigObjPhi) < maxDeltaR){
68  partTrigBits[partNr] |= filterCode;
69  }//end dR<maxDeltaR trig obj match test
70  }//end loop over all objects passing filter
71  }//end loop over particles
72  }//end check if filter is present
73  }//end loop over all filters
74 
75  //okay the first element is the key, the second is the filter that exists in trigger event
76  for(const auto & l1PreAndSeedFilter : l1PreAndSeedFilters){
77  const TrigCodes::TrigBitSet filterCode = trigCodes.getCode(l1PreAndSeedFilter.first.c_str());
78  if((filterCode&evtTrigBits)==filterCode){ //check that filter has fired in the event
79 
80  size_t filterNrInEvt = trigEvt->filterIndex(edm::InputTag(l1PreAndSeedFilter.second,"",hltTag));
81 
82  if(filterNrInEvt<trigEvt->sizeFilters()){ //filter found in event, something passes it
83  const trigger::Keys& trigKeys = trigEvt->filterKeys(filterNrInEvt); //trigger::Keys is actually a vector<uint16_t> holding the position of trigger objects in the trigger collection passing the filter
84  const trigger::TriggerObjectCollection & trigObjColl(trigEvt->getObjects());
85  for(size_t partNr=0;partNr<particles.size();partNr++){
86  for(unsigned short trigKey : trigKeys){
87  float trigObjEta = trigObjColl[trigKey].eta();
88  float trigObjPhi = trigObjColl[trigKey].phi();
89  if (reco::deltaR(particles[partNr].eta(),particles[partNr].phi(),trigObjEta,trigObjPhi) < maxDeltaR){
90  partTrigBits[partNr] |= filterCode;
91  }//end dR<maxDeltaR trig obj match test
92  }//end loop over all objects passing filter
93  }//end loop over particles
94  }//end check if filter is present
95  }//end check if path has fired in the event
96  }//end loop over all filters
97 
98  for(size_t partNr=0;partNr<particles.size();partNr++) particles[partNr].setTrigBits(partTrigBits[partNr]);
99 
100  }
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:111
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:123
std::vector< TPRegexp > filters
Definition: eve_filter.cc:22
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:98
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
std::vector< size_type > Keys
void egHLT::trigTools::translateFiltersToPathNames ( const HLTConfigProvider hltConfig,
const std::vector< std::string > &  filters,
std::vector< std::string > &  paths 
)

Definition at line 270 of file EgHLTTrigTools.cc.

References ALCARECOTkAlBeamHalo_cff::filter, HLTConfigProvider::moduleLabels(), HLTConfigProvider::size(), AlCaHLTBitMon_QueryRunRegistry::string, and HLTConfigProvider::triggerName().

Referenced by EgHLTOfflineSummaryClient::beginRun(), and egHLT::OffHelper::setupTriggers().

271 {
272 
273  paths.clear();
274  std::vector<std::pair<std::string,std::string> > filtersAndPaths;
275 
276  for(size_t pathNr=0;pathNr<hltConfig.size();pathNr++){
277  const std::string& pathName = hltConfig.triggerName(pathNr);
278  if(pathName.find("HLT_")==0){ //hlt path as they all start with HLT_XXXX
279 
280  std::string lastFilter;
281  const std::vector<std::string>& pathFilters = hltConfig.moduleLabels(pathNr);
282  if(!pathFilters.empty()){
283  if(pathFilters.back()=="hltBoolEnd" && pathFilters.size()>=2){
284  //2nd to last element is the last filter, useally the case as last is hltBool except for ES bits
285  filtersAndPaths.push_back(std::make_pair(pathFilters[pathFilters.size()-2],pathName));
286  }else filtersAndPaths.push_back(std::make_pair(pathFilters.back(),pathName));
287  }
288  }//end hlt path check
289  }//end path loop over
290 
291  std::sort(filtersAndPaths.begin(),filtersAndPaths.end(),StringPairCompare());
292 
293  for(auto const & filter : filters){
294  typedef std::vector<std::pair<std::string,std::string> >::const_iterator VecIt;
295  std::pair<VecIt,VecIt> searchResult = std::equal_range(filtersAndPaths.begin(),filtersAndPaths.end(),filter,StringPairCompare());
296  if(searchResult.first!=searchResult.second) paths.push_back(searchResult.first->second);
297  else paths.push_back(filter);//if cant find the path, just write the filter
298  //---Morse-----
299  //std::cout<<filtersAndPaths[filterNr].first<<" "<<filtersAndPaths[filterNr].second<<std::endl;
300  //-------------
301  }
302 
303 }
unsigned int size() const
number of trigger paths in trigger table
const std::string & triggerName(unsigned int triggerIndex) const
std::vector< TPRegexp > filters
Definition: eve_filter.cc:22
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path