CMS 3D CMS Logo

HLTSinglet.cc
Go to the documentation of this file.
1 
12 
19 
21 
23 
24 // extract the candidate type
25 template<typename T>
26 int getObjectType(const T &) {
27  return 0;
28 }
29 
30 // specialize for type l1extra::L1EmParticle
31 template<typename T>
32 int getObjectType(const l1extra::L1EmParticle & candidate) {
33  switch (candidate.type()) {
38  default:
39  return 0;
40  }
41 }
42 
43 // specialize for type l1extra::L1EtMissParticle
44 template<typename T>
45 int getObjectType(const l1extra::L1EtMissParticle & candidate) {
46  switch (candidate.type()) {
48  return trigger::TriggerL1ETM;
50  return trigger::TriggerL1HTM;
51  default:
52  return 0;
53  }
54 }
55 
56 // specialize for type l1extra::L1JetParticle
57 template<typename T>
58 int getObjectType(const l1extra::L1JetParticle & candidate) {
59  switch (candidate.type()) {
66  default:
67  return 0;
68  }
69 }
70 
71 
72 //
73 // constructors and destructor
74 //
75 template<typename T>
77  inputTag_ (iConfig.template getParameter<edm::InputTag>("inputTag")),
78  inputToken_ (consumes<std::vector<T> >(inputTag_)),
79  triggerType_ (iConfig.template getParameter<int>("triggerType")),
80  min_N_ (iConfig.template getParameter<int> ("MinN" )),
81  min_E_ (iConfig.template getParameter<double> ("MinE" )),
82  min_Pt_ (iConfig.template getParameter<double> ("MinPt" )),
83  min_Mass_ (iConfig.template getParameter<double> ("MinMass" )),
84  max_Mass_ (iConfig.template getParameter<double> ("MaxMass" )),
85  min_Eta_ (iConfig.template getParameter<double> ("MinEta" )),
86  max_Eta_ (iConfig.template getParameter<double> ("MaxEta" ))
87 {
88  LogDebug("") << "Input/ptcut/etacut/ncut : "
89  << inputTag_.encode() << " "
90  << min_E_ << " " << min_Pt_ << " " << min_Mass_ << " " << max_Mass_ << " "
91  << min_Eta_ << " " << max_Eta_ << " " << min_N_ ;
92 }
93 
94 template<typename T>
95 HLTSinglet<T>::~HLTSinglet() = default;
96 
97 template<typename T>
98 void
102  desc.add<edm::InputTag>("inputTag",edm::InputTag("hltCollection"));
103  desc.add<int>("triggerType",0);
104  desc.add<double>("MinE",-1.0);
105  desc.add<double>("MinPt",-1.0);
106  desc.add<double>("MinMass",-1.0);
107  desc.add<double>("MaxMass",-1.0);
108  desc.add<double>("MinEta",-1.0);
109  desc.add<double>("MaxEta",-1.0);
110  desc.add<int>("MinN",1);
111  descriptions.add(defaultModuleLabel<HLTSinglet<T>>(), desc);
112 }
113 
114 //
115 // member functions
116 //
117 
118 // ------------ method called to produce the data ------------
119 template<typename T>
120 bool
122 {
123  using namespace std;
124  using namespace edm;
125  using namespace reco;
126  using namespace trigger;
127 
128  typedef vector<T> TCollection;
129  typedef Ref<TCollection> TRef;
130 
131  // All HLT filters must create and fill an HLT filter object,
132  // recording any reconstructed physics objects satisfying (or not)
133  // this HLT filter, and place it in the Event.
134 
135  // The filter object
136  if (saveTags()) filterproduct.addCollectionTag(inputTag_);
137 
138  // Ref to Candidate object to be recorded in filter object
139  TRef ref;
140 
141 
142  // get hold of collection of objects
144  iEvent.getByToken(inputToken_,objects);
145 
146  // look at all objects, check cuts and add to filter object
147  int n(0);
148  typename TCollection::const_iterator i ( objects->begin() );
149  for (; i!=objects->end(); i++) {
150  if ( (i->energy() >= min_E_) &&
151  (i->pt() >= min_Pt_) &&
152  (i->mass() >= min_Mass_) &&
153  ( (max_Mass_ < 0.0) || (i->mass() <= max_Mass_ ) ) &&
154  ( (min_Eta_ < 0.0) || (std::abs(i->eta()) >= min_Eta_) ) &&
155  ( (max_Eta_ < 0.0) || (std::abs(i->eta()) <= max_Eta_) ) ) {
156  n++;
157  ref=TRef(objects,distance(objects->begin(),i));
158  int tid = getObjectType<T>(*i);
159  if (tid == 0)
160  tid = triggerType_;
161  filterproduct.addObject(tid, ref);
162  }
163  }
164 
165  // filter decision
166  bool accept(n>=min_N_);
167 
168  return accept;
169 }
#define LogDebug(id)
std::string defaultModuleLabel()
int getObjectType(const T &)
Definition: HLTSinglet.cc:26
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
const double max_Mass_
Definition: HLTSinglet.h:42
EmType type() const
Definition: L1EmParticle.h:62
const double min_E_
Definition: HLTSinglet.h:39
EtMissType type() const
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
std::string encode() const
Definition: InputTag.cc:166
JetType type() const
Definition: L1JetParticle.h:63
void addObject(int id, const reco::RecoEcalCandidateRef &ref)
setters for L3 collections: (id=physics type, and Ref<C>)
bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
Definition: HLTSinglet.cc:121
int iEvent
Definition: GenABIO.cc:230
const double max_Eta_
Definition: HLTSinglet.h:44
const double min_Eta_
Definition: HLTSinglet.h:43
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:520
const double min_Mass_
Definition: HLTSinglet.h:41
const double min_Pt_
Definition: HLTSinglet.h:40
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void makeHLTFilterDescription(edm::ParameterSetDescription &desc)
Definition: HLTFilter.cc:29
const int min_N_
Definition: HLTSinglet.h:38
const int triggerType_
Definition: HLTSinglet.h:37
void addCollectionTag(const edm::InputTag &collectionTag)
collectionTags
void add(std::string const &label, ParameterSetDescription const &psetDescription)
fixed size matrix
bool saveTags() const
Definition: HLTFilter.h:45
HLT enums.
~HLTSinglet() override
const edm::EDGetTokenT< std::vector< T > > inputToken_
Definition: HLTSinglet.h:36
const edm::InputTag inputTag_
Definition: HLTSinglet.h:35
long double T
HLTSinglet(const edm::ParameterSet &)
Definition: HLTSinglet.cc:76
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTSinglet.cc:99