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