CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTSinglet.cc
Go to the documentation of this file.
1 
14 
16 
19 
21 
22 //
23 // constructors and destructor
24 //
25 template<typename T, int Tid>
27  inputTag_ (iConfig.template getParameter<edm::InputTag>("inputTag")),
28  saveTag_ (iConfig.template getUntrackedParameter<bool>("saveTag",false)),
29  min_Pt_ (iConfig.template getParameter<double> ("MinPt" )),
30  max_Eta_ (iConfig.template getParameter<double> ("MaxEta" )),
31  min_N_ (iConfig.template getParameter<int> ("MinN" ))
32 {
33  LogDebug("") << "Input/ptcut/etacut/ncut : "
34  << inputTag_.encode() << " "
35  << min_Pt_ << " " << max_Eta_ << " " << min_N_ ;
36 
37  //register your products
38  produces<trigger::TriggerFilterObjectWithRefs>();
39 }
40 
41 template<typename T, int Tid>
43 {
44 }
45 
46 //
47 // member functions
48 //
49 
50 // ------------ method called to produce the data ------------
51 template<typename T, int Tid>
52 bool
54 {
55  using namespace std;
56  using namespace edm;
57  using namespace reco;
58  using namespace trigger;
59 
60  typedef vector<T> TCollection;
61  typedef Ref<TCollection> TRef;
62 
63  // All HLT filters must create and fill an HLT filter object,
64  // recording any reconstructed physics objects satisfying (or not)
65  // this HLT filter, and place it in the Event.
66 
67  // The filter object
68  auto_ptr<TriggerFilterObjectWithRefs>
69  filterobject (new TriggerFilterObjectWithRefs(path(),module()));
70  if (saveTag_) filterobject->addCollectionTag(inputTag_);
71  // Ref to Candidate object to be recorded in filter object
72  TRef ref;
73 
74 
75  // get hold of collection of objects
76  Handle<TCollection> objects;
77  iEvent.getByLabel (inputTag_,objects);
78 
79  // look at all objects, check cuts and add to filter object
80  int n(0);
81  typename TCollection::const_iterator i ( objects->begin() );
82  for (; i!=objects->end(); i++) {
83  if ( (i->pt() >= min_Pt_) &&
84  ( (max_Eta_ < 0.0) || (std::abs(i->eta()) <= max_Eta_) ) ) {
85  n++;
86  ref=TRef(objects,distance(objects->begin(),i));
87  filterobject->addObject(Tid,ref);
88  }
89  }
90 
91  // filter decision
92  bool accept(n>=min_N_);
93 
94  // put filter object into the Event
95  iEvent.put(filterobject);
96 
97  return accept;
98 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
int module() const
Definition: HLTadd.h:12
HLTSinglet(const edm::ParameterSet &)
Definition: HLTSinglet.cc:26
double min_Pt_
Definition: HLTSinglet.h:37
virtual bool filter(edm::Event &, const edm::EventSetup &)
Definition: HLTSinglet.cc:53
#define abs(x)
Definition: mlp_lapack.h:159
edm::InputTag inputTag_
Definition: HLTSinglet.h:35
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
double max_Eta_
Definition: HLTSinglet.h:38
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
int min_N_
Definition: HLTSinglet.h:39
def template
Definition: svgfig.py:520