CMS 3D CMS Logo

EgHLTTrigTools.h
Go to the documentation of this file.
1 #ifndef DQMOFFLINE_TRIGGER_EGHLTTRIGTOOLS
2 #define DQMOFFLINE_TRIGGER_EGHLTTRIGTOOLS
3 
8 #include <vector>
9 
10 class HLTConfigProvider;
11 
12 namespace egHLT {
13 
14  namespace trigTools {
15  TrigCodes::TrigBitSet getFiltersPassed(const std::vector<std::pair<std::string, int> >& filters,
16  const trigger::TriggerEvent* trigEvt,
17  const std::string& hltTag,
18  const TrigCodes& trigCodes);
19 
20  template <class T>
21  void setFiltersObjPasses(std::vector<T>& objs,
22  const std::vector<std::string>& filters,
23  const std::vector<std::pair<std::string, std::string> >& l1PreAndSeedFilters,
24  const TrigCodes::TrigBitSet& evtTrigBits,
25  const TrigCodes& trigCodes,
26  const trigger::TriggerEvent* trigEvt,
27  const std::string& hltTag);
28 
29  template <class T, class U>
30  void fillHLTposition(T& obj,
31  U& hltData,
32  const std::vector<std::string>& filters,
33  const trigger::TriggerEvent* trigEvt,
34  const std::string& hltTag);
35  std::vector<int> getMinNrObjsRequiredByFilter(
36  const std::vector<std::string>& filterName); //slow function, call at begin job and cache results
37 
38  //reads hlt config and works out which are the active last filters stored in trigger summary, is sorted
40  std::vector<std::string>& activeFilters,
41  std::vector<std::string>& activeEleFilters,
42  std::vector<std::string>& activeEle2LegFilters,
43  std::vector<std::string>& activePhoFilters,
44  std::vector<std::string>& activePho2LegFilters);
45  //---Morse test--------
46  //void getPhoton30(const HLTConfigProvider& hltConfig,std::vector<std::string>& activeFilters);
47  //------------------
48  //filters a list of filternames removing any filters which are not in active filters, assumes active filters is sorted
49  void filterInactiveTriggers(std::vector<std::string>& namesToFilter, std::vector<std::string>& activeFilters);
50  //filters a list of filterName1:filterName2 removing any entry for which either filter is not in activeFilters, assumes active filters is sorted
51  void filterInactiveTightLooseTriggers(std::vector<std::string>& namesToFilter,
52  const std::vector<std::string>& activeFilters);
53 
55  const std::vector<std::string>& filters,
56  std::vector<std::string>& paths);
58 
59  //looks for string Et and then looks for a number after that (currently the standard of all E/g triggers)
60  //returns 0 if unsuccessful
63  } // namespace trigTools
64 
65  //I have the horrible feeling that I'm converting into an intermediatry format and then coverting back again
66  //Okay how this works
67  //1) create a TrigBitSet for each particle set to 0 initally
68  //2) loop over each filter, for each particle that passes the filter, set the appropriate bit in the TrigBitSet
69  //3) after that, loop over each particle setting that its TrigBitSet which has been calculated
70  //4) because L1 pre-scaled paths are special, we only set those if an event wide trigger has been set
71  template <class T>
73  const std::vector<std::string>& filters,
74  const std::vector<std::pair<std::string, std::string> >& l1PreAndSeedFilters,
75  const TrigCodes::TrigBitSet& evtTrigBits,
76  const TrigCodes& trigCodes,
77  const trigger::TriggerEvent* trigEvt,
78  const std::string& hltTag) {
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  }
128 
129  template <class T, class U>
131  U& hltData,
132  const std::vector<std::string>& filters,
133  const trigger::TriggerEvent* trigEvt,
134  const std::string& hltTag) {
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
158 
159 } // namespace egHLT
160 
161 #endif
Handle.h
filters
std::vector< TPRegexp > filters
Definition: eve_filter.cc:22
trigger::TriggerEvent::filterKeys
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:118
egHLT::trigTools::filterInactiveTightLooseTriggers
void filterInactiveTightLooseTriggers(std::vector< std::string > &namesToFilter, const std::vector< std::string > &activeFilters)
Definition: EgHLTTrigTools.cc:250
TriggerEvent.h
egHLT::TrigCodes
Definition: EgHLTTrigCodes.h:20
ecalTrigSettings_cff.particles
particles
Definition: ecalTrigSettings_cff.py:11
egHLT::trigTools::getMinNrObjsRequiredByFilter
std::vector< int > getMinNrObjsRequiredByFilter(const std::vector< std::string > &filterName)
Definition: EgHLTTrigTools.cc:36
egHLT::trigTools::getEtThresFromName
float getEtThresFromName(const std::string &trigName)
Definition: EgHLTTrigTools.cc:343
egHLT::TrigCodes::TrigBitSet
std::bitset< maxNrBits_ > TrigBitSet
Definition: EgHLTTrigCodes.h:23
PVValHelper::eta
Definition: PVValidationHelpers.h:70
trigTools
Definition: trigTools.py:1
ALCARECOTkAlBeamHalo_cff.filter
filter
Definition: ALCARECOTkAlBeamHalo_cff.py:27
egHLT::trigTools::getFiltersPassed
TrigCodes::TrigBitSet getFiltersPassed(const std::vector< std::pair< std::string, int > > &filters, const trigger::TriggerEvent *trigEvt, const std::string &hltTag, const TrigCodes &trigCodes)
Definition: EgHLTTrigTools.cc:8
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EgHLTOffTrigSelection_cfi.trigName
trigName
Definition: EgHLTOffTrigSelection_cfi.py:8
egHLT::TrigCodes::getCode
TrigBitSet getCode(const char *descript) const
Definition: EgHLTTrigCodes.cc:42
deltaR.h
trigger::TriggerObjectCollection
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:75
trigger::TriggerEvent::filterIndex
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:132
trigger::Keys
std::vector< size_type > Keys
Definition: TriggerTypeDefs.h:19
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
egHLT::trigTools::getL1SeedFilterOfPath
std::string getL1SeedFilterOfPath(const HLTConfigProvider &hltConfig, const std::string &path)
Definition: EgHLTTrigTools.cc:331
trigger::TriggerEvent
The single EDProduct to be saved for each event (AOD case)
Definition: TriggerEvent.h:25
trigger::TriggerEvent::getObjects
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:101
egHLT::trigTools::getSecondEtThresFromName
float getSecondEtThresFromName(const std::string &trigName)
Definition: EgHLTTrigTools.cc:361
pdwgDoubleElectron_cfi.filterName
filterName
Definition: pdwgDoubleElectron_cfi.py:7
HLTConfigProvider
Definition: HLTConfigProvider.h:29
T
long double T
Definition: Basic3DVectorLD.h:48
egHLT::trigTools::filterInactiveTriggers
void filterInactiveTriggers(std::vector< std::string > &namesToFilter, std::vector< std::string > &activeFilters)
Definition: EgHLTTrigTools.cc:233
ewkMuLumiMonitorDQM_cfi.maxDeltaR
maxDeltaR
Definition: ewkMuLumiMonitorDQM_cfi.py:44
egHLT::trigTools::getActiveFilters
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)
Definition: EgHLTTrigTools.cc:129
egHLT::trigTools::translateFiltersToPathNames
void translateFiltersToPathNames(const HLTConfigProvider &hltConfig, const std::vector< std::string > &filters, std::vector< std::string > &paths)
Definition: EgHLTTrigTools.cc:293
reco::deltaR
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
HltComparatorCreateWorkflow.hltConfig
hltConfig
Definition: HltComparatorCreateWorkflow.py:161
Skims_PA_cff.paths
paths
Definition: Skims_PA_cff.py:18
HLTEGTnPMonitor_cfi.objs
objs
Definition: HLTEGTnPMonitor_cfi.py:1018
EgHLTOfflineClient_cfi.hltTag
hltTag
Definition: EgHLTOfflineClient_cfi.py:9
EgHLTTrigCodes.h
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
egHLT
Definition: EgHLTBinData.h:10
edm::InputTag
Definition: InputTag.h:15
egHLT::trigTools::setFiltersObjPasses
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)
Definition: EgHLTTrigTools.h:72
egHLT::trigTools::fillHLTposition
void fillHLTposition(T &obj, U &hltData, const std::vector< std::string > &filters, const trigger::TriggerEvent *trigEvt, const std::string &hltTag)
Definition: EgHLTTrigTools.h:130