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<edm::InputTag>("originTag1")),
23  originTag2_(iConfig.template getParameter<edm::InputTag>("originTag2")),
24  inputTag1_(iConfig.template getParameter<edm::InputTag>("inputTag1")),
25  inputTag2_(iConfig.template getParameter<edm::InputTag>("inputTag2")),
26  triggerType1_(iConfig.template getParameter<int>("triggerType1")),
27  triggerType2_(iConfig.template getParameter<int>("triggerType2")),
28  minDR_ (iConfig.template getParameter<double>("MinDR")),
29  maxDZ_ (iConfig.template getParameter<double>("MaxDZ")),
30  min_N_ (iConfig.template getParameter<int>("MinN")),
31  checkSC_ (iConfig.template getParameter<bool>("checkSC")),
32  label_ (iConfig.getParameter<std::string>("@module_label")),
33  coll1_(),
34  coll2_()
35 {
36  // same collections to be compared?
38 }
39 
40 template<typename T1, typename T2>
42 {
43 }
44 
45 template<typename T1, typename T2>
46 void
49  makeHLTFilterDescription(desc);
50  desc.add<edm::InputTag>("originTag1",edm::InputTag("hltOriginal1"));
51  desc.add<edm::InputTag>("originTag2",edm::InputTag("hltOriginal2"));
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 " << label_ << " 0 " << std::endl;
80 
81  // get hold of pre-filtered object collections
83  if (iEvent.getByLabel (inputTag1_,coll1) && iEvent.getByLabel (inputTag2_,coll2)) {
84  coll1_.clear();
85  coll1->getObjects(triggerType1_,coll1_);
86  const size_type n1(coll1_.size());
87  coll2_.clear();
88  coll2->getObjects(triggerType2_,coll2_);
89  const size_type n2(coll2_.size());
90 
91  if (saveTags()) {
92  InputTag tagOld;
93  filterproduct.addCollectionTag(originTag1_);
94  LogVerbatim("HLTDoubletDZ") << " XXX " << label_ << " 1a " << originTag1_.encode() << std::endl;
95  tagOld=InputTag();
96  for (size_type i1=0; i1!=n1; ++i1) {
97  const ProductID pid(coll1_[i1].id());
98  const string& label(iEvent.getProvenance(pid).moduleLabel());
99  const string& instance(iEvent.getProvenance(pid).productInstanceName());
100  const string& process(iEvent.getProvenance(pid).processName());
101  InputTag tagNew(InputTag(label,instance,process));
102  if (tagOld.encode()!=tagNew.encode()) {
103  filterproduct.addCollectionTag(tagNew);
104  tagOld=tagNew;
105  LogVerbatim("HLTDoubletDZ") << " XXX " << label_ << " 1b " << tagNew.encode() << std::endl;
106  }
107  }
108  filterproduct.addCollectionTag(originTag2_);
109  LogVerbatim("HLTDoubletDZ") << " XXX " << label_ << " 2a " << originTag2_.encode() << std::endl;
110  tagOld=InputTag();
111  for (size_type i2=0; i2!=n2; ++i2) {
112  const ProductID pid(coll2_[i2].id());
113  const string& label(iEvent.getProvenance(pid).moduleLabel());
114  const string& instance(iEvent.getProvenance(pid).productInstanceName());
115  const string& process(iEvent.getProvenance(pid).processName());
116  InputTag tagNew(InputTag(label,instance,process));
117  if (tagOld.encode()!=tagNew.encode()) {
118  filterproduct.addCollectionTag(tagNew);
119  tagOld=tagNew;
120  LogVerbatim("HLTDoubletDZ") << " XXX " << label_ << " 2b " << tagNew.encode() << std::endl;
121  }
122  }
123  }
124 
125  int n(0);
126  T1Ref r1;
127  T2Ref r2;
129  for (unsigned int i1=0; i1!=n1; i1++) {
130  r1=coll1_[i1];
131  const reco::Candidate& candidate1(*r1);
132  unsigned int I(0);
133  if (same_) {I=i1+1;}
134  for (unsigned int i2=I; i2!=n2; i2++) {
135  r2=coll2_[i2];
136  if (checkSC_) {
137  if (r1->superCluster().isNonnull() && r2->superCluster().isNonnull()) {
138  if (r1->superCluster() == r2->superCluster()) continue;
139  }
140  }
141  const reco::Candidate& candidate2(*r2);
142  if ( reco::deltaR(candidate1, candidate2) < minDR_ ) continue;
143  if ( std::abs(candidate1.vz()-candidate2.vz()) > maxDZ_ ) continue;
144  n++;
145  filterproduct.addObject(triggerType1_,r1);
146  filterproduct.addObject(triggerType2_,r2);
147  }
148  }
149  // filter decision
150  accept = accept || (n>=min_N_);
151  }
152 
153  return accept;
154 }
HLTDoubletDZ(const edm::ParameterSet &)
Definition: HLTDoubletDZ.cc:21
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTDoubletDZ.cc:47
static PFTauRenderPlugin instance
#define abs(x)
Definition: mlp_lapack.h:159
virtual bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct)
Definition: HLTDoubletDZ.cc:66
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
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;)
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
int iEvent
Definition: GenABIO.cc:243
edm::InputTag inputTag2_
Definition: HLTDoubletDZ.h:34
edm::InputTag inputTag1_
Definition: HLTDoubletDZ.h:33
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
const std::complex< double > I
Definition: I.h:8
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
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
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:64
tuple process
Definition: LaserDQM_cfg.py:3
Provenance getProvenance(BranchID const &theID) const
Definition: Event.cc:68
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:25
def template
Definition: svgfig.py:520