CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTDoublet.cc
Go to the documentation of this file.
1 
14 
16 
19 
21 
23 
24 #include<cmath>
25 
26 //
27 // constructors and destructor
28 //
29 template<typename T1, typename T2>
31  originTag1_(iConfig.template getParameter<edm::InputTag>("originTag1")),
32  originTag2_(iConfig.template getParameter<edm::InputTag>("originTag2")),
33  inputTag1_(iConfig.template getParameter<edm::InputTag>("inputTag1")),
34  inputTag2_(iConfig.template getParameter<edm::InputTag>("inputTag2")),
35  triggerType1_(iConfig.template getParameter<int>("triggerType1")),
36  triggerType2_(iConfig.template getParameter<int>("triggerType2")),
37  min_Dphi_ (iConfig.template getParameter<double>("MinDphi")),
38  max_Dphi_ (iConfig.template getParameter<double>("MaxDphi")),
39  min_Deta_ (iConfig.template getParameter<double>("MinDeta")),
40  max_Deta_ (iConfig.template getParameter<double>("MaxDeta")),
41  min_Minv_ (iConfig.template getParameter<double>("MinMinv")),
42  max_Minv_ (iConfig.template getParameter<double>("MaxMinv")),
43  min_DelR_ (iConfig.template getParameter<double>("MinDelR")),
44  max_DelR_ (iConfig.template getParameter<double>("MaxDelR")),
45  min_Pt_ (iConfig.template getParameter<double>("MinPt")),
46  max_Pt_ (iConfig.template getParameter<double>("MaxPt")),
47  min_N_ (iConfig.template getParameter<int>("MinN")),
48  label_ (iConfig.getParameter<std::string>("@module_label")),
49  coll1_(),
50  coll2_()
51 {
52 
53  // same collections to be compared?
55 
56  cutdphi_ = (min_Dphi_ <= max_Dphi_); // cut active?
57  cutdeta_ = (min_Deta_ <= max_Deta_); // cut active?
58  cutminv_ = (min_Minv_ <= max_Minv_); // cut active?
59  cutdelr_ = (min_DelR_ <= max_DelR_); // cut active?
60  cutpt_ = (min_Pt_ <= max_Pt_ ); // cut active?
61 
62  LogDebug("") << "InputTags and cuts : "
63  << inputTag1_.encode() << " " << inputTag2_.encode()
64  << triggerType1_ << " " << triggerType2_
65  << " Dphi [" << min_Dphi_ << " " << max_Dphi_ << "]"
66  << " Deta [" << min_Deta_ << " " << max_Deta_ << "]"
67  << " Minv [" << min_Minv_ << " " << max_Minv_ << "]"
68  << " DelR [" << min_DelR_ << " " << max_DelR_ << "]"
69  << " Pt [" << min_Pt_ << " " << max_Pt_ << "]"
70  << " MinN =" << min_N_
71  << " same/dphi/deta/minv/delr/pt "
72  << same_
73  << cutdphi_ << cutdeta_ << cutminv_ << cutdelr_ << cutpt_;
74 }
75 
76 template<typename T1, typename T2>
78 {
79 }
80 template<typename T1, typename T2>
81 void
84  makeHLTFilterDescription(desc);
85  desc.add<edm::InputTag>("originTag1",edm::InputTag("hltOriginal1"));
86  desc.add<edm::InputTag>("originTag2",edm::InputTag("hltOriginal2"));
87  desc.add<edm::InputTag>("inputTag1",edm::InputTag("hltFiltered1"));
88  desc.add<edm::InputTag>("inputTag2",edm::InputTag("hltFiltered22"));
89  desc.add<int>("triggerType1",0);
90  desc.add<int>("triggerType2",0);
91  desc.add<double>("MinDphi",+1.0);
92  desc.add<double>("MaxDphi",-1.0);
93  desc.add<double>("MinDeta",+1.0);
94  desc.add<double>("MaxDeta",-1.0);
95  desc.add<double>("MinMinv",+1.0);
96  desc.add<double>("MaxMinv",-1.0);
97  desc.add<double>("MinDelR",+1.0);
98  desc.add<double>("MaxDelR",-1.0);
99  desc.add<double>("MinPt" ,+1.0);
100  desc.add<double>("MaxPt" ,-1.0);
101  desc.add<int>("MinN",1);
102  descriptions.add(std::string("hlt")+std::string(typeid(HLTDoublet<T1,T2>).name()),desc);
103 }
104 
105 //
106 // member functions
107 //
108 
109 // ------------ method called to produce the data ------------
110 template<typename T1, typename T2>
111 bool
113 {
114  using namespace std;
115  using namespace edm;
116  using namespace reco;
117  using namespace trigger;
118 
119  // All HLT filters must create and fill an HLT filter object,
120  // recording any reconstructed physics objects satisfying (or not)
121  // this HLT filter, and place it in the Event.
122 
123  bool accept(false);
124 
125  LogVerbatim("HLTDoublet") << " XXX " << label_ << " 0 " << std::endl;
126 
127  // get hold of pre-filtered object collections
129  if (iEvent.getByLabel (inputTag1_,coll1) && iEvent.getByLabel (inputTag2_,coll2)) {
130  coll1_.clear();
131  coll1->getObjects(triggerType1_,coll1_);
132  const size_type n1(coll1_.size());
133  coll2_.clear();
134  coll2->getObjects(triggerType2_,coll2_);
135  const size_type n2(coll2_.size());
136 
137  if (saveTags()) {
138  InputTag tagOld;
139  filterproduct.addCollectionTag(originTag1_);
140  LogVerbatim("HLTDoublet") << " XXX " << label_ << " 1a " << originTag1_.encode() << std::endl;
141  tagOld=InputTag();
142  for (size_type i1=0; i1!=n1; ++i1) {
143  const ProductID pid(coll1_[i1].id());
144  const string& label(iEvent.getProvenance(pid).moduleLabel());
145  const string& instance(iEvent.getProvenance(pid).productInstanceName());
146  const string& process(iEvent.getProvenance(pid).processName());
148  if (tagOld.encode()!=tagNew.encode()) {
149  filterproduct.addCollectionTag(tagNew);
150  tagOld=tagNew;
151  LogVerbatim("HLTDoublet") << " XXX " << label_ << " 1b " << tagNew.encode() << std::endl;
152  }
153  }
154  filterproduct.addCollectionTag(originTag2_);
155  LogVerbatim("HLTDoublet") << " XXX " << label_ << " 2a " << originTag2_.encode() << std::endl;
156  tagOld=InputTag();
157  for (size_type i2=0; i2!=n2; ++i2) {
158  const ProductID pid(coll2_[i2].id());
159  const string& label(iEvent.getProvenance(pid).moduleLabel());
160  const string& instance(iEvent.getProvenance(pid).productInstanceName());
161  const string& process(iEvent.getProvenance(pid).processName());
163  if (tagOld.encode()!=tagNew.encode()) {
164  filterproduct.addCollectionTag(tagNew);
165  tagOld=tagNew;
166  LogVerbatim("HLTDoublet") << " XXX " << label_ << " 2b " << tagNew.encode() << std::endl;
167  }
168  }
169  }
170 
171  int n(0);
172  T1Ref r1;
173  T2Ref r2;
175  for (unsigned int i1=0; i1!=n1; i1++) {
176  r1=coll1_[i1];
177  p1=r1->p4();
178  unsigned int I(0);
179  if (same_) {I=i1+1;}
180  for (unsigned int i2=I; i2!=n2; i2++) {
181  r2=coll2_[i2];
182  p2=r2->p4();
183 
184  double Dphi(std::abs(p1.phi()-p2.phi()));
185  if (Dphi>M_PI) Dphi=2.0*M_PI-Dphi;
186 
187  double Deta(std::abs(p1.eta()-p2.eta()));
188 
189  p=p1+p2;
190  double Minv(std::abs(p.mass()));
191  double Pt(p.pt());
192 
193  double DelR(sqrt(Dphi*Dphi+Deta*Deta));
194 
195  if ( ( (!cutdphi_) || ((min_Dphi_<=Dphi) && (Dphi<=max_Dphi_)) ) &&
196  ( (!cutdeta_) || ((min_Deta_<=Deta) && (Deta<=max_Deta_)) ) &&
197  ( (!cutminv_) || ((min_Minv_<=Minv) && (Minv<=max_Minv_)) ) &&
198  ( (!cutdelr_) || ((min_DelR_<=DelR) && (DelR<=max_DelR_)) ) &&
199  ( (!cutpt_ ) || ((min_Pt_ <=Pt ) && (Pt <=max_Pt_ )) ) ) {
200  n++;
201  filterproduct.addObject(triggerType1_,r1);
202  filterproduct.addObject(triggerType2_,r2);
203  }
204 
205  }
206  }
207  // filter decision
208  accept = (n>=min_N_);
209  }
210 
211  return accept;
212 }
#define LogDebug(id)
double min_Pt_
Definition: HLTDoublet.h:54
edm::InputTag inputTag1_
Definition: HLTDoublet.h:46
double max_Dphi_
Definition: HLTDoublet.h:50
HLTDoublet(const edm::ParameterSet &)
Definition: HLTDoublet.cc:30
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTDoublet.cc:82
bool cutpt_
Definition: HLTDoublet.h:59
static PFTauRenderPlugin instance
int triggerType2_
Definition: HLTDoublet.h:49
double max_Deta_
Definition: HLTDoublet.h:51
#define abs(x)
Definition: mlp_lapack.h:159
std::string const & processName() const
Definition: Provenance.h:63
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:22
uint16_t size_type
double min_DelR_
Definition: HLTDoublet.h:53
std::string encode() const
Definition: InputTag.cc:164
void addObject(int id, const reco::RecoEcalCandidateRef &ref)
setters for L3 collections: (id=physics type, and Ref&lt;C&gt;)
int triggerType1_
Definition: HLTDoublet.h:48
double min_Dphi_
Definition: HLTDoublet.h:50
int iEvent
Definition: GenABIO.cc:243
bool cutminv_
Definition: HLTDoublet.h:59
T sqrt(T t)
Definition: SSEVec.h:48
double max_DelR_
Definition: HLTDoublet.h:53
double min_Deta_
Definition: HLTDoublet.h:51
double min_Minv_
Definition: HLTDoublet.h:52
const std::complex< double > I
Definition: I.h:8
bool same_
Definition: HLTDoublet.h:58
ParameterDescriptionBase * add(U const &iLabel, T const &value)
double p2[4]
Definition: TauolaWrapper.h:90
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
bool cutdelr_
Definition: HLTDoublet.h:59
#define M_PI
Definition: BFit3D.cc:3
virtual bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct)
Definition: HLTDoublet.cc:112
void addCollectionTag(const edm::InputTag &collectionTag)
collectionTags
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::string const & moduleLabel() const
Definition: Provenance.h:62
double max_Pt_
Definition: HLTDoublet.h:54
double p1[4]
Definition: TauolaWrapper.h:89
int min_N_
Definition: HLTDoublet.h:55
std::string const & productInstanceName() const
Definition: Provenance.h:64
double max_Minv_
Definition: HLTDoublet.h:52
tuple process
Definition: LaserDQM_cfg.py:3
Provenance getProvenance(BranchID const &theID) const
Definition: Event.cc:68
bool cutdphi_
Definition: HLTDoublet.h:59
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:25
edm::InputTag inputTag2_
Definition: HLTDoublet.h:47
def template
Definition: svgfig.py:520
bool cutdeta_
Definition: HLTDoublet.h:59