CMS 3D CMS Logo

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