CMS 3D CMS Logo

HLTHcalSimpleRecHitFilter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HLTHcalSimpleRecHitFilter
4 // Class: HLTHcalSimpleRecHitFilter
5 //
13 //
14 // Original Author: Bryan DAHMES
15 // Created: Wed Sep 19 16:21:29 CEST 2007
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
29 
33 
36 
37 //
38 // class declaration
39 //
40 
42 public:
44  ~HLTHcalSimpleRecHitFilter() override;
45  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
46 
47 private:
48  bool hltFilter(edm::Event&, const edm::EventSetup&, trigger::TriggerFilterObjectWithRefs & filterproduct) const override;
49 
50  // ----------member data ---------------------------
53  double threshold_;
57  std::vector<unsigned int> maskedList_;
58 
59 };
60 
61 //
62 // constructors and destructor
63 //
65 {
66  //now do what ever initialization is needed
67  threshold_ = iConfig.getParameter<double>("threshold");
68  minNHitsNeg_ = iConfig.getParameter<int>("minNHitsNeg");
69  minNHitsPos_ = iConfig.getParameter<int>("minNHitsPos");
70  doCoincidence_ = iConfig.getParameter<bool>("doCoincidence");
71  if (iConfig.existsAs<std::vector<unsigned int> >("maskedChannels"))
72  maskedList_ = iConfig.getParameter<std::vector<unsigned int> >("maskedChannels"); //this is using the raw DetId index
73  else
74  //worry about possible user menus with the old interface
75  if (iConfig.existsAs<std::vector<int> >("maskedChannels")) {
76  std::vector<int> tVec=iConfig.getParameter<std::vector<int> >("maskedChannels");
77  if ( !tVec.empty() ) {
78  edm::LogError("cfg error") << "masked list of channels missing from HLT menu. Migration from vector of ints to vector of uints needed for this release";
79  cms::Exception("Invalid/obsolete masked list of channels");
80  }
81  }
82  HcalRecHitCollection_ = iConfig.getParameter<edm::InputTag>("HFRecHitCollection");
83  HcalRecHitsToken_ = consumes<HFRecHitCollection>(HcalRecHitCollection_);
84 }
85 
86 
88 {
89 
90  // do anything here that needs to be done at desctruction time
91  // (e.g. close files, deallocate resources etc.)
92 
93 }
94 
95 
96 void
100  desc.add<edm::InputTag>("HFRecHitCollection",edm::InputTag("hltHfreco"));
101  desc.add<double>("threshold",3.0);
102  desc.add<int>("minNHitsNeg",1);
103  desc.add<int>("minNHitsPos",1);
104  desc.add<bool>("doCoincidence",true);
105  std::vector<unsigned int> temp;
106  desc.add<std::vector<unsigned int> >("maskedChannels",temp)->
107  setComment(" # now by raw detid, not hashed id");
108  descriptions.add("hltHcalSimpleRecHitFilter",desc);
109 }
110 
111 //
112 // member functions
113 //
114 
115 // ------------ method called on each new Event ------------
116 bool
118  // using namespace edm;
119 
120  // getting very basic uncalRH
122  try {
123  iEvent.getByToken(HcalRecHitsToken_, crudeHits);
124  } catch ( std::exception& ex) {
125  edm::LogWarning("HLTHcalSimpleRecHitFilter") << HcalRecHitCollection_ << " not available";
126  }
127 
128  bool accept = false ;
129 
130  int nHitsNeg=0, nHitsPos=0;
131  for (auto hit : *crudeHits) {
132  // masking noisy channels
133  if (std::find( maskedList_.begin(), maskedList_.end(), hit.id().rawId() ) != maskedList_.end())
134  continue;
135 
136  // only count tower above threshold
137  if ( hit.energy() < threshold_ ) continue;
138 
139  // count
140  if (hit.id().zside()<0) ++nHitsNeg;
141  else ++nHitsPos;
142  }
143 
144  // Logic
145  if (!doCoincidence_) accept = (nHitsNeg>=minNHitsNeg_) || (nHitsPos>=minNHitsPos_);
146  else accept = (nHitsNeg>=minNHitsNeg_) && (nHitsPos>=minNHitsPos_);
147 // edm::LogInfo("HcalFilter") << "at evet: " << iEvent.id().event()
148 // << " and run: " << iEvent.id().run()
149 // << " Total HF hits: " << crudeHits->size() << " Above Threshold - nNeg: " << nHitsNeg << " nPos " << nHitsPos
150 // << " doCoinc: " << doCoincidence_ << " accept: " << accept << std::endl;
151 
152  // result
153  return accept;
154 }
155 
156 // declare this class as a framework plugin
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:161
bool hltFilter(edm::Event &, const edm::EventSetup &, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< unsigned int > maskedList_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
HLTHcalSimpleRecHitFilter(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ParameterDescriptionBase * add(U const &iLabel, T const &value)
unsigned int id
static void makeHLTFilterDescription(edm::ParameterSetDescription &desc)
Definition: HLTFilter.cc:29
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< HFRecHitCollection > HcalRecHitsToken_