CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // $Id: HcalQLPlotAnalAlgos.cc,v 1.4 2008/01/05 22:27:39 elmer Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 #include <math.h>
24 
25 // user include files
31 #include "TH1.h"
32 
33 //
34 // constants, enums and typedefs
35 //
36 
37 //
38 // static data member definitions
39 //
40 
41 //
42 // constructors and destructor
43 //
44 HcalQLPlotAnalAlgos::HcalQLPlotAnalAlgos(const char *outputFilename,
45  edm::ParameterSet histoParams)
46 {
48 
49  mf_ = new TFile(outputFilename,"RECREATE");
50  histos_ = new HcalQLPlotHistoMgr(mf_,histoParams);
51 }
52 
53 
54 //
55 // member functions
56 //
57 
59 {
60  mf_->Write();
61 }
62 
64 {
65  if( trigd.wasInSpillPedestalTrigger() ||
72 
74  edm::LogError("HcalQLPlotAnalAlgos::begin") <<
75  "Trigger Type unrecognized, aborting";
77  throw e;
78  }
79 }
80 
82  const HBHEDigiCollection& hbhedgc)
83 {
85 
86  for (it = hbherhc.begin();
87  it != hbherhc.end();
88  it++) {
89  HcalDetId id (it->id());
91  HBHEDigiCollection::const_iterator dit = hbhedgc.find(id);
92  if (dit != hbhedgc.end())
93  eid = dit->elecId();
94  else {
95  edm::LogWarning("HcalQLPlotAnalAlgos::processRH") <<
96  "No digi found for id" << id;
97  continue;
98  }
99 
101  if (ehist){
102  ehist->Fill(it->energy());
103  }
104 
106  if (thist){
107  thist->Fill(it->time());
108  }
109  }
110 }
111 
113  const HODigiCollection& hodgc)
114 {
116 
117  for (it = horhc.begin();
118  it != horhc.end();
119  it++) {
120  HcalDetId id (it->id());
121  HcalElectronicsId eid;
122  HODigiCollection::const_iterator dit = hodgc.find(id);
123  if (dit != hodgc.end())
124  eid = dit->elecId();
125  else {
126  edm::LogWarning("HcalQLPlotAnalAlgos::processRH") <<
127  "No digi found for id" << id;
128  continue;
129  }
130 
132  if (ehist){
133  ehist->Fill(it->energy());
134  }
135 
137  if (thist){
138  thist->Fill(it->time());
139  }
140  }
141 }
142 
144  const HFDigiCollection& hfdgc)
145 {
147 
148  for (it = hfrhc.begin();
149  it != hfrhc.end();
150  it++) {
151  HcalDetId id (it->id());
152  HcalElectronicsId eid;
153  HFDigiCollection::const_iterator dit = hfdgc.find(id);
154  if (dit != hfdgc.end())
155  eid = dit->elecId();
156  else {
157  edm::LogWarning("HcalQLPlotAnalAlgos::processRH") <<
158  "No digi found for id" << id;
159  continue;
160  }
161 
163  if (ehist){
164  ehist->Fill(it->energy());
165  }
166 
168  if (thist){
169  thist->Fill(it->time());
170  }
171  }
172 }
173 
175 {
177 
178  for (it = hbhedigic.begin();
179  it != hbhedigic.end();
180  it++) {
181  HcalDetId id (it->id());
182  HcalElectronicsId eid (it->elecId());
183 
185  if (phist){
186  for (int bin=0; bin<it->size(); bin++)
187  phist->Fill(bin*1.0,(*it)[bin].nominal_fC());
188  }
189 
192  if (phist){
193  for (int bin=0; bin<it->size(); bin++)
194  phist->Fill((*it)[bin].adc());
195  }
196  }
197  }
198 }
199 
201 {
203 
204  for (it = hodigic.begin();
205  it != hodigic.end();
206  it++) {
207  HcalDetId id (it->id());
208  HcalElectronicsId eid (it->elecId());
209 
211  if (phist){
212  for (int bin=0; bin<it->size(); bin++)
213  phist->Fill(bin*1.0,(*it)[bin].nominal_fC());
214  }
215 
218  if (phist){
219  for (int bin=0; bin<it->size(); bin++)
220  phist->Fill((*it)[bin].adc());
221  }
222  }
223  }
224 }
225 
227 {
229 
230  for (it = hfdigic.begin();
231  it != hfdigic.end();
232  it++) {
233  HcalDetId id (it->id());
234  HcalElectronicsId eid (it->elecId());
235 
237  if (phist){
238  for (int bin=0; bin<it->size(); bin++)
239  phist->Fill(bin*1.0,(*it)[bin].nominal_fC());
240  }
241 
244  if (phist){
245  for (int bin=0; bin<it->size(); bin++)
246  phist->Fill((*it)[bin].adc());
247  }
248  }
249  }
250 }
251 
253  double calibFC2GeV)
254 {
255  double nominal_ped = (cdigi[0].nominal_fC() + cdigi[1].nominal_fC())/2.0;
256 
257  double totamp = 0.0;
258  double maxA = -1e99;
259  int maxI = -1;
260  for (int i=0; i<cdigi.size(); i++) {
261  double ampl = (cdigi[i].nominal_fC()-nominal_ped)*calibFC2GeV;
262  totamp += ampl;
263 
264  if (ampl > maxA) {
265  maxA = ampl;
266  maxI = i;
267  }
268  }
269 
270  maxA=fabs(maxA);
271  float t0 = (maxI > 0) ? (fabs((cdigi[maxI-1].nominal_fC()-nominal_ped))*calibFC2GeV):0.0;
272  float t2 = fabs((cdigi[maxI+1].nominal_fC()-nominal_ped)*calibFC2GeV);
273  float wpksamp = (maxA + 2.0*t2) / (t0 + maxA + t2);
274  float time = (maxI - cdigi.presamples() + wpksamp)*25.0;
275 
276  return HcalCalibRecHit(cdigi.id(),totamp,time);
277 }
278 
280  double calibFC2GeV)
281 {
283 
284  for (it = calibdigic.begin();
285  it != calibdigic.end();
286  it++) {
287  HcalCalibDetId id (it->id());
288  HcalElectronicsId eid (it->elecId());
289 
291  if (phist){
292  for (int bin=0; bin<it->size(); bin++)
293  phist->Fill(bin*1.0,(*it)[bin].nominal_fC());
294  }
295 
296  // HACK-reco the calib digi into a rechit:
297  //
298  HcalCalibRecHit rh = recoCalib(*it, calibFC2GeV);
299 
301  if (ehist){
302  ehist->Fill(rh.amplitude());
303  }
304 
306  if (thist){
307  thist->Fill(rh.time());
308  }
309  }
310 }
311 
int i
Definition: DBlmapReader.cc:9
float amplitude() const
get the amplitude (generally fC, but can vary)
HcalQLPlotAnalAlgos(const char *outputFilename, edm::ParameterSet histoParams)
bool wasLEDTrigger() const
returns true if this was a LED trigger
void processDigi(const HBHEDigiCollection &hbhedigic)
std::vector< T >::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:18
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)
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 [31:26] Unused (so far) [25] Trigger-chain id flag [24:20] Read...
const_iterator begin() const