SND@LHC Software
Loading...
Searching...
No Matches
runMufluxDigi.py
Go to the documentation of this file.
1#!/usr/bin/env python
2
3from __future__ import print_function
4from __future__ import division
5firstEvent = 0
6dy = None
7
8import resource
10 # Getting virtual memory size
11 pid = os.getpid()
12 with open(os.path.join("/proc", str(pid), "status")) as f:
13 lines = f.readlines()
14 _vmsize = [l for l in lines if l.startswith("VmSize")][0]
15 vmsize = int(_vmsize.split()[1])
16 #Getting physical memory size
17 pmsize = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
18 print("memory: virtuell = %5.2F MB physical = %5.2F MB"%(vmsize/1.0E3,pmsize/1.0E3))
19
20import ROOT,os,sys,getopt
21import global_variables
22import rootUtils as ut
23import shipunit as u
24import shipRoot_conf
25
27
28from argparse import ArgumentParser
29parser = ArgumentParser()
30parser.add_argument("-f", "--inputFile", dest="inputFile", help="single input file", required=True)
31parser.add_argument("-g", "--geoFile", dest="geoFile", help="geofile", required=True)
32parser.add_argument("-n", "--nEvents", dest="nEvents", help="number of events to process", default=100000)
33parser.add_argument("-d", "--Debug", dest="debug", help="debug", default=False)
34
35options = parser.parse_args()
36
37outFile = options.inputFile.replace('.root','_dig.root')
38# outfile should be in local directory
39tmp = outFile.split('/')
40outFile = tmp[len(tmp)-1]
41os.system('cp '+options.inputFile+' '+outFile)
42
43fgeo = ROOT.TFile.Open(options.geoFile)
44from ShipGeoConfig import ConfigRegistry
45from rootpyPickler import Unpickler
46#load Shipgeo dictionary
47upkl = Unpickler(fgeo)
48ShipGeo = upkl.load('ShipGeo')
49
50# -----Create geometry----------------------------------------------
51import charmDet_conf
52run = ROOT.FairRunSim()
53run.SetName("TGeant4") # Transport engine
54run.SetOutputFile(ROOT.TMemFile('output', 'recreate')) # Output file
55run.SetUserConfig("g4Config_basic.C") # geant4 transport not used, only needed for the mag field
56rtdb = run.GetRuntimeDb()
57modules = charmDet_conf.configure(run,ShipGeo)
58fgeo.FAIRGeom
59
60# make global variables
61global_variables.debug = options.debug
62global_variables.ShipGeo = ShipGeo
63
64global_variables.iEvent = 0
65
66# import reco tasks
67import MufluxDigi
68SHiP = MufluxDigi.MufluxDigi(outFile)
69
70nEvents = min(SHiP.sTree.GetEntries(),int(options.nEvents))
71# main loop
72for global_variables.iEvent in range(firstEvent, nEvents):
73 if global_variables.iEvent % 50000 == 0 or global_variables.debug:
74 print('event ', global_variables.iEvent, nEvents - firstEvent)
75 SHiP.iEvent = global_variables.iEvent
76 rc = SHiP.sTree.GetEvent(global_variables.iEvent)
77 SHiP.digitize()
78 # memory monitoring
79 # mem_monitor()
80
81# end loop over events
82SHiP.finish()
configure(run, ship_geo, Gfield='')
configure(darkphoton=None)