SND@LHC Software
Loading...
Searching...
No Matches
run_fixedTarget Namespace Reference

Functions

 get_work_dir (run_number, tag=None)
 
 init ()
 

Variables

str mcEngine = "TGeant4"
 
str simEngine = "Pythia8"
 
int runnr = 1
 
int nev = 1000
 
bool checkOverlap = True
 
bool G4only = False
 
bool storeOnlyMuons = False
 
bool skipNeutrinos = False
 
bool withEvtGen = True
 
int boostDiMuon = 1.
 
int boostFactor = 1.
 
bool charm = False
 
bool beauty = False
 
float chicc = 1.7e-3
 
float chibb = 1.6e-7
 
int npot = 5E13
 
int nStart = 0
 
str charmInputFile = ROOT.gSystem.Getenv("EOSSHIP")+"/eos/experiment/ship/data/Charm/Cascade-parp16-MSTP82-1-MSEL4-76Mpot_1.root"
 
str outputDir = "."
 
str work_dir = "./"
 
float ecut = 0.5
 
int dy = 10.
 
int dv = 6
 
int ds = 9
 
int nud = 3
 
 logger = logging.getLogger(os.path.splitext(os.path.basename(os.sys.argv[0]))[0])
 
 args = init()
 
 ship_geo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py", Yheight = dy, tankDesign = dv, muShieldDesign = ds, nuTauTargetDesign=nud)
 
str txt = 'pythia8_Geant4_'
 
str outFile = outputDir+'/'+txt+str(runnr)+'_'+str(ecut)+'.root'
 
str parFile = outputDir+'/ship.params.'+txt+str(runnr)+'_'+str(ecut)+'.root'
 
 timer = ROOT.TStopwatch()
 
 run = ROOT.FairRunSim()
 
 rtdb = run.GetRuntimeDb()
 
 cave = ROOT.ShipCave("CAVE")
 
 TargetStation
 
 slices_length = ROOT.std.vector('float')()
 
 slices_material = ROOT.std.vector('std::string')()
 
 MuonShield
 
 sensPlane = ROOT.exitHadronAbsorber()
 
 primGen = ROOT.FairPrimaryGenerator()
 
 P8gen = ROOT.FixedTargetGenerator()
 
 gMC = ROOT.TVirtualMC.GetMC()
 
 fStack = gMC.GetStack()
 
 gProcessTable = ROOT.G4ProcessTable.GetProcessTable()
 
 procAnnihil = gProcessTable.FindProcess(ROOT.G4String('AnnihiToMuPair'),ROOT.G4String('e+'))
 
 procGMuPair = gProcessTable.FindProcess(ROOT.G4String('GammaToMuPair'),ROOT.G4String('gamma'))
 
 rtime = timer.RealTime()
 
 ctime = timer.CpuTime()
 
str tmpFile = outFile+"tmp"
 
 fin = ROOT.gROOT.GetListOfFiles()[0]
 
 fHeader = fin.FileHeader
 
 poteq = P8gen.GetPotForCharm()
 
str info = "POT equivalent = %7.3G"%(poteq)
 
str conditions = " with ecut="+str(ecut)
 
 nt = fin.Get('4DP')
 
 tf = ROOT.TFile('FourDP.root','recreate')
 
 tnt = nt.CloneTree(0)
 
 rc = nt.GetEvent(i)
 
 t = fin.cbmsim
 
 fout = ROOT.TFile(tmpFile,'recreate' )
 
 sTree = t.CloneTree(0)
 
int nEvents = 0
 
 x = fin.Get(k.GetName())
 
 className = x.Class().GetName()
 
 xcopy = x.Clone()
 
 ff = fin.FileHeader.Clone(fout.GetName())
 
 rc1 = os.system("rm "+outFile)
 
 rc2 = os.system("mv "+tmpFile+" "+outFile)
 
 sGeo = ROOT.gGeoManager
 

Function Documentation

◆ get_work_dir()

run_fixedTarget.get_work_dir (   run_number,
  tag = None 
)

Definition at line 52 of file run_fixedTarget.py.

