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 <memory>
10 #include <vector>
11 #include <map>
12 #include <set>
13 
14 // user include files
16 
31 
32 using namespace edm;
33 using namespace std;
34 
36 {
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 {
49 }
50 
52 {
53  bool accepted = false;
54 
55  bool acceptedtot = false;
56  bool acceptedEcal = false;
57  bool acceptedHcal = false;
58 
59  int ievt = iEvent.id().event();
60  int irun = iEvent.id().run();
61  int ils = iEvent.luminosityBlock();
62  int ibx = iEvent.bunchCrossing();
63 
64  double totene=0;
65  double ecalene=0;
66  double hcalene=0;
67 
68 
71  Handle< HBHERecHitCollection > pHBHERecHits;
72 
73  const EBRecHitCollection* EBRecHits = 0;
74  const EERecHitCollection* EERecHits = 0;
76 
77  if ( EBRecHitCollection_.label() != "" && EBRecHitCollection_.instance() != "" )
78  {
79  iEvent.getByLabel( EBRecHitCollection_, pEBRecHits);
80  if ( pEBRecHits.isValid() )
81  {
82  EBRecHits = pEBRecHits.product(); // get a ptr to the product
83  }
84  else
85  {
86  edm::LogError("EcalRecHitError") << "Error! can't get the product " << EBRecHitCollection_.label() ;
87  }
88  }
89 
90  if ( EERecHitCollection_.label() != "" && EERecHitCollection_.instance() != "" )
91  {
92  iEvent.getByLabel( EERecHitCollection_, pEERecHits);
93 
94  if ( pEERecHits.isValid() )
95  {
96  EERecHits = pEERecHits.product(); // get a ptr to the product
97  }
98  else
99  {
100  edm::LogError("EcalRecHitError") << "Error! can't get the product " << EERecHitCollection_.label() ;
101  }
102  }
103 
104  if ( HBHERecHitCollection_.label() != "" )
105  {
106  iEvent.getByLabel( HBHERecHitCollection_, pHBHERecHits);
107 
108  if ( pHBHERecHits.isValid() )
109  {
110  HBHERecHits = pHBHERecHits.product(); // get a ptr to the product
111  }
112  else
113  {
114  edm::LogError("HcalRecHitError") << "Error! can't get the product " << HBHERecHitCollection_.label() ;
115  }
116  }
117 
118  // now sum over them
119  if (EBRecHits)
120  {
121  for(EBRecHitCollection::const_iterator it = EBRecHits->begin(); it != EBRecHits->end(); ++it)
122  {
123  totene+=it->energy();
124  ecalene+=it->energy();
125  }
126  }
127  if (EERecHits)
128  {
129  for(EERecHitCollection::const_iterator it = EERecHits->begin(); it != EERecHits->end(); ++it)
130  {
131  totene+=it->energy();
132  ecalene+=it->energy();
133  }
134  }
135  if (HBHERecHits)
136  {
137  for(HBHERecHitCollection::const_iterator it = HBHERecHits->begin(); it != HBHERecHits->end(); ++it)
138  {
139  totene+=it->energy();
140  hcalene+=it->energy();
141  }
142  }
143 
144  if(totene>EnergyCutTot) acceptedtot=true;
145  if(ecalene>EnergyCutEcal) acceptedEcal=true;
146  if(hcalene>EnergyCutHcal) acceptedHcal=true;
147 
148  accepted = acceptedtot|acceptedEcal|acceptedHcal;
149 
150 
151  if (accepted)
152  {
153  edm::LogVerbatim("BeamSplash") << "!!!!!!!BeamSplash!!!!!!!: run:" << irun << " event:" << ievt << " ls:"<< ils << " bx= " << ibx <<" totene=" << totene << " ecalene=" << ecalene << " hcalene=" << hcalene ;
154  std::cout << "!!!!!!!BeamSplash!!!!!!!: run:" << irun << " event:" << ievt << " ls:"<< ils << " bx= " << ibx <<" totene=" <<totene << " ecalene=" << ecalene << " hcalene=" << hcalene << std::endl;
155  }
156 
157  if (applyfilter)
158  return accepted;
159  else
160  return true;
161 
162 }
163 
164 //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
std::vector< T >::const_iterator const_iterator
int bunchCrossing() const
Definition: EventBase.h:62
virtual bool filter(edm::Event &, const edm::EventSetup &)
Definition: BeamSplash.cc:51
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
DEFINE_FWK_MODULE(HiMixingModule)
int iEvent
Definition: GenABIO.cc:243
BeamSplash(const edm::ParameterSet &)
Definition: BeamSplash.cc:35
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
const_iterator end() const
T const * product() const
Definition: Handle.h:74
tuple applyfilter
Definition: align_tpl.py:76
edm::EventID id() const
Definition: EventBase.h:56
tuple cout
Definition: gather_cfg.py:41
const_iterator begin() const