Пример #1
0
    def run_ship(self, phiRandom=False, followMuon=True, n_events=10, first_event=0):
        """
        phiRandom = False  # only relevant for muon background generator
        followMuon = True  # only transport muons for a fast muon only background
        """
        r.gErrorIgnoreLevel = r.kWarning
        r.gSystem.Load('libpythia8')

        print ('FairShip setup to produce', n_events, 'events')
        r.gRandom.SetSeed(self.theSeed)
        ship_geo = ConfigRegistry.loadpy(
            '$FAIRSHIP/geometry/geometry_config.py',
            Yheight=self.dy,
            tankDesign=self.vessel_design,
            muShieldDesign=self.shield_design,
            muShieldGeo=self.shield_geo_file)

        run = r.FairRunSim()
        run.SetName(self.mcEngine)  # Transport engine
        run.SetOutputFile(self.output_file)  # Output file
        # user configuration file default g4Config.C
        run.SetUserConfig('g4Config.C')
        modules = shipDet_conf.configure(run, ship_geo)
        primGen = r.FairPrimaryGenerator()
        primGen.SetTarget(ship_geo.target.z0 + 50 * u.m, 0.)
        MuonBackgen = r.MuonBackGenerator()
        MuonBackgen.Init(self.input_file, first_event, phiRandom)
        MuonBackgen.SetSmearBeam(3 * u.cm)  # beam size mimicking spiral
        if self.same_seed:
            MuonBackgen.SetSameSeed(self.same_seed)
        primGen.AddGenerator(MuonBackgen)
        if not n_events:
            n_events = MuonBackgen.GetNevents()
        else:
            n_events = min(n_events, MuonBackgen.GetNevents())
        print ('Process ', n_events, ' from input file, with Phi random=', phiRandom)
        if followMuon:
            modules['Veto'].SetFastMuon()
        run.SetGenerator(primGen)
        run.SetStoreTraj(r.kFALSE)
        run.Init()
        print ('Initialised run.')
        # geomGeant4.setMagnetField()
        if hasattr(ship_geo.Bfield, "fieldMap"):
            fieldMaker = geomGeant4.addVMCFields(ship_geo, '', True)
        print ('Start run of {} events.'.format(n_events))
        run.Run(n_events)
        print ('Finished simulation of {} events.'.format(n_events))

        geofile_output_path = os.path.join(self.output_dir,
                                           "geofile_full.fe_{}_n_events_{}.root" .format(first_event, n_events))
        run.CreateGeometryFile(geofile_output_path)
        # save ShipGeo dictionary in geofile
        saveBasicParameters.execute(geofile_output_path, ship_geo)
        return run
Пример #2
0
    procmu.SetVerboseLevel(2)
# -----Start run----------------------------------------------------
run.Run(nEvents)
# -----Runtime database---------------------------------------------
kParameterMerged = ROOT.kTRUE
parOut = ROOT.FairParRootFileIo(kParameterMerged)
parOut.open(parFile)
rtdb.setOutput(parOut)
rtdb.saveOutput()
rtdb.printParamContexts()
getattr(rtdb, "print")()
# ------------------------------------------------------------------------
run.CreateGeometryFile("%s/geofile_full.%s.root" % (outputDir, tag))
# save ShipGeo dictionary in geofile
import saveBasicParameters
saveBasicParameters.execute("%s/geofile_full.%s.root" % (outputDir, tag),
                            ship_geo)

# checking for overlaps
if checking4overlaps:
    fGeo = ROOT.gGeoManager
    fGeo.SetNmeshPoints(10000)
    fGeo.CheckOverlaps(0.1)  # 1 micron takes 5minutes
    fGeo.PrintOverlaps()
    # check subsystems in more detail
    for x in fGeo.GetTopNode().GetNodes():
        x.CheckOverlaps(0.0001)
        fGeo.PrintOverlaps()
# -----Finish-------------------------------------------------------
timer.Stop()
rtime = timer.RealTime()
ctime = timer.CpuTime()
Пример #3
0
if local and not particleGun:
    gApplyUICommand('/vis/drawVolume')
    gApplyUICommand('/vis/scene/add/trajectories')
    gApplyUICommand('/vis/viewer/zoom 1.5')

t0 = time.time()
gRunManager.BeamOn(nev)
t1 = time.time()
print 'Time used', t1 - t0, ' seconds'
for x in myTimer:
    print x, myTimer[x]

logger.info("output directory: %s" % work_dir)
# save arguments and GIT tags
import saveBasicParameters
saveBasicParameters.execute(f, args, 'SHiP-Params')

if local:
    wrld = snoopyPhys.GetMotherLogical()
    parser = G4GDMLParser()
    geofile = work_dir + '/g4Geom.gdml'
    if os.path.isfile(geofile): os.system('rm ' + geofile)
    parser.Write('g4Geom.gdml', wrld)
    ROOT.TGeoManager()
    geomgr = ROOT.gGeoManager
    geomgr.Import('g4Geom.gdml', 'world', 'new')
    ROOT.gGeoManager.CheckOverlaps()
    ROOT.gGeoManager.PrintOverlaps()
    geomgr.GetTopVolume().Draw('ogl')
Пример #4
0
   recotrack = ROOT.TEveRecTrackD()
   #adding all subnodes for drawing
   for node in top.GetNodes():
     evenode = ROOT.TEveGeoTopNode(sGeo,node)
     evenode.UseNodeTrans()
     gEve.AddGlobalElement(evenode) 
   gEve.FullRedraw3D(kTRUE)
   
 except: pass

saveGeofile = False
import saveBasicParameters
if saveGeofile:
 run.CreateGeometryFile("charmxsec_geofile.root")
# save ShipGeo dictionary in geofile
 saveBasicParameters.execute("charmxsec_geofile.root",ShipGeo)

#list of positions of RPC channels, each entry of the list has two TVector3 objects
RPCPositionsBotTop = {}

vbot = ROOT.TVector3()
vtop = ROOT.TVector3()

def GetPixelPositions(n=1,draw=True,writentuple=False):
  """ retrieves the position of the pixel hit using the pixel map """
  if not options.withDisplay:
   #print 'display disabled, hits will not be drawn'
   draw = False

  sTree.GetEntry(n)
  npixelpoints = 0
     #t.Clear()
 fout.cd()
 for x in fin.GetList():
  if not x.Class().GetName().find('TH')<0: 
    xcopy = x.Clone()
    rc = xcopy.Write()
 sTree.AutoSave()
 ff   = fin.FileHeader.Clone(fout.GetName())
 fout.cd()
 ff.Write("FileHeader", ROOT.TObject.kSingleKey)
 sTree.Write()
 fout.Close()
 os.system("mv "+tmpFile+" "+outFile)

 print "Number of events produced with activity after hadron absorber:",nEvents 

else:
 print "No post processing done"

sGeo = ROOT.gGeoManager
run.CreateGeometryFile("%s/geofile_full.root" % (outputDir))

if checkOverlap:
 sGeo = ROOT.gGeoManager
 sGeo.CheckOverlaps()
 sGeo.PrintOverlaps()
 run.CreateGeometryFile("%s/geofile_full.root" % (outputDir))
 import saveBasicParameters
 saveBasicParameters.execute("%s/geofile_full.root" % (outputDir),ship_geo)

Пример #6
0
        #adding all subnodes for drawing
        for node in top.GetNodes():
            evenode = ROOT.TEveGeoTopNode(sGeo, node)
            evenode.UseNodeTrans()
            gEve.AddGlobalElement(evenode)
        gEve.FullRedraw3D(kTRUE)

    except:
        pass

saveGeofile = False
import saveBasicParameters
if saveGeofile:
    run.CreateGeometryFile("charmxsec_geofile.root")
    # save ShipGeo dictionary in geofile
    saveBasicParameters.execute("charmxsec_geofile.root", ShipGeo)

#list of positions of RPC channels, each entry of the list has two TVector3 objects
RPCPositionsBotTop = {}

vbot = ROOT.TVector3()
vtop = ROOT.TVector3()


def GetPixelPositions(n=1, draw=True, writentuple=False):
    """ retrieves the position of the pixel hit using the pixel map """
    if not options.withDisplay:
        draw = False

    sTree.GetEntry(n)
    npixelpoints = 0
Пример #7
0
# -----Start run----------------------------------------------------
run.Run(options.nEvents)
# -----Runtime database---------------------------------------------
kParameterMerged = ROOT.kTRUE
parOut = ROOT.FairParRootFileIo(kParameterMerged)
parOut.open(parFile)
rtdb.setOutput(parOut)
rtdb.saveOutput()
rtdb.printParamContexts()
getattr(rtdb, "print")()
# ------------------------------------------------------------------------
geoFile = "%s/geofile_full.%s.root" % (options.outputDir, tag)
run.CreateGeometryFile(geoFile)
# save detector parameters dictionary in geofile
import saveBasicParameters
saveBasicParameters.execute(geoFile, snd_geo)

# -----Finish-------------------------------------------------------
timer.Stop()
rtime = timer.RealTime()
ctime = timer.CpuTime()
print(' ')
print("Macro finished succesfully.")

print("Output file is ", outFile)
print("Geometry file is ", geoFile)
print("Real time ", rtime, " s, CPU time ", ctime, "s")


# ------------------------------------------------------------------------
def checkOverlaps(removeScifi=False):
Пример #8
0
modules = charmDet_conf.configure(run,ShipGeo)
# -----Create geometry----------------------------------------------
run.Init()

sGeo = ROOT.gGeoManager
nav = sGeo.GetCurrentNavigator()
top = sGeo.GetTopVolume()
top.SetVisibility(0)
top.Draw('ogl')

saveGeofile = True
import saveBasicParameters
if saveGeofile:
 run.CreateGeometryFile("muflux_geofile.root")
# save ShipGeo dictionary in geofile
 saveBasicParameters.execute("muflux_geofile.root",ShipGeo)

for n in range(1,6):
 rc = nav.cd('/VMuonBox_1/VSensitive_'+str(n))  # detector setup wrong, there is no station in front of iron wall
 vol = nav.GetCurrentNode()
 shape = vol.GetVolume().GetShape()
 local = array('d',[0,0,0])
 globOrigin = array('d',[0,0,0])
 nav.LocalToMaster(local,globOrigin)
 rpc[n] = [shape.GetDX(),shape.GetDY(),globOrigin[2]]
rpcchannels = 184 # estimate for x view

vbot = ROOT.TVector3()
vtop = ROOT.TVector3()
import rootUtils as ut
h={}
Пример #9
0
if local and not particleGun:
 gApplyUICommand('/vis/drawVolume')
 gApplyUICommand('/vis/scene/add/trajectories')
 gApplyUICommand('/vis/viewer/zoom 1.5')

t0 = time.time()
gRunManager.BeamOn(nev)
t1 = time.time()
print 'Time used',t1-t0, ' seconds' 
for x in myTimer: 
  print x,myTimer[x]

logger.info("output directory: %s" % work_dir)
# save arguments and GIT tags
import saveBasicParameters
saveBasicParameters.execute(f,args,'SHiP-Params')

if local:
 wrld = snoopyPhys.GetMotherLogical()
 parser = G4GDMLParser()
 geofile = work_dir+'/g4Geom.gdml' 
 if os.path.isfile(geofile): os.system('rm '+geofile)
 parser.Write('g4Geom.gdml',wrld)
 ROOT.TGeoManager()
 geomgr = ROOT.gGeoManager
 geomgr.Import('g4Geom.gdml','world','new')
 ROOT.gGeoManager.CheckOverlaps()
 ROOT.gGeoManager.PrintOverlaps()
 geomgr.GetTopVolume().Draw('ogl')