CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {
38  EBRecHitCollection_ = iConfig.getParameter<edm::InputTag>("ebrechitcollection");
39  EERecHitCollection_ = iConfig.getParameter<edm::InputTag>("eerechitcollection");
40  HBHERecHitCollection_ = iConfig.getParameter<edm::InputTag>("hbherechitcollection");
41 
42  EnergyCutTot = iConfig.getUntrackedParameter<double>("energycuttot");
43  EnergyCutEcal = iConfig.getUntrackedParameter<double>("energycutecal");
44  EnergyCutHcal = iConfig.getUntrackedParameter<double>("energycuthcal");
45  applyfilter = iConfig.getUntrackedParameter<bool>("applyfilter",true);
46 }
47 
49 {
50 }
51 
53 {
54  bool accepted = false;
55 
56  bool acceptedtot = false;
57  bool acceptedEcal = false;
58  bool acceptedHcal = false;
59 
60  int ievt = iEvent.id().event();
61  int irun = iEvent.id().run();
62  int ils = iEvent.luminosityBlock();
63  int ibx = iEvent.bunchCrossing();
64 
65  double totene=0;
66  double ecalene=0;
67  double hcalene=0;
68 
69 
72  Handle< HBHERecHitCollection > pHBHERecHits;
73 
74  const EBRecHitCollection* EBRecHits = 0;
75  const EERecHitCollection* EERecHits = 0;
77 
78  if ( EBRecHitCollection_.label() != "" && EBRecHitCollection_.instance() != "" )
79  {
80  iEvent.getByLabel( EBRecHitCollection_, pEBRecHits);
81  if ( pEBRecHits.isValid() )
82  {
83  EBRecHits = pEBRecHits.product(); // get a ptr to the product
84  }
85  else
86  {
87  edm::LogError("EcalRecHitError") << "Error! can't get the product " << EBRecHitCollection_.label() ;
88  }
89  }
90 
91  if ( EERecHitCollection_.label() != "" && EERecHitCollection_.instance() != "" )
92  {
93  iEvent.getByLabel( EERecHitCollection_, pEERecHits);
94 
95  if ( pEERecHits.isValid() )
96  {
97  EERecHits = pEERecHits.product(); // get a ptr to the product
98  }
99  else
100  {
101  edm::LogError("EcalRecHitError") << "Error! can't get the product " << EERecHitCollection_.label() ;
102  }
103  }
104 
105  if ( HBHERecHitCollection_.label() != "" )
106  {
107  iEvent.getByLabel( HBHERecHitCollection_, pHBHERecHits);
108 
109  if ( pHBHERecHits.isValid() )
110  {
111  HBHERecHits = pHBHERecHits.product(); // get a ptr to the product
112  }
113  else
114  {
115  edm::LogError("HcalRecHitError") << "Error! can't get the product " << HBHERecHitCollection_.label() ;
116  }
117  }
118 
119  // now sum over them
120  if (EBRecHits)
121  {
122  for(EBRecHitCollection::const_iterator it = EBRecHits->begin(); it != EBRecHits->end(); ++it)
123  {
124  totene+=it->energy();
125  ecalene+=it->energy();
126  }
127  }
128  if (EERecHits)
129  {
130  for(EERecHitCollection::const_iterator it = EERecHits->begin(); it != EERecHits->end(); ++it)
131  {
132  totene+=it->energy();
133  ecalene+=it->energy();
134  }
135  }
136  if (HBHERecHits)
137  {
138  for(HBHERecHitCollection::const_iterator it = HBHERecHits->begin(); it != HBHERecHits->end(); ++it)
139  {
140  totene+=it->energy();
141  hcalene+=it->energy();
142  }
143  }
144 
145  if(totene>EnergyCutTot) acceptedtot=true;
146  if(ecalene>EnergyCutEcal) acceptedEcal=true;
147  if(hcalene>EnergyCutHcal) acceptedHcal=true;
148 
149  accepted = acceptedtot|acceptedEcal|acceptedHcal;
150 
151 
152  if (accepted)
153  {
154  edm::LogVerbatim("BeamSplash") << "!!!!!!!BeamSplash!!!!!!!: run:" << irun << " event:" << ievt << " ls:"<< ils << " bx= " << ibx <<" totene=" << totene << " ecalene=" << ecalene << " hcalene=" << hcalene ;
155  std::cout << "!!!!!!!BeamSplash!!!!!!!: run:" << irun << " event:" << ievt << " ls:"<< ils << " bx= " << ibx <<" totene=" <<totene << " ecalene=" << ecalene << " hcalene=" << hcalene << std::endl;
156  }
157 
158  if (applyfilter)
159  return accepted;
160  else
161  return true;
162 
163 }
164 
165 //define this as a plug-in
RunNumber_t run() const
Definition: EventID.h:42
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
T getUntrackedParameter(std::string const &, T const &) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< EcalRecHit >::const_iterator const_iterator
int bunchCrossing() const
Definition: EventBase.h:62
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
int iEvent
Definition: GenABIO.cc:230
virtual bool filter(edm::Event &, const edm::EventSetup &) override
Definition: BeamSplash.cc:52
BeamSplash(const edm::ParameterSet &)
Definition: BeamSplash.cc:36
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
const_iterator end() const
T const * product() const
Definition: Handle.h:81
edm::EventID id() const
Definition: EventBase.h:56
tuple cout
Definition: gather_cfg.py:121
const_iterator begin() const