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

Functions

 count (hFile=outFile)
 
 myPrint (tc, tname)
 
 absorptionLength ()
 
 absorptionLengthOLD ()
 
 debugging ()
 

Variables

 parser = ArgumentParser()
 
 dest
 
 type
 
 int
 
 help
 
 default
 
 str
 
 float
 
 required
 
 False
 
 action
 
 options = parser.parse_args()
 
 logEstart = int(ROOT.TMath.Log10(options.Estart))
 
 logEend = int(ROOT.TMath.Log10(options.Eend))
 
str outFile = 'thermNeutron_'+options.targetMaterial+'_'+str(options.targetLength)+'_'+str(logEstart)+'_'+str(logEend)+'_'+str(options.run)+'.root'
 
str parFile = outFile.replace('thermNeutron','params-thermNeutron')
 
 timer = ROOT.TStopwatch()
 
 run = ROOT.FairRunSim()
 
 primGen = ROOT.FairPrimaryGenerator()
 
 Neutrongen = ROOT.NeutronGenerator_FLUKA()
 
 myPgun = ROOT.FairBoxGenerator(options.pID,1)
 
 cave = ROOT.ShipCave("CAVE")
 
 target = ROOT.boxTarget()
 
 neutron = ROOT.G4Neutron.Neutron()
 
 pManager = neutron.GetProcessManager()
 
bool thermal = False
 
 process = pManager.GetProcess("hadElastic")
 
 process1 = ROOT.G4HadronElasticProcess()
 
 model1a = ROOT.G4ParticleHPElastic()
 
int eV = 1E-6
 
 model1b = ROOT.G4ParticleHPThermalScattering()
 
 gMC = ROOT.TVirtualMC.GetMC()
 
 fStack = gMC.GetStack()
 
 rtime = timer.RealTime()
 
 ctime = timer.CpuTime()
 
 sGeo = ROOT.gGeoManager
 
dict h = {}
 
str pathToPlots = "/mnt/hgfs/microDisk/CERNBOX/SND@LHC/Thermal Neutrons/"
 
 rate = ROOT.TF1('rate','1./10**x*exp(-[0]/([1]*sqrt(10**x)))',-9,2)
 

Function Documentation

◆ absorptionLength()

thermalNeutrons.absorptionLength ( )

Definition at line 173 of file thermalNeutrons.py.

173def absorptionLength():
174 for material in ['Boratedpolyethylene','BoronCarbide']:
175 for Erange in ['-10_-8','-8_-7','-6_-4']:
176 fname = "thermNeutron_"+material+"_100.0_"+Erange+"_0.root"
177 count(fname)
178 for x in ['Lab','Labz']:
179 hname = x+'_'+material+E
180 h[hname] = h[x].ProfileX(hname,1,-1,'g')
181
182
183
184
185

◆ absorptionLengthOLD()

thermalNeutrons.absorptionLengthOLD ( )

Definition at line 186 of file thermalNeutrons.py.

186def absorptionLengthOLD():
187 Lfun = ROOT.TF1('Lfun','[0]*(10**x)**[1]',-9,-6)
188 Lfun.SetParameter(0,6.4)
189 Lfun.SetParameter(1,0.98)
190 hFiles = {"thermNeutron_BoronCarbide_X.XX_-E_-E_0.root":[0.08,0.3],"thermNeutron_Boratedpolyethylene_X.XX_0.root":[1.0,100.]}
191 # thermNeutron_BoronCarbide_4.0_-8_-7_0.root
192
193 Ls = {0.01:ROOT.kRed,0.1:ROOT.kOrange,0.04:ROOT.kCyan,0.4:ROOT.kBlue,4.0:ROOT.kMagenta}
194
195 for hFile in hFiles:
196 material = hFile.split('_')[1]
197 ut.bookCanvas(h,'absorb'+material,'',1200,800,1,1)
198 h['absorb'+material].cd()
199 for L in Ls:
200 l = str(L)
201 if L<3: tmp = hFile.replace("X.XX",l).replace(" _-E_-E","")
202 else: tmp = hFile.replace("X.XX",l).replace(" _-E_-E","_-8_-7")
203 count(tmp)
204 h['Eff_'+l]=h['Eff'].Clone('Eff_'+l)
205 h['L_'+l]=ROOT.TGraph()
206 h['L_'+l].SetLineColor(Ls[L])
207 h['Eff'].Draw()
208 g = h['Eff'].GetPaintedGraph()
209 for n in range(g.GetN()):
210 logE, p = g.GetPointX(n),g.GetPointY(n)
211 if p>0:
212 absL = -L/ROOT.TMath.Log(p)
213 else:
214 absL = 0
215 h['L_'+l].SetPoint(n,logE,absL)
216 ut.bookHist(h,'L',';logE; L [cm]',100,-9.,-6.)
217 h['L'].SetMaximum(hFiles[hFile][0])
218 h['L'].SetStats(0)
219 h['L'].Draw()
220 for L in Ls:
221 if L>hFiles[hFile][1]: continue
222 h['L_'+str(L)].Draw('same')
223 h['L_'+str(0.1)].Fit(Lfun)
224 myPrint(h['absorb'+material],'absorbLength'+material)
225
226

