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