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

Functions

 get_work_dir (run_number, tag=None)
 
 init ()
 

Variables

str mcEngine = "TGeant4"
 
str simEngine = "Pythia8"
 
int runnr = 1000
 
int nev = 500
 
bool checkOverlap = False
 
bool G4only = False
 
bool storeOnlyMuons = 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://eoslhcb.cern.ch//eos/ship/data/Charm/Cascade-parp16-MSTP82-1-MSEL4-76Mpot_1.root"
 
str outputDir = "."
 
 theSeed = int(10000 * time.time() % 10000000)
 
str work_dir = "./"
 
float ecut = 0.5
 
int dy = 10.
 
int dv = 5
 
int ds = 7
 
int nud = 1
 
 logger = logging.getLogger(os.path.splitext(os.path.basename(os.sys.argv[0]))[0])
 
 args = init()
 
 ship_geo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/charm-geometry_config.py", Setup = args.CharmdetSetup, cTarget = args.CharmTarget)
 
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()
 
 modules = shipDet_conf.configure(run,ship_geo)
 
 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()
 
 t = fin.cbmsim
 
 fout = ROOT.TFile(tmpFile,'recreate' )
 
 sTree = t.CloneTree(0)
 
int nEvents = 0
 
 rc = t.GetEvent(n)
 
 xcopy = x.Clone()
 
 ff = fin.FileHeader.Clone(fout.GetName())
 
 sGeo = ROOT.gGeoManager
 

Function Documentation

◆ get_work_dir()

run_MufluxfixedTarget.get_work_dir (   run_number,
  tag = None 
)

Definition at line 52 of file run_MufluxfixedTarget.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_MufluxfixedTarget.init ( )

Definition at line 61 of file run_MufluxfixedTarget.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
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('-cs', '--CharmdetSetup', type=int, dest='CharmdetSetup',help="setting detector setup", default=0)
71 ap.add_argument('-ct', '--CharmTarget', type=int, dest='CharmTarget',help="choosing target configuration for charm exposure", default=3)
72 ap.add_argument('-r', '--run-number', type=int, dest='runnr', default=runnr)
73 ap.add_argument('-e', '--ecut', type=float, help="energy cut", dest='ecut', default=ecut)
74 ap.add_argument('-n', '--num-events', type=int, help="number of events to generate", dest='nev', default=nev)
75 ap.add_argument('-G', '--G4only', action='store_true', dest='G4only', default=False, help="use Geant4 directly, no Pythia8")
76 ap.add_argument('-P', '--PythiaDecay', action='store_true', dest='pythiaDecay', default=False, help="use Pythia8 for decays")
77 ap.add_argument('-V', '--EvtGen', action='store_true', dest='withEvtGen', default=withEvtGen, help="use EvtGen for decays")
78 ap.add_argument('-t', '--tau-only', action='store_true', dest='tauOnly', default=False)
79 ap.add_argument('-J', '--Jpsi-mainly', action='store_true', dest='JpsiMainly', default=False)
80 ap.add_argument('-b', '--boostDiMuon', type=float, dest='boostDiMuon', default=boostDiMuon, help="boost Di-muon branching ratios")
81 ap.add_argument('-X', '--boostFactor', type=float, dest='boostFactor', default=boostFactor, help="boost Di-muon prod cross sections")
82 ap.add_argument('-C', '--charm', action='store_true', dest='charm', default=charm, help="generate charm decays")
83 ap.add_argument('-B', '--beauty', action='store_true', dest='beauty', default=beauty, help="generate beauty decays")
84 ap.add_argument('-M', '--storeOnlyMuons', action='store_true', dest='storeOnlyMuons', default=storeOnlyMuons, help="store only muons, ignore neutrinos")
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',action='store_true', dest='nStart', default=nStart, help="first event of input file to start")
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 args = ap.parse_args()
93 if args.debug:
94 logger.setLevel(logging.DEBUG)
95 runnr = args.runnr
96 nev = args.nev
97 ecut = args.ecut
98 tauOnly = args.tauOnly
99 JpsiMainly = args.JpsiMainly
100 G4only = args.G4only
101 boostFactor = args.boostFactor
102 boostDiMuon = args.boostDiMuon
103 storeOnlyMuons = args.storeOnlyMuons
104 if G4only:
105 args.charm = False
106 args.beauty = False
107 args.withEvtGen = False
108 args.pythiaDecay = False
109 elif args.pythiaDecay:
110 withEvtGen = False
111 args.withEvtGen = False
112 logger.info("use Pythia8 as primary decayer")
113 else:
114 withEvtGen = True
115 logger.info("use EvtGen as primary decayer")
116 withEvtGen = args.withEvtGen
117 charm = args.charm
118 beauty = args.beauty
119 if charm and beauty:
120 logger.warn("charm and beauty decays are set! Beauty gets priority")
121 charm = False
122 charmInputFile = args.charmInputFile
123 nStart = int(args.nStart)
124 Debug = args.debug
125 if args.work_dir is None:
126 if charm: args.work_dir = get_work_dir(runnr,"charm")
127 if beauty: args.work_dir = get_work_dir(runnr,"beauty")
128 else: args.work_dir = get_work_dir(runnr)
129 work_dir = args.work_dir
130 logger.debug("work_dir: %s" % work_dir)
131 logger.debug("command line arguments: %s", args)
132 if os.path.exists(work_dir):
133 logger.warn("output directory '%s' already exists." % work_dir)
134 if args.force:
135 logger.warn("...cleaning")
136 for root, dirs, files in os.walk(work_dir):
137 for f in files:
138 os.unlink(os.path.join(root, f))
139 for d in dirs:
140 shutil.rmtree(os.path.join(root, d))
141 else:
142 logger.warn("...use '-f' option to overwrite it")
143 else:
144 os.makedirs(work_dir)
145 return args
146

