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
edm::SortedCollection< EcalRecHit >::const_iterator
std::vector< EcalRecHit >::const_iterator const_iterator
Definition: SortedCollection.h:80
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ESHandle.h
edm
HLT enums.
Definition: AlignableModifier.h:19
EBDetId.h
EEDetId.h
edm::SortedCollection< EcalRecHit >
EDFilter.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
ECALActivity
Definition: ECALActivity.h:31
edm::Handle
Definition: AssociativeIterator.h:50
filterRecHits_cfi.EERecHits
EERecHits
Definition: filterRecHits_cfi.py:9
EcalRecHitCollections.h
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bsc_activity_cfg.ETOTthresh
ETOTthresh
Definition: bsc_activity_cfg.py:22
ECALActivity.h
bsc_activity_cfg.EBnum
EBnum
Definition: bsc_activity_cfg.py:17
ECALActivity::filter
bool filter(edm::Event &, const edm::EventSetup &) override
Definition: ECALActivity.cc:48
edm::ParameterSet
Definition: ParameterSet.h:47
bsc_activity_cfg.ETOTnum
ETOTnum
Definition: bsc_activity_cfg.py:21
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
bsc_activity_cfg.EEnum
EEnum
Definition: bsc_activity_cfg.py:19
EcalRecHit.h
InputTag.h
ECALActivity::ECALActivity
ECALActivity(const edm::ParameterSet &)
Definition: ECALActivity.cc:33
bsc_activity_cfg.applyfilter
applyfilter
Definition: bsc_activity_cfg.py:23
bsc_activity_cfg.EEthresh
EEthresh
Definition: bsc_activity_cfg.py:20
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
ECALActivity::~ECALActivity
~ECALActivity() override
Definition: ECALActivity.cc:46
bsc_activity_cfg.EBthresh
EBthresh
Definition: bsc_activity_cfg.py:18
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ParameterSet.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
filterRecHits_cfi.EBRecHits
EBRecHits
Definition: filterRecHits_cfi.py:8