20 for (
int k = 0;
k < 4;
k++)
21 state.push_back(
true);
24 if (!m_outputFileText.empty()) {
25 edm::LogInfo(
"HcalLedAnalysis") <<
"Hcal LED results will be saved to " << m_outputFileText.c_str() << endl;
26 m_outFile.open(m_outputFileText.c_str());
29 if (!m_outputFileROOT.empty()) {
30 edm::LogInfo(
"HcalLedAnalysis") <<
"Hcal LED histograms will be saved to " << m_outputFileROOT.c_str() << endl;
35 m_nevtsample = 9999999;
55 hbHists.ALLLEDS =
new TH1F(
"HBHE All LEDs",
"HB/HE All Leds", 10, 0, 9);
56 hbHists.LEDRMS =
new TH1F(
"HBHE All LED RMS",
"HB/HE All LED RMS", 100, 0, 3);
57 hbHists.LEDMEAN =
new TH1F(
"HBHE All LED Means",
"HB/HE All LED Means", 100, 0, 9);
58 hbHists.CHI2 =
new TH1F(
"HBHE Chi2 by ndf for Landau fit",
"HB/HE Chi2/ndf Landau", 200, 0., 50.);
60 hoHists.ALLLEDS =
new TH1F(
"HO All LEDs",
"HO All Leds", 10, 0, 9);
61 hoHists.LEDRMS =
new TH1F(
"HO All LED RMS",
"HO All LED RMS", 100, 0, 3);
62 hoHists.LEDMEAN =
new TH1F(
"HO All LED Means",
"HO All LED Means", 100, 0, 9);
63 hoHists.CHI2 =
new TH1F(
"HO Chi2 by ndf for Landau fit",
"HO Chi2/ndf Landau", 200, 0., 50.);
65 hfHists.ALLLEDS =
new TH1F(
"HF All LEDs",
"HF All Leds", 10, 0, 9);
66 hfHists.LEDRMS =
new TH1F(
"HF All LED RMS",
"HF All LED RMS", 100, 0, 3);
67 hfHists.LEDMEAN =
new TH1F(
"HF All LED Means",
"HF All LED Means", 100, 0, 9);
68 hfHists.CHI2 =
new TH1F(
"HF Chi2 by ndf for Landau fit",
"HF Chi2/ndf Landau", 200, 0., 50.);
73 m_outputFileXML.open(m_outputFileX.c_str());
75 m_outputFileXML <<
"<?xml version='1.0' encoding='UTF-8'?>" << endl;
77 m_outputFileXML <<
"<ROOT>" << endl;
79 m_outputFileXML <<
" <HEADER>" << endl;
81 m_outputFileXML <<
" <TYPE>" << endl;
83 m_outputFileXML <<
" <EXTENSION_TABLE_NAME>HCAL_LED_TIMING</EXTENSION_TABLE_NAME>" << endl;
85 m_outputFileXML <<
" <NAME>HCAL LED Timing</NAME>" << endl;
87 m_outputFileXML <<
" </TYPE>" << endl;
89 m_outputFileXML <<
" <RUN>" << endl;
91 m_outputFileXML <<
" <RUN_TYPE>hcal-led-timing-test</RUN_TYPE>" << endl;
94 m_outputFileXML <<
output << endl;
96 m_outputFileXML <<
" <RUN_BEGIN_TIMESTAMP>2007-07-09 00:00:00.0</RUN_BEGIN_TIMESTAMP>" << endl;
98 m_outputFileXML <<
" <COMMENT_DESCRIPTION></COMMENT_DESCRIPTION>" << endl;
100 m_outputFileXML <<
" </RUN>" << endl;
102 m_outputFileXML <<
" </HEADER>" << endl;
104 m_outputFileXML <<
"<!-- Tags secton -->" << endl;
106 m_outputFileXML <<
" <ELEMENTS>" << endl;
108 m_outputFileXML <<
" <DATA_SET id='-1'/>" << endl;
110 m_outputFileXML <<
" <IOV id='1'>" << endl;
112 m_outputFileXML <<
" <INTERVAL_OF_VALIDITY_BEGIN>2147483647</INTERVAL_OF_VALIDITY_BEGIN>" << endl;
114 m_outputFileXML <<
" <INTERVAL_OF_VALIDITY_END>0</INTERVAL_OF_VALIDITY_END>" << endl;
116 m_outputFileXML <<
" </IOV>" << endl;
118 m_outputFileXML <<
" <TAG id='2' mode='auto'>" << endl;
121 m_outputFileXML <<
output << endl;
123 m_outputFileXML <<
" <DETECTOR_NAME>HCAL</DETECTOR_NAME>" << endl;
125 m_outputFileXML <<
" <COMMENT_DESCRIPTION></COMMENT_DESCRIPTION>" << endl;
127 m_outputFileXML <<
" </TAG>" << endl;
129 m_outputFileXML <<
" </ELEMENTS>" << endl;
131 m_outputFileXML <<
" <MAPS>" << endl;
133 m_outputFileXML <<
" <TAG idref ='2'>" << endl;
135 m_outputFileXML <<
" <IOV idref='1'>" << endl;
137 m_outputFileXML <<
" <DATA_SET idref='-1' />" << endl;
139 m_outputFileXML <<
" </IOV>" << endl;
141 m_outputFileXML <<
" </TAG>" << endl;
143 m_outputFileXML <<
" </MAPS>" << endl;
149 for (_meol = hbHists.LEDTRENDS.begin(); _meol != hbHists.LEDTRENDS.end(); _meol++) {
150 for (
int i = 0;
i < 15;
i++)
151 _meol->second[
i].first->Delete();
153 for (_meol = hoHists.LEDTRENDS.begin(); _meol != hoHists.LEDTRENDS.end(); _meol++) {
154 for (
int i = 0;
i < 15;
i++)
155 _meol->second[
i].first->Delete();
157 for (_meol = hfHists.LEDTRENDS.begin(); _meol != hfHists.LEDTRENDS.end(); _meol++) {
158 for (
int i = 0;
i < 15;
i++)
159 _meol->second[
i].first->Delete();
161 hbHists.ALLLEDS->Delete();
162 hbHists.LEDRMS->Delete();
163 hbHists.LEDMEAN->Delete();
164 hbHists.CHI2->Delete();
166 hoHists.ALLLEDS->Delete();
167 hoHists.LEDRMS->Delete();
168 hoHists.LEDMEAN->Delete();
169 hoHists.CHI2->Delete();
171 hfHists.ALLLEDS->Delete();
172 hfHists.LEDRMS->Delete();
173 hfHists.LEDMEAN->Delete();
174 hfHists.CHI2->Delete();
180 m_file =
new TFile(m_outputFileROOT.c_str(),
"RECREATE");
181 m_file->mkdir(
"HBHE");
187 m_file->mkdir(
"Calib");
224 if (!m_outputFileText.empty()) {
225 if (m_fitflag == 0 || m_fitflag == 2)
226 m_outFile <<
"Det Eta,Phi,D Mean Error" << std::endl;
227 else if (m_fitflag == 1 || m_fitflag == 3)
228 m_outFile <<
"Det Eta,Phi,D Peak Error" << std::endl;
229 else if (m_fitflag == 4)
230 m_outFile <<
"Det Eta,Phi,D Mean Error Peak Error MeanEv Error PeakEv Error" 233 for (_meol = toolT.begin(); _meol != toolT.end(); _meol++) {
235 _meol->second[10].first->Scale(1. / evt_curr);
236 if (m_fitflag == 0 || m_fitflag == 4) {
237 time1 = _meol->second[10].first->GetMean();
238 dtime1 = _meol->second[10].first->GetRMS() /
sqrt((
float)evt_curr * (m_endTS - m_startTS + 1));
240 if (m_fitflag == 1 || m_fitflag == 4) {
242 for (
int j = 0;
j < 10;
j++)
243 _meol->second[10].first->SetBinError(
j + 1, _meol->second[
j].first->GetRMS() /
sqrt((
float)evt_curr));
245 if (m_fitflag == 1 || m_fitflag == 3 || m_fitflag == 4) {
246 _meol->second[10].first->Fit(
"landau",
"Q");
248 TF1*
fit = _meol->second[10].first->GetFunction(
"landau");
250 time2 =
fit->GetParameter(1);
251 dtime2 =
fit->GetParError(1);
253 if (m_fitflag == 2 || m_fitflag == 4) {
254 time3 = _meol->second[12].first->GetMean();
255 dtime3 = _meol->second[12].first->GetRMS() /
sqrt((
float)_meol->second[12].first->GetEntries());
257 if (m_fitflag == 3 || m_fitflag == 4) {
258 time4 = _meol->second[13].first->GetMean();
259 dtime4 = _meol->second[13].first->GetRMS() /
sqrt((
float)_meol->second[13].first->GetEntries());
261 for (
int i = 0;
i < 10;
i++) {
262 _meol->second[
i].first->GetXaxis()->SetTitle(
"Pulse height (fC)");
263 _meol->second[
i].first->GetYaxis()->SetTitle(
"Counts");
266 _meol->second[10].first->GetXaxis()->SetTitle(
"Time slice");
267 _meol->second[10].first->GetYaxis()->SetTitle(
"Averaged pulse (fC)");
268 if (m_hiSaveflag > 0)
269 _meol->second[10].first->Write();
270 _meol->second[10].second.first[0].push_back(time1);
271 _meol->second[10].second.first[1].push_back(dtime1);
272 _meol->second[11].second.first[0].push_back(time2);
273 _meol->second[11].second.first[1].push_back(dtime2);
274 _meol->second[12].first->GetXaxis()->SetTitle(
"Mean TS");
275 _meol->second[12].first->GetYaxis()->SetTitle(
"Counts");
276 if (m_fitflag == 2 && m_hiSaveflag > 0)
277 _meol->second[12].first->Write();
278 _meol->second[12].second.first[0].push_back(time3);
279 _meol->second[12].second.first[1].push_back(dtime3);
280 _meol->second[13].first->GetXaxis()->SetTitle(
"Peak TS");
281 _meol->second[13].first->GetYaxis()->SetTitle(
"Counts");
282 if (m_fitflag > 2 && m_hiSaveflag > 0)
283 _meol->second[13].first->Write();
284 _meol->second[13].second.first[0].push_back(time4);
285 _meol->second[13].second.first[1].push_back(dtime4);
286 _meol->second[14].first->GetXaxis()->SetTitle(
"Peak TS error");
287 _meol->second[14].first->GetYaxis()->SetTitle(
"Counts");
288 if (m_fitflag > 2 && m_hiSaveflag > 0)
289 _meol->second[14].first->Write();
290 _meol->second[15].first->GetXaxis()->SetTitle(
"Chi2/NDF");
291 _meol->second[15].first->GetYaxis()->SetTitle(
"Counts");
292 if (m_fitflag > 2 && m_hiSaveflag > 0)
293 _meol->second[15].first->Write();
294 _meol->second[16].first->GetXaxis()->SetTitle(
"Integrated Signal");
295 _meol->second[16].first->Write();
300 if (!m_outputFileText.empty()) {
301 if (m_fitflag == 0) {
302 m_outFile << detid <<
" " << time1 <<
" " << dtime1 << std::endl;
303 m_outputFileXML <<
" <DATA_SET>" << endl;
304 m_outputFileXML <<
" <VERSION>version:1</VERSION>" << endl;
305 m_outputFileXML <<
" <CHANNEL>" << endl;
306 m_outputFileXML <<
" <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>" << endl;
308 m_outputFileXML <<
output << endl;
310 m_outputFileXML <<
output << endl;
312 m_outputFileXML <<
output << endl;
314 m_outputFileXML <<
output << endl;
317 m_outputFileXML <<
" <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
319 m_outputFileXML <<
" <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
321 m_outputFileXML <<
" <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
323 m_outputFileXML <<
" <DETECTOR_NAME>HF</DETECTOR_NAME>" << endl;
324 snprintf(
output,
sizeof output,
" <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.
rawId());
325 m_outputFileXML <<
output << endl;
326 m_outputFileXML <<
" </CHANNEL>" << endl;
327 m_outputFileXML <<
" <DATA>" << endl;
328 snprintf(
output,
sizeof output,
" <MEAN_TIME>%7f</MEAN_TIME>", time1);
329 m_outputFileXML <<
output << endl;
330 m_outputFileXML <<
" <OFFSET_TIME> 0</OFFSET_TIME>" << endl;
331 snprintf(
output,
sizeof output,
" <ERROR_STAT>%7f</ERROR_STAT>", dtime1);
332 m_outputFileXML <<
output << endl;
333 snprintf(
output,
sizeof output,
" <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag + 1);
334 m_outputFileXML <<
output << endl;
335 m_outputFileXML <<
" <STATUS_WORD> 0</STATUS_WORD>" << endl;
336 m_outputFileXML <<
" </DATA>" << endl;
337 m_outputFileXML <<
" </DATA_SET>" << endl;
339 }
else if (m_fitflag == 1) {
340 m_outFile << detid <<
" " << time2 <<
" " << dtime2 << std::endl;
341 m_outputFileXML <<
" <DATA_SET>" << endl;
342 m_outputFileXML <<
" <VERSION>version:1</VERSION>" << endl;
343 m_outputFileXML <<
" <CHANNEL>" << endl;
344 m_outputFileXML <<
" <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>" << endl;
346 m_outputFileXML <<
output << endl;
348 m_outputFileXML <<
output << endl;
350 m_outputFileXML <<
output << endl;
352 m_outputFileXML <<
output << endl;
354 m_outputFileXML <<
" <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
356 m_outputFileXML <<
" <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
358 m_outputFileXML <<
" <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
360 m_outputFileXML <<
" <DETECTOR_NAME>HF</DETECTOR_NAME>" << endl;
361 snprintf(
output,
sizeof output,
" <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.
rawId());
362 m_outputFileXML <<
output << endl;
363 m_outputFileXML <<
" </CHANNEL>" << endl;
364 m_outputFileXML <<
" <DATA>" << endl;
365 snprintf(
output,
sizeof output,
" <MEAN_TIME>%7f</MEAN_TIME>", time2);
366 m_outputFileXML <<
output << endl;
367 m_outputFileXML <<
" <OFFSET_TIME> 0</OFFSET_TIME>" << endl;
368 snprintf(
output,
sizeof output,
" <ERROR_STAT>%7f</ERROR_STAT>", dtime2);
369 m_outputFileXML <<
output << endl;
370 snprintf(
output,
sizeof output,
" <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag + 1);
371 m_outputFileXML <<
output << endl;
372 m_outputFileXML <<
" <STATUS_WORD> 0</STATUS_WORD>" << endl;
373 m_outputFileXML <<
" </DATA>" << endl;
374 m_outputFileXML <<
" </DATA_SET>" << endl;
377 else if (m_fitflag == 2) {
378 m_outFile << detid <<
" " << time3 <<
" " << dtime3 << std::endl;
379 m_outputFileXML <<
" <DATA_SET>" << endl;
380 m_outputFileXML <<
" <VERSION>version:1</VERSION>" << endl;
381 m_outputFileXML <<
" <CHANNEL>" << endl;
382 m_outputFileXML <<
" <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>" << endl;
384 m_outputFileXML <<
output << endl;
386 m_outputFileXML <<
output << endl;
388 m_outputFileXML <<
output << endl;
390 m_outputFileXML <<
output << endl;
392 m_outputFileXML <<
" <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
394 m_outputFileXML <<
" <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
396 m_outputFileXML <<
" <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
398 m_outputFileXML <<
" <DETECTOR_NAME>HF</DETECTOR_NAME>" << endl;
399 snprintf(
output,
sizeof output,
" <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.
rawId());
400 m_outputFileXML <<
output << endl;
401 m_outputFileXML <<
" </CHANNEL>" << endl;
402 m_outputFileXML <<
" <DATA>" << endl;
403 snprintf(
output,
sizeof output,
" <MEAN_TIME>%7f</MEAN_TIME>", time3);
404 m_outputFileXML <<
output << endl;
405 m_outputFileXML <<
" <OFFSET_TIME> 0</OFFSET_TIME>" << endl;
406 snprintf(
output,
sizeof output,
" <ERROR_STAT>%7f</ERROR_STAT>", dtime3);
407 m_outputFileXML <<
output << endl;
408 snprintf(
output,
sizeof output,
" <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag + 1);
409 m_outputFileXML <<
output << endl;
410 m_outputFileXML <<
" <STATUS_WORD> 0</STATUS_WORD>" << endl;
411 m_outputFileXML <<
" </DATA>" << endl;
412 m_outputFileXML <<
" </DATA_SET>" << endl;
413 }
else if (m_fitflag == 3) {
414 m_outFile << detid <<
" " << time4 <<
" " << dtime4 << std::endl;
415 m_outputFileXML <<
" <DATA_SET>" << endl;
416 m_outputFileXML <<
" <VERSION>version:1</VERSION>" << endl;
417 m_outputFileXML <<
" <CHANNEL>" << endl;
418 m_outputFileXML <<
" <EXTENSION_TABLE_NAME>HCAL_CHANNELS</EXTENSION_TABLE_NAME>" << endl;
420 m_outputFileXML <<
output << endl;
422 m_outputFileXML <<
output << endl;
424 m_outputFileXML <<
output << endl;
426 m_outputFileXML <<
output << endl;
428 m_outputFileXML <<
" <DETECTOR_NAME>HB</DETECTOR_NAME>" << endl;
430 m_outputFileXML <<
" <DETECTOR_NAME>HE</DETECTOR_NAME>" << endl;
432 m_outputFileXML <<
" <DETECTOR_NAME>HO</DETECTOR_NAME>" << endl;
434 m_outputFileXML <<
" <DETECTOR_NAME>HF</DETECTOR_NAME>" << endl;
435 snprintf(
output,
sizeof output,
" <HCAL_CHANNEL_ID>%10i</HCAL_CHANNEL_ID>", detid.
rawId());
436 m_outputFileXML <<
output << endl;
437 m_outputFileXML <<
" </CHANNEL>" << endl;
438 m_outputFileXML <<
" <DATA>" << endl;
439 snprintf(
output,
sizeof output,
" <MEAN_TIME>%7f</MEAN_TIME>", time4);
440 m_outputFileXML <<
output << endl;
441 m_outputFileXML <<
" <OFFSET_TIME> 0</OFFSET_TIME>" << endl;
442 snprintf(
output,
sizeof output,
" <ERROR_STAT>%7f</ERROR_STAT>", dtime4);
443 m_outputFileXML <<
output << endl;
444 snprintf(
output,
sizeof output,
" <ANALYSIS_FLAG>%2i</ANALYSIS_FLAG>", m_fitflag + 1);
445 m_outputFileXML <<
output << endl;
446 m_outputFileXML <<
" <STATUS_WORD> 0</STATUS_WORD>" << endl;
447 m_outputFileXML <<
" </DATA>" << endl;
448 m_outputFileXML <<
" </DATA_SET>" << endl;
451 else if (m_fitflag == 4) {
452 m_outFile << detid <<
" " << time1 <<
" " << dtime1 <<
" " << time2 <<
" " << dtime2 <<
" " << time3
453 <<
" " << dtime3 <<
" " << time4 <<
" " << dtime4 << std::endl;
462 char LedSampleNum[20];
464 snprintf(LedSampleNum,
sizeof LedSampleNum,
"LedSample_%d",
sample);
466 m_file->mkdir(LedSampleNum);
467 m_file->cd(LedSampleNum);
470 GetLedConst(hbHists.LEDTRENDS);
471 GetLedConst(hoHists.LEDTRENDS);
472 GetLedConst(hfHists.LEDTRENDS);
477 for (_meol = toolT.begin(); _meol != toolT.end(); _meol++) {
480 snprintf(
name,
sizeof name,
"LED timing trend, eta=%d phi=%d depth=%d", detid.
ieta(), detid.
iphi(), detid.
depth());
481 int bins = _meol->second[10 + m_fitflag].second.first[0].size();
484 _meol->second[10 + m_fitflag].second.second.push_back(
new TH1F(
name,
name,
bins, lo,
hi));
486 std::vector<double>::iterator sample_it;
489 for (sample_it = _meol->second[10 + m_fitflag].second.first[0].begin();
490 sample_it != _meol->second[10 + m_fitflag].second.first[0].end();
492 _meol->second[10 + m_fitflag].second.second[0]->SetBinContent(++
j, *sample_it);
495 for (sample_it = _meol->second[10 + m_fitflag].second.first[1].begin();
496 sample_it != _meol->second[10 + m_fitflag].second.first[1].end();
498 _meol->second[10 + m_fitflag].second.second[0]->SetBinError(++
j, *sample_it);
500 snprintf(
name,
sizeof name,
"Sample (%d events)", m_nevtsample);
501 _meol->second[10 + m_fitflag].second.second[0]->GetXaxis()->SetTitle(
name);
502 _meol->second[10 + m_fitflag].second.second[0]->GetYaxis()->SetTitle(
"Peak position");
503 _meol->second[10 + m_fitflag].second.second[0]->Write();
510 if (evt % m_nevtsample != 0)
514 if (
sample > 1 && m_fitflag != 4) {
517 LedTrendings(hbHists.LEDTRENDS);
520 LedTrendings(hoHists.LEDTRENDS);
523 LedTrendings(hfHists.LEDTRENDS);
530 hbHists.ALLLEDS->Write();
531 hbHists.LEDRMS->Write();
532 hbHists.LEDMEAN->Write();
536 hoHists.ALLLEDS->Write();
537 hoHists.LEDRMS->Write();
538 hoHists.LEDMEAN->Write();
542 hfHists.ALLLEDS->Write();
543 hfHists.LEDRMS->Write();
544 hfHists.LEDMEAN->Write();
548 for (_meca = calibHists.begin(); _meca != calibHists.end(); _meca++) {
549 _meca->second.avePulse->Write();
550 _meca->second.integPulse->Write();
556 edm::LogInfo(
"HcalLedAnalysis") <<
"Hcal histograms written to " << m_outputFileROOT.c_str() << endl;
566 sample = (evt - 1) / m_nevtsample + 1;
567 evt_curr = evt % m_nevtsample;
569 evt_curr = m_nevtsample;
600 _meol = hbHists.LEDTRENDS.find(digi.
id());
601 if (_meol == hbHists.LEDTRENDS.end()) {
602 SetupLEDHists(0, digi.
id(), hbHists.LEDTRENDS);
604 LedHBHEHists(digi.
id(), digi, hbHists.LEDTRENDS,
cond);
609 edm::LogError(
"HcalLedAnalysis") <<
"Event with " << (
int)
ho.size() <<
" HO Digis passed.";
614 _meol = hoHists.LEDTRENDS.find(digi.
id());
615 if (_meol == hoHists.LEDTRENDS.end()) {
616 SetupLEDHists(1, digi.
id(), hoHists.LEDTRENDS);
618 LedHOHists(digi.
id(), digi, hoHists.LEDTRENDS,
cond);
623 edm::LogError(
"HcalLedAnalysis") <<
"Event with " << (
int)
hf.size() <<
" HF Digis passed.";
628 _meol = hfHists.LEDTRENDS.find(digi.
id());
629 if (_meol == hfHists.LEDTRENDS.end()) {
630 SetupLEDHists(2, digi.
id(), hfHists.LEDTRENDS);
632 LedHFHists(digi.
id(), digi, hfHists.LEDTRENDS,
cond);
636 if (evt % m_nevtsample == 0)
641 string type =
"HBHE";
647 _meol = toolT.find(detid);
648 if (_meol == toolT.end()) {
650 map<int, LEDBUNCH>
insert;
652 for (
int i = 0;
i < 10;
i++) {
655 "%s Pulse height, eta=%d phi=%d depth=%d TS=%d",
665 "%s LED Mean pulse, eta=%d phi=%d depth=%d",
673 "%s LED Pulse, eta=%d phi=%d depth=%d",
681 "%s Mean TS, eta=%d phi=%d depth=%d",
689 "%s Peak TS, eta=%d phi=%d depth=%d",
697 "%s Peak TS error, eta=%d phi=%d depth=%d",
705 "%s Fit chi2, eta=%d phi=%d depth=%d",
713 "%s Integrated Signal, eta=%d phi=%d depth=%d",
728 map<int, LEDBUNCH> _mei;
729 _meol = toolT.find(detid);
730 _mei = _meol->second;
733 if ((evt - 1) % m_nevtsample == 0 &&
state[0]) {
736 for (
int i = 0;
i < 16;
i++)
745 m_coder =
cond.getHcalCoder(detid);
746 m_ped =
cond.getPedestal(detid);
747 m_shape =
cond.getHcalShape(m_coder);
748 for (
int TS = m_startTS; TS < m_endTS && TS < ledDigi.
size(); TS++) {
749 int capid = ledDigi[TS].capid();
750 int adc = ledDigi[TS].adc();
751 double fC = m_coder->charge(*m_shape,
adc, capid);
752 ta = (fC - m_ped->getValue(capid));
754 _mei[TS].first->Fill(ta);
755 _mei[10].first->AddBinContent(TS + 1, ta);
758 _mei[11].first->Reset();
759 _mei[11].first->SetBinContent(TS + 1, ta);
774 for (
int i = 0;
i < 10;
i++)
775 sum = sum + _mei[11].
first->GetBinContent(
i + 1);
777 if (m_fitflag == 2 || m_fitflag == 4) {
778 float timmean = _mei[11].first->GetMean();
779 float timmeancorr = BinsizeCorr(timmean);
780 _mei[12].first->Fill(timmeancorr);
782 _mei[16].first->Fill(
783 _mei[11].
first->Integral());
784 if (m_fitflag == 3 || m_fitflag == 4) {
785 _mei[11].first->Fit(
"landau",
"Q");
786 TF1*
fit = _mei[11].first->GetFunction(
"landau");
787 _mei[13].first->Fill(
fit->GetParameter(1));
788 _mei[14].first->Fill(
fit->GetParError(1));
789 _mei[15].first->Fill(
fit->GetChisquare() /
fit->GetNDF());
799 map<int, LEDBUNCH> _mei;
800 _meol = toolT.find(detid);
801 _mei = _meol->second;
803 if ((evt - 1) % m_nevtsample == 0 &&
state[0]) {
806 for (
int i = 0;
i < 16;
i++)
816 m_coder =
cond.getHcalCoder(detid);
817 m_ped =
cond.getPedestal(detid);
818 m_shape =
cond.getHcalShape(m_coder);
819 for (
int TS = m_startTS; TS < m_endTS && TS < ledDigi.
size(); TS++) {
820 int capid = ledDigi[TS].capid();
821 int adc = ledDigi[TS].adc();
822 double fC = m_coder->charge(*m_shape,
adc, capid);
823 ta = (fC - m_ped->getValue(capid));
824 _mei[TS].first->Fill(ta);
825 _mei[10].first->AddBinContent(TS + 1, ta);
828 _mei[11].first->Reset();
829 _mei[11].first->SetBinContent(TS + 1, ta);
844 for (
int i = 0;
i < 10;
i++)
845 sum = sum + _mei[11].
first->GetBinContent(
i + 1);
847 if (m_fitflag == 2 || m_fitflag == 4) {
848 float timmean = _mei[11].first->GetMean();
849 float timmeancorr = BinsizeCorr(timmean);
850 _mei[12].first->Fill(timmeancorr);
852 _mei[16].first->Fill(
853 _mei[11].
first->Integral());
854 if (m_fitflag == 3 || m_fitflag == 4) {
855 _mei[11].first->Fit(
"landau",
"Q");
856 TF1*
fit = _mei[11].first->GetFunction(
"landau");
857 _mei[13].first->Fill(
fit->GetParameter(1));
858 _mei[14].first->Fill(
fit->GetParError(1));
859 _mei[15].first->Fill(
fit->GetChisquare() /
fit->GetNDF());
869 map<int, LEDBUNCH> _mei;
870 _meol = toolT.find(detid);
871 _mei = _meol->second;
873 if ((evt - 1) % m_nevtsample == 0 &&
state[0]) {
876 for (
int i = 0;
i < 16;
i++)
886 m_coder =
cond.getHcalCoder(detid);
887 m_ped =
cond.getPedestal(detid);
888 m_shape =
cond.getHcalShape(m_coder);
890 for (
int TS = m_startTS; TS < m_endTS && TS < ledDigi.
size(); TS++) {
891 int capid = ledDigi[TS].capid();
893 int adc = (
int)(ledDigi[TS].
adc() - m_ped->getValue(capid));
898 double fC = m_coder->charge(*m_shape,
adc, capid);
902 _mei[TS].first->Fill(ta);
903 _mei[10].first->AddBinContent(TS + 1, ta);
906 _mei[11].first->Reset();
907 _mei[11].first->SetBinContent(TS + 1, ta);
923 for (
int i = 0;
i < 10;
i++)
924 sum = sum + _mei[11].
first->GetBinContent(
i + 1);
926 if (m_fitflag == 2 || m_fitflag == 4) {
927 float timmean = _mei[11].first->GetMean();
928 float timmeancorr = BinsizeCorr(timmean);
929 _mei[12].first->Fill(timmeancorr);
931 _mei[16].first->Fill(
932 _mei[11].
first->Integral());
933 if (m_fitflag == 3 || m_fitflag == 4) {
934 _mei[11].first->Fit(
"landau",
"Q");
935 TF1*
fit = _mei[11].first->GetFunction(
"landau");
936 _mei[13].first->Fill(
fit->GetParameter(1));
937 _mei[14].first->Fill(
fit->GetParError(1));
938 _mei[15].first->Fill(
fit->GetChisquare() /
fit->GetNDF());
950 static const float tstrue[32] = {0.003, 0.03425, 0.06548, 0.09675, 0.128, 0.15925, 0.1905, 0.22175,
951 0.253, 0.28425, 0.3155, 0.34675, 0.378, 0.40925, 0.4405, 0.47175,
952 0.503, 0.53425, 0.5655, 0.59675, 0.628, 0.65925, 0.6905, 0.72175,
953 0.753, 0.78425, 0.8155, 0.84675, 0.878, 0.90925, 0.9405, 0.97175};
954 static const float tsreco[32] = {-0.00422, 0.01815, 0.04409, 0.07346, 0.09799, 0.12192, 0.15072, 0.18158,
955 0.21397, 0.24865, 0.28448, 0.31973, 0.35449, 0.39208, 0.43282, 0.47244,
956 0.5105, 0.55008, 0.58827, 0.62828, 0.6717, 0.70966, 0.74086, 0.77496,
957 0.80843, 0.83472, 0.86044, 0.8843, 0.90674, 0.92982, 0.95072, 0.9726};
960 float restime =
time - inttime;
961 for (
int i = 0;
i <= 32;
i++) {
967 lolim = tsreco[
i - 1];
968 tsdown = tstrue[
i - 1];
970 tsdown = tstrue[31] - 1.;
975 tsup = tstrue[0] + 1.;
976 if (restime >= lolim && restime < uplim) {
977 corrtime = (tsdown * (uplim - restime) + tsup * (restime - lolim)) / (uplim - lolim);
990 _meca = calibHists.find(calibId);
991 if (_meca == calibHists.end()) {
1003 "%s %+d iphi=%d %s",
1011 snprintf(
name,
sizeof name,
"%s Pin Diode Mean",
prefix.c_str());
1012 calibHists[calibId].avePulse =
new TProfile(
name,
name, 10, -0.5, 9.5, 0, 1000);
1013 snprintf(
name,
sizeof name,
"%s Pin Diode Current Pulse",
prefix.c_str());
1014 calibHists[calibId].thisPulse =
new TH1F(
name,
name, 10, -0.5, 9.5);
1015 snprintf(
name,
sizeof name,
"%s Pin Diode Integrated Pulse",
prefix.c_str());
1016 calibHists[calibId].integPulse =
new TH1F(
name,
name, 200, 0, 500);
1018 for (
int i = m_startTS;
i < digi.
size() &&
i <= m_endTS;
i++) {
1019 calibHists[calibId].avePulse->Fill(
i, digi.
sample(
i).
adc());
1020 calibHists[calibId].thisPulse->SetBinContent(
i + 1, digi.
sample(
i).
adc());
1022 calibHists[calibId].integPulse->Fill(calibHists[calibId].thisPulse->Integral());
constexpr HcalDetId const & id() const
void LedHBHEHists(const HcalDetId &detid, const HBHEDataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
constexpr int zside() const
get the z-side of the cell (1/-1)
std::string cboxChannelString() const
get the calibration box channel as a string (if relevant)
constexpr int ietaAbs() const
get the absolute value of the cell ieta
void LedSetup(const std::string &m_outputFileROOT)
void processLedEvent(const HBHEDigiCollection &hbhe, const HODigiCollection &ho, const HFDigiCollection &hf, const HcalCalibDigiCollection &calib, const HcalDbService &cond)
std::vector< T >::const_iterator const_iterator
~HcalLedAnalysis()
Destructor.
int size() const
total number of samples in the digi
Log< level::Error, false > LogError
HcalSubdetector hcalSubdet() const
get the HcalSubdetector (if relevant)
HcalLedAnalysis(const edm::ParameterSet &ps)
Constructor.
T getUntrackedParameter(std::string const &, T const &) const
constexpr HcalSubdetector subdet() const
get the subdetector
const HcalQIESample & sample(int i) const
access a sample
const HcalElectronicsId & elecId() const
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)
const HcalCalibDetId & id() const
constexpr int32_t fiberChanId() const
get the fiber channel id (which of channels on a fiber)
void ProcessCalibEvent(int fiberChan, HcalCalibDetId calibId, const HcalCalibDataFrame &digi)
constexpr int ieta() const
get the cell ieta
int iphi() const
get the low-edge iphi (if relevant)
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
constexpr int size() const
total number of samples in the digi
constexpr const HcalDetId & id() const
Log< level::Info, false > LogInfo
float BinsizeCorr(float time)
void LedHFHists(const HcalDetId &detid, const HFDataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
constexpr uint32_t rawId() const
get the raw id
CalibDetType calibFlavor() const
get the flavor of this calibration detid
constexpr int size() const
total number of samples in the digi
constexpr int adc() const
get the ADC sample
void LedTrendings(std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT)
void LedHOHists(const HcalDetId &detid, const HODataFrame &ledDigi, std::map< HcalDetId, std::map< int, LEDBUNCH > > &toolT, const HcalDbService &cond)
constexpr int size() const
total number of samples in the digi
Readout chain identification for Hcal.
constexpr int iphi() const
get the cell iphi
constexpr HcalDetId const & id() const
uint16_t *__restrict__ uint16_t const *__restrict__ adc
constexpr int depth() const
get the tower depth