CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTDoubletDZ.cc
Go to the documentation of this file.
3 
5 
8 
9 //#include "DataFormats/Candidate/interface/Particle.h"
17 
19 
21 
22 #include<cmath>
23 
24 //
25 // constructors and destructor
26 //
27 template<typename T1, typename T2>
29  HLTFilter(iConfig),
30  originTag1_(iConfig.template getParameter<std::vector<edm::InputTag> >("originTag1")),
31  originTag2_(iConfig.template getParameter<std::vector<edm::InputTag> >("originTag2")),
32  inputTag1_(iConfig.template getParameter<edm::InputTag>("inputTag1")),
33  inputTag2_(iConfig.template getParameter<edm::InputTag>("inputTag2")),
34  inputToken1_(consumes<trigger::TriggerFilterObjectWithRefs>(inputTag1_)),
35  inputToken2_(consumes<trigger::TriggerFilterObjectWithRefs>(inputTag2_)),
36  //electronToken_ (consumes<reco::ElectronCollection>(iConfig.template getParameter<edm::InputTag>("electronTag"))),
37  triggerType1_(iConfig.template getParameter<int>("triggerType1")),
38  triggerType2_(iConfig.template getParameter<int>("triggerType2")),
39  minDR_ (iConfig.template getParameter<double>("MinDR")),
40  maxDZ_ (iConfig.template getParameter<double>("MaxDZ")),
41  min_N_ (iConfig.template getParameter<int>("MinN")),
42  checkSC_ (iConfig.template getParameter<bool>("checkSC")),
43  same_ (inputTag1_.encode()==inputTag2_.encode()) // same collections to be compared?
44 {}
45 
46 template<>
48  HLTFilter(iConfig),
49  originTag1_(iConfig.template getParameter<std::vector<edm::InputTag> >("originTag1")),
50  originTag2_(iConfig.template getParameter<std::vector<edm::InputTag> >("originTag2")),
51  inputTag1_(iConfig.template getParameter<edm::InputTag>("inputTag1")),
52  inputTag2_(iConfig.template getParameter<edm::InputTag>("inputTag2")),
53  inputToken1_(consumes<trigger::TriggerFilterObjectWithRefs>(inputTag1_)),
54  inputToken2_(consumes<trigger::TriggerFilterObjectWithRefs>(inputTag2_)),
55  electronToken_ (consumes<reco::ElectronCollection>(iConfig.template getParameter<edm::InputTag>("electronTag"))),
56  triggerType1_(iConfig.template getParameter<int>("triggerType1")),
57  triggerType2_(iConfig.template getParameter<int>("triggerType2")),
58  minDR_ (iConfig.template getParameter<double>("MinDR")),
59  maxDZ_ (iConfig.template getParameter<double>("MaxDZ")),
60  min_N_ (iConfig.template getParameter<int>("MinN")),
61  checkSC_ (iConfig.template getParameter<bool>("checkSC")),
62  same_ (inputTag1_.encode()==inputTag2_.encode()) // same collections to be compared?
63 {}
64 
65 template<>
67  HLTFilter(iConfig),
68  originTag1_(iConfig.template getParameter<std::vector<edm::InputTag> >("originTag1")),
69  originTag2_(iConfig.template getParameter<std::vector<edm::InputTag> >("originTag2")),
70  inputTag1_(iConfig.template getParameter<edm::InputTag>("inputTag1")),
71  inputTag2_(iConfig.template getParameter<edm::InputTag>("inputTag2")),
72  inputToken1_(consumes<trigger::TriggerFilterObjectWithRefs>(inputTag1_)),
73  inputToken2_(consumes<trigger::TriggerFilterObjectWithRefs>(inputTag2_)),
74  electronToken_ (consumes<reco::ElectronCollection>(iConfig.template getParameter<edm::InputTag>("electronTag"))),
75  triggerType1_(iConfig.template getParameter<int>("triggerType1")),
76  triggerType2_(iConfig.template getParameter<int>("triggerType2")),
77  minDR_ (iConfig.template getParameter<double>("MinDR")),
78  maxDZ_ (iConfig.template getParameter<double>("MaxDZ")),
79  min_N_ (iConfig.template getParameter<int>("MinN")),
80  checkSC_ (iConfig.template getParameter<bool>("checkSC")),
81  same_ (inputTag1_.encode()==inputTag2_.encode()) // same collections to be compared?
82 {}
83 
84 template<>
86  HLTFilter(iConfig),
87  originTag1_(iConfig.template getParameter<std::vector<edm::InputTag> >("originTag1")),
88  originTag2_(iConfig.template getParameter<std::vector<edm::InputTag> >("originTag2")),
89  inputTag1_(iConfig.template getParameter<edm::InputTag>("inputTag1")),
90  inputTag2_(iConfig.template getParameter<edm::InputTag>("inputTag2")),
91  inputToken1_(consumes<trigger::TriggerFilterObjectWithRefs>(inputTag1_)),
92  inputToken2_(consumes<trigger::TriggerFilterObjectWithRefs>(inputTag2_)),
93  electronToken_ (consumes<reco::ElectronCollection>(iConfig.template getParameter<edm::InputTag>("electronTag"))),
94  triggerType1_(iConfig.template getParameter<int>("triggerType1")),
95  triggerType2_(iConfig.template getParameter<int>("triggerType2")),
96  minDR_ (iConfig.template getParameter<double>("MinDR")),
97  maxDZ_ (iConfig.template getParameter<double>("MaxDZ")),
98  min_N_ (iConfig.template getParameter<int>("MinN")),
99  checkSC_ (iConfig.template getParameter<bool>("checkSC")),
100  same_ (inputTag1_.encode()==inputTag2_.encode()) // same collections to be compared?
101 {}
102 
103 template<typename T1, typename T2>
105 {}
106 
107 template<typename T1, typename T2>
108 void
111  makeHLTFilterDescription(desc);
112  std::vector<edm::InputTag> originTag1(1,edm::InputTag("hltOriginal1"));
113  std::vector<edm::InputTag> originTag2(1,edm::InputTag("hltOriginal2"));
114  desc.add<std::vector<edm::InputTag> >("originTag1",originTag1);
115  desc.add<std::vector<edm::InputTag> >("originTag2",originTag2);
116  desc.add<edm::InputTag>("inputTag1",edm::InputTag("hltFiltered1"));
117  desc.add<edm::InputTag>("inputTag2",edm::InputTag("hltFiltered2"));
118  desc.add<int>("triggerType1",0);
119  desc.add<int>("triggerType2",0);
120  desc.add<double>("MinDR",-1.0);
121  desc.add<double>("MaxDZ",0.2);
122  desc.add<bool>("checkSC",false);
123  desc.add<int>("MinN",1);
124  descriptions.add(std::string("hlt")+std::string(typeid(HLTDoubletDZ<T1,T2>).name()),desc);
125 }
126 
127 template<>
128 void
131  makeHLTFilterDescription(desc);
132  std::vector<edm::InputTag> originTag1(1,edm::InputTag("hltOriginal1"));
133  std::vector<edm::InputTag> originTag2(1,edm::InputTag("hltOriginal2"));
134  desc.add<std::vector<edm::InputTag> >("originTag1",originTag1);
135  desc.add<std::vector<edm::InputTag> >("originTag2",originTag2);
136  desc.add<edm::InputTag>("inputTag1",edm::InputTag("hltFiltered1"));
137  desc.add<edm::InputTag>("inputTag2",edm::InputTag("hltFiltered2"));
138  desc.add<edm::InputTag>("electronTag",edm::InputTag("electronTag"));
139  desc.add<int>("triggerType1",0);
140  desc.add<int>("triggerType2",0);
141  desc.add<double>("MinDR",-1.0);
142  desc.add<double>("MaxDZ",0.2);
143  desc.add<bool>("checkSC",false);
144  desc.add<int>("MinN",1);
146 }
147 
148 template<>
149 void
152  makeHLTFilterDescription(desc);
153  std::vector<edm::InputTag> originTag1(1,edm::InputTag("hltOriginal1"));
154  std::vector<edm::InputTag> originTag2(1,edm::InputTag("hltOriginal2"));
155  desc.add<std::vector<edm::InputTag> >("originTag1",originTag1);
156  desc.add<std::vector<edm::InputTag> >("originTag2",originTag2);
157  desc.add<edm::InputTag>("inputTag1",edm::InputTag("hltFiltered1"));
158  desc.add<edm::InputTag>("inputTag2",edm::InputTag("hltFiltered2"));
159  desc.add<edm::InputTag>("electronTag",edm::InputTag("electronTag"));
160  desc.add<int>("triggerType1",0);
161  desc.add<int>("triggerType2",0);
162  desc.add<double>("MinDR",-1.0);
163  desc.add<double>("MaxDZ",0.2);
164  desc.add<bool>("checkSC",false);
165  desc.add<int>("MinN",1);
167 }
168 
169 template<>
170 void
173  makeHLTFilterDescription(desc);
174  std::vector<edm::InputTag> originTag1(1,edm::InputTag("hltOriginal1"));
175  std::vector<edm::InputTag> originTag2(1,edm::InputTag("hltOriginal2"));
176  desc.add<std::vector<edm::InputTag> >("originTag1",originTag1);
177  desc.add<std::vector<edm::InputTag> >("originTag2",originTag2);
178  desc.add<edm::InputTag>("inputTag1",edm::InputTag("hltFiltered1"));
179  desc.add<edm::InputTag>("inputTag2",edm::InputTag("hltFiltered2"));
180  desc.add<edm::InputTag>("electronTag",edm::InputTag("electronTag"));
181  desc.add<int>("triggerType1",0);
182  desc.add<int>("triggerType2",0);
183  desc.add<double>("MinDR",-1.0);
184  desc.add<double>("MaxDZ",0.2);
185  desc.add<bool>("checkSC",false);
186  desc.add<int>("MinN",1);
188 }
189 
190 template<typename T1, typename T2>
191 bool
192 //HLTDoubletDZ<T1, T2>::getCollections(edm::Event& iEvent, std::vector<T1Ref>& coll1, std::vector<T2Ref>& coll2) const {
193 HLTDoubletDZ<T1, T2>::getCollections(edm::Event& iEvent, std::vector<T1Ref>& coll1, std::vector<T2Ref>& coll2, trigger::TriggerFilterObjectWithRefs & filterproduct) const {
194 
196  if (iEvent.getByToken(inputToken1_, handle1) and iEvent.getByToken(inputToken2_, handle2)) {
197 
198  // get hold of pre-filtered object collections
199  handle1->getObjects(triggerType1_, coll1);
200  handle2->getObjects(triggerType2_, coll2);
201  const trigger::size_type n1(coll1.size());
202  const trigger::size_type n2(coll2.size());
203 
204  if (saveTags()) {
205  edm::InputTag tagOld;
206  for (unsigned int i=0; i<originTag1_.size(); ++i) {
207  filterproduct.addCollectionTag(originTag1_[i]);
208  }
209  tagOld=edm::InputTag();
210  for (trigger::size_type i1=0; i1!=n1; ++i1) {
211  const edm::ProductID pid(coll1[i1].id());
212  const std::string& label(iEvent.getProvenance(pid).moduleLabel());
214  const std::string& process(iEvent.getProvenance(pid).processName());
216  if (tagOld.encode()!=tagNew.encode()) {
217  filterproduct.addCollectionTag(tagNew);
218  tagOld=tagNew;
219  }
220  }
221  for (unsigned int i=0; i<originTag2_.size(); ++i) {
222  filterproduct.addCollectionTag(originTag2_[i]);
223  }
224  tagOld=edm::InputTag();
225  for (trigger::size_type i2=0; i2!=n2; ++i2) {
226  const edm::ProductID pid(coll2[i2].id());
227  const std::string& label(iEvent.getProvenance(pid).moduleLabel());
229  const std::string& process(iEvent.getProvenance(pid).processName());
231  if (tagOld.encode()!=tagNew.encode()) {
232  filterproduct.addCollectionTag(tagNew);
233  tagOld=tagNew;
234  }
235  }
236  }
237 
238  return true;
239  } else
240  return false;
241 }
242 
243 template<typename T1, typename T2>
244 bool
246 {
247 
248  const reco::Candidate& candidate1(*r1);
249  const reco::Candidate& candidate2(*r2);
250  if ( reco::deltaR(candidate1, candidate2) < minDR_ )
251  return false;
252  if ( std::abs(candidate1.vz()-candidate2.vz()) > maxDZ_ )
253  return false;
254 
255  return true;
256 }
257 
258 template<>
259 bool
261 {
263  iEvent.getByToken(electronToken_, electronHandle_);
264  if (!electronHandle_.isValid())
265  edm::LogError("HLTDoubletDZ") << "HLTDoubletDZ: Electron Handle not valid.";
266 
267  if ( reco::deltaR(*r1, *r2) < minDR_ )
268  return false;
269  reco::Electron e1;
270  for(reco::ElectronCollection::const_iterator eleIt = electronHandle_->begin(); eleIt != electronHandle_->end(); eleIt++) {
271  if (eleIt->superCluster() == r1->superCluster())
272  e1 = *(eleIt);
273  }
274 
275  const reco::Candidate& candidate2(*r2);
276  if ( std::abs(e1.vz()-candidate2.vz()) > maxDZ_ )
277  return false;
278 
279  return true;
280 }
281 
282 template<>
283 bool
285 {
287  iEvent.getByToken(electronToken_, electronHandle_);
288  if (!electronHandle_.isValid())
289  edm::LogError("HLTDoubletDZ") << "HLTDoubletDZ: Electron Handle not valid.";
290 
291  if ( reco::deltaR(*r1, *r2) < minDR_ )
292  return false;
293  reco::Electron e2;
294  for(reco::ElectronCollection::const_iterator eleIt = electronHandle_->begin(); eleIt != electronHandle_->end(); eleIt++) {
295  if (eleIt->superCluster() == r2->superCluster())
296  e2 = *(eleIt);
297  }
298 
299  const reco::Candidate& candidate1(*r1);
300  if ( std::abs(e2.vz()-candidate1.vz()) > maxDZ_ )
301  return false;
302 
303  return true;
304 }
305 
306 template<>
307 bool
309 {
311  iEvent.getByToken(electronToken_, electronHandle_);
312  if (!electronHandle_.isValid())
313  edm::LogError("HLTDoubletDZ") << "HLTDoubletDZ: Electron Handle not valid.";
314 
315  if ( reco::deltaR(*r1, *r2) < minDR_ )
316  return false;
317  reco::Electron e1, e2;
318  for(reco::ElectronCollection::const_iterator eleIt = electronHandle_->begin(); eleIt != electronHandle_->end(); eleIt++) {
319  if (eleIt->superCluster() == r2->superCluster())
320  e2 = *(eleIt);
321  if (eleIt->superCluster() == r1->superCluster())
322  e1 = *(eleIt);
323  }
324 
325  if ( std::abs(e2.vz()-e1.vz()) > maxDZ_ )
326  return false;
327 
328  return true;
329 }
330 
331 // ------------ method called to produce the data ------------
332 template<typename T1, typename T2>
333 bool
335 {
336 
337  // All HLT filters must create and fill an HLT filter object,
338  // recording any reconstructed physics objects satisfying (or not)
339  // this HLT filter, and place it in the Event.
340  bool accept(false);
341 
342  std::vector<T1Ref> coll1;
343  std::vector<T2Ref> coll2;
344 
345  if (getCollections(iEvent, coll1, coll2, filterproduct)) {
346  int n(0);
347  T1Ref r1;
348  T2Ref r2;
349 
350  for (unsigned int i1=0; i1!=coll1.size(); i1++) {
351  r1=coll1[i1];
352  //const reco::Candidate& candidate1(*r1);
353  unsigned int I(0);
354  if (same_) {I=i1+1;}
355  for (unsigned int i2=I; i2!=coll2.size(); i2++) {
356  r2=coll2[i2];
357  if (checkSC_) {
358  if (r1->superCluster().isNonnull() && r2->superCluster().isNonnull()) {
359  if (r1->superCluster() == r2->superCluster()) continue;
360  }
361  }
362 
363  if (!computeDZ(iEvent, r1, r2))
364  continue;
365 
366  n++;
367  filterproduct.addObject(triggerType1_,r1);
368  filterproduct.addObject(triggerType2_,r2);
369  }
370  }
371 
372  accept = accept || (n>=min_N_);
373  }
374 
375  return accept;
376 }
377 
384 
int i
Definition: DBlmapReader.cc:9
HLTDoubletDZ(const edm::ParameterSet &)
Definition: HLTDoubletDZ.cc:28
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static PFTauRenderPlugin instance
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
HLTDoubletDZ< reco::RecoEcalCandidate, reco::RecoChargedCandidate > HLT2PhotonMuonDZ
HLTDoubletDZ< reco::Electron, reco::Electron > HLT2ElectronElectronDZ
double deltaR(const T1 &t1, const T2 &t2)
Definition: deltaR.h:48
std::string const & processName() const
Definition: Provenance.h:62
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:25
uint16_t size_type
std::string encode() const
Definition: InputTag.cc:164
bool getCollections(edm::Event &iEvent, std::vector< T1Ref > &coll1, std::vector< T2Ref > &coll2, trigger::TriggerFilterObjectWithRefs &filterproduct) const
void addObject(int id, const reco::RecoEcalCandidateRef &ref)
setters for L3 collections: (id=physics type, and Ref&lt;C&gt;)
int iEvent
Definition: GenABIO.cc:230
bool computeDZ(edm::Event &iEvent, T1Ref &c1, T2Ref &c2) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const std::complex< double > I
Definition: I.h:8
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:76
virtual double vz() const
z coordinate of vertex position
std::vector< Electron > ElectronCollection
collectin of Electron objects
Definition: ElectronFwd.h:9
virtual bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
HLTDoubletDZ< reco::RecoChargedCandidate, reco::RecoChargedCandidate > HLT2MuonMuonDZ
HLTDoubletDZ< reco::Electron, reco::RecoChargedCandidate > HLT2ElectronMuonDZ
HLTDoubletDZ< reco::RecoEcalCandidate, reco::RecoEcalCandidate > HLT2PhotonPhotonDZ
tuple pid
Definition: sysUtil.py:22
void addCollectionTag(const edm::InputTag &collectionTag)
collectionTags
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::string const & moduleLabel() const
Definition: Provenance.h:61
HLTDoubletDZ< reco::RecoChargedCandidate, reco::RecoEcalCandidate > HLT2MuonPhotonDZ
virtual double vz() const =0
z coordinate of vertex position
std::string const & productInstanceName() const
Definition: Provenance.h:63
tuple process
Definition: LaserDQM_cfg.py:3
Provenance getProvenance(BranchID const &theID) const
Definition: Event.cc:73
def template
Definition: svgfig.py:520