162 const char *part[5] = {
"AUX",
"LBA",
"LBC",
"EBA",
"EBC" };
163 const char *gain[6] = {
"_lo",
"_hi",
"",
" low gain",
" high gain",
"" };
175 MsgStream log(msgSvc(), name());
177 std::ostringstream sStr;
178 sStr << part[ros] << std::setfill(
'0') << std::setw(2) << drawer + 1 << std::setfill(
' ');
179 std::string moduleName = sStr.str();
180 std::string subDir = moduleName;
181 std::string histName, histTitle;
190 for (
int gn = mingain; gn < maxgain; ++gn) {
195 sStr << moduleName <<
"_DMU_head_" << gain[gn] <<
"_err";
196 histName = sStr.str();
199 sStr << moduleName <<
" DMU Header " << gain[3 + gn] <<
" errors";
200 histTitle = sStr.str();
202 m_data->m_hist2[ros][drawer][adc].push_back(
book2F(subDir, histName, histTitle, 16, 0., 16., 8, -0.5, 7.5));
205 for (
int ch = 0; ch < 48; ++ch) {
210 sStr << std::setfill(
'0') << std::setw(2) << ch << std::setfill(
' ');
211 std::string sCh = sStr.str();
213 for (
int gn = mingain; gn < maxgain; ++gn) {
219 sStr << moduleName <<
"_ch_" << sCh << gain[gn] <<
"_sample0";
220 histName = sStr.str();
223 sStr << moduleName <<
" CH " << ch << gain[3 + gn] <<
" sample[0]";
224 histTitle = sStr.str();
226 m_data->m_hist1[ros][drawer][ch][adc].push_back(
book1S(subDir, histName, histTitle, 151, -0.5, 150.5));
230 sStr << moduleName <<
"_ch_" << sCh << gain[gn] <<
"_meanRMS";
231 histName = sStr.str();
234 sStr << moduleName <<
" CH " << ch << gain[3 + gn] <<
" mean RMS in event";
235 histTitle = sStr.str();
237 m_data->m_hist1[ros][drawer][ch][adc].push_back(
book1S(subDir, histName, histTitle, 101, -0.05, 10.05));
241 sStr << moduleName <<
"_ch_" << sCh << gain[gn] <<
"_samples";
242 histName = sStr.str();
245 sStr << moduleName <<
" CH " << ch << gain[3 + gn] <<
" all samples";
246 histTitle = sStr.str();
252 sStr << moduleName <<
"_ch_" << sCh << gain[gn] <<
"_evtn_mod32";
253 histName = sStr.str();
256 sStr << moduleName <<
" CH " << ch << gain[3 + gn] <<
" event number % 32";
257 histTitle = sStr.str();
259 m_data->m_histC[ros][drawer][ch][adc].push_back(
book1C(subDir, histName, histTitle, 32, -0.5, 31.5));
263 sStr << moduleName <<
"_ch_" << sCh << gain[gn] <<
"_prof";
264 histName = sStr.str();
267 sStr << moduleName <<
" CH " << ch << gain[3 + gn] <<
" average profile";
268 histTitle = sStr.str();
274 double shiftxmin = 0.;
279 sStr << moduleName <<
"_ch_" << sCh << gain[gn] <<
"_samples_shifted";
280 histName = sStr.str();
283 sStr << moduleName <<
" CH " << ch << gain[3 + gn] <<
" all samples shifted";
284 histTitle = sStr.str();
286 m_data->m_shifted_hist[ros][drawer][ch][adc] =
book1S(subDir, histName, histTitle, shiftnbins, shiftxmin, shiftxmax);
291 sStr << std::setfill(
'0') << std::setw(2) << ch << std::setfill(
' ');
292 std::string sDmu = sStr.str();
295 sStr << moduleName <<
"_dmu_" << sDmu << gain[gn] <<
"_BCID";
296 histName = sStr.str();
299 sStr << moduleName <<
" DMU0 " << ch << gain[3 + gn] <<
" BCID";
300 histTitle = sStr.str();
302 m_data->m_hist1[ros][drawer][ch][adc].push_back(
book1S(subDir, histName, histTitle, 100, 2050.5, 2150.5));
305 sStr << moduleName <<
"_dmu_" << sDmu << gain[gn] <<
"_BCID_err";
306 histName = sStr.str();
309 sStr << moduleName <<
" DMU0 " << ch << gain[3 + gn] <<
" BCID errors";
310 histTitle = sStr.str();
312 m_data->m_hist_DMUerr[ros][drawer][ch][adc].push_back(
book1I(subDir, histName, histTitle, 3, -0.5, 2.5));
317 sStr << moduleName <<
"_dmu_" << sDmu <<
"_CRC_err";
318 histName = sStr.str();
321 sStr << moduleName <<
" DMU0 " << ch <<
" CRC errors";
322 histTitle = sStr.str();
324 m_data->m_hist_DMUerr[ros][drawer][ch][0].push_back(
book1I(subDir, histName, histTitle, 5, -0.5, 4.5));
333 sStr << moduleName <<
"_CRC_global";
334 histName = sStr.str();
337 sStr << moduleName <<
" global CRC errors";
338 histTitle = sStr.str();
340 m_data->m_hist0[ros][drawer].push_back(
book1S(
"Summary", histName, histTitle, 3, -0.5, 2.5));
367 if (digitsCollection->empty())
continue;
369 HWIdentifier adc_id = digitsCollection->front()->adc_HWID();
373 if (
m_data->m_hist1[ros][drawer][0][0].size() == 0) {
375 m_nSamples = digitsCollection->front()->NtimeSamples();
379 uint32_t status = digitsCollection->getFragStatus();
387 for (
int dmu = 0; dmu < 16; dmu++) {
388 m_data->m_corrup[ros][drawer][0][dmu] =
true;
389 m_data->m_corrup[ros][drawer][1][dmu] =
true;
390 m_data->m_hist2[ros][drawer][0][0]->Fill(dmu + 0.5,
bin, 1.);
391 m_data->m_hist2[ros][drawer][1][0]->Fill(dmu + 0.5,
bin, 1.);
396 std::vector<uint32_t> headerVec = digitsCollection->getFragChipHeaderWords();
398 int headsize = headerVec.size();
400 ATH_MSG_ERROR(
"length of BCID vector " << headsize <<
" - greater than 16 !");
404 for (
int dmu = 0; dmu < headsize; dmu++) {
409 for (
int dmu = headsize; dmu < 16; dmu++) {
410 m_data->m_corrup[ros][drawer][0][dmu] =
false;
411 m_data->m_corrup[ros][drawer][1][dmu] =
false;
417 if (digitsCollection->empty())
continue;
419 HWIdentifier adc_id = digitsCollection->front()->adc_HWID();
423 if (
m_data->m_hist1[ros][drawer][0][0].size() == 0) {
427 m_nSamples = digitsCollection->front()->NtimeSamples();
431 std::vector<uint32_t> headerVec = digitsCollection->getFragChipHeaderWords();
433 int headsize = headerVec.size();
440 double mean_tmp[48][2][16];
441 memset(mean_tmp, 0,
sizeof(mean_tmp));
453 for (
const TileDigits* tileDigits : *digitsCollection) {
455 adc_id = tileDigits->adc_HWID();
461 std::vector<float> vdigits = tileDigits->samples();
463 double meansamp = 0.0;
464 double rmssamp = 0.0;
465 unsigned int dsize = vdigits.size();
467 ATH_MSG_ERROR(
"length of digits vector " << dsize <<
" - greater than 16 !");
471 for (
unsigned int i = 0; i < dsize; ++i) {
472 double dig = vdigits[i];
474 rmssamp += dig * dig;
475 mean_tmp[chan][gain][i] = dig;
477 if (!
m_data->m_corrup[ros][drawer][gain][chan / 3]) {
479 m_data->m_histP[ros][drawer][chan][gain][0]->Fill(i + 0.1, dig, 1.0);
480 m_data->m_hist1[ros][drawer][chan][gain][2]->Fill(dig, 1.0);
481 }
else if (
m_cispar[6] > 0. && (dig > 0 || gain < 1 ||
charge < 12.)) {
482 m_data->m_histP[ros][drawer][chan][gain][0]->Fill(i + 0.1, dig, 1.0);
483 m_data->m_hist1[ros][drawer][chan][gain][2]->Fill(dig, 1.0);
491 if (dsize > 0 && !
m_data->m_corrup[ros][drawer][gain][chan / 3]) {
492 double ped = vdigits[0];
493 m_data->m_hist1[ros][drawer][chan][gain][0]->Fill(ped, 1.0);
494 m_data->m_sumPed1[ros][drawer][chan][gain] += ped;
495 m_data->m_sumPed2[ros][drawer][chan][gain] += ped * ped;
502 rmssamp = rmssamp / dsize - meansamp * meansamp;
503 rmssamp = (rmssamp > 0.0) ? sqrt(rmssamp * dsize / (dsize - 1)) : 0.0;
504 m_data->m_hist1[ros][drawer][chan][gain][1]->Fill(rmssamp, 1.0);
505 m_data->m_sumRms1[ros][drawer][chan][gain] += rmssamp;
506 m_data->m_sumRms2[ros][drawer][chan][gain] += rmssamp * rmssamp;
512 for (
int sample = 0; sample <
m_nSamples; ++sample) {
513 for (
int gain = 0; gain < 2; ++gain) {
514 for (
int ch_i = 0; ch_i < 48; ++ch_i)
515 if (!
m_data->m_corrup[ros][drawer][gain][ch_i / 3]) {
516 m_data->m_nEvents_i[ros][drawer][gain][ch_i]++;
517 m_data->m_meanAmp[ros][drawer][gain][ch_i] += mean_tmp[ch_i][gain][sample];
518 for (
int ch_j = 0; ch_j < 48; ++ch_j)
519 if (!
m_data->m_corrup[ros][drawer][gain][ch_j / 3]) {
520 m_data->m_nEvents_ij[ros][drawer][gain][ch_i][ch_j]++;
521 m_data->m_meanAmp_ij[ros][drawer][gain][ch_i][ch_j] += mean_tmp[ch_i][gain][sample] * mean_tmp[ch_j][gain][sample];
528 uint32_t bcid = digitsCollection->getRODBCID();
530 for (
int ch = 0; ch < headsize; ++ch) {
531 uint32_t bcid_ch = (headerVec[ch] & 0xFFF);
532 m_data->m_hist1[ros][drawer][ch][0][3]->Fill(bcid_ch, 1.0);
533 if ((bcid_ch == bcid) || (bcid_ch == bcid - 1))
534 m_data->m_hist_DMUerr[ros][drawer][ch][0][0]->Fill(1.0, 1.0);
535 else if ((bcid == 0) && ((bcid_ch == 3563) || (bcid_ch == 3564)))
536 m_data->m_hist_DMUerr[ros][drawer][ch][0][0]->Fill(1.0, 1.0);
547 if ((
m_bigain) && ((digitsCollection->getFragChipHeaderWordsHigh()).size() > 0)) {
549 headerVec = digitsCollection->getFragChipHeaderWordsHigh();
550 headsize = headerVec.size();
552 ATH_MSG_ERROR(
"length of BCIDhigh vector " << headsize <<
" - greater than 16 !");
557 for (
int ch = 0; ch < headsize; ++ch) {
558 uint32_t bcid_ch = (headerVec[ch] & 0xFFF);
559 m_data->m_hist1[ros][drawer][ch][1][3]->Fill(bcid_ch, 1.0);
560 if ((bcid_ch == bcid) || (bcid_ch == bcid - 1))
561 m_data->m_hist_DMUerr[ros][drawer][ch][1][0]->Fill(1.0, 1.0);
562 else if ((bcid == 0) && ((bcid_ch == 3563) || (bcid_ch == 3564)))
563 m_data->m_hist_DMUerr[ros][drawer][ch][1][0]->Fill(1.0, 1.0);
576 uint32_t crc32 = digitsCollection->getFragCRC();
577 uint32_t CRCmask = digitsCollection->getFragDMUMask();
579 CRCcheck(dqStatus, crc32, CRCmask, headsize, ros, drawer);
588 return StatusCode::SUCCESS;
600 const EventContext &ctx = Gaudi::Hive::currentContext();
602 const char *part[5] = {
"AUX",
"LBA",
"LBC",
"EBA",
"EBC" };
603 const char *gain[6] = {
"_lo",
"_hi",
"",
" low gain",
" high gain",
"" };
605 std::string pedestalTitile(
" Pedestal[0]");
608 const char *HistName[8] = {
"_ped",
"_rms_lfr",
"_rms_hfr",
"_bits"
609 , pedestalTitile.c_str(),
" RMS noise low frequency",
" RMS noise high frequency",
" Stuck bits and zero amp" };
611 const char *ErrName[4] = {
"_bcid",
"_crc",
" BCID errors",
" CRC errors" };
612 const char *HistName2[4] = {
"_covar",
"_corr",
" covariance",
" correlation" };
621 if (
m_data->m_hist1[ros][drawer][0][0].size() != 0) {
624 std::ostringstream sStr;
626 std::string subDir =
"Summary";
627 std::string histName, histTitle;
629 for (
int gn = mingain; gn < maxgain; ++gn) {
635 sStr << moduleName << gain[gn] << HistName[
type];
636 histName = sStr.str();
638 sStr << moduleName << gain[3 + gn] << HistName[4 +
type];
639 histTitle = sStr.str();
640 m_data->m_final_hist1[ros][drawer][adc].push_back(
book1F(subDir, histName, histTitle, 48, 0.0, 48.0));
645 sStr << moduleName << gain[gn] <<
"_stucks";
646 histName = sStr.str();
648 sStr << moduleName << gain[3 + gn] <<
" Stuck bits and saturation";
649 histTitle = sStr.str();
650 m_data->m_final_hist_stucks[ros][drawer][adc] =
book2C(subDir, histName, histTitle, 48, 0.0, 48.0, 7, 0., 7.);
651 m_data->m_final_hist_stucks[ros][drawer][adc]->GetYaxis()->SetBinLabel(1,
"SB 0");
652 m_data->m_final_hist_stucks[ros][drawer][adc]->GetYaxis()->SetBinLabel(2,
"SB 1,2");
653 m_data->m_final_hist_stucks[ros][drawer][adc]->GetYaxis()->SetBinLabel(3,
"SB 3,4");
654 m_data->m_final_hist_stucks[ros][drawer][adc]->GetYaxis()->SetBinLabel(4,
"SB 5-9");
655 m_data->m_final_hist_stucks[ros][drawer][adc]->GetYaxis()->SetBinLabel(5,
"zeros");
656 m_data->m_final_hist_stucks[ros][drawer][adc]->GetYaxis()->SetBinLabel(6,
"saturation");
657 m_data->m_final_hist_stucks[ros][drawer][adc]->GetYaxis()->SetBinLabel(7,
"n % 32");
663 double Ped = 0.0, PedRMS = 0.0, RMSHi = 0.0;
665 int nevents = int(
m_data->m_hist1[ros][drawer][channel][adc][0]->GetEntries());
666 bool fillPedAndRms = (nevents > 0);
681 ATH_MSG_VERBOSE(
"Number of entries in histo " <<
m_data->m_hist1[ros][drawer][channel][adc][0]->GetTitle()
682 <<
" doesnt match n. of events! Using the first one in mean and RMS calculation" );
693 Ped =
m_data->m_sumPed1[ros][drawer][channel][adc] / nevents;
694 RMSHi =
m_data->m_sumRms1[ros][drawer][channel][adc] / nevents;
697 PedRMS =
m_data->m_sumPed2[ros][drawer][channel][adc] / nevents - Ped * Ped;
698 PedRMS = (PedRMS > 0.0) ? sqrt(PedRMS * nevents / (nevents - 1)) : 0.0;
714 m_data->m_final_hist1[ros][drawer][adc][0]->SetBinError(channel + 1, PedRMS);
718 m_data->m_final_hist1[ros][drawer][adc][0]->SetBinContent(channel + 1, Ped);
719 m_data->m_final_hist1[ros][drawer][adc][0]->SetBinError(channel + 1, PedRMS);
722 m_data->m_final_hist1[ros][drawer][adc][1]->SetBinContent(channel + 1, PedRMS);
723 m_data->m_final_hist1[ros][drawer][adc][2]->SetBinContent(channel + 1, RMSHi);
730 TH1S * hist =
m_data->m_hist1[ros][drawer][channel][adc][2];
733 weight += hist->GetBinContent(i);
737 if (hist->GetBinContent(1) > 0) {
748 m_data->m_final_hist1[ros][drawer][adc][3]->SetBinContent(channel + 1, weight);
750 m_data->m_final_hist_stucks[ros][drawer][adc], channel,
751 m_data->m_stuck_probs[ros][drawer][channel][adc]);
756 sStr << moduleName << gain[gn] << ErrName[0];
757 histName = sStr.str();
759 sStr << moduleName << gain[3 + gn] << ErrName[2];
760 histTitle = sStr.str();
761 m_data->m_final_hist1[ros][drawer][adc].push_back(
book1F(subDir, histName, histTitle, 16, 0.0, 16.0));
766 sStr << moduleName << ErrName[1];
767 histName = sStr.str();
769 sStr << moduleName << ErrName[3];
770 histTitle = sStr.str();
771 m_data->m_final_hist1[ros][drawer][adc].push_back(
book1F(subDir, histName, histTitle, 16, 0.0, 16.0));
774 for (
int ch = 0; ch < 16; ++ch) {
779 for (
int id = 0;
id < 2; ++id) {
780 int bin0 = lround(
m_data->m_hist_DMUerr[ros][drawer][ch][adc][
id]->GetBinContent(0));
781 int bin1 = lround(
m_data->m_hist_DMUerr[ros][drawer][ch][adc][
id]->GetBinContent(1));
782 int bin2 = lround(
m_data->m_hist_DMUerr[ros][drawer][ch][adc][
id]->GetBinContent(2));
783 int bin3 = lround(
m_data->m_hist_DMUerr[ros][drawer][ch][adc][
id]->GetBinContent(3));
784 int bin4 = lround(
m_data->m_hist_DMUerr[ros][drawer][ch][adc][
id]->GetBinContent(4));
785 int bin5 = lround(
m_data->m_hist_DMUerr[ros][drawer][ch][adc][
id]->GetBinContent(5));
786 double weight = -1.0;
788 if (bin0 +
bin3 + bin4 + bin5 > 0) {
789 if ((bin4 == 0) && (bin5 == 0)) {
791 }
else if ((
bin3 == 0) && (bin5 == 0)) {
800 }
else if (bin1 == 0) {
804 if (weight > 0.8) weight = 0.8;
807 m_data->m_final_hist1[ros][drawer][adc][
id + 4]->SetBinContent(dmu, weight);
818 sStr << moduleName << gain[gn] << HistName2[
type];
819 histName = sStr.str();
821 sStr << moduleName << gain[3 + gn] << HistName2[2 +
type];
822 histTitle = sStr.str();
823 m_data->m_final_hist2[ros][drawer][adc].push_back(
book2F(subDir, histName, histTitle, 48, 0.0, 48.0, 48, 0.0, 48.0));
828 for (
int ch_i = 0; ch_i < 48; ++ch_i) {
829 if (
m_data->m_nEvents_i[ros][drawer][adc][ch_i] > 0)
830 m_data->m_meanAmp[ros][drawer][adc][ch_i] /=
m_data->m_nEvents_i[ros][drawer][adc][ch_i];
831 for (
int ch_j = 0; ch_j < 48; ++ch_j)
832 if (
m_data->m_nEvents_ij[ros][drawer][adc][ch_i][ch_j] > 0)
833 m_data->m_meanAmp_ij[ros][drawer][adc][ch_i][ch_j] /=
m_data->m_nEvents_ij[ros][drawer][adc][ch_i][ch_j];
837 double covar[48][48];
841 double mean_cov_ii = 0.;
842 double mean_cov_ij = 0.;
844 for (
int ch_i = 0; ch_i < 48; ++ch_i) {
846 for (
int ch_j = 0; ch_j < 48; ++ch_j) {
848 covar[ch_i][ch_j] =
m_data->m_meanAmp_ij[ros][drawer][adc][ch_i][ch_j] -
m_data->m_meanAmp[ros][drawer][adc][ch_i] *
m_data->m_meanAmp[ros][drawer][adc][ch_j];
851 mean_cov_ij += covar[ch_i][ch_j];
855 mean_cov_ii += covar[ch_i][ch_i];
857 if (covar[ch_i][ch_i] != 0.0)
858 mean_rms[ch_i] = covar[ch_i][ch_i] / sqrt(TMath::Abs(covar[ch_i][ch_i]));
863 if (mean_cov_ii != 0.) {
864 m_data->m_cov_ratio[ros][drawer][adc] = (2. * mean_cov_ij) / (mean_cov_ii * 47.);
866 m_data->m_cov_ratio[ros][drawer][adc] = 0.;
870 for (
int i = 0; i < 48; ++i) {
871 for (
int j = 0; j < 48; ++j) {
872 if ((mean_rms[i] == 0.) || (mean_rms[j] == 0.)) {
875 corr[i][j] = covar[i][j] / mean_rms[i] / mean_rms[j];
877 m_data->m_final_hist2[ros][drawer][adc][0]->SetBinContent(i + 1, j + 1, covar[i][j]);
878 m_data->m_final_hist2[ros][drawer][adc][1]->SetBinContent(i + 1, j + 1, corr[i][j]);
891 for (
int gn = mingain; gn < maxgain; ++gn) {
892 for (
int i = 0; i < 48; ++i) {
893 TH1S *
h = (TH1S*)
m_data->m_hist1[ros][drawer][i][gn][2]->Clone(
"temphist");
898 double shiftxmin = 0.;
902 std::ostringstream s;
903 s << part[ros] << std::setfill(
'0') << std::setw(2) << drawer + 1 << std::setfill(
' ');
904 std::string moduleName = s.str();
905 std::string subDir = moduleName;
908 s << moduleName << gain[gn] <<
"_samples_ref";
909 std::string histName = s.str();
912 s << moduleName << gain[3 + gn] <<
" all samples reference";
913 std::string histTitle = s.str();
915 m_data->m_shifted_hist[ros][drawer][48][gn] =
book1S(subDir, histName, histTitle, shiftnbins, shiftxmin, shiftxmax);
926 return StatusCode::SUCCESS;
953 if (ncolors == 51 && colors == 0) {
954 TColor::InitializeColors();
956 Double_t stops[nRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
957 Double_t
red[nRGBs] = { 0.00, 0.09, 0.18, 0.09, 0.00 };
958 Double_t
green[nRGBs] = { 0.01, 0.02, 0.39, 0.68, 0.97 };
959 Double_t blue[nRGBs] = { 0.17, 0.39, 0.62, 0.79, 0.97 };
960 ind = TColor::CreateGradientColorTable(nRGBs, stops,
red,
green, blue,
m_NCont, alpha);
964 else if (ncolors == 52 && colors == 0) {
965 TColor::InitializeColors();
967 Double_t stops[nRGBs] = { 0.00, 0.50, 1.00 };
968 Double_t
red[nRGBs] = { 0.90, 0.50, 0.10 };
969 Double_t
green[nRGBs] = { 0.90, 0.50, 0.10 };
970 Double_t blue[nRGBs] = { 0.90, 0.50, 0.10 };
971 ind = TColor::CreateGradientColorTable(nRGBs, stops,
red,
green, blue,
m_NCont, alpha);
985 double ms = (
m_bigain) ? 0.75 : 1.0;
987 static bool palette_init_done =
false;
990 static TExec *ex_pal51;
991 static TExec *ex_pal52;
994 if (palette_init_done ==
false) {
995 palette_init_done =
true;
998 if (ind < 0) ind = 0;
1002 if (ind < 0) ind = 0;
1006 s.Form(
"gStyle->SetPalette(%d,(int*)%ld);",
m_NCont, (
long) pal51);
1007 ex_pal51 =
new TExec(
"ex_pal51", s.Data());
1008 s.Form(
"gStyle->SetPalette(%d,(int*)%ld);",
m_NCont, (
long) pal52);
1009 ex_pal52 =
new TExec(
"ex_pal52", s.Data());
1013 double line[8] = { 1.2, 2.5, 1.0, 1.0, 48.0, 48.0, 48.0, 16.0 };
1014 double miny[12] = { 20.0, 20.0, 0.0, 0.0, 0.0, 0.0, -0.1, -0.1, -0.1, -0.1, -0.1, -0.1 };
1015 double maxy[12] = { 80.0, 80.0, 1.5, 3.0, 1.5, 3.0, 2.2, 2.2, 2.2, 2.2, 3.2, 2.2 };
1018 miny[0] = miny[1] = -5.0;
1019 maxy[0] = maxy[1] = 5.0;
1022 TText *t =
new TText();
1023 t->SetTextAlign(32);
1024 t->SetTextSize(0.06);
1029 for (
int ind = 0; ind < 12; ind += 2) {
1030 miny[ind] = miny[ind + 1] = std::min(miny[ind], miny[ind + 1]);
1031 maxy[ind] = maxy[ind + 1] = std::max(maxy[ind], maxy[ind + 1]);
1037 maxline[
type]->SetLineColor(2 +
type / 2);
1040 TCanvas * Can = NULL;
1042 Can =
new TCanvas(
"dig_noise",
"dig_noise", 402 * maxgain, 588);
1043 Can->Divide(maxgain, 3);
1044 gStyle->SetOptStat(0);
1045 gStyle->SetTitleFontSize(0.1);
1048 for (
int gain = 0; gain < maxgain; ++gain) {
1052 TVirtualPad * pad = Can->cd(
type * maxgain + gain + 1);
1053 pad->SetTopMargin(0.15);
1056 int ind =
type * 2 + gain;
1058 if (
m_data->m_final_hist1[ros][drawer][gain][
type]->GetMaximum() < 0.9 * maxy[ind])
1059 m_data->m_final_hist1[ros][drawer][gain][
type]->SetMaximum(maxy[ind]);
1060 if (
m_data->m_final_hist1[ros][drawer][gain][
type]->GetMinimum() > (miny[ind] + 0.1 * TMath::Abs(miny[ind])))
1061 m_data->m_final_hist1[ros][drawer][gain][
type]->SetMinimum(miny[ind]);
1063 m_data->m_final_hist1[ros][drawer][gain][
type]->SetMarkerStyle(21);
1064 m_data->m_final_hist1[ros][drawer][gain][
type]->SetMarkerSize(ms);
1065 m_data->m_final_hist1[ros][drawer][gain][
type]->SetLabelSize(0.08,
"X");
1066 m_data->m_final_hist1[ros][drawer][gain][
type]->SetLabelSize(0.08,
"Y");
1068 m_data->m_final_hist1[ros][drawer][gain][
type]->Draw(
"P0");
1069 if (
type > 0) maxline[gain]->Draw();
1075 Can->Print(TString(moduleName +
"_dig_noise.png"),
"png");
1078 Can->Print(TString(moduleName +
"_dig_noise.ps"),
"ps");
1081 Can->Print(TString(moduleName +
"_dig_noise.svg"),
"svg");
1086 Can =
new TCanvas(
"dig_errors",
"dig_errors", 402 * maxgain, 588);
1087 Can->Divide(maxgain, 4);
1088 gStyle->SetOptStat(1);
1089 gStyle->SetTitleFontSize(0.1);
1092 for (
int gain = 0; gain < maxgain; ++gain) {
1095 TVirtualPad * pad = NULL;
1097 pad = Can->cd((
type - 3) * maxgain + gain + 1);
1098 pad->SetTopMargin(0.15);
1100 int ind =
type * 2 + gain;
1102 if (
type == 5 && gain == 1) {
1103 if (do_plots) pad->SetLogy();
1105 m_data->m_hist0[ros][drawer][0]->SetStats(kFALSE);
1106 gStyle->SetStatFontSize(0.1);
1107 m_data->m_hist0[ros][drawer][0]->SetStats(kTRUE);
1108 m_data->m_hist0[ros][drawer][0]->SetLabelSize(0.08,
"X");
1109 m_data->m_hist0[ros][drawer][0]->SetLabelSize(0.08,
"Y");
1110 if (do_plots)
m_data->m_hist0[ros][drawer][0]->Draw();
1113 if (do_plots) pad->SetGridx();
1115 if (
m_data->m_final_hist1[ros][drawer][gain][
type]->GetMaximum() < 0.9 * maxy[ind])
1116 m_data->m_final_hist1[ros][drawer][gain][
type]->SetMaximum(maxy[ind]);
1117 if (
m_data->m_final_hist1[ros][drawer][gain][
type]->GetMinimum() > (miny[ind] + 0.1 * TMath::Abs(miny[ind])))
1118 m_data->m_final_hist1[ros][drawer][gain][
type]->SetMinimum(miny[ind]);
1120 m_data->m_final_hist1[ros][drawer][gain][
type]->SetMarkerStyle(21);
1121 m_data->m_final_hist1[ros][drawer][gain][
type]->SetMarkerSize(ms);
1122 m_data->m_final_hist1[ros][drawer][gain][
type]->SetStats(kFALSE);
1123 m_data->m_final_hist1[ros][drawer][gain][
type]->SetLabelSize(0.08,
"X");
1124 m_data->m_final_hist1[ros][drawer][gain][
type]->SetLabelSize(0.08,
"Y");
1126 if (do_plots)
m_data->m_final_hist1[ros][drawer][gain][
type]->Draw(
"P0");
1128 m_data->m_final_hist_stucks[ros][drawer][gain]->SetStats(kFALSE);
1129 m_data->m_final_hist_stucks[ros][drawer][gain]->SetMarkerSize(3.);
1130 m_data->m_final_hist_stucks[ros][drawer][gain]->SetMarkerColor(4);
1131 m_data->m_final_hist_stucks[ros][drawer][gain]->SetLabelSize(0.08,
"X");
1132 m_data->m_final_hist_stucks[ros][drawer][gain]->SetLabelSize(0.1,
"Y");
1133 gStyle->SetNumberContours(
m_NCont);
1135 m_data->m_final_hist_stucks[ros][drawer][gain]->Draw(
"textzcol");
1137 m_data->m_final_hist_stucks[ros][drawer][gain]->Draw(
"textcolzsame");
1139 TPaletteAxis *palette = (TPaletteAxis*)
m_data->m_final_hist_stucks[ros][drawer][gain]->GetListOfFunctions()->FindObject(
"palette");
1140 if (palette != NULL) palette->SetLabelSize(0.07);
1144 if (
type == 4 || (
type == 5 && gain == 0)) {
1145 m_data->m_final_hist1[ros][drawer][gain][
type]->GetYaxis()->SetLabelOffset(-0.85);
1147 t->DrawText(-0.2, 1.,
"all OK");
1148 t->DrawText(-0.2, .0,
"wrong");
1150 t->DrawText(-0.2, 2.,
"mismatch");
1152 t->DrawText(-0.2, 2.,
"FE fail");
1153 t->DrawText(-0.2, 2.5,
"FE+ROD fail");
1154 t->DrawText(-0.2, 3.,
"ROD fail");
1161 if (
type != 3)
if (do_plots) maxline[3]->Draw();
1165 TVirtualPad * pad = NULL;
1167 pad = Can->cd(6 + gain + 1);
1168 pad->SetTopMargin(0.15);
1171 m_data->m_hist2[ros][drawer][gain][0]->SetMarkerSize(3.);
1172 m_data->m_hist2[ros][drawer][gain][0]->SetMarkerColor(2);
1173 m_data->m_hist2[ros][drawer][gain][0]->SetLabelSize(0.11,
"Y");
1174 m_data->m_hist2[ros][drawer][gain][0]->SetLabelSize(0.08,
"X");
1175 m_data->m_hist2[ros][drawer][gain][0]->SetStats(kFALSE);
1176 m_data->m_hist2[ros][drawer][gain][0]->GetYaxis()->SetBinLabel(1,
"OK ");
1177 m_data->m_hist2[ros][drawer][gain][0]->GetYaxis()->SetBinLabel(2,
"Format");
1178 m_data->m_hist2[ros][drawer][gain][0]->GetYaxis()->SetBinLabel(3,
"Parity");
1179 m_data->m_hist2[ros][drawer][gain][0]->GetYaxis()->SetBinLabel(4,
"Memory");
1180 m_data->m_hist2[ros][drawer][gain][0]->GetYaxis()->SetBinLabel(5,
"SingleStr");
1181 m_data->m_hist2[ros][drawer][gain][0]->GetYaxis()->SetBinLabel(6,
"DbleStr");
1182 m_data->m_hist2[ros][drawer][gain][0]->GetYaxis()->SetBinLabel(7,
"DummyFrag");
1183 m_data->m_hist2[ros][drawer][gain][0]->GetYaxis()->SetBinLabel(8,
"NoDataFrag");
1184 m_data->m_hist2[ros][drawer][gain][0]->GetYaxis()->SetTickLength(0.01);
1185 m_data->m_hist2[ros][drawer][gain][0]->GetYaxis()->SetLabelOffset(0.001);
1187 gStyle->SetNumberContours(
m_NCont);
1188 m_data->m_hist2[ros][drawer][gain][0]->Draw(
"textzcol");
1190 m_data->m_hist2[ros][drawer][gain][0]->Draw(
"textzcolsame");
1192 TPaletteAxis *palette = (TPaletteAxis*)
m_data->m_hist2[ros][drawer][gain][0]->GetListOfFunctions()->FindObject(
"palette");
1193 if (palette != NULL) palette->SetLabelSize(0.07);
1200 Can->Print(TString(moduleName +
"_dig_errors.png"),
"png");
1203 Can->Print(TString(moduleName +
"_dig_errors.ps"),
"ps");
1206 Can->Print(TString(moduleName +
"_dig_errors.svg"),
"svg");
1208 if (do_plots)
delete Can;
1211 delete maxline[
type];
1219 Can =
new TCanvas(
"correlation",
"correlation", 402 * maxgain, 588);
1220 Can->Divide(maxgain, 2);
1221 gStyle->SetOptStat(0);
1222 gStyle->SetPalette(1);
1223 gStyle->SetTitleFontSize(0.1);
1226 TPaveLabel covar_label[2];
1227 covar_label[0] = TPaveLabel(37., 49., 54., 56.,
"");
1228 covar_label[1] = TPaveLabel(37., 49., 54., 56.,
"");
1230 for (
int gain = 0; gain < maxgain; ++gain) {
1233 TVirtualPad * pad = Can->cd(
type * maxgain + gain + 1);
1234 pad->SetTopMargin(0.15);
1236 m_data->m_final_hist2[ros][drawer][gain][
type]->SetLabelSize(0.06,
"X");
1237 m_data->m_final_hist2[ros][drawer][gain][
type]->SetLabelSize(0.06,
"Y");
1239 m_data->m_final_hist2[ros][drawer][gain][
type]->Draw(
"COLZ");
1241 std::ostringstream label_text;
1242 label_text <<
"<C_ij>/<C_ii>= " << std::setprecision(4) <<
m_data->m_cov_ratio[ros][drawer][gain] << std::setprecision(4);
1243 covar_label[gain].SetLabel(label_text.str().c_str());
1244 covar_label[gain].SetTextSize(0.4);
1245 covar_label[gain].Draw();
1252 Can->Print(TString(moduleName +
"_correlation.png"),
"png");
1255 Can->Print(TString(moduleName +
"_correlation.ps"),
"ps");
1257 if (do_plots)
delete Can;
1260 gStyle->SetOptStat(1111);
1428 if (hist->GetEntries() < 1000)
return 0;
1430 int i, b, c, cc = 0;
1432 int last_non0, first_non0 = -1;
1433 int bc[10] = { 0 }, bv[10] = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 };
1434 double bs[10] = { 0. };
1435 int bac[10] = { 0 }, ba0[10] = { 0 }, ba1[10] = { 0 }, bas[10] = { 0 };
1439 int zero_limit, saturation_limit;
1442 cp = hist->GetBinContent(1);
1444 if (f) first_non0 = 0;
1445 for (last_non0 =
m_i_ADCmax; last_non0 >= 0; last_non0--)
1446 if (hist->GetBinContent(last_non0 + 1) > 0)
break;
1449 for (i = 1; i <= last_non0; i++) {
1452 cp = (i <
m_i_ADCmax) ? hist->GetBinContent(i + 2) : 0;
1453 if (first_non0 < 0) {
1459 for (b = 0; b < 10; b++) {
1460 if ((i & bv[b]) != ((i - 1) & bv[b])) {
1463 if ((i - 1) & bv[b])
1470 if (cc > 0) bas[b]++;
1473 cont = sqrt((
double) (c +
cm));
1474 if ((c == 0 ||
cm == 0) && (c > 0 ||
cm > 0)) {
1475 prob = erf((cont - sqrt(cont)) / sqrt(2 * cont));
1478 if (c > 0 && c < 0.25 * (cp +
cm - std::sqrt((
double) cp) - std::sqrt((
double)
cm))) {
1479 prob = 1. - (double) c / (0.25 * (cp +
cm - std::sqrt((
double) cp) - std::sqrt((
double)
cm)));
1483 for (b = 0; b < 10; b++) {
1484 if ((i & bv[b]) != ((i - 1) & bv[b]))
1489 if (f > 0 && c > 0)
continue;
1490 if (f == 0 && c == 0)
continue;
1492 for (b = 0; b < 10; b++) {
1493 if ((i & bv[b]) != ((i - 1) & bv[b]))
1494 bs[b] += (i & bv[b]) ? (c ? prob : -prob) : (c ? -prob : prob);
1501 for (b = 0; b < 10; b++)
1502 if ((i & bv[b]) != ((i - 1) & bv[b])) {
1505 if ((i - 1) & bv[b])
1513 double sb_prob[4] = {0., 0., 0., 0.};
1514 static const int sb_map[10] = {0, 1, 1, 2, 2, 3, 3, 3, 3, 3};
1515 for (b = 0; b < 10; b++) {
1516 if ((ba0[b] == 0 || ba1[b] == 0) && bac[b] > 2 && (ba0[b] + ba1[b] >= bac[b] / 2 || ba0[b] + ba1[b] > 2)) {
1518 if (outhist != NULL) {
1519 sb_prob[sb_map[b]] = 1.;
1521 if (stuck_probs != NULL)
1522 stuck_probs[b] = ba0[b] == 0 ? 100u : 200u;
1525 double bs1 = std::fabs(bs[b]) - sqrt(std::fabs(bs[b]));
1526 if (bs1 < 0.) bs1 = 0.;
1527 if ((bs1 > 0.5 * bc[b]) || (bc[b] > 7 && bs1 * 3 > bc[b])) is_stack = 1;
1528 if (outhist != NULL && bc[b] > 0) {
1530 sb_prob[sb_map[b]] = 1. - (1. - sb_prob[sb_map[b]]) * (1. - 1. * bs1 / bc[b]);
1532 if (stuck_probs != NULL)
1534 stuck_probs[b] = (uint8_t) (100. * bs1 / bc[b]);
1537 stuck_probs[b] += 100u;
1538 if (stuck_probs[b] == 100u)
1539 stuck_probs[b] = 0u;
1544 || (last_non0 == (
m_i_ADCmax + 1) / 2 - 1 && hist->GetBinContent(last_non0) > 3)) {
1548 if (stuck_probs != NULL)
1549 stuck_probs[9] = first_non0 >= 512 ? 200u : 100u;
1551 if (outhist != NULL) {
1552 outhist->Fill((
double) ch, 0., 100. * sb_prob[0]);
1553 outhist->Fill((
double) ch, 1., 100. * sb_prob[1]);
1554 outhist->Fill((
double) ch, 2., 100. * sb_prob[2]);
1555 outhist->Fill((
double) ch, 3., 100. * sb_prob[3]);
1557 if (first_non0 >= saturation_limit)
1558 outhist->Fill((
double) ch, 5., 100.);
1559 else if (last_non0 >= saturation_limit) {
1561 int saturation_entries = 0;
1563 for (i = saturation_limit + 1; i <= maxADC; ++i)
1564 saturation_entries += hist->GetBinContent(i);
1565 frac = 100. * (double) saturation_entries / hist->GetEntries();
1566 if (frac > 0. && frac < 1.) frac = 1.;
1567 if (frac > 99. && frac < 100.) frac = 99.;
1568 outhist->Fill((
double) ch, 5., frac);
1570 if (last_non0 <= zero_limit)
1571 outhist->Fill((
double) ch, 4., 100.);
1572 else if (first_non0 <= zero_limit) {
1574 int zero_entries = 0;
1575 for (i = 1; i <= zero_limit + 1; ++i)
1576 zero_entries += hist->GetBinContent(i);
1577 frac = 100. * (double) zero_entries / hist->GetEntries();
1578 if (frac > 0. && frac < 1.) frac = 1.;
1579 if (frac > 99. && frac < 100.) frac = 99.;
1580 outhist->Fill((
double) ch, 4., frac);
1582 double entries, empty_cut, full_cut;
1585 bool enough =
false;
1589 if (full_cut > 126.)
1591 if (full_cut - empty_cut < 1.)
1592 full_cut = empty_cut + 1.;
1594 for (i = 1; i <= 32; ++i) {
1595 if (modhist->GetBinContent(i) <= empty_cut)
1597 else if (modhist->GetBinContent(i) > full_cut)
1599 if (modhist->GetBinContent(i) > 64)
1602 if (mod32empty + mod32full == 32 || enough)
1603 if (mod32empty != 0 && mod32full != 0)
1604 outhist->Fill((
double) ch, 6., mod32empty);
1606 outhist->SetMaximum(100.);
1613 uint32_t crc32, uint32_t crcMask,
int headsize,
int ros,
int drawer) {
1625 if (
m_data->m_hist0[ros][drawer].size() == 0)
return;
1634 int chFE_ext[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 12, 13, 8, 9, 10, 11, 14, 15 };
1635 int chFE_sp[16] = { 11, 0, 1, 2, 3, 4, 5, 6, 12, 13, 7, 8, 9, 10, 14, 15 };
1638 uint32_t crc0 = crc32 & 0xFFFF;
1639 uint32_t crc1 = crc32 >> 16;
1641 m_data->m_hist0[ros][drawer][0]->Fill(0.0, 1.0);
1642 else if (crc0 == crc1)
1643 m_data->m_hist0[ros][drawer][0]->Fill(1.0, 1.0);
1645 m_data->m_hist0[ros][drawer][0]->Fill(2.0, 1.0);
1650 if (headsize < 16) {
1654 for (
int ch = 0; ch < headsize; ++ch) {
1656 m_data->m_hist_DMUerr[ros][drawer][ch][0][1]->Fill(0.0, 1.0);
1657 else if (crc0 == crc1)
1658 m_data->m_hist_DMUerr[ros][drawer][ch][0][1]->Fill(1.0, 1.0);
1660 m_data->m_hist_DMUerr[ros][drawer][ch][0][1]->Fill(2.0, 1.0);
1670 for (
int ch = 0; ch < headsize; ++ch) {
1671 m_data->m_hist_DMUerr[ros][drawer][ch][0][1]->Fill(0.0, 1.0);
1673 }
else if (crcMask == 0xFFFFFFFF) {
1674 for (
int ch = 0; ch < headsize; ++ch) {
1675 m_data->m_hist_DMUerr[ros][drawer][ch][0][1]->Fill(1.0, 1.0);
1678 uint32_t fe_crc = crcMask & 0xFFFF;
1679 uint32_t rod_crc = crcMask >> 16;
1680 for (
int ch = 0; ch < headsize; ++ch) {
1682 if (ros == 1 || ros == 2)
1684 if ((fe_crc >> ch & 0x1) == 0x0) flag++;
1685 }
else if (ros == 3 || ros == 4)
1687 if ((ros == 3 && drawer == 14) || (ros == 4 && drawer == 17))
1689 if ((fe_crc >> chFE_sp[ch] & 0x1) == 0x0) flag++;
1691 if ((fe_crc >> chFE_ext[ch] & 0x1) == 0x0) flag++;
1694 if ((rod_crc >> ch & 0x1) == 0x0) flag += 2;
1700 m_data->m_hist_DMUerr[ros][drawer][ch][0][1]->Fill(1.0, 1.0);
1703 m_data->m_hist_DMUerr[ros][drawer][ch][0][1]->Fill(2.0, 1.0);
1706 m_data->m_hist_DMUerr[ros][drawer][ch][0][1]->Fill(3.0, 1.0);
1709 m_data->m_hist_DMUerr[ros][drawer][ch][0][1]->Fill(4.0, 1.0);