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 
10 
12 
14 
15 #include<cmath>
16 
17 //
18 // constructors and destructor
19 //
20 template<typename T1, typename T2>
22  originTag1_(iConfig.template getParameter<std::vector<edm::InputTag> >("originTag1")),
23  originTag2_(iConfig.template getParameter<std::vector<edm::InputTag> >("originTag2")),
24  inputTag1_(iConfig.template getParameter<edm::InputTag>("inputTag1")),
25  inputTag2_(iConfig.template getParameter<edm::InputTag>("inputTag2")),
26  inputToken1_(consumes<trigger::TriggerFilterObjectWithRefs>(inputTag1_)),
27  inputToken2_(consumes<trigger::TriggerFilterObjectWithRefs>(inputTag2_)),
28  triggerType1_(iConfig.template getParameter<int>("triggerType1")),
29  triggerType2_(iConfig.template getParameter<int>("triggerType2")),
30  minDR_ (iConfig.template getParameter<double>("MinDR")),
31  maxDZ_ (iConfig.template getParameter<double>("MaxDZ")),
32  min_N_ (iConfig.template getParameter<int>("MinN")),
33  checkSC_ (iConfig.template getParameter<bool>("checkSC")),
34  same_ (inputTag1_.encode()==inputTag2_.encode()) // same collections to be compared?
35 {
36 }
37 
38 template<typename T1, typename T2>
40 {
41 }
42 
43 template<typename T1, typename T2>
44 void
47  makeHLTFilterDescription(desc);
48  std::vector<edm::InputTag> originTag1(1,edm::InputTag("hltOriginal1"));
49  std::vector<edm::InputTag> originTag2(1,edm::InputTag("hltOriginal2"));
50  desc.add<std::vector<edm::InputTag> >("originTag1",originTag1);
51  desc.add<std::vector<edm::InputTag> >("originTag2",originTag2);
52  desc.add<edm::InputTag>("inputTag1",edm::InputTag("hltFiltered1"));
53  desc.add<edm::InputTag>("inputTag2",edm::InputTag("hltFiltered2"));
54  desc.add<int>("triggerType1",0);
55  desc.add<int>("triggerType2",0);
56  desc.add<double>("MinDR",-1.0);
57  desc.add<double>("MaxDZ",0.2);
58  desc.add<bool>("checkSC",false);
59  desc.add<int>("MinN",1);
60  descriptions.add(std::string("hlt")+std::string(typeid(HLTDoubletDZ<T1,T2>).name()),desc);
61 }
62 
63 // ------------ method called to produce the data ------------
64 template<typename T1, typename T2>
65 bool
67 {
68  using namespace std;
69  using namespace edm;
70  using namespace reco;
71  using namespace trigger;
72 
73  // All HLT filters must create and fill an HLT filter object,
74  // recording any reconstructed physics objects satisfying (or not)
75  // this HLT filter, and place it in the Event.
76 
77  bool accept(false);
78 
79  LogVerbatim("HLTDoubletDZ") << " XXX " << moduleLabel() << " 0 " << std::endl;
80 
81  std::vector<T1Ref> coll1;
82  std::vector<T2Ref> coll2;
83 
84  // get hold of pre-filtered object collections
86  if (iEvent.getByToken(inputToken1_, handle1) and iEvent.getByToken(inputToken2_, handle2)) {
87  handle1->getObjects(triggerType1_, coll1);
88  handle2->getObjects(triggerType2_, coll2);
89  const size_type n1(coll1.size());
90  const size_type n2(coll2.size());
91 
92  if (saveTags()) {
93  InputTag tagOld;
94  for (unsigned int i=0; i<originTag1_.size(); ++i) {
95  filterproduct.addCollectionTag(originTag1_[i]);
96  LogVerbatim("HLTDoubletDZ") << " XXX " << moduleLabel() << " 1a/" << i << " " << originTag1_[i].encode() << std::endl;
97  }
98  tagOld=InputTag();
99  for (size_type i1=0; i1!=n1; ++i1) {
100  const ProductID pid(coll1[i1].id());
101  const string& label(iEvent.getProvenance(pid).moduleLabel());
102  const string& instance(iEvent.getProvenance(pid).productInstanceName());
103  const string& process(iEvent.getProvenance(pid).processName());
104  InputTag tagNew(InputTag(label,instance,process));
105  if (tagOld.encode()!=tagNew.encode()) {
106  filterproduct.addCollectionTag(tagNew);
107  tagOld=tagNew;
108  LogVerbatim("HLTDoubletDZ") << " XXX " << moduleLabel() << " 1b " << tagNew.encode() << std::endl;
109  }
110  }
111  for (unsigned int i=0; i<originTag2_.size(); ++i) {
112  filterproduct.addCollectionTag(originTag2_[i]);
113  LogVerbatim("HLTDoubletDZ") << " XXX " << moduleLabel() << " 2a/" << originTag2_[i].encode() << std::endl;
114  }
115  tagOld=InputTag();
116  for (size_type i2=0; i2!=n2; ++i2) {
117  const ProductID pid(coll2[i2].id());
118  const string& label(iEvent.getProvenance(pid).moduleLabel());
119  const string& instance(iEvent.getProvenance(pid).productInstanceName());
120  const string& process(iEvent.getProvenance(pid).processName());
121  InputTag tagNew(InputTag(label,instance,process));
122  if (tagOld.encode()!=tagNew.encode()) {
123  filterproduct.addCollectionTag(tagNew);
124  tagOld=tagNew;
125  LogVerbatim("HLTDoubletDZ") << " XXX " << moduleLabel() << " 2b " << tagNew.encode() << std::endl;
126  }
127  }
128  }
129 
130  int n(0);
131  T1Ref r1;
132  T2Ref r2;
134  for (unsigned int i1=0; i1!=n1; i1++) {
135  r1=coll1[i1];
136  const reco::Candidate& candidate1(*r1);
137  unsigned int I(0);
138  if (same_) {I=i1+1;}
139  for (unsigned int i2=I; i2!=n2; i2++) {
140  r2=coll2[i2];
141  if (checkSC_) {
142  if (r1->superCluster().isNonnull() && r2->superCluster().isNonnull()) {
143  if (r1->superCluster() == r2->superCluster()) continue;
144  }
145  }
146  const reco::Candidate& candidate2(*r2);
147  if ( reco::deltaR(candidate1, candidate2) < minDR_ ) continue;
148  if ( std::abs(candidate1.vz()-candidate2.vz()) > maxDZ_ ) continue;
149  n++;
150  filterproduct.addObject(triggerType1_,r1);
151  filterproduct.addObject(triggerType2_,r2);
152  }
153  }
154  // filter decision
155  accept = accept || (n>=min_N_);
156  }
157 
158  return accept;
159 }
int i
Definition: DBlmapReader.cc:9
HLTDoubletDZ(const edm::ParameterSet &)
Definition: HLTDoubletDZ.cc:21
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTDoubletDZ.cc:45
static PFTauRenderPlugin instance
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
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:26
uint16_t size_type
void addObject(int id, const reco::RecoEcalCandidateRef &ref)
setters for L3 collections: (id=physics type, and Ref&lt;C&gt;)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
int iEvent
Definition: GenABIO.cc:230
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)
double p2[4]
Definition: TauolaWrapper.h:90
virtual bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
Definition: HLTDoubletDZ.cc:66
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
virtual double vz() const =0
z coordinate of vertex position
double p1[4]
Definition: TauolaWrapper.h:89
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:76
def template
Definition: svgfig.py:520
math::PtEtaPhiELorentzVectorF LorentzVector