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

◆ fillHLTposition()

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 130 of file EgHLTTrigTools.h.

References reco::deltaR(), ALCARECOTkAlBeamHalo_cff::filter, trigger::TriggerEvent::filterIndex(), trigger::TriggerEvent::filterKeys(), filters, trigger::TriggerEvent::getObjects(), EgHLTOfflineClient_cfi::hltTag, and ewkMuLumiMonitorDQM_cfi::maxDeltaR.

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

134  {
135  std::vector<TrigCodes::TrigBitSet> partTrigBits(1);
136  const double maxDeltaR = 0.1;
137  for (const auto& filter : filters) {
138  size_t filterNrInEvt = trigEvt->filterIndex(edm::InputTag(filter, "", hltTag));
139  //const TrigCodes::TrigBitSet filterCode = trigCodes.getCode(filters[filterNrInVec].c_str());
140  if (filterNrInEvt < trigEvt->sizeFilters()) { //filter found in event, something passes it
141  const trigger::Keys& trigKeys = trigEvt->filterKeys(
142  filterNrInEvt); //trigger::Keys is actually a vector<uint16_t> holding the position of trigger objects in the trigger collection passing the filter
143  const trigger::TriggerObjectCollection& trigObjColl(trigEvt->getObjects());
144  for (unsigned short trigKey : trigKeys) {
145  float trigObjEta = trigObjColl[trigKey].eta();
146  float trigObjPhi = trigObjColl[trigKey].phi();
147  float trigObjE = trigObjColl[trigKey].energy();
148  if (reco::deltaR(particle.superCluster()->eta(), particle.superCluster()->phi(), trigObjEta, trigObjPhi) <
149  maxDeltaR) {
150  hltData.HLTeta = trigObjEta;
151  hltData.HLTphi = trigObjPhi;
152  hltData.HLTenergy = trigObjE;
153  } //end dR<maxDeltaR trig obj match test
154  } //end loop over all objects passing filter`
155  } //end check if filter is present
156  } //end check if path has fired in the event
157  } //end loop over all filters
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:119
std::vector< TPRegexp > filters
Definition: eve_filter.cc:22
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:102
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:75
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:133
std::vector< size_type > Keys

◆ filterInactiveTightLooseTriggers()

void egHLT::trigTools::filterInactiveTightLooseTriggers ( std::vector< std::string > &  namesToFilter,
const std::vector< std::string > &  activeFilters 
)

Definition at line 250 of file EgHLTTrigTools.cc.