52def get_work_dir(run_number,tag=None):
53 import socket
54 host = socket.gethostname()
55 job_base_name = os.path.splitext(os.path.basename(os.sys.argv[0]))[0]
56 if tag: out_dir = "{host}_{base}_{runnr}_{comment}".format(host=host, base=job_base_name, runnr=run_number, comment=tag)
57 else: out_dir = "{host}_{base}_{runnr}".format(host=host, base=job_base_name, runnr=run_number)
58 return out_dir
59
60

◆ init()

run_fixedTarget.init ( )

Definition at line 61 of file run_fixedTarget.py.

61def init():
62 global runnr, nev, ecut, G4only, tauOnly,JpsiMainly, work_dir,Debug,withEvtGen,boostDiMuon,\
63 boostFactor,charm,beauty,charmInputFile,nStart,storeOnlyMuons,chicc,chibb,npot,nStart,skipNeutrinos,FourDP
64 logger.info("SHiP proton-on-taget simulator (C) Thomas Ruf, 2017")
65
66 ap = argparse.ArgumentParser(
67 description='Run SHiP "pot" simulation')
68 ap.add_argument('-d', '--debug', action='store_true', dest='debug')
69 ap.add_argument('-f', '--force', action='store_true', help="force overwriting output directory")
70 ap.add_argument('-r', '--run-number', type=int, dest='runnr', default=runnr)
71 ap.add_argument('-e', '--ecut', type=float, help="energy cut", dest='ecut', default=ecut)
72 ap.add_argument('-n', '--num-events', type=int, help="number of events to generate", dest='nev', default=nev)
73 ap.add_argument('-G', '--G4only', action='store_true', dest='G4only', default=False, help="use Geant4 directly, no Pythia8")
74 ap.add_argument('-P', '--PythiaDecay', action='store_true', dest='pythiaDecay', default=False, help="use Pythia8 for decays")
75 ap.add_argument('-V', '--EvtGen', action='store_true', dest='withEvtGen', default=withEvtGen, help="use EvtGen for decays")
76 ap.add_argument('-t', '--tau-only', action='store_true', dest='tauOnly', default=False)
77 ap.add_argument('-J', '--Jpsi-mainly', action='store_true', dest='JpsiMainly', default=False)
78 ap.add_argument('-b', '--boostDiMuon', type=float, dest='boostDiMuon', default=boostDiMuon, help="boost Di-muon branching ratios")
79 ap.add_argument('-X', '--boostFactor', type=float, dest='boostFactor', default=boostFactor, help="boost Di-muon prod cross sections")
80 ap.add_argument('-C', '--charm', action='store_true', dest='charm', default=charm, help="generate charm decays")
81 ap.add_argument('-B', '--beauty', action='store_true', dest='beauty', default=beauty, help="generate beauty decays")
82 ap.add_argument('-M', '--storeOnlyMuons', action='store_true', dest='storeOnlyMuons', default=storeOnlyMuons, help="store only muons, ignore neutrinos")
83 ap.add_argument('-N', '--skipNeutrinos', action='store_true', dest='skipNeutrinos', default=False, help="skip neutrinos")
84 ap.add_argument('-D', '--4darkPhoton', action='store_true', dest='FourDP', default=False, help="enable ntuple production")
85# for charm production
86 ap.add_argument('-cc','--chicc',action='store_true', dest='chicc', default=chicc, help="ccbar over mbias cross section")
87 ap.add_argument('-bb','--chibb',action='store_true', dest='chibb', default=chibb, help="bbbar over mbias cross section")
88 ap.add_argument('-p','--pot',action='store_true', dest='npot', default=npot, help="number of protons on target per spill to normalize on")
89 ap.add_argument('-S', '--nStart', type=int, help="first event of input file to start", dest='nStart', default=nStart)
90 ap.add_argument('-I', '--InputFile', type=str, dest='charmInputFile', default=charmInputFile, help="input file for charm/beauty decays")
91 ap.add_argument('-o','--output' , type=str, help="output directory", dest='work_dir', default=None)
92 ap.add_argument('-rs','--seed', type=int, help="random seed; default value is 0, see TRrandom::SetSeed documentation", dest='seed', default=0)
93 args = ap.parse_args()
94 if args.debug:
95 logger.setLevel(logging.DEBUG)
96 runnr = args.runnr
97 nev = args.nev
98 ecut = args.ecut
99 tauOnly = args.tauOnly
100 JpsiMainly = args.JpsiMainly
101 G4only = args.G4only
102 boostFactor = args.boostFactor
103 boostDiMuon = args.boostDiMuon
104 storeOnlyMuons = args.storeOnlyMuons
105 skipNeutrinos = args.skipNeutrinos
106 FourDP = args.FourDP
107 if G4only:
108 args.charm = False
109 args.beauty = False
110 args.withEvtGen = False
111 args.pythiaDecay = False
112 elif args.pythiaDecay:
113 withEvtGen = False
114 args.withEvtGen = False
115 logger.info("use Pythia8 as primary decayer")
116 else:
117 withEvtGen = True
118 logger.info("use EvtGen as primary decayer")
119 withEvtGen = args.withEvtGen
120 charm = args.charm
121 beauty = args.beauty
122 if charm and beauty:
123 logger.warn("charm and beauty decays are set! Beauty gets priority")
124 charm = False
125 charmInputFile = args.charmInputFile
126 nStart = int(args.nStart)
127 Debug = args.debug
128 if args.work_dir is None:
129 if charm: args.work_dir = get_work_dir(runnr,"charm")
130 if beauty: args.work_dir = get_work_dir(runnr,"beauty")
131 else: args.work_dir = get_work_dir(runnr)
132 work_dir = args.work_dir
133 logger.debug("work_dir: %s" % work_dir)
134 logger.debug("command line arguments: %s", args)
135 if os.path.exists(work_dir):
136 logger.warn("output directory '%s' already exists." % work_dir)
137 if args.force:
138 logger.warn("...cleaning")
139 for root, dirs, files in os.walk(work_dir):
140 for f in files:
141 os.unlink(os.path.join(root, f))
142 for d in dirs:
143 shutil.rmtree(os.path.join(root, d))
144 else:
145 logger.warn("...use '-f' option to overwrite it")
146 else:
147 os.makedirs(work_dir)
148 return args
149

