10 #include "TGraphErrors.h" 54 histogram[0]->SetLineColor(color[0]);
56 histogram[0]->Scale(1.0 / histogram[0]->Integral());
61 for (
int iFile = 1; iFile <
kMaxFiles; iFile++) {
62 if (histogram[iFile]) {
64 histogram[iFile]->SetLineColor(color[iFile]);
66 histogram[iFile]->Scale(1.0 / histogram[iFile]->Integral());
67 histogram[iFile]->Draw(
"Same");
72 double legendX1 = 0.6;
73 double legendY1 = 0.9 - 0.07 * nHistograms;
74 double legendX2 = 0.9;
75 double legendY2 = 0.9;
76 if (legendPosition == 1) {
78 legendY1 = 0.4 - 0.07 * nHistograms + 0.07 * (nHistograms / 4);
80 legendY2 = 0.4 + 0.07 * (nHistograms / 4);
82 TLegend *
legend =
new TLegend(legendX1, legendY1, legendX2, legendY2);
89 legend->AddEntry(histogram[0], comment[0],
"l");
90 for (
int iFile = 1; iFile <
kMaxFiles; iFile++) {
91 if (histogram[iFile]) {
92 legend->AddEntry(histogram[iFile], comment[iFile],
"l");
99 gPad->GetCanvas()->SaveAs(Form(
"output/%s.pdf",
saveName));
113 double minValue = histogram[0]->GetMinimum();
114 double maxValue = histogram[0]->GetMaximum();
116 double newMinValue, newMaxValue;
118 for (
int iFile = 1; iFile <
kMaxFiles; iFile++) {
119 if (histogram[iFile]) {
120 newMinValue = histogram[iFile]->GetMinimum();
121 newMaxValue = histogram[iFile]->GetMaximum();
153 std::vector<std::string> ptHatFileList;
154 std::vector<int> ptHatList;
163 while (std::getline(ptHatFile, lineInFile)) {
164 auto stringStream = std::istringstream{lineInFile};
168 stringStream >> wordString;
169 ptHatFileList.push_back(wordString);
170 stringStream >> wordString;
171 ptHatList.push_back(std::stoi(wordString));
175 return std::make_tuple(ptHatFileList, ptHatList);
183 double ptHatWeights[] = {
199 const int nPtHat = 14;
200 int ptHatBoundaries[] = {30, 50, 80, 120, 170, 300, 470, 600, 800, 1000, 1400, 1800, 2400, 3200};
202 TFile *openFile = ptHatFiles.at(0);
204 TH1 *currentHistogram;
205 combinedHistogram->Reset(
"ICES");
208 const int nFiles = ptHatFiles.size();
210 for (
int iFile = 0; iFile <
nFiles; iFile++) {
212 for (
int iPtHat = 0; iPtHat < nPtHat; iPtHat++) {
213 if (ptHatValues.at(iFile) == ptHatBoundaries[iPtHat]) {
219 if (ptHatIndex < 0) {
220 std::cout <<
"Could not find pT hat boundary " << ptHatValues.at(iFile) <<
" for file " << ptHatFiles.at(iFile)
222 std::cout <<
"Please check your input! It needs to be in the form <fileName> <ptHatBoundary>" << std::endl;
226 openFile = ptHatFiles.at(iFile);
228 combinedHistogram->Add(currentHistogram, ptHatWeights[ptHatIndex]);
231 return combinedHistogram;
245 std::tuple<std::vector<int>, std::vector<double>, std::vector<TString>, std::vector<TString>>
runAndLumiLists(
246 const char *
inputFile,
const char *iovListMode) {
248 std::vector<int> iovVector;
249 std::vector<double> lumiPerIov;
250 std::vector<TString> iovNames;
251 std::vector<TString> iovLegend;
262 while (std::getline(
iovList, lineInFile)) {
264 std::istringstream lineStream(lineInFile);
265 lineStream >> thisIov;
266 lineStream >> thisLumi;
269 iovVector.push_back(thisIov);
270 lumiPerIov.push_back(thisLumi);
275 iovNames.push_back(Form(
"iov%d-%d", iovVector.at(
i - 1), iovVector.at(
i) - 1));
279 TString listModeParser = iovListMode;
280 if (listModeParser.EqualTo(
"iov", TString::kIgnoreCase)) {
282 iovLegend.push_back(Form(
"IOV %d-%d", iovVector.at(
i - 1), iovVector.at(
i) - 1));
286 iovLegend.push_back(Form(
"Run %d", iovVector.at(
i)));
291 iovNames.push_back(
"all");
292 iovNames.push_back(
"central");
293 iovLegend.push_back(
"All");
294 iovLegend.push_back(
"Central");
297 return std::make_tuple(iovVector, lumiPerIov, iovNames, iovLegend);
312 std::vector<double> lumiPerIov,
313 bool skipMissingRuns) {
315 int nRuns = runGraph->GetN();
318 std::vector<double> xAxisValues, yAxisValues, xAxisErrors, yAxisErrors;
322 double lumiFactor = 1000;
328 std::vector<double> lumiPerIovWithSkips;
331 while (iRun < nRuns) {
332 runGraph->GetPoint(iRun,
runIndex, yValue);
334 if (lumiPerIov.at(iRun +
offset) == 0 || (yValue <
epsilon && skipMissingRuns)) {
336 runGraph->RemovePoint(iRun);
340 lumiPerIovWithSkips.push_back(0);
342 xValue += lumiPerIov.at(iRun +
offset) / lumiFactor;
343 xAxisValues.push_back(xValue - (lumiPerIov.at(iRun +
offset) / (lumiFactor * 2)));
344 xAxisErrors.push_back(lumiPerIov.at(iRun +
offset) / (lumiFactor * 2));
345 yAxisValues.push_back(yValue);
346 yAxisErrors.push_back(runGraph->GetErrorY(iRun));
349 lumiPerIovWithSkips.push_back(lumiPerIov.at(iRun +
offset));
356 runGraph->GetHistogram()->Delete();
357 runGraph->SetHistogram(
nullptr);
358 for (
int iRun = 0; iRun < nRuns; iRun++) {
359 runGraph->SetPoint(iRun, xAxisValues.at(iRun), yAxisValues.at(iRun));
360 runGraph->SetPointError(iRun, xAxisErrors.at(iRun), yAxisErrors.at(iRun));
363 return lumiPerIovWithSkips;
374 double lumiFactor = 1000;
376 int nRuns = lumiPerIov.size();
377 double luminosityBefore = 0;
379 for (
int iRun = 0; iRun < nRuns; iRun++) {
381 return luminosityBefore;
383 luminosityBefore += lumiPerIov.at(iRun) / lumiFactor;
386 return luminosityBefore;
398 configurationGiver->
readJsonFile(configurationFileName);
401 enum enumHistogramType { kDz, kDzError, kDxy, kDxyError, knHistogramTypes };
402 TString
histogramName[knHistogramTypes] = {
"dz",
"dzerr",
"dxy",
"dxyerr"};
403 TString histogramXaxis[knHistogramTypes] = {
404 "d_{z} (#mum)",
"#sigma(d_{z}) (#mum)",
"d_{xy} (#mum)",
"#sigma(d_{xy}) (#mum)"};
405 enum enumProfileType {
416 enum enumTrendType { kDzErrorTrend, kDxyErrorTrend, knTrendTypes };
417 TString profileName[knProfileTypes] = {
"dzErrVsPt",
425 TString profileXaxis[knProfileTypes] = {
426 "p_{T} (GeV)",
"#varphi",
"#eta",
"p_{T} (GeV)",
"#varphi",
"#eta",
"p_{T} bin",
"p_{T} bin"};
427 TString profileYaxis[knProfileTypes] = {
"d_{z}",
"d_{z}",
"d_{z}",
"d_{xy}",
"d_{xy}",
"d_{xy}",
"d_{z}",
"d_{xy}"};
428 TString trendName[] = {
"dzErr",
"dxyErr"};
429 bool drawHistogram[knHistogramTypes];
430 bool drawProfile[knProfileTypes];
431 bool drawTrend[knTrendTypes];
433 bool drawTrackQA = configurationGiver->
drawTrackQA();
435 drawHistogram[kDzError] = configurationGiver->
drawHistogram(kDzError);
436 drawProfile[kDzErrorVsPt] = configurationGiver->
drawProfile(kDzErrorVsPt);
437 drawProfile[kDzErrorVsPhi] =
439 drawProfile[kDzErrorVsEta] =
441 drawProfile[kDzErrorVsPtWide] =
443 drawHistogram[kDxy] = configurationGiver->
drawHistogram(kDxy);
444 drawHistogram[kDxyError] = configurationGiver->
drawHistogram(kDxyError);
445 drawProfile[kDxyErrorVsPt] =
447 drawProfile[kDxyErrorVsPhi] =
449 drawProfile[kDxyErrorVsEta] =
451 drawProfile[kDxyErrorVsPtWide] =
452 configurationGiver->
drawProfile(kDxyErrorVsPtWide);
454 bool drawCentralEtaSummaryProfile =
456 drawTrend[kDzErrorTrend] = configurationGiver->
drawTrend(kDzErrorTrend);
457 drawTrend[kDxyErrorTrend] = configurationGiver->
drawTrend(kDxyErrorTrend);
459 const int nMaxLegendColumns = 3;
460 double profileLegendShiftTotalX =
462 double profileLegendShiftTotalY =
464 double profileLegendShiftColumnX[nMaxLegendColumns];
465 double profileLegendShiftColumnY[nMaxLegendColumns];
466 for (
int iColumn = 0; iColumn < nMaxLegendColumns; iColumn++) {
474 TString legendTextForAllRuns =
477 double trendLegendShiftTotalX =
479 double trendLegendShiftTotalY =
485 std::vector<std::string> trendTagText = configurationGiver->
trendTagText();
506 bool drawPlotsForEachIOV =
509 bool useLuminosityForTrends =
512 bool skipRunsWithNoData =
516 int colors[] = {kBlue, kRed, kGreen + 2, kMagenta, kCyan, kViolet + 3, kOrange, kPink - 7, kSpring + 3, kAzure - 7};
519 double profileZoomLow[knProfileTypes];
520 double profileZoomHigh[knProfileTypes];
521 double trendZoomLow[knTrendTypes];
522 double trendZoomHigh[knTrendTypes];
524 for (
int iProfile = 0; iProfile < knProfileTypes; iProfile++) {
525 profileZoomLow[iProfile] = configurationGiver->
profileZoomLow(iProfile);
526 profileZoomHigh[iProfile] = configurationGiver->
profileZoomHigh(iProfile);
528 for (
int iTrend = 0; iTrend < knTrendTypes; iTrend++) {
529 trendZoomLow[iTrend] = configurationGiver->
trendZoomLow(iTrend);
530 trendZoomHigh[iTrend] = configurationGiver->
trendZoomHigh(iTrend);
533 const std::vector<double> widePtBinBorders = configurationGiver->
widePtBinBorders();
534 const int nWidePtBins = widePtBinBorders.size();
537 bool saveFigures =
true;
538 const char *saveComment = configurationGiver->
saveComment();
540 int compareFiles = configurationGiver->
nInputFiles();
541 if (compareFiles == 0)
547 if (compareFiles > 1)
552 bool loadFromList[
kMaxFiles] = {
false,
false,
false,
false};
559 for (
int iFile = 0; iFile <
kMaxFiles; iFile++) {
562 loadFromList[iFile] =
true;
563 legendComment[iFile] = configurationGiver->
legendComment(iFile);
564 fileColor[iFile] = configurationGiver->
markerColor(iFile);
565 fileMarkerStyle[iFile] = configurationGiver->
markerStyle(iFile);
566 fileMarkerSize[iFile] = configurationGiver->
markerSize(iFile);
567 copyErrorColor[iFile] =
576 int profileIndexForIovList = 0;
577 for (
int iProfile = 0; iProfile < knProfileTypes; iProfile++) {
578 if (drawProfile[iProfile]) {
579 profileIndexForIovList = iProfile;
584 TString plotTitle =
" ";
588 std::vector<int> linePosition = configurationGiver->
runsForLines();
602 TString outputFolderStatus = gSystem->GetFromPipe(
"if [ -d output ]; then echo true; else echo false; fi");
603 if (outputFolderStatus ==
"false") {
604 gSystem->Exec(
"mkdir output");
613 std::vector<std::string> ptHatFileNameList[
kMaxFiles];
614 std::vector<TFile *> ptHatFileList[
kMaxFiles];
618 for (
int iInput = 0; iInput <
kMaxFiles; iInput++) {
619 if (loadFromList[iInput]) {
623 nFiles = ptHatFileNameList[iInput].size();
624 for (
int iFile = 0; iFile <
nFiles; iFile++) {
625 ptHatFileList[iInput].push_back(TFile::Open(ptHatFileNameList[iInput].at(iFile).
data()));
635 const char *iovAndLumiFile = configurationGiver->
lumiPerIovFile();
636 const char *iovListMode = configurationGiver->
iovListMode();
639 std::vector<int> iovVector;
640 std::vector<double> lumiPerIov;
641 std::vector<double> lumiPerIovWithSkips;
642 std::vector<TString> iovNames;
643 std::vector<TString> iovLegend;
645 std::tie(iovVector, lumiPerIov, iovNames, iovLegend) =
runAndLumiLists(iovAndLumiFile, iovListMode);
648 iovLegend.pop_back();
649 iovLegend.pop_back();
650 iovLegend.push_back(legendTextForAllRuns);
651 iovLegend.push_back(Form(
"%s |#eta| < 1", legendTextForAllRuns.Data()));
658 std::ofstream iovFileForSlides;
659 if (makeIovListForSlides)
660 iovFileForSlides.open(iovListForSlides);
668 for (
int iFile = 0; iFile <
kMaxFiles; iFile++) {
669 if (compareFiles > iFile && !loadFromList[iFile])
674 const int nIov = iovNames.size();
680 TH1D *jetHtHistograms[
kMaxFiles][knHistogramTypes][nIov];
681 TProfile *jetHtProfiles[
kMaxFiles][knProfileTypes][nIov];
682 TGraphErrors *gBigTrend[
kMaxFiles][knTrendTypes][nWidePtBins];
685 for (
int iFile = 0; iFile <
kMaxFiles; iFile++) {
686 hVertex[iFile] =
nullptr;
687 hTracksPerVertex[iFile] =
nullptr;
688 hTrackPt[iFile] =
nullptr;
689 hTrackEta[iFile] =
nullptr;
690 hTrackPhi[iFile] =
nullptr;
691 for (
int iIov = 0; iIov < nIov; iIov++) {
692 for (
int iHistogramType = 0; iHistogramType < knHistogramTypes; iHistogramType++) {
693 jetHtHistograms[iFile][iHistogramType][iIov] =
nullptr;
695 for (
int iProfileType = 0; iProfileType < knProfileTypes; iProfileType++) {
696 jetHtProfiles[iFile][iProfileType][iIov] =
nullptr;
699 for (
int iTrend = 0; iTrend < knTrendTypes; iTrend++) {
700 for (
int iWidePt = 0; iWidePt < nWidePtBins; iWidePt++) {
701 gBigTrend[iFile][iTrend][iWidePt] =
nullptr;
707 for (
int iFile = 0; iFile < compareFiles; iFile++) {
708 if (loadFromList[iFile]) {
711 hVertex[iFile] = (TH1D *)
ptHatCombinedHistogram(ptHatFileList[iFile], ptHatList[iFile],
"jetHTAnalyzer/all_nvtx");
712 hTracksPerVertex[iFile] =
720 for (
int iIov = nIov - 2; iIov < nIov - 1; iIov++) {
721 for (
int iHistogramType = 0; iHistogramType < knHistogramTypes; iHistogramType++) {
722 if (drawHistogram[iHistogramType]) {
724 ptHatFileList[iFile],
726 Form(
"jetHTAnalyzer/%s_%s", iovNames.at(iIov).Data(),
histogramName[iHistogramType].Data()));
729 for (
int iProfileType = 0; iProfileType < knProfileTypes; iProfileType++) {
730 if (drawProfile[iProfileType] || (drawTrend[kDzErrorTrend] && iProfileType == kDzErrorVsPtWide) ||
731 (drawTrend[kDxyErrorTrend] && iProfileType == kDxyErrorVsPtWide)) {
733 ptHatFileList[iFile],
735 Form(
"jetHTAnalyzer/%s_%s", iovNames.at(iIov).Data(), profileName[iProfileType].Data()));
743 hVertex[iFile] = (TH1D *)
inputFile[iFile]->
Get(
"jetHTAnalyzer/all_nvtx");
744 hTracksPerVertex[iFile] = (TH1D *)
inputFile[iFile]->
Get(
"jetHTAnalyzer/h_ntrks");
745 hTrackPt[iFile] = (TH1D *)
inputFile[iFile]->
Get(
"jetHTAnalyzer/h_probePt");
746 hTrackEta[iFile] = (TH1D *)
inputFile[iFile]->
Get(
"jetHTAnalyzer/h_probeEta");
747 hTrackPhi[iFile] = (TH1D *)
inputFile[iFile]->
Get(
"jetHTAnalyzer/h_probePhi");
748 for (
int iIov = 0; iIov < nIov; iIov++) {
749 for (
int iHistogramType = 0; iHistogramType < knHistogramTypes; iHistogramType++) {
750 if (drawHistogram[iHistogramType]) {
751 jetHtHistograms[iFile][iHistogramType][iIov] = (TH1D *)
inputFile[iFile]->
Get(
752 Form(
"jetHTAnalyzer/%s_%s", iovNames.at(iIov).Data(),
histogramName[iHistogramType].Data()));
755 for (
int iProfileType = 0; iProfileType < knProfileTypes; iProfileType++) {
756 if (drawProfile[iProfileType] || (drawTrend[kDzErrorTrend] && iProfileType == kDzErrorVsPtWide) ||
757 (drawTrend[kDxyErrorTrend] && iProfileType == kDxyErrorVsPtWide)) {
758 jetHtProfiles[iFile][iProfileType][iIov] = (TProfile *)
inputFile[iFile]->
Get(
759 Form(
"jetHTAnalyzer/%s_%s", iovNames.at(iIov).Data(), profileName[iProfileType].Data()));
767 const int nRuns = iovVector.size() - 1;
768 double yValueDz[nRuns];
769 double yErrorDz[nRuns];
770 double yValueDxy[nRuns];
771 double yErrorDxy[nRuns];
772 double xValue[nRuns];
773 double xError[nRuns];
774 TString commentEntry =
"";
775 if (drawTrend[kDzErrorTrend] || drawTrend[kDxyErrorTrend]) {
776 for (
int iFile = 0; iFile < compareFiles; iFile++) {
777 for (
int iWidePt = 0; iWidePt < nWidePtBins; iWidePt++) {
778 for (
int iRun = 0; iRun < nRuns; iRun++) {
781 if (jetHtProfiles[iFile][kDzErrorVsPtWide][iRun] ==
nullptr) {
785 yValueDz[iRun] = jetHtProfiles[iFile][kDzErrorVsPtWide][iRun]->GetBinContent(iWidePt + 1);
786 yErrorDz[iRun] = jetHtProfiles[iFile][kDzErrorVsPtWide][iRun]->GetBinError(iWidePt + 1);
788 if (jetHtProfiles[iFile][kDxyErrorVsPtWide][iRun] ==
nullptr) {
792 yValueDxy[iRun] = jetHtProfiles[iFile][kDxyErrorVsPtWide][iRun]->GetBinContent(iWidePt + 1);
793 yErrorDxy[iRun] = jetHtProfiles[iFile][kDxyErrorVsPtWide][iRun]->GetBinError(iWidePt + 1);
797 gBigTrend[iFile][kDzErrorTrend][iWidePt] =
new TGraphErrors(nRuns, xValue, yValueDz, xError, yErrorDz);
798 gBigTrend[iFile][kDxyErrorTrend][iWidePt] =
new TGraphErrors(nRuns, xValue, yValueDxy, xError, yErrorDxy);
801 if (useLuminosityForTrends) {
802 lumiPerIovWithSkips =
816 TLegend *
legend[nMaxLegendColumns];
817 int columnOrder[nMaxLegendColumns];
818 bool noIovFound =
true;
821 double minZoomY, maxZoomY;
822 int nDrawnHistograms, nLeftLegend, nRightLegend;
823 double legendX1, legendX2, legendY1, legendY2;
828 TString legendString;
830 for (
int iFile = 0; iFile <
kMaxFiles; iFile++) {
831 histogramSearchArray[iFile] =
nullptr;
837 hVertex, Form(
"vertex%s", saveComment), saveFigures, legendComment, 0, normalizeQAplots,
false, fileColor);
839 Form(
"tracksPerVertex%s", saveComment),
847 hTrackPt, Form(
"trackPt%s", saveComment), saveFigures, legendComment, 0, normalizeQAplots,
true, fileColor);
849 hTrackEta, Form(
"trackEta%s", saveComment), saveFigures, legendComment, 1, normalizeQAplots,
false, fileColor);
851 hTrackPhi, Form(
"trackPhi%s", saveComment), saveFigures, legendComment, 1, normalizeQAplots,
false, fileColor);
855 for (
int iIov = 0; iIov < nIov; iIov++) {
856 if (!drawPlotsForEachIOV && iIov < nIov - 2)
858 for (
int iHistogramType = 0; iHistogramType < knHistogramTypes; iHistogramType++) {
859 if (drawHistogram[iHistogramType]) {
860 double legendX1 = 0.6;
861 double legendY1 = 0.9 - 0.07 * compareFiles;
862 double legendX2 = 0.9;
863 double legendY2 = 0.9;
864 if (iHistogramType == kDxy || iHistogramType == kDz) {
866 legendY1 = 0.4 - 0.07 * compareFiles + 0.07 * (compareFiles / 4);
868 legendY2 = 0.4 + 0.07 * (compareFiles / 4);
871 legend[0] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
872 legend[0]->SetFillStyle(0);
873 legend[0]->SetBorderSize(0);
874 legend[0]->SetTextSize(0.05);
875 legend[0]->SetTextFont(62);
877 if (jetHtHistograms[0][iHistogramType][iIov] !=
nullptr) {
878 for (
int iFile = 0; iFile < compareFiles; iFile++) {
879 histogramSearchArray[iFile] = jetHtHistograms[iFile][iHistogramType][iIov];
883 jetHtHistograms[0][iHistogramType][iIov]->GetYaxis()->SetRangeUser(minZoomY, maxZoomY);
884 jetHtHistograms[0][iHistogramType][iIov]->SetLineColor(fileColor[0]);
886 drawer->
DrawHistogram(jetHtHistograms[0][iHistogramType][iIov],
887 histogramXaxis[iHistogramType],
889 iovLegend.at(iIov).Data());
890 legend[0]->AddEntry(jetHtHistograms[0][iHistogramType][iIov], legendComment[0],
"l");
892 for (
int iFile = 1; iFile < compareFiles; iFile++) {
893 if (jetHtHistograms[iFile][iHistogramType][iIov] !=
nullptr) {
894 jetHtHistograms[iFile][iHistogramType][iIov]->SetLineColor(fileColor[iFile]);
895 jetHtHistograms[iFile][iHistogramType][iIov]->Draw(
"same");
896 legend[0]->AddEntry(jetHtHistograms[iFile][iHistogramType][iIov], legendComment[iFile],
"l");
904 gPad->GetCanvas()->SaveAs(Form(
905 "output/%s%s_%s.pdf",
histogramName[iHistogramType].Data(), saveComment, iovNames.at(iIov).Data()));
910 << Form(
"%s_%s", iovNames.at(iIov).Data(),
histogramName[iHistogramType].Data()) << std::endl;
917 for (
int iProfileType = 0; iProfileType < knProfileTypes; iProfileType++) {
918 if (drawProfile[iProfileType]) {
920 for (
int iFile = 0; iFile < compareFiles; iFile++) {
921 jetHtProfiles[iFile][iProfileType][nIov - 2]->SetLineColor(fileColor[iFile]);
922 jetHtProfiles[iFile][iProfileType][nIov - 2]->SetLineWidth(2);
923 jetHtProfiles[iFile][iProfileType][nIov - 2]->SetLineStyle(2);
924 jetHtProfiles[iFile][iProfileType][nIov - 2]->GetYaxis()->SetRangeUser(profileZoomLow[iProfileType],
925 profileZoomHigh[iProfileType]);
929 if (drawPlotsForEachIOV) {
930 for (
int iIov = 0; iIov < nIov - 2; iIov = iIov + nIovInOnePlot) {
938 for (
int iFile = 0; iFile < compareFiles; iFile++) {
940 for (
int iSamePlot = 0; iSamePlot < nIovInOnePlot; iSamePlot++) {
941 if (iIov + iSamePlot >= nIov - 2)
943 if (jetHtProfiles[iFile][iProfileType][iIov + iSamePlot] !=
nullptr) {
944 if (nIovInOnePlot > 1) {
945 if (
colors[iFile + iSamePlot] == fileColor[0])
947 jetHtProfiles[iFile][iProfileType][iIov + iSamePlot]->SetLineColor(
colors[skipColor + iSamePlot]);
949 jetHtProfiles[iFile][iProfileType][iIov + iSamePlot]->SetLineColor(fileColor[iFile + iSamePlot]);
951 jetHtProfiles[iFile][iProfileType][iIov + iSamePlot]->SetLineWidth(2);
955 << Form(
"%s_%s", iovNames.at(iIov).Data(), profileName[iProfileType].Data()) << std::endl;
972 nDrawnHistograms = drawReferenceProfile * compareFiles + nIovInOnePlot * compareFiles - nNullHistograms;
973 nLeftLegend = TMath::Ceil(nDrawnHistograms / 2.0);
974 nRightLegend = TMath::Floor(nDrawnHistograms / 2.0);
977 if (!drawReferenceProfile) {
978 if (compareFiles > 1) {
980 nRightLegend = nDrawnHistograms;
982 if (nIovInOnePlot > 1) {
983 if (nLeftLegend > nRightLegend) {
995 if (compareFiles > 1) {
999 if (!drawReferenceProfile) {
1007 legendX1 = 0.19 + 0.24 * drawReferenceProfile * (compareFiles > 1) + profileLegendShiftTotalX +
1008 profileLegendShiftColumnX[columnOrder[0]];
1009 legendY1 = 0.9 - (profileLegendTextSize + 0.02) * nLeftLegend + profileLegendShiftTotalY +
1010 profileLegendShiftColumnY[columnOrder[0]];
1011 legendX2 = 0.41 + 0.24 * drawReferenceProfile * (compareFiles > 1) + profileLegendShiftTotalX +
1012 profileLegendShiftColumnX[columnOrder[0]];
1013 legendY2 = 0.9 + profileLegendShiftTotalY + profileLegendShiftColumnY[columnOrder[0]];
1015 legend[0] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1016 legend[0]->SetFillStyle(0);
1017 legend[0]->SetBorderSize(0);
1018 legend[0]->SetTextSize(profileLegendTextSize);
1019 legend[0]->SetTextFont(profileLegendTextFont);
1021 legendX1 = 0.55 - 0.24 * !drawReferenceProfile * (compareFiles > 1) + profileLegendShiftTotalX +
1022 profileLegendShiftColumnX[columnOrder[1]];
1023 legendY1 = 0.9 - (profileLegendTextSize + 0.02) * nRightLegend + profileLegendShiftTotalY +
1024 profileLegendShiftColumnY[columnOrder[1]];
1025 legendX2 = 0.77 - 0.24 * !drawReferenceProfile * (compareFiles > 1) + profileLegendShiftTotalX +
1026 profileLegendShiftColumnX[columnOrder[1]];
1027 legendY2 = 0.9 + profileLegendShiftTotalY + profileLegendShiftColumnY[columnOrder[1]];
1028 legend[1] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1029 legend[1]->SetFillStyle(0);
1030 legend[1]->SetBorderSize(0);
1031 legend[1]->SetTextSize(profileLegendTextSize);
1032 legend[1]->SetTextFont(profileLegendTextFont);
1034 legendX1 = 0.13 + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[2]];
1035 legendY1 = 0.9 - (profileLegendTextSize + 0.02) * nLeftLegend + profileLegendShiftTotalY +
1036 profileLegendShiftColumnY[columnOrder[2]];
1037 legendX2 = 0.49 + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[2]];
1038 legendY2 = 0.9 + profileLegendShiftTotalY + profileLegendShiftColumnY[columnOrder[2]];
1039 legend[2] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1040 legend[2]->SetFillStyle(0);
1041 legend[2]->SetBorderSize(0);
1042 legend[2]->SetTextSize(profileLegendTextSize);
1043 legend[2]->SetTextFont(profileLegendTextFont);
1046 if (drawReferenceProfile) {
1047 for (
int iFile = 0; iFile < compareFiles; iFile++) {
1048 if (jetHtProfiles[iFile][iProfileType][nIov - 2] !=
nullptr) {
1050 drawer->
DrawHistogram(jetHtProfiles[iFile][iProfileType][nIov - 2],
1051 profileXaxis[iProfileType],
1052 Form(
"#LT#sigma(%s)#GT (#mum)", profileYaxis[iProfileType].Data()),
1057 jetHtProfiles[iFile][iProfileType][nIov - 2]->Draw(
"same,HIST,C");
1059 legendString = legendTextForAllRuns.Data();
1060 if (nIovInOnePlot > 1)
1061 legendString.Append(Form(
" (%s)", legendComment[iFile].Data()));
1062 legend[0]->AddEntry(jetHtProfiles[iFile][iProfileType][nIov - 2], legendString.Data(),
"l");
1063 legend[2]->AddEntry((TObject *)
nullptr, Form(
"%s:", legendComment[iFile].Data()),
"");
1069 if (!drawReferenceProfile && (nIovInOnePlot > 1)) {
1070 legend[0]->AddEntry((TObject *)
nullptr, legendComment[0].Data(),
"");
1074 for (
int iFile = 0; iFile < compareFiles; iFile++) {
1076 for (
int iSamePlot = 0; iSamePlot < nIovInOnePlot; iSamePlot++) {
1077 if (iIov + iSamePlot >= nIov - 2)
1079 if (jetHtProfiles[iFile][iProfileType][iIov + iSamePlot] !=
nullptr) {
1081 drawer->
DrawHistogram(jetHtProfiles[iFile][iProfileType][iIov + iSamePlot],
1082 profileXaxis[iProfileType],
1083 Form(
"#LT#sigma(%s)#GT (#mum)", profileYaxis[iProfileType].Data()),
1087 jetHtProfiles[iFile][iProfileType][iIov + iSamePlot]->Draw(
"same");
1091 if (compareFiles > 1) {
1092 legendString = iovLegend.at(iIov + iSamePlot).Data();
1093 if (!drawReferenceProfile)
1094 legendString.Append(Form(
" (%s)", legendComment[iFile].Data()));
1095 legend[1]->AddEntry(jetHtProfiles[iFile][iProfileType][iIov + iSamePlot], legendString.Data(),
"l");
1097 if (iHistogram + 1 == nLeftLegend)
1099 legend[iLegend]->AddEntry(
1100 jetHtProfiles[iFile][iProfileType][iIov + iSamePlot], iovLegend.at(iIov + iSamePlot),
"l");
1110 if (drawReferenceProfile && compareFiles > 1)
1115 gPad->GetCanvas()->SaveAs(Form(
"output/%s%s_iov%d-%d.pdf",
1116 profileName[iProfileType].Data(),
1119 iovVector.at(
std::min(iIov + nIovInOnePlot, nIov - 2)) - 1));
1123 if (makeIovListForSlides && (iProfileType == profileIndexForIovList)) {
1124 iovFileForSlides << Form(
"%d-%d",
1126 iovVector.at(
std::min(iIov + nIovInOnePlot, nIov - 2)) - 1)
1134 doNotDrawEta = (!drawCentralEtaSummaryProfile || iProfileType == kDxyErrorVsEta || iProfileType == kDzErrorVsEta);
1147 legendX1 = 0.48 + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[0]];
1148 legendY1 = 0.9 - (profileLegendTextSize + 0.02) * compareFiles + profileLegendShiftTotalY +
1149 profileLegendShiftColumnY[columnOrder[0]];
1150 legendX2 = 0.7 + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[0]];
1151 legendY2 = 0.9 + profileLegendShiftTotalY + profileLegendShiftColumnY[columnOrder[0]];
1152 legend[0] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1153 legend[0]->SetFillStyle(0);
1154 legend[0]->SetBorderSize(0);
1155 legend[0]->SetTextSize(profileLegendTextSize);
1156 legend[0]->SetTextFont(profileLegendTextFont);
1158 legendX1 = 0.65 - 0.25 * doNotDrawEta + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[1]];
1159 legendY1 = 0.9 - (profileLegendTextSize + 0.02) * compareFiles + profileLegendShiftTotalY +
1160 profileLegendShiftColumnY[columnOrder[1]];
1161 legendX2 = 0.87 - 0.25 * doNotDrawEta + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[1]];
1162 legendY2 = 0.9 + profileLegendShiftTotalY + profileLegendShiftColumnY[columnOrder[1]];
1163 legend[1] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1164 legend[1]->SetFillStyle(0);
1165 legend[1]->SetBorderSize(0);
1166 legend[1]->SetTextSize(profileLegendTextSize);
1167 legend[1]->SetTextFont(profileLegendTextFont);
1169 legendX1 = 0.18 + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[2]];
1170 legendY1 = 0.9 - (profileLegendTextSize + 0.02) * compareFiles + profileLegendShiftTotalY +
1171 profileLegendShiftColumnY[columnOrder[2]];
1172 legendX2 = 0.54 + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[2]];
1173 legendY2 = 0.9 + profileLegendShiftTotalY + profileLegendShiftColumnY[columnOrder[2]];
1174 legend[2] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1175 legend[2]->SetFillStyle(0);
1176 legend[2]->SetBorderSize(0);
1177 legend[2]->SetTextSize(profileLegendTextSize);
1178 legend[2]->SetTextFont(profileLegendTextFont);
1181 canvasDrawn =
false;
1182 for (
int iFile = 0; iFile < compareFiles; iFile++) {
1183 if (jetHtProfiles[iFile][iProfileType][nIov - 2] !=
nullptr) {
1184 jetHtProfiles[iFile][iProfileType][nIov - 2]->SetLineStyle(
1187 drawer->
DrawHistogram(jetHtProfiles[iFile][iProfileType][nIov - 2],
1188 profileXaxis[iProfileType],
1189 Form(
"#LT#sigma(%s)#GT (#mum)", profileYaxis[iProfileType].Data()),
1193 jetHtProfiles[iFile][iProfileType][nIov - 2]->Draw(
"same");
1195 legendString = legendTextForAllRuns.Data();
1197 legendString.Append(Form(
" (%s)", legendComment[iFile].Data()));
1198 legend[1]->AddEntry(jetHtProfiles[iFile][iProfileType][nIov - 2], legendString.Data(),
"l");
1199 legend[2]->AddEntry((TObject *)
nullptr, Form(
"%s:", legendComment[iFile].Data()),
"");
1208 if (!doNotDrawEta) {
1209 for (
int iFile = 0; iFile < compareFiles; iFile++) {
1210 if (jetHtProfiles[iFile][iProfileType][nIov - 1] !=
nullptr) {
1211 jetHtProfiles[iFile][iProfileType][nIov - 1]->SetLineColor(fileColor[iFile]);
1212 jetHtProfiles[iFile][iProfileType][nIov - 1]->SetLineWidth(2);
1213 jetHtProfiles[iFile][iProfileType][nIov - 1]->SetLineStyle(2);
1214 jetHtProfiles[iFile][iProfileType][nIov - 1]->Draw(
"same,HIST,C");
1215 legend[0]->AddEntry(jetHtProfiles[iFile][iProfileType][nIov - 1],
"|#eta| < 1",
"l");
1221 if (!doNotDrawEta) {
1228 gPad->GetCanvas()->SaveAs(Form(
"output/%s%s_allIovs.pdf", profileName[iProfileType].Data(), saveComment));
1234 if (makeIovListForSlides)
1235 iovFileForSlides.close();
1238 TLegend *trendLegend;
1256 TLatex *tagWriter =
new TLatex();
1257 tagWriter->SetTextFont(trendTagTextFont);
1258 tagWriter->SetTextSize(trendTagTextSize);
1260 TString xTitle =
"Run index";
1261 if (useLuminosityForTrends)
1262 xTitle =
"Delivered luminosity (1/fb)";
1264 for (
int iTrend = 0; iTrend < knTrendTypes; iTrend++) {
1265 if (!drawTrend[iTrend])
1267 for (
int iWidePt = 0; iWidePt < nWidePtBins; iWidePt++) {
1268 legendX1 = 0.65 + trendLegendShiftTotalX;
1269 legendY1 = 0.83 - (profileLegendTextSize + 0.02) * compareFiles + trendLegendShiftTotalY;
1270 legendX2 = 0.9 + trendLegendShiftTotalX;
1271 legendY2 = 0.9 + trendLegendShiftTotalY;
1272 trendLegend =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1273 trendLegend->SetFillStyle(0);
1274 trendLegend->SetBorderSize(0);
1275 trendLegend->SetTextSize(trendLegendTextSize);
1276 trendLegend->SetTextFont(trendLegendTextFont);
1277 trendLegend->SetHeader(
1278 Form(
"%s error trend for p_{T} > %.0f GeV", profileYaxis[iTrend + 6].Data(), widePtBinBorders.at(iWidePt)));
1280 for (
int iFile = 0; iFile < compareFiles; iFile++) {
1281 gBigTrend[iFile][iTrend][iWidePt]->SetMarkerColor(fileColor[iFile]);
1282 gBigTrend[iFile][iTrend][iWidePt]->SetMarkerStyle(fileMarkerStyle[iFile]);
1283 gBigTrend[iFile][iTrend][iWidePt]->SetMarkerSize(fileMarkerSize[iFile]);
1284 if (copyErrorColor[iFile])
1285 gBigTrend[iFile][iTrend][iWidePt]->SetLineColor(fileColor[iFile]);
1291 trendZoomLow[iTrend],
1292 trendZoomHigh[iTrend],
1294 Form(
"#LT #sigma(%s) #GT", profileYaxis[iTrend + 6].Data()),
1298 gBigTrend[iFile][iTrend][iWidePt]->Draw(
"p,same");
1301 trendLegend->AddEntry(gBigTrend[iFile][iTrend][iWidePt], legendComment[iFile].Data(),
"p");
1305 trendLegend->Draw();
1308 if (drawYearLines) {
1309 for (
int thisRun : linePosition) {
1311 lumiLine =
new TLine(lumiX, trendZoomLow[iTrend], lumiX, trendZoomHigh[iTrend]);
1312 lumiLine->SetLineColor(yearLineColor);
1313 lumiLine->SetLineWidth(yearLineWidth);
1314 lumiLine->SetLineStyle(yearLineStyle);
1322 tagWriter->DrawLatexNDC(
1323 trendTagPositionX.at(iTag), trendTagPositionY.at(iTag), trendTagText.at(iTag).c_str());
1329 gPad->GetCanvas()->SaveAs(Form(
1330 "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
void SetCanvasSize(int width, int height)
double trendLabelSizeY() const
int yearLineColor() const
double trendMarginBottom() const
std::vector< int > runsForLines() const
void SetLabelOffsetX(double offset)
double trendZoomLow(const int iTrend) const
void SetLeftMargin(double margin)
double trendTitleOffsetY() const
bool makeIovListForSlides() const
void SetLabelSizeY(double size)
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)
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
void SetLabelSizeX(double size)
int trendCanvasWidth() const
void SetTitleOffsetY(double offset)
void SetTitleSizeX(double size)
double trendTagTextSize() const
bool drawCentralEtaSummaryProfile() const
void DrawGraphCustomAxes(TGraph *graph, double xlow, double xhigh, double ylow, double yhigh, const char *xTitle="", const char *yTitle="", const char *title="", const char *drawOption="")
int trendLegendTextFont() const
bool drawTrend(const int iTrend) const
std::string legendComment(const int iComment) const
void SetTopMargin(double margin)
void SetTitleSizeY(double size)
int trendTagTextFont() const
void SetBottomMargin(double margin)
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
void SetRightMargin(double margin)
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])
void SetLogY(bool log=true)
std::string legendTextForAllRuns() const
float normalize(float in)
double trendLabelOffsetY() const
char data[epos_bytes_allocation]
bool drawReferenceProfile() const
const char * iovListMode() const
void SetLabelOffsetY(double offset)
double profileLegendShiftTotalY() const
bool drawPlotsForEachIOV() const
int yearLineWidth() const
double trendMarginRight() const
void SetTitleOffsetX(double offset)
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
void DrawHistogram(TH1 *histo, const char *xTitle, const char *yTitle, const char *title="", const char *drawOption="")
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