CMS 3D CMS Logo

HcalQLPlotAnalAlgos.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HcalQLPlotAnal
4 // Class: HcalQLPlotAnal
5 //
13 //
14 // Original Author: Phillip R. Dudero
15 // Created: Tue Jan 16 21:11:37 CST 2007
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 #include <cmath>
22 
23 // user include files
29 #include "TH1.h"
30 
31 //
32 // constants, enums and typedefs
33 //
34 
35 //
36 // static data member definitions
37 //
38 
39 //
40 // constructors and destructor
41 //
44 
45  mf_ = new TFile(outputFilename, "RECREATE");
46  histos_ = new HcalQLPlotHistoMgr(mf_, histoParams);
47 }
48 
49 //
50 // member functions
51 //
52 
53 void HcalQLPlotAnalAlgos::end(void) { mf_->Write(); }
54 
59  if (trigd.wasLEDTrigger())
61  if (trigd.wasLaserTrigger())
63  if (trigd.wasBeamTrigger())
65 
67  edm::LogError("HcalQLPlotAnalAlgos::begin") << "Trigger Type unrecognized, aborting";
69  throw e;
70  }
71 }
72 
75 
76  for (it = hbherhc.begin(); it != hbherhc.end(); it++) {
77  HcalDetId id(it->id());
79  HBHEDigiCollection::const_iterator dit = hbhedgc.find(id);
80  if (dit != hbhedgc.end())
81  eid = dit->elecId();
82  else {
83  edm::LogWarning("HcalQLPlotAnalAlgos::processRH") << "No digi found for id" << id;
84  continue;
85  }
86 
88  if (ehist) {
89  ehist->Fill(it->energy());
90  }
91 
93  if (thist) {
94  thist->Fill(it->time());
95  }
96  }
97 }
98 
101 
102  for (it = horhc.begin(); it != horhc.end(); it++) {
103  HcalDetId id(it->id());
105  HODigiCollection::const_iterator dit = hodgc.find(id);
106  if (dit != hodgc.end())
107  eid = dit->elecId();
108  else {
109  edm::LogWarning("HcalQLPlotAnalAlgos::processRH") << "No digi found for id" << id;
110  continue;
111  }
112 
114  if (ehist) {
115  ehist->Fill(it->energy());
116  }
117 
119  if (thist) {
120  thist->Fill(it->time());
121  }
122  }
123 }
124 
127 
128  for (it = hfrhc.begin(); it != hfrhc.end(); it++) {
129  HcalDetId id(it->id());
131  HFDigiCollection::const_iterator dit = hfdgc.find(id);
132  if (dit != hfdgc.end())
133  eid = dit->elecId();
134  else {
135  edm::LogWarning("HcalQLPlotAnalAlgos::processRH") << "No digi found for id" << id;
136  continue;
137  }
138 
140  if (ehist) {
141  ehist->Fill(it->energy());
142  }
143 
145  if (thist) {
146  thist->Fill(it->time());
147  }
148  }
149 }
150 
153 
154  for (it = hbhedigic.begin(); it != hbhedigic.end(); it++) {
155  HcalDetId id(it->id());
156  HcalElectronicsId eid(it->elecId());
157 
159  if (phist) {
160  for (int bin = 0; bin < it->size(); bin++)
161  phist->Fill(bin * 1.0, (*it)[bin].nominal_fC());
162  }
163 
166  if (phist) {
167  for (int bin = 0; bin < it->size(); bin++)
168  phist->Fill((*it)[bin].adc());
169  }
170  }
171  }
172 }
173 
176 
177  for (it = hodigic.begin(); it != hodigic.end(); it++) {
178  HcalDetId id(it->id());
179  HcalElectronicsId eid(it->elecId());
180 
182  if (phist) {
183  for (int bin = 0; bin < it->size(); bin++)
184  phist->Fill(bin * 1.0, (*it)[bin].nominal_fC());
185  }
186 
189  if (phist) {
190  for (int bin = 0; bin < it->size(); bin++)
191  phist->Fill((*it)[bin].adc());
192  }
193  }
194  }
195 }
196 
199 
200  for (it = hfdigic.begin(); it != hfdigic.end(); it++) {
201  HcalDetId id(it->id());
202  HcalElectronicsId eid(it->elecId());
203 
205  if (phist) {
206  for (int bin = 0; bin < it->size(); bin++)
207  phist->Fill(bin * 1.0, (*it)[bin].nominal_fC());
208  }
209 
212  if (phist) {
213  for (int bin = 0; bin < it->size(); bin++)
214  phist->Fill((*it)[bin].adc());
215  }
216  }
217  }
218 }
219 
221  double nominal_ped = (cdigi[0].nominal_fC() + cdigi[1].nominal_fC()) / 2.0;
222 
223  double totamp = 0.0;
224  double maxA = -1e99;
225  int maxI = -1;
226  for (int i = 0; i < cdigi.size(); i++) {
227  double ampl = (cdigi[i].nominal_fC() - nominal_ped) * calibFC2GeV;
228  totamp += ampl;
229 
230  if (ampl > maxA) {
231  maxA = ampl;
232  maxI = i;
233  }
234  }
235 
236  maxA = fabs(maxA);
237  float t0 = (maxI > 0) ? (fabs((cdigi[maxI - 1].nominal_fC() - nominal_ped)) * calibFC2GeV) : 0.0;
238  float t2 = fabs((cdigi[maxI + 1].nominal_fC() - nominal_ped) * calibFC2GeV);
239  float wpksamp = (maxA + 2.0 * t2) / (t0 + maxA + t2);
240  float time = (maxI - cdigi.presamples() + wpksamp) * 25.0;
241 
242  return HcalCalibRecHit(cdigi.id(), totamp, time);
243 }
244 
245 void HcalQLPlotAnalAlgos::processDigi(const HcalCalibDigiCollection& calibdigic, double calibFC2GeV) {
247 
248  for (it = calibdigic.begin(); it != calibdigic.end(); it++) {
249  HcalCalibDetId id(it->id());
250  HcalElectronicsId eid(it->elecId());
251 
253  if (phist) {
254  for (int bin = 0; bin < it->size(); bin++)
255  phist->Fill(bin * 1.0, (*it)[bin].nominal_fC());
256  }
257 
258  // HACK-reco the calib digi into a rechit:
259  //
260  HcalCalibRecHit rh = recoCalib(*it, calibFC2GeV);
261 
263  if (ehist) {
264  ehist->Fill(rh.amplitude());
265  }
266 
268  if (thist) {
269  thist->Fill(rh.time());
270  }
271  }
272 }
int presamples() const
number of samples before the sample from the triggered beam crossing (according to the hardware) ...
bool wasLEDTrigger() const
returns true if this was a LED trigger
void processDigi(const HBHEDigiCollection &hbhedigic)
std::vector< T >::const_iterator const_iterator
int size() const
total number of samples in the digi
Log< level::Error, false > LogError
HcalCalibRecHit recoCalib(const HcalCalibDataFrame &cdigi, double calibFC2GeV)
bool wasSpillIgnorantPedestalTrigger() const
returns true if this trigger was a calibration trigger
float time() const
get the hit time (if available)
float amplitude() const
get the amplitude (generally fC, but can vary)
const HcalCalibDetId & id() const
void processRH(const HBHERecHitCollection &hbherhc, const HBHEDigiCollection &hbhedgc)
const_iterator begin() const
bool wasInSpillPedestalTrigger() const
returns true if this was an in-spill pedestal trigger
bool wasOutSpillPedestalTrigger() const
returns true if this was an out-of-spill pedestal trigger
void SetEventType(const HcalTBTriggerData &trigd)
HcalQLPlotAnalAlgos(const char *outputFilename, const edm::ParameterSet &histoParams)
const_iterator end() const
HcalQLPlotHistoMgr * histos_
TH1 * GetAHistogram(const HcalDetId &id, const HcalElectronicsId &eid, HistType ht, EventType et)
iterator find(key_type k)
bool wasLaserTrigger() const
returns true if this was a laser trigger
bool wasBeamTrigger() const
returns true if this trigger came from beam data
Log< level::Warning, false > LogWarning
HcalQLPlotHistoMgr::EventType triggerID_
Readout chain identification for Hcal.