CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
HcalLedAnalysis Class Reference

#include <HcalLedAnalysis.h>

Classes

struct  CALIBBUNCH
 

Public Member Functions

 HcalLedAnalysis (const edm::ParameterSet &ps)
 Constructor. More...
 
void LedDone ()
 
void LedSampleAnalysis ()
 
void LedSetup (const std::string &m_outputFileROOT)
 
void processLedEvent (const HBHEDigiCollection &hbhe, const HODigiCollection &ho, const HFDigiCollection &hf, const HcalCalibDigiCollection &calib, const HcalDbService &cond)
 
 ~HcalLedAnalysis ()
 Destructor. More...
 

Private Types

typedef std::pair< TH1F *, std::pair< std::map< int, std::vector< double > >, std::vector< TH1F * > > > LEDBUNCH
 

Private Member Functions

float BinsizeCorr (float time)
 
void GetLedConst (std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
 
void LedHBHEHists (const HcalDetId &detid, const HBHEDataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
 
void LedHFHists (const HcalDetId &detid, const HFDataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
 
void LedHOHists (const HcalDetId &detid, const HODataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
 
void LedTrendings (std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
 
void ProcessCalibEvent (int fiberChan, HcalCalibDetId calibId, const HcalCalibDataFrame &digi)
 
void SetupLEDHists (int id, const HcalDetId detid, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
 

Private Attributes

std::map< HcalCalibDetId, CALIBBUNCH >::iterator _meca
 
std::map< HcalDetId, std::map< int, float > >::iterator _meee
 
std::map< HcalDetId, std::map< int, LEDBUNCH > >::iterator _meol
 
std::map< HcalCalibDetId, CALIBBUNCHcalibHists
 
int evt
 
int evt_curr
 
struct {
   TH1F *   ALLLEDS
 
   TH1F *   CHI2
 
   TH1F *   LEDMEAN
 
   TH1F *   LEDRMS
 
   std::map< HcalDetId, std::map< int, LEDBUNCH > >   LEDTRENDS
 
hbHists
 
struct {
   TH1F *   ALLLEDS
 
   TH1F *   CHI2
 
   TH1F *   LEDMEAN
 
   TH1F *   LEDRMS
 
   std::map< HcalDetId, std::map< int, LEDBUNCH > >   LEDTRENDS
 
hfHists
 
struct {
   TH1F *   ALLLEDS
 
   TH1F *   CHI2
 
   TH1F *   LEDMEAN
 
   TH1F *   LEDRMS
 
   std::map< HcalDetId, std::map< int, LEDBUNCH > >   LEDTRENDS
 
hoHists
 
std::map< HcalDetId, std::map< int, float > > m_AllPedVals
 
const HcalQIECoderm_coder
 
int m_endTS
 
TFile * m_file
 
int m_fitflag
 
int m_hiSaveflag
 
std::ofstream m_logFile
 
int m_nevtsample
 
std::ofstream m_outFile
 
std::string m_outputFileROOT
 
std::string m_outputFileText
 
std::string m_outputFileX
 
std::ofstream m_outputFileXML
 
const HcalPedestalm_ped
 
const HcalQIEShapem_shape
 
int m_startTS
 
bool m_usecalib
 
int sample
 
std::vector< bool > state
 

Detailed Description

Definition at line 25 of file HcalLedAnalysis.h.

Member Typedef Documentation

◆ LEDBUNCH

typedef std::pair<TH1F*, std::pair<std::map<int, std::vector<double> >, std::vector<TH1F*> > > HcalLedAnalysis::LEDBUNCH
private

Definition at line 57 of file HcalLedAnalysis.h.

Constructor & Destructor Documentation

◆ HcalLedAnalysis()

HcalLedAnalysis::HcalLedAnalysis ( const edm::ParameterSet ps)

Constructor.

Definition at line 11 of file HcalLedAnalysis.cc.

References gather_cfg::cout, edm::ParameterSet::getUntrackedParameter(), dqmdumpme::k, convertSQLitetoXML_cfg::output, DeadROC_duringRun::runNum, and ecalGpuTask_cfi::sample.

11  {
12  // init
13 
14  m_coder = nullptr;
15  m_ped = nullptr;
16  m_shape = nullptr;
17  evt = 0;
18  sample = 0;
19  m_file = nullptr;
20  // output files
21  for (int k = 0; k < 4; k++)
22  state.push_back(true); // 4 cap-ids (do we care?)
23  m_outputFileText = ps.getUntrackedParameter<string>("outputFileText", "");
24  m_outputFileX = ps.getUntrackedParameter<string>("outputFileXML", "");
25  if (!m_outputFileText.empty()) {
26  cout << "Hcal LED results will be saved to " << m_outputFileText.c_str() << endl;
27  m_outFile.open(m_outputFileText.c_str());
28  }
29  m_outputFileROOT = ps.getUntrackedParameter<string>("outputFileHist", "");
30  if (!m_outputFileROOT.empty()) {
31  cout << "Hcal LED histograms will be saved to " << m_outputFileROOT.c_str() << endl;
32  }
33 
34  m_nevtsample = ps.getUntrackedParameter<int>("nevtsample", 9999999);
35  if (m_nevtsample < 1)
36  m_nevtsample = 9999999;
37  m_hiSaveflag = ps.getUntrackedParameter<int>("hiSaveflag", 0);
38  if (m_hiSaveflag < 0)
39  m_hiSaveflag = 0;
40  if (m_hiSaveflag > 0)
41  m_hiSaveflag = 1;
42  m_fitflag = ps.getUntrackedParameter<int>("analysisflag", 2);
43  if (m_fitflag < 0)
44  m_fitflag = 0;
45  if (m_fitflag > 4)
46  m_fitflag = 4;
47  m_startTS = ps.getUntrackedParameter<int>("firstTS", 0);
48  if (m_startTS < 0)
49  m_startTS = 0;
50  m_endTS = ps.getUntrackedParameter<int>("lastTS", 9);
51  m_usecalib = ps.getUntrackedParameter<bool>("usecalib", false);
52  m_logFile.open("HcalLedAnalysis.log");
53 
54  int runNum = ps.getUntrackedParameter<int>("runNumber", 999999);
55 
56  // histogram booking
57  hbHists.ALLLEDS = new TH1F("HBHE All LEDs", "HB/HE All Leds", 10, 0, 9);
58  hbHists.LEDRMS = new TH1F("HBHE All LED RMS", "HB/HE All LED RMS", 100, 0, 3);
59  hbHists.LEDMEAN = new TH1F("HBHE All LED Means", "HB/HE All LED Means", 100, 0, 9);
60  hbHists.CHI2 = new TH1F("HBHE Chi2 by ndf for Landau fit", "HB/HE Chi2/ndf Landau", 200, 0., 50.);
61 
62  hoHists.ALLLEDS = new TH1F("HO All LEDs", "HO All Leds", 10, 0, 9);
63  hoHists.LEDRMS = new TH1F("HO All LED RMS", "HO All LED RMS", 100, 0, 3);
64  hoHists.LEDMEAN = new TH1F("HO All LED Means", "HO All LED Means", 100, 0, 9);
65  hoHists.CHI2 = new TH1F("HO Chi2 by ndf for Landau fit", "HO Chi2/ndf Landau", 200, 0., 50.);
66 
67  hfHists.ALLLEDS = new TH1F("HF All LEDs", "HF All Leds", 10, 0, 9);
68  hfHists.LEDRMS = new TH1F("HF All LED RMS", "HF All LED RMS", 100, 0, 3);
69  hfHists.LEDMEAN = new TH1F("HF All LED Means", "HF All LED Means", 100, 0, 9);
70  hfHists.CHI2 = new TH1F("HF Chi2 by ndf for Landau fit", "HF Chi2/ndf Landau", 200, 0., 50.);
71 
72  char output[100]{0};
73 
74  //XML file header
75  m_outputFileXML.open(m_outputFileX.c_str());
76 
77  m_outputFileXML << "<?xml version='1.0' encoding='UTF-8'?>" << endl;
78 
79  m_outputFileXML << "<ROOT>" << endl;
80 
81  m_outputFileXML << " <HEADER>" << endl;
82 
83  m_outputFileXML << " <TYPE>" << endl;
84 
85  m_outputFileXML << " <EXTENSION_TABLE_NAME>HCAL_LED_TIMING</EXTENSION_TABLE_NAME>" << endl;
86 
87  m_outputFileXML << " <NAME>HCAL LED Timing</NAME>" << endl;
88 
89  m_outputFileXML << " </TYPE>" << endl;
90 
91  m_outputFileXML << " <RUN>" << endl;
92 
93  m_outputFileXML << " <RUN_TYPE>hcal-led-timing-test</RUN_TYPE>" << endl;
94 
95  snprintf(output, sizeof output, " <RUN_NUMBER>%06i</RUN_NUMBER>", runNum);
96  m_outputFileXML << output << endl;
97 
98  m_outputFileXML << " <RUN_BEGIN_TIMESTAMP>2007-07-09 00:00:00.0</RUN_BEGIN_TIMESTAMP>" << endl;
99 
100  m_outputFileXML << " <COMMENT_DESCRIPTION></COMMENT_DESCRIPTION>" << endl;
101 
102  m_outputFileXML << " </RUN>" << endl;
103 
104  m_outputFileXML << " </HEADER>" << endl;
105 
106  m_outputFileXML << "<!-- Tags secton -->" << endl;
107 
108  m_outputFileXML << " <ELEMENTS>" << endl;
109 
110  m_outputFileXML << " <DATA_SET id='-1'/>" << endl;
111 
112  m_outputFileXML << " <IOV id='1'>" << endl;
113 
114  m_outputFileXML << " <INTERVAL_OF_VALIDITY_BEGIN>2147483647</INTERVAL_OF_VALIDITY_BEGIN>" << endl;
115 
116  m_outputFileXML << " <INTERVAL_OF_VALIDITY_END>0</INTERVAL_OF_VALIDITY_END>" << endl;
117 
118  m_outputFileXML << " </IOV>" << endl;
119 
120  m_outputFileXML << " <TAG id='2' mode='auto'>" << endl;
121 
122  snprintf(output, sizeof output, " <TAG_NAME>laser_led_%06i<TAG_NAME>", runNum);
123  m_outputFileXML << output << endl;
124 
125  m_outputFileXML << " <DETECTOR_NAME>HCAL</DETECTOR_NAME>" << endl;
126 
127  m_outputFileXML << " <COMMENT_DESCRIPTION></COMMENT_DESCRIPTION>" << endl;
128 
129  m_outputFileXML << " </TAG>" << endl;
130 
131  m_outputFileXML << " </ELEMENTS>" << endl;
132 
133  m_outputFileXML << " <MAPS>" << endl;
134 
135  m_outputFileXML << " <TAG idref ='2'>" << endl;
136 
137  m_outputFileXML << " <IOV idref='1'>" << endl;
138 
139  m_outputFileXML << " <DATA_SET idref='-1' />" << endl;
140 
141  m_outputFileXML << " </IOV>" << endl;
142 
143  m_outputFileXML << " </TAG>" << endl;
144 
145  m_outputFileXML << " </MAPS>" << endl;
146 }
struct HcalLedAnalysis::@59 hoHists
std::vector< bool > state
std::ofstream m_logFile
struct HcalLedAnalysis::@59 hbHists
std::string m_outputFileROOT
const HcalPedestal * m_ped
T getUntrackedParameter(std::string const &, T const &) const
std::string m_outputFileX
const HcalQIECoder * m_coder
std::ofstream m_outputFileXML
std::ofstream m_outFile
struct HcalLedAnalysis::@59 hfHists
const HcalQIEShape * m_shape
std::string m_outputFileText

◆ ~HcalLedAnalysis()

HcalLedAnalysis::~HcalLedAnalysis ( )

Destructor.

All done, clean up!!

Definition at line 149 of file HcalLedAnalysis.cc.

References mps_fire::i.

149  {
151  for (_meol = hbHists.LEDTRENDS.begin(); _meol != hbHists.LEDTRENDS.end(); _meol++) {
152  for (int i = 0; i < 15; i++)
153  _meol->second[i].first->Delete();
154  }
155  for (_meol = hoHists.LEDTRENDS.begin(); _meol != hoHists.LEDTRENDS.end(); _meol++) {
156  for (int i = 0; i < 15; i++)
157  _meol->second[i].first->Delete();
158  }
159  for (_meol = hfHists.LEDTRENDS.begin(); _meol != hfHists.LEDTRENDS.end(); _meol++) {
160  for (int i = 0; i < 15; i++)
161  _meol->second[i].first->Delete();
162  }
163  hbHists.ALLLEDS->Delete();
164  hbHists.LEDRMS->Delete();
165  hbHists.LEDMEAN->Delete();
166  hbHists.CHI2->Delete();
167 
168  hoHists.ALLLEDS->Delete();
169  hoHists.LEDRMS->Delete();
170  hoHists.LEDMEAN->Delete();
171  hoHists.CHI2->Delete();
172 
173  hfHists.ALLLEDS->Delete();
174  hfHists.LEDRMS->Delete();
175  hfHists.LEDMEAN->Delete();
176  hfHists.CHI2->Delete();
177 }
struct HcalLedAnalysis::@59 hoHists
struct HcalLedAnalysis::@59 hbHists
std::map< HcalDetId, std::map< int, LEDBUNCH > >::iterator _meol
struct HcalLedAnalysis::@59 hfHists

Member Function Documentation

◆ BinsizeCorr()

float HcalLedAnalysis::BinsizeCorr ( float  time)
private

Definition at line 954 of file HcalLedAnalysis.cc.

References mps_fire::i, createfilelist::int, and hcalRecHitTable_cff::time.

954  {
955  // this is the bin size correction to be applied for laser data (from Andy),
956  // it comes from a pulse shape measured from TB04 data (from Jordan)
957  // This should eventually be replaced with the more thorough treatment from Phil
958 
959  float corrtime = 0.;
960  static const float tstrue[32] = {0.003, 0.03425, 0.06548, 0.09675, 0.128, 0.15925, 0.1905, 0.22175,
961  0.253, 0.28425, 0.3155, 0.34675, 0.378, 0.40925, 0.4405, 0.47175,
962  0.503, 0.53425, 0.5655, 0.59675, 0.628, 0.65925, 0.6905, 0.72175,
963  0.753, 0.78425, 0.8155, 0.84675, 0.878, 0.90925, 0.9405, 0.97175};
964  static const float tsreco[32] = {-0.00422, 0.01815, 0.04409, 0.07346, 0.09799, 0.12192, 0.15072, 0.18158,
965  0.21397, 0.24865, 0.28448, 0.31973, 0.35449, 0.39208, 0.43282, 0.47244,
966  0.5105, 0.55008, 0.58827, 0.62828, 0.6717, 0.70966, 0.74086, 0.77496,
967  0.80843, 0.83472, 0.86044, 0.8843, 0.90674, 0.92982, 0.95072, 0.9726};
968 
969  int inttime = (int)time;
970  float restime = time - inttime;
971  for (int i = 0; i <= 32; i++) {
972  float lolim = 0.;
973  float uplim = 1.;
974  float tsdown;
975  float tsup;
976  if (i > 0) {
977  lolim = tsreco[i - 1];
978  tsdown = tstrue[i - 1];
979  } else
980  tsdown = tstrue[31] - 1.;
981  if (i < 32) {
982  uplim = tsreco[i];
983  tsup = tstrue[i];
984  } else
985  tsup = tstrue[0] + 1.;
986  if (restime >= lolim && restime < uplim) {
987  corrtime = (tsdown * (uplim - restime) + tsup * (restime - lolim)) / (uplim - lolim);
988  }
989  }
990  corrtime += inttime;
991 
992  return corrtime;
993 }

◆ GetLedConst()

void HcalLedAnalysis::GetLedConst ( std::map< HcalDetId, std::map< int, LEDBUNCH > > &  toolT)
private

Definition at line 215 of file HcalLedAnalysis.cc.

References HcalDetId::depth(), mps_fire::i, HcalDetId::ietaAbs(), HcalDetId::iphi(), dqmiolumiharvest::j, convertSQLitetoXML_cfg::output, DetId::rawId(), mathSSE::sqrt(), HcalDetId::subdet(), and HcalDetId::zside().

215  {
216  double time2 = 0;
217  double time1 = 0;
218  double time3 = 0;
219  double time4 = 0;
220  double dtime2 = 0;
221  double dtime1 = 0;
222  double dtime3 = 0;
223  double dtime4 = 0;
224  char output[256]{0};
225 
226  if (!m_outputFileText.empty()) {
227  if (m_fitflag == 0 || m_fitflag == 2)
228  m_outFile << "Det Eta,Phi,D Mean Error" << std::endl;
229  else if (m_fitflag == 1 || m_fitflag == 3)
230  m_outFile << "Det Eta,Phi,D Peak Error" << std::endl;
231  else if (m_fitflag == 4)
232  m_outFile << "Det Eta,Phi,D Mean Error Peak Error MeanEv Error PeakEv Error"
233  << std::endl;
234  }
235  for (_meol = toolT.begin(); _meol != toolT.end(); _meol++) {
236  // scale the LED pulse to 1 event
237  _meol->second[10].first->Scale(1. / evt_curr);
238  if (m_fitflag == 0 || m_fitflag == 4) {
239  time1 = _meol->second[10].first->GetMean();
240  dtime1 = _meol->second[10].first->GetRMS() / sqrt((float)evt_curr * (m_endTS - m_startTS + 1));
241  }
242  if (m_fitflag == 1 || m_fitflag == 4) {
243  // put proper errors
244  for (int j = 0; j < 10; j++)
245  _meol->second[10].first->SetBinError(j + 1, _meol->second[j].first->GetRMS() / sqrt((float)evt_curr));
246  }
247  if (m_fitflag == 1 || m_fitflag == 3 || m_fitflag == 4) {
248  _meol->second[10].first->Fit("landau", "Q");
249  // _meol->second[10].first->Fit("gaus","Q");
250  TF1* fit = _meol->second[10].first->GetFunction("landau");
251  // TF1 *fit = _meol->second[10].first->GetFunction("gaus");
252  time2 = fit->GetParameter(1);
253  dtime2 = fit->GetParError(1);
254  }
255  if (m_fitflag == 2 || m_fitflag == 4) {
256  time3 = _meol->second[12].first->GetMean();
257  dtime3 = _meol->second[12].first->GetRMS() / sqrt((float)_meol->second[12].first->GetEntries());
258  }
259  if (m_fitflag == 3 || m_fitflag == 4) {
260  time4 = _meol->second[13].first->GetMean();
261  dtime4 = _meol->second[13].first->GetRMS() / sqrt((float)_meol->second[13].first->GetEntries());
262  }
263  for (int i = 0; i < 10; i++) {
264  _meol->second[i].first->GetXaxis()->SetTitle("Pulse height (fC)");
265  _meol->second[i].first->GetYaxis()->SetTitle("Counts");
266  // if(m_hiSaveflag>0)_meol->second[i].first->Write();
267  }
268  _meol->second[10].first->GetXaxis()->SetTitle("Time slice");
269  _meol->second[10].first->GetYaxis()->SetTitle("Averaged pulse (fC)");
270  if (m_hiSaveflag > 0)
271  _meol->second[10].first->Write();
272  _meol->second[10].second.first[0].push_back(time1);
273  _meol->second[10].second.first[1].push_back(dtime1);
274  _meol->second[11].second.first[0].push_back(time2);
275  _meol->second[11].second.first[1].push_back(dtime2);
276  _meol->second[12].first->GetXaxis()->SetTitle("Mean TS");
277  _meol->second[12].first->GetYaxis()->SetTitle("Counts");
278  if (m_fitflag == 2 && m_hiSaveflag > 0)
279  _meol->second[12].first->Write();
280  _meol->second[12].second.first[0].push_back(time3);
281  _meol->second[12].second.first[1].push_back(dtime3);
282  _meol->second[13].first->GetXaxis()->SetTitle("Peak TS");
283  _meol->second[13].first->GetYaxis()->SetTitle("Counts");
284  if (m_fitflag > 2 && m_hiSaveflag > 0)
285  _meol->second[13].first->Write();
286  _meol->second[13].second.first[0].push_back(time4);
287  _meol->second[13].second.first[1].push_back(dtime4);
288  _meol->second[14].first->GetXaxis()->SetTitle("Peak TS error");
289  _meol->second[14].first->GetYaxis()->SetTitle("Counts");
290  if (m_fitflag > 2 && m_hiSaveflag > 0)
291  _meol->second[14].first->Write();
292  _meol->second[15].first->GetXaxis()->SetTitle("Chi2/NDF");
293  _meol->second[15].first->GetYaxis()->SetTitle("Counts");
294  if (m_fitflag > 2 && m_hiSaveflag > 0)
295  _meol->second[15].first->Write();
296  _meol->second[16].first->GetXaxis()->SetTitle("Integrated Signal");
297  _meol->second[16].first->Write();
298 
299  // Ascii printout (need to modify to include new info)
300  HcalDetId detid = _meol->first;
301 
302  if (!m_outputFileText.empty()) {
303  if (m_fitflag == 0) {
304  m_outFile << detid << " " << time1 << " " << dtime1 << std::endl;
305  m_outputFileXML << " <DATA_SET>" << endl;
306  m_outputFileXML << " <VERSION>version:1</VERSION>" << endl;
307  m_outputFileXML << " <CHANNEL>" << endl;
308  m_outputFileXML << " <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>" << endl;
309  snprintf(output, sizeof output, " <ETA>%2i</ETA>", detid.ietaAbs());
310  m_outputFileXML << output << endl;
311  snprintf(output, sizeof output, " <PHI>%2i</PHI>", detid.iphi());
312  m_outputFileXML << output << endl;
313  snprintf(output, sizeof output, " <DEPTH>%2i</DEPTH>", detid.depth());
314  m_outputFileXML << output << endl;
315  snprintf(output, sizeof output, " <Z>%2i</Z>", detid.zside());
316  m_outputFileXML << output << endl;
317 
318  if (detid.subdet() == 1)
319  m_outputFileXML << " <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
320  if (detid.subdet() == 2)
321  m_outputFileXML << " <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
322  if (detid.subdet() == 3)
323  m_outputFileXML << " <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
324  if (detid.subdet() == 4)
325  m_outputFileXML << " <DETECTOR_NAME>HF</DETECTOR_NAME>" << endl;
326  snprintf(output, sizeof output, " <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.rawId());
327  m_outputFileXML << output << endl;
328  m_outputFileXML << " </CHANNEL>" << endl;
329  m_outputFileXML << " <DATA>" << endl;
330  snprintf(output, sizeof output, " <MEAN_TIME>%7f</MEAN_TIME>", time1);
331  m_outputFileXML << output << endl;
332  m_outputFileXML << " <OFFSET_TIME> 0</OFFSET_TIME>" << endl;
333  snprintf(output, sizeof output, " <ERROR_STAT>%7f</ERROR_STAT>", dtime1);
334  m_outputFileXML << output << endl;
335  snprintf(output, sizeof output, " <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag + 1);
336  m_outputFileXML << output << endl;
337  m_outputFileXML << " <STATUS_WORD> 0</STATUS_WORD>" << endl;
338  m_outputFileXML << " </DATA>" << endl;
339  m_outputFileXML << " </DATA_SET>" << endl;
340 
341  } else if (m_fitflag == 1) {
342  m_outFile << detid << " " << time2 << " " << dtime2 << std::endl;
343  m_outputFileXML << " <DATA_SET>" << endl;
344  m_outputFileXML << " <VERSION>version:1</VERSION>" << endl;
345  m_outputFileXML << " <CHANNEL>" << endl;
346  m_outputFileXML << " <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>" << endl;
347  snprintf(output, sizeof output, " <ETA>%2i</ETA>", detid.ietaAbs());
348  m_outputFileXML << output << endl;
349  snprintf(output, sizeof output, " <PHI>%2i</PHI>", detid.iphi());
350  m_outputFileXML << output << endl;
351  snprintf(output, sizeof output, " <DEPTH>%2i</DEPTH>", detid.depth());
352  m_outputFileXML << output << endl;
353  snprintf(output, sizeof output, " <Z>%2i</Z>", detid.zside());
354  m_outputFileXML << output << endl;
355  if (detid.subdet() == 1)
356  m_outputFileXML << " <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
357  if (detid.subdet() == 2)
358  m_outputFileXML << " <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
359  if (detid.subdet() == 3)
360  m_outputFileXML << " <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
361  if (detid.subdet() == 4)
362  m_outputFileXML << " <DETECTOR_NAME>HF</DETECTOR_NAME>" << endl;
363  snprintf(output, sizeof output, " <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.rawId());
364  m_outputFileXML << output << endl;
365  m_outputFileXML << " </CHANNEL>" << endl;
366  m_outputFileXML << " <DATA>" << endl;
367  snprintf(output, sizeof output, " <MEAN_TIME>%7f</MEAN_TIME>", time2);
368  m_outputFileXML << output << endl;
369  m_outputFileXML << " <OFFSET_TIME> 0</OFFSET_TIME>" << endl;
370  snprintf(output, sizeof output, " <ERROR_STAT>%7f</ERROR_STAT>", dtime2);
371  m_outputFileXML << output << endl;
372  snprintf(output, sizeof output, " <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag + 1);
373  m_outputFileXML << output << endl;
374  m_outputFileXML << " <STATUS_WORD> 0</STATUS_WORD>" << endl;
375  m_outputFileXML << " </DATA>" << endl;
376  m_outputFileXML << " </DATA_SET>" << endl;
377  }
378 
379  else if (m_fitflag == 2) {
380  m_outFile << detid << " " << time3 << " " << dtime3 << std::endl;
381  m_outputFileXML << " <DATA_SET>" << endl;
382  m_outputFileXML << " <VERSION>version:1</VERSION>" << endl;
383  m_outputFileXML << " <CHANNEL>" << endl;
384  m_outputFileXML << " <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>" << endl;
385  snprintf(output, sizeof output, " <ETA>%2i</ETA>", detid.ietaAbs());
386  m_outputFileXML << output << endl;
387  snprintf(output, sizeof output, " <PHI>%2i</PHI>", detid.iphi());
388  m_outputFileXML << output << endl;
389  snprintf(output, sizeof output, " <DEPTH>%2i</DEPTH>", detid.depth());
390  m_outputFileXML << output << endl;
391  snprintf(output, sizeof output, " <Z>%2i</Z>", detid.zside());
392  m_outputFileXML << output << endl;
393  if (detid.subdet() == 1)
394  m_outputFileXML << " <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
395  if (detid.subdet() == 2)
396  m_outputFileXML << " <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
397  if (detid.subdet() == 3)
398  m_outputFileXML << " <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
399  if (detid.subdet() == 4)
400  m_outputFileXML << " <DETECTOR_NAME>HF</DETECTOR_NAME>" << endl;
401  snprintf(output, sizeof output, " <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.rawId());
402  m_outputFileXML << output << endl;
403  m_outputFileXML << " </CHANNEL>" << endl;
404  m_outputFileXML << " <DATA>" << endl;
405  snprintf(output, sizeof output, " <MEAN_TIME>%7f</MEAN_TIME>", time3);
406  m_outputFileXML << output << endl;
407  m_outputFileXML << " <OFFSET_TIME> 0</OFFSET_TIME>" << endl;
408  snprintf(output, sizeof output, " <ERROR_STAT>%7f</ERROR_STAT>", dtime3);
409  m_outputFileXML << output << endl;
410  snprintf(output, sizeof output, " <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag + 1);
411  m_outputFileXML << output << endl;
412  m_outputFileXML << " <STATUS_WORD> 0</STATUS_WORD>" << endl;
413  m_outputFileXML << " </DATA>" << endl;
414  m_outputFileXML << " </DATA_SET>" << endl;
415  } else if (m_fitflag == 3) {
416  m_outFile << detid << " " << time4 << " " << dtime4 << std::endl;
417  m_outputFileXML << " <DATA_SET>" << endl;
418  m_outputFileXML << " <VERSION>version:1</VERSION>" << endl;
419  m_outputFileXML << " <CHANNEL>" << endl;
420  m_outputFileXML << " <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>" << endl;
421  snprintf(output, sizeof output, " <ETA>%2i</ETA>", detid.ietaAbs());
422  m_outputFileXML << output << endl;
423  snprintf(output, sizeof output, " <PHI>%2i</PHI>", detid.iphi());
424  m_outputFileXML << output << endl;
425  snprintf(output, sizeof output, " <DEPTH>%2i</DEPTH>", detid.depth());
426  m_outputFileXML << output << endl;
427  sprintf(output, " <Z>%2i</Z>", detid.zside());
428  m_outputFileXML << output << endl;
429  if (detid.subdet() == 1)
430  m_outputFileXML << " <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
431  if (detid.subdet() == 2)
432  m_outputFileXML << " <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
433  if (detid.subdet() == 3)
434  m_outputFileXML << " <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
435  if (detid.subdet() == 4)
436  m_outputFileXML << " <DETECTOR_NAME>HF</DETECTOR_NAME>" << endl;
437  snprintf(output, sizeof output, " <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.rawId());
438  m_outputFileXML << output << endl;
439  m_outputFileXML << " </CHANNEL>" << endl;
440  m_outputFileXML << " <DATA>" << endl;
441  snprintf(output, sizeof output, " <MEAN_TIME>%7f</MEAN_TIME>", time4);
442  m_outputFileXML << output << endl;
443  m_outputFileXML << " <OFFSET_TIME> 0</OFFSET_TIME>" << endl;
444  snprintf(output, sizeof output, " <ERROR_STAT>%7f</ERROR_STAT>", dtime4);
445  m_outputFileXML << output << endl;
446  snprintf(output, sizeof output, " <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag + 1);
447  m_outputFileXML << output << endl;
448  m_outputFileXML << " <STATUS_WORD> 0</STATUS_WORD>" << endl;
449  m_outputFileXML << " </DATA>" << endl;
450  m_outputFileXML << " </DATA_SET>" << endl;
451  }
452 
453  else if (m_fitflag == 4) {
454  m_outFile << detid << " " << time1 << " " << dtime1 << " " << time2 << " " << dtime2 << " " << time3
455  << " " << dtime3 << " " << time4 << " " << dtime4 << std::endl;
456  }
457  }
458  }
459 }
constexpr int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:141
constexpr int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:148
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
T sqrt(T t)
Definition: SSEVec.h:19
std::map< HcalDetId, std::map< int, LEDBUNCH > >::iterator _meol
std::ofstream m_outputFileXML
std::ofstream m_outFile
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
std::string m_outputFileText
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164

◆ LedDone()

void HcalLedAnalysis::LedDone ( )

Definition at line 510 of file HcalLedAnalysis.cc.

References gather_cfg::cout, and ecalGpuTask_cfi::sample.

510  {
511  // First process the last sample (remaining events).
512  if (evt % m_nevtsample != 0)
514 
515  // Now do the end of run analysis: trending histos
516  if (sample > 1 && m_fitflag != 4) {
517  m_file->cd();
518  m_file->cd("HBHE");
519  LedTrendings(hbHists.LEDTRENDS);
520  m_file->cd();
521  m_file->cd("HO");
522  LedTrendings(hoHists.LEDTRENDS);
523  m_file->cd();
524  m_file->cd("HF");
525  LedTrendings(hfHists.LEDTRENDS);
526  }
527 
528  // Write other histograms.
529  // HB
530  m_file->cd();
531  m_file->cd("HBHE");
532  hbHists.ALLLEDS->Write();
533  hbHists.LEDRMS->Write();
534  hbHists.LEDMEAN->Write();
535  // HO
536  m_file->cd();
537  m_file->cd("HO");
538  hoHists.ALLLEDS->Write();
539  hoHists.LEDRMS->Write();
540  hoHists.LEDMEAN->Write();
541  // HF
542  m_file->cd();
543  m_file->cd("HF");
544  hfHists.ALLLEDS->Write();
545  hfHists.LEDRMS->Write();
546  hfHists.LEDMEAN->Write();
547  // Calib
548  m_file->cd();
549  m_file->cd("Calib");
550  for (_meca = calibHists.begin(); _meca != calibHists.end(); _meca++) {
551  _meca->second.avePulse->Write();
552  _meca->second.integPulse->Write();
553  }
554 
555  // Write the histo file and close it
556  // m_file->Write();
557  m_file->Close();
558  cout << "Hcal histograms written to " << m_outputFileROOT.c_str() << endl;
559 }
struct HcalLedAnalysis::@59 hoHists
std::map< HcalCalibDetId, CALIBBUNCH > calibHists
struct HcalLedAnalysis::@59 hbHists
std::string m_outputFileROOT
struct HcalLedAnalysis::@59 hfHists
std::map< HcalCalibDetId, CALIBBUNCH >::iterator _meca
void LedTrendings(std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)

◆ LedHBHEHists()

void HcalLedAnalysis::LedHBHEHists ( const HcalDetId detid,
const HBHEDataFrame ledDigi,
std::map< HcalDetId, std::map< int, LEDBUNCH > > &  toolT,
const HcalDbService cond 
)
private

Definition at line 734 of file HcalLedAnalysis.cc.

References gpuClustering::adc, dqmdumpme::first, mps_fire::i, createfilelist::int, dqmdumpme::k, and HBHEDataFrame::size().

737  {
738  map<int, LEDBUNCH> _mei;
739  _meol = toolT.find(detid);
740  _mei = _meol->second;
741 
742  // Reset the histos if we're at the end of a 'bunch'
743  if ((evt - 1) % m_nevtsample == 0 && state[0]) {
744  for (int k = 0; k < (int)state.size(); k++)
745  state[k] = false;
746  for (int i = 0; i < 16; i++)
747  _mei[i].first->Reset();
748  }
749 
750  // Most of this is borrowed from HcalSimpleReconstructor, so thanks Jeremy/Phil
751 
752  // int maxTS = -1;
753  float max_fC = 0;
754  float ta = 0;
755  m_coder = cond.getHcalCoder(detid);
756  m_ped = cond.getPedestal(detid);
757  m_shape = cond.getHcalShape(m_coder);
758  for (int TS = m_startTS; TS < m_endTS && TS < ledDigi.size(); TS++) {
759  int capid = ledDigi[TS].capid();
760  int adc = ledDigi[TS].adc();
761  double fC = m_coder->charge(*m_shape, adc, capid);
762  ta = (fC - m_ped->getValue(capid));
763  //cout << "DetID: " << detid << " CapID: " << capid << " ADC: " << adc << " fC: " << fC << endl;
764  _mei[TS].first->Fill(ta);
765  _mei[10].first->AddBinContent(TS + 1, ta); // This is average pulse, could probably do better (Profile?)
766  if (m_fitflag > 1) {
767  if (TS == m_startTS)
768  _mei[11].first->Reset();
769  _mei[11].first->SetBinContent(TS + 1, ta);
770  }
771  // keep track of max TS and max amplitude (in fC)
772  if (ta > max_fC) {
773  max_fC = ta;
774  // maxTS = TS;
775  }
776  }
777 
778  // Now we have a sample with pedestals subtracted and in units of fC
779  // If we are using a weighted mean (m_fitflag = 2) to extraxt timing
780  // we now want to use Phil's timing correction. This is not necessary
781  // if we are performing a Landau fit (m_fitflag = 3)
782 
783  float sum = 0.;
784  for (int i = 0; i < 10; i++)
785  sum = sum + _mei[11].first->GetBinContent(i + 1);
786  if (sum > 100) {
787  if (m_fitflag == 2 || m_fitflag == 4) {
788  float timmean = _mei[11].first->GetMean(); // let's use Phil's way instead
789  float timmeancorr = BinsizeCorr(timmean);
790  _mei[12].first->Fill(timmeancorr);
791  }
792  _mei[16].first->Fill(
793  _mei[11].first->Integral()); // Integrated charge (may be more usfull to convert to Energy first?)
794  if (m_fitflag == 3 || m_fitflag == 4) {
795  _mei[11].first->Fit("landau", "Q");
796  TF1* fit = _mei[11].first->GetFunction("landau");
797  _mei[13].first->Fill(fit->GetParameter(1));
798  _mei[14].first->Fill(fit->GetParError(1));
799  _mei[15].first->Fill(fit->GetChisquare() / fit->GetNDF());
800  }
801  }
802 }
std::vector< bool > state
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalPedestal.h:20
const HcalPedestal * m_ped
const HcalQIECoder * m_coder
std::map< HcalDetId, std::map< int, LEDBUNCH > >::iterator _meol
float BinsizeCorr(float time)
const HcalQIEShape * m_shape
Definition: plugin.cc:23
constexpr int size() const
total number of samples in the digi
Definition: HBHEDataFrame.h:27
float charge(const HcalQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -> fC conversion.
Definition: HcalQIECoder.cc:20
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ LedHFHists()

void HcalLedAnalysis::LedHFHists ( const HcalDetId detid,
const HFDataFrame ledDigi,
std::map< HcalDetId, std::map< int, LEDBUNCH > > &  toolT,
const HcalDbService cond 
)
private

Definition at line 875 of file HcalLedAnalysis.cc.

References gpuClustering::adc, dqmdumpme::first, mps_fire::i, createfilelist::int, dqmdumpme::k, and HFDataFrame::size().

878  {
879  map<int, LEDBUNCH> _mei;
880  _meol = toolT.find(detid);
881  _mei = _meol->second;
882  // Rest the histos if we're at the end of a 'bunch'
883  if ((evt - 1) % m_nevtsample == 0 && state[0]) {
884  for (int k = 0; k < (int)state.size(); k++)
885  state[k] = false;
886  for (int i = 0; i < 16; i++)
887  _mei[i].first->Reset();
888  }
889 
890  // now we have the signal in fC, let's get rid of that darn pedestal
891  // Most of this is borrowed from HcalSimpleReconstructor, so thanks Jeremy/Phil
892 
893  // int maxTS = -1;
894  float max_fC = 0;
895  float ta = 0;
896  m_coder = cond.getHcalCoder(detid);
897  m_ped = cond.getPedestal(detid);
898  m_shape = cond.getHcalShape(m_coder);
899  //cout << "New Digi!!!!!!!!!!!!!!!!!!!!!!" << endl;
900  for (int TS = m_startTS; TS < m_endTS && TS < ledDigi.size(); TS++) {
901  int capid = ledDigi[TS].capid();
902  // BE CAREFUL: this is assuming peds are stored in ADCs
903  int adc = (int)(ledDigi[TS].adc() - m_ped->getValue(capid));
904  if (adc < 0) {
905  adc = 0;
906  } // to prevent negative adcs after ped subtraction, which should really only happen
907  // if you're using the wrong peds.
908  double fC = m_coder->charge(*m_shape, adc, capid);
909  //ta = (fC - m_ped->getValue(capid));
910  ta = fC;
911  //cout << "DetID: " << detid << " CapID: " << capid << " ADC: " << adc << " Ped: " << m_ped->getValue(capid) << " fC: " << fC << endl;
912  _mei[TS].first->Fill(ta);
913  _mei[10].first->AddBinContent(TS + 1, ta); // This is average pulse, could probably do better (Profile?)
914  if (m_fitflag > 1) {
915  if (TS == m_startTS)
916  _mei[11].first->Reset();
917  _mei[11].first->SetBinContent(TS + 1, ta);
918  }
919 
920  // keep track of max TS and max amplitude (in fC)
921  if (ta > max_fC) {
922  max_fC = ta;
923  // maxTS = TS;
924  }
925  }
926 
927  // Now we have a sample with pedestals subtracted and in units of fC
928  // If we are using a weighted mean (m_fitflag = 2) to extraxt timing
929  // we now want to use Phil's timing correction. This is not necessary
930  // if we are performing a Landau fit (m_fitflag = 3)
931 
932  float sum = 0.;
933  for (int i = 0; i < 10; i++)
934  sum = sum + _mei[11].first->GetBinContent(i + 1);
935  if (sum > 100) {
936  if (m_fitflag == 2 || m_fitflag == 4) {
937  float timmean = _mei[11].first->GetMean(); // let's use Phil's way instead
938  float timmeancorr = BinsizeCorr(timmean);
939  _mei[12].first->Fill(timmeancorr);
940  }
941  _mei[16].first->Fill(
942  _mei[11].first->Integral()); // Integrated charge (may be more usfull to convert to Energy first?)
943  if (m_fitflag == 3 || m_fitflag == 4) {
944  _mei[11].first->Fit("landau", "Q");
945  TF1* fit = _mei[11].first->GetFunction("landau");
946  _mei[13].first->Fill(fit->GetParameter(1));
947  _mei[14].first->Fill(fit->GetParError(1));
948  _mei[15].first->Fill(fit->GetChisquare() / fit->GetNDF());
949  }
950  }
951 }
std::vector< bool > state
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalPedestal.h:20
const HcalPedestal * m_ped
const HcalQIECoder * m_coder
std::map< HcalDetId, std::map< int, LEDBUNCH > >::iterator _meol
constexpr int size() const
total number of samples in the digi
Definition: HFDataFrame.h:27
float BinsizeCorr(float time)
const HcalQIEShape * m_shape
Definition: plugin.cc:23
float charge(const HcalQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -> fC conversion.
Definition: HcalQIECoder.cc:20
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ LedHOHists()

void HcalLedAnalysis::LedHOHists ( const HcalDetId detid,
const HODataFrame ledDigi,
std::map< HcalDetId, std::map< int, LEDBUNCH > > &  toolT,
const HcalDbService cond 
)
private

Definition at line 805 of file HcalLedAnalysis.cc.

References gpuClustering::adc, dqmdumpme::first, mps_fire::i, createfilelist::int, dqmdumpme::k, and HODataFrame::size().

808  {
809  map<int, LEDBUNCH> _mei;
810  _meol = toolT.find(detid);
811  _mei = _meol->second;
812  // Rest the histos if we're at the end of a 'bunch'
813  if ((evt - 1) % m_nevtsample == 0 && state[0]) {
814  for (int k = 0; k < (int)state.size(); k++)
815  state[k] = false;
816  for (int i = 0; i < 16; i++)
817  _mei[i].first->Reset();
818  }
819 
820  // now we have the signal in fC, let's get rid of that darn pedestal
821  // Most of this is borrowed from HcalSimpleReconstructor, so thanks Jeremy/Phil
822 
823  // int maxTS = -1;
824  float max_fC = 0;
825  float ta = 0;
826  m_coder = cond.getHcalCoder(detid);
827  m_ped = cond.getPedestal(detid);
828  m_shape = cond.getHcalShape(m_coder);
829  for (int TS = m_startTS; TS < m_endTS && TS < ledDigi.size(); TS++) {
830  int capid = ledDigi[TS].capid();
831  int adc = ledDigi[TS].adc();
832  double fC = m_coder->charge(*m_shape, adc, capid);
833  ta = (fC - m_ped->getValue(capid));
834  _mei[TS].first->Fill(ta);
835  _mei[10].first->AddBinContent(TS + 1, ta); // This is average pulse, could probably do better (Profile?)
836  if (m_fitflag > 1) {
837  if (TS == m_startTS)
838  _mei[11].first->Reset();
839  _mei[11].first->SetBinContent(TS + 1, ta);
840  }
841  // keep track of max TS and max amplitude (in fC)
842  if (ta > max_fC) {
843  max_fC = ta;
844  // maxTS = TS;
845  }
846  }
847 
848  // Now we have a sample with pedestals subtracted and in units of fC
849  // If we are using a weighted mean (m_fitflag = 2) to extraxt timing
850  // we now want to use Phil's timing correction. This is not necessary
851  // if we are performing a Landau fit (m_fitflag = 3)
852 
853  float sum = 0.;
854  for (int i = 0; i < 10; i++)
855  sum = sum + _mei[11].first->GetBinContent(i + 1);
856  if (sum > 100) {
857  if (m_fitflag == 2 || m_fitflag == 4) {
858  float timmean = _mei[11].first->GetMean(); // let's use Phil's way instead
859  float timmeancorr = BinsizeCorr(timmean);
860  _mei[12].first->Fill(timmeancorr);
861  }
862  _mei[16].first->Fill(
863  _mei[11].first->Integral()); // Integrated charge (may be more usfull to convert to Energy first?)
864  if (m_fitflag == 3 || m_fitflag == 4) {
865  _mei[11].first->Fit("landau", "Q");
866  TF1* fit = _mei[11].first->GetFunction("landau");
867  _mei[13].first->Fill(fit->GetParameter(1));
868  _mei[14].first->Fill(fit->GetParError(1));
869  _mei[15].first->Fill(fit->GetChisquare() / fit->GetNDF());
870  }
871  }
872 }
std::vector< bool > state
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalPedestal.h:20
const HcalPedestal * m_ped
const HcalQIECoder * m_coder
std::map< HcalDetId, std::map< int, LEDBUNCH > >::iterator _meol
float BinsizeCorr(float time)
const HcalQIEShape * m_shape
constexpr int size() const
total number of samples in the digi
Definition: HODataFrame.h:27
Definition: plugin.cc:23
float charge(const HcalQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -> fC conversion.
Definition: HcalQIECoder.cc:20
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ LedSampleAnalysis()

void HcalLedAnalysis::LedSampleAnalysis ( )

Definition at line 462 of file HcalLedAnalysis.cc.

References ecalGpuTask_cfi::sample.

462  {
463  // it is called every m_nevtsample events (a sample) and the end of run
464  char LedSampleNum[20];
465 
466  snprintf(LedSampleNum, sizeof LedSampleNum, "LedSample_%d", sample);
467  m_file->cd();
468  m_file->mkdir(LedSampleNum);
469  m_file->cd(LedSampleNum);
470 
471  // Compute LED constants for each HB/HE, HO, HF
472  GetLedConst(hbHists.LEDTRENDS);
473  GetLedConst(hoHists.LEDTRENDS);
474  GetLedConst(hfHists.LEDTRENDS);
475 }
struct HcalLedAnalysis::@59 hoHists
struct HcalLedAnalysis::@59 hbHists
void GetLedConst(std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
struct HcalLedAnalysis::@59 hfHists

◆ LedSetup()

void HcalLedAnalysis::LedSetup ( const std::string &  m_outputFileROOT)

Definition at line 180 of file HcalLedAnalysis.cc.

180  {
181  // open the histogram file, create directories within
182  m_file = new TFile(m_outputFileROOT.c_str(), "RECREATE");
183  m_file->mkdir("HBHE");
184  m_file->cd();
185  m_file->mkdir("HO");
186  m_file->cd();
187  m_file->mkdir("HF");
188  m_file->cd();
189  m_file->mkdir("Calib");
190  m_file->cd();
191 }
std::string m_outputFileROOT

◆ LedTrendings()

void HcalLedAnalysis::LedTrendings ( std::map< HcalDetId, std::map< int, LEDBUNCH > > &  toolT)
private

Definition at line 478 of file HcalLedAnalysis.cc.

References trigObjTnPSource_cfi::bins, HcalDetId::depth(), nano_mu_digi_cff::float, HcalDetId::ieta(), HcalDetId::iphi(), dqmiolumiharvest::j, and Skims_PA_cff::name.

478  {
479  for (_meol = toolT.begin(); _meol != toolT.end(); _meol++) {
480  char name[1024];
481  HcalDetId detid = _meol->first;
482  snprintf(name, sizeof name, "LED timing trend, eta=%d phi=%d depth=%d", detid.ieta(), detid.iphi(), detid.depth());
483  int bins = _meol->second[10 + m_fitflag].second.first[0].size();
484  float lo = 0.5;
485  float hi = (float)bins + 0.5;
486  _meol->second[10 + m_fitflag].second.second.push_back(new TH1F(name, name, bins, lo, hi));
487 
488  std::vector<double>::iterator sample_it;
489  // LED timing - put content and errors
490  int j = 0;
491  for (sample_it = _meol->second[10 + m_fitflag].second.first[0].begin();
492  sample_it != _meol->second[10 + m_fitflag].second.first[0].end();
493  ++sample_it) {
494  _meol->second[10 + m_fitflag].second.second[0]->SetBinContent(++j, *sample_it);
495  }
496  j = 0;
497  for (sample_it = _meol->second[10 + m_fitflag].second.first[1].begin();
498  sample_it != _meol->second[10 + m_fitflag].second.first[1].end();
499  ++sample_it) {
500  _meol->second[10 + m_fitflag].second.second[0]->SetBinError(++j, *sample_it);
501  }
502  snprintf(name, sizeof name, "Sample (%d events)", m_nevtsample);
503  _meol->second[10 + m_fitflag].second.second[0]->GetXaxis()->SetTitle(name);
504  _meol->second[10 + m_fitflag].second.second[0]->GetYaxis()->SetTitle("Peak position");
505  _meol->second[10 + m_fitflag].second.second[0]->Write();
506  }
507 }
Definition: EPCuts.h:4
constexpr int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
std::map< HcalDetId, std::map< int, LEDBUNCH > >::iterator _meol
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164

◆ ProcessCalibEvent()

void HcalLedAnalysis::ProcessCalibEvent ( int  fiberChan,
HcalCalibDetId  calibId,
const HcalCalibDataFrame digi 
)
private

Definition at line 999 of file HcalLedAnalysis.cc.

References HcalQIESample::adc(), HcalCalibDetId::calibFlavor(), HcalCalibDetId::CalibrationBox, HcalCalibDetId::cboxChannelString(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, HcalCalibDetId::hcalSubdet(), mps_fire::i, HcalCalibDetId::ieta(), HcalCalibDetId::iphi(), Skims_PA_cff::name, hcallasereventfilter2012_cfi::prefix, HcalCalibDataFrame::sample(), nano_mu_digi_cff::sector, HcalCalibDataFrame::size(), and AlCaHLTBitMon_QueryRunRegistry::string.

999  {
1000  _meca = calibHists.find(calibId);
1001  if (_meca == calibHists.end()) {
1002  // if histos for this channel do not exist, first create them
1003  char name[1024];
1005  if (calibId.calibFlavor() == HcalCalibDetId::CalibrationBox) {
1006  std::string sector = (calibId.hcalSubdet() == HcalBarrel) ? ("HB")
1007  : (calibId.hcalSubdet() == HcalEndcap) ? ("HE")
1008  : (calibId.hcalSubdet() == HcalOuter) ? ("HO")
1009  : (calibId.hcalSubdet() == HcalForward) ? ("HF")
1010  : "";
1011  snprintf(name,
1012  sizeof name,
1013  "%s %+d iphi=%d %s",
1014  sector.c_str(),
1015  calibId.ieta(),
1016  calibId.iphi(),
1017  calibId.cboxChannelString().c_str());
1018  prefix = name;
1019  }
1020 
1021  snprintf(name, sizeof name, "%s Pin Diode Mean", prefix.c_str());
1022  calibHists[calibId].avePulse = new TProfile(name, name, 10, -0.5, 9.5, 0, 1000);
1023  snprintf(name, sizeof name, "%s Pin Diode Current Pulse", prefix.c_str());
1024  calibHists[calibId].thisPulse = new TH1F(name, name, 10, -0.5, 9.5);
1025  snprintf(name, sizeof name, "%s Pin Diode Integrated Pulse", prefix.c_str());
1026  calibHists[calibId].integPulse = new TH1F(name, name, 200, 0, 500);
1027  } else {
1028  for (int i = m_startTS; i < digi.size() && i <= m_endTS; i++) {
1029  calibHists[calibId].avePulse->Fill(i, digi.sample(i).adc());
1030  calibHists[calibId].thisPulse->SetBinContent(i + 1, digi.sample(i).adc());
1031  }
1032  calibHists[calibId].integPulse->Fill(calibHists[calibId].thisPulse->Integral());
1033  }
1034 }
std::string cboxChannelString() const
get the calibration box channel as a string (if relevant)
std::map< HcalCalibDetId, CALIBBUNCH > calibHists
int size() const
total number of samples in the digi
int ieta() const
HcalSubdetector hcalSubdet() const
get the HcalSubdetector (if relevant)
const HcalQIESample & sample(int i) const
access a sample
int iphi() const
get the low-edge iphi (if relevant)
CalibDetType calibFlavor() const
get the flavor of this calibration detid
std::map< HcalCalibDetId, CALIBBUNCH >::iterator _meca
constexpr int adc() const
get the ADC sample
Definition: HcalQIESample.h:43

◆ processLedEvent()

void HcalLedAnalysis::processLedEvent ( const HBHEDigiCollection hbhe,
const HODigiCollection ho,
const HFDigiCollection hf,
const HcalCalibDigiCollection calib,
const HcalDbService cond 
)

Definition at line 562 of file HcalLedAnalysis.cc.

References HcalCalibDataFrame::elecId(), HcalElectronicsId::fiberChanId(), photonIsolationHIProducer_cfi::hbhe, photonIsolationHIProducer_cfi::hf, photonIsolationHIProducer_cfi::ho, mps_fire::i, HcalCalibDataFrame::id(), HFDataFrame::id(), HBHEDataFrame::id(), HODataFrame::id(), createfilelist::int, dqmiolumiharvest::j, dqmdumpme::k, and ecalGpuTask_cfi::sample.

566  {
567  evt++;
568  sample = (evt - 1) / m_nevtsample + 1;
570  if (evt_curr == 0)
572 
573  // Calib
574 
575  if (m_usecalib) {
576  try {
577  if (calib.empty())
578  throw (int)calib.size();
579  // this is effectively a loop over electronic channels
580  for (HcalCalibDigiCollection::const_iterator j = calib.begin(); j != calib.end(); ++j) {
581  const HcalCalibDataFrame digi = (const HcalCalibDataFrame)(*j);
582  HcalElectronicsId elecId = digi.elecId();
583  HcalCalibDetId calibId = digi.id();
585  calibId,
586  digi); //Shouldn't depend on anything in elecId but not sure how else to do it
587  }
588  } catch (int i) {
589  // m_logFile<< "Event with " << i<<" Calib Digis passed." << std::endl;
590  }
591  }
592 
593  // HB + HE
594  try {
595  if (hbhe.empty())
596  throw (int)hbhe.size();
597  // this is effectively a loop over electronic channels
598  for (HBHEDigiCollection::const_iterator j = hbhe.begin(); j != hbhe.end(); ++j) {
599  const HBHEDataFrame digi = (const HBHEDataFrame)(*j);
600  for (int k = 0; k < (int)state.size(); k++)
601  state[k] = true;
602  // See if histos exist for this channel, and if not, create them
603  _meol = hbHists.LEDTRENDS.find(digi.id());
604  if (_meol == hbHists.LEDTRENDS.end()) {
605  SetupLEDHists(0, digi.id(), hbHists.LEDTRENDS);
606  }
607  LedHBHEHists(digi.id(), digi, hbHists.LEDTRENDS, cond);
608  }
609  } catch (int i) {
610  // m_logFile<< "Event with " << i<<" HBHE Digis passed." << std::endl;
611  }
612 
613  // HO
614  try {
615  if (ho.empty())
616  throw (int)ho.size();
617  for (HODigiCollection::const_iterator j = ho.begin(); j != ho.end(); ++j) {
618  const HODataFrame digi = (const HODataFrame)(*j);
619  _meol = hoHists.LEDTRENDS.find(digi.id());
620  if (_meol == hoHists.LEDTRENDS.end()) {
621  SetupLEDHists(1, digi.id(), hoHists.LEDTRENDS);
622  }
623  LedHOHists(digi.id(), digi, hoHists.LEDTRENDS, cond);
624  }
625  } catch (int i) {
626  // m_logFile << "Event with " << i<<" HO Digis passed." << std::endl;
627  }
628 
629  // HF
630  try {
631  if (hf.empty())
632  throw (int)hf.size();
633  for (HFDigiCollection::const_iterator j = hf.begin(); j != hf.end(); ++j) {
634  const HFDataFrame digi = (const HFDataFrame)(*j);
635  _meol = hfHists.LEDTRENDS.find(digi.id());
636  if (_meol == hfHists.LEDTRENDS.end()) {
637  SetupLEDHists(2, digi.id(), hfHists.LEDTRENDS);
638  }
639  LedHFHists(digi.id(), digi, hfHists.LEDTRENDS, cond);
640  }
641  } catch (int i) {
642  // m_logFile << "Event with " << i<<" HF Digis passed." << std::endl;
643  }
644 
645  // Call the function every m_nevtsample events
646  if (evt % m_nevtsample == 0)
648 }
constexpr HcalDetId const & id() const
Definition: HFDataFrame.h:23
struct HcalLedAnalysis::@59 hoHists
void LedHBHEHists(const HcalDetId &detid, const HBHEDataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
std::vector< bool > state
std::vector< T >::const_iterator const_iterator
struct HcalLedAnalysis::@59 hbHists
const HcalElectronicsId & elecId() const
void SetupLEDHists(int id, const HcalDetId detid, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
const HcalCalibDetId & id() const
void ProcessCalibEvent(int fiberChan, HcalCalibDetId calibId, const HcalCalibDataFrame &digi)
std::map< HcalDetId, std::map< int, LEDBUNCH > >::iterator _meol
constexpr const HcalDetId & id() const
Definition: HBHEDataFrame.h:23
struct HcalLedAnalysis::@59 hfHists
void LedHFHists(const HcalDetId &detid, const HFDataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
constexpr int fiberChanId() const
get the fiber channel id (which of channels on a fiber)
Definition: plugin.cc:23
void LedHOHists(const HcalDetId &detid, const HODataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
Readout chain identification for Hcal.
constexpr HcalDetId const & id() const
Definition: HODataFrame.h:23

◆ SetupLEDHists()

void HcalLedAnalysis::SetupLEDHists ( int  id,
const HcalDetId  detid,
std::map< HcalDetId, std::map< int, LEDBUNCH > > &  toolT 
)
private

Definition at line 650 of file HcalLedAnalysis.cc.

References HcalDetId::depth(), mps_fire::i, HcalDetId::ieta(), edm::eventsetup::heterocontainer::insert(), HcalDetId::iphi(), and Skims_PA_cff::name.

650  {
651  string type = "HBHE";
652  if (id == 1)
653  type = "HO";
654  if (id == 2)
655  type = "HF";
656 
657  _meol = toolT.find(detid);
658  if (_meol == toolT.end()) {
659  // if histos for this channel do not exist, create them
660  map<int, LEDBUNCH> insert;
661  char name[1024];
662  for (int i = 0; i < 10; i++) {
663  snprintf(name,
664  sizeof name,
665  "%s Pulse height, eta=%d phi=%d depth=%d TS=%d",
666  type.c_str(),
667  detid.ieta(),
668  detid.iphi(),
669  detid.depth(),
670  i);
671  insert[i].first = new TH1F(name, name, 200, 0., 2000.);
672  }
673  snprintf(name,
674  sizeof name,
675  "%s LED Mean pulse, eta=%d phi=%d depth=%d",
676  type.c_str(),
677  detid.ieta(),
678  detid.iphi(),
679  detid.depth());
680  insert[10].first = new TH1F(name, name, 10, -0.5, 9.5);
681  snprintf(name,
682  sizeof name,
683  "%s LED Pulse, eta=%d phi=%d depth=%d",
684  type.c_str(),
685  detid.ieta(),
686  detid.iphi(),
687  detid.depth());
688  insert[11].first = new TH1F(name, name, 10, -0.5, 9.5);
689  snprintf(name,
690  sizeof name,
691  "%s Mean TS, eta=%d phi=%d depth=%d",
692  type.c_str(),
693  detid.ieta(),
694  detid.iphi(),
695  detid.depth());
696  insert[12].first = new TH1F(name, name, 200, 0., 10.);
697  snprintf(name,
698  sizeof name,
699  "%s Peak TS, eta=%d phi=%d depth=%d",
700  type.c_str(),
701  detid.ieta(),
702  detid.iphi(),
703  detid.depth());
704  insert[13].first = new TH1F(name, name, 200, 0., 10.);
705  snprintf(name,
706  sizeof name,
707  "%s Peak TS error, eta=%d phi=%d depth=%d",
708  type.c_str(),
709  detid.ieta(),
710  detid.iphi(),
711  detid.depth());
712  insert[14].first = new TH1F(name, name, 200, 0., 0.05);
713  snprintf(name,
714  sizeof name,
715  "%s Fit chi2, eta=%d phi=%d depth=%d",
716  type.c_str(),
717  detid.ieta(),
718  detid.iphi(),
719  detid.depth());
720  insert[15].first = new TH1F(name, name, 100, 0., 50.);
721  snprintf(name,
722  sizeof name,
723  "%s Integrated Signal, eta=%d phi=%d depth=%d",
724  type.c_str(),
725  detid.ieta(),
726  detid.iphi(),
727  detid.depth());
728  insert[16].first = new TH1F(name, name, 500, 0., 5000.);
729 
730  toolT[detid] = insert;
731  }
732 }
constexpr int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
std::map< HcalDetId, std::map< int, LEDBUNCH > >::iterator _meol
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:50
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164

Member Data Documentation

◆ _meca

std::map<HcalCalibDetId, CALIBBUNCH>::iterator HcalLedAnalysis::_meca
private

Definition at line 119 of file HcalLedAnalysis.h.

◆ _meee

std::map<HcalDetId, std::map<int, float> >::iterator HcalLedAnalysis::_meee
private

Definition at line 116 of file HcalLedAnalysis.h.

◆ _meol

std::map<HcalDetId, std::map<int, LEDBUNCH> >::iterator HcalLedAnalysis::_meol
private

Definition at line 114 of file HcalLedAnalysis.h.

◆ ALLLEDS

TH1F* HcalLedAnalysis::ALLLEDS

Definition at line 109 of file HcalLedAnalysis.h.

◆ calibHists

std::map<HcalCalibDetId, CALIBBUNCH> HcalLedAnalysis::calibHists
private

Definition at line 118 of file HcalLedAnalysis.h.

◆ CHI2

TH1F* HcalLedAnalysis::CHI2

Definition at line 112 of file HcalLedAnalysis.h.

◆ evt

int HcalLedAnalysis::evt
private

Definition at line 122 of file HcalLedAnalysis.h.

◆ evt_curr

int HcalLedAnalysis::evt_curr
private

Definition at line 124 of file HcalLedAnalysis.h.

◆ hbHists

struct { ... } HcalLedAnalysis::hbHists

◆ hfHists

struct { ... } HcalLedAnalysis::hfHists

◆ hoHists

struct { ... } HcalLedAnalysis::hoHists

◆ LEDMEAN

TH1F* HcalLedAnalysis::LEDMEAN

Definition at line 111 of file HcalLedAnalysis.h.

◆ LEDRMS

TH1F* HcalLedAnalysis::LEDRMS

Definition at line 110 of file HcalLedAnalysis.h.

◆ LEDTRENDS

std::map<HcalDetId, std::map<int, LEDBUNCH> > HcalLedAnalysis::LEDTRENDS

Definition at line 108 of file HcalLedAnalysis.h.

◆ m_AllPedVals

std::map<HcalDetId, std::map<int, float> > HcalLedAnalysis::m_AllPedVals
private

Definition at line 115 of file HcalLedAnalysis.h.

◆ m_coder

const HcalQIECoder* HcalLedAnalysis::m_coder
private

Definition at line 105 of file HcalLedAnalysis.h.

◆ m_endTS

int HcalLedAnalysis::m_endTS
private

Definition at line 90 of file HcalLedAnalysis.h.

◆ m_file

TFile* HcalLedAnalysis::m_file
private

Definition at line 63 of file HcalLedAnalysis.h.

◆ m_fitflag

int HcalLedAnalysis::m_fitflag
private

Definition at line 102 of file HcalLedAnalysis.h.

◆ m_hiSaveflag

int HcalLedAnalysis::m_hiSaveflag
private

Definition at line 92 of file HcalLedAnalysis.h.

◆ m_logFile

std::ofstream HcalLedAnalysis::m_logFile
private

Definition at line 86 of file HcalLedAnalysis.h.

◆ m_nevtsample

int HcalLedAnalysis::m_nevtsample
private

Definition at line 91 of file HcalLedAnalysis.h.

◆ m_outFile

std::ofstream HcalLedAnalysis::m_outFile
private

Definition at line 85 of file HcalLedAnalysis.h.

◆ m_outputFileROOT

std::string HcalLedAnalysis::m_outputFileROOT
private

Definition at line 82 of file HcalLedAnalysis.h.

◆ m_outputFileText

std::string HcalLedAnalysis::m_outputFileText
private

Definition at line 83 of file HcalLedAnalysis.h.

◆ m_outputFileX

std::string HcalLedAnalysis::m_outputFileX
private

Definition at line 84 of file HcalLedAnalysis.h.

◆ m_outputFileXML

std::ofstream HcalLedAnalysis::m_outputFileXML
private

Definition at line 87 of file HcalLedAnalysis.h.

◆ m_ped

const HcalPedestal* HcalLedAnalysis::m_ped
private

Definition at line 106 of file HcalLedAnalysis.h.

◆ m_shape

const HcalQIEShape* HcalLedAnalysis::m_shape
private

Definition at line 104 of file HcalLedAnalysis.h.

◆ m_startTS

int HcalLedAnalysis::m_startTS
private

Definition at line 89 of file HcalLedAnalysis.h.

◆ m_usecalib

bool HcalLedAnalysis::m_usecalib
private

Definition at line 93 of file HcalLedAnalysis.h.

◆ sample

int HcalLedAnalysis::sample
private

Definition at line 123 of file HcalLedAnalysis.h.

Referenced by svgfig.Curve::Path().

◆ state

std::vector<bool> HcalLedAnalysis::state
private