CMS 3D CMS Logo

HLTDoublet.cc
Go to the documentation of this file.
1 
11 #include "HLTDoublet.h"
12 
14 
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  triggerType1_(iConfig.template getParameter<int>("triggerType1")),
38  triggerType2_(iConfig.template getParameter<int>("triggerType2")),
39  min_Dphi_(iConfig.template getParameter<double>("MinDphi")),
40  max_Dphi_(iConfig.template getParameter<double>("MaxDphi")),
41  min_Deta_(iConfig.template getParameter<double>("MinDeta")),
42  max_Deta_(iConfig.template getParameter<double>("MaxDeta")),
43  min_Minv_(iConfig.template getParameter<double>("MinMinv")),
44  max_Minv_(iConfig.template getParameter<double>("MaxMinv")),
45  min_DelR_(iConfig.template getParameter<double>("MinDelR")),
46  max_DelR_(iConfig.template getParameter<double>("MaxDelR")),
47  min_Pt_(iConfig.template getParameter<double>("MinPt")),
48  max_Pt_(iConfig.template getParameter<double>("MaxPt")),
49  min_N_(iConfig.template getParameter<int>("MinN")),
50  same_(inputTag1_.encode() == inputTag2_.encode()), // same collections to be compared?
51  cutdphi_(min_Dphi_ <= max_Dphi_), // cut active?
52  cutdeta_(min_Deta_ <= max_Deta_), // cut active?
53  cutminv_(min_Minv_ <= max_Minv_), // cut active?
54  cutdelr_(min_DelR_ <= max_DelR_), // cut active?
55  cutpt_(min_Pt_ <= max_Pt_) // cut active?
56 {
57  LogDebug("") << "InputTags and cuts : " << inputTag1_.encode() << " " << inputTag2_.encode() << triggerType1_ << " "
58  << triggerType2_ << " Dphi [" << min_Dphi_ << " " << max_Dphi_ << "]"
59  << " Deta [" << min_Deta_ << " " << max_Deta_ << "]"
60  << " Minv [" << min_Minv_ << " " << max_Minv_ << "]"
61  << " DelR [" << min_DelR_ << " " << max_DelR_ << "]"
62  << " Pt [" << min_Pt_ << " " << max_Pt_ << "]"
63  << " MinN =" << min_N_ << " same/dphi/deta/minv/delr/pt " << same_ << cutdphi_ << cutdeta_ << cutminv_
64  << cutdelr_ << cutpt_;
65 }
66 
67 template <typename T1, typename T2>
69 template <typename T1, typename T2>
72  makeHLTFilterDescription(desc);
73  std::vector<edm::InputTag> originTag1(1, edm::InputTag("hltOriginal1"));
74  std::vector<edm::InputTag> originTag2(1, edm::InputTag("hltOriginal2"));
75  desc.add<std::vector<edm::InputTag>>("originTag1", originTag1);
76  desc.add<std::vector<edm::InputTag>>("originTag2", originTag2);
77  desc.add<edm::InputTag>("inputTag1", edm::InputTag("hltFiltered1"));
78  desc.add<edm::InputTag>("inputTag2", edm::InputTag("hltFiltered22"));
79  desc.add<int>("triggerType1", 0);
80  desc.add<int>("triggerType2", 0);
81  desc.add<double>("MinDphi", +1.0);
82  desc.add<double>("MaxDphi", -1.0);
83  desc.add<double>("MinDeta", +1.0);
84  desc.add<double>("MaxDeta", -1.0);
85  desc.add<double>("MinMinv", +1.0);
86  desc.add<double>("MaxMinv", -1.0);
87  desc.add<double>("MinDelR", +1.0);
88  desc.add<double>("MaxDelR", -1.0);
89  desc.add<double>("MinPt", +1.0);
90  desc.add<double>("MaxPt", -1.0);
91  desc.add<int>("MinN", 1);
93 }
94 
95 //
96 // member functions
97 //
98 
99 // ------------ method called to produce the data ------------
100 template <typename T1, typename T2>
102  const edm::EventSetup& iSetup,
103  trigger::TriggerFilterObjectWithRefs& filterproduct) const {
104  using namespace std;
105  using namespace edm;
106  using namespace reco;
107  using namespace trigger;
108 
109  // All HLT filters must create and fill an HLT filter object,
110  // recording any reconstructed physics objects satisfying (or not)
111  // this HLT filter, and place it in the Event.
112 
113  bool accept(false);
114 
115  LogVerbatim("HLTDoublet") << " XXX " << moduleLabel() << " 0 " << std::endl;
116 
117  std::vector<T1Ref> coll1;
118  std::vector<T2Ref> coll2;
119 
120  // get hold of pre-filtered object collections
121  Handle<TriggerFilterObjectWithRefs> handle1, handle2;
122  if (iEvent.getByToken(inputToken1_, handle1) && iEvent.getByToken(inputToken2_, handle2)) {
123  handle1->getObjects(triggerType1_, coll1);
124  handle2->getObjects(triggerType2_, coll2);
125  const size_type n1(coll1.size());
126  const size_type n2(coll2.size());
127 
128  if (saveTags()) {
129  InputTag tagOld;
130  for (unsigned int i = 0; i < originTag1_.size(); ++i) {
131  filterproduct.addCollectionTag(originTag1_[i]);
132  LogVerbatim("HLTDoublet") << " XXX " << moduleLabel() << " 1a/" << i << " " << originTag1_[i].encode()
133  << std::endl;
134  }
135  tagOld = InputTag();
136  for (size_type i1 = 0; i1 != n1; ++i1) {
137  const ProductID pid(coll1[i1].id());
138  const auto& prov = iEvent.getStableProvenance(pid);
139  const string& label(prov.moduleLabel());
140  const string& instance(prov.productInstanceName());
141  const string& process(prov.processName());
143  if (tagOld.encode() != tagNew.encode()) {
144  filterproduct.addCollectionTag(tagNew);
145  tagOld = tagNew;
146  LogVerbatim("HLTDoublet") << " XXX " << moduleLabel() << " 1b " << tagNew.encode() << std::endl;
147  }
148  }
149  for (unsigned int i = 0; i < originTag2_.size(); ++i) {
150  filterproduct.addCollectionTag(originTag2_[i]);
151  LogVerbatim("HLTDoublet") << " XXX " << moduleLabel() << " 2a/" << i << " " << originTag2_[i].encode()
152  << std::endl;
153  }
154  tagOld = InputTag();
155  for (size_type i2 = 0; i2 != n2; ++i2) {
156  const ProductID pid(coll2[i2].id());
157  const auto& prov = iEvent.getStableProvenance(pid);
158  const string& label(prov.moduleLabel());
159  const string& instance(prov.productInstanceName());
160  const string& process(prov.processName());
162  if (tagOld.encode() != tagNew.encode()) {
163  filterproduct.addCollectionTag(tagNew);
164  tagOld = tagNew;
165  LogVerbatim("HLTDoublet") << " XXX " << moduleLabel() << " 2b " << tagNew.encode() << std::endl;
166  }
167  }
168  }
169 
170  int n(0);
171  T1Ref r1;
172  T2Ref r2;
174  for (unsigned int i1 = 0; i1 != n1; i1++) {
175  r1 = coll1[i1];
176  p1 = r1->p4();
177  unsigned int I(0);
178  if (same_) {
179  I = i1 + 1;
180  }
181  for (unsigned int i2 = I; i2 != n2; i2++) {
182  r2 = coll2[i2];
183  p2 = r2->p4();
184 
185  double Dphi(std::abs(p1.phi() - p2.phi()));
186  if (Dphi > M_PI)
187  Dphi = 2.0 * M_PI - Dphi;
188 
189  double Deta(std::abs(p1.eta() - p2.eta()));
190 
191  p = p1 + p2;
192  double Minv(std::abs(p.mass()));
193  double Pt(p.pt());
194 
195  double DelR(sqrt(Dphi * Dphi + Deta * Deta));
196 
197  if (((!cutdphi_) || ((min_Dphi_ <= Dphi) && (Dphi <= max_Dphi_))) &&
198  ((!cutdeta_) || ((min_Deta_ <= Deta) && (Deta <= max_Deta_))) &&
199  ((!cutminv_) || ((min_Minv_ <= Minv) && (Minv <= max_Minv_))) &&
200  ((!cutdelr_) || ((min_DelR_ <= DelR) && (DelR <= max_DelR_))) &&
201  ((!cutpt_) || ((min_Pt_ <= Pt) && (Pt <= max_Pt_)))) {
202  n++;
203  filterproduct.addObject(triggerType1_, r1);
204  filterproduct.addObject(triggerType2_, r2);
205  }
206  }
207  }
208  // filter decision
209  accept = (n >= min_N_);
210  }
211 
212  return accept;
213 }
defaultModuleLabel.h
trigger::TriggerRefsCollections::addObject
void addObject(int id, const reco::RecoEcalCandidateRef &ref)
setters for L3 collections: (id=physics type, and Ref<C>)
Definition: TriggerRefsCollections.h:299
HLTDoublet::min_Minv_
const double min_Minv_
Definition: HLTDoublet.h:55
trigger::TriggerFilterObjectWithRefs
Definition: TriggerFilterObjectWithRefs.h:35
testProducerWithPsetDescEmpty_cfi.i2
i2
Definition: testProducerWithPsetDescEmpty_cfi.py:46
Handle.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
HLTDoublet::min_N_
const int min_N_
Definition: HLTDoublet.h:58
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
HLTDoublet::HLTDoublet
HLTDoublet(const edm::ParameterSet &)
Definition: HLTDoublet.cc:29
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition: testProducerWithPsetDescEmpty_cfi.py:45
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
trigger::TriggerFilterObjectWithRefs::addCollectionTag
void addCollectionTag(const edm::InputTag &collectionTag)
collectionTags
Definition: TriggerFilterObjectWithRefs.h:55
HLTDoublet::inputTag1_
const edm::InputTag inputTag1_
Definition: HLTDoublet.h:47
HLTDoublet::min_DelR_
const double min_DelR_
Definition: HLTDoublet.h:56
TriggerFilterObjectWithRefs.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
trigger::TriggerRefsCollections::getObjects
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
Definition: TriggerRefsCollections.h:590
HLTFilter
Definition: HLTFilter.h:28
edm::Ref
Definition: AssociativeIterator.h:58
HLTDoublet
Definition: HLTDoublet.h:34
accept
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
Exhume::I
const std::complex< double > I
Definition: I.h:8
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
p2
double p2[4]
Definition: TauolaWrapper.h:90
Particle.h
HLTDoublet.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
HLTDoublet::max_Pt_
const double max_Pt_
Definition: HLTDoublet.h:57
BeamBkgSkim_cff.saveTags
saveTags
Definition: BeamBkgSkim_cff.py:9
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
defaultModuleLabel
std::string defaultModuleLabel()
Definition: defaultModuleLabel.h:16
LaserDQM_cfg.process
process
Definition: LaserDQM_cfg.py:3
diffTwoXMLs.r2
r2
Definition: diffTwoXMLs.py:73
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
p1
double p1[4]
Definition: TauolaWrapper.h:89
edm::InputTag::encode
std::string encode() const
Definition: InputTag.cc:159
HLTDoublet::cutdelr_
const bool cutdelr_
Definition: HLTDoublet.h:62
edm::EventSetup
Definition: EventSetup.h:58
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
instance
static PFTauRenderPlugin instance
Definition: PFTauRenderPlugin.cc:70
reco::JetExtendedAssociation::LorentzVector
math::PtEtaPhiELorentzVectorF LorentzVector
Definition: JetExtendedAssociation.h:25
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
Ref.h
HLTDoublet::~HLTDoublet
~HLTDoublet() override
HLTDoublet::triggerType1_
const int triggerType1_
Definition: HLTDoublet.h:51
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
alcaDQMUpload.encode
def encode(args, files)
Definition: alcaDQMUpload.py:32
HLTDoublet::cutdeta_
const bool cutdeta_
Definition: HLTDoublet.h:62
HLT_FULL_cff.originTag2
originTag2
Definition: HLT_FULL_cff.py:19401
HLTDoublet::min_Dphi_
const double min_Dphi_
Definition: HLTDoublet.h:53
HLTDoublet::same_
const bool same_
Definition: HLTDoublet.h:61
HLTDoublet::max_Minv_
const double max_Minv_
Definition: HLTDoublet.h:55
HLTDoublet::cutpt_
const bool cutpt_
Definition: HLTDoublet.h:62
HLTDoublet::hltFilter
bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
Definition: HLTDoublet.cc:101
trigger
Definition: HLTPrescaleTableCond.h:8
HLTDoublet::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTDoublet.cc:70
HLT_FULL_cff.originTag1
originTag1
Definition: HLT_FULL_cff.py:19404
HLTDoublet::cutminv_
const bool cutminv_
Definition: HLTDoublet.h:62
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterSet.h
HLTDoublet::min_Pt_
const double min_Pt_
Definition: HLTDoublet.h:57
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
edm::Event
Definition: Event.h:73
HLTDoublet::max_DelR_
const double max_DelR_
Definition: HLTDoublet.h:56
HLTDoublet::max_Deta_
const double max_Deta_
Definition: HLTDoublet.h:54
HLTDoublet::min_Deta_
const double min_Deta_
Definition: HLTDoublet.h:54
edm::InputTag
Definition: InputTag.h:15
label
const char * label
Definition: PFTauDecayModeTools.cc:11
edm::ProductID
Definition: ProductID.h:27
HLTDoublet::inputTag2_
const edm::InputTag inputTag2_
Definition: HLTDoublet.h:48
HLTDoublet::triggerType2_
const int triggerType2_
Definition: HLTDoublet.h:52
HLTDoublet::max_Dphi_
const double max_Dphi_
Definition: HLTDoublet.h:53
HLTDoublet::cutdphi_
const bool cutdphi_
Definition: HLTDoublet.h:62