Пример #1
0
def run():
    # -------------------------------------------------------------------
    ROOT.gRandom.SetSeed(
        0)  # this should be propagated via ROOT to Pythia8 and Geant4VMC
    shipRoot_conf.configure(
    )  # load basic libraries, prepare atexit for python
    # -----Timer--------------------------------------------------------
    timer = ROOT.TStopwatch()
    timer.Start()
    # -----Create simulation run----------------------------------------
    gFairBaseContFact = ROOT.FairBaseContFact(
    )  # required by change to FairBaseContFact to avoid TList::Clear errors
    run = ROOT.FairRunSim()
    run.SetName(mcEngine)  # Transport engine
    run.SetOutputFile(outFile)  # Output file
    run.SetUserConfig(
        "g4Config.C")  # user configuration file default g4Config.C
    rtdb = run.GetRuntimeDb()
    # -----Materials----------------------------------------------
    run.SetMaterials("media.geo")
    # -----Create geometry----------------------------------------------
    cave = ROOT.ShipCave("CAVE")
    cave.SetGeometryFileName("cave.geo")
    run.AddModule(cave)
    #
    target = ROOT.simpleTarget()
    target.SetEnergyCut(0.)
    target.SetParameters(material, thickness, 0.)
    if storeOnlyMuons: target.SetFastMuon()
    run.AddModule(target)
    #
    primGen = ROOT.FairPrimaryGenerator()
    mufluxSim = ROOT.ReProcessAbsorber()
    mufluxSim.Init(fname)
    mufluxSim.SetZposition(-thickness)
    primGen.AddGenerator(mufluxSim)
    #
    run.SetGenerator(primGen)
    # -----Initialize simulation run------------------------------------
    run.Init()
    gMC = ROOT.TVirtualMC.GetMC()

    fStack = gMC.GetStack()
    fStack.SetMinPoints(1)
    fStack.SetEnergyCut(-1.)

    # -----Start run----------------------------------------------------
    print "run for ", nev, "events"
    run.Run(nev)

    # -----Finish-------------------------------------------------------
    timer.Stop()
    rtime = timer.RealTime()
    ctime = timer.CpuTime()
    print ' '
    print "Macro finished succesfully."
    print "Output file is ", outFile
    print "Real time ", rtime, " s, CPU time ", ctime, "s"
Пример #2
0
from __future__ import print_function
# example for accessing smeared hits and fitted tracks
import ROOT, os, sys, getopt
import rootUtils as ut
import shipunit as u
from ShipGeoConfig import ConfigRegistry
from rootpyPickler import Unpickler
from rootpyPickler import Pickler
from decorators import *
import shipRoot_conf
shipRoot_conf.configure()
import numpy as np
import matplotlib
# Force matplotlib to not use any Xwindows backend.
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import math
import glob
import pickle
import argparse
import shutil

parser = argparse.ArgumentParser()
parser.add_argument('-jobid',
                    action='store',
                    dest='jobid',
                    type=int,
                    help='jobid')
results = parser.parse_args()
job_id = int(results.jobid)
Пример #3
0
        if o in ("-c", "--couplings", "--coupling"):
            theHNLcouplings = [float(c) for c in a.split(",")]

if (simEngine == "Genie" or simEngine == "nuRadiography") and not inputFile: 
  inputFile = os.environ['SHIPSOFT']+'/data/Genie-mu-_anti_nu_mu-gntp.113.gst.root' # anti_nu_mu
# nu_mu: inputFile = os.environ['SHIPSOFT']+'/data/Genie-mu+_nu_mu-gntp.113.gst.root'
if simEngine == "muonDIS" and not inputFile:
 inputFile = os.environ['SHIPSOFT']+'/data/muonDis.root' 
if simEngine == "Nuage" and not inputFile:
 inputFile = 'Numucc.root'

print "FairShip setup for",simEngine,"to produce",nEvents,"events"
if (simEngine == "Ntuple" or simEngine == "MuonBack") and not inputFile :
  print 'input file required if simEngine = Ntuple or MuonBack'
ROOT.gRandom.SetSeed(theSeed)  # this should be propagated via ROOT to Pythia8 and Geant4VMC
shipRoot_conf.configure()      # load basic libraries, prepare atexit for python
# - muShieldDesign = 2  # 1=passive 2=active (default)
# - targetOpt      = 5  # 0=solid   >0 sliced, 5: 5 pieces of tungsten, 4 H20 slits, 17: Mo + W +H2O (default)
# - strawDesign    = 4  # simplistic tracker design,  4=sophisticated straw tube design, horizontal wires (default)
# - HcalOption     = -1 # no hcal,  0=hcal after muon,  1=hcal between ecal and muon (default)
ship_geo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py", Yheight = dy)
# Output file name, add dy to be able to setup geometry with ambiguities.
tag = simEngine+"-"+mcEngine
if eventDisplay: tag = tag+'_D'
if dy: tag = str(dy)+'.'+tag 
if not os.path.exists(outputDir):
  os.makedirs(outputDir)
