5from argparse
import ArgumentParser
16 with open(os.path.join(
"/proc", str(pid),
"status"))
as f:
18 _vmsize = [line
for line
in lines
if line.startswith(
"VmSize")][0]
19 vmsize = int(_vmsize.split()[1])
21 pmsize = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
22 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=
"Option for pattern recognition without MC truth. \n\
67 FH : Hough transform.\n\
68 AR : Artificial retina.\n\
69 TemplateMatching : Tracks are searched for based on the template: track seed + hits within a window around the seed.",
71 choices=[
"FH",
"AR",
"TemplateMatching"],
74parser.add_argument(
"-dy", dest=
"dy", help=
"Max height of tank", required=
False, default=
None, type=int)
75parser.add_argument(
"--Debug", dest=
"Debug", help=
"Switch on debugging", required=
False, action=
"store_true")
77options = parser.parse_args()
78vertexing =
not options.noVertexing
84 tmp = options.inputFile.split(
".")
86 dy = float(tmp[1] +
"." + tmp[2])
87 except (ValueError, IndexError):
91 "configured to process ",
95 " starting with event ",
97 " with option Yheight = ",
101 " and real pattern reco ",
105if not options.inputFile.find(
"_rec.root") < 0:
106 outFile = options.inputFile
107 options.inputFile = outFile.replace(
"_rec.root",
".root")
109 outFile = options.inputFile.replace(
".root",
"_rec.root")
111 tmp = outFile.split(
"/")
112 outFile = tmp[len(tmp) - 1]
114if not options.geoFile:
115 tmp = options.inputFile.replace(
"ship.",
"geofile_full.")
116 options.geoFile = tmp.replace(
"_rec",
"")
118fgeo = ROOT.TFile.Open(options.geoFile)
119geoMat = ROOT.genfit.TGeoMaterialInterface()
121from ShipGeoConfig
import load_from_root_file
124ShipGeo = load_from_root_file(fgeo,
"ShipGeo")
128 ut.bookHist(h,
"distu",
"distance to wire", 100, 0.0, 5.0)
129 ut.bookHist(h,
"distv",
"distance to wire", 100, 0.0, 5.0)
130 ut.bookHist(h,
"disty",
"distance to wire", 100, 0.0, 5.0)
131 ut.bookHist(h,
"nmeas",
"nr measurements", 100, 0.0, 50.0)
132 ut.bookHist(h,
"chi2",
"Chi2/DOF", 100, 0.0, 20.0)
136run = ROOT.FairRunSim()
137run.SetName(
"TGeant4")
138run.SetSink(ROOT.FairRootFileSink(ROOT.TMemFile(
"output",
"recreate")))
139run.SetUserConfig(
"g4Config_basic.C")
140rtdb = run.GetRuntimeDb()
147if hasattr(ShipGeo.Bfield,
"fieldMap"):
151global_variables.debug = options.Debug
152global_variables.fieldMaker = fieldMaker
153global_variables.pidProton = pidProton
154global_variables.withT0 = options.withT0
155global_variables.realPR = options.realPR
156global_variables.vertexing = vertexing
157global_variables.ShipGeo = ShipGeo
158global_variables.modules = modules
159global_variables.withNoStrawSmearing = options.withNoStrawSmearing
160global_variables.h = h
161global_variables.iEvent = 0
167options.nEvents = min(SHiP.sTree.GetEntries(), options.nEvents)
169for global_variables.iEvent
in range(options.firstEvent, options.nEvents):
170 if global_variables.iEvent % 1000 == 0
or global_variables.debug:
171 print(
"event ", global_variables.iEvent)
172 rc = SHiP.sTree.GetEvent(global_variables.iEvent)
def addVMCFields(shipGeo, str controlFile="", bool verbose=False, bool withVirtualMC=True)
def configure(run, ship_geo)
None configure(darkphoton=None)
int open(const char *, int)
Opens a file descriptor.