Variable Documentation

◆ args

run_fixedTarget.args = init()

Definition at line 150 of file run_fixedTarget.py.

◆ beauty

bool run_fixedTarget.beauty = False

Definition at line 19 of file run_fixedTarget.py.

◆ boostDiMuon

int run_fixedTarget.boostDiMuon = 1.

Definition at line 16 of file run_fixedTarget.py.

◆ boostFactor

int run_fixedTarget.boostFactor = 1.

Definition at line 17 of file run_fixedTarget.py.

◆ cave

run_fixedTarget.cave = ROOT.ShipCave("CAVE")

Definition at line 176 of file run_fixedTarget.py.

◆ charm

bool run_fixedTarget.charm = False

Definition at line 18 of file run_fixedTarget.py.

◆ charmInputFile

str run_fixedTarget.charmInputFile = ROOT.gSystem.Getenv("EOSSHIP")+"/eos/experiment/ship/data/Charm/Cascade-parp16-MSTP82-1-MSEL4-76Mpot_1.root"

Definition at line 25 of file run_fixedTarget.py.

◆ checkOverlap

bool run_fixedTarget.checkOverlap = True

Definition at line 11 of file run_fixedTarget.py.

◆ chibb

float run_fixedTarget.chibb = 1.6e-7

Definition at line 21 of file run_fixedTarget.py.

◆ chicc

float run_fixedTarget.chicc = 1.7e-3

Definition at line 20 of file run_fixedTarget.py.

◆ className

run_fixedTarget.className = x.Class().GetName()

Definition at line 310 of file run_fixedTarget.py.

◆ conditions

str run_fixedTarget.conditions = " with ecut="+str(ecut)

Definition at line 276 of file run_fixedTarget.py.

◆ ctime

run_fixedTarget.ctime = timer.CpuTime()

Definition at line 256 of file run_fixedTarget.py.

◆ ds

int run_fixedTarget.ds = 9

Definition at line 34 of file run_fixedTarget.py.

◆ dv

int run_fixedTarget.dv = 6

Definition at line 33 of file run_fixedTarget.py.

◆ dy

int run_fixedTarget.dy = 10.

Definition at line 32 of file run_fixedTarget.py.

◆ ecut

float run_fixedTarget.ecut = 0.5

Definition at line 30 of file run_fixedTarget.py.

◆ ff

run_fixedTarget.ff = fin.FileHeader.Clone(fout.GetName())