outFile = "%s/ship.%s.root" % (outputDir, tag)


# rm older files !!! 
Пример #4
0
    # "/eos/experiment/ship/data/GenieEvents/genie-nu_mu_bar.root"
if simEngine == "muonDIS" and defaultInputFile:
    print 'input file required if simEngine = muonDIS'
    print " for example -f  /eos/experiment/ship/data/muonDIS/muonDis_1.root"
    sys.exit()
if simEngine == "Nuage" and not inputFile:
    inputFile = 'Numucc.root'

print "FairShip setup for", simEngine, "to produce", nEvents, "events"
if (simEngine == "Ntuple" or simEngine == "MuonBack") and defaultInputFile:
    print 'input file required if simEngine = Ntuple or MuonBack'
    print " for example -f /eos/experiment/ship/data/Mbias/pythia8_Geant4-withCharm_onlyMuons_4magTarget.root"
    sys.exit()
ROOT.gRandom.SetSeed(
    theSeed)  # this should be propagated via ROOT to Pythia8 and Geant4VMC
shipRoot_conf.configure(0)  # load basic libraries, prepare atexit for python
# - muShieldDesign = 2  # 1=passive 5=active (default) 7=short design+magnetized hadron absorber
# - targetOpt      = 5  # 0=solid   >0 sliced, 5: 5 pieces of tungsten, 4 H20 slits, 17: Mo + W +H2O (default)
#   nuTauTargetDesign = 0 # 0 = TP, 1 = NEW with magnet, 2 = NEW without magnet, 3 = 2018 design
if charm == 0:    ship_geo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py", Yheight = dy, tankDesign = dv, \
                                     muShieldDesign = ds, nuTauTargetDesign=nud, CaloDesign=caloDesign, strawDesign=strawDesign, muShieldGeo=geofile)
else:
    ship_geo = ConfigRegistry.loadpy(
        "$FAIRSHIP/geometry/charm-geometry_config.py", Setup=CharmdetSetup)
    if CharmdetSetup == 0: print "Setup for muon flux measurement has been set"
    else: print "Setup for charm cross section measurement has been set"
# switch off magnetic field to measure muon flux
#ship_geo.muShield.Field = 0.
#ship_geo.EmuMagnet.B = 0.
#ship_geo.tauMudet.B = 0.
Пример #5
0
# example for accessing smeared hits and fitted tracks
import ROOT,os,sys,getopt
import rootUtils as ut
import shipunit as u
from ShipGeoConfig import ConfigRegistry
from rootpyPickler import Unpickler
from decorators import *
import shipRoot_conf
shipRoot_conf.configure()

debug = False
chi2CutOff  = 4.
PDG = ROOT.TDatabasePDG.Instance()
inputFile  = None
geoFile    = None
dy         = None
nEvents    = 9999999
fiducialCut = True
measCutFK = 25
measCutPR = 22
docaCut = 2.
try:
        opts, args = getopt.getopt(sys.argv[1:], "n:f:g:A:Y:i", ["nEvents=","geoFile="])
except getopt.GetoptError:
        # print help information and exit:
        print ' enter file name'
        sys.exit()
for o, a in opts:
        if o in ("-f"):
            inputFile = a
        if o in ("-g", "--geoFile"):
