Skip to content

Commit 7d2d887

Browse files
committed
feat: draw PID limit boxes on eta vs. P plot in CI
1 parent 2cc451f commit 7d2d887

File tree

3 files changed

+63
-5
lines changed

3 files changed

+63
-5
lines changed

macro/ci/postprocess_eta_vs_p_forPID.C

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,46 @@ R__LOAD_LIBRARY(EpicAnalysis)
66
// plot eta vs. p in one bin, for PID coverage requests
77
void postprocess_eta_vs_p_forPID(TString infile="out/coverage.fastsim.root") {
88
PostProcessor *P = new PostProcessor(infile);
9-
P->Op()->Payload( [&P](Histos *H) {
10-
P->DrawSingle(H,"etaVsP","COLZ");
11-
});
9+
auto draw_payload = [&P] (Histos *H) {
10+
auto draw_formatting = [] (auto hist, auto canv) {
11+
gStyle->SetPalette(kBird);
12+
std::vector<std::tuple<TString,TBox*,Color_t>> limits;
13+
limits.push_back({
14+
"#splitline{dRICH}{gas}",
15+
new TBox(
16+
9.5, // p min
17+
1.3, // eta min
18+
50.0, // p max
19+
3.7 // eta max
20+
),
21+
kRed
22+
});
23+
limits.push_back({
24+
"#splitline{dRICH}{aerogel}",
25+
new TBox(
26+
2.0, // p min
27+
1.3, // eta min
28+
10.3, // p max
29+
3.7 // eta max
30+
),
31+
kBlue
32+
});
33+
for(auto [name,box,color] : limits) {
34+
auto box_line = (TBox*) box->Clone();
35+
box->SetFillColorAlpha(color,0.3);
36+
box->Draw();
37+
box_line->SetLineWidth(3);
38+
box_line->SetFillStyle(kFEmpty);
39+
box_line->SetLineColor(color);
40+
box_line->Draw();
41+
auto text = new TLatex(1.1*box->GetX1(), (box->GetY1()+box->GetY2())/2, name);
42+
text->SetTextColor(color);
43+
text->Draw();
44+
}
45+
};
46+
P->DrawSingle(H, "etaVsP", "COLZ", 0, false, draw_formatting);
47+
};
48+
P->Op()->Payload(draw_payload);
1249
P->Execute();
1350
P->Finish();
1451
}

src/PostProcessor.cxx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,17 @@ void PostProcessor::FinishDumpAve(TString datFile) {
222222
* - `profileAxis` will draw a TProfile on the specified axis, for 2D dists
223223
* - 0=disabled(default), 1=x-axis, 2=y-axis
224224
* - `profileOnly` draw only the TProfile, for 2D dists
225+
* - `extra_lambda` can be used to apply additional custom formatting, etc.
225226
*/
226-
void PostProcessor::DrawSingle(Histos *H, TString histName, TString drawFormat, Int_t profileAxis, Bool_t profileOnly) {
227+
void PostProcessor::DrawSingle(
228+
Histos *H,
229+
TString histName,
230+
TString drawFormat,
231+
Int_t profileAxis,
232+
Bool_t profileOnly,
233+
std::function<void(TH1*,TCanvas*)> extra_lambda
234+
)
235+
{
227236
cout << "draw single plot " << histName << "..." << endl;
228237
TH1 *hist = H->Hist(histName);
229238
if(hist==nullptr) {
@@ -275,6 +284,10 @@ void PostProcessor::DrawSingle(Histos *H, TString histName, TString drawFormat,
275284
prof->Write();
276285
}
277286

287+
// apply custom formatting
288+
extra_lambda(hist, canv);
289+
290+
// print and write
278291
canv->Print(pngDir+"/"+canvN+".png");
279292
outfile->cd("/");
280293
canv->Write();

src/PostProcessor.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <map>
77
#include <iomanip>
8+
#include <functional>
89

910
// root
1011
#include "TFile.h"
@@ -69,7 +70,14 @@ class PostProcessor
6970
// - you are welcome to add your own algorithms
7071
void DumpHist(TString datFile, TString histSet, TString varName);
7172
void DumpAve(TString datFile, Histos *H, TString cutName);
72-
void DrawSingle(Histos *H, TString histName, TString drawFormat="", Int_t profileAxis=0, Bool_t profileOnly=false);
73+
void DrawSingle(
74+
Histos *H,
75+
TString histName,
76+
TString drawFormat = "",
77+
Int_t profileAxis = 0,
78+
Bool_t profileOnly = false,
79+
std::function<void(TH1*,TCanvas*)> extra_lambda = [] (TH1* h, TCanvas *c) {}
80+
);
7381
void DrawSingle(TString histSet, TString histName);
7482
void DrawRatios(
7583
TString outName, Histos *numerSet, Histos *denomSet, Bool_t plotRatioOnly=false

0 commit comments

Comments
 (0)