CMS 3D CMS Logo

BeamSplash.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: BeamSplash
4 // Class: BeamSPlash
5 //
6 //
7 // Original Author: Luca Malgeri
8 
9 #include <iostream>
10 #include <memory>
11 #include <vector>
12 #include <map>
13 #include <set>
14 
15 // user include files
17 
32 
33 using namespace edm;
34 using namespace std;
35 
37  EBRecHitCollection_ = iConfig.getParameter<edm::InputTag>("ebrechitcollection");
38  EERecHitCollection_ = iConfig.getParameter<edm::InputTag>("eerechitcollection");
39  HBHERecHitCollection_ = iConfig.getParameter<edm::InputTag>("hbherechitcollection");
40 
41  EnergyCutTot = iConfig.getUntrackedParameter<double>("energycuttot");
42  EnergyCutEcal = iConfig.getUntrackedParameter<double>("energycutecal");
43  EnergyCutHcal = iConfig.getUntrackedParameter<double>("energycuthcal");
44  applyfilter = iConfig.getUntrackedParameter<bool>("applyfilter", true);
45 }
46 
48 
50  bool accepted = false;
51 
52  bool acceptedtot = false;
53  bool acceptedEcal = false;
54  bool acceptedHcal = false;
55 
56  int ievt = iEvent.id().event();
57  int irun = iEvent.id().run();
58  int ils = iEvent.luminosityBlock();
59  int ibx = iEvent.bunchCrossing();
60 
61  double totene = 0;
62  double ecalene = 0;
63  double hcalene = 0;
64 
65  Handle<EBRecHitCollection> pEBRecHits;
66  Handle<EERecHitCollection> pEERecHits;
67  Handle<HBHERecHitCollection> pHBHERecHits;
68 
69  const EBRecHitCollection* EBRecHits = nullptr;
70  const EERecHitCollection* EERecHits = nullptr;
71  const HBHERecHitCollection* HBHERecHits = nullptr;
72 
73  if (!EBRecHitCollection_.label().empty() && !EBRecHitCollection_.instance().empty()) {
74  iEvent.getByLabel(EBRecHitCollection_, pEBRecHits);
75  if (pEBRecHits.isValid()) {
76  EBRecHits = pEBRecHits.product(); // get a ptr to the product
77  } else {
78  edm::LogError("EcalRecHitError") << "Error! can't get the product " << EBRecHitCollection_.label();
79  }
80  }
81 
82  if (!EERecHitCollection_.label().empty() && !EERecHitCollection_.instance().empty()) {
83  iEvent.getByLabel(EERecHitCollection_, pEERecHits);
84 
85  if (pEERecHits.isValid()) {
86  EERecHits = pEERecHits.product(); // get a ptr to the product
87  } else {
88  edm::LogError("EcalRecHitError") << "Error! can't get the product " << EERecHitCollection_.label();
89  }
90  }
91 
92  if (!HBHERecHitCollection_.label().empty()) {
93  iEvent.getByLabel(HBHERecHitCollection_, pHBHERecHits);
94 
95  if (pHBHERecHits.isValid()) {
96  HBHERecHits = pHBHERecHits.product(); // get a ptr to the product
97  } else {
98  edm::LogError("HcalRecHitError") << "Error! can't get the product " << HBHERecHitCollection_.label();
99  }
100  }
101 
102  // now sum over them
103  if (EBRecHits) {
104  for (EBRecHitCollection::const_iterator it = EBRecHits->begin(); it != EBRecHits->end(); ++it) {
105  totene += it->energy();
106  ecalene += it->energy();
107  }
108  }
109  if (EERecHits) {
110  for (EERecHitCollection::const_iterator it = EERecHits->begin(); it != EERecHits->end(); ++it) {
111  totene += it->energy();
112  ecalene += it->energy();
113  }
114  }
115  if (HBHERecHits) {
116  for (HBHERecHitCollection::const_iterator it = HBHERecHits->begin(); it != HBHERecHits->end(); ++it) {
117  totene += it->energy();
118  hcalene += it->energy();
119  }
120  }
121 
122  if (totene > EnergyCutTot)
123  acceptedtot = true;
124  if (ecalene > EnergyCutEcal)
125  acceptedEcal = true;
126  if (hcalene > EnergyCutHcal)
127  acceptedHcal = true;
128 
129  accepted = acceptedtot | acceptedEcal | acceptedHcal;
130 
131  if (accepted) {
132  edm::LogVerbatim("BeamSplash") << "!!!!!!!BeamSplash!!!!!!!: run:" << irun << " event:" << ievt << " ls:" << ils
133  << " bx= " << ibx << " totene=" << totene << " ecalene=" << ecalene
134  << " hcalene=" << hcalene;
135  std::cout << "!!!!!!!BeamSplash!!!!!!!: run:" << irun << " event:" << ievt << " ls:" << ils << " bx= " << ibx
136  << " totene=" << totene << " ecalene=" << ecalene << " hcalene=" << hcalene << std::endl;
137  }
138 
139  if (applyfilter)
140  return accepted;
141  else
142  return true;
143 }
144 
145 //define this as a plug-in
BeamSplash::~BeamSplash
~BeamSplash() override
Definition: BeamSplash.cc:47
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
egHLT::errCodes::HBHERecHits
Definition: EgHLTErrCodes.h:20
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
EBDetId.h
EEDetId.h
edm::SortedCollection< EcalRecHit >
EDFilter.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::Handle
Definition: AssociativeIterator.h:50
filterRecHits_cfi.EERecHits
EERecHits
Definition: filterRecHits_cfi.py:9
EcalRecHitCollections.h
BeamSplash
Definition: BeamSplash.h:31
MakerMacros.h
BeamSplash::BeamSplash
BeamSplash(const edm::ParameterSet &)
Definition: BeamSplash.cc:36
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
BeamSplash::filter
bool filter(edm::Event &, const edm::EventSetup &) override
Definition: BeamSplash.cc:49
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
HcalDetId.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
BeamSplash.h
EcalRecHit.h
InputTag.h
bsc_activity_cfg.applyfilter
applyfilter
Definition: bsc_activity_cfg.py:23
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HcalRecHitCollections.h
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