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 #include <typeinfo>
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  cut_ (iConfig.template getParameter<std::string> ("cut" )),
32  min_N_ (iConfig.template getParameter<int> ("MinN" )),
33  select_ (cut_ )
34 {
35  LogDebug("") << "Input/tyre/cut/ncut : "
36  << inputTag_.encode() << " "
37  << triggerType_ << " "
38  << cut_<< " "
39  << min_N_ ;
40 }
41 
42 template<typename T>
44 {
45 }
46 
47 template<typename T>
48 void
51  makeHLTFilterDescription(desc);
52  desc.add<edm::InputTag>("inputTag",edm::InputTag("hltCollection"));
53  desc.add<int>("triggerType",0);
54  desc.add<std::string>("cut","1>0");
55  desc.add<int>("MinN",1);
56  descriptions.add(std::string("hlt")+std::string(typeid(HLTSmartSinglet<T>).name()),desc);
57 }
58 
59 //
60 // member functions
61 //
62 
63 // ------------ method called to produce the data ------------
64 template<typename T>
65 bool
67 {
68  using namespace std;
69  using namespace edm;
70  using namespace reco;
71  using namespace trigger;
72 
73  typedef vector<T> TCollection;
74  typedef Ref<TCollection> TRef;
75 
76  // All HLT filters must create and fill an HLT filter object,
77  // recording any reconstructed physics objects satisfying (or not)
78  // this HLT filter, and place it in the Event.
79 
80  // The filter object
81  if (saveTags()) filterproduct.addCollectionTag(inputTag_);
82 
83  // Ref to Candidate object to be recorded in filter object
84  TRef ref;
85 
86  // get hold of collection of objects
87  Handle<TCollection> objects;
88  iEvent.getByLabel (inputTag_,objects);
89 
90  // look at all objects, check cuts and add to filter object
91  int n(0);
92  typename TCollection::const_iterator i ( objects->begin() );
93  for (; i!=objects->end(); i++) {
94  if (select_(*i)) {
95  n++;
96  ref=TRef(objects,distance(objects->begin(),i));
97  filterproduct.addObject(triggerType_,ref);
98  }
99  }
100 
101  // filter decision
102  bool accept(n>=min_N_);
103 
104  return accept;
105 }
#define LogDebug(id)
HLTSmartSinglet(const edm::ParameterSet &)
int i
Definition: DBlmapReader.cc:9
edm::InputTag inputTag_
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
std::string cut_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
virtual bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct)
void addCollectionTag(const edm::InputTag &collectionTag)
collectionTags
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
def template
Definition: svgfig.py:520