Variable Documentation

◆ args

run_MufluxfixedTarget.args = init()

Definition at line 147 of file run_MufluxfixedTarget.py.

◆ beauty

bool run_MufluxfixedTarget.beauty = False

Definition at line 18 of file run_MufluxfixedTarget.py.

◆ boostDiMuon

int run_MufluxfixedTarget.boostDiMuon = 1.

Definition at line 15 of file run_MufluxfixedTarget.py.

◆ boostFactor

int run_MufluxfixedTarget.boostFactor = 1.

Definition at line 16 of file run_MufluxfixedTarget.py.

◆ charm

bool run_MufluxfixedTarget.charm = False

Definition at line 17 of file run_MufluxfixedTarget.py.

◆ charmInputFile

str run_MufluxfixedTarget.charmInputFile = "root://eoslhcb.cern.ch//eos/ship/data/Charm/Cascade-parp16-MSTP82-1-MSEL4-76Mpot_1.root"

Definition at line 24 of file run_MufluxfixedTarget.py.

◆ checkOverlap

bool run_MufluxfixedTarget.checkOverlap = False

Definition at line 11 of file run_MufluxfixedTarget.py.

◆ chibb

float run_MufluxfixedTarget.chibb = 1.6e-7

Definition at line 20 of file run_MufluxfixedTarget.py.

◆ chicc

float run_MufluxfixedTarget.chicc = 1.7e-3

Definition at line 19 of file run_MufluxfixedTarget.py.

◆ ctime

run_MufluxfixedTarget.ctime = timer.CpuTime()

Definition at line 238 of file run_MufluxfixedTarget.py.

◆ ds

int run_MufluxfixedTarget.ds = 7

Definition at line 34 of file run_MufluxfixedTarget.py.

◆ dv

int run_MufluxfixedTarget.dv = 5

Definition at line 33 of file run_MufluxfixedTarget.py.

◆ dy

int run_MufluxfixedTarget.dy = 10.

Definition at line 32 of file run_MufluxfixedTarget.py.

◆ ecut

float run_MufluxfixedTarget.ecut = 0.5

Definition at line 30 of file run_MufluxfixedTarget.py.

◆ ff

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

Definition at line 274 of file run_MufluxfixedTarget.py.

◆ fHeader

run_MufluxfixedTarget.fHeader = fin.FileHeader

Definition at line 249 of file run_MufluxfixedTarget.py.

◆ fin

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

Definition at line 247 of file run_MufluxfixedTarget.py.

◆ fout

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

Definition at line 259 of file run_MufluxfixedTarget.py.

◆ fStack

run_MufluxfixedTarget.fStack = gMC.GetStack()

Definition at line 213 of file run_MufluxfixedTarget.py.

◆ G4only

bool run_MufluxfixedTarget.G4only = False

Definition at line 12 of file run_MufluxfixedTarget.py.

◆ gMC

run_MufluxfixedTarget.gMC = ROOT.TVirtualMC.GetMC()

Definition at line 212 of file run_MufluxfixedTarget.py.

◆ gProcessTable

run_MufluxfixedTarget.gProcessTable = ROOT.G4ProcessTable.GetProcessTable()

Definition at line 225 of file run_MufluxfixedTarget.py.

◆ logger

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

Definition at line 48 of file run_MufluxfixedTarget.py.

◆ mcEngine

str run_MufluxfixedTarget.mcEngine = "TGeant4"

Definition at line 7 of file run_MufluxfixedTarget.py.

◆ modules

run_MufluxfixedTarget.modules = shipDet_conf.configure(run,ship_geo)

Definition at line 175 of file run_MufluxfixedTarget.py.

◆ nev

int run_MufluxfixedTarget.nev = 500

Definition at line 10 of file run_MufluxfixedTarget.py.

◆ nEvents

int run_MufluxfixedTarget.nEvents = 0

Definition at line 261 of file run_MufluxfixedTarget.py.

◆ npot

int run_MufluxfixedTarget.npot = 5E13

Definition at line 21 of file run_MufluxfixedTarget.py.

◆ nStart

int run_MufluxfixedTarget.nStart = 0

Definition at line 22 of file run_MufluxfixedTarget.py.

◆ nud

int run_MufluxfixedTarget.nud = 1

Definition at line 35 of file run_MufluxfixedTarget.py.

◆ outFile

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

Definition at line 157 of file run_MufluxfixedTarget.py.

◆ outputDir

str run_MufluxfixedTarget.outputDir = "."

Definition at line 27 of file run_MufluxfixedTarget.py.

◆ P8gen

run_MufluxfixedTarget.P8gen = ROOT.FixedTargetGenerator()

Definition at line 179 of file run_MufluxfixedTarget.py.

◆ parFile

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

Definition at line 158 of file run_MufluxfixedTarget.py.

◆ poteq

run_MufluxfixedTarget.poteq = P8gen.GetPotForCharm()

Definition at line 253 of file run_MufluxfixedTarget.py.

◆ primGen

run_MufluxfixedTarget.primGen = ROOT.FairPrimaryGenerator()

Definition at line 178 of file run_MufluxfixedTarget.py.

◆ procAnnihil

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

Definition at line 226 of file run_MufluxfixedTarget.py.

◆ procGMuPair

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

Definition at line 227 of file run_MufluxfixedTarget.py.

◆ rc

run_MufluxfixedTarget.rc = t.GetEvent(n)

Definition at line 263 of file run_MufluxfixedTarget.py.

◆ rtdb

run_MufluxfixedTarget.rtdb = run.GetRuntimeDb()

Definition at line 169 of file run_MufluxfixedTarget.py.

◆ rtime

run_MufluxfixedTarget.rtime = timer.RealTime()

Definition at line 237 of file run_MufluxfixedTarget.py.

◆ run

run_MufluxfixedTarget.run = ROOT.FairRunSim()

Definition at line 165 of file run_MufluxfixedTarget.py.

◆ runnr

int run_MufluxfixedTarget.runnr = 1000

Definition at line 9 of file run_MufluxfixedTarget.py.

◆ sGeo

run_MufluxfixedTarget.sGeo = ROOT.gGeoManager

Definition at line 286 of file run_MufluxfixedTarget.py.

◆ ship_geo

run_MufluxfixedTarget.ship_geo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/charm-geometry_config.py", Setup = args.CharmdetSetup, cTarget = args.CharmTarget)

Definition at line 153 of file run_MufluxfixedTarget.py.

◆ simEngine

str run_MufluxfixedTarget.simEngine = "Pythia8"

Definition at line 8 of file run_MufluxfixedTarget.py.

◆ storeOnlyMuons

bool run_MufluxfixedTarget.storeOnlyMuons = False

Definition at line 13 of file run_MufluxfixedTarget.py.

◆ sTree

run_MufluxfixedTarget.sTree = t.CloneTree(0)

Definition at line 260 of file run_MufluxfixedTarget.py.

◆ t

run_MufluxfixedTarget.t = fin.cbmsim

Definition at line 258 of file run_MufluxfixedTarget.py.

◆ theSeed

run_MufluxfixedTarget.theSeed = int(10000 * time.time() % 10000000)

Definition at line 28 of file run_MufluxfixedTarget.py.

◆ timer

run_MufluxfixedTarget.timer = ROOT.TStopwatch()

Definition at line 161 of file run_MufluxfixedTarget.py.

◆ tmpFile

str run_MufluxfixedTarget.tmpFile = outFile+"tmp"

Definition at line 246 of file run_MufluxfixedTarget.py.

◆ txt

run_MufluxfixedTarget.txt = 'pythia8_Geant4_'

Definition at line 155 of file run_MufluxfixedTarget.py.

◆ withEvtGen

bool run_MufluxfixedTarget.withEvtGen = True

Definition at line 14 of file run_MufluxfixedTarget.py.

◆ work_dir

str run_MufluxfixedTarget.work_dir = "./"

Definition at line 29 of file run_MufluxfixedTarget.py.

◆ xcopy

run_MufluxfixedTarget.xcopy = x.Clone()

Definition at line 271 of file run_MufluxfixedTarget.py.