Skip to content

Commit

Permalink
feat: draw PID limit boxes on eta vs. P plot in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
c-dilks committed May 1, 2023
1 parent 2cc451f commit 7d2d887
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 5 deletions.
43 changes: 40 additions & 3 deletions macro/ci/postprocess_eta_vs_p_forPID.C
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,46 @@ R__LOAD_LIBRARY(EpicAnalysis)
// plot eta vs. p in one bin, for PID coverage requests
void postprocess_eta_vs_p_forPID(TString infile="out/coverage.fastsim.root") {
PostProcessor *P = new PostProcessor(infile);
P->Op()->Payload( [&P](Histos *H) {
P->DrawSingle(H,"etaVsP","COLZ");
});
auto draw_payload = [&P] (Histos *H) {
auto draw_formatting = [] (auto hist, auto canv) {
gStyle->SetPalette(kBird);
std::vector<std::tuple<TString,TBox*,Color_t>> limits;
limits.push_back({
"#splitline{dRICH}{gas}",
new TBox(
9.5, // p min
1.3, // eta min
50.0, // p max
3.7 // eta max
),
kRed
});
limits.push_back({
"#splitline{dRICH}{aerogel}",
new TBox(
2.0, // p min
1.3, // eta min
10.3, // p max
3.7 // eta max
),
kBlue
});
for(auto [name,box,color] : limits) {
auto box_line = (TBox*) box->Clone();
box->SetFillColorAlpha(color,0.3);
box->Draw();
box_line->SetLineWidth(3);
box_line->SetFillStyle(kFEmpty);
box_line->SetLineColor(color);
box_line->Draw();
auto text = new TLatex(1.1*box->GetX1(), (box->GetY1()+box->GetY2())/2, name);
text->SetTextColor(color);
text->Draw();
}
};
P->DrawSingle(H, "etaVsP", "COLZ", 0, false, draw_formatting);
};
P->Op()->Payload(draw_payload);
P->Execute();
P->Finish();
}
15 changes: 14 additions & 1 deletion src/PostProcessor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,17 @@ void PostProcessor::FinishDumpAve(TString datFile) {
* - `profileAxis` will draw a TProfile on the specified axis, for 2D dists
* - 0=disabled(default), 1=x-axis, 2=y-axis
* - `profileOnly` draw only the TProfile, for 2D dists
* - `extra_lambda` can be used to apply additional custom formatting, etc.
*/
void PostProcessor::DrawSingle(Histos *H, TString histName, TString drawFormat, Int_t profileAxis, Bool_t profileOnly) {
void PostProcessor::DrawSingle(
Histos *H,
TString histName,
TString drawFormat,
Int_t profileAxis,
Bool_t profileOnly,
std::function<void(TH1*,TCanvas*)> extra_lambda
)
{
cout << "draw single plot " << histName << "..." << endl;
TH1 *hist = H->Hist(histName);
if(hist==nullptr) {
Expand Down Expand Up @@ -275,6 +284,10 @@ void PostProcessor::DrawSingle(Histos *H, TString histName, TString drawFormat,
prof->Write();
}

// apply custom formatting
extra_lambda(hist, canv);

// print and write
canv->Print(pngDir+"/"+canvN+".png");
outfile->cd("/");
canv->Write();
Expand Down
10 changes: 9 additions & 1 deletion src/PostProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <map>
#include <iomanip>
#include <functional>

// root
#include "TFile.h"
Expand Down Expand Up @@ -69,7 +70,14 @@ class PostProcessor
// - you are welcome to add your own algorithms
void DumpHist(TString datFile, TString histSet, TString varName);
void DumpAve(TString datFile, Histos *H, TString cutName);
void DrawSingle(Histos *H, TString histName, TString drawFormat="", Int_t profileAxis=0, Bool_t profileOnly=false);
void DrawSingle(
Histos *H,
TString histName,
TString drawFormat = "",
Int_t profileAxis = 0,
Bool_t profileOnly = false,
std::function<void(TH1*,TCanvas*)> extra_lambda = [] (TH1* h, TCanvas *c) {}
);
void DrawSingle(TString histSet, TString histName);
void DrawRatios(
TString outName, Histos *numerSet, Histos *denomSet, Bool_t plotRatioOnly=false
Expand Down

0 comments on commit 7d2d887

Please sign in to comment.