FairShip
Loading...
Searching...
No Matches
skim_muonback_plane_smoke Namespace Reference

Functions

int main ()

Detailed Description

Create the run_fixedTarget skim for the ci-sim-muonback-plane smoke test.

Keeps only the events with a muon in PlaneHA from one or more
run_fixedTarget.py outputs (simulated with the hadron absorber field) and
writes them, with the FileSummary of the first input, to
tests/data/muonback_plane_smoke.root. Muons behind the absorber are rare, so
the inputs need a few 10k protons on target in total, e.g.

    python macro/run_fixedTarget.py -n 5000 -e 0.5 -r <run> --AddHadronAbsorberOnly

for a few runs. Re-run only if the output format of run_fixedTarget changes.

Function Documentation

◆ main()

int skim_muonback_plane_smoke.main ( )

Definition at line 26 of file skim_muonback_plane_smoke.py.

26def main() -> int:
27 parser = argparse.ArgumentParser(description=__doc__)
28 parser.add_argument("inputs", nargs="+", help="run_fixedTarget.py output files")
29 parser.add_argument(
30 "--output",
31 type=Path,
32 default=Path(__file__).with_name("muonback_plane_smoke.root"),
33 help="Output skim file",
34 )
35 args = parser.parse_args()
36
37 chain = ROOT.TChain("cbmsim")
38 for f in args.inputs:
39 chain.Add(f)
40 with ROOT.TFile.Open(args.inputs[0]) as first:
41 summary = str(first.Get("FileSummary"))
42
43 out = ROOT.TFile.Open(str(args.output), "RECREATE")
44 skim = chain.CopyTree("Sum$(abs(PlaneHAPoint.fPdgCode) == 13) > 0")
45 skim.Write()
46 out.WriteObject(ROOT.TString(summary), "FileSummary")
47 n = skim.GetEntries()
48 out.Close()
49 print(f"Wrote {n} events to {args.output} ({args.output.stat().st_size} B)")
50 return 0
51
52