CMS 3D CMS Logo

HLTGlobalSums.cc
Go to the documentation of this file.
1 
10 #include <cmath>
11 
13 #include "HLTGlobalSums.h"
14 
16 
19 
21 
23 
24 //
25 // constructors and destructor
26 //
27 template <typename T>
29  : HLTFilter(iConfig),
30  inputTag_(iConfig.template getParameter<edm::InputTag>("inputTag")),
31  inputToken_(consumes<std::vector<T>>(inputTag_)),
32  triggerType_(iConfig.template getParameter<int>("triggerType")),
33  observable_(iConfig.template getParameter<std::string>("observable")),
34  min_(iConfig.template getParameter<double>("Min")),
35  max_(iConfig.template getParameter<double>("Max")),
36  min_N_(iConfig.template getParameter<int>("MinN")),
37  tid_(triggerType_) {
38  LogDebug("") << "InputTags and cuts : " << inputTag_.encode() << " " << triggerType_ << " " << observable_
39  << " Range [" << min_ << " " << max_ << "]"
40  << " MinN =" << min_N_;
41 
42  if (observable_ == "sumEt") {
44  } else if (observable_ == "mEtSig") {
47  } else if (triggerType_ == trigger::TriggerTHT) {
49  } else {
51  }
52  } else if (observable_ == "e_longitudinal") {
55  } else if (triggerType_ == trigger::TriggerTHT) {
57  } else {
59  }
60  } else {
62  }
63 }
64 
65 template <typename T>
67 
68 template <typename T>
71  makeHLTFilterDescription(desc);
72  desc.add<edm::InputTag>("inputTag", edm::InputTag("hltCollection"));
73  desc.add<int>("triggerType", 0);
74  desc.add<std::string>("observable", "");
75  desc.add<double>("Min", -1e125);
76  desc.add<double>("Max", +1e125);
77  desc.add<int>("MinN", 1);
78  descriptions.add(defaultModuleLabel<HLTGlobalSums<T>>(), desc);
79 }
80 
81 //
82 // member functions
83 //
84 
85 // ------------ method called to produce the data ------------
86 template <typename T>
88  const edm::EventSetup& iSetup,
89  trigger::TriggerFilterObjectWithRefs& filterproduct) const {
90  using namespace std;
91  using namespace edm;
92  using namespace reco;
93  using namespace trigger;
94 
95  typedef vector<T> TCollection;
96  typedef Ref<TCollection> TRef;
97 
98  // All HLT filters must create and fill an HLT filter object,
99  // recording any reconstructed physics objects satisfying (or not)
100  // this HLT filter, and place it in the Event.
101 
102  // The filter object
103  if (saveTags())
104  filterproduct.addCollectionTag(inputTag_);
105  // Ref to Candidate object to be recorded in filter object
106  TRef ref;
107 
108  // get hold of MET product from Event
110  iEvent.getByToken(inputToken_, objects);
111  if (!objects.isValid()) {
112  LogDebug("") << inputTag_ << " collection not found!";
113  return false;
114  }
115 
116  LogDebug("") << "Size of MET collection: " << objects->size();
117  if (objects->empty()) {
118  LogDebug("") << "MET collection does not contain a MET object!";
119  } else if (objects->size() > 1) {
120  LogDebug("") << "MET collection contains more than one MET object!";
121  }
122 
123  int n(0);
124  double value(0.0);
125  typename TCollection::const_iterator ibegin(objects->begin());
126  typename TCollection::const_iterator iend(objects->end());
127  typename TCollection::const_iterator iter;
128  for (iter = ibegin; iter != iend; iter++) {
129  // get hold of value of observable to cut on
130  if ((tid_ == TriggerTET) || (tid_ == TriggerTHT)) {
131  value = iter->sumEt();
132  } else if ((tid_ == TriggerMETSig) || (tid_ == TriggerMHTSig)) {
133  value = iter->mEtSig();
134  } else if ((tid_ == TriggerELongit) || (tid_ == TriggerHLongit)) {
135  value = iter->e_longitudinal();
136  } else {
137  value = 0.0;
138  }
139 
140  value = std::abs(value);
141 
142  if (((min_ < 0.0) || (min_ <= value)) && ((max_ < 0.0) || (value <= max_))) {
143  n++;
144  ref = TRef(objects, distance(ibegin, iter));
145  filterproduct.addObject(tid_, ref);
146  }
147  }
148 
149  // filter decision
150  const bool accept(n >= min_N_);
151 
152  return accept;
153 }
bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
std::string encode() const
Definition: InputTag.cc:159
std::string defaultModuleLabel()
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
void addObject(int id, const reco::RecoEcalCandidateRef &ref)
setters for L3 collections: (id=physics type, and Ref<C>)
int iEvent
Definition: GenABIO.cc:224
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
Definition: value.py:1
~HLTGlobalSums() override
void addCollectionTag(const edm::InputTag &collectionTag)
collectionTags
void add(std::string const &label, ParameterSetDescription const &psetDescription)
fixed size matrix
HLT enums.
edm::InputTag inputTag_
Definition: HLTGlobalSums.h:37
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
long double T
HLTGlobalSums(const edm::ParameterSet &)
std::string observable_
Definition: HLTGlobalSums.h:40
#define LogDebug(id)