CMS 3D CMS Logo

ECALActivity.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: ECALActivity
4 // Class: ECALActivity
5 //
6 //
7 // Original Author: Luca Malgeri
8 
9 #include <memory>
10 #include <vector>
11 #include <map>
12 #include <set>
13 
14 // user include files
16 
28 
29 using namespace edm;
30 using namespace std;
31 
33  EBRecHitCollection_ = iConfig.getParameter<edm::InputTag>("ebrechitcollection");
34  EERecHitCollection_ = iConfig.getParameter<edm::InputTag>("ebrechitcollection");
35 
36  EBnum = iConfig.getUntrackedParameter<int>("EBnum");
37  EBthresh = iConfig.getUntrackedParameter<double>("EBthresh");
38  EEnum = iConfig.getUntrackedParameter<int>("EEnum");
39  EEthresh = iConfig.getUntrackedParameter<double>("EEthresh");
40  ETOTnum = iConfig.getUntrackedParameter<int>("ETOTnum");
41  ETOTthresh = iConfig.getUntrackedParameter<double>("ETOTthresh");
42  applyfilter = iConfig.getUntrackedParameter<bool>("applyfilter", true);
43 }
44 
46 
48  bool accepted = false;
49  bool eb = false;
50  bool ee = false;
51  bool etot = false;
52 
53  //int ievt = iEvent.id().event();
54  //int irun = iEvent.id().run();
55  //int ils = iEvent.luminosityBlock();
56 
57  int ebabovethresh = 0;
58  int eeabovethresh = 0;
59  int etotabovethresh = 0;
60 
61  Handle<EBRecHitCollection> pEBRecHits;
62  Handle<EERecHitCollection> pEERecHits;
63 
64  const EBRecHitCollection* EBRecHits = nullptr;
65  const EERecHitCollection* EERecHits = nullptr;
66 
67  if (!EBRecHitCollection_.label().empty() && !EBRecHitCollection_.instance().empty()) {
68  iEvent.getByLabel(EBRecHitCollection_, pEBRecHits);
69  if (pEBRecHits.isValid()) {
70  EBRecHits = pEBRecHits.product(); // get a ptr to the product
71  } else {
72  edm::LogError("EcalRecHitError") << "Error! can't get the product " << EBRecHitCollection_.label();
73  }
74  }
75 
76  if (!EERecHitCollection_.label().empty() && !EERecHitCollection_.instance().empty()) {
77  iEvent.getByLabel(EERecHitCollection_, pEERecHits);
78 
79  if (pEERecHits.isValid()) {
80  EERecHits = pEERecHits.product(); // get a ptr to the product
81  } else {
82  edm::LogError("EcalRecHitError") << "Error! can't get the product " << EERecHitCollection_.label();
83  }
84  }
85 
86  // now loop over them
87  if (EBRecHits) {
88  for (EBRecHitCollection::const_iterator it = EBRecHits->begin(); it != EBRecHits->end(); ++it) {
89  if (it->energy() > EBthresh)
90  ebabovethresh++;
91  if (it->energy() > ETOTthresh)
92  etotabovethresh++;
93  }
94  }
95  if (EERecHits) {
96  for (EERecHitCollection::const_iterator it = EERecHits->begin(); it != EERecHits->end(); ++it) {
97  if (it->energy() > EEthresh)
98  eeabovethresh++;
99  if (it->energy() > ETOTthresh)
100  etotabovethresh++;
101  }
102  }
103 
104  if (ebabovethresh >= EBnum)
105  eb = true;
106  if (eeabovethresh >= EEnum)
107  ee = true;
108  if (etotabovethresh >= ETOTnum)
109  etot = true;
110 
111  accepted = eb | ee | etot;
112 
113  if (applyfilter)
114  return accepted;
115  else
116  return true;
117 }
118 
119 //define this as a plug-in
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
applyfilter
Definition: DMR_cfg.py:138
T const * product() const
Definition: Handle.h:70
std::vector< EcalRecHit >::const_iterator const_iterator
Log< level::Error, false > LogError
T getUntrackedParameter(std::string const &, T const &) const
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool filter(edm::Event &, const edm::EventSetup &) override
Definition: ECALActivity.cc:47
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
ECALActivity(const edm::ParameterSet &)
Definition: ECALActivity.cc:32
~ECALActivity() override
Definition: ECALActivity.cc:45