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, int Tid1, typename T2, int Tid2>
31  inputTag1_(iConfig.template getParameter<edm::InputTag>("inputTag1")),
32  inputTag2_(iConfig.template getParameter<edm::InputTag>("inputTag2")),
33  saveTags_ (iConfig.template getUntrackedParameter<bool>("saveTags",false)),
34  min_Dphi_ (iConfig.template getParameter<double>("MinDphi")),
35  max_Dphi_ (iConfig.template getParameter<double>("MaxDphi")),
36  min_Deta_ (iConfig.template getParameter<double>("MinDeta")),
37  max_Deta_ (iConfig.template getParameter<double>("MaxDeta")),
38  min_Minv_ (iConfig.template getParameter<double>("MinMinv")),
39  max_Minv_ (iConfig.template getParameter<double>("MaxMinv")),
40  min_DelR_ (iConfig.template getParameter<double>("MinDelR")),
41  max_DelR_ (iConfig.template getParameter<double>("MaxDelR")),
42  min_N_ (iConfig.template getParameter<int>("MinN")),
43  coll1_(),
44  coll2_()
45 {
46  // same collections to be compared?
48 
49  cutdphi_ = (min_Dphi_ <= max_Dphi_); // cut active?
50  cutdeta_ = (min_Deta_ <= max_Deta_); // cut active?
51  cutminv_ = (min_Minv_ <= max_Minv_); // cut active?
52  cutdelr_ = (min_DelR_ <= max_DelR_); // cut active?
53 
54  LogDebug("") << "InputTags and cuts : "
55  << inputTag1_.encode() << " " << inputTag2_.encode()
56  << " Dphi [" << min_Dphi_ << " " << max_Dphi_ << "]"
57  << " Deta [" << min_Deta_ << " " << max_Deta_ << "]"
58  << " Minv [" << min_Minv_ << " " << max_Minv_ << "]"
59  << " DelR [" << min_DelR_ << " " << max_DelR_ << "]"
60  << " MinN =" << min_N_
61  << " same/dphi/deta/minv/delr "
62  << same_ << cutdphi_ << cutdeta_ << cutminv_ << cutdelr_;
63 
64  //register your products
65  produces<trigger::TriggerFilterObjectWithRefs>();
66 }
67 
68 template<typename T1, int Tid1, typename T2, int Tid2>
70 {
71 }
72 
73 //
74 // member functions
75 //
76 
77 // ------------ method called to produce the data ------------
78 template<typename T1, int Tid1, typename T2, int Tid2>
79 bool
81 {
82  using namespace std;
83  using namespace edm;
84  using namespace reco;
85  using namespace trigger;
86 
87  // All HLT filters must create and fill an HLT filter object,
88  // recording any reconstructed physics objects satisfying (or not)
89  // this HLT filter, and place it in the Event.
90 
91  // The filter object
92  auto_ptr<TriggerFilterObjectWithRefs>
93  filterobject (new TriggerFilterObjectWithRefs(path(),module()));
94  // Don't saveTag the TFOWRs, but rather the collections pointed to!
95  // if (saveTags_) {
96  // filterobject->addCollectionTag(inputTag1_);
97  // filterobject->addCollectionTag(inputTag2_);
98  // }
99  bool accept(false);
100 
101  // get hold of pre-filtered object collections
103  if (iEvent.getByLabel (inputTag1_,coll1) && iEvent.getByLabel (inputTag2_,coll2)) {
104  coll1_.clear();
105  coll1->getObjects(Tid1,coll1_);
106  const size_type n1(coll1_.size());
107  coll2_.clear();
108  coll2->getObjects(Tid2,coll2_);
109  const size_type n2(coll2_.size());
110 
111  if (saveTags_) {
112  InputTag tagOld;
113  tagOld=InputTag();
114  for (size_type i1=0; i1!=n1; ++i1) {
115  const ProductID pid(coll1_[i1].id());
116  const string& label(iEvent.getProvenance(pid).moduleLabel());
117  const string& instance(iEvent.getProvenance(pid).productInstanceName());
118  const string& process(iEvent.getProvenance(pid).processName());
119  InputTag tagNew(InputTag(label,instance,process));
120  if (tagOld.encode()!=tagNew.encode()) {
121  filterobject->addCollectionTag(tagNew);
122  tagOld=tagNew;
123  }
124  }
125  tagOld=InputTag();
126  for (size_type i2=0; i2!=n2; ++i2) {
127  const ProductID pid(coll2_[i2].id());
128  const string& label(iEvent.getProvenance(pid).moduleLabel());
129  const string& instance(iEvent.getProvenance(pid).productInstanceName());
130  const string& process(iEvent.getProvenance(pid).processName());
131  InputTag tagNew(InputTag(label,instance,process));
132  if (tagOld.encode()!=tagNew.encode()) {
133  filterobject->addCollectionTag(tagNew);
134  tagOld=tagNew;
135  }
136  }
137  }
138 
139  int n(0);
140  T1Ref r1;
141  T2Ref r2;
143  for (unsigned int i1=0; i1!=n1; i1++) {
144  r1=coll1_[i1];
145  p1=r1->p4();
146  unsigned int I(0);
147  if (same_) {I=i1+1;}
148  for (unsigned int i2=I; i2!=n2; i2++) {
149  r2=coll2_[i2];
150  p2=r2->p4();
151 
152  double Dphi(std::abs(p1.phi()-p2.phi()));
153  if (Dphi>M_PI) Dphi=2.0*M_PI-Dphi;
154 
155  double Deta(std::abs(p1.eta()-p2.eta()));
156 
157  p=p1+p2;
158  double Minv(std::abs(p.mass()));
159 
160  double DelR(sqrt(Dphi*Dphi+Deta*Deta));
161 
162  if ( ( (!cutdphi_) || ((min_Dphi_<=Dphi) && (Dphi<=max_Dphi_)) ) &&
163  ( (!cutdeta_) || ((min_Deta_<=Deta) && (Deta<=max_Deta_)) ) &&
164  ( (!cutminv_) || ((min_Minv_<=Minv) && (Minv<=max_Minv_)) ) &&
165  ( (!cutdelr_) || ((min_DelR_<=DelR) && (DelR<=max_DelR_)) ) ) {
166  n++;
167  filterobject->addObject(Tid1,r1);
168  filterobject->addObject(Tid2,r2);
169  }
170 
171  }
172  }
173  // filter decision
174  accept = accept || (n>=min_N_);
175  }
176 
177  iEvent.put(filterobject);
178  return accept;
179 }
#define LogDebug(id)
bool cutdelr_
Definition: HLTDoublet.h:52
edm::InputTag inputTag1_
Definition: HLTDoublet.h:41
int module() const
Definition: HLTadd.h:12
double min_Deta_
Definition: HLTDoublet.h:45
double max_DelR_
Definition: HLTDoublet.h:47
const std::string & label
Definition: MVAComputer.cc:186
int min_N_
Definition: HLTDoublet.h:48
double min_Dphi_
Definition: HLTDoublet.h:44
edm::InputTag inputTag2_
Definition: HLTDoublet.h:42
#define abs(x)
Definition: mlp_lapack.h:159
bool cutminv_
Definition: HLTDoublet.h:52
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:21
uint16_t size_type
std::string encode() const
Definition: InputTag.cc:72
double min_DelR_
Definition: HLTDoublet.h:47
int path() const
Definition: HLTadd.h:3
double max_Dphi_
Definition: HLTDoublet.h:44
int iEvent
Definition: GenABIO.cc:243
virtual bool filter(edm::Event &, const edm::EventSetup &)
Definition: HLTDoublet.cc:80
double min_Minv_
Definition: HLTDoublet.h:46
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
double max_Minv_
Definition: HLTDoublet.h:46
T sqrt(T t)
Definition: SSEVec.h:28
const std::complex< double > I
Definition: I.h:8
bool cutdeta_
Definition: HLTDoublet.h:52
HLTDoublet(const edm::ParameterSet &)
Definition: HLTDoublet.cc:30
double p2[4]
Definition: TauolaWrapper.h:90
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
#define M_PI
Definition: BFit3D.cc:3
std::string const & moduleLabel() const
Definition: Provenance.h:62
bool cutdphi_
Definition: HLTDoublet.h:52
double max_Deta_
Definition: HLTDoublet.h:45
bool same_
Definition: HLTDoublet.h:51
tuple process
Definition: align_tpl.py:3
double p1[4]
Definition: TauolaWrapper.h:89
std::string const & productInstanceName() const
Definition: Provenance.h:65
Provenance getProvenance(BranchID const &theID) const
Definition: Event.cc:61
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:26
def template
Definition: svgfig.py:520