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, int Tid>
29  inputTag_ (iConfig.template getParameter<edm::InputTag>("inputTag")),
30  saveTag_ (iConfig.template getUntrackedParameter<bool> ("saveTag",false)),
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_()
36 {
37  LogDebug("") << "InputTags and cuts : "
38  << inputTag_.encode() << " " << observable_
39  << " Range [" << min_ << " " << max_ << "]"
40  << " MinN =" << min_N_
41  ;
42 
43  if (observable_=="sumEt") {
44  tid_=Tid;
45  } else if (observable_=="mEtSig") {
46  if (Tid==trigger::TriggerTET) {
48  } else if (Tid==trigger::TriggerTHT) {
50  } else {
51  tid_=Tid;
52  }
53  } else if (observable_=="e_longitudinal") {
54  if (Tid==trigger::TriggerTET) {
56  } else if (Tid==trigger::TriggerTHT) {
58  } else {
59  tid_=Tid;
60  }
61  } else {
62  tid_=Tid;
63  }
64 
65  //register your products
66  produces<trigger::TriggerFilterObjectWithRefs>();
67 }
68 
69 template<typename T, int Tid>
71 {
72 }
73 
74 //
75 // member functions
76 //
77 
78 // ------------ method called to produce the data ------------
79 template<typename T, int Tid>
80 bool
82 {
83  using namespace std;
84  using namespace edm;
85  using namespace reco;
86  using namespace trigger;
87 
88  typedef vector<T> TCollection;
89  typedef Ref<TCollection> TRef;
90 
91  // All HLT filters must create and fill an HLT filter object,
92  // recording any reconstructed physics objects satisfying (or not)
93  // this HLT filter, and place it in the Event.
94 
95  // The filter object
96  auto_ptr<TriggerFilterObjectWithRefs>
97  filterobject (new TriggerFilterObjectWithRefs(path(),module()));
98  if (saveTag_) filterobject->addCollectionTag(inputTag_);
99  // Ref to Candidate object to be recorded in filter object
100  TRef ref;
101 
102 
103  // get hold of MET product from Event
104  Handle<TCollection> objects;
105  iEvent.getByLabel(inputTag_,objects);
106  if (!objects.isValid()) {
107  LogDebug("") << inputTag_ << " collection not found!";
108  iEvent.put(filterobject);
109  return false;
110  }
111 
112  LogDebug("") << "Size of MET collection: " << objects->size();
113  if (objects->size()==0) {
114  LogDebug("") << "MET collection does not contain a MET object!";
115  } else if (objects->size()>1) {
116  LogDebug("") << "MET collection contains more than one MET object!";
117  }
118 
119  int n(0);
120  double value(0.0);
121  typename TCollection::const_iterator ibegin(objects->begin());
122  typename TCollection::const_iterator iend(objects->end());
123  typename TCollection::const_iterator iter;
124  for (iter=ibegin; iter!=iend; iter++) {
125 
126  // get hold of value of observable to cut on
127  if ( (tid_==TriggerTET) || (tid_==TriggerTHT) ) {
128  value=iter->sumEt();
129  } else if ( (tid_==TriggerMETSig) || (tid_==TriggerMHTSig) ) {
130  value=iter->mEtSig();
131  } else if ( (tid_==TriggerELongit) || (tid_==TriggerHLongit) ) {
132  value=iter->e_longitudinal();
133  } else {
134  value=0.0;
135  }
136 
137  value=std::abs(value);
138 
139  if ( ( (min_<0.0) || (min_<=value) ) &&
140  ( (max_<0.0) || (value<=max_) ) ) {
141  n++;
142  ref=TRef(objects,distance(ibegin,iter));
143  filterobject->addObject(tid_,ref);
144  }
145 
146  }
147 
148  // filter decision
149  const bool accept(n>=min_N_);
150 
151  // put filter object into the Event
152  iEvent.put(filterobject);
153 
154  return accept;
155 }
#define LogDebug(id)
int module() const
Definition: HLTadd.h:12
#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:21
std::string encode() const
Definition: InputTag.cc:72
int path() const
Definition: HLTadd.h:3
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
HLTGlobalSums(const edm::ParameterSet &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
std::string observable_
Definition: HLTGlobalSums.h:38
virtual bool filter(edm::Event &, const edm::EventSetup &)
edm::InputTag inputTag_
Definition: HLTGlobalSums.h:36
def template
Definition: svgfig.py:520