2from __future__
import print_function
3import ROOT,os,sys,getopt,time,shipRoot_conf
4ROOT.gROOT.ProcessLine(
'#include "FairModule.h"')
8from ShipGeoConfig
import ConfigRegistry
15setup[
'10'] = {
'thickness': 2*u.cm,
'material':
'aluminium',
'momentum': 10*u.GeV}
16setup[
'100'] = {
'thickness': 2*u.cm,
'material':
'aluminium',
'momentum': 100*u.GeV}
17setup[
'200'] = {
'thickness': 2*u.cm,
'material':
'aluminium',
'momentum': 200*u.GeV}
23thickness = setup[s][
'thickness']
24material = setup[s][
'material']
25momentum = setup[s][
'momentum']
29outFile =
"gconv"+s+
".root"
30theSeed = int(10000 * time.time() % 10000000)
34ROOT.gRandom.SetSeed(theSeed)
36ship_geo = ConfigRegistry.loadpy(
"$FAIRSHIP/geometry/geometry_config.py", Yheight = 10, tankDesign = 5, muShieldDesign = 7, nuTauTargetDesign=1)
39timer = ROOT.TStopwatch()
43run = ROOT.FairRunSim()
45run.SetOutputFile(outFile)
46run.SetUserConfig(
"g4Config.C")
47rtdb = run.GetRuntimeDb()
50run.SetMaterials(
"media.geo")
52cave= ROOT.ShipCave(
"CAVE")
53cave.SetGeometryFileName(
"cave.geo")
59 ROOT.pyFairModule.__init__(self,self)
62 print(
"Construct Block")
63 top=ROOT.gGeoManager.GetTopVolume()
64 geoLoad=ROOT.FairGeoLoader.Instance()
65 geoFace=geoLoad.getGeoInterface()
66 media=geoFace.getMedia()
67 geoBuild=geoLoad.getGeoBuilder()
68 ShipMedium=media.getMedium(material)
69 W = ROOT.gGeoManager.GetMedium(material)
71 rc = geoBuild.createMedium(ShipMedium)
72 W = ROOT.gGeoManager.GetMedium(material)
73 aBox = ROOT.gGeoManager.MakeBox(
"target", W, 100.*u.cm, 100.*u.cm, thickness)
74 top.AddNode(aBox, 1, ROOT.TGeoTranslation(0, 0, 0 ))
77 print(
"not implemented!")
81sensPlane = ROOT.exitHadronAbsorber()
82sensPlane.SetEnergyCut(ecut*u.GeV)
83sensPlane.SetZposition(thickness+10*u.cm)
84run.AddModule(sensPlane)
86target.makeSensitive(sensPlane)
89primGen = ROOT.FairPrimaryGenerator()
90myPgun = ROOT.FairBoxGenerator(22,1)
91myPgun.SetPRange(momentum-0.01,momentum+0.01)
92myPgun.SetPhiRange(0,0)
93myPgun.SetThetaRange(0,0)
94myPgun.SetXYZ(0.*u.cm, 0.*u.cm, -10.*u.cm - (thickness) )
95primGen.AddGenerator(myPgun)
96run.SetGenerator(primGen)
98run.SetGenerator(primGen)
101gMC = ROOT.TVirtualMC.GetMC()
103fStack = gMC.GetStack()
104fStack.SetMinPoints(1)
105fStack.SetEnergyCut(-1.)
109 ROOT.gROOT.ProcessLine(
'#include "Geant4/G4ProcessTable.hh"')
110 ROOT.gROOT.ProcessLine(
'#include "Geant4/G4AnnihiToMuPair.hh"')
111 ROOT.gROOT.ProcessLine(
'#include "Geant4/G4GammaConversionToMuons.hh"')
112 gProcessTable = ROOT.G4ProcessTable.GetProcessTable()
113 procAnnihil = gProcessTable.FindProcess(ROOT.G4String(
'AnnihiToMuPair'),ROOT.G4String(
'e+'))
114 procGMuPair = gProcessTable.FindProcess(ROOT.G4String(
'GammaToMuPair'),ROOT.G4String(
'gamma'))
115 procGMuPair.SetCrossSecFactor(boostFactor)
116 procAnnihil.SetCrossSecFactor(boostFactor)
122ROOT.gROOT.ProcessLine(
'#include "Geant4/G4EmParameters.hh"')
123emP = ROOT.G4EmParameters.Instance()
126import rootUtils
as ut
128f=ROOT.gROOT.GetListOfFiles()[0]
130ut.bookHist(h,
'muons',
'muon mult',10,-0.5,9.5)
131ut.bookHist(h,
'electrons',
'e mult',10,-0.5,9.5)
133for n
in range(sTree.GetEntries()):
134 rc = sTree.GetEvent(n)
137 for aHit
in sTree.vetoPoint:
138 if abs(sTree.MCTrack[aHit.GetTrackID()].GetPdgCode())==13: nMu+=1
139 if abs(sTree.MCTrack[aHit.GetTrackID()].GetPdgCode())==11: nEl+=1
140 rc = h[
'muons'].Fill(nMu)
141 rc = h[
'electrons'].Fill(nEl)
146rtime = timer.RealTime()
147ctime = timer.CpuTime()
149print(
"Macro finished succesfully.")
150print(
"Output file is ", outFile)
151print(
"Real time ",rtime,
" s, CPU time ",ctime,
"s")
makeSensitive(self, sensPlane)
configure(darkphoton=None)