CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTGlobalSums.cc
Go to the documentation of this file.
1 
12 
14 
17 
19 
20 #include<cmath>
21 
22 //
23 // constructors and destructor
24 //
25 template<typename T>
27  inputTag_ (iConfig.template getParameter<edm::InputTag>("inputTag")),
28  inputToken_ (consumes<std::vector<T> >(inputTag_)),
29  triggerType_(iConfig.template getParameter<int>("triggerType")),
30  observable_ (iConfig.template getParameter<std::string>("observable")),
31  min_ (iConfig.template getParameter<double>("Min")),
32  max_ (iConfig.template getParameter<double>("Max")),
33  min_N_ (iConfig.template getParameter<int>("MinN")),
34  tid_(triggerType_)
35 {
36  LogDebug("") << "InputTags and cuts : "
37  << inputTag_.encode() << " "
38  << triggerType_ << " "
39  << observable_
40  << " Range [" << min_ << " " << max_ << "]"
41  << " MinN =" << min_N_ ;
42 
43  if (observable_=="sumEt") {
45  } else if (observable_=="mEtSig") {
48  } else if (triggerType_==trigger::TriggerTHT) {
50  } else {
52  }
53  } else if (observable_=="e_longitudinal") {
56  } else if (triggerType_==trigger::TriggerTHT) {
58  } else {
60  }
61  } else {
63  }
64 }
65 
66 template<typename T>
68 {
69 }
70 
71 template<typename T>
72 void
75  makeHLTFilterDescription(desc);
76  desc.add<edm::InputTag>("inputTag",edm::InputTag("hltCollection"));
77  desc.add<int>("triggerType",0);
78  desc.add<std::string>("observable","");
79  desc.add<double>("Min",-1e125);
80  desc.add<double>("Max",+1e125);
81  desc.add<int>("MinN",1);
82  descriptions.add(std::string("hlt")+std::string(typeid(HLTGlobalSums<T>).name()),desc);
83 }
84 
85 //
86 // member functions
87 //
88 
89 // ------------ method called to produce the data ------------
90 template<typename T>
91 bool
93 {
94  using namespace std;
95  using namespace edm;
96  using namespace reco;
97  using namespace trigger;
98 
99  typedef vector<T> TCollection;
100  typedef Ref<TCollection> TRef;
101 
102  // All HLT filters must create and fill an HLT filter object,
103  // recording any reconstructed physics objects satisfying (or not)
104  // this HLT filter, and place it in the Event.
105 
106  // The filter object
107  if (saveTags()) filterproduct.addCollectionTag(inputTag_);
108  // Ref to Candidate object to be recorded in filter object
109  TRef ref;
110 
111 
112  // get hold of MET product from Event
113  Handle<TCollection> objects;
114  iEvent.getByToken(inputToken_,objects);
115  if (!objects.isValid()) {
116  LogDebug("") << inputTag_ << " collection not found!";
117  return false;
118  }
119 
120  LogDebug("") << "Size of MET collection: " << objects->size();
121  if (objects->size()==0) {
122  LogDebug("") << "MET collection does not contain a MET object!";
123  } else if (objects->size()>1) {
124  LogDebug("") << "MET collection contains more than one MET object!";
125  }
126 
127  int n(0);
128  double value(0.0);
129  typename TCollection::const_iterator ibegin(objects->begin());
130  typename TCollection::const_iterator iend(objects->end());
131  typename TCollection::const_iterator iter;
132  for (iter=ibegin; iter!=iend; iter++) {
133 
134  // get hold of value of observable to cut on
135  if ( (tid_==TriggerTET) || (tid_==TriggerTHT) ) {
136  value=iter->sumEt();
137  } else if ( (tid_==TriggerMETSig) || (tid_==TriggerMHTSig) ) {
138  value=iter->mEtSig();
139  } else if ( (tid_==TriggerELongit) || (tid_==TriggerHLongit) ) {
140  value=iter->e_longitudinal();
141  } else {
142  value=0.0;
143  }
144 
145  value=std::abs(value);
146 
147  if ( ( (min_<0.0) || (min_<=value) ) &&
148  ( (max_<0.0) || (value<=max_) ) ) {
149  n++;
150  ref=TRef(objects,distance(ibegin,iter));
151  filterproduct.addObject(tid_,ref);
152  }
153 
154  }
155 
156  // filter decision
157  const bool accept(n>=min_N_);
158 
159  return accept;
160 }
#define LogDebug(id)
virtual bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:26
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;)
int iEvent
Definition: GenABIO.cc:230
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void addCollectionTag(const edm::InputTag &collectionTag)
collectionTags
void add(std::string const &label, ParameterSetDescription const &psetDescription)
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
def template
Definition: svgfig.py:520