CMS 3D CMS Logo

HLTElectronGenericFilter.cc
Go to the documentation of this file.
1 
9 
11 
15 
20 
23 
24 //
25 // constructors and destructor
26 //
28  candTag_ = iConfig.getParameter< edm::InputTag > ("candTag");
29  varTag_ = iConfig.getParameter< edm::InputTag > ("varTag");
30  lessThan_ = iConfig.getParameter<bool> ("lessThan");
31  thrRegularEB_ = iConfig.getParameter<double> ("thrRegularEB");
32  thrRegularEE_ = iConfig.getParameter<double> ("thrRegularEE");
33  thrOverPtEB_ = iConfig.getParameter<double> ("thrOverPtEB");
34  thrOverPtEE_ = iConfig.getParameter<double> ("thrOverPtEE");
35  thrTimesPtEB_ = iConfig.getParameter<double> ("thrTimesPtEB");
36  thrTimesPtEE_ = iConfig.getParameter<double> ("thrTimesPtEE");
37  ncandcut_ = iConfig.getParameter<int> ("ncandcut");
38  l1EGTag_ = iConfig.getParameter< edm::InputTag > ("l1EGCand");
39 
40  candToken_ = consumes<trigger::TriggerFilterObjectWithRefs> (candTag_);
41  varToken_ = consumes<reco::ElectronIsolationMap>(varTag_);
42 }
43 
45 
46 void
50  desc.add<edm::InputTag>("candTag", edm::InputTag("hltSingleElectronOneOEMinusOneOPFilter"));
51  desc.add<edm::InputTag>("varTag", edm::InputTag("hltSingleElectronTrackIsol"));
52  desc.add<bool>("lessThan", true);
53  desc.add<double>("thrRegularEB", 0.0);
54  desc.add<double>("thrRegularEE", 0.0);
55  desc.add<double>("thrOverPtEB", -1.0);
56  desc.add<double>("thrOverPtEE", -1.0);
57  desc.add<double>("thrTimesPtEB", -1.0);
58  desc.add<double>("thrTimesPtEE", -1.0);
59  desc.add<int>("ncandcut", 1);
60  desc.add<edm::InputTag>("l1EGCand", edm::InputTag("hltPixelMatchElectronsL1Iso"));
61  descriptions.add("hltElectronGenericFilter", desc);
62 }
63 
64 // ------------ method called to produce the data ------------
65 bool
67 {
68  using namespace trigger;
69 
70  if (saveTags()) {
71  filterproduct.addCollectionTag(l1EGTag_);
72  }
73 
74  // Ref to Candidate object to be recorded in filter object
76 
78  iEvent.getByToken (candToken_, PrevFilterOutput);
79 
80  std::vector<edm::Ref<reco::ElectronCollection> > elecands;
81  PrevFilterOutput->getObjects(TriggerElectron, elecands);
82 
83 
84  //get hold of isolated association map
86  iEvent.getByToken (varToken_,depMap);
87 
88  // look at all photons, check cuts and add to filter object
89  int n = 0;
90 
91  for (auto & elecand : elecands) {
92 
93  ref = elecand;
94  reco::ElectronIsolationMap::const_iterator mapi = (*depMap).find( ref );
95 
96  float vali = mapi->val;
97  float Pt = ref->pt();
98  float Eta = fabs(ref->eta());
99 
100  if ( lessThan_ ) {
101  if ( (Eta < 1.479 && vali <= thrRegularEB_) || (Eta >= 1.479 && vali <= thrRegularEE_) ) {
102  n++;
103  filterproduct.addObject(TriggerElectron, ref);
104  continue;
105  }
106  if (Pt > 0. && (thrOverPtEB_ > 0. || thrOverPtEE_ > 0. || thrTimesPtEB_ > 0. || thrTimesPtEE_ > 0.) ) {
107  if ((Eta < 1.479 && vali/Pt <= thrOverPtEB_) || (Eta >= 1.479 && vali/Pt <= thrOverPtEE_) ) {
108  n++;
109  filterproduct.addObject(TriggerElectron, ref);
110  continue;
111  }
112  if ((Eta < 1.479 && vali*Pt <= thrTimesPtEB_) || (Eta >= 1.479 && vali*Pt <= thrTimesPtEE_) ) {
113  n++;
114  filterproduct.addObject(TriggerElectron, ref);
115  }
116  }
117  } else {
118  if ( (Eta < 1.479 && vali >= thrRegularEB_) || (Eta >= 1.479 && vali >= thrRegularEE_) ) {
119  n++;
120  filterproduct.addObject(TriggerElectron, ref);
121  continue;
122  }
123  if (Pt > 0. && (thrOverPtEB_ > 0. || thrOverPtEE_ > 0. || thrTimesPtEB_ > 0. || thrTimesPtEE_ > 0.) ) {
124  if ((Eta < 1.479 && vali/Pt >= thrOverPtEB_) || (Eta >= 1.479 && vali/Pt >= thrOverPtEE_) ) {
125  n++;
126  filterproduct.addObject(TriggerElectron, ref);
127  continue;
128  }
129  if ((Eta < 1.479 && vali*Pt >= thrTimesPtEB_) || (Eta >= 1.479 && vali*Pt >= thrTimesPtEE_) ) {
130  n++;
131  filterproduct.addObject(TriggerElectron, ref);
132  }
133  }
134  }
135  }
136 
137  // filter decision
138  bool accept(n>=ncandcut_);
139 
140  return accept;
141 }
142 
143 
144 // declare this class as a framework plugin
T getParameter(std::string const &) const
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
void addObject(int id, const reco::RecoEcalCandidateRef &ref)
setters for L3 collections: (id=physics type, and Ref<C>)
bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< reco::ElectronIsolationMap > varToken_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void makeHLTFilterDescription(edm::ParameterSetDescription &desc)
Definition: HLTFilter.cc:29
void addCollectionTag(const edm::InputTag &collectionTag)
collectionTags
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > candToken_
bool saveTags() const
Definition: HLTFilter.h:45
~HLTElectronGenericFilter() override
HLTElectronGenericFilter(const edm::ParameterSet &)