Definition at line 315 of file run_fixedTarget.py.

◆ fHeader

run_fixedTarget.fHeader = fin.FileHeader

Definition at line 267 of file run_fixedTarget.py.

◆ fin

run_fixedTarget.fin = ROOT.gROOT.GetListOfFiles()[0]

Definition at line 264 of file run_fixedTarget.py.

◆ fout

run_fixedTarget.fout = ROOT.TFile(tmpFile,'recreate' )

Definition at line 298 of file run_fixedTarget.py.

◆ fStack

run_fixedTarget.fStack = gMC.GetStack()

Definition at line 232 of file run_fixedTarget.py.

◆ G4only

bool run_fixedTarget.G4only = False

Definition at line 12 of file run_fixedTarget.py.

◆ gMC

run_fixedTarget.gMC = ROOT.TVirtualMC.GetMC()

Definition at line 231 of file run_fixedTarget.py.

◆ gProcessTable

run_fixedTarget.gProcessTable = ROOT.G4ProcessTable.GetProcessTable()

Definition at line 244 of file run_fixedTarget.py.

◆ info

str run_fixedTarget.info = "POT equivalent = %7.3G"%(poteq)

Definition at line 272 of file run_fixedTarget.py.

◆ logger

run_fixedTarget.logger = logging.getLogger(os.path.splitext(os.path.basename(os.sys.argv[0]))[0])

Definition at line 48 of file run_fixedTarget.py.

◆ mcEngine

str run_fixedTarget.mcEngine = "TGeant4"

Definition at line 7 of file run_fixedTarget.py.

◆ MuonShield

run_fixedTarget.MuonShield
Initial value:
1= ROOT.ShipMuonShield("MuonShield",ship_geo.muShieldDesign,"ShipMuonShield",ship_geo.muShield.z,ship_geo.muShield.dZ0,ship_geo.muShield.dZ1,\
2 ship_geo.muShield.dZ2,ship_geo.muShield.dZ3,ship_geo.muShield.dZ4,ship_geo.muShield.dZ5,ship_geo.muShield.dZ6,\
3 ship_geo.muShield.dZ7,ship_geo.muShield.dZ8,ship_geo.muShield.dXgap,ship_geo.muShield.LE,ship_geo.Yheight*4./10.,0.)

Definition at line 190 of file run_fixedTarget.py.

◆ nev

int run_fixedTarget.nev = 1000

Definition at line 10 of file run_fixedTarget.py.

◆ nEvents

int run_fixedTarget.nEvents = 0

Definition at line 300 of file run_fixedTarget.py.

◆ npot

int run_fixedTarget.npot = 5E13

Definition at line 22 of file run_fixedTarget.py.

◆ nStart

int run_fixedTarget.nStart = 0

Definition at line 23 of file run_fixedTarget.py.

◆ nt

run_fixedTarget.nt = fin.Get('4DP')

Definition at line 287 of file run_fixedTarget.py.

◆ nud

int run_fixedTarget.nud = 3

Definition at line 35 of file run_fixedTarget.py.

◆ outFile

str run_fixedTarget.outFile = outputDir+'/'+txt+str(runnr)+'_'+str(ecut)+'.root'

Definition at line 159 of file run_fixedTarget.py.

◆ outputDir

str run_fixedTarget.outputDir = "."

Definition at line 28 of file run_fixedTarget.py.

◆ P8gen

run_fixedTarget.P8gen = ROOT.FixedTargetGenerator()

Definition at line 205 of file run_fixedTarget.py.

◆ parFile

str run_fixedTarget.parFile = outputDir+'/ship.params.'+txt+str(runnr)+'_'+str(ecut)+'.root'

Definition at line 160 of file run_fixedTarget.py.

◆ poteq

run_fixedTarget.poteq = P8gen.GetPotForCharm()

Definition at line 271 of file run_fixedTarget.py.

◆ primGen

run_fixedTarget.primGen = ROOT.FairPrimaryGenerator()

Definition at line 204 of file run_fixedTarget.py.

◆ procAnnihil

run_fixedTarget.procAnnihil = gProcessTable.FindProcess(ROOT.G4String('AnnihiToMuPair'),ROOT.G4String('e+'))

Definition at line 245 of file run_fixedTarget.py.

◆ procGMuPair

run_fixedTarget.procGMuPair = gProcessTable.FindProcess(ROOT.G4String('GammaToMuPair'),ROOT.G4String('gamma'))

Definition at line 246 of file run_fixedTarget.py.

◆ rc

run_fixedTarget.rc = nt.GetEvent(i)

Definition at line 292 of file run_fixedTarget.py.

◆ rc1

run_fixedTarget.rc1 = os.system("rm "+outFile)

Definition at line 321 of file run_fixedTarget.py.

◆ rc2

run_fixedTarget.rc2 = os.system("mv "+tmpFile+" "+outFile)

Definition at line 322 of file run_fixedTarget.py.

◆ rtdb

run_fixedTarget.rtdb = run.GetRuntimeDb()

Definition at line 171 of file run_fixedTarget.py.

◆ rtime

run_fixedTarget.rtime = timer.RealTime()

Definition at line 255 of file run_fixedTarget.py.

◆ run

run_fixedTarget.run = ROOT.FairRunSim()

Definition at line 167 of file run_fixedTarget.py.

◆ runnr

int run_fixedTarget.runnr = 1

Definition at line 9 of file run_fixedTarget.py.

◆ sensPlane

run_fixedTarget.sensPlane = ROOT.exitHadronAbsorber()

Definition at line 195 of file run_fixedTarget.py.

◆ sGeo

run_fixedTarget.sGeo = ROOT.gGeoManager

Definition at line 329 of file run_fixedTarget.py.

◆ ship_geo

run_fixedTarget.ship_geo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py", Yheight = dy, tankDesign = dv, muShieldDesign = ds, nuTauTargetDesign=nud)

Definition at line 155 of file run_fixedTarget.py.

◆ simEngine

str run_fixedTarget.simEngine = "Pythia8"

Definition at line 8 of file run_fixedTarget.py.

◆ skipNeutrinos

bool run_fixedTarget.skipNeutrinos = False

Definition at line 14 of file run_fixedTarget.py.

◆ slices_length

run_fixedTarget.slices_length = ROOT.std.vector('float')()

Definition at line 182 of file run_fixedTarget.py.

◆ slices_material

run_fixedTarget.slices_material = ROOT.std.vector('std::string')()

Definition at line 183 of file run_fixedTarget.py.

◆ storeOnlyMuons

bool run_fixedTarget.storeOnlyMuons = False

Definition at line 13 of file run_fixedTarget.py.

◆ sTree

run_fixedTarget.sTree = t.CloneTree(0)

Definition at line 299 of file run_fixedTarget.py.

◆ t

run_fixedTarget.t = fin.cbmsim

Definition at line 297 of file run_fixedTarget.py.

◆ TargetStation

run_fixedTarget.TargetStation
Initial value:
1= ROOT.ShipTargetStation("TargetStation",ship_geo.target.length,ship_geo.hadronAbsorber.length,
2 ship_geo.target.z,ship_geo.hadronAbsorber.z,ship_geo.targetOpt,ship_geo.target.sl)

Definition at line 180 of file run_fixedTarget.py.

◆ tf

run_fixedTarget.tf = ROOT.TFile('FourDP.root','recreate')

Definition at line 289 of file run_fixedTarget.py.

◆ timer

run_fixedTarget.timer = ROOT.TStopwatch()

Definition at line 163 of file run_fixedTarget.py.

◆ tmpFile

str run_fixedTarget.tmpFile = outFile+"tmp"

Definition at line 262 of file run_fixedTarget.py.

◆ tnt

run_fixedTarget.tnt = nt.CloneTree(0)

Definition at line 290 of file run_fixedTarget.py.

◆ txt

run_fixedTarget.txt = 'pythia8_Geant4_'

Definition at line 157 of file run_fixedTarget.py.

◆ withEvtGen

bool run_fixedTarget.withEvtGen = True

Definition at line 15 of file run_fixedTarget.py.

◆ work_dir

str run_fixedTarget.work_dir = "./"

Definition at line 29 of file run_fixedTarget.py.

◆ x

run_fixedTarget.x = fin.Get(k.GetName())

Definition at line 309 of file run_fixedTarget.py.

◆ xcopy

run_fixedTarget.xcopy = x.Clone()

Definition at line 312 of file run_fixedTarget.py.