Skip to content
Snippets Groups Projects
Commit 21711f9f authored by Dmitry Kalinkin's avatar Dmitry Kalinkin
Browse files

move to a separate rule, avoid overwriting files

parent 8cce9607
No related branches found
No related tags found
No related merge requests found
Pipeline #109352 failed
// Code to draw average number of hits vs eta at the generated level
// Shyam Kumar; shyam055119@gmail.com; shyam.kumar@ba.infn.it
void NhitsvsEta_ePIC(TString filePath="")
void NhitsvsEta_ePIC(TString filePath="", TString label="", TString output_prefix=".")
{
gStyle->SetPalette(1);
......@@ -18,9 +18,6 @@ void NhitsvsEta_ePIC(TString filePath="")
// Find the last occurrence of '/'
Int_t lastSlashPos = filePath.Last('/');
// Extract the file name
TString filename = (lastSlashPos != kNPOS) ? filePath(lastSlashPos + 1, filePath.Length()) : filePath;
TTreeReaderArray<Float_t> charge(myReader, "MCParticles.charge");
TTreeReaderArray<Double_t> vx_mc(myReader, "MCParticles.vertex.x");
TTreeReaderArray<Double_t> vy_mc(myReader, "MCParticles.vertex.y");
......@@ -109,10 +106,8 @@ void NhitsvsEta_ePIC(TString filePath="")
c1->SetGridx();
c1->SetGridy();
filename.Resize(filename.Sizeof()-14); // keep filename up to energy
TProfile* hits = new TProfile("hits","Nhits (#theta)",70,-3.5,3.5);
hits->SetTitle(Form("%s;#eta_{mc};Nhits",filename.Data()));
hits->SetTitle(Form("%s;#eta_{mc};Nhits",label.Data()));
hits->GetXaxis()->CenterTitle();
hits->GetYaxis()->CenterTitle();
hits->SetMinimum(0.);
......@@ -241,7 +236,7 @@ void NhitsvsEta_ePIC(TString filePath="")
gPad->SetTicks(1,1);
hits->SetLineWidth(2);
hits->Draw("hist");
c1->SaveAs(Form("%s.png",filename.Data()));
c1->SaveAs(Form("Nhitsvsmom%s.root",filename.Data()));
c1->SaveAs(Form("%s/Nhits_vs_eta.png", output_prefix.Data()));
c1->SaveAs(Form("%s/Nhits_vs_eta.root", output_prefix.Data()));
}
......@@ -63,17 +63,34 @@ rule tracking_performance_sim_hadd:
hadd {output} {input.simoutput}
"""
rule tracking_performance_at_momentum:
rule tracking_performance_hit_maps:
input:
script="benchmarks/tracking_performances/Tracking_Performances.C",
script_hitsmap="benchmarks/tracking_performances/draw_hits.C",
script_nhits_eta="benchmarks/tracking_performances/NhitsvsEta_ePIC.C",
outsim=lambda wildcards:
expand(
"sim_output/tracking_performance/{DETECTOR_CONFIG}/{PARTICLE}/{ENERGY}/{PARTICLE}.{ENERGY}.edm4hep.root",
DETECTOR_CONFIG="epic_craterlake_tracking_only", PARTICLE=wildcards.PARTICLE,
ENERGY=f"{float(wildcards.MOMENTUM):.0f}GeV" if float(wildcards.MOMENTUM) >= 1 else f"{float(wildcards.MOMENTUM) * 1000:.0f}MeV",
)
sim_hadd=expand(
"sim_output/tracking_performance/{DETECTOR_CONFIG}/{{PARTICLE}}/{{MOMENTUM}}/{{PARTICLE}}.{{MOMENTUM}}.edm4hep.root",
DETECTOR_CONFIG="epic_craterlake_tracking_only",
)
output:
"local/{SEEDING}/pi-/{MOMENTUM}/{SEEDING_IGNORE}/{PARTICLE}/hitsxy_dd4hep.png",
"local/{SEEDING}/pi-/{MOMENTUM}/{SEEDING_IGNORE}/{PARTICLE}/hitsxy_dd4hep.eps",
"local/{SEEDING}/pi-/{MOMENTUM}/{SEEDING_IGNORE}/{PARTICLE}/hitsxy_dd4hep.root",
"local/{SEEDING}/pi-/{MOMENTUM}/{SEEDING_IGNORE}/{PARTICLE}/hitsrz_dd4hep.png",
"local/{SEEDING}/pi-/{MOMENTUM}/{SEEDING_IGNORE}/{PARTICLE}/hitsrz_dd4hep.eps",
"local/{SEEDING}/pi-/{MOMENTUM}/{SEEDING_IGNORE}/{PARTICLE}/hitsrz_dd4hep.root",
"local/{SEEDING}/pi-/{MOMENTUM}/{SEEDING_IGNORE}/{PARTICLE}/Nhits_vs_eta.png",
"local/{SEEDING}/pi-/{MOMENTUM}/{SEEDING_IGNORE}/{PARTICLE}/Nhits_vs_eta.root",
shell: """
OUTPUT_PREFIX="$(dirname {output[0]})"
root -l -b -q {input.script_hitsmap}'("{input.outsim}", "'$OUTPUT_PREFIX'")'
root -l -b -q {input.script_nhits_eta}'("{input.outsim}", "{wildcards.MOMENTUM}", "'$OUTPUT_PREFIX'")'
"""
rule tracking_performance_at_momentum:
input:
script="benchmarks/tracking_performances/Tracking_Performances.C",
hit_maps=lambda wildcards:
[ "{CAMPAIGN}/{SEEDING}/pi-/{MOMENTUM}/{SEEDING_IGNORE}/{PARTICLE}/Nhits_vs_eta.png".format(**wildcards) ]
if wildcards.CAMPAIGN == "local" else
[],
# TODO pass as a file list?
......@@ -107,8 +124,6 @@ fi
hadd {output.combined_root} {input.sim}
cd {wildcards.CAMPAIGN}
root -l -b -q ../{input.script}'("../{output.combined_root}", "{wildcards.PARTICLE}", {wildcards.MOMENTUM}, 0.15, '$TRUTH_SEEDING')'
root -l -b -q ../{input.script_hitsmap}'("../{input.outsim}")'
root -l -b -q ../{input.script_nhits_eta}'("../{input.outsim}")'
"""
......
......@@ -8,7 +8,7 @@
#include <TLegend.h>
#include <TMath.h>
void draw_hits(TString filename="")
void draw_hits(TString filename="", TString output_prefix=".")
{
//==========Style of the plot============
......@@ -97,9 +97,9 @@ void draw_hits(TString filename="")
l->AddEntry(hitsxy_barrel_tof,"TOFBarrelHits");
l->AddEntry(hitsxy_barrel_mm_out,"OuterMPGDBarrelHits");
l->Draw();
c1->SaveAs("hitsxy_dd4hep.png");
c1->SaveAs("hitsxy_dd4hep.eps");
c1->SaveAs("hitsxy_dd4hep.root");
c1->SaveAs(Form("%s/hitsxy_dd4hep.png", output_prefix.Data()));
c1->SaveAs(Form("%s/hitsxy_dd4hep.eps", output_prefix.Data()));
c1->SaveAs(Form("%s/hitsxy_dd4hep.root", output_prefix.Data()));
TCanvas *c2 = new TCanvas("c2","c2",1200,1000);
c2->SetMargin(0.09, 0.03 ,0.1,0.06);
......@@ -301,9 +301,9 @@ void draw_hits(TString filename="")
l1->AddEntry(hitsrz_bwd_mpgd,"BackwardMPGDEndcapHits");
l1->Draw();
c2->SaveAs("hitsrz_dd4hep.png");
c2->SaveAs("hitsrz_dd4hep.eps");
c2->SaveAs("hitsrz_dd4hep.root");
c2->SaveAs(Form("%s/hitsrz_dd4hep.png", output_prefix.Data()));
c2->SaveAs(Form("%s/hitsrz_dd4hep.eps", output_prefix.Data()));
c2->SaveAs(Form("%s/hitsrz_dd4hep.root", output_prefix.Data()));
// Timer Stop
timer.Stop();
Double_t realtime = timer.RealTime();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment