203 printf(
"=================CbmTrdHitDensityQa====================\n");
215 printf(
"\n Event: %i\n\n", (Int_t)
fEventCounter->GetEntries());
220 Int_t nCluster =
fClusters->GetEntriesFast();
221 for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) {
225 for (Int_t iDigi = 0; iDigi < nDigisInCluster; iDigi++) {
235 title.Form(
"hd_Module_%i", moduleAddress);
238 fModuleHitMap[moduleAddress] =
new TH2I(title, title, nCols, -0.5, nCols - 0.5, nRows, -0.5, nRows - 0.5);
245 title.Form(
"hd_Module_%i_ASIC", moduleAddress);
254 Int_t iRow = fModuleDigi->
GetModuleRow(iSec, local_Row);
268 for (Int_t iDigi = 0; iDigi < nDigis; iDigi++) {
279 title.Form(
"hd_Module_%i", moduleAddress);
282 fModuleHitMap[moduleAddress] =
new TH2I(title, title, nCols, -0.5, nCols - 0.5, nRows, -0.5, nRows - 0.5);
289 title.Form(
"hd_Module_%i_ASIC", moduleAddress);
298 Int_t iRow = fModuleDigi->
GetModuleRow(iSec, local_Row);
353 std::map<Int_t, std::pair<Int_t, TH2D*>> AsicTriggerMap;
354 std::map<Int_t, std::pair<Int_t, TH2D*>>::iterator AsicTriggerMapIt;
358 Int_t nTotalAsics = 0;
359 Int_t nTotalOptLinks = 0;
360 Double_t trdTotalDataRate = 0.;
361 Double_t ratePerModule = 0;
364 outfile.Form(
"hits_per_asic.%i:%i:%i_%i.%i.%i.txt", time.GetHour(), time.GetMinute(), time.GetSecond(), time.GetDay(),
365 time.GetMonth(), time.GetYear());
375 std::vector<Int_t> fColors;
376 std::vector<Double_t> fZLevel;
377 for (Int_t i = 0; i < TColor::GetNumberOfColors(); i++) {
378 fColors.push_back(TColor::GetColorPalette(i));
380 fZLevel.push_back(
fmin + TMath::Power(10, TMath::Log10(
fmax -
fmin) / Double_t(TColor::GetNumberOfColors()) * i));
382 fZLevel.push_back(
fmin + ((
fmax -
fmin) / Double_t(TColor::GetNumberOfColors()) * i));
385 std::map<Int_t, TCanvas*> LayerMap;
386 std::map<Int_t, TCanvas*>::iterator LayerMapIt;
389 TFile* oldFile = gFile;
390 TString origpath = gDirectory->GetPath();
391 printf(
"\n%s\n", origpath.Data());
393 TString newpath = origpath;
396 newpath =
"data/result.root";
399 newpath.ReplaceAll(
"eds",
"hd_qa");
400 newpath.ReplaceAll(
":/",
"");
402 printf(
"\n%s\n", newpath.Data());
403 TFile* tempFile = NULL;
404 TFile* tempFileNumerator = NULL;
405 TFile* tempFileDenominator = NULL;
407 tempFile =
new TFile(newpath,
"update");
409 tempFileNumerator =
new TFile(
"data/result_Numerator.root",
"read");
410 if (NULL == tempFileNumerator) LOG(error) <<
"CbmTrdHitRateFastQa:: data/result_Numerator.root not found";
411 tempFileDenominator =
new TFile(
"data/result_Denominator.root",
"read");
412 if (NULL == tempFileDenominator) LOG(error) <<
"CbmTrdHitRateFastQa:: data/result_Denominator.root not found";
416 tempFile =
new TFile(newpath,
"recreate");
423 if (!gDirectory->Cd(
"TrdHitDensityQa")) gDirectory->mkdir(
"TrdHitDensityQa");
424 gDirectory->Cd(
"TrdHitDensityQa");
425 if (!gDirectory->Cd(
"Module")) gDirectory->mkdir(
"Module");
426 gDirectory->Cd(
"Module");
429 Int_t moduleAddress = -1;
436 tempFileNumerator->Get<TH2I>(
"TrdHitDensityQa/Module/" + histName)->Clone(histName +
"_numerator"));
442 tempFileDenominator->Get<TH2I>(
"TrdHitDensityQa/Module/" + histName)->Clone(histName +
"_denominator")));
457 fModuleHitMapIt->second = tempFile->Get<TH2I>(
"TrdHitDensityQa/Module/" + histName);
470 if (LayerMap.find(LayerId) == LayerMap.end()) {
475 LayerMap[LayerId] =
new TCanvas(name, title, 1000, 900);
478 TH2I* Layer =
new TH2I(name, title, 1, -4000, 4000, 1, -3500, 3500);
479 Layer->SetContour(99);
480 Layer->SetXTitle(
"x-Coordinate [mm]");
481 Layer->SetYTitle(
"y-Coordinate [mm]");
482 Layer->SetZTitle(
"Trigger/Channel [kHz]");
484 Layer->SetStats(kFALSE);
485 Layer->GetXaxis()->SetLabelSize(0.02);
486 Layer->GetYaxis()->SetLabelSize(0.02);
487 Layer->GetZaxis()->SetLabelSize(0.02);
488 Layer->GetXaxis()->SetTitleSize(0.02);
489 Layer->GetXaxis()->SetTitleOffset(1.5);
490 Layer->GetYaxis()->SetTitleSize(0.02);
491 Layer->GetYaxis()->SetTitleOffset(2);
492 Layer->GetZaxis()->SetTitleSize(0.02);
493 Layer->GetZaxis()->SetTitleOffset(-2);
494 Layer->GetZaxis()->SetRangeUser(
fmin / 1000,
fmax / 1000);
496 LayerMap[LayerId]->cd()->SetLogz(
flogScale);
497 Layer->Fill(0., 0., 0);
503 gGeoManager->FindNode(fModuleGeo->
GetX(), fModuleGeo->
GetY(), fModuleGeo->
GetZ());
505 std::vector<Int_t> AsicAddresses;
509 if (AsicTriggerMap.find(nofAsics) == AsicTriggerMap.end()) {
510 name.Form(
"hd_ASICs%03i", nofAsics);
511 title.Form(
"hd_ASICs%03d_%4.1fcmx%4.1fcm_%03dx%03dpads", nofAsics, 2 * fModuleDigi->
GetSizeX(),
513 AsicTriggerMap[nofAsics] =
514 std::make_pair(1,
new TH2D(name, title, nofAsics, -0.5, nofAsics - 0.5, nModules, -0.5, nModules - 0.5));
515 AsicTriggerMap[nofAsics].second->SetContour(99);
516 AsicTriggerMap[nofAsics].second->SetXTitle(
"ASIC Id");
517 AsicTriggerMap[nofAsics].second->SetYTitle(
"module count");
518 AsicTriggerMap[nofAsics].second->SetZTitle(
"trigger per ASIC");
521 AsicTriggerMap[nofAsics].first += 1;
527 nTotalAsics += nofAsics;
528 std::map<Int_t, Double_t> ratePerAsicMap;
529 for (Int_t iAsic = 0; iAsic < nofAsics; iAsic++) {
530 ratePerAsicMap[AsicAddresses[iAsic]] = 0.;
533 Int_t global_Row = 0;
539 for (Int_t s = 0; s < nSec; s++) {
542 for (Int_t r = 0; r < nRow; r++) {
543 for (Int_t c = 0; c < nCol; c++) {
548 Double_t local_min[3] = {padPos[0] - 0.5 * padSize[0], padPos[1] - 0.5 * padSize[1], padPos[2]};
549 Double_t local_max[3] = {padPos[0] + 0.5 * padSize[0], padPos[1] + 0.5 * padSize[1], padPos[2]};
553 local_min[0] = padPos[0] - 0.5 * padSize[1];
554 local_min[1] = padPos[1] - 0.5 * padSize[0];
555 local_max[0] = padPos[0] + 0.5 * padSize[1];
556 local_max[1] = padPos[1] + 0.5 * padSize[0];
558 for (Int_t i = 0; i < 3; i++) {
567 ratePerModule += rate;
569 ratePerAsicMap[AsicAddress] += rate;
571 LOG(error) <<
"CbmTrdHitRateFastQa::ScanModulePlane: Channel address:" << channelAddress
572 <<
" is not initialized in module " << moduleAddress <<
"(s:" << s <<
", r:" << r <<
", c:" << c
575 pad =
new TBox(local_min[0], local_min[1], local_max[0], local_max[1]);
577 pad->SetLineColor(0);
578 pad->SetLineWidth(0);
583 while ((rate > fZLevel[j]) && (j < (Int_t) fZLevel.size())) {
588 pad->SetFillColor(fColors[j]);
589 if (j == (Int_t) fZLevel.size()) pad->SetFillColor(12);
590 if (rate <
fmin) pad->SetFillColor(17);
592 LayerMap[LayerId]->cd();
600 fModuleGeo->GetX() * 10 - fModuleDigi->GetSizeX() * 10, fModuleGeo->GetY() * 10 - fModuleDigi->GetSizeY() * 10,
601 fModuleGeo->GetX() * 10 + fModuleDigi->GetSizeX() * 10, fModuleGeo->GetY() * 10 + fModuleDigi->GetSizeY() * 10);
602 module->SetFillStyle(0);
603 LayerMap[LayerId]->cd();
604 module->Draw("same");
606 for (Int_t iAsic = 0; iAsic < nofAsics; iAsic++) {
610 if (ratePerAsicMap[AsicAddresses[0]] > ratePerAsicMap[AsicAddresses[nofAsics - 1]])
611 AsicTriggerMap[nofAsics].second->SetBinContent(iAsic + 1, AsicTriggerMap[nofAsics].
first,
614 AsicTriggerMap[nofAsics].second->SetBinContent(nofAsics - iAsic, AsicTriggerMap[nofAsics].
first,
619 myfile << setfill(
' ') << setw(5) << moduleAddress <<
" " << setfill(
' ') << setw(2)
621 << util->
GetModuleType(moduleAddress, fModuleDigi,
fDigiPar) <<
" " << setfill(
'0') << setw(2) << iAsic
622 <<
" " << setiosflags(ios::fixed) << setprecision(0) << setfill(
' ') << setw(8)
623 << ratePerAsicMap[AsicAddresses[iAsic]] << endl;
638 (Int_t)(1 + dataPerModule / 4000.);
643 nTotalOptLinks += nOptLinks;
644 trdTotalDataRate += dataPerModule;
646 printf(
" --------------------------\n");
647 printf(
" total number of ASICs : %d\n", nTotalAsics);
648 printf(
" total number of optical links: %d\n", nTotalOptLinks);
649 printf(
" total TRD data rate : %.2f (Gbit/s)\n", trdTotalDataRate * 1e-3);
650 printf(
" --------------------------\n");
651 printf(
" --------------------------\n");
660 gDirectory->Cd(
"..");
661 if (!gDirectory->Cd(
"ASIC")) gDirectory->mkdir(
"ASIC");
662 gDirectory->Cd(
"ASIC");
664 for (AsicTriggerMapIt = AsicTriggerMap.begin(); AsicTriggerMapIt != AsicTriggerMap.end(); ++AsicTriggerMapIt) {
665 AsicTriggerMapIt->second.second->GetYaxis()->SetRangeUser(-0.5, AsicTriggerMapIt->second.first - 1.5);
666 AsicTriggerMapIt->second.second->GetZaxis()->SetRangeUser(0, 8.0E6);
667 AsicTriggerMapIt->second.second->Write(
"", TObject::kOverwrite);
670 gDirectory->Cd(
"..");
671 for (LayerMapIt = LayerMap.begin(); LayerMapIt != LayerMap.end(); ++LayerMapIt) {
672 LayerMapIt->second->Write(
"", TObject::kOverwrite);
673 fStation = LayerMapIt->first / 4 + 1;
674 fLayer = LayerMapIt->first % 4 + 1;
676 name.Form(
"pics/CbmTrdHitDensityQaFinal_S%i_L%i.png",
fStation,
fLayer);
680 name.Form(
"pics/CbmTrdHitDensityQa_S%i_L%i.png",
fStation,
fLayer);
681 LayerMapIt->second->SaveAs(name);
682 name.ReplaceAll(
"png",
"pdf");
683 LayerMapIt->second->SaveAs(name);
686 gDirectory->Cd(
"..");
691 gDirectory->Cd(origpath);