References names, submitPVValidationJobs::split(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

251  {
252  //tempory vector to store the filtered results
253  std::vector<std::string> filteredNames;
254 
255  for (auto& inputFilterNr : namesToFilter) {
256  std::vector<std::string> names;
257  boost::split(names, inputFilterNr, boost::is_any_of(std::string(":")));
258  if (names.size() != 2)
259  continue; //format incorrect, reject it
260  if (std::binary_search(activeFilters.begin(), activeFilters.end(), names[0]) &&
261  std::binary_search(activeFilters.begin(), activeFilters.end(), names[1])) { //both filters are valid
262  filteredNames.push_back(inputFilterNr);
263  }
264  }
265 
266  namesToFilter.swap(filteredNames);
267 }
const std::string names[nVars_]

◆ filterInactiveTriggers()

void egHLT::trigTools::filterInactiveTriggers ( std::vector< std::string > &  namesToFilter,
std::vector< std::string > &  activeFilters 
)

Definition at line 233 of file EgHLTTrigTools.cc.

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

234  {
235  //tempory vector to store the filtered results
236  std::vector<std::string> filteredNames;
237  /*
238  for(size_t inputFilterNr=0;inputFilterNr<namesToFilter.size();inputFilterNr++){
239  if(std::binary_search(activeFilters.begin(),activeFilters.end(),namesToFilter[inputFilterNr])){
240  filteredNames.push_back(namesToFilter[inputFilterNr]);
241  }//std::cout<<filteredNames[inputFilterNr]<<std::endl;
242  }
243  */
244  //namesToFilter.swap(activeFilters);
245  filteredNames = activeFilters;
246  namesToFilter.swap(filteredNames);
247 }

◆ getActiveFilters()

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 129 of file EgHLTTrigTools.cc.

References ALCARECOTkAlBeamHalo_cff::filter, filters, spr::find(), getMinNrObjsRequiredByFilter(), HltComparatorCreateWorkflow::hltConfig, hltMonBTagIPClient_cfi::pathName, jetUpdater_cfi::sort, and AlCaHLTBitMon_QueryRunRegistry::string.

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

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

◆ getEtThresFromName()

float egHLT::trigTools::getEtThresFromName ( const std::string &  trigName)

Definition at line 343 of file EgHLTTrigTools.cc.

References cscTnPEfficiencyTask_cfi::trigName.

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

343  {
344  size_t etStrPos = trigName.find("Et");
345  while (etStrPos != std::string::npos && trigName.find_first_of("1234567890", etStrPos) != etStrPos + 2) {
346  etStrPos = trigName.find("Et", etStrPos + 1);
347  }
348  if (etStrPos != std::string::npos && trigName.find_first_of("1234567890", etStrPos) == etStrPos + 2) {
349  size_t endOfEtValStr = trigName.find_first_not_of("1234567890", etStrPos + 2);
350 
351  std::istringstream etValStr(trigName.substr(etStrPos + 2, endOfEtValStr - etStrPos - 2));
352  float etVal;
353  etValStr >> etVal;
354  return etVal;
355  }
356  return 0;
357 }

◆ getFiltersPassed()

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, egHLT::TrigCodes::getCode(), and EgHLTOfflineClient_cfi::hltTag.

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

11  {
12  TrigCodes::TrigBitSet evtTrigs;
13  for (auto const& filter : filters) {
14  size_t filterNrInEvt = trigEvt->filterIndex(edm::InputTag(filter.first, "", hltTag));
15  const TrigCodes::TrigBitSet filterCode = trigCodes.getCode(filter.first.c_str());
16  if (filterNrInEvt <
17  trigEvt
18  ->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  return evtTrigs;
27 }
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:119
std::vector< TPRegexp > filters
Definition: eve_filter.cc:22
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:133
std::vector< size_type > Keys
TrigBitSet getCode(const char *descript) const
std::bitset< maxNrBits_ > TrigBitSet

◆ getL1SeedFilterOfPath()

std::string egHLT::trigTools::getL1SeedFilterOfPath ( const HLTConfigProvider hltConfig,
const std::string &  path 
)

◆ getMinNrObjsRequiredByFilter()

std::vector< int > egHLT::trigTools::getMinNrObjsRequiredByFilter ( const std::vector< std::string > &  filterName)

Definition at line 36 of file EgHLTTrigTools.cc.

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

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

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

◆ getSecondEtThresFromName()

float egHLT::trigTools::getSecondEtThresFromName ( const std::string &  trigName)

Definition at line 361 of file EgHLTTrigTools.cc.

References jetsAK4_CHS_cff::isEle, and cscTnPEfficiencyTask_cfi::trigName.

362  { //std::cout<<"What the heck is this trigName?:"<<trigName<<std::endl;
363  bool isEle = false, isPhoton = false, isEG = false, isEle2 = false, isPhoton2 = false, isEG2 = false, isSC2 = false;
364  size_t etStrPos = trigName.npos;
365  if (trigName.find("Ele") < trigName.find("Photon") && trigName.find("Ele") < trigName.find("EG")) {
366  etStrPos = trigName.find("Ele");
367  isEle = true;
368  } else if (trigName.find("EG") < trigName.find("Photon") && trigName.find("EG") < trigName.find("Ele")) {
369  etStrPos = trigName.find("EG");
370  isEG = true;
371  } else if (trigName.find("Photon") < trigName.find("Ele") && trigName.find("Photon") < trigName.find("EG")) {
372  etStrPos = trigName.find("Photon");
373  isPhoton = true;
374  }
375  //size_t etStrPos = trigName.find("Et");
376  //std::cout<<"Got Original Et spot; etStrPos="<<etStrPos<<std::endl;
377  /*while(etStrPos!=std::string::npos && trigName.find_first_of("1234567890",etStrPos)!=etStrPos+2){
378  etStrPos = trigName.find("Et",etStrPos+1);//std::cout<<"Got first Et spot; etStrPos="<<etStrPos<<std::endl;
379  }*/
380  if (etStrPos != trigName.npos &&
381  (trigName.find("Ele", etStrPos + 1) != trigName.npos || trigName.find("EG", etStrPos + 1) != trigName.npos ||
382  trigName.find("Photon", etStrPos + 1) != trigName.npos || trigName.find("SC", etStrPos + 1) != trigName.npos)) {
383  if (trigName.find("Ele", etStrPos + 1) < trigName.find("Photon", etStrPos + 1) &&
384  trigName.find("Ele", etStrPos + 1) < trigName.find("EG", etStrPos + 1) &&
385  trigName.find("Ele", etStrPos + 1) < trigName.find("SC", etStrPos + 1)) {
386  etStrPos = trigName.find("Ele", etStrPos + 1);
387  isEle2 = true;
388  } else if (trigName.find("EG", etStrPos + 1) < trigName.find("Photon", etStrPos + 1) &&
389  trigName.find("EG", etStrPos + 1) < trigName.find("Ele", etStrPos + 1) &&
390  trigName.find("EG", etStrPos + 1) < trigName.find("SC", etStrPos + 1)) {
391  etStrPos = trigName.find("EG", etStrPos + 1);
392  isEG2 = true;
393  } else if (trigName.find("Photon", etStrPos + 1) < trigName.find("EG", etStrPos + 1) &&
394  trigName.find("Photon", etStrPos + 1) < trigName.find("Ele", etStrPos + 1) &&
395  trigName.find("Photon", etStrPos + 1) < trigName.find("SC", etStrPos + 1)) {
396  etStrPos = trigName.find("Photon", etStrPos + 1);
397  isPhoton2 = true;
398  } else if (trigName.find("SC", etStrPos + 1) < trigName.find("EG", etStrPos + 1) &&
399  trigName.find("SC", etStrPos + 1) < trigName.find("Ele", etStrPos + 1) &&
400  trigName.find("SC", etStrPos + 1) < trigName.find("Photon", etStrPos + 1)) {
401  etStrPos = trigName.find("Photon", etStrPos + 1);
402  isSC2 = true;
403  }
404  //std::cout<<"Got second Et spot; etStrPos="<<etStrPos<<std::endl;//}//get second instance. if it dne, keep first
405 
406  if (isEle2) {
407  if (etStrPos != trigName.npos &&
408  trigName.find_first_of("1234567890", etStrPos) == etStrPos + 3) { //std::cout<<"In if"<<std::endl;
409  size_t endOfEtValStr = trigName.find_first_not_of("1234567890", etStrPos + 3);
410 
411  std::istringstream etValStr(trigName.substr(etStrPos + 3, endOfEtValStr - etStrPos - 3));
412  float etVal;
413  etValStr >> etVal; //std::cout<<"TrigName= "<<trigName<<" etVal= "<<etVal<<std::endl;
414  return etVal;
415  }
416  }
417  if (isEG2 || isSC2) {
418  if (etStrPos != trigName.npos &&
419  trigName.find_first_of("1234567890", etStrPos) == etStrPos + 2) { //std::cout<<"In if"<<std::endl;
420  size_t endOfEtValStr = trigName.find_first_not_of("1234567890", etStrPos + 2);
421 
422  std::istringstream etValStr(trigName.substr(etStrPos + 2, endOfEtValStr - etStrPos - 2));
423  float etVal;
424  etValStr >> etVal; //std::cout<<"TrigName= "<<trigName<<" etVal= "<<etVal<<std::endl;
425  return etVal;
426  }
427  }
428 
429  if (isPhoton2) {
430  if (etStrPos != trigName.npos &&
431  trigName.find_first_of("1234567890", etStrPos) == etStrPos + 6) { //std::cout<<"In if"<<std::endl;
432  size_t endOfEtValStr = trigName.find_first_not_of("1234567890", etStrPos + 6);
433 
434  std::istringstream etValStr(trigName.substr(etStrPos + 6, endOfEtValStr - etStrPos - 6));
435  float etVal;
436  etValStr >> etVal; //std::cout<<"TrigName= "<<trigName<<" etVal= "<<etVal<<std::endl;
437  return etVal;
438  }
439  }
440  } else if (etStrPos != trigName.npos) {
441  if (isEle) {
442  if (etStrPos != trigName.npos &&
443  trigName.find_first_of("1234567890", etStrPos) == etStrPos + 3) { //std::cout<<"In if"<<std::endl;
444  size_t endOfEtValStr = trigName.find_first_not_of("1234567890", etStrPos + 3);
445 
446  std::istringstream etValStr(trigName.substr(etStrPos + 3, endOfEtValStr - etStrPos - 3));
447  float etVal;
448  etValStr >> etVal; //std::cout<<"TrigName= "<<trigName<<" etVal= "<<etVal<<std::endl;
449  return etVal;
450  }
451  }
452  if (isEG) {
453  if (etStrPos != trigName.npos &&
454  trigName.find_first_of("1234567890", etStrPos) == etStrPos + 2) { //std::cout<<"In if"<<std::endl;
455  size_t endOfEtValStr = trigName.find_first_not_of("1234567890", etStrPos + 2);
456 
457  std::istringstream etValStr(trigName.substr(etStrPos + 2, endOfEtValStr - etStrPos - 2));
458  float etVal;
459  etValStr >> etVal; //std::cout<<"TrigName= "<<trigName<<" etVal= "<<etVal<<std::endl;
460  return etVal;
461  }
462  }
463 
464  if (isPhoton) {
465  if (etStrPos != trigName.npos &&
466  trigName.find_first_of("1234567890", etStrPos) == etStrPos + 6) { //std::cout<<"In if"<<std::endl;
467  size_t endOfEtValStr = trigName.find_first_not_of("1234567890", etStrPos + 6);
468 
469  std::istringstream etValStr(trigName.substr(etStrPos + 6, endOfEtValStr - etStrPos - 6));
470  float etVal;
471  etValStr >> etVal; //std::cout<<"TrigName= "<<trigName<<" etVal= "<<etVal<<std::endl;
472  return etVal;
473  }
474  }
475  }
476 
477  return 0;
478 }

◆ setFiltersObjPasses()

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 72 of file EgHLTTrigTools.h.

References reco::deltaR(), PVValHelper::eta, ALCARECOTkAlBeamHalo_cff::filter, trigger::TriggerEvent::filterIndex(), trigger::TriggerEvent::filterKeys(), filters, egHLT::TrigCodes::getCode(), trigger::TriggerEvent::getObjects(), EgHLTOfflineClient_cfi::hltTag, ewkMuLumiMonitorDQM_cfi::maxDeltaR, and ecalTrigSettings_cff::particles.

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

78  {
79  std::vector<TrigCodes::TrigBitSet> partTrigBits(particles.size());
80  const double maxDeltaR = 0.1;
81  for (const auto& filter : filters) {
82  size_t filterNrInEvt = trigEvt->filterIndex(edm::InputTag(filter, "", hltTag));
83  const TrigCodes::TrigBitSet filterCode = trigCodes.getCode(filter.c_str());
84 
85  if (filterNrInEvt < trigEvt->sizeFilters()) { //filter found in event, something passes it
86  const trigger::Keys& trigKeys = trigEvt->filterKeys(
87  filterNrInEvt); //trigger::Keys is actually a vector<uint16_t> holding the position of trigger objects in the trigger collection passing the filter
88  const trigger::TriggerObjectCollection& trigObjColl(trigEvt->getObjects());
89  for (size_t partNr = 0; partNr < particles.size(); partNr++) {
90  for (unsigned short trigKey : trigKeys) {
91  float trigObjEta = trigObjColl[trigKey].eta();
92  float trigObjPhi = trigObjColl[trigKey].phi();
93  if (reco::deltaR(particles[partNr].eta(), particles[partNr].phi(), trigObjEta, trigObjPhi) < maxDeltaR) {
94  partTrigBits[partNr] |= filterCode;
95  } //end dR<maxDeltaR trig obj match test
96  } //end loop over all objects passing filter
97  } //end loop over particles
98  } //end check if filter is present
99  } //end loop over all filters
100 
101  //okay the first element is the key, the second is the filter that exists in trigger event
102  for (const auto& l1PreAndSeedFilter : l1PreAndSeedFilters) {
103  const TrigCodes::TrigBitSet filterCode = trigCodes.getCode(l1PreAndSeedFilter.first.c_str());
104  if ((filterCode & evtTrigBits) == filterCode) { //check that filter has fired in the event
105 
106  size_t filterNrInEvt = trigEvt->filterIndex(edm::InputTag(l1PreAndSeedFilter.second, "", hltTag));
107 
108  if (filterNrInEvt < trigEvt->sizeFilters()) { //filter found in event, something passes it
109  const trigger::Keys& trigKeys = trigEvt->filterKeys(
110  filterNrInEvt); //trigger::Keys is actually a vector<uint16_t> holding the position of trigger objects in the trigger collection passing the filter
111  const trigger::TriggerObjectCollection& trigObjColl(trigEvt->getObjects());
112  for (size_t partNr = 0; partNr < particles.size(); partNr++) {
113  for (unsigned short trigKey : trigKeys) {
114  float trigObjEta = trigObjColl[trigKey].eta();
115  float trigObjPhi = trigObjColl[trigKey].phi();
116  if (reco::deltaR(particles[partNr].eta(), particles[partNr].phi(), trigObjEta, trigObjPhi) < maxDeltaR) {
117  partTrigBits[partNr] |= filterCode;
118  } //end dR<maxDeltaR trig obj match test
119  } //end loop over all objects passing filter
120  } //end loop over particles
121  } //end check if filter is present
122  } //end check if path has fired in the event
123  } //end loop over all filters
124 
125  for (size_t partNr = 0; partNr < particles.size(); partNr++)
126  particles[partNr].setTrigBits(partTrigBits[partNr]);
127  }
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:119
std::vector< TPRegexp > filters
Definition: eve_filter.cc:22
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:102
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:75
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:133
std::vector< size_type > Keys

◆ translateFiltersToPathNames()

void egHLT::trigTools::translateFiltersToPathNames ( const HLTConfigProvider hltConfig,
const std::vector< std::string > &  filters,
std::vector< std::string > &  paths 
)

Definition at line 293 of file EgHLTTrigTools.cc.

References ALCARECOTkAlBeamHalo_cff::filter, filters, HltComparatorCreateWorkflow::hltConfig, hltMonBTagIPClient_cfi::pathName, Skims_PA_cff::paths, jetUpdater_cfi::sort, and AlCaHLTBitMon_QueryRunRegistry::string.

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

295  {
296  paths.clear();
297  std::vector<std::pair<std::string, std::string> > filtersAndPaths;
298 
299  for (size_t pathNr = 0; pathNr < hltConfig.size(); pathNr++) {
300  const std::string& pathName = hltConfig.triggerName(pathNr);
301  if (pathName.find("HLT_") == 0) { //hlt path as they all start with HLT_XXXX
302 
303  std::string lastFilter;
304  const std::vector<std::string>& pathFilters = hltConfig.moduleLabels(pathNr);
305  if (!pathFilters.empty()) {
306  if (pathFilters.back() == "hltBoolEnd" && pathFilters.size() >= 2) {
307  //2nd to last element is the last filter, useally the case as last is hltBool except for ES bits
308  filtersAndPaths.push_back(std::make_pair(pathFilters[pathFilters.size() - 2], pathName));
309  } else
310  filtersAndPaths.push_back(std::make_pair(pathFilters.back(), pathName));
311  }
312  } //end hlt path check
313  } //end path loop over
314 
315  std::sort(filtersAndPaths.begin(), filtersAndPaths.end(), StringPairCompare());
316 
317  for (auto const& filter : filters) {
318  typedef std::vector<std::pair<std::string, std::string> >::const_iterator VecIt;
319  std::pair<VecIt, VecIt> searchResult =
320  std::equal_range(filtersAndPaths.begin(), filtersAndPaths.end(), filter, StringPairCompare());
321  if (searchResult.first != searchResult.second)
322  paths.push_back(searchResult.first->second);
323  else
324  paths.push_back(filter); //if cant find the path, just write the filter
325  //---Morse-----
326  //std::cout<<filtersAndPaths[filterNr].first<<" "<<filtersAndPaths[filterNr].second<<std::endl;
327  //-------------
328  }
329 }
std::vector< TPRegexp > filters
Definition: eve_filter.cc:22