21 for (
int k = 0;
k < 4;
k++)
22 state.push_back(
true);
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());
30 if (!m_outputFileROOT.empty()) {
31 cout <<
"Hcal LED histograms will be saved to " << m_outputFileROOT.c_str() << endl;
36 m_nevtsample = 9999999;
52 m_logFile.open(
"HcalLedAnalysis.log");
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.);
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.);
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.);
75 m_outputFileXML.open(m_outputFileX.c_str());
77 m_outputFileXML <<
"<?xml version='1.0' encoding='UTF-8'?>" << endl;
79 m_outputFileXML <<
"<ROOT>" << endl;
81 m_outputFileXML <<
" <HEADER>" << endl;
83 m_outputFileXML <<
" <TYPE>" << endl;
85 m_outputFileXML <<
" <EXTENSION_TABLE_NAME>HCAL_LED_TIMING</EXTENSION_TABLE_NAME>" << endl;
87 m_outputFileXML <<
" <NAME>HCAL LED Timing</NAME>" << endl;
89 m_outputFileXML <<
" </TYPE>" << endl;
91 m_outputFileXML <<
" <RUN>" << endl;
93 m_outputFileXML <<
" <RUN_TYPE>hcal-led-timing-test</RUN_TYPE>" << endl;
95 snprintf(
output,
sizeof output,
" <RUN_NUMBER>%06i</RUN_NUMBER>", runNum);
96 m_outputFileXML <<
output << endl;
98 m_outputFileXML <<
" <RUN_BEGIN_TIMESTAMP>2007-07-09 00:00:00.0</RUN_BEGIN_TIMESTAMP>" << endl;
100 m_outputFileXML <<
" <COMMENT_DESCRIPTION></COMMENT_DESCRIPTION>" << endl;
102 m_outputFileXML <<
" </RUN>" << endl;
104 m_outputFileXML <<
" </HEADER>" << endl;
106 m_outputFileXML <<
"<!-- Tags secton -->" << endl;
108 m_outputFileXML <<
" <ELEMENTS>" << endl;
110 m_outputFileXML <<
" <DATA_SET id='-1'/>" << endl;
112 m_outputFileXML <<
" <IOV id='1'>" << endl;
114 m_outputFileXML <<
" <INTERVAL_OF_VALIDITY_BEGIN>2147483647</INTERVAL_OF_VALIDITY_BEGIN>" << endl;
116 m_outputFileXML <<
" <INTERVAL_OF_VALIDITY_END>0</INTERVAL_OF_VALIDITY_END>" << endl;
118 m_outputFileXML <<
" </IOV>" << endl;
120 m_outputFileXML <<
" <TAG id='2' mode='auto'>" << endl;
122 snprintf(
output,
sizeof output,
" <TAG_NAME>laser_led_%06i<TAG_NAME>", runNum);
123 m_outputFileXML <<
output << endl;
125 m_outputFileXML <<
" <DETECTOR_NAME>HCAL</DETECTOR_NAME>" << endl;
127 m_outputFileXML <<
" <COMMENT_DESCRIPTION></COMMENT_DESCRIPTION>" << endl;
129 m_outputFileXML <<
" </TAG>" << endl;
131 m_outputFileXML <<
" </ELEMENTS>" << endl;
133 m_outputFileXML <<
" <MAPS>" << endl;
135 m_outputFileXML <<
" <TAG idref ='2'>" << endl;
137 m_outputFileXML <<
" <IOV idref='1'>" << endl;
139 m_outputFileXML <<
" <DATA_SET idref='-1' />" << endl;
141 m_outputFileXML <<
" </IOV>" << endl;
143 m_outputFileXML <<
" </TAG>" << endl;
145 m_outputFileXML <<
" </MAPS>" << endl;
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();
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();
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();
163 hbHists.ALLLEDS->Delete();
164 hbHists.LEDRMS->Delete();
165 hbHists.LEDMEAN->Delete();
166 hbHists.CHI2->Delete();
168 hoHists.ALLLEDS->Delete();
169 hoHists.LEDRMS->Delete();
170 hoHists.LEDMEAN->Delete();
171 hoHists.CHI2->Delete();
173 hfHists.ALLLEDS->Delete();
174 hfHists.LEDRMS->Delete();
175 hfHists.LEDMEAN->Delete();
176 hfHists.CHI2->Delete();
182 m_file =
new TFile(m_outputFileROOT.c_str(),
"RECREATE");
183 m_file->mkdir(
"HBHE");
189 m_file->mkdir(
"Calib");
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" 235 for (_meol = toolT.begin(); _meol != toolT.end(); _meol++) {
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));
242 if (m_fitflag == 1 || m_fitflag == 4) {
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));
247 if (m_fitflag == 1 || m_fitflag == 3 || m_fitflag == 4) {
248 _meol->second[10].first->Fit(
"landau",
"Q");
250 TF1*
fit = _meol->second[10].first->GetFunction(
"landau");
252 time2 = fit->GetParameter(1);
253 dtime2 = fit->GetParError(1);
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());
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());
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");
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();
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;
310 m_outputFileXML <<
output << endl;
312 m_outputFileXML <<
output << endl;
314 m_outputFileXML <<
output << endl;
316 m_outputFileXML <<
output << endl;
319 m_outputFileXML <<
" <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
321 m_outputFileXML <<
" <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
323 m_outputFileXML <<
" <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
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;
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;
348 m_outputFileXML <<
output << endl;
350 m_outputFileXML <<
output << endl;
352 m_outputFileXML <<
output << endl;
354 m_outputFileXML <<
output << endl;
356 m_outputFileXML <<
" <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
358 m_outputFileXML <<
" <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
360 m_outputFileXML <<
" <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
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;
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;
386 m_outputFileXML <<
output << endl;
388 m_outputFileXML <<
output << endl;
390 m_outputFileXML <<
output << endl;
392 m_outputFileXML <<
output << endl;
394 m_outputFileXML <<
" <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
396 m_outputFileXML <<
" <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
398 m_outputFileXML <<
" <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
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;
422 m_outputFileXML <<
output << endl;
424 m_outputFileXML <<
output << endl;
426 m_outputFileXML <<
output << endl;
428 m_outputFileXML <<
output << endl;
430 m_outputFileXML <<
" <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
432 m_outputFileXML <<
" <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
434 m_outputFileXML <<
" <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
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;
453 else if (m_fitflag == 4) {
454 m_outFile << detid <<
" " << time1 <<
" " << dtime1 <<
" " << time2 <<
" " << dtime2 <<
" " << time3
455 <<
" " << dtime3 <<
" " << time4 <<
" " << dtime4 << std::endl;
464 char LedSampleNum[20];
466 snprintf(LedSampleNum,
sizeof LedSampleNum,
"LedSample_%d",
sample);
468 m_file->mkdir(LedSampleNum);
469 m_file->cd(LedSampleNum);
472 GetLedConst(hbHists.LEDTRENDS);
473 GetLedConst(hoHists.LEDTRENDS);
474 GetLedConst(hfHists.LEDTRENDS);
479 for (_meol = toolT.begin(); _meol != toolT.end(); _meol++) {
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();
486 _meol->second[10 + m_fitflag].second.second.push_back(
new TH1F(name, name, bins, lo, hi));
488 std::vector<double>::iterator sample_it;
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();
494 _meol->second[10 + m_fitflag].second.second[0]->SetBinContent(++j, *sample_it);
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();
500 _meol->second[10 + m_fitflag].second.second[0]->SetBinError(++j, *sample_it);
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();
512 if (evt % m_nevtsample != 0)
516 if (
sample > 1 && m_fitflag != 4) {
519 LedTrendings(hbHists.LEDTRENDS);
522 LedTrendings(hoHists.LEDTRENDS);
525 LedTrendings(hfHists.LEDTRENDS);
532 hbHists.ALLLEDS->Write();
533 hbHists.LEDRMS->Write();
534 hbHists.LEDMEAN->Write();
538 hoHists.ALLLEDS->Write();
539 hoHists.LEDRMS->Write();
540 hoHists.LEDMEAN->Write();
544 hfHists.ALLLEDS->Write();
545 hfHists.LEDRMS->Write();
546 hfHists.LEDMEAN->Write();
550 for (_meca = calibHists.begin(); _meca != calibHists.end(); _meca++) {
551 _meca->second.avePulse->Write();
552 _meca->second.integPulse->Write();
558 cout <<
"Hcal histograms written to " << m_outputFileROOT.c_str() << endl;
568 sample = (evt - 1) / m_nevtsample + 1;
569 evt_curr = evt % m_nevtsample;
571 evt_curr = m_nevtsample;
578 throw(
int) calib.
size();
596 throw(
int) hbhe.
size();
600 for (
int k = 0;
k < (
int)state.size();
k++)
603 _meol = hbHists.LEDTRENDS.find(digi.
id());
604 if (_meol == hbHists.LEDTRENDS.end()) {
605 SetupLEDHists(0, digi.
id(), hbHists.LEDTRENDS);
607 LedHBHEHists(digi.
id(), digi, hbHists.LEDTRENDS, cond);
616 throw(
int) ho.
size();
619 _meol = hoHists.LEDTRENDS.find(digi.
id());
620 if (_meol == hoHists.LEDTRENDS.end()) {
621 SetupLEDHists(1, digi.
id(), hoHists.LEDTRENDS);
623 LedHOHists(digi.
id(), digi, hoHists.LEDTRENDS, cond);
632 throw(
int) hf.
size();
635 _meol = hfHists.LEDTRENDS.find(digi.
id());
636 if (_meol == hfHists.LEDTRENDS.end()) {
637 SetupLEDHists(2, digi.
id(), hfHists.LEDTRENDS);
639 LedHFHists(digi.
id(), digi, hfHists.LEDTRENDS, cond);
646 if (evt % m_nevtsample == 0)
651 string type =
"HBHE";
657 _meol = toolT.find(detid);
658 if (_meol == toolT.end()) {
660 map<int, LEDBUNCH>
insert;
662 for (
int i = 0;
i < 10;
i++) {
665 "%s Pulse height, eta=%d phi=%d depth=%d TS=%d",
671 insert[
i].first =
new TH1F(name, name, 200, 0., 2000.);
675 "%s LED Mean pulse, eta=%d phi=%d depth=%d",
680 insert[10].first =
new TH1F(name, name, 10, -0.5, 9.5);
683 "%s LED Pulse, eta=%d phi=%d depth=%d",
688 insert[11].first =
new TH1F(name, name, 10, -0.5, 9.5);
691 "%s Mean TS, eta=%d phi=%d depth=%d",
696 insert[12].first =
new TH1F(name, name, 200, 0., 10.);
699 "%s Peak TS, eta=%d phi=%d depth=%d",
704 insert[13].first =
new TH1F(name, name, 200, 0., 10.);
707 "%s Peak TS error, eta=%d phi=%d depth=%d",
712 insert[14].first =
new TH1F(name, name, 200, 0., 0.05);
715 "%s Fit chi2, eta=%d phi=%d depth=%d",
720 insert[15].first =
new TH1F(name, name, 100, 0., 50.);
723 "%s Integrated Signal, eta=%d phi=%d depth=%d",
728 insert[16].first =
new TH1F(name, name, 500, 0., 5000.);
738 map<int, LEDBUNCH> _mei;
739 _meol = toolT.find(detid);
740 _mei = _meol->second;
743 if ((evt - 1) % m_nevtsample == 0 && state[0]) {
744 for (
int k = 0;
k < (
int)state.size();
k++)
746 for (
int i = 0;
i < 16;
i++)
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));
764 _mei[TS].first->Fill(ta);
765 _mei[10].first->AddBinContent(TS + 1, ta);
768 _mei[11].first->Reset();
769 _mei[11].first->SetBinContent(TS + 1, ta);
784 for (
int i = 0;
i < 10;
i++)
785 sum = sum + _mei[11].
first->GetBinContent(
i + 1);
787 if (m_fitflag == 2 || m_fitflag == 4) {
788 float timmean = _mei[11].first->GetMean();
789 float timmeancorr = BinsizeCorr(timmean);
790 _mei[12].first->Fill(timmeancorr);
792 _mei[16].first->Fill(
793 _mei[11].
first->Integral());
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());
809 map<int, LEDBUNCH> _mei;
810 _meol = toolT.find(detid);
811 _mei = _meol->second;
813 if ((evt - 1) % m_nevtsample == 0 && state[0]) {
814 for (
int k = 0;
k < (
int)state.size();
k++)
816 for (
int i = 0;
i < 16;
i++)
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);
838 _mei[11].first->Reset();
839 _mei[11].first->SetBinContent(TS + 1, ta);
854 for (
int i = 0;
i < 10;
i++)
855 sum = sum + _mei[11].
first->GetBinContent(
i + 1);
857 if (m_fitflag == 2 || m_fitflag == 4) {
858 float timmean = _mei[11].first->GetMean();
859 float timmeancorr = BinsizeCorr(timmean);
860 _mei[12].first->Fill(timmeancorr);
862 _mei[16].first->Fill(
863 _mei[11].
first->Integral());
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());
879 map<int, LEDBUNCH> _mei;
880 _meol = toolT.find(detid);
881 _mei = _meol->second;
883 if ((evt - 1) % m_nevtsample == 0 && state[0]) {
884 for (
int k = 0;
k < (
int)state.size();
k++)
886 for (
int i = 0;
i < 16;
i++)
900 for (
int TS = m_startTS; TS < m_endTS && TS < ledDigi.
size(); TS++) {
901 int capid = ledDigi[TS].capid();
903 int adc = (
int)(ledDigi[TS].
adc() - m_ped->getValue(capid));
908 double fC = m_coder->charge(*m_shape, adc, capid);
912 _mei[TS].first->Fill(ta);
913 _mei[10].first->AddBinContent(TS + 1, ta);
916 _mei[11].first->Reset();
917 _mei[11].first->SetBinContent(TS + 1, ta);
933 for (
int i = 0;
i < 10;
i++)
934 sum = sum + _mei[11].
first->GetBinContent(
i + 1);
936 if (m_fitflag == 2 || m_fitflag == 4) {
937 float timmean = _mei[11].first->GetMean();
938 float timmeancorr = BinsizeCorr(timmean);
939 _mei[12].first->Fill(timmeancorr);
941 _mei[16].first->Fill(
942 _mei[11].
first->Integral());
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());
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};
969 int inttime = (
int)time;
970 float restime = time - inttime;
971 for (
int i = 0;
i <= 32;
i++) {
977 lolim = tsreco[
i - 1];
978 tsdown = tstrue[
i - 1];
980 tsdown = tstrue[31] - 1.;
985 tsup = tstrue[0] + 1.;
986 if (restime >= lolim && restime < uplim) {
987 corrtime = (tsdown * (uplim - restime) + tsup * (restime - lolim)) / (uplim - lolim);
1000 _meca = calibHists.find(calibId);
1001 if (_meca == calibHists.end()) {
1015 "%s %+d iphi=%d %s",
1023 snprintf(name,
sizeof name,
"%s Pin Diode Mean", prefix.c_str());
1024 calibHists[calibId].avePulse =
new TProfile(name, name, 10, -0.5, 9.5, 0, 1000);
1025 snprintf(name,
sizeof name,
"%s Pin Diode Current Pulse", prefix.c_str());
1026 calibHists[calibId].thisPulse =
new TH1F(name, name, 10, -0.5, 9.5);
1027 snprintf(name,
sizeof name,
"%s Pin Diode Integrated Pulse", prefix.c_str());
1028 calibHists[calibId].integPulse =
new TH1F(name, name, 200, 0, 500);
1030 for (
int i = m_startTS;
i < digi.
size() &&
i <= m_endTS;
i++) {
1031 calibHists[calibId].avePulse->Fill(
i, digi.
sample(
i).
adc());
1032 calibHists[calibId].thisPulse->SetBinContent(
i + 1, digi.
sample(
i).
adc());
1034 calibHists[calibId].integPulse->Fill(calibHists[calibId].thisPulse->Integral());
T getUntrackedParameter(std::string const &, T const &) const
void LedHBHEHists(const HcalDetId &detid, const HBHEDataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
HcalSubdetector subdet() const
get the subdetector
CalibDetType calibFlavor() const
get the flavor of this calibration detid
int zside() const
get the z-side of the cell (1/-1)
void LedSetup(const std::string &m_outputFileROOT)
int size() const
total number of samples in the digi
void processLedEvent(const HBHEDigiCollection &hbhe, const HODigiCollection &ho, const HFDigiCollection &hf, const HcalCalibDigiCollection &calib, const HcalDbService &cond)
constexpr uint32_t rawId() const
get the raw id
HcalDetId const & id() const
std::vector< T >::const_iterator const_iterator
~HcalLedAnalysis()
Destructor.
HcalLedAnalysis(const edm::ParameterSet &ps)
Constructor.
const HcalElectronicsId & elecId() const
int size() const
total number of samples in the digi
int depth() const
get the tower depth
std::string cboxChannelString() const
get the calibration box channel as a string (if relevant)
void SetupLEDHists(int id, const HcalDetId detid, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
void GetLedConst(std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
void ProcessCalibEvent(int fiberChan, HcalCalibDetId calibId, const HcalCalibDataFrame &digi)
HcalDetId const & id() const
int ieta() const
get the cell ieta
const HcalQIESample & sample(int i) const
access a sample
int size() const
total number of samples in the digi
const HcalCalibDetId & id() const
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
constexpr int adc() const
get the ADC sample
int ietaAbs() const
get the absolute value of the cell ieta
int iphi() const
get the low-edge iphi (if relevant)
const_iterator end() const
int iphi() const
get the cell iphi
float BinsizeCorr(float time)
int size() const
total number of samples in the digi
void LedHFHists(const HcalDetId &detid, const HFDataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
void LedTrendings(std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
const HcalDetId & id() const
void LedHOHists(const HcalDetId &detid, const HODataFrame &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)
HcalSubdetector hcalSubdet() const
get the HcalSubdetector (if relevant)
const HcalPedestal * getPedestal(const HcalGenericDetId &fId) const
Readout chain identification for Hcal.
const_iterator begin() const