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 //
42 HcalQLPlotAnalAlgos::HcalQLPlotAnalAlgos(const char* outputFilename, const edm::ParameterSet& histoParams) {
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 }
RandomServiceHelper.t2
t2
Definition: RandomServiceHelper.py:257
HcalTBTriggerData::wasLEDTrigger
bool wasLEDTrigger() const
returns true if this was a LED trigger
Definition: HcalTBTriggerData.h:93
mps_fire.i
i
Definition: mps_fire.py:355
HcalQLPlotHistoMgr::BEAM
Definition: HcalQLPlotHistoMgr.h:15
HcalCalibRecHit::time
float time() const
get the hit time (if available)
Definition: HcalCalibRecHit.h:19
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
MessageLogger.h
HcalQLPlotHistoMgr::ENERGY
Definition: HcalQLPlotHistoMgr.h:14
HcalQLPlotHistoMgr
Definition: HcalQLPlotHistoMgr.h:12
HcalCalibDetId
Definition: HcalCalibDetId.h:45
edm::SortedCollection
Definition: SortedCollection.h:49
HcalQLPlotAnalAlgos::processDigi
void processDigi(const HBHEDigiCollection &hbhedigic)
Definition: HcalQLPlotAnalAlgos.cc:151
findQualityFiles.maxI
int maxI
Definition: findQualityFiles.py:182
HcalQLPlotAnalAlgos::recoCalib
HcalCalibRecHit recoCalib(const HcalCalibDataFrame &cdigi, double calibFC2GeV)
Definition: HcalQLPlotAnalAlgos.cc:220
HcalQLPlotAnalAlgos::SetEventType
void SetEventType(const HcalTBTriggerData &trigd)
Definition: HcalQLPlotAnalAlgos.cc:55
HcalQLPlotAnalAlgos::end
void end(void)
Definition: HcalQLPlotAnalAlgos.cc:53
HcalTBTriggerData::wasSpillIgnorantPedestalTrigger
bool wasSpillIgnorantPedestalTrigger() const
returns true if this trigger was a calibration trigger
Definition: HcalTBTriggerData.h:79
FrontierCondition_GT_autoExpress_cfi.t0
t0
Definition: FrontierCondition_GT_autoExpress_cfi.py:148
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
HcalTBTriggerData::wasInSpillPedestalTrigger
bool wasInSpillPedestalTrigger() const
returns true if this was an in-spill pedestal trigger
Definition: HcalTBTriggerData.h:87
HcalElectronicsId
Readout chain identification for Hcal.
Definition: HcalElectronicsId.h:32
HcalQLPlotAnalAlgos::HcalQLPlotAnalAlgos
HcalQLPlotAnalAlgos(const char *outputFilename, const edm::ParameterSet &histoParams)
Definition: HcalQLPlotAnalAlgos.cc:42
HcalCalibRecHit::amplitude
float amplitude() const
get the amplitude (generally fC, but can vary)
Definition: HcalCalibRecHit.h:17
HcalQLPlotAnalAlgos::triggerID_
HcalQLPlotHistoMgr::EventType triggerID_
Definition: HcalQLPlotAnalAlgos.h:35
HcalQLPlotHistoMgr::TIME
Definition: HcalQLPlotHistoMgr.h:14
edm::LogWarning
Definition: MessageLogger.h:141
HcalCalibDataFrame
Definition: HcalCalibDataFrame.h:15
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
HcalCalibRecHit
Definition: HcalCalibRecHit.h:10
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
HcalQLPlotHistoMgr::PULSE
Definition: HcalQLPlotHistoMgr.h:14
HcalTBTriggerData
Definition: HcalTBTriggerData.h:17
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
HcalCalibDataFrame::presamples
int presamples() const
number of samples before the sample from the triggered beam crossing (according to the hardware)
Definition: HcalCalibDataFrame.h:28
HcalDetId
Definition: HcalDetId.h:12
runTauDisplay.eid
eid
Definition: runTauDisplay.py:298
HcalQLPlotHistoMgr::LED
Definition: HcalQLPlotHistoMgr.h:15
HcalQLPlotHistoMgr::LASER
Definition: HcalQLPlotHistoMgr.h:15
HcalCalibRecHit.h
HcalElectronicsId.h
HcalQLPlotAnalAlgos.h
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
edm::SortedCollection::find
iterator find(key_type k)
Definition: SortedCollection.h:240
HcalTBTriggerData::wasOutSpillPedestalTrigger
bool wasOutSpillPedestalTrigger() const
returns true if this was an out-of-spill pedestal trigger
Definition: HcalTBTriggerData.h:84
HcalQLPlotHistoMgr::UNKNOWN
Definition: HcalQLPlotHistoMgr.h:15
HcalQLPlotAnalAlgos::mf_
TFile * mf_
Definition: HcalQLPlotAnalAlgos.h:37
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
HcalQLPlotHistoMgr::PEDESTAL
Definition: HcalQLPlotHistoMgr.h:15
HcalTBTriggerData::wasLaserTrigger
bool wasLaserTrigger() const
returns true if this was a laser trigger
Definition: HcalTBTriggerData.h:90
HcalCalibDataFrame::size
int size() const
total number of samples in the digi
Definition: HcalCalibDataFrame.h:26
Exception.h
HcalQLPlotHistoMgr::ADC
Definition: HcalQLPlotHistoMgr.h:14
HcalTBTriggerData::wasBeamTrigger
bool wasBeamTrigger() const
returns true if this trigger came from beam data
Definition: HcalTBTriggerData.h:73
ntuplemaker.time
time
Definition: ntuplemaker.py:310
HcalCalibDataFrame::id
const HcalCalibDetId & id() const
Definition: HcalCalibDataFrame.h:22
HcalQLPlotAnalAlgos::histos_
HcalQLPlotHistoMgr * histos_
Definition: HcalQLPlotAnalAlgos.h:36
HcalQLPlotAnalAlgos::processRH
void processRH(const HBHERecHitCollection &hbherhc, const HBHEDigiCollection &hbhedgc)
Definition: HcalQLPlotAnalAlgos.cc:73
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
HcalQLPlotHistoMgr::GetAHistogram
TH1 * GetAHistogram(const HcalDetId &id, const HcalElectronicsId &eid, HistType ht, EventType et)
Definition: HcalQLPlotHistoMgr.cc:64