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 
20 // system include files
21 #include <memory>
22 #include <cmath>
23 
24 // user include files
30 #include "TH1.h"
31 
32 //
33 // constants, enums and typedefs
34 //
35 
36 //
37 // static data member definitions
38 //
39 
40 //
41 // constructors and destructor
42 //
43 HcalQLPlotAnalAlgos::HcalQLPlotAnalAlgos(const char *outputFilename,
44  const edm::ParameterSet& histoParams)
45 {
47 
48  mf_ = new TFile(outputFilename,"RECREATE");
49  histos_ = new HcalQLPlotHistoMgr(mf_,histoParams);
50 }
51 
52 
53 //
54 // member functions
55 //
56 
58 {
59  mf_->Write();
60 }
61 
63 {
64  if( trigd.wasInSpillPedestalTrigger() ||
71 
73  edm::LogError("HcalQLPlotAnalAlgos::begin") <<
74  "Trigger Type unrecognized, aborting";
76  throw e;
77  }
78 }
79 
81  const HBHEDigiCollection& hbhedgc)
82 {
84 
85  for (it = hbherhc.begin();
86  it != hbherhc.end();
87  it++) {
88  HcalDetId id (it->id());
90  HBHEDigiCollection::const_iterator dit = hbhedgc.find(id);
91  if (dit != hbhedgc.end())
92  eid = dit->elecId();
93  else {
94  edm::LogWarning("HcalQLPlotAnalAlgos::processRH") <<
95  "No digi found for id" << id;
96  continue;
97  }
98 
100  if (ehist){
101  ehist->Fill(it->energy());
102  }
103 
105  if (thist){
106  thist->Fill(it->time());
107  }
108  }
109 }
110 
112  const HODigiCollection& hodgc)
113 {
115 
116  for (it = horhc.begin();
117  it != horhc.end();
118  it++) {
119  HcalDetId id (it->id());
121  HODigiCollection::const_iterator dit = hodgc.find(id);
122  if (dit != hodgc.end())
123  eid = dit->elecId();
124  else {
125  edm::LogWarning("HcalQLPlotAnalAlgos::processRH") <<
126  "No digi found for id" << id;
127  continue;
128  }
129 
131  if (ehist){
132  ehist->Fill(it->energy());
133  }
134 
136  if (thist){
137  thist->Fill(it->time());
138  }
139  }
140 }
141 
143  const HFDigiCollection& hfdgc)
144 {
146 
147  for (it = hfrhc.begin();
148  it != hfrhc.end();
149  it++) {
150  HcalDetId id (it->id());
152  HFDigiCollection::const_iterator dit = hfdgc.find(id);
153  if (dit != hfdgc.end())
154  eid = dit->elecId();
155  else {
156  edm::LogWarning("HcalQLPlotAnalAlgos::processRH") <<
157  "No digi found for id" << id;
158  continue;
159  }
160 
162  if (ehist){
163  ehist->Fill(it->energy());
164  }
165 
167  if (thist){
168  thist->Fill(it->time());
169  }
170  }
171 }
172 
174 {
176 
177  for (it = hbhedigic.begin();
178  it != hbhedigic.end();
179  it++) {
180  HcalDetId id (it->id());
181  HcalElectronicsId eid (it->elecId());
182 
184  if (phist){
185  for (int bin=0; bin<it->size(); bin++)
186  phist->Fill(bin*1.0,(*it)[bin].nominal_fC());
187  }
188 
191  if (phist){
192  for (int bin=0; bin<it->size(); bin++)
193  phist->Fill((*it)[bin].adc());
194  }
195  }
196  }
197 }
198 
200 {
202 
203  for (it = hodigic.begin();
204  it != hodigic.end();
205  it++) {
206  HcalDetId id (it->id());
207  HcalElectronicsId eid (it->elecId());
208 
210  if (phist){
211  for (int bin=0; bin<it->size(); bin++)
212  phist->Fill(bin*1.0,(*it)[bin].nominal_fC());
213  }
214 
217  if (phist){
218  for (int bin=0; bin<it->size(); bin++)
219  phist->Fill((*it)[bin].adc());
220  }
221  }
222  }
223 }
224 
226 {
228 
229  for (it = hfdigic.begin();
230  it != hfdigic.end();
231  it++) {
232  HcalDetId id (it->id());
233  HcalElectronicsId eid (it->elecId());
234 
236  if (phist){
237  for (int bin=0; bin<it->size(); bin++)
238  phist->Fill(bin*1.0,(*it)[bin].nominal_fC());
239  }
240 
243  if (phist){
244  for (int bin=0; bin<it->size(); bin++)
245  phist->Fill((*it)[bin].adc());
246  }
247  }
248  }
249 }
250 
252  double calibFC2GeV)
253 {
254  double nominal_ped = (cdigi[0].nominal_fC() + cdigi[1].nominal_fC())/2.0;
255 
256  double totamp = 0.0;
257  double maxA = -1e99;
258  int maxI = -1;
259  for (int i=0; i<cdigi.size(); i++) {
260  double ampl = (cdigi[i].nominal_fC()-nominal_ped)*calibFC2GeV;
261  totamp += ampl;
262 
263  if (ampl > maxA) {
264  maxA = ampl;
265  maxI = i;
266  }
267  }
268 
269  maxA=fabs(maxA);
270  float t0 = (maxI > 0) ? (fabs((cdigi[maxI-1].nominal_fC()-nominal_ped))*calibFC2GeV):0.0;
271  float t2 = fabs((cdigi[maxI+1].nominal_fC()-nominal_ped)*calibFC2GeV);
272  float wpksamp = (maxA + 2.0*t2) / (t0 + maxA + t2);
273  float time = (maxI - cdigi.presamples() + wpksamp)*25.0;
274 
275  return HcalCalibRecHit(cdigi.id(),totamp,time);
276 }
277 
279  double calibFC2GeV)
280 {
282 
283  for (it = calibdigic.begin();
284  it != calibdigic.end();
285  it++) {
286  HcalCalibDetId id (it->id());
287  HcalElectronicsId eid (it->elecId());
288 
290  if (phist){
291  for (int bin=0; bin<it->size(); bin++)
292  phist->Fill(bin*1.0,(*it)[bin].nominal_fC());
293  }
294 
295  // HACK-reco the calib digi into a rechit:
296  //
297  HcalCalibRecHit rh = recoCalib(*it, calibFC2GeV);
298 
300  if (ehist){
301  ehist->Fill(rh.amplitude());
302  }
303 
305  if (thist){
306  thist->Fill(rh.time());
307  }
308  }
309 }
310 
float amplitude() const
get the amplitude (generally fC, but can vary)
bool wasLEDTrigger() const
returns true if this was a LED trigger
void processDigi(const HBHEDigiCollection &hbhedigic)
std::vector< HBHERecHit >::const_iterator const_iterator
int presamples() const
number of samples before the sample from the triggered beam crossing (according to the hardware) ...
HcalCalibRecHit recoCalib(const HcalCalibDataFrame &cdigi, double calibFC2GeV)
int size() const
total number of samples in the digi
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:16
bool wasOutSpillPedestalTrigger() const
returns true if this was an out-of-spill pedestal trigger
void processRH(const HBHERecHitCollection &hbherhc, const HBHEDigiCollection &hbhedgc)
const HcalCalibDetId & id() const
void SetEventType(const HcalTBTriggerData &trigd)
HcalQLPlotAnalAlgos(const char *outputFilename, const edm::ParameterSet &histoParams)
bin
set the eta bin as selection string.
HcalQLPlotHistoMgr * histos_
const_iterator end() const
TH1 * GetAHistogram(const HcalDetId &id, const HcalElectronicsId &eid, HistType ht, EventType et)
float time() const
get the hit time (if available)
iterator find(key_type k)
bool wasSpillIgnorantPedestalTrigger() const
returns true if this trigger was a calibration trigger
bool wasInSpillPedestalTrigger() const
returns true if this was an in-spill pedestal trigger
bool wasBeamTrigger() const
returns true if this trigger came from beam data
bool wasLaserTrigger() const
returns true if this was a laser trigger
HcalQLPlotHistoMgr::EventType triggerID_
Readout chain identification for Hcal.
const_iterator begin() const