92 {
93 if (toDraw.empty()){
94 return;
95 }
98 return a->event() <
b->event();
99 });
101 std::unique_ptr<TCanvas> summaryCan{};
102 const std::string summaryPdfName = std::format("{:}/All{}.pdf",
103 m_outDir.value(), token.preFixName);
104 if (token.saveSummaryPlot) {
105 ATH_MSG_DEBUG(
"Open "<<summaryPdfName<<
" to dump all canvases in a common file");
108 summaryCan->SaveAs(std::format("{:}[", summaryPdfName).c_str());
109 }
110 if (token.fileFormats.count(
"root") && !
m_outFile) {
117 }
118 ATH_MSG_DEBUG(
"Open "<<outFile<<
" to save the plots in root format");
119 }
120 std::size_t currEvt{toDraw.back()->event()}, plotCount{0};
123 while (!drawMe.unique()) {
124 using namespace std::chrono_literals;
125 ATH_MSG_DEBUG(
"Wait until "<<drawMe->name()<<
" is finished.");
126 std::this_thread::sleep_for(10ms);
127 }
129 if (currEvt != drawMe->event()) {
130 currEvt = drawMe->event();
131 plotCount = 0;
132 }
133 std::string plotName = std::format(
"{:}/{:}/{:}_{:}_{:}_{:}",
m_outDir.value(),
134 token.subDirectory, token.preFixName,
135 drawMe->event(), ++plotCount,
137
139 singleCan->cd();
141 using enum ICanvasObject::AxisRanges;
142 ATH_MSG_VERBOSE(
"Crate new canvas: "<<plotName<<
" ["<<drawMe->corner(xLow)<<
";"<<drawMe->corner(xHigh)
143 <<"], ["<<drawMe->corner(yLow)<<";"<<drawMe->corner(yHigh)<<"].");
144 auto frameH = std::make_unique<TH2F>("frameH",
145 std::format("frame;{:};{:};{:}", drawMe->xTitle(), drawMe->yTitle(), drawMe->zTitle()).c_str(),
146 1, drawMe->corner(xLow), drawMe->corner(xHigh),
147 1, drawMe->corner(yLow), drawMe->corner(yHigh));
148 frameH->Draw("AXIS");
149
150 if (token.drawAtlas) {
151 drawMe->add(
drawAtlasLabel(token.atlasLabelPos[0], token.atlasLabelPos[1], token.atlasLabel));
152 }
153 if (token.drawSqrtS) {
154 drawMe->add(
drawLumiSqrtS(token.atlasLabelPos[0], token.atlasLabelPos[1] - 0.05,
155 token.sqrtSLabel, token.lumiLabel));
156 }
158 for (auto& [primitive, opt] : drawMe->primitives()) {
159 primitive->Draw(
opt.c_str());
160 }
162 if (token.saveSinglePlots) {
163 for (const std::string& fileExt : token.fileFormats) {
164 if (fileExt != "root") {
166 singleCan->SaveAs(std::format("{:}.{:}", plotName, fileExt).c_str());
167 }
168 }
169 }
170 if (token.fileFormats.count("root")) {
172 if (!token.subDirectory.empty()) {
173 writeTo =
m_outFile->GetDirectory(token.subDirectory.c_str());
174 if (!writeTo) {
175 writeTo =
m_outFile->mkdir(token.subDirectory.c_str());
176 }
177 }
178 writeTo->WriteObject(singleCan.get(),
179 std::format("{:}_{:}_{:}_{:}",token.preFixName,
180 drawMe->event(), plotCount,
182 }
183 if (summaryCan) {
184 singleCan->SaveAs(summaryPdfName.c_str());
185 }
186 }
187 if (summaryCan) {
188 summaryCan->SaveAs(std::format("{:}]", summaryPdfName).c_str());
189 }
190 }
#define ATH_MSG_VERBOSE(x)
Gaudi::Property< std::string > m_outDir
Directory into which all plots are written to.
Gaudi::Property< std::string > m_outRootFileName
Name of the ROOT file into which the output Canvases are written (needs root to be in the list of out...
Gaudi::Property< unsigned > m_canvasHeight
Height of all drawn Canvases.
Gaudi::Property< unsigned > m_canvasWidth
Width of all drawn Canvases.
std::shared_ptr< detail::DrawCanvasObject > PlotPtr_t
outFile
Comment Out Those You do not wish to run.
void ensureDirectory(const std::string &path)
Ensures that the subdirectory in the path is created.
std::string removeNonAlphaNum(std::string str)
Removes all non-alpha numerical characters from a string.
std::unique_ptr< TLatex > drawLumiSqrtS(const double xPos, const double yPos, const std::string_view sqrtS="14", const std::string_view lumi="")
Create a luminosity sqrtS label.
std::unique_ptr< TLatex > drawAtlasLabel(const double xPos, const double yPos, const std::string &status="Internal")
Create a ATLAS label.
#define THROW_EXCEPTION(MESSAGE)