CMS 3D CMS Logo

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