5from argparse
import ArgumentParser
15 with open(os.path.join(
"/proc", str(pid),
"status"))
as f:
17 _vmsize = [line
for line
in lines
if line.startswith(
"VmSize")][0]
18 vmsize = int(_vmsize.split()[1])
20 pmsize = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
21 print(f
"memory: virtual = {vmsize / 1.0e3:5.2F} MB physical = {pmsize / 1.0e3:5.2F} MB")
27import global_variables
34parser = ArgumentParser()
36parser.add_argument(
"-f",
"--inputFile", dest=
"inputFile", help=
"Input file", required=
True)
38 "-n",
"--nEvents", dest=
"nEvents", help=
"Number of events to reconstruct", required=
False, default=999999, type=int
40parser.add_argument(
"-g",
"--geoFile", dest=
"geoFile", help=
"ROOT geofile", required=
True)
42 "--noVertexing", dest=
"noVertexing", help=
"switch off vertexing", required=
False, action=
"store_true"
46 dest=
"withNoStrawSmearing",
47 help=
"no smearing of distance to wire, default on",
52 "--withT0", dest=
"withT0", help=
"simulate arbitrary T0 and correct for it", required=
False, action=
"store_true"
58 help=
"First event of input file to use",
66 help=
"Options for pattern recognition. \n\
67 Segments (default) : drift-circle segments matched across the magnet, requires --trackFitter acts.\n\
68 Truth : MC truth hit assignment -- for simulation only, requires --trackFitter acts.\n\
69 FH : Hough transform (deprecated).\n\
70 AR : Artificial retina (deprecated, default with --trackFitter genfit).\n\
71 TemplateMatching : Tracks are searched for based on the template: track seed + hits within a window around the seed (deprecated).",
73 choices=[
"FH",
"AR",
"TemplateMatching",
"Truth",
"Segments"],
79 help=
"Track fitter to use. \n\
80 acts (default) : writes RecoTracks/RecoVertices/Particles branches.\n\
81 genfit (deprecated) : writes FitTracks/goodTracks branches.",
83 choices=[
"genfit",
"acts"],
86parser.add_argument(
"-dy", dest=
"dy", help=
"Max height of tank", required=
False, default=
None, type=int)
87parser.add_argument(
"--Debug", dest=
"Debug", help=
"Switch on debugging", required=
False, action=
"store_true")
89 "--caloScoringPlanePID",
90 dest=
"caloScoringPlanePID",
91 help=
"YAML file with energy-dependent electron/hadron/muon confusion matrices for the scoring plane "
92 "(format: CaloScoringPlane/README.md, provided: geometry/caloScoringPlane_pid_provided.yaml); default: perfect PID",
99 help=
"Print reconstruction validation summary after finishing",
103options = parser.parse_args()
104if options.patRec
is None:
105 options.patRec =
"Segments" if options.trackFitter ==
"acts" else "AR"
106if options.trackFitter ==
"genfit":
108 "GenFit tracking and vertexing (--trackFitter genfit) are deprecated and will be removed, "
109 "use --trackFitter acts",
113if options.patRec
in (
"FH",
"AR",
"TemplateMatching"):
115 f
"--patRec {options.patRec} is deprecated and will be removed, use --patRec Segments with --trackFitter acts",
119if options.patRec
in (
"Truth",
"Segments")
and options.trackFitter !=
"acts":
120 parser.error(f
"--patRec {options.patRec} requires --trackFitter acts")
121vertexing =
not options.noVertexing
128 tmp = options.inputFile.split(
".")
130 dy = float(tmp[1] +
"." + tmp[2])
131 except (ValueError, IndexError):
135 "configured to process ",
139 " starting with event ",
141 " with option Yheight = ",
145 " and pattern reco ",
147 " and track fitter ",
151if not options.inputFile.find(
"_rec.root") < 0:
152 outFile = options.inputFile
153 options.inputFile = outFile.replace(
"_rec.root",
".root")
155 outFile = options.inputFile.replace(
".root",
"_rec.root")
157 tmp = outFile.split(
"/")
158 outFile = tmp[len(tmp) - 1]
160if not options.geoFile:
161 tmp = options.inputFile.replace(
"ship.",
"geofile_full.")
162 options.geoFile = tmp.replace(
"_rec",
"")
164fgeo = ROOT.TFile.Open(options.geoFile)
165geoMat = ROOT.genfit.TGeoMaterialInterface()
167from ShipGeoConfig
import load_from_root_file
170ShipGeo = load_from_root_file(fgeo,
"ShipGeo")
174 ut.bookHist(h,
"distu",
"distance to wire", 100, 0.0, 5.0)
175 ut.bookHist(h,
"distv",
"distance to wire", 100, 0.0, 5.0)
176 ut.bookHist(h,
"disty",
"distance to wire", 100, 0.0, 5.0)
177 ut.bookHist(h,
"nmeas",
"nr measurements", 100, 0.0, 50.0)
178 ut.bookHist(h,
"chi2",
"Chi2/DOF", 100, 0.0, 20.0)
182run = ROOT.FairRunSim()
183run.SetName(
"TGeant4")
186sink = ROOT.FairRootFileSink(tempfile.mktemp(suffix=
".root"))
188ROOT.SetOwnership(sink,
False)
189run.SetUserConfig(
"g4Config_basic.C")
190rtdb = run.GetRuntimeDb()
194sGeo = fgeo[
"FAIRGeom"]
198if hasattr(ShipGeo.Bfield,
"fieldMap"):
202global_variables.debug = options.Debug
203global_variables.fieldMaker = fieldMaker
204global_variables.withT0 = options.withT0
205global_variables.patRec = options.patRec
206global_variables.trackFitter = options.trackFitter
207global_variables.vertexing = vertexing
208global_variables.ShipGeo = ShipGeo
209global_variables.modules = modules
210global_variables.withNoStrawSmearing = options.withNoStrawSmearing
211global_variables.h = h
212global_variables.iEvent = 0
213global_variables.caloScoringPlanePIDFile = options.caloScoringPlanePID
219nEntries = SHiP.sTree.GetEntries()
221for global_variables.iEvent
in range(options.firstEvent, min(nEntries, options.firstEvent + options.nEvents)):
222 if global_variables.iEvent % 1000 == 0
or global_variables.debug:
223 print(
"event ", global_variables.iEvent)
224 rc = SHiP.sTree.GetEvent(global_variables.iEvent)
addVMCFields(shipGeo, str controlFile="", bool verbose=False, bool withVirtualMC=True)
configure(run, ship_geo, str|None geofile=None)
None configure(darkphoton=None)