Пример #6
0
def run():
    # -------------------------------------------------------------------
    ROOT.gRandom.SetSeed(
        theSeed)  # this should be propagated via ROOT to Pythia8 and Geant4VMC
    shipRoot_conf.configure(
    )  # load basic libraries, prepare atexit for python
    # ship_geo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py", Yheight = 10, tankDesign = 5, muShieldDesign = 7, nuTauTargetDesign=1)
    # -----Timer--------------------------------------------------------
    timer = ROOT.TStopwatch()
    timer.Start()
    # -----Create simulation run----------------------------------------
    gFairBaseContFact = ROOT.FairBaseContFact(
    )  # required by change to FairBaseContFact to avoid TList::Clear errors
    run = ROOT.FairRunSim()
    run.SetName(mcEngine)  # Transport engine
    if nev == 0: run.SetOutputFile("dummy.root")
    else: run.SetOutputFile(outFile)  # Output file
    run.SetUserConfig(
        "g4Config.C")  # user configuration file default g4Config.C
    rtdb = run.GetRuntimeDb()
    # -----Materials----------------------------------------------
    run.SetMaterials("media.geo")
    # -----Create geometry----------------------------------------------
    cave = ROOT.ShipCave("CAVE")
    cave.SetGeometryFileName("cave.geo")
    run.AddModule(cave)
    #
    target = ROOT.simpleTarget()
    material, thickness, 0
    #
    target.SetEnergyCut(ecut * u.GeV)
    if storeOnlyMuons: target.SetOnlyMuons()
    target.SetParameters(material, thickness, 0.)
    run.AddModule(target)
    #
    primGen = ROOT.FairPrimaryGenerator()
    myPgun = ROOT.FairBoxGenerator(13, 1)  # pdg id  and multiplicity
    if s == "NA62": myPgun.SetPRange(momentum, maxTheta)
    else: myPgun.SetPRange(momentum - 0.01, momentum + 0.01)
    myPgun.SetPhiRange(0, 0)  # // Azimuth angle range [degree]
    myPgun.SetThetaRange(0, 0)  # // Polar angle in lab system range [degree]
    myPgun.SetXYZ(0. * u.cm, 0. * u.cm, -1. * u.mm - (thickness))
    primGen.AddGenerator(myPgun)
    #
    run.SetGenerator(primGen)
    # -----Initialize simulation run------------------------------------
    run.Init()
    if nev == 0: return
    gMC = ROOT.TVirtualMC.GetMC()

    fStack = gMC.GetStack()
    fStack.SetMinPoints(1)
    fStack.SetEnergyCut(-1.)

    # -----Start run----------------------------------------------------
    print("run for ", nev, "events")
    run.Run(nev)

    # -----Start Analysis---------------
    ROOT.gROOT.ProcessLine('#include "Geant4/G4EmParameters.hh"')
    emP = ROOT.G4EmParameters.Instance()
    emP.Dump()
    h['f'] = ROOT.gROOT.GetListOfFiles()[0].GetName()
    # -----Finish-------------------------------------------------------
    timer.Stop()
    rtime = timer.RealTime()
    ctime = timer.CpuTime()
    print(' ')
    print("Macro finished succesfully.")
    print("Output file is ", outFile)
    print("Real time ", rtime, " s, CPU time ", ctime, "s")
Пример #7
0
def run():
# -------------------------------------------------------------------
 ROOT.gRandom.SetSeed(0)  # this should be propagated via ROOT to Pythia8 and Geant4VMC
 shipRoot_conf.configure()      # load basic libraries, prepare atexit for python
# -----Timer--------------------------------------------------------
 timer = ROOT.TStopwatch()
 timer.Start()
# -----Create simulation run----------------------------------------
 gFairBaseContFact = ROOT.FairBaseContFact() # required by change to FairBaseContFact to avoid TList::Clear errors
 run = ROOT.FairRunSim()
 run.SetName(mcEngine)  # Transport engine
 run.SetOutputFile(outFile)  # Output file
 run.SetUserConfig("g4Config.C") # user configuration file default g4Config.C
 rtdb = run.GetRuntimeDb() 
# -----Materials----------------------------------------------
 run.SetMaterials("media.geo")  
# -----Create geometry----------------------------------------------
 cave= ROOT.ShipCave("CAVE")
 cave.SetGeometryFileName("cave.geo")
 run.AddModule(cave)
#
 target = ROOT.simpleTarget()
 target.SetEnergyCut(0.) 
 target.SetParameters(material,thickness,0.)
 if storeOnlyMuons: target.SetFastMuon()
 run.AddModule(target)
#
 primGen = ROOT.FairPrimaryGenerator()
 if options.PG:
   myPgun = ROOT.FairBoxGenerator(13,1)
   myPgun.SetPRange(0.,10.)
   myPgun.SetPhiRange(0, 0)
   myPgun.SetXYZ(0.*u.cm, 0.*u.cm, -thickness)
   myPgun.SetThetaRange(0,0)
   primGen.AddGenerator(myPgun)
 else:
   mufluxSim = ROOT.ReProcessAbsorber()
   mufluxSim.Init(fname)
   mufluxSim.SetZposition(-thickness)
   primGen.AddGenerator(mufluxSim)
#
 run.SetGenerator(primGen)
# -----Initialize simulation run------------------------------------
 run.Init()
 gMC = ROOT.TVirtualMC.GetMC()

 fStack = gMC.GetStack()
 fStack.SetMinPoints(1)
 fStack.SetEnergyCut(-1.)

 run.CreateGeometryFile("geofile.root")
# -----Start run----------------------------------------------------
 print "run for ",nev,"events"
 run.Run(nev)

# -----Finish-------------------------------------------------------
 timer.Stop()
 rtime = timer.RealTime()
 ctime = timer.CpuTime()
 print ' ' 
 print "Macro finished succesfully." 
 print "Output file is ",  outFile 
 print "Real time ",rtime, " s, CPU time ",ctime,"s"