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