13 #include "TGraphErrors.h" 57 histogram[0]->SetLineColor(color[0]);
59 histogram[0]->Scale(1.0 / histogram[0]->Integral());
64 for (
int iFile = 1; iFile <
kMaxFiles; iFile++) {
65 if (histogram[iFile]) {
67 histogram[iFile]->SetLineColor(color[iFile]);
69 histogram[iFile]->Scale(1.0 / histogram[iFile]->Integral());
70 histogram[iFile]->Draw(
"Same");
75 double legendX1 = 0.6;
76 double legendY1 = 0.9 - 0.07 * nHistograms;
77 double legendX2 = 0.9;
78 double legendY2 = 0.9;
79 if (legendPosition == 1) {
81 legendY1 = 0.4 - 0.07 * nHistograms + 0.07 * (nHistograms / 4);
83 legendY2 = 0.4 + 0.07 * (nHistograms / 4);
85 TLegend *
legend =
new TLegend(legendX1, legendY1, legendX2, legendY2);
92 legend->AddEntry(histogram[0], comment[0],
"l");
93 for (
int iFile = 1; iFile <
kMaxFiles; iFile++) {
94 if (histogram[iFile]) {
95 legend->AddEntry(histogram[iFile], comment[iFile],
"l");
102 gPad->GetCanvas()->SaveAs(Form(
"output/%s.pdf",
saveName));
116 double minValue = histogram[0]->GetMinimum();
117 double maxValue = histogram[0]->GetMaximum();
119 double newMinValue, newMaxValue;
121 for (
int iFile = 1; iFile <
kMaxFiles; iFile++) {
122 if (histogram[iFile]) {
123 newMinValue = histogram[iFile]->GetMinimum();
124 newMaxValue = histogram[iFile]->GetMaximum();
156 std::vector<std::string> ptHatFileList;
157 std::vector<int> ptHatList;
166 while (std::getline(ptHatFile, lineInFile)) {
167 auto stringStream = std::istringstream{lineInFile};
171 stringStream >> wordString;
172 ptHatFileList.push_back(wordString);
173 stringStream >> wordString;
174 ptHatList.push_back(std::stoi(wordString));
178 return std::make_tuple(ptHatFileList, ptHatList);
186 double ptHatWeights[] = {
202 const int nPtHat = 14;
203 int ptHatBoundaries[] = {30, 50, 80, 120, 170, 300, 470, 600, 800, 1000, 1400, 1800, 2400, 3200};
205 TFile *openFile = ptHatFiles.at(0);
207 TH1 *currentHistogram;
208 combinedHistogram->Reset(
"ICES");
211 const int nFiles = ptHatFiles.size();
213 for (
int iFile = 0; iFile <
nFiles; iFile++) {
215 for (
int iPtHat = 0; iPtHat < nPtHat; iPtHat++) {
216 if (ptHatValues.at(iFile) == ptHatBoundaries[iPtHat]) {
222 if (ptHatIndex < 0) {
223 std::cout <<
"Could not find pT hat boundary " << ptHatValues.at(iFile) <<
" for file " << ptHatFiles.at(iFile)
225 std::cout <<
"Please check your input! It needs to be in the form <fileName> <ptHatBoundary>" << std::endl;
229 openFile = ptHatFiles.at(iFile);
231 combinedHistogram->Add(currentHistogram, ptHatWeights[ptHatIndex]);
234 return combinedHistogram;
248 std::tuple<std::vector<int>, std::vector<double>, std::vector<TString>, std::vector<TString>>
runAndLumiLists(
249 const char *
inputFile,
const char *iovListMode) {
251 std::vector<int> iovVector;
252 std::vector<double> lumiPerIov;
253 std::vector<TString> iovNames;
254 std::vector<TString> iovLegend;
265 while (std::getline(
iovList, lineInFile)) {
267 std::istringstream lineStream(lineInFile);
268 lineStream >> thisIov;
269 lineStream >> thisLumi;
272 iovVector.push_back(thisIov);
273 lumiPerIov.push_back(thisLumi);
278 iovNames.push_back(Form(
"iov%d-%d", iovVector.at(
i - 1), iovVector.at(
i) - 1));
282 TString listModeParser = iovListMode;
283 if (listModeParser.EqualTo(
"iov", TString::kIgnoreCase)) {
285 iovLegend.push_back(Form(
"IOV %d-%d", iovVector.at(
i - 1), iovVector.at(
i) - 1));
289 iovLegend.push_back(Form(
"Run %d", iovVector.at(
i)));
294 iovNames.push_back(
"all");
295 iovNames.push_back(
"central");
296 iovLegend.push_back(
"All");
297 iovLegend.push_back(
"Central");
300 return std::make_tuple(iovVector, lumiPerIov, iovNames, iovLegend);
315 std::vector<double> lumiPerIov,
316 bool skipMissingRuns) {
318 int nRuns = runGraph->GetN();
321 std::vector<double> xAxisValues, yAxisValues, xAxisErrors, yAxisErrors;
325 double lumiFactor = 1000;
331 std::vector<double> lumiPerIovWithSkips;
334 while (iRun < nRuns) {
335 runGraph->GetPoint(iRun,
runIndex, yValue);
337 if (lumiPerIov.at(iRun +
offset) == 0 || (yValue <
epsilon && skipMissingRuns)) {
339 runGraph->RemovePoint(iRun);
343 lumiPerIovWithSkips.push_back(0);
345 xValue += lumiPerIov.at(iRun +
offset) / lumiFactor;
346 xAxisValues.push_back(xValue - (lumiPerIov.at(iRun +
offset) / (lumiFactor * 2)));
347 xAxisErrors.push_back(lumiPerIov.at(iRun +
offset) / (lumiFactor * 2));
348 yAxisValues.push_back(yValue);
349 yAxisErrors.push_back(runGraph->GetErrorY(iRun));
352 lumiPerIovWithSkips.push_back(lumiPerIov.at(iRun +
offset));
359 runGraph->GetHistogram()->Delete();
360 runGraph->SetHistogram(
nullptr);
361 for (
int iRun = 0; iRun < nRuns; iRun++) {
362 runGraph->SetPoint(iRun, xAxisValues.at(iRun), yAxisValues.at(iRun));
363 runGraph->SetPointError(iRun, xAxisErrors.at(iRun), yAxisErrors.at(iRun));
366 return lumiPerIovWithSkips;
377 double lumiFactor = 1000;
379 int nRuns = lumiPerIov.size();
380 double luminosityBefore = 0;
382 for (
int iRun = 0; iRun < nRuns; iRun++) {
384 return luminosityBefore;
386 luminosityBefore += lumiPerIov.at(iRun) / lumiFactor;
389 return luminosityBefore;
401 configurationGiver->
readJsonFile(configurationFileName);
404 enum enumHistogramType { kDz, kDzError, kDxy, kDxyError, knHistogramTypes };
405 TString
histogramName[knHistogramTypes] = {
"dz",
"dzerr",
"dxy",
"dxyerr"};
406 TString histogramXaxis[knHistogramTypes] = {
407 "d_{z} (#mum)",
"#sigma(d_{z}) (#mum)",
"d_{xy} (#mum)",
"#sigma(d_{xy}) (#mum)"};
408 enum enumProfileType {
419 enum enumTrendType { kDzErrorTrend, kDxyErrorTrend, knTrendTypes };
420 TString profileName[knProfileTypes] = {
"dzErrVsPt",
428 TString profileXaxis[knProfileTypes] = {
429 "p_{T} (GeV)",
"#varphi",
"#eta",
"p_{T} (GeV)",
"#varphi",
"#eta",
"p_{T} bin",
"p_{T} bin"};
430 TString profileYaxis[knProfileTypes] = {
"d_{z}",
"d_{z}",
"d_{z}",
"d_{xy}",
"d_{xy}",
"d_{xy}",
"d_{z}",
"d_{xy}"};
431 TString trendName[] = {
"dzErr",
"dxyErr"};
432 bool drawHistogram[knHistogramTypes];
433 bool drawProfile[knProfileTypes];
434 bool drawTrend[knTrendTypes];
436 bool drawTrackQA = configurationGiver->
drawTrackQA();
438 drawHistogram[kDzError] = configurationGiver->
drawHistogram(kDzError);
439 drawProfile[kDzErrorVsPt] = configurationGiver->
drawProfile(kDzErrorVsPt);
440 drawProfile[kDzErrorVsPhi] =
442 drawProfile[kDzErrorVsEta] =
444 drawProfile[kDzErrorVsPtWide] =
446 drawHistogram[kDxy] = configurationGiver->
drawHistogram(kDxy);
447 drawHistogram[kDxyError] = configurationGiver->
drawHistogram(kDxyError);
448 drawProfile[kDxyErrorVsPt] =
450 drawProfile[kDxyErrorVsPhi] =
452 drawProfile[kDxyErrorVsEta] =
454 drawProfile[kDxyErrorVsPtWide] =
455 configurationGiver->
drawProfile(kDxyErrorVsPtWide);
457 bool drawCentralEtaSummaryProfile =
459 drawTrend[kDzErrorTrend] = configurationGiver->
drawTrend(kDzErrorTrend);
460 drawTrend[kDxyErrorTrend] = configurationGiver->
drawTrend(kDxyErrorTrend);
462 const int nMaxLegendColumns = 3;
463 double profileLegendShiftTotalX =
465 double profileLegendShiftTotalY =
467 double profileLegendShiftColumnX[nMaxLegendColumns];
468 double profileLegendShiftColumnY[nMaxLegendColumns];
469 for (
int iColumn = 0; iColumn < nMaxLegendColumns; iColumn++) {
477 TString legendTextForAllRuns =
480 double trendLegendShiftTotalX =
482 double trendLegendShiftTotalY =
488 std::vector<std::string> trendTagText = configurationGiver->
trendTagText();
509 bool drawPlotsForEachIOV =
512 bool useLuminosityForTrends =
515 bool skipRunsWithNoData =
519 int colors[] = {kBlue, kRed, kGreen + 2, kMagenta, kCyan, kViolet + 3, kOrange, kPink - 7, kSpring + 3, kAzure - 7};
522 double profileZoomLow[knProfileTypes];
523 double profileZoomHigh[knProfileTypes];
524 double trendZoomLow[knTrendTypes];
525 double trendZoomHigh[knTrendTypes];
527 for (
int iProfile = 0; iProfile < knProfileTypes; iProfile++) {
528 profileZoomLow[iProfile] = configurationGiver->
profileZoomLow(iProfile);
529 profileZoomHigh[iProfile] = configurationGiver->
profileZoomHigh(iProfile);
531 for (
int iTrend = 0; iTrend < knTrendTypes; iTrend++) {
532 trendZoomLow[iTrend] = configurationGiver->
trendZoomLow(iTrend);
533 trendZoomHigh[iTrend] = configurationGiver->
trendZoomHigh(iTrend);
536 const std::vector<double> widePtBinBorders = configurationGiver->
widePtBinBorders();
537 const int nWidePtBins = widePtBinBorders.size();
540 bool saveFigures =
true;
541 const char *saveComment = configurationGiver->
saveComment();
543 int compareFiles = configurationGiver->
nInputFiles();
544 if (compareFiles == 0)
550 if (compareFiles > 1)
555 bool loadFromList[
kMaxFiles] = {
false,
false,
false,
false};
562 for (
int iFile = 0; iFile <
kMaxFiles; iFile++) {
565 loadFromList[iFile] =
true;
566 legendComment[iFile] = configurationGiver->
legendComment(iFile);
567 fileColor[iFile] = configurationGiver->
markerColor(iFile);
568 fileMarkerStyle[iFile] = configurationGiver->
markerStyle(iFile);
569 fileMarkerSize[iFile] = configurationGiver->
markerSize(iFile);
570 copyErrorColor[iFile] =
579 int profileIndexForIovList = 0;
580 for (
int iProfile = 0; iProfile < knProfileTypes; iProfile++) {
581 if (drawProfile[iProfile]) {
582 profileIndexForIovList = iProfile;
587 TString plotTitle =
" ";
591 std::vector<int> linePosition = configurationGiver->
runsForLines();
605 TString outputFolderStatus = gSystem->GetFromPipe(
"if [ -d output ]; then echo true; else echo false; fi");
606 if (outputFolderStatus ==
"false") {
607 gSystem->Exec(
"mkdir output");
616 std::vector<std::string> ptHatFileNameList[
kMaxFiles];
617 std::vector<TFile *> ptHatFileList[
kMaxFiles];
621 for (
int iInput = 0; iInput <
kMaxFiles; iInput++) {
622 if (loadFromList[iInput]) {
626 nFiles = ptHatFileNameList[iInput].size();
627 for (
int iFile = 0; iFile <
nFiles; iFile++) {
628 ptHatFileList[iInput].push_back(TFile::Open(ptHatFileNameList[iInput].at(iFile).
data()));
638 const char *iovAndLumiFile = configurationGiver->
lumiPerIovFile();
639 const char *iovListMode = configurationGiver->
iovListMode();
642 std::vector<int> iovVector;
643 std::vector<double> lumiPerIov;
644 std::vector<double> lumiPerIovWithSkips;
645 std::vector<TString> iovNames;
646 std::vector<TString> iovLegend;
648 std::tie(iovVector, lumiPerIov, iovNames, iovLegend) =
runAndLumiLists(iovAndLumiFile, iovListMode);
651 iovLegend.pop_back();
652 iovLegend.pop_back();
653 iovLegend.push_back(legendTextForAllRuns);
654 iovLegend.push_back(Form(
"%s |#eta| < 1", legendTextForAllRuns.Data()));
661 std::ofstream iovFileForSlides;
662 if (makeIovListForSlides)
663 iovFileForSlides.open(iovListForSlides);
671 for (
int iFile = 0; iFile <
kMaxFiles; iFile++) {
672 if (compareFiles > iFile && !loadFromList[iFile])
677 const int nIov = iovNames.size();
683 TH1D *jetHtHistograms[
kMaxFiles][knHistogramTypes][nIov];
684 TProfile *jetHtProfiles[
kMaxFiles][knProfileTypes][nIov];
685 TGraphErrors *gBigTrend[
kMaxFiles][knTrendTypes][nWidePtBins];
688 for (
int iFile = 0; iFile <
kMaxFiles; iFile++) {
689 hVertex[iFile] =
nullptr;
690 hTracksPerVertex[iFile] =
nullptr;
691 hTrackPt[iFile] =
nullptr;
692 hTrackEta[iFile] =
nullptr;
693 hTrackPhi[iFile] =
nullptr;
694 for (
int iIov = 0; iIov < nIov; iIov++) {
695 for (
int iHistogramType = 0; iHistogramType < knHistogramTypes; iHistogramType++) {
696 jetHtHistograms[iFile][iHistogramType][iIov] =
nullptr;
698 for (
int iProfileType = 0; iProfileType < knProfileTypes; iProfileType++) {
699 jetHtProfiles[iFile][iProfileType][iIov] =
nullptr;
702 for (
int iTrend = 0; iTrend < knTrendTypes; iTrend++) {
703 for (
int iWidePt = 0; iWidePt < nWidePtBins; iWidePt++) {
704 gBigTrend[iFile][iTrend][iWidePt] =
nullptr;
710 for (
int iFile = 0; iFile < compareFiles; iFile++) {
711 if (loadFromList[iFile]) {
714 hVertex[iFile] = (TH1D *)
ptHatCombinedHistogram(ptHatFileList[iFile], ptHatList[iFile],
"jetHTAnalyzer/all_nvtx");
715 hTracksPerVertex[iFile] =
723 for (
int iIov = nIov - 2; iIov < nIov - 1; iIov++) {
724 for (
int iHistogramType = 0; iHistogramType < knHistogramTypes; iHistogramType++) {
725 if (drawHistogram[iHistogramType]) {
727 ptHatFileList[iFile],
729 Form(
"jetHTAnalyzer/%s_%s", iovNames.at(iIov).Data(),
histogramName[iHistogramType].Data()));
732 for (
int iProfileType = 0; iProfileType < knProfileTypes; iProfileType++) {
733 if (drawProfile[iProfileType] || (drawTrend[kDzErrorTrend] && iProfileType == kDzErrorVsPtWide) ||
734 (drawTrend[kDxyErrorTrend] && iProfileType == kDxyErrorVsPtWide)) {
736 ptHatFileList[iFile],
738 Form(
"jetHTAnalyzer/%s_%s", iovNames.at(iIov).Data(), profileName[iProfileType].Data()));
746 hVertex[iFile] = (TH1D *)
inputFile[iFile]->
Get(
"jetHTAnalyzer/all_nvtx");
747 hTracksPerVertex[iFile] = (TH1D *)
inputFile[iFile]->
Get(
"jetHTAnalyzer/h_ntrks");
748 hTrackPt[iFile] = (TH1D *)
inputFile[iFile]->
Get(
"jetHTAnalyzer/h_probePt");
749 hTrackEta[iFile] = (TH1D *)
inputFile[iFile]->
Get(
"jetHTAnalyzer/h_probeEta");
750 hTrackPhi[iFile] = (TH1D *)
inputFile[iFile]->
Get(
"jetHTAnalyzer/h_probePhi");
751 for (
int iIov = 0; iIov < nIov; iIov++) {
752 for (
int iHistogramType = 0; iHistogramType < knHistogramTypes; iHistogramType++) {
753 if (drawHistogram[iHistogramType]) {
754 jetHtHistograms[iFile][iHistogramType][iIov] = (TH1D *)
inputFile[iFile]->
Get(
755 Form(
"jetHTAnalyzer/%s_%s", iovNames.at(iIov).Data(),
histogramName[iHistogramType].Data()));
758 for (
int iProfileType = 0; iProfileType < knProfileTypes; iProfileType++) {
759 if (drawProfile[iProfileType] || (drawTrend[kDzErrorTrend] && iProfileType == kDzErrorVsPtWide) ||
760 (drawTrend[kDxyErrorTrend] && iProfileType == kDxyErrorVsPtWide)) {
761 jetHtProfiles[iFile][iProfileType][iIov] = (TProfile *)
inputFile[iFile]->
Get(
762 Form(
"jetHTAnalyzer/%s_%s", iovNames.at(iIov).Data(), profileName[iProfileType].Data()));
770 const int nRuns = iovVector.size() - 1;
771 double yValueDz[nRuns];
772 double yErrorDz[nRuns];
773 double yValueDxy[nRuns];
774 double yErrorDxy[nRuns];
775 double xValue[nRuns];
776 double xError[nRuns];
777 TString commentEntry =
"";
778 if (drawTrend[kDzErrorTrend] || drawTrend[kDxyErrorTrend]) {
779 for (
int iFile = 0; iFile < compareFiles; iFile++) {
780 for (
int iWidePt = 0; iWidePt < nWidePtBins; iWidePt++) {
781 for (
int iRun = 0; iRun < nRuns; iRun++) {
784 if (jetHtProfiles[iFile][kDzErrorVsPtWide][iRun] ==
nullptr) {
788 yValueDz[iRun] = jetHtProfiles[iFile][kDzErrorVsPtWide][iRun]->GetBinContent(iWidePt + 1);
789 yErrorDz[iRun] = jetHtProfiles[iFile][kDzErrorVsPtWide][iRun]->GetBinError(iWidePt + 1);
791 if (jetHtProfiles[iFile][kDxyErrorVsPtWide][iRun] ==
nullptr) {
795 yValueDxy[iRun] = jetHtProfiles[iFile][kDxyErrorVsPtWide][iRun]->GetBinContent(iWidePt + 1);
796 yErrorDxy[iRun] = jetHtProfiles[iFile][kDxyErrorVsPtWide][iRun]->GetBinError(iWidePt + 1);
800 gBigTrend[iFile][kDzErrorTrend][iWidePt] =
new TGraphErrors(nRuns, xValue, yValueDz, xError, yErrorDz);
801 gBigTrend[iFile][kDxyErrorTrend][iWidePt] =
new TGraphErrors(nRuns, xValue, yValueDxy, xError, yErrorDxy);
804 if (useLuminosityForTrends) {
805 lumiPerIovWithSkips =
819 TLegend *
legend[nMaxLegendColumns];
820 int columnOrder[nMaxLegendColumns];
821 bool noIovFound =
true;
824 double minZoomY, maxZoomY;
825 int nDrawnHistograms, nLeftLegend, nRightLegend;
826 double legendX1, legendX2, legendY1, legendY2;
831 TString legendString;
833 for (
int iFile = 0; iFile <
kMaxFiles; iFile++) {
834 histogramSearchArray[iFile] =
nullptr;
840 hVertex, Form(
"vertex%s", saveComment), saveFigures, legendComment, 0, normalizeQAplots,
false, fileColor);
842 Form(
"tracksPerVertex%s", saveComment),
850 hTrackPt, Form(
"trackPt%s", saveComment), saveFigures, legendComment, 0, normalizeQAplots,
true, fileColor);
852 hTrackEta, Form(
"trackEta%s", saveComment), saveFigures, legendComment, 1, normalizeQAplots,
false, fileColor);
854 hTrackPhi, Form(
"trackPhi%s", saveComment), saveFigures, legendComment, 1, normalizeQAplots,
false, fileColor);
858 for (
int iIov = 0; iIov < nIov; iIov++) {
859 if (!drawPlotsForEachIOV && iIov < nIov - 2)
861 for (
int iHistogramType = 0; iHistogramType < knHistogramTypes; iHistogramType++) {
862 if (drawHistogram[iHistogramType]) {
863 double legendX1 = 0.6;
864 double legendY1 = 0.9 - 0.07 * compareFiles;
865 double legendX2 = 0.9;
866 double legendY2 = 0.9;
867 if (iHistogramType == kDxy || iHistogramType == kDz) {
869 legendY1 = 0.4 - 0.07 * compareFiles + 0.07 * (compareFiles / 4);
871 legendY2 = 0.4 + 0.07 * (compareFiles / 4);
874 legend[0] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
875 legend[0]->SetFillStyle(0);
876 legend[0]->SetBorderSize(0);
877 legend[0]->SetTextSize(0.05);
878 legend[0]->SetTextFont(62);
880 if (jetHtHistograms[0][iHistogramType][iIov] !=
nullptr) {
881 for (
int iFile = 0; iFile < compareFiles; iFile++) {
882 histogramSearchArray[iFile] = jetHtHistograms[iFile][iHistogramType][iIov];
886 jetHtHistograms[0][iHistogramType][iIov]->GetYaxis()->SetRangeUser(minZoomY, maxZoomY);
887 jetHtHistograms[0][iHistogramType][iIov]->SetLineColor(fileColor[0]);
889 drawer->
DrawHistogram(jetHtHistograms[0][iHistogramType][iIov],
890 histogramXaxis[iHistogramType],
892 iovLegend.at(iIov).Data());
893 legend[0]->AddEntry(jetHtHistograms[0][iHistogramType][iIov], legendComment[0],
"l");
895 for (
int iFile = 1; iFile < compareFiles; iFile++) {
896 if (jetHtHistograms[iFile][iHistogramType][iIov] !=
nullptr) {
897 jetHtHistograms[iFile][iHistogramType][iIov]->SetLineColor(fileColor[iFile]);
898 jetHtHistograms[iFile][iHistogramType][iIov]->Draw(
"same");
899 legend[0]->AddEntry(jetHtHistograms[iFile][iHistogramType][iIov], legendComment[iFile],
"l");
907 gPad->GetCanvas()->SaveAs(Form(
908 "output/%s%s_%s.pdf",
histogramName[iHistogramType].Data(), saveComment, iovNames.at(iIov).Data()));
913 << Form(
"%s_%s", iovNames.at(iIov).Data(),
histogramName[iHistogramType].Data()) << std::endl;
920 for (
int iProfileType = 0; iProfileType < knProfileTypes; iProfileType++) {
921 if (drawProfile[iProfileType]) {
923 for (
int iFile = 0; iFile < compareFiles; iFile++) {
924 jetHtProfiles[iFile][iProfileType][nIov - 2]->SetLineColor(fileColor[iFile]);
925 jetHtProfiles[iFile][iProfileType][nIov - 2]->SetLineWidth(2);
926 jetHtProfiles[iFile][iProfileType][nIov - 2]->SetLineStyle(2);
927 jetHtProfiles[iFile][iProfileType][nIov - 2]->GetYaxis()->SetRangeUser(profileZoomLow[iProfileType],
928 profileZoomHigh[iProfileType]);
932 if (drawPlotsForEachIOV) {
933 for (
int iIov = 0; iIov < nIov - 2; iIov = iIov + nIovInOnePlot) {
941 for (
int iFile = 0; iFile < compareFiles; iFile++) {
943 for (
int iSamePlot = 0; iSamePlot < nIovInOnePlot; iSamePlot++) {
944 if (iIov + iSamePlot >= nIov - 2)
946 if (jetHtProfiles[iFile][iProfileType][iIov + iSamePlot] !=
nullptr) {
947 if (nIovInOnePlot > 1) {
948 if (
colors[iFile + iSamePlot] == fileColor[0])
950 jetHtProfiles[iFile][iProfileType][iIov + iSamePlot]->SetLineColor(
colors[skipColor + iSamePlot]);
952 jetHtProfiles[iFile][iProfileType][iIov + iSamePlot]->SetLineColor(fileColor[iFile + iSamePlot]);
954 jetHtProfiles[iFile][iProfileType][iIov + iSamePlot]->SetLineWidth(2);
958 << Form(
"%s_%s", iovNames.at(iIov).Data(), profileName[iProfileType].Data()) << std::endl;
975 nDrawnHistograms = drawReferenceProfile * compareFiles + nIovInOnePlot * compareFiles - nNullHistograms;
976 nLeftLegend = TMath::Ceil(nDrawnHistograms / 2.0);
977 nRightLegend = TMath::Floor(nDrawnHistograms / 2.0);
980 if (!drawReferenceProfile) {
981 if (compareFiles > 1) {
983 nRightLegend = nDrawnHistograms;
985 if (nIovInOnePlot > 1) {
986 if (nLeftLegend > nRightLegend) {
998 if (compareFiles > 1) {
1002 if (!drawReferenceProfile) {
1010 legendX1 = 0.19 + 0.24 * drawReferenceProfile * (compareFiles > 1) + profileLegendShiftTotalX +
1011 profileLegendShiftColumnX[columnOrder[0]];
1012 legendY1 = 0.9 - (profileLegendTextSize + 0.02) * nLeftLegend + profileLegendShiftTotalY +
1013 profileLegendShiftColumnY[columnOrder[0]];
1014 legendX2 = 0.41 + 0.24 * drawReferenceProfile * (compareFiles > 1) + profileLegendShiftTotalX +
1015 profileLegendShiftColumnX[columnOrder[0]];
1016 legendY2 = 0.9 + profileLegendShiftTotalY + profileLegendShiftColumnY[columnOrder[0]];
1018 legend[0] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1019 legend[0]->SetFillStyle(0);
1020 legend[0]->SetBorderSize(0);
1021 legend[0]->SetTextSize(profileLegendTextSize);
1022 legend[0]->SetTextFont(profileLegendTextFont);
1024 legendX1 = 0.55 - 0.24 * !drawReferenceProfile * (compareFiles > 1) + profileLegendShiftTotalX +
1025 profileLegendShiftColumnX[columnOrder[1]];
1026 legendY1 = 0.9 - (profileLegendTextSize + 0.02) * nRightLegend + profileLegendShiftTotalY +
1027 profileLegendShiftColumnY[columnOrder[1]];
1028 legendX2 = 0.77 - 0.24 * !drawReferenceProfile * (compareFiles > 1) + profileLegendShiftTotalX +
1029 profileLegendShiftColumnX[columnOrder[1]];
1030 legendY2 = 0.9 + profileLegendShiftTotalY + profileLegendShiftColumnY[columnOrder[1]];
1031 legend[1] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1032 legend[1]->SetFillStyle(0);
1033 legend[1]->SetBorderSize(0);
1034 legend[1]->SetTextSize(profileLegendTextSize);
1035 legend[1]->SetTextFont(profileLegendTextFont);
1037 legendX1 = 0.13 + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[2]];
1038 legendY1 = 0.9 - (profileLegendTextSize + 0.02) * nLeftLegend + profileLegendShiftTotalY +
1039 profileLegendShiftColumnY[columnOrder[2]];
1040 legendX2 = 0.49 + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[2]];
1041 legendY2 = 0.9 + profileLegendShiftTotalY + profileLegendShiftColumnY[columnOrder[2]];
1042 legend[2] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1043 legend[2]->SetFillStyle(0);
1044 legend[2]->SetBorderSize(0);
1045 legend[2]->SetTextSize(profileLegendTextSize);
1046 legend[2]->SetTextFont(profileLegendTextFont);
1049 if (drawReferenceProfile) {
1050 for (
int iFile = 0; iFile < compareFiles; iFile++) {
1051 if (jetHtProfiles[iFile][iProfileType][nIov - 2] !=
nullptr) {
1053 drawer->
DrawHistogram(jetHtProfiles[iFile][iProfileType][nIov - 2],
1054 profileXaxis[iProfileType],
1055 Form(
"#LT#sigma(%s)#GT (#mum)", profileYaxis[iProfileType].Data()),
1060 jetHtProfiles[iFile][iProfileType][nIov - 2]->Draw(
"same,HIST,C");
1062 legendString = legendTextForAllRuns.Data();
1063 if (nIovInOnePlot > 1)
1064 legendString.Append(Form(
" (%s)", legendComment[iFile].Data()));
1065 legend[0]->AddEntry(jetHtProfiles[iFile][iProfileType][nIov - 2], legendString.Data(),
"l");
1066 legend[2]->AddEntry((TObject *)
nullptr, Form(
"%s:", legendComment[iFile].Data()),
"");
1072 if (!drawReferenceProfile && (nIovInOnePlot > 1)) {
1073 legend[0]->AddEntry((TObject *)
nullptr, legendComment[0].Data(),
"");
1077 for (
int iFile = 0; iFile < compareFiles; iFile++) {
1079 for (
int iSamePlot = 0; iSamePlot < nIovInOnePlot; iSamePlot++) {
1080 if (iIov + iSamePlot >= nIov - 2)
1082 if (jetHtProfiles[iFile][iProfileType][iIov + iSamePlot] !=
nullptr) {
1084 drawer->
DrawHistogram(jetHtProfiles[iFile][iProfileType][iIov + iSamePlot],
1085 profileXaxis[iProfileType],
1086 Form(
"#LT#sigma(%s)#GT (#mum)", profileYaxis[iProfileType].Data()),
1090 jetHtProfiles[iFile][iProfileType][iIov + iSamePlot]->Draw(
"same");
1094 if (compareFiles > 1) {
1095 legendString = iovLegend.at(iIov + iSamePlot).Data();
1096 if (!drawReferenceProfile)
1097 legendString.Append(Form(
" (%s)", legendComment[iFile].Data()));
1098 legend[1]->AddEntry(jetHtProfiles[iFile][iProfileType][iIov + iSamePlot], legendString.Data(),
"l");
1100 if (iHistogram + 1 == nLeftLegend)
1102 legend[iLegend]->AddEntry(
1103 jetHtProfiles[iFile][iProfileType][iIov + iSamePlot], iovLegend.at(iIov + iSamePlot),
"l");
1113 if (drawReferenceProfile && compareFiles > 1)
1118 gPad->GetCanvas()->SaveAs(Form(
"output/%s%s_iov%d-%d.pdf",
1119 profileName[iProfileType].Data(),
1122 iovVector.at(
std::min(iIov + nIovInOnePlot, nIov - 2)) - 1));
1126 if (makeIovListForSlides && (iProfileType == profileIndexForIovList)) {
1127 iovFileForSlides << Form(
"%d-%d",
1129 iovVector.at(
std::min(iIov + nIovInOnePlot, nIov - 2)) - 1)
1137 doNotDrawEta = (!drawCentralEtaSummaryProfile || iProfileType == kDxyErrorVsEta || iProfileType == kDzErrorVsEta);
1150 legendX1 = 0.48 + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[0]];
1151 legendY1 = 0.9 - (profileLegendTextSize + 0.02) * compareFiles + profileLegendShiftTotalY +
1152 profileLegendShiftColumnY[columnOrder[0]];
1153 legendX2 = 0.7 + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[0]];
1154 legendY2 = 0.9 + profileLegendShiftTotalY + profileLegendShiftColumnY[columnOrder[0]];
1155 legend[0] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1156 legend[0]->SetFillStyle(0);
1157 legend[0]->SetBorderSize(0);
1158 legend[0]->SetTextSize(profileLegendTextSize);
1159 legend[0]->SetTextFont(profileLegendTextFont);
1161 legendX1 = 0.65 - 0.25 * doNotDrawEta + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[1]];
1162 legendY1 = 0.9 - (profileLegendTextSize + 0.02) * compareFiles + profileLegendShiftTotalY +
1163 profileLegendShiftColumnY[columnOrder[1]];
1164 legendX2 = 0.87 - 0.25 * doNotDrawEta + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[1]];
1165 legendY2 = 0.9 + profileLegendShiftTotalY + profileLegendShiftColumnY[columnOrder[1]];
1166 legend[1] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1167 legend[1]->SetFillStyle(0);
1168 legend[1]->SetBorderSize(0);
1169 legend[1]->SetTextSize(profileLegendTextSize);
1170 legend[1]->SetTextFont(profileLegendTextFont);
1172 legendX1 = 0.18 + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[2]];
1173 legendY1 = 0.9 - (profileLegendTextSize + 0.02) * compareFiles + profileLegendShiftTotalY +
1174 profileLegendShiftColumnY[columnOrder[2]];
1175 legendX2 = 0.54 + profileLegendShiftTotalX + profileLegendShiftColumnX[columnOrder[2]];
1176 legendY2 = 0.9 + profileLegendShiftTotalY + profileLegendShiftColumnY[columnOrder[2]];
1177 legend[2] =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1178 legend[2]->SetFillStyle(0);
1179 legend[2]->SetBorderSize(0);
1180 legend[2]->SetTextSize(profileLegendTextSize);
1181 legend[2]->SetTextFont(profileLegendTextFont);
1184 canvasDrawn =
false;
1185 for (
int iFile = 0; iFile < compareFiles; iFile++) {
1186 if (jetHtProfiles[iFile][iProfileType][nIov - 2] !=
nullptr) {
1187 jetHtProfiles[iFile][iProfileType][nIov - 2]->SetLineStyle(
1190 drawer->
DrawHistogram(jetHtProfiles[iFile][iProfileType][nIov - 2],
1191 profileXaxis[iProfileType],
1192 Form(
"#LT#sigma(%s)#GT (#mum)", profileYaxis[iProfileType].Data()),
1196 jetHtProfiles[iFile][iProfileType][nIov - 2]->Draw(
"same");
1198 legendString = legendTextForAllRuns.Data();
1200 legendString.Append(Form(
" (%s)", legendComment[iFile].Data()));
1201 legend[1]->AddEntry(jetHtProfiles[iFile][iProfileType][nIov - 2], legendString.Data(),
"l");
1202 legend[2]->AddEntry((TObject *)
nullptr, Form(
"%s:", legendComment[iFile].Data()),
"");
1211 if (!doNotDrawEta) {
1212 for (
int iFile = 0; iFile < compareFiles; iFile++) {
1213 if (jetHtProfiles[iFile][iProfileType][nIov - 1] !=
nullptr) {
1214 jetHtProfiles[iFile][iProfileType][nIov - 1]->SetLineColor(fileColor[iFile]);
1215 jetHtProfiles[iFile][iProfileType][nIov - 1]->SetLineWidth(2);
1216 jetHtProfiles[iFile][iProfileType][nIov - 1]->SetLineStyle(2);
1217 jetHtProfiles[iFile][iProfileType][nIov - 1]->Draw(
"same,HIST,C");
1218 legend[0]->AddEntry(jetHtProfiles[iFile][iProfileType][nIov - 1],
"|#eta| < 1",
"l");
1224 if (!doNotDrawEta) {
1231 gPad->GetCanvas()->SaveAs(Form(
"output/%s%s_allIovs.pdf", profileName[iProfileType].Data(), saveComment));
1237 if (makeIovListForSlides)
1238 iovFileForSlides.close();
1241 TLegend *trendLegend;
1259 TLatex *tagWriter =
new TLatex();
1260 tagWriter->SetTextFont(trendTagTextFont);
1261 tagWriter->SetTextSize(trendTagTextSize);
1263 TString xTitle =
"Run index";
1264 if (useLuminosityForTrends)
1265 xTitle =
"Delivered luminosity (1/fb)";
1267 for (
int iTrend = 0; iTrend < knTrendTypes; iTrend++) {
1268 if (!drawTrend[iTrend])
1270 for (
int iWidePt = 0; iWidePt < nWidePtBins; iWidePt++) {
1271 legendX1 = 0.65 + trendLegendShiftTotalX;
1272 legendY1 = 0.83 - (profileLegendTextSize + 0.02) * compareFiles + trendLegendShiftTotalY;
1273 legendX2 = 0.9 + trendLegendShiftTotalX;
1274 legendY2 = 0.9 + trendLegendShiftTotalY;
1275 trendLegend =
new TLegend(legendX1, legendY1, legendX2, legendY2);
1276 trendLegend->SetFillStyle(0);
1277 trendLegend->SetBorderSize(0);
1278 trendLegend->SetTextSize(trendLegendTextSize);
1279 trendLegend->SetTextFont(trendLegendTextFont);
1280 trendLegend->SetHeader(
1281 Form(
"%s error trend for p_{T} > %.0f GeV", profileYaxis[iTrend + 6].Data(), widePtBinBorders.at(iWidePt)));
1283 for (
int iFile = 0; iFile < compareFiles; iFile++) {
1284 gBigTrend[iFile][iTrend][iWidePt]->SetMarkerColor(fileColor[iFile]);
1285 gBigTrend[iFile][iTrend][iWidePt]->SetMarkerStyle(fileMarkerStyle[iFile]);
1286 gBigTrend[iFile][iTrend][iWidePt]->SetMarkerSize(fileMarkerSize[iFile]);
1287 if (copyErrorColor[iFile])
1288 gBigTrend[iFile][iTrend][iWidePt]->SetLineColor(fileColor[iFile]);
1294 trendZoomLow[iTrend],
1295 trendZoomHigh[iTrend],
1297 Form(
"#LT #sigma(%s) #GT", profileYaxis[iTrend + 6].Data()),
1301 gBigTrend[iFile][iTrend][iWidePt]->Draw(
"p,same");
1304 trendLegend->AddEntry(gBigTrend[iFile][iTrend][iWidePt], legendComment[iFile].Data(),
"p");
1308 trendLegend->Draw();
1311 if (drawYearLines) {
1312 for (
int thisRun : linePosition) {
1314 lumiLine =
new TLine(lumiX, trendZoomLow[iTrend], lumiX, trendZoomHigh[iTrend]);
1315 lumiLine->SetLineColor(yearLineColor);
1316 lumiLine->SetLineWidth(yearLineWidth);
1317 lumiLine->SetLineStyle(yearLineStyle);
1325 tagWriter->DrawLatexNDC(
1326 trendTagPositionX.at(iTag), trendTagPositionY.at(iTag), trendTagText.at(iTag).c_str());
1332 gPad->GetCanvas()->SaveAs(Form(
1333 "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