2from __future__
import print_function
3from __future__
import division
4from argparse
import ArgumentParser
13 with open(os.path.join(
"/proc", str(pid),
"status"))
as f:
15 _vmsize = [l
for l
in lines
if l.startswith(
"VmSize")][0]
16 vmsize = int(_vmsize.split()[1])
18 pmsize = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
19 print(
"memory: virtuell = %5.2F MB physical = %5.2F MB"%(vmsize/1.0E3,pmsize/1.0E3))
22import global_variables
29parser = ArgumentParser()
31parser.add_argument(
"-f",
"--inputFile", dest=
"inputFile", help=
"Input file", required=
True)
32parser.add_argument(
"-n",
"--nEvents", dest=
"nEvents", help=
"Number of events to reconstruct", required=
False, default=999999,type=int)
33parser.add_argument(
"-g",
"--geoFile", dest=
"geoFile", help=
"ROOT geofile", required=
True)
34parser.add_argument(
"--noVertexing", dest=
"noVertexing", help=
"switch off vertexing", required=
False, action=
"store_true")
35parser.add_argument(
"--noStrawSmearing", dest=
"withNoStrawSmearing", help=
"no smearing of distance to wire, default on", required=
False, action=
"store_true")
36parser.add_argument(
"--withT0", dest=
"withT0", help=
"simulate arbitrary T0 and correct for it", required=
False, action=
"store_true")
37parser.add_argument(
"--ecalDebugDraw", dest=
"EcalDebugDraw", help=
"switch in debog for ECAL", required=
False, action=
"store_true")
38parser.add_argument(
"--saveDisk", dest=
"saveDisk", help=
"if set, will remove input file, only rec file kept", required=
False, action=
"store_true")
39parser.add_argument(
"-i",
"--firstEvent",dest=
"firstEvent", help=
"First event of input file to use", required=
False, default=0,type=int)
40parser.add_argument(
"--realPR", dest=
"realPR", help=
"Option for pattern recognition without MC truth. \n\
41 FH : Hough transform.\n\
42 AR : Artificial retina.\n\
43 TemplateMatching : Tracks are searched for based on the template: track seed + hits within a window around the seed."\
44 , required=
False, choices=[
'FH',
'AR',
'TemplateMatching'], default=
'')
45parser.add_argument(
"-dy", dest=
"dy", help=
"Max height of tank", required=
False, default=
None,type=int)
46parser.add_argument(
"--Debug", dest=
"Debug", help=
"Switch on debugging", required=
False, action=
"store_true")
48options = parser.parse_args()
49vertexing =
not options.noVertexing
51if options.EcalDebugDraw: ROOT.gSystem.Load(
"libASImage")
56 tmp = options.inputFile.split(
'.')
58 dy = float( tmp[1]+
'.'+tmp[2] )
62print(
'configured to process ', options.nEvents,
' events from ', options.inputFile,
63 ' starting with event ', options.firstEvent,
' with option Yheight = ' ,dy,
64 ' with vertexing', vertexing,
' and real pattern reco ', options.realPR)
65if not options.inputFile.find(
'_rec.root') < 0:
66 outFile = options.inputFile
67 options.inputFile = outFile.replace(
'_rec.root',
'.root')
69 outFile = options.inputFile.replace(
'.root',
'_rec.root')
71 tmp = outFile.split(
'/')
72 outFile = tmp[len(tmp)-1]
73 if options.inputFile[:7]==
"root://" : os.system(
'xrdcp '+options.inputFile+
' '+outFile)
74 elif options.saveDisk: os.system(
'mv '+options.inputFile+
' '+outFile)
75 else : os.system(
'cp '+options.inputFile+
' '+outFile)
77if not options.geoFile:
78 tmp = options.inputFile.replace(
'ship.',
'geofile_full.')
79 options.geoFile = tmp.replace(
'_rec',
'')
81fgeo = ROOT.TFile.Open(options.geoFile)
82geoMat = ROOT.genfit.TGeoMaterialInterface()
84from ShipGeoConfig
import ConfigRegistry
85from rootpyPickler
import Unpickler
88ShipGeo = upkl.load(
'ShipGeo')
89ecalGeoFile = ShipGeo.ecal.File
94 ut.bookHist(h,
'distu',
'distance to wire',100,0.,5.)
95 ut.bookHist(h,
'distv',
'distance to wire',100,0.,5.)
96 ut.bookHist(h,
'disty',
'distance to wire',100,0.,5.)
97 ut.bookHist(h,
'nmeas',
'nr measuerements',100,0.,50.)
98 ut.bookHist(h,
'chi2',
'Chi2/DOF',100,0.,20.)
101run = ROOT.FairRunSim()
102run.SetName(
"TGeant4")
103run.SetOutputFile(ROOT.TMemFile(
'output',
'recreate'))
104run.SetUserConfig(
"g4Config_basic.C")
105rtdb = run.GetRuntimeDb()
112if hasattr(ShipGeo.Bfield,
"fieldMap"):
116global_variables.debug = options.Debug
117global_variables.fieldMaker = fieldMaker
118global_variables.pidProton = pidProton
119global_variables.withT0 = options.withT0
120global_variables.realPR = options.realPR
121global_variables.vertexing = vertexing
122global_variables.ecalGeoFile = ecalGeoFile
123global_variables.ShipGeo = ShipGeo
124global_variables.modules = modules
125global_variables.EcalDebugDraw = options.EcalDebugDraw
126global_variables.withNoStrawSmearing = options.withNoStrawSmearing
127global_variables.h = h
128global_variables.log = log
129global_variables.iEvent = 0
135options.nEvents = min(SHiP.sTree.GetEntries(),options.nEvents)
137for global_variables.iEvent
in range(options.firstEvent, options.nEvents):
138 if global_variables.iEvent % 1000 == 0
or global_variables.debug:
139 print(
'event ', global_variables.iEvent)
140 rc = SHiP.sTree.GetEvent(global_variables.iEvent)
addVMCFields(shipGeo, controlFile='', verbose=False, withVirtualMC=True)
configure(darkphoton=None)