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