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