◆ count()

thermalNeutrons.count (   hFile = outFile)

Definition at line 133 of file thermalNeutrons.py.

133def count(hFile = outFile):
134 f=ROOT.TFile(hFile)
135 ut.bookHist(h,'E',';log10(Ekin [MeV])',1000,-10.,4.)
136 ut.bookHist(h,'Epassed',';log10(Ekin [MeV])',1000,-10.,4.)
137 ut.bookHist(h,'Lab',';absorption Length vs logE',1000,-10.,4.,500,-0.1,10.)
138 ut.bookHist(h,'Labz',';absorption Length vs logE',1000,-10.,4.,500,-0.1,10.)
139 ut.bookHist(h,'xyz','', 100,-0.1,0.1,100,-0.1,0.1,200,-1.,1.)
140 ut.bookHist(h,'dxyz','',100,-0.1,0.1,100,-0.1,0.1,200,-1.,1.)
141 ut.bookHist(h,'Epassed',';log10(Ekin [MeV])',1000,-10.,4.)
142 Npassed = 0
143 for sTree in f.cbmsim:
144 N = sTree.MCTrack[0]
145 Ekin = N.GetP()**2/(2*N.GetMass())*1000.
146 logEkin = ROOT.TMath.Log10(Ekin)
147 rc = h['E'].Fill(logEkin)
148 for p in sTree.vetoPoint:
149 if not p.PdgCode()==2112: continue
150 if p.GetDetectorID()==1 :
151 mean = ROOT.TVector3(p.GetX(),p.GetY(),p.GetZ())
152 end = p.LastPoint()
153 D = 2*(end-mean)
154 start = 2*mean-end
155 rc = h['Lab'].Fill(logEkin,D.Mag())
156 rc = h['Labz'].Fill(logEkin,D.Z())
157 rc = h['xyz'].Fill(start.X(),start.Y(),start.Z())
158 rc = h['dxyz'].Fill(end.X(),end.Y(),end.Z())
159 else:
160 Npassed+=1
161 rc = h['Epassed'].Fill(ROOT.TMath.Log10(Ekin))
162 h['Eff'] = ROOT.TEfficiency(h['Epassed'],h['E'])
163 h['Eff'].Draw()
164 print(Npassed)
165

◆ debugging()

thermalNeutrons.debugging ( )

Definition at line 240 of file thermalNeutrons.py.

240def debugging():
241 neutron = ROOT.G4Neutron.Neutron()
242 neutron.DumpTable()
243 pManager = neutron.GetProcessManager()
244 pManager.DumpInfo()
245 for p in pManager.GetProcessList():
246 p.DumpInfo()
247 store = ROOT.G4HadronicProcessStore.Instance()
248 store.Dump(1)
249 runManager = ROOT.G4RunManager.GetRunManager()
250 gt = ROOT.G4TransportationManager.GetTransportationManager()
251 gn = gt.GetNavigatorForTracking()
252 world = gn.GetWorldVolume().GetLogicalVolume()
253 vmap = {}
254 for da in range(world.GetNoDaughters()):
255 vl = world.GetDaughter(da)
256 vmap[vl.GetName().c_str()] = vl
257 lvl = vl.GetLogicalVolume()
258 mat = lvl.GetMaterial()
259 print("%2i %s %5.3F g/cm3 %5.2F kg %s"%(da, vl.GetName(),mat.GetDensity()/G4Unit.g*G4Unit.cm3,lvl.GetMass()/G4Unit.kg,mat.GetName()))
260 for n in range(mat.GetNumberOfElements()):
261 element = mat.GetElement(n)
262 print(" %2i %s %4.1F %5.4F "%(n,element.GetName(),element.GetAtomicMassAmu(),mat.GetFractionVector()[n]))

◆ myPrint()

thermalNeutrons.myPrint (   tc,
  tname 
)

Definition at line 167 of file thermalNeutrons.py.

167def myPrint(tc,tname):
168 for z in ['.png','.pdf','.root']:
169 tc.Print(tname+z)
170 os.system('mv '+tname+z+' '+pathToPlots)
171
172

Variable Documentation

◆ action

thermalNeutrons.action

Definition at line 35 of file thermalNeutrons.py.

◆ cave

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

Definition at line 73 of file thermalNeutrons.py.

◆ ctime

thermalNeutrons.ctime = timer.CpuTime()

Definition at line 118 of file thermalNeutrons.py.

◆ default

thermalNeutrons.default

Definition at line 26 of file thermalNeutrons.py.

◆ dest

thermalNeutrons.dest

Definition at line 26 of file thermalNeutrons.py.

◆ eV

int thermalNeutrons.eV = 1E-6

Definition at line 98 of file thermalNeutrons.py.

◆ False

thermalNeutrons.False

Definition at line 32 of file thermalNeutrons.py.

◆ float

thermalNeutrons.float

Definition at line 30 of file thermalNeutrons.py.

◆ fStack

thermalNeutrons.fStack = gMC.GetStack()

Definition at line 108 of file thermalNeutrons.py.

◆ gMC

thermalNeutrons.gMC = ROOT.TVirtualMC.GetMC()

Definition at line 107 of file thermalNeutrons.py.

◆ h

dict thermalNeutrons.h = {}

Definition at line 131 of file thermalNeutrons.py.

◆ help

thermalNeutrons.help

Definition at line 26 of file thermalNeutrons.py.

◆ int

thermalNeutrons.int

Definition at line 26 of file thermalNeutrons.py.

◆ logEend

thermalNeutrons.logEend = int(ROOT.TMath.Log10(options.Eend))

Definition at line 40 of file thermalNeutrons.py.

◆ logEstart

thermalNeutrons.logEstart = int(ROOT.TMath.Log10(options.Estart))

Definition at line 39 of file thermalNeutrons.py.

◆ model1a

thermalNeutrons.model1a = ROOT.G4ParticleHPElastic()

Definition at line 97 of file thermalNeutrons.py.

◆ model1b

thermalNeutrons.model1b = ROOT.G4ParticleHPThermalScattering()

Definition at line 102 of file thermalNeutrons.py.

◆ myPgun

thermalNeutrons.myPgun = ROOT.FairBoxGenerator(options.pID,1)

Definition at line 62 of file thermalNeutrons.py.

◆ neutron

thermalNeutrons.neutron = ROOT.G4Neutron.Neutron()

Definition at line 88 of file thermalNeutrons.py.

◆ Neutrongen

thermalNeutrons.Neutrongen = ROOT.NeutronGenerator_FLUKA()

Definition at line 59 of file thermalNeutrons.py.

◆ options

thermalNeutrons.options = parser.parse_args()

Definition at line 36 of file thermalNeutrons.py.

◆ outFile

thermalNeutrons.outFile = 'thermNeutron_'+options.targetMaterial+'_'+str(options.targetLength)+'_'+str(logEstart)+'_'+str(logEend)+'_'+str(options.run)+'.root'

Definition at line 41 of file thermalNeutrons.py.

◆ parFile

str thermalNeutrons.parFile = outFile.replace('thermNeutron','params-thermNeutron')

Definition at line 43 of file thermalNeutrons.py.

◆ parser

thermalNeutrons.parser = ArgumentParser()

Definition at line 25 of file thermalNeutrons.py.

◆ pathToPlots

str thermalNeutrons.pathToPlots = "/mnt/hgfs/microDisk/CERNBOX/SND@LHC/Thermal Neutrons/"

Definition at line 166 of file thermalNeutrons.py.

◆ pManager

thermalNeutrons.pManager = neutron.GetProcessManager()

Definition at line 89 of file thermalNeutrons.py.

◆ primGen

thermalNeutrons.primGen = ROOT.FairPrimaryGenerator()

Definition at line 56 of file thermalNeutrons.py.

◆ process

thermalNeutrons.process = pManager.GetProcess("hadElastic")

Definition at line 93 of file thermalNeutrons.py.

◆ process1

thermalNeutrons.process1 = ROOT.G4HadronElasticProcess()

Definition at line 95 of file thermalNeutrons.py.

◆ rate

thermalNeutrons.rate = ROOT.TF1('rate','1./10**x*exp(-[0]/([1]*sqrt(10**x)))',-9,2)

Definition at line 227 of file thermalNeutrons.py.

◆ required

thermalNeutrons.required

Definition at line 32 of file thermalNeutrons.py.

◆ rtime

thermalNeutrons.rtime = timer.RealTime()

Definition at line 117 of file thermalNeutrons.py.

◆ run

thermalNeutrons.run = ROOT.FairRunSim()

Definition at line 50 of file thermalNeutrons.py.

◆ sGeo

thermalNeutrons.sGeo = ROOT.gGeoManager

Definition at line 125 of file thermalNeutrons.py.

◆ str

thermalNeutrons.str

Definition at line 29 of file thermalNeutrons.py.

◆ target

thermalNeutrons.target = ROOT.boxTarget()

Definition at line 77 of file thermalNeutrons.py.

◆ thermal

bool thermalNeutrons.thermal = False

Definition at line 91 of file thermalNeutrons.py.

◆ timer

thermalNeutrons.timer = ROOT.TStopwatch()

Definition at line 46 of file thermalNeutrons.py.

◆ type

thermalNeutrons.type

Definition at line 26 of file thermalNeutrons.py.