14 #include "TGraphErrors.h" 53 const auto &drawer = std::make_unique<JDrawer>();
54 drawer->SetLogY(logScale);
55 drawer->SetTopMargin(0.08);
58 histogram[0]->SetLineColor(color[0]);
60 histogram[0]->Scale(1.0 / histogram[0]->Integral());
61 drawer->DrawHistogram(histogram[0]);
65 for (
int iFile = 1; iFile <
kMaxFiles; iFile++) {
66 if (histogram[iFile]) {
68 histogram[iFile]->SetLineColor(color[iFile]);
70 histogram[iFile]->Scale(1.0 / histogram[iFile]->Integral());
71 histogram[iFile]->Draw(
"Same");
76 double legendX1 = 0.6;
77 double legendY1 = 0.9 - 0.07 * nHistograms;
78 double legendX2 = 0.9;
79 double legendY2 = 0.9;
80 if (legendPosition == 1) {
82 legendY1 = 0.4 - 0.07 * nHistograms + 0.07 * (nHistograms / 4);
84 legendY2 = 0.4 + 0.07 * (nHistograms / 4);
86 TLegend *
legend =
new TLegend(legendX1, legendY1, legendX2, legendY2);
93 legend->AddEntry(histogram[0], comment[0],
"l");
94 for (
int iFile = 1; iFile <
kMaxFiles; iFile++) {
95 if (histogram[iFile]) {
96 legend->AddEntry(histogram[iFile], comment[iFile],
"l");
103 gPad->GetCanvas()->SaveAs(Form(
"output/%s.pdf",
saveName));
117 double minValue = histogram[0]->GetMinimum();
118 double maxValue = histogram[0]->GetMaximum();
120 double newMinValue, newMaxValue;
122 for (
int iFile = 1; iFile <
kMaxFiles; iFile++) {
123 if (histogram[iFile]) {
124 newMinValue = histogram[iFile]->GetMinimum();
125 newMaxValue = histogram[iFile]->GetMaximum();
157 std::vector<std::string> ptHatFileList;
158 std::vector<int> ptHatList;
167 while (std::getline(ptHatFile, lineInFile)) {
168 auto stringStream = std::istringstream{lineInFile};
172 stringStream >> wordString;
173 ptHatFileList.push_back(wordString);
174 stringStream >> wordString;
175 ptHatList.push_back(std::stoi(wordString));
179 return std::make_tuple(ptHatFileList, ptHatList);
187 double ptHatWeights[] = {
203 const int nPtHat = 14;
204 int ptHatBoundaries[] = {30, 50, 80, 120, 170, 300, 470, 600, 800, 1000, 1400, 1800, 2400, 3200};
206 TFile *openFile = ptHatFiles.at(0);
208 TH1 *currentHistogram;
209 combinedHistogram->Reset(
"ICES");
212 const int nFiles = ptHatFiles.size();
214 for (
int iFile = 0; iFile <
nFiles; iFile++) {
216 for (
int iPtHat = 0; iPtHat < nPtHat; iPtHat++) {
217 if (ptHatValues.at(iFile) == ptHatBoundaries[iPtHat]) {
223 if (ptHatIndex < 0) {
224 std::cout <<
"Could not find pT hat boundary " << ptHatValues.at(iFile) <<
" for file " << ptHatFiles.at(iFile)
226 std::cout <<
"Please check your input! It needs to be in the form <fileName> <ptHatBoundary>" << std::endl;
230 openFile = ptHatFiles.at(iFile);
232 combinedHistogram->Add(currentHistogram, ptHatWeights[ptHatIndex]);
235 return combinedHistogram;
249 std::tuple<std::vector<int>, std::vector<double>, std::vector<TString>, std::vector<TString>>
runAndLumiLists(
250 const char *
inputFile,
const char *iovListMode) {
252 std::vector<int> iovVector;
253 std::vector<double> lumiPerIov;
254 std::vector<TString> iovNames;
255 std::vector<TString> iovLegend;
266 <<
" is corrupt or not existing";
267 return std::make_tuple(iovVector, lumiPerIov, iovNames, iovLegend);
271 while (std::getline(
iovList, lineInFile)) {
273 std::istringstream lineStream(lineInFile);
274 lineStream >> thisIov;
275 lineStream >> thisLumi;
278 iovVector.push_back(thisIov);
279 lumiPerIov.push_back(thisLumi);
284 iovNames.push_back(Form(
"iov%d-%d", iovVector.at(
i - 1), iovVector.at(
i) - 1));
288 TString listModeParser = iovListMode;
289 if (listModeParser.EqualTo(
"iov", TString::kIgnoreCase)) {
291 iovLegend.push_back(Form(
"IOV %d-%d", iovVector.at(
i - 1), iovVector.at(
i) - 1));
295 iovLegend.push_back(Form(
"Run %d", iovVector.at(
i)));
300 iovNames.push_back(
"all");
301 iovNames.push_back(
"central");
302 iovLegend.push_back(
"All");
303 iovLegend.push_back(
"Central");
306 return std::make_tuple(iovVector, lumiPerIov, iovNames, iovLegend);
321 std::vector<double> lumiPerIov,
322 bool skipMissingRuns) {
324 int nRuns = runGraph->GetN();
327 std::vector<double> xAxisValues, yAxisValues, xAxisErrors, yAxisErrors;
331 double lumiFactor = 1000;
337 std::vector<double> lumiPerIovWithSkips;
340 while (iRun < nRuns) {
341 runGraph->GetPoint(iRun,
runIndex, yValue);
343 if (lumiPerIov.at(iRun +
offset) == 0 || (yValue <
epsilon && skipMissingRuns)) {
345 runGraph->RemovePoint(iRun);
349 lumiPerIovWithSkips.push_back(0);
351 xValue += lumiPerIov.at(iRun +
offset) / lumiFactor;
352 xAxisValues.push_back(xValue - (lumiPerIov.at(iRun +
offset) / (lumiFactor * 2)));
353 xAxisErrors.push_back(lumiPerIov.at(iRun +
offset) / (lumiFactor * 2));
354 yAxisValues.push_back(yValue);
355 yAxisErrors.push_back(runGraph->GetErrorY(iRun));
358 lumiPerIovWithSkips.push_back(lumiPerIov.at(iRun +
offset));
365 runGraph->GetHistogram()->Delete();
366 runGraph->SetHistogram(
nullptr);
367 for (
int iRun = 0; iRun < nRuns; iRun++) {
368 runGraph->SetPoint(iRun, xAxisValues.at(iRun), yAxisValues.at(iRun));
369 runGraph->SetPointError(iRun, xAxisErrors.at(iRun), yAxisErrors.at(iRun));
372 return lumiPerIovWithSkips;
383 double lumiFactor = 1000;
385 int nRuns = lumiPerIov.size();
386 double luminosityBefore = 0;
388 for (
int iRun = 0; iRun < nRuns; iRun++) {
390 return luminosityBefore;
392 luminosityBefore += lumiPerIov.at(iRun) / lumiFactor;
395 return luminosityBefore;
407 configurationGiver->
readJsonFile(configurationFileName);
410 enum enumHistogramType { kDz, kDzError, kDxy, kDxyError, knHistogramTypes };
411 TString
histogramName[knHistogramTypes] = {
"dz",
"dzerr",
"dxy",
"dxyerr"};
412 TString histogramXaxis[knHistogramTypes] = {
413 "d_{z} (#mum)",
"#sigma(d_{z}) (#mum)",
"d_{xy} (#mum)",
"#sigma(d_{xy}) (#mum)"};
414 enum enumProfileType {
425 enum enumTrendType { kDzErrorTrend, kDxyErrorTrend, knTrendTypes };
426 TString profileName[knProfileTypes] = {
"dzErrVsPt",
434 TString profileXaxis[knProfileTypes] = {
435 "p_{T} (GeV)",
"#varphi",
"#eta",
"p_{T} (GeV)",
"#varphi",
"#eta",
"p_{T} bin",
"p_{T} bin"};
436 TString profileYaxis[knProfileTypes] = {
"d_{z}",
"d_{z}",
"d_{z}",
"d_{xy}",
"d_{xy}",
"d_{xy}",
"d_{z}",
"d_{xy}"};
437 TString trendName[] = {
"dzErr",
"dxyErr"};
438 bool drawHistogram[knHistogramTypes];
439 bool drawProfile[knProfileTypes];
440 bool drawTrend[knTrendTypes];
442 bool drawTrackQA = configurationGiver->
drawTrackQA();
444 drawHistogram[kDzError] = configurationGiver->
drawHistogram(kDzError);
445 drawProfile[kDzErrorVsPt] = configurationGiver->
drawProfile(kDzErrorVsPt);
446 drawProfile[kDzErrorVsPhi] =
448 drawProfile[kDzErrorVsEta] =
450 drawProfile[kDzErrorVsPtWide] =
452 drawHistogram[kDxy] = configurationGiver->
drawHistogram(kDxy);
453 drawHistogram[kDxyError] = configurationGiver->
drawHistogram(kDxyError);
454 drawProfile[kDxyErrorVsPt] =
456 drawProfile[kDxyErrorVsPhi] =
458 drawProfile[kDxyErrorVsEta] =
460 drawProfile[kDxyErrorVsPtWide] =
461 configurationGiver->
drawProfile(kDxyErrorVsPtWide);
463 bool drawCentralEtaSummaryProfile =
465 drawTrend[kDzErrorTrend] = configurationGiver->
drawTrend(kDzErrorTrend);
466 drawTrend[kDxyErrorTrend] = configurationGiver->
drawTrend(kDxyErrorTrend);
468 const int nMaxLegendColumns = 3;
469 double profileLegendShiftTotalX =
471 double profileLegendShiftTotalY =
473 double profileLegendShiftColumnX[nMaxLegendColumns];
474 double profileLegendShiftColumnY[nMaxLegendColumns];
475 for (
int iColumn = 0; iColumn < nMaxLegendColumns; iColumn++) {
483 TString legendTextForAllRuns =
486 double trendLegendShiftTotalX =
488 double trendLegendShiftTotalY =
494 std::vector<std::string> trendTagText = configurationGiver->
trendTagText();
515 bool drawPlotsForEachIOV =
518 bool useLuminosityForTrends =
521 bool skipRunsWithNoData =
525 int colors[] = {kBlue, kRed, kGreen + 2, kMagenta, kCyan, kViolet + 3, kOrange, kPink - 7, kSpring + 3, kAzure - 7};
528 double profileZoomLow[knProfileTypes];
529 double profileZoomHigh[knProfileTypes];
530 double trendZoomLow[knTrendTypes];
531 double trendZoomHigh[knTrendTypes];
533 for (
int iProfile = 0; iProfile < knProfileTypes; iProfile++) {
534 profileZoomLow[iProfile] = configurationGiver->
profileZoomLow(iProfile);
535 profileZoomHigh[iProfile] = configurationGiver->
profileZoomHigh(iProfile);
537 for (
int iTrend = 0; iTrend < knTrendTypes; iTrend++) {
538 trendZoomLow[iTrend] = configurationGiver->
trendZoomLow(iTrend);
539 trendZoomHigh[iTrend] = configurationGiver->
trendZoomHigh(iTrend);
542 const std::vector<double> widePtBinBorders = configurationGiver->
widePtBinBorders();
543 const int nWidePtBins = widePtBinBorders.size();
546 bool saveFigures =
true;
547 const char *saveComment = configurationGiver->
saveComment();
549 int compareFiles = configurationGiver->
nInputFiles();
550 if (compareFiles == 0)
556 if (compareFiles > 1)
561 bool loadFromList[
kMaxFiles] = {
false,
false,
false,
false};
568 for (
int iFile = 0; iFile <
kMaxFiles; iFile++) {
571 loadFromList[iFile] =
true;
572 legendComment[iFile] = configurationGiver->
legendComment(iFile);
573 fileColor[iFile] = configurationGiver->
markerColor(iFile);
574 fileMarkerStyle[iFile] = configurationGiver->
markerStyle(iFile);
575 fileMarkerSize[iFile] = configurationGiver->
markerSize(iFile);
576 copyErrorColor[iFile] =
585 int profileIndexForIovList = 0;
586 for (
int iProfile = 0; iProfile < knProfileTypes; iProfile++) {
587 if (drawProfile[iProfile]) {
588 profileIndexForIovList = iProfile;
593 TString plotTitle =
" ";
597 std::vector<int> linePosition = configurationGiver->
runsForLines();
611 TString outputFolderStatus = gSystem->GetFromPipe(
"if [ -d output ]; then echo true; else echo false; fi");
612 if (outputFolderStatus ==
"false") {
613 gSystem->Exec(
"mkdir output");
622 std::vector<std::string> ptHatFileNameList[
kMaxFiles];
623 std::vector<TFile *> ptHatFileList[
kMaxFiles];
627 for (
int iInput = 0; iInput <
kMaxFiles; iInput++) {
628 if (loadFromList[iInput]) {
632 nFiles = ptHatFileNameList[iInput].size();
633 for (
int iFile = 0; iFile <
nFiles; iFile++) {
634 ptHatFileList[iInput].push_back(TFile::Open(ptHatFileNameList[iInput].at(iFile).
data()));
644 const char *iovAndLumiFile = configurationGiver->
lumiPerIovFile();
645 const char *iovListMode = configurationGiver->
iovListMode();
648 std::vector<int> iovVector;
649 std::vector<double> lumiPerIov;
650 std::vector<double> lumiPerIovWithSkips;
651 std::vector<TString> iovNames;
652 std::vector<TString> iovLegend;
654 std::tie(iovVector, lumiPerIov, iovNames, iovLegend) =
runAndLumiLists(iovAndLumiFile, iovListMode);
656 if (iovVector.empty()) {
657 edm::LogError(
"jetHTPlotter") << __PRETTY_FUNCTION__ <<
"\n The list of input IOVs is empty. Exiting!";
662 iovLegend.pop_back();
663 iovLegend.pop_back();
664 iovLegend.push_back(legendTextForAllRuns);
665 iovLegend.push_back(Form(
"%s |#eta| < 1", legendTextForAllRuns.Data()));
672 std::ofstream iovFileForSlides;
673 if (makeIovListForSlides)
674 iovFileForSlides.open(iovListForSlides);
682 for (
int iFile = 0; iFile <
kMaxFiles; iFile++) {
683 if (compareFiles > iFile && !loadFromList[iFile])
688 const int nIov = iovNames.size();
694 TH1D *jetHtHistograms[
kMaxFiles][knHistogramTypes][nIov];
695 TProfile *jetHtProfiles[
kMaxFiles][knProfileTypes][nIov];
696 TGraphErrors *gBigTrend[
kMaxFiles][knTrendTypes][nWidePtBins];
699 for (
int iFile = 0; iFile <
kMaxFiles; iFile++) {
700 hVertex[iFile] =
nullptr;
701 hTracksPerVertex[iFile] =
nullptr;
702 hTrackPt[iFile] =
nullptr;
703 hTrackEta[iFile] =
nullptr;
704 hTrackPhi[iFile] =
nullptr;
705 for (
int iIov = 0; iIov < nIov; iIov++) {
706 for (
int iHistogramType = 0; iHistogramType < knHistogramTypes; iHistogramType++) {
707 jetHtHistograms[iFile][iHistogramType][iIov] =
nullptr;
709 for (
int iProfileType = 0; iProfileType < knProfileTypes; iProfileType++) {
710 jetHtProfiles[iFile][iProfileType][iIov] =
nullptr;
713 for (
int iTrend = 0; iTrend < knTrendTypes; iTrend++) {
714 for (
int iWidePt = 0; iWidePt < nWidePtBins; iWidePt++) {
715 gBigTrend[iFile][iTrend][iWidePt] =
nullptr;
721 for (
int iFile = 0; iFile < compareFiles; iFile++) {
722 if (loadFromList[iFile]) {
725 hVertex[iFile] = (TH1D *)
ptHatCombinedHistogram(ptHatFileList[iFile], ptHatList[iFile],
"jetHTAnalyzer/all_nvtx");
726 hTracksPerVertex[iFile] =
734 for (
int iIov = nIov - 2; iIov < nIov - 1; iIov++) {
735 for (
int iHistogramType = 0; iHistogramType < knHistogramTypes; iHistogramType++) {
736 if (drawHistogram[iHistogramType]) {
738 ptHatFileList[iFile],
740 Form(
"jetHTAnalyzer/%s_%s", iovNames.at(iIov).Data(),
histogramName[iHistogramType].Data()));
743 for (
int iProfileType = 0; iProfileType < knProfileTypes; iProfileType++) {
744 if (drawProfile[iProfileType] || (drawTrend[kDzErrorTrend] && iProfileType == kDzErrorVsPtWide) ||
745 (drawTrend[kDxyErrorTrend] && iProfileType == kDxyErrorVsPtWide)) {
747 ptHatFileList[iFile],
749 Form(
"jetHTAnalyzer/%s_%s", iovNames.at(iIov).Data(), profileName[iProfileType].Data()));
757 hVertex[iFile] = (TH1D *)
inputFile[iFile]->
Get(
"jetHTAnalyzer/all_nvtx");
758 hTracksPerVertex[iFile] = (TH1D *)
inputFile[iFile]->
Get(
"jetHTAnalyzer/h_ntrks");
759 hTrackPt[iFile] = (TH1D *)
inputFile[iFile]->
Get(
"jetHTAnalyzer/h_probePt");
760 hTrackEta[iFile] = (TH1D *)
inputFile[iFile]->
Get(
"jetHTAnalyzer/h_probeEta");
761 hTrackPhi[iFile] = (TH1D *)
inputFile[iFile]->
Get(
"jetHTAnalyzer/h_probePhi");
762 for (
int iIov = 0; iIov < nIov; iIov++) {
763 for (
int iHistogramType = 0; iHistogramType < knHistogramTypes; iHistogramType++) {
764 if (drawHistogram[iHistogramType]) {
765 jetHtHistograms[iFile][iHistogramType][iIov] = (TH1D *)
inputFile[iFile]->
Get(
766 Form(
"jetHTAnalyzer/%s_%s", iovNames.at(iIov).Data(),
histogramName[iHistogramType].Data()));
769 for (
int iProfileType = 0; iProfileType < knProfileTypes; iProfileType++) {
770 if (drawProfile[iProfileType] || (drawTrend[kDzErrorTrend] && iProfileType == kDzErrorVsPtWide) ||
771 (drawTrend[kDxyErrorTrend] && iProfileType == kDxyErrorVsPtWide)) {
772 jetHtProfiles[iFile][iProfileType][iIov] = (TProfile *)
inputFile[iFile]->
Get(
773 Form(
"jetHTAnalyzer/%s_%s", iovNames.at(iIov).Data(), profileName[iProfileType].Data()));
781 const int nRuns = iovVector.size() - 1;
782 double yValueDz[nRuns];
783 double yErrorDz[nRuns];
784 double yValueDxy[nRuns];
785 double yErrorDxy[nRuns];
786 double xValue[nRuns];
787 double xError[nRuns];
788 TString commentEntry =
"";
789 if (drawTrend[kDzErrorTrend] || drawTrend[kDxyErrorTrend]) {
790 for (
int iFile = 0; iFile < compareFiles; iFile++) {
791 for (
int iWidePt = 0; iWidePt < nWidePtBins; iWidePt++) {
792 for (
int iRun = 0; iRun < nRuns; iRun++) {
795 if (jetHtProfiles[iFile][kDzErrorVsPtWide][iRun] ==
nullptr) {
799 yValueDz[iRun] = jetHtProfiles[iFile][kDzErrorVsPtWide][iRun]->GetBinContent(iWidePt + 1);
800 yErrorDz[iRun] = jetHtProfiles[iFile][kDzErrorVsPtWide][iRun]->GetBinError(iWidePt + 1);
802 if (jetHtProfiles[iFile][kDxyErrorVsPtWide][iRun] ==
nullptr) {
806 yValueDxy[iRun] = jetHtProfiles[iFile][kDxyErrorVsPtWide][iRun]->GetBinContent(iWidePt + 1);
807 yErrorDxy[iRun] = jetHtProfiles[iFile][kDxyErrorVsPtWide][iRun]->GetBinError(iWidePt + 1);
811 gBigTrend[iFile][kDzErrorTrend][iWidePt] =
new TGraphErrors(nRuns, xValue, yValueDz, xError, yErrorDz);
812 gBigTrend[iFile][kDxyErrorTrend][iWidePt] =
new TGraphErrors(nRuns, xValue, yValueDxy, xError, yErrorDxy);
815 if (useLuminosityForTrends) {
816 lumiPerIovWithSkips =
829 const auto &drawer = std::make_unique<JDrawer>();
830 TLegend *
legend[nMaxLegendColumns];
831 int columnOrder[nMaxLegendColumns];
832 bool noIovFound =
true;
835 double minZoomY, maxZoomY;
836 int nDrawnHistograms, nLeftLegend, nRightLegend;
837 double legendX1, legendX2, legendY1, legendY2;
842 TString legendString;
844 for (
int iFile = 0; iFile <
kMaxFiles; iFile++) {
845 histogramSearchArray[iFile] =
nullptr;
851 hVertex, Form(
"vertex%s", saveComment), saveFigures, legendComment, 0, normalizeQAplots,
false, fileColor);
853 Form(
"tracksPerVertex%s", saveComment),
861 hTrackPt, Form(
"trackPt%s", saveComment), saveFigures, legendComment, 0, normalizeQAplots,
true, fileColor);
863 hTrackEta, Form(
"trackEta%s", saveComment), saveFigures, legendComment, 1, normalizeQAplots,
false, fileColor);
865 hTrackPhi, Form(
"trackPhi%s", saveComment), saveFigures, legendComment, 1, normalizeQAplots,
false, fileColor);
869 for (
int iIov = 0; iIov < nIov; iIov++) {
870 if (!drawPlotsForEachIOV && iIov < nIov - 2)
872 for (
int iHistogramType = 0; iHistogramType < knHistogramTypes; iHistogramType++) {
873 if (drawHistogram[iHistogramType]) {
874 double legendX1 = 0.6;
875 double legendY1 = 0.9 - 0.07 * compareFiles;
876 double legendX2 = 0.9;
877 double legendY2 = 0.9;
878 if (iHistogramType == kDxy || iHistogramType == kDz) {
880 legendY1 = 0.4 - 0.07 * compareFiles + 0.07 * (compareFiles / 4);
882 legendY2 = 0.4 + 0.07 * (compareFiles / 4);
885 legend[0] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
886 legend[0]->SetFillStyle(0);
887 legend[0]->SetBorderSize(0);
888 legend[0]->SetTextSize(0.05);
889 legend[0]->SetTextFont(62);
891 if (jetHtHistograms[0][iHistogramType][iIov] !=
nullptr) {
892 for (
int iFile = 0; iFile < compareFiles; iFile++) {
893 histogramSearchArray[iFile] = jetHtHistograms[iFile][iHistogramType][iIov];
897 jetHtHistograms[0][iHistogramType][iIov]->GetYaxis()->SetRangeUser(minZoomY, maxZoomY);
898 jetHtHistograms[0][iHistogramType][iIov]->SetLineColor(fileColor[0]);
900 drawer->DrawHistogram(jetHtHistograms[0][iHistogramType][iIov],
901 histogramXaxis[iHistogramType],
903 iovLegend.at(iIov).Data());
904 legend[0]->AddEntry(jetHtHistograms[0][iHistogramType][iIov], legendComment[0],
"l");
906 for (
int iFile = 1; iFile < compareFiles; iFile++) {
907 if (jetHtHistograms[iFile][iHistogramType][iIov] !=
nullptr) {
908 jetHtHistograms[iFile][iHistogramType][iIov]->SetLineColor(fileColor[iFile]);
909 jetHtHistograms[iFile][iHistogramType][iIov]->Draw(
"same");
910 legend[0]->AddEntry(jetHtHistograms[iFile][iHistogramType][iIov], legendComment[iFile],
"l");
918 gPad->GetCanvas()->SaveAs(Form(
919 "output/%s%s_%s.pdf",
histogramName[iHistogramType].Data(), saveComment, iovNames.at(iIov).Data()));
924 << Form(
"%s_%s", iovNames.at(iIov).Data(),
histogramName[iHistogramType].Data()) << std::endl;
931 for (
int iProfileType = 0; iProfileType < knProfileTypes; iProfileType++) {
932 if (drawProfile[iProfileType]) {
934 for (
int iFile = 0; iFile < compareFiles; iFile++) {
935 jetHtProfiles[iFile][iProfileType][nIov - 2]->SetLineColor(fileColor[iFile]);
936 jetHtProfiles[iFile][iProfileType][nIov - 2]->SetLineWidth(2);
937 jetHtProfiles[iFile][iProfileType][nIov - 2]->SetLineStyle(2);
938 jetHtProfiles[iFile][iProfileType][nIov - 2]->GetYaxis()->SetRangeUser(profileZoomLow[iProfileType],
939 profileZoomHigh[iProfileType]);
943 if (drawPlotsForEachIOV) {
944 for (
int iIov = 0; iIov < nIov - 2; iIov = iIov + nIovInOnePlot) {
952 for (
int iFile = 0; iFile < compareFiles; iFile++) {
954 for (
int iSamePlot = 0; iSamePlot < nIovInOnePlot; iSamePlot++) {
955 if (iIov + iSamePlot >= nIov - 2)
957 if (jetHtProfiles[iFile][iProfileType][iIov + iSamePlot] !=
nullptr) {
958 if (nIovInOnePlot > 1) {
959 if (
colors[iFile + iSamePlot] == fileColor[0])
961 jetHtProfiles[iFile][iProfileType][iIov + iSamePlot]->SetLineColor(
colors[skipColor + iSamePlot]);
963 jetHtProfiles[iFile][iProfileType][iIov + iSamePlot]->SetLineColor(fileColor[iFile + iSamePlot]);
965 jetHtProfiles[iFile][iProfileType][iIov + iSamePlot]->SetLineWidth(2);
969 << Form(
"%s_%s", iovNames.at(iIov).Data(), profileName[iProfileType].Data()) << std::endl;
986 nDrawnHistograms = drawReferenceProfile * compareFiles + nIovInOnePlot * compareFiles - nNullHistograms;
987 nLeftLegend = TMath::Ceil(nDrawnHistograms / 2.0);
988 nRightLegend = TMath::Floor(nDrawnHistograms / 2.0);
991 if (!drawReferenceProfile) {
992 if (compareFiles > 1) {
994 nRightLegend = nDrawnHistograms;
996 if (nIovInOnePlot > 1) {
997 if (nLeftLegend > nRightLegend) {
1009 if (compareFiles > 1) {
1013 if (!drawReferenceProfile) {
1021 legendX1 = 0.19 + 0.24 * drawReferenceProfile * (compareFiles > 1) + profileLegendShiftTotalX +
1022 profileLegendShiftColumnX[columnOrder[0]];
1023 legendY1 = 0.9 - (profileLegendTextSize + 0.02) * nLeftLegend + profileLegendShiftTotalY +
1024 profileLegendShiftColumnY[columnOrder[0]];
1025 legendX2 = 0.41 + 0.24 * drawReferenceProfile * (compareFiles > 1) + profileLegendShiftTotalX +
1026 profileLegendShiftColumnX[columnOrder[0]];
1027 legendY2 = 0.9 + profileLegendShiftTotalY + profileLegendShiftColumnY[columnOrder[0]];
1029 legend[0] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1030 legend[0]->SetFillStyle(0);
1031 legend[0]->SetBorderSize(0);
1032 legend[0]->SetTextSize(profileLegendTextSize);
1033 legend[0]->SetTextFont(profileLegendTextFont);
1035 legendX1 = 0.55 - 0.24 * !drawReferenceProfile * (compareFiles > 1) + profileLegendShiftTotalX +
1036 profileLegendShiftColumnX[columnOrder[1]];
1037 legendY1 = 0.9 - (profileLegendTextSize + 0.02) * nRightLegend + profileLegendShiftTotalY +
1038 profileLegendShiftColumnY[columnOrder[1]];
1039 legendX2 = 0.77 - 0.24 * !drawReferenceProfile * (compareFiles > 1) + profileLegendShiftTotalX +
1040 profileLegendShiftColumnX[columnOrder[1]];
1041 legendY2 = 0.9 + profileLegendShiftTotalY + profileLegendShiftColumnY[columnOrder[1]];
1042 legend[1] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1043 legend[1]->SetFillStyle(0);
1044 legend[1]->SetBorderSize(0);
1045 legend[1]->SetTextSize(profileLegendTextSize);
1046 legend[1]->SetTextFont(profileLegendTextFont);
1048 legendX1 = 0.13 + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[2]];
1049 legendY1 = 0.9 - (profileLegendTextSize + 0.02) * nLeftLegend + profileLegendShiftTotalY +
1050 profileLegendShiftColumnY[columnOrder[2]];
1051 legendX2 = 0.49 + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[2]];
1052 legendY2 = 0.9 + profileLegendShiftTotalY + profileLegendShiftColumnY[columnOrder[2]];
1053 legend[2] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1054 legend[2]->SetFillStyle(0);
1055 legend[2]->SetBorderSize(0);
1056 legend[2]->SetTextSize(profileLegendTextSize);
1057 legend[2]->SetTextFont(profileLegendTextFont);
1060 if (drawReferenceProfile) {
1061 for (
int iFile = 0; iFile < compareFiles; iFile++) {
1062 if (jetHtProfiles[iFile][iProfileType][nIov - 2] !=
nullptr) {
1064 drawer->DrawHistogram(jetHtProfiles[iFile][iProfileType][nIov - 2],
1065 profileXaxis[iProfileType],
1066 Form(
"#LT#sigma(%s)#GT (#mum)", profileYaxis[iProfileType].Data()),
1071 jetHtProfiles[iFile][iProfileType][nIov - 2]->Draw(
"same,HIST,C");
1073 legendString = legendTextForAllRuns.Data();
1074 if (nIovInOnePlot > 1)
1075 legendString.Append(Form(
" (%s)", legendComment[iFile].Data()));
1076 legend[0]->AddEntry(jetHtProfiles[iFile][iProfileType][nIov - 2], legendString.Data(),
"l");
1077 legend[2]->AddEntry((TObject *)
nullptr, Form(
"%s:", legendComment[iFile].Data()),
"");
1083 if (!drawReferenceProfile && (nIovInOnePlot > 1)) {
1084 legend[0]->AddEntry((TObject *)
nullptr, legendComment[0].Data(),
"");
1088 for (
int iFile = 0; iFile < compareFiles; iFile++) {
1090 for (
int iSamePlot = 0; iSamePlot < nIovInOnePlot; iSamePlot++) {
1091 if (iIov + iSamePlot >= nIov - 2)
1093 if (jetHtProfiles[iFile][iProfileType][iIov + iSamePlot] !=
nullptr) {
1095 drawer->DrawHistogram(jetHtProfiles[iFile][iProfileType][iIov + iSamePlot],
1096 profileXaxis[iProfileType],
1097 Form(
"#LT#sigma(%s)#GT (#mum)", profileYaxis[iProfileType].Data()),
1101 jetHtProfiles[iFile][iProfileType][iIov + iSamePlot]->Draw(
"same");
1105 if (compareFiles > 1) {
1106 legendString = iovLegend.at(iIov + iSamePlot).Data();
1107 if (!drawReferenceProfile)
1108 legendString.Append(Form(
" (%s)", legendComment[iFile].Data()));
1109 legend[1]->AddEntry(jetHtProfiles[iFile][iProfileType][iIov + iSamePlot], legendString.Data(),
"l");
1111 if (iHistogram + 1 == nLeftLegend)
1113 legend[iLegend]->AddEntry(
1114 jetHtProfiles[iFile][iProfileType][iIov + iSamePlot], iovLegend.at(iIov + iSamePlot),
"l");
1124 if (drawReferenceProfile && compareFiles > 1)
1129 gPad->GetCanvas()->SaveAs(Form(
"output/%s%s_iov%d-%d.pdf",
1130 profileName[iProfileType].Data(),
1133 iovVector.at(
std::min(iIov + nIovInOnePlot, nIov - 2)) - 1));
1137 if (makeIovListForSlides && (iProfileType == profileIndexForIovList)) {
1138 iovFileForSlides << Form(
"%d-%d",
1140 iovVector.at(
std::min(iIov + nIovInOnePlot, nIov - 2)) - 1)
1148 doNotDrawEta = (!drawCentralEtaSummaryProfile || iProfileType == kDxyErrorVsEta || iProfileType == kDzErrorVsEta);
1161 legendX1 = 0.48 + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[0]];
1162 legendY1 = 0.9 - (profileLegendTextSize + 0.02) * compareFiles + profileLegendShiftTotalY +
1163 profileLegendShiftColumnY[columnOrder[0]];
1164 legendX2 = 0.7 + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[0]];
1165 legendY2 = 0.9 + profileLegendShiftTotalY + profileLegendShiftColumnY[columnOrder[0]];
1166 legend[0] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1167 legend[0]->SetFillStyle(0);
1168 legend[0]->SetBorderSize(0);
1169 legend[0]->SetTextSize(profileLegendTextSize);
1170 legend[0]->SetTextFont(profileLegendTextFont);
1172 legendX1 = 0.65 - 0.25 * doNotDrawEta + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[1]];
1173 legendY1 = 0.9 - (profileLegendTextSize + 0.02) * compareFiles + profileLegendShiftTotalY +
1174 profileLegendShiftColumnY[columnOrder[1]];
1175 legendX2 = 0.87 - 0.25 * doNotDrawEta + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[1]];
1176 legendY2 = 0.9 + profileLegendShiftTotalY + profileLegendShiftColumnY[columnOrder[1]];
1177 legend[1] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1178 legend[1]->SetFillStyle(0);
1179 legend[1]->SetBorderSize(0);
1180 legend[1]->SetTextSize(profileLegendTextSize);
1181 legend[1]->SetTextFont(profileLegendTextFont);
1183 legendX1 = 0.18 + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[2]];
1184 legendY1 = 0.9 - (profileLegendTextSize + 0.02) * compareFiles + profileLegendShiftTotalY +
1185 profileLegendShiftColumnY[columnOrder[2]];
1186 legendX2 = 0.54 + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[2]];
1187 legendY2 = 0.9 + profileLegendShiftTotalY + profileLegendShiftColumnY[columnOrder[2]];
1188 legend[2] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1189 legend[2]->SetFillStyle(0);
1190 legend[2]->SetBorderSize(0);
1191 legend[2]->SetTextSize(profileLegendTextSize);
1192 legend[2]->SetTextFont(profileLegendTextFont);
1195 canvasDrawn =
false;
1196 for (
int iFile = 0; iFile < compareFiles; iFile++) {
1197 if (jetHtProfiles[iFile][iProfileType][nIov - 2] !=
nullptr) {
1198 jetHtProfiles[iFile][iProfileType][nIov - 2]->SetLineStyle(
1201 drawer->DrawHistogram(jetHtProfiles[iFile][iProfileType][nIov - 2],
1202 profileXaxis[iProfileType],
1203 Form(
"#LT#sigma(%s)#GT (#mum)", profileYaxis[iProfileType].Data()),
1207 jetHtProfiles[iFile][iProfileType][nIov - 2]->Draw(
"same");
1209 legendString = legendTextForAllRuns.Data();
1211 legendString.Append(Form(
" (%s)", legendComment[iFile].Data()));
1212 legend[1]->AddEntry(jetHtProfiles[iFile][iProfileType][nIov - 2], legendString.Data(),
"l");
1213 legend[2]->AddEntry((TObject *)
nullptr, Form(
"%s:", legendComment[iFile].Data()),
"");
1222 if (!doNotDrawEta) {
1223 for (
int iFile = 0; iFile < compareFiles; iFile++) {
1224 if (jetHtProfiles[iFile][iProfileType][nIov - 1] !=
nullptr) {
1225 jetHtProfiles[iFile][iProfileType][nIov - 1]->SetLineColor(fileColor[iFile]);
1226 jetHtProfiles[iFile][iProfileType][nIov - 1]->SetLineWidth(2);
1227 jetHtProfiles[iFile][iProfileType][nIov - 1]->SetLineStyle(2);
1228 jetHtProfiles[iFile][iProfileType][nIov - 1]->Draw(
"same,HIST,C");
1229 legend[0]->AddEntry(jetHtProfiles[iFile][iProfileType][nIov - 1],
"|#eta| < 1",
"l");
1235 if (!doNotDrawEta) {
1242 gPad->GetCanvas()->SaveAs(Form(
"output/%s%s_allIovs.pdf", profileName[iProfileType].Data(), saveComment));
1248 if (makeIovListForSlides)
1249 iovFileForSlides.close();
1252 TLegend *trendLegend;
1253 drawer->SetCanvasSize(trendCanvasWidth, trendCanvasHeight);
1254 drawer->SetLeftMargin(trendMarginLeft);
1255 drawer->SetRightMargin(trendMarginRight);
1256 drawer->SetTopMargin(trendMarginTop);
1257 drawer->SetBottomMargin(trendMarginBottom);
1258 drawer->SetTitleOffsetX(trendTitleOffsetX);
1259 drawer->SetTitleOffsetY(trendTitleOffsetY);
1260 drawer->SetTitleSizeX(trendTitleSizeX);
1261 drawer->SetTitleSizeY(trendTitleSizeY);
1262 drawer->SetLabelOffsetX(trendLabelOffsetX);
1263 drawer->SetLabelOffsetY(trendLabelOffsetY);
1264 drawer->SetLabelSizeX(trendLabelSizeX);
1265 drawer->SetLabelSizeY(trendLabelSizeY);
1270 TLatex *tagWriter =
new TLatex();
1271 tagWriter->SetTextFont(trendTagTextFont);
1272 tagWriter->SetTextSize(trendTagTextSize);
1274 TString xTitle =
"Run index";
1275 if (useLuminosityForTrends)
1276 xTitle =
"Delivered luminosity (1/fb)";
1278 for (
int iTrend = 0; iTrend < knTrendTypes; iTrend++) {
1279 if (!drawTrend[iTrend])
1281 for (
int iWidePt = 0; iWidePt < nWidePtBins; iWidePt++) {
1282 legendX1 = 0.65 + trendLegendShiftTotalX;
1283 legendY1 = 0.83 - (profileLegendTextSize + 0.02) * compareFiles + trendLegendShiftTotalY;
1284 legendX2 = 0.9 + trendLegendShiftTotalX;
1285 legendY2 = 0.9 + trendLegendShiftTotalY;
1286 trendLegend =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1287 trendLegend->SetFillStyle(0);
1288 trendLegend->SetBorderSize(0);
1289 trendLegend->SetTextSize(trendLegendTextSize);
1290 trendLegend->SetTextFont(trendLegendTextFont);
1291 trendLegend->SetHeader(
1292 Form(
"%s error trend for p_{T} > %.0f GeV", profileYaxis[iTrend + 6].Data(), widePtBinBorders.at(iWidePt)));
1294 for (
int iFile = 0; iFile < compareFiles; iFile++) {
1295 gBigTrend[iFile][iTrend][iWidePt]->SetMarkerColor(fileColor[iFile]);
1296 gBigTrend[iFile][iTrend][iWidePt]->SetMarkerStyle(fileMarkerStyle[iFile]);
1297 gBigTrend[iFile][iTrend][iWidePt]->SetMarkerSize(fileMarkerSize[iFile]);
1298 if (copyErrorColor[iFile])
1299 gBigTrend[iFile][iTrend][iWidePt]->SetLineColor(fileColor[iFile]);
1302 drawer->DrawGraphCustomAxes(gBigTrend[iFile][iTrend][iWidePt],
1305 trendZoomLow[iTrend],
1306 trendZoomHigh[iTrend],
1308 Form(
"#LT #sigma(%s) #GT", profileYaxis[iTrend + 6].Data()),
1312 gBigTrend[iFile][iTrend][iWidePt]->Draw(
"p,same");
1315 trendLegend->AddEntry(gBigTrend[iFile][iTrend][iWidePt], legendComment[iFile].Data(),
"p");
1319 trendLegend->Draw();
1322 if (drawYearLines) {
1323 for (
int thisRun : linePosition) {
1325 lumiLine =
new TLine(lumiX, trendZoomLow[iTrend], lumiX, trendZoomHigh[iTrend]);
1326 lumiLine->SetLineColor(yearLineColor);
1327 lumiLine->SetLineWidth(yearLineWidth);
1328 lumiLine->SetLineStyle(yearLineStyle);
1336 tagWriter->DrawLatexNDC(
1337 trendTagPositionX.at(iTag), trendTagPositionY.at(iTag), trendTagText.at(iTag).c_str());
1343 gPad->GetCanvas()->SaveAs(Form(
1344 "output/%sTrendPtOver%.0f%s.pdf", trendName[iTrend].Data(), widePtBinBorders.at(iWidePt), saveComment));
std::vector< std::string > trendTagText() const
bool drawProfile(const int iProfile) const
double profileLegendShiftColumnY(const int iColumn) const
double trendMarginTop() const
std::vector< double > trendTagPositionX() const
bool normalizeQAplots() const
double trendLabelSizeY() const
int yearLineColor() const
double trendMarginBottom() const
std::vector< int > runsForLines() const
double trendZoomLow(const int iTrend) const
double trendTitleOffsetY() const
bool makeIovListForSlides() const
void drawSingleHistogram(TH1D *histogram[kMaxFiles], const char *saveName, bool saveFigures, TString comment[kMaxFiles], int legendPosition, bool normalize, bool logScale, int color[kMaxFiles])
bool drawTrendTag() const
bool skipRunsWithNoData() const
bool copyErrorColor(const int iFile) const
int markerStyle(const int iFile) const
void jetHtPlotter(std::string configurationFileName)
Log< level::Error, false > LogError
int trendCanvasHeight() const
double profileLegendTextSize() const
std::tuple< std::vector< std::string >, std::vector< int > > ptHatFilesAndValues(const char *inputFile)
const char * iovListForSlides() const
double trendTitleOffsetX() const
double trendZoomHigh(const int iTrend) const
double trendLabelSizeX() const
bool useLuminosityForTrends() const
double luminosityBeforeRun(std::vector< double > lumiPerIov, std::vector< int > iovVector, int runNumber)
bool drawYearLines() const
int trendCanvasWidth() const
double trendTagTextSize() const
bool drawCentralEtaSummaryProfile() const
int trendLegendTextFont() const
bool drawTrend(const int iTrend) const
std::string legendComment(const int iComment) const
int trendTagTextFont() const
int yearLineStyle() const
bool drawHistogram(const int iHistogram) const
TH1 * ptHatCombinedHistogram(std::vector< TFile *> ptHatFiles, std::vector< int > ptHatValues, const char *histogramName)
int markerColor(const int iFile) const
std::vector< double > scaleGraphByLuminosity(TGraphErrors *runGraph, std::vector< double > lumiPerIov, bool skipMissingRuns)
const char * lumiPerIovFile() const
int profileLegendTextFont() const
int markerSize(const int iFile) const
int nIovInOnePlot() const
double trendLegendShiftTotalY() const
double profileLegendShiftColumnX(const int iColumn) const
double trendTitleSizeX() const
std::tuple< double, double > findHistogramYaxisRange(TH1D *histogram[kMaxFiles])
std::string legendTextForAllRuns() const
float normalize(float in)
double trendLabelOffsetY() const
char data[epos_bytes_allocation]
bool drawReferenceProfile() const
const char * iovListMode() const
double profileLegendShiftTotalY() const
bool drawPlotsForEachIOV() const
int yearLineWidth() const
double trendMarginRight() const
double trendLegendTextSize() const
int main(int argc, char **argv)
double profileZoomHigh(const int iProfile) const
double profileLegendShiftTotalX() const
double trendMarginLeft() const
const char * saveComment() const
double trendLabelOffsetX() const
double trendTitleSizeY() const
std::tuple< std::vector< int >, std::vector< double >, std::vector< TString >, std::vector< TString > > runAndLumiLists(const char *inputFile, const char *iovListMode)
std::vector< double > widePtBinBorders() const
void readJsonFile(const std::string fileName)
std::vector< double > trendTagPositionY() const
double trendLegendShiftTotalX() const
double profileZoomLow(const int iProfile) const
std::string inputFile(const int iFile) const