89 materials = {
'Boratedpolyethylene':ROOT.kGreen,
'BoronCarbide':ROOT.kBlue,
'Concrete':ROOT.kGray,
'EmulsionAg109':ROOT.kOrange,
'H2O':ROOT.kCyan}
91 B10Parameter [
'Boratedpolyethylene'] = 0.01*0.94 / (10.*1.672E-24)
92 B10Parameter [
'BoronCarbide'] = 0.125*1.360 / (10.*1.672E-24)
95 Fabsorp = h[
'Fabsorp']
96 for m
in B10Parameter:
97 Fabsorp[m] = ROOT.TF1(
'fabs'+m,
'1./([0]/sqrt(10**x)*[1])',-10.,4.)
98 Fabsorp[m].SetParameter(0,Xsec)
99 Fabsorp[m].SetParameter(1,B10Parameter[m])
101 for material
in materials:
102 for Erange
in [
'-14_-12',
'-12_-10',
'-10_-8',
'-8_-7',
'-7_-6',
'-6_-4',
'-4_-2']:
103 fname =
"thermNeutron_"+material+
"_100.0_"+Erange+
"_0.root"
104 if not fname
in os.listdir(
'.'):
continue
106 h[
'Esecondary'+
'_'+material+Erange] = h[
'Esecondary'].Clone(
'Esecondary'+
'_'+material+Erange)
107 h[
'electrons'+
'_'+material+Erange] = h[
'electrons'].Clone(
'electrons'+
'_'+material+Erange)
108 h[
'photons'+
'_'+material+Erange] = h[
'photons'].Clone(
'photons'+
'_'+material+Erange)
109 for x
in [
'Lab',
'Labz']:
110 hname = x+
'_'+material+Erange
111 h[hname] = h[x].ProfileX(hname,1,-1,
'g')
112 hsum = x+
'_'+material
114 h[hsum] = h[hname].Clone(hsum)
115 h[hsum].SetLineColor(materials[material])
116 else: h[hsum].Add(h[hname])
118 ut.writeHists(h,
'thermalNeutrons-histograms.root',plusCanvas=
True)
120 ut.readHists(h,
'thermalNeutrons-histograms.root')
122 for material
in materials:
123 for Erange
in [
'-14_-12',
'-12_-10',
'-10_-8',
'-8_-7',
'-7_-6',
'-6_-4',
'-4_-2']:
124 histo = h[
'Esecondary'+
'_'+material+Erange]
125 print(
"secondary neutrons for %s %s %5.2F%%"%(material,Erange,100.*histo.GetEntries()/h[
'Labz'+
'_'+material+Erange].GetEntries()))
126 for X
in [
'electrons',
'photons']:
127 for material
in materials:
128 h[X+
'_'+material]=h[X].Clone(X+
'_'+material)
129 for Erange
in [
'-14_-12',
'-12_-10',
'-10_-8',
'-8_-7',
'-7_-6',
'-6_-4',
'-4_-2']:
130 h[X+
'_'+material].Add(h[X+
'_'+material+Erange])
131 norm = h[X+
'_'+material].ProjectionX(
'norm',1,101)
133 h[X+
str(p)+
'Percent_'+material] = h[X+
'_'+material].ProjectionX(X+
str(p)+
'Percent_'+material,1,p)
134 h[X+
str(p)+
'Percent_'+material].Divide(norm)
135 ut.bookCanvas(h,
'T'+X,
'',1200,800,1,1)
137 material =
'EmulsionAg109'
138 h[X+
'1Percent_'+material].SetLineColor(ROOT.kRed)
139 h[X+
'2Percent_'+material].SetLineColor(ROOT.kOrange)
140 h[X+
'5Percent_'+material].SetLineColor(ROOT.kBlue)
141 h[X+
'10Percent_'+material].SetLineColor(ROOT.kGreen)
142 h[X+
'1Percent_'+material].SetTitle(
'')
143 h[X+
'1Percent_'+material].GetYaxis().SetTitle(
'fraction of events with < N_{'+X+
'}')
144 h[X+
'1Percent_'+material].GetXaxis().SetRangeUser(-12.,1)
145 h[X+
'1Percent_'+material].SetStats(0)
146 h[X+
'1Percent_'+material].Draw(
'hist')
147 h[
'leg'+X]=ROOT.TLegend(0.63,0.25,0.88,0.40)
149 h[X+
str(p)+
'Percent_'+material].Draw(
'histsame')
150 rc = h[
'leg'+X].AddEntry(h[X+
str(p)+
'Percent_'+material],
'N_{'+X+
'}<'+
str(p),
'PL')
151 h[
'leg'+X].Draw(
'same')
152 myPrint(h[
'T'+X],
'fracEveWith'+X)
154 fntuple = ROOT.TFile.Open(
'neutronsTI18.root')
158 if tcanv
in h: h.pop(tcanv)
159 ut.bookCanvas(h,tcanv,
'',1200,800,1,1)
161 nt.Draw(
'log10(N*Eleft):log10(Eleft)>>rates',
'',
'box')
162 h[
'rates']=ROOT.gROOT.FindObjectAny(
'rates').Clone(
'rates')
164 for x
in [
'Lab',
'Labz']:
166 if tcanv
in h: h.pop(tcanv)
167 ut.bookCanvas(h,tcanv,
'',1200,800,1,1)
171 h[hsum].GetXaxis().SetRangeUser(-12.,1)
172 h[hsum].SetMaximum(30.)
173 h[hsum].SetMinimum(0.004)
174 h[hsum].GetXaxis().SetTitle(
'logE[MeV]')
175 h[hsum].GetYaxis().SetTitle(
'absorption Length [cm]')
176 h[hsum].SetLineWidth(2)
178 h[
'leg'+x]=ROOT.TLegend(0.6,0.2,0.86,0.36)
179 for material
in materials:
180 hsum = x+
'_'+material
182 h[hsum].SetLineWidth(2)
183 h[hsum].Draw(
'histsame')
184 if material
in Fabsorp: Fabsorp[material].Draw(
'same')
185 rc = h[
'leg'+x].AddEntry(h[hsum],material,
'PL')
186 h[
'leg'+x].Draw(
'same')
187 myPrint(h[
'abs'+x],
'AbsLength'+x)
190 h[
'Fig12'] = ROOT.TGraph()
191 h[
'dE'] = ROOT.TGraph()
192 h[
'neutronRate'] = ROOT.TGraph()
193 h[
'dangerZone']=ROOT.TGraph()
194 h[
'dangerZone'].SetPoint(0,-5.6,0.)
195 h[
'dangerZone'].SetPoint(1,-5.6,1.E7)
196 h[
'dangerZone'].SetPoint(2,-5.1,1.E7)
197 h[
'dangerZone'].SetPoint(3,-5.1,0.)
198 h[
'dangerZone'].SetFillStyle(1001)
199 h[
'dangerZone'].SetFillColor(ROOT.kYellow)
204 for nt
in fntuple.nt:
205 E = (nt.Eleft+nt.Eright)/2.
206 dE = nt.Eright - nt.Eleft
207 h[
'Fig12'].SetPoint(n,ROOT.TMath.Log10(E),ROOT.TMath.Log10(nt.N*E))
208 h[
'neutronRate'].SetPoint(n,E,nt.N)
209 h[
'dE'].SetPoint(n,E,dE)
211 RateIntegratedW+=nt.N*dE
215 h[
'Fig12'].Draw(
'same')
217 ut.bookHist(h,
'Nr',
';E [MeV];dn/dlogE [cm^{-2}y^{-1}] ',100,-12.,1.)
218 h[
'Nr'].SetMaximum(2.E8)
219 h[
'Nr'].SetMinimum(1.E-4)
222 thick = {0.0:ROOT.kBlue,0.5:ROOT.kOrange,1:ROOT.kRed,2:ROOT.kRed+2,5:ROOT.kRed-7,10:ROOT.kGreen}
223 for material
in [
'Boratedpolyethylene',
'BoronCarbide']:
224 intRates[material]={}
225 tcanv =
'ratesWith_'+material
226 if tcanv
in h: h.pop(tcanv)
227 ut.bookCanvas(h,tcanv,material,1200,800,1,1)
230 h[
'ratesWith_'+material].cd()
232 h[
'dangerZone'].Draw(
'sameF')
233 h[
'legthick'+material]=ROOT.TLegend(0.6,0.2,0.86,0.36)
235 intRates[material][d]=0
236 absorbLength = h[
'Labz_'+material]
237 gname =
'neutronRate_'+material+
'_'+
str(d)
238 h[gname] = ROOT.TGraph()
239 h[gname].SetLineWidth(2)
240 h[gname].SetLineColor(thick[d])
241 for n
in range(h[
'Fig12'].GetN()):
242 logE = h[
'Fig12'].GetX()[n]
243 R = ROOT.TMath.Power(10.,h[
'Fig12'].GetY()[n])
244 dE = h[
'dE'].GetPointY(n)
245 E = ROOT.TMath.Power(10.,logE)
248 h[gname].SetPoint(n,logE,R)
249 intRates[material][d] += dE*R/E
251 L = absorbLength.GetBinContent(absorbLength.FindBin(logE))
254 absorpt = ROOT.TMath.Exp(-d/L)
256 h[gname].SetPoint(n,logE,Rnew)
258 intRates[material][d] += dE * Rnew/E
259 h[gname].Draw(
'same')
260 rc = h[
'legthick'+material].AddEntry(h[gname],
'thickness %3.1Fcm'%(d),
'PL')
261 reduction = intRates[material][d]/intRates[material][0]
262 print(
'integrated rate with %s d=%3.1Fcm: %6.4G reduction factor=%6.2G'%(material,d,intRates[material][d],reduction) )
264 h[
'IUp-neutronRate_'+material+
str(d)] = ROOT.TGraph()
265 h[
'IUp-neutronRateW_'+material+
str(d)] = ROOT.TGraph()
266 h[
'IDown-neutronRate_'+material+
str(d)] = ROOT.TGraph()
267 up = h[
'IUp-neutronRate_'+material+
str(d)]
268 down = h[
'IDown-neutronRate_'+material+
str(d)]
272 logE = h[gname].GetX()[n]
273 dE = h[
'dE'].GetPointY(n)
274 Rnew = h[gname].GetY()[n]
275 E = ROOT.TMath.Power(10.,logE)
277 up.SetPoint(n,logE,S)
279 W = 1 - h[
'electrons1Percent_EmulsionAg109'].GetBinContent(n)
280 h[
'IUp-neutronRateW_'+material+
str(d)].SetPoint(n,logE,W*S)
285 down.SetPoint(n,logE,S)
287 for Elimit
in [100.,1.,0.1,0.01]:
288 g = h[
'IUp-neutronRate_'+material+
str(d)]
289 gW = h[
'IUp-neutronRateW_'+material+
str(d)]
291 for n
in range(N-1,1,-1):
292 if ROOT.TMath.Power(10,g.GetX()[n])<Elimit:
break
293 reduction = g.GetY()[n]/h[
'IUp-neutronRate_'+material+
str(0.0)].GetY()[N-1]
294 reductionW = gW.GetY()[n]/h[
'IUp-neutronRate_'+material+
str(0.0)].GetY()[N-1]
295 print(
'integrated rate E < %5.3F with %s d=%3.1Fcm: %6.4G reduction factor=%6.2G | %6.4G reduction factor=%6.2G'%(
296 Elimit,material,d,g.GetY()[n],reduction,gW.GetY()[n],reductionW))
298 h[
'legthick'+material].Draw(
'same')
299 myPrint(h[
'ratesWith_'+material],
'reducedRates_'+material)
432 tmp = options.inputFile.split(
'/')
433 gFile =
"geofile-"+(tmp[len(tmp)-1].split(
'_coldbox')[0]+
'_coldbox.root').replace(
'histos-',
'')
434 g = ROOT.TFile(gFile)
437 vbox = sGeo.FindVolumeFast(
'vbox')
438 sbox = sGeo.FindVolumeFast(
'sensBox')
439 dX,dY,dZ = vbox.GetShape().GetDX(),vbox.GetShape().GetDY(),vbox.GetShape().GetDZ()
440 nav = sGeo.GetCurrentNavigator()
443 start = array(
'd',[0,200,0])
444 direction = array(
'd',[0,-1,0])
445 startnode = sGeo.InitTrack(start, direction)
446 length = c_double(200.)
447 node = sGeo.FindNextBoundaryAndStep(length, ROOT.kFALSE)
448 boundaries[
'topIn'] = nav.GetCurrentPoint()[1]
449 node = sGeo.FindNextBoundaryAndStep(length, ROOT.kFALSE)
450 boundaries[
'topSens'] = nav.GetCurrentPoint()[1]
451 start = array(
'd',[0,-200,0])
452 direction = array(
'd',[0,1,0])
453 startnode = sGeo.InitTrack(start, direction)
454 node = sGeo.FindNextBoundaryAndStep(length, ROOT.kFALSE)
455 node = sGeo.FindNextBoundaryAndStep(length, ROOT.kFALSE)
456 boundaries[
'botSens'] = nav.GetCurrentPoint()[1]
458 start = array(
'd',[-200,0,0])
459 direction = array(
'd',[1,0,0])
460 startnode = sGeo.InitTrack(start, direction)
461 node = sGeo.FindNextBoundaryAndStep(length, ROOT.kFALSE)
462 boundaries[
'leftIn'] = nav.GetCurrentPoint()[0]
463 node = sGeo.FindNextBoundaryAndStep(length, ROOT.kFALSE)
464 boundaries[
'leftSens'] = nav.GetCurrentPoint()[0]
465 start = array(
'd',[200,0,0])
466 direction = array(
'd',[-1,0,0])
467 startnode = sGeo.InitTrack(start, direction)
468 node = sGeo.FindNextBoundaryAndStep(length, ROOT.kFALSE)
469 boundaries[
'rightIn'] = nav.GetCurrentPoint()[0]
470 node = sGeo.FindNextBoundaryAndStep(length, ROOT.kFALSE)
471 boundaries[
'rightSens'] = nav.GetCurrentPoint()[0]
473 start = array(
'd',[0,0,-200])
474 direction = array(
'd',[0,0,1])
475 startnode = sGeo.InitTrack(start, direction)
476 node = sGeo.FindNextBoundaryAndStep(length, ROOT.kFALSE)
477 boundaries[
'backIn'] = nav.GetCurrentPoint()[2]
478 node = sGeo.FindNextBoundaryAndStep(length, ROOT.kFALSE)
479 boundaries[
'backSens'] = nav.GetCurrentPoint()[2]
480 start = array(
'd',[0,0,200])
481 direction = array(
'd',[0,0,-1])
482 startnode = sGeo.InitTrack(start, direction)
483 node = sGeo.FindNextBoundaryAndStep(length, ROOT.kFALSE)
484 boundaries[
'frontIn'] = nav.GetCurrentPoint()[2]
485 node = sGeo.FindNextBoundaryAndStep(length, ROOT.kFALSE)
486 boundaries[
'frontSens'] = nav.GetCurrentPoint()[2]
487 Rin = {
'':
'',
'topIn':
'Y',
'leftIn':
'X',
'rightIn':
'X',
'frontIn':
'Z',
'backIn':
'Z'}
488 Rsens = {
'':
'',
'topSens':
'Y',
'botSens':
'Y',
'leftSens':
'X',
'rightSens':
'X',
'frontSens':
'Z',
'backSens':
'Z'}
494 f = ROOT.TFile.Open(options.inputFile)
496 ut.bookHist(h,
'start',
'start neutron;x [cm] ;y [cm] ;z [cm]',100,-200,200,100,-200,200,100,-200,200)
497 ut.bookHist(h,
'startR',
'start neutron;R',100,0,200)
498 for o
in [
'_seco',
'_prim']:
499 for T
in [
'',
'cold',
'hot']:
500 ut.bookHist(h,
'entry'+T+o,
'entry neutron;x [cm] ;y [cm] ;z [cm]',100,-100,100,100,-100,100,100,-100,100)
501 ut.bookHist(h,
'exit'+T+
'-original'+o,
'enter coldbox neutron;x [cm] ;y [cm] ;z [cm]',100,-100,100,100,-100,100,100,-100,100)
502 ut.bookHist(h,
'exit'+T+o,
'enter coldbox neutron;x [cm] ;y [cm] ;z [cm]',100,-100,100,100,-100,100,100,-100,100)
504 ut.bookHist(h,
'EkinE'+r+o,
'log10(Ekin)',100,-13.,0,100,-200.,200.)
505 ut.bookHist(h,
'Ekin'+r+o,
'log10(Ekin)',100,-13.,0,100,-200.,200.)
507 ut.bookHist(h,
'DF'+r+o,
'travel distance',100,0.,200.)
508 ut.bookHist(h,
'EkinF'+r+o,
'log10(Ekin) vs distance',100,-13.,0,100,-200.,200.)
509 ut.bookHist(h,
'EkinF-original'+r+o,
'log10(Ekin) vs distance',100,-13.,0,100,-200.,200.)
510 ut.bookHist(h,
'checkBox'+r+o,
'enter coldbox neutron;x [cm] ;y [cm] ;z [cm]',100,-100,100,100,-100,100,100,-100,100)
511 ut.bookHist(h,
'EkinG',
'log10(Ekin)',100,-13.,0.)
512 ut.bookHist(h,
'EkinW',
'log10(Ekin)',100,-13.,0.)
513 ut.bookHist(h,
'EkinWlin',
'Ekin',100,1E-9,100*1E-9)
514 ut.bookHist(h,
'multS',
'mult veto points shielding',100,-0.5,99.5)
515 ut.bookHist(h,
'multC',
'mult veto points inside',100,-0.5,99.5)
516 ut.bookHist(h,
'multN',
'mult neutrons',100,-0.5,99.5)
519 Nsim = f.cbmsim.GetEntries()
520 for sTree
in f.cbmsim:
521 rc=h[
'multN'].Fill(sTree.MCTrack.GetEntries())
522 neutron = sTree.MCTrack[0]
523 start = ROOT.TVector3(neutron.GetStartX(),neutron.GetStartY(),neutron.GetStartZ())
524 if start.y() < boundaries[
'botSens']:
continue
526 P = ROOT.TVector3(neutron.GetPx(),neutron.GetPy(),neutron.GetPz())
527 Ekin = ROOT.TMath.Sqrt(P.Mag2()+neutronMass**2) - neutronMass
528 W = h[
'Fig12'].Eval(ROOT.TMath.Log10(Ekin*1000)) / Nsim
529 rc = h[
'start'].Fill(start.Z(),start.X(),start.Y(),W)
530 rc = h[
'EkinW'].Fill(ROOT.TMath.Log10(Ekin),W)
531 rc = h[
'EkinWlin'].Fill(Ekin,W)
532 rc = h[
'EkinG'].Fill(ROOT.TMath.Log10(Ekin))
533 rc = h[
'startR'].Fill(start.Mag(),W)
535 for p
in sTree.vetoPoint:
536 if p.PdgCode()!=2112:
continue
537 if p.GetDetectorID()==13: nC+=1
539 rc = h[
'multC'].Fill(nC)
540 rc = h[
'multS'].Fill(nS)
542 for p
in sTree.vetoPoint:
543 if p.PdgCode()!=2112:
continue
544 trackID = p.GetTrackID()
545 if not trackID
in trajectory: trajectory[trackID]=[]
546 trajectory[trackID].append(p)
547 for trackID
in trajectory:
549 for p
in trajectory[trackID]:
551 if trackID==0: origin =
'_prim'
552 lastPoint = p.LastPoint()
553 mPoint = ROOT.TVector3(p.GetX(),p.GetY(),p.GetZ())
554 firstPoint = 2*mPoint-lastPoint
555 D = lastPoint-firstPoint
556 TD = firstPoint - start
557 firstMom = ROOT.TVector3(p.GetPx(),p.GetPy(),p.GetPz())
558 Ekin_entry = ROOT.TMath.Sqrt(firstMom.Mag2()+neutronMass**2) - neutronMass
559 if p.GetDetectorID()==13
and firstSens:
561 rc = h[
'exit'+origin].Fill(firstPoint.X(),firstPoint.Y(),firstPoint.Z(),W)
563 if Ekin*1E9< 10: rc = h[
'exitcold-original'+origin].Fill(firstPoint.X(),firstPoint.Y(),firstPoint.Z(),W)
564 else: rc = h[
'exithot-original'+origin].Fill(firstPoint.X(),firstPoint.Y(),firstPoint.Z(),W)
566 if Ekin_entry*1E9< 10: rc = h[
'exitcold'+origin].Fill(firstPoint.X(),firstPoint.Y(),firstPoint.Z(),W)
567 else: rc = h[
'exithot'+origin].Fill(firstPoint.X(),firstPoint.Y(),firstPoint.Z(),W)
568 rc = h[
'DF'+origin].Fill(TD.Mag(),W)
569 rc = h[
'EkinF'+origin].Fill(ROOT.TMath.Log10(Ekin_entry),D.Mag(),W)
570 rc = h[
'EkinF-original'+origin].Fill(ROOT.TMath.Log10(Ekin),D.Mag(),W)
575 X = eval(
'firstPoint.'+Rsens[r]+
'()')
576 if abs(X-boundaries[r]) < epsi:
584 X = eval(
'firstPoint.'+Rsens[r]+
'()')
585 txt+=
" "+r+
" "+
str(X)
586 print(
"this should no happen", txt, boundaries)
587 for P
in trajectory[trackID]: print(P.GetDetectorID(),P.LastPoint().X(),P.LastPoint().Y(),P.LastPoint().Z())
588 rc = h[
'DF'+r+origin].Fill(TD.Mag(),W)
589 rc = h[
'EkinF'+r+origin].Fill(ROOT.TMath.Log10(Ekin_entry),D.Mag(),W)
590 rc = h[
'EkinF-original'+r+origin].Fill(ROOT.TMath.Log10(Ekin),D.Mag(),W)
591 rc = h[
'checkBox'+r+origin].Fill(firstPoint.X(),firstPoint.Y(),firstPoint.Z(),W)
593 if p.GetDetectorID()==1:
595 if firstPoint.Mag()<lastPoint.Mag():
continue
596 rc = h[
'Ekin'+origin].Fill(ROOT.TMath.Log10(Ekin),D.Mag(),W)
597 rc = h[
'EkinE'+origin].Fill(ROOT.TMath.Log10(Ekin_entry),D.Mag(),W)
598 rc = h[
'entry'+origin].Fill(firstPoint.X(),firstPoint.Y(),firstPoint.Z(),W)
599 if Ekin*1E9< 10: rc = h[
'entrycold'+origin].Fill(firstPoint.X(),firstPoint.Y(),firstPoint.Z(),W)
600 else: rc = h[
'entryhot'+origin].Fill(firstPoint.X(),firstPoint.Y(),firstPoint.Z(),W)
604 X = eval(
'firstPoint.'+Rin[r]+
'()')
605 if abs(X-boundaries[r]) < epsi:
break
606 rc = h[
'Ekin'+r+origin].Fill(ROOT.TMath.Log10(Ekin),X,W)
607 rc = h[
'EkinE'+r+origin].Fill(ROOT.TMath.Log10(Ekin_entry),X,W)
609 tmp = options.inputFile.split(
'/')
610 outFile =
'histos-'+ tmp[len(tmp)-1]
612 hkeys = list(h.keys())
614 if x.find(
'_seco')>0:
615 hname = x.replace(
'_seco',
'')
616 h[hname]=h[x].Clone(hname)
617 h[hname].Add(h[x.replace(
'_seco',
'_prim')])
619 ut.writeHists(h,outFile)
620 print(
'finished making histograms ',
'histos-noConc-'+options.inputFile)
623 ut.readHists(h,options.inputFile)
624 if pas!=
'': ut.readHists(hnorm,
'histos-thermNeutron_vacuums_0.0001_coldbox_pass1.root')
625 else: ut.readHists(hnorm,options.inputFile)
626 tmp = options.inputFile.split(
'_')
627 material = tmp[1]+
"_coldbox/"
628 thickness =
"_"+tmp[2]
631 for c
in [
'entry',
'exit']:
633 for p
in [
'x',
'y',
'z']:
634 tmp = h[c].Project3D(p)
635 for imin
in range(1,tmp.GetNbinsX()+1):
636 if tmp.GetBinContent(imin)>0:
break
637 for imax
in range(tmp.GetNbinsX(),0,-1):
638 if tmp.GetBinContent(imax)>0:
break
639 binning[c][p]={
'min':imin,
'max':imax}
642 ytop = {
'axis':
'Y',
'proj':
'xz',
'entry':binning[
'entry'][
'y'][
'max'],
'exit':h[
'exit'].GetYaxis().FindBin(boundaries[
'topSens']),
'xdist':dZ,
'ydist':dX}
643 ybot = {
'axis':
'Y',
'proj':
'xz',
'entry':binning[
'entry'][
'y'][
'min'],
'exit':h[
'exit'].GetYaxis().FindBin(boundaries[
'botSens']),
'xdist':dZ,
'ydist':dX}
644 xLeft = {
'axis':
'X',
'proj':
'yz',
'entry':binning[
'entry'][
'x'][
'min'],
'exit':h[
'exit'].GetXaxis().FindBin(boundaries[
'leftSens']),
'xdist':dZ,
'ydist':dY}
645 xRight = {
'axis':
'X',
'proj':
'yz',
'entry':binning[
'entry'][
'x'][
'max'],
'exit':h[
'exit'].GetXaxis().FindBin(boundaries[
'rightSens']),
'xdist':dZ,
'ydist':dY}
646 zMin = {
'axis':
'Z',
'proj':
'yx',
'entry':binning[
'entry'][
'z'][
'min'],
'exit':h[
'exit'].GetZaxis().FindBin(boundaries[
'backSens']),
'xdist':dX,
'ydist':dY}
647 zMax = {
'axis':
'Z',
'proj':
'yx',
'entry':binning[
'entry'][
'z'][
'max'],
'exit':h[
'exit'].GetXaxis().FindBin(boundaries[
'frontSens']),
'xdist':dX,
'ydist':dY}
648 print(
'boundaries',boundaries)
651 projections = {
'Top':ytop,
'Bot':ybot,
'Right':xRight,
'Left':xLeft,
'Front':zMax,
'Back':zMin}
653 for o
in [
'',
'_prim']:
654 for T
in [
'',
'cold',
'hot']:
655 for Z
in [
'entry',
'exit',
'exit-original']:
659 if len(tmp)>1: x=
'-'+tmp[1]
661 ut.bookCanvas(h,
't'+case,case,1200,1800,2,3)
663 for p
in projections:
666 axis = eval(
'tmp.Get'+projections[p][
'axis']+
'axis()')
667 if Z==
'entry': axis.SetRange(projections[p][c]-1,projections[p][c]+1)
669 axis.SetRange(projections[p][c],projections[p][c])
672 xax.SetRange(xax.FindBin(boundaries[
'leftSens'])+1,xax.FindBin(boundaries[
'rightSens'])-1)
674 zax.SetRange(zax.FindBin(boundaries[
'backSens'])+1,zax.FindBin(boundaries[
'frontSens'])-1)
675 h[case+p] = tmp.Project3D(projections[p][
'proj'])
676 h[case+p].SetName(case+p)
677 tmp.GetXaxis().SetRange(0,0)
678 tmp.GetYaxis().SetRange(0,0)
679 tmp.GetZaxis().SetRange(0,0)
680 h[case+p].SetStats(0)
681 h[case+p].SetMinimum(0)
682 h[case+p].SetTitle(p)
683 h[case+p].Draw(
'colz')
685 h[
'X-'+case+p]=h[case+p].ProjectionX(
'X-'+case+p)
686 h[
'Y-'+case+p]=h[case+p].ProjectionY(
'Y-'+case+p)
688 sqcm = projections[p][
'xdist']* projections[p][
'ydist']
689 entries = h[case+p].GetSumOfWeights()
691 if X > 100: txt =
"%5.1F/cm^{2}"%(X)
692 else: txt =
"%5.2F/cm^{2}"%(X)
693 h[
'fluences'][case+p] =X
695 rc = L.DrawLatexNDC(0.2,0.85,txt)
696 h[
'X-'+case+p].Scale(1./ projections[p][
'ydist'])
697 h[
'Y-'+case+p].Scale(1./ projections[p][
'xdist'])
698 myPrint(h[
't'+case],material+
't'+case+thickness)
701 ut.bookCanvas(h,
'crosschecks',
'cross checks',900,600,1,1)
702 tc = h[
'crosschecks'].cd()
706 h[
'EkinW'].SetStats(0)
707 h[
'EkinW'].SetStats(0)
708 h[
'EkinW'].SetLineWidth(3)
709 h[
'EkinW'].SetTitle(
';log(E) [GeV];dn/dlogE [cm^{-2}y^{-1}] ')
710 h[
'EkinW'].SetMaximum(1E8)
711 h[
'EkinW'].SetMinimum(1E2)
713 myPrint(h[
'crosschecks'],material+
'kinEnergy'+thickness )
716 for p
in projections:
717 for l
in [
'X-',
'Y-']:
719 h[case].SetLineColor(ROOT.kRed+k)
722 h[case].SetTitle(
'; x,y,z [cm]; N/L [cm^{-1}]')
723 tpl = ut.findMaximumAndMinimum(h[case])
724 h[case].SetMaximum(tpl[1]*1.5)
726 else: h[case].Draw(
'same')
728 myPrint(h[
'crosschecks'],material+
'irradiationXYZ'+thickness )
733 ut.bookCanvas(h,
'trej',
'rejections',1200,1800,2,3)
735 for r
in [
'',
'top',
'bot',
'right',
'left',
'front',
'back']:
739 norm = hnorm[
'Ekin'].ProjectionX(
'norm')
740 h[rej] = h[
'EkinF'].ProjectionX(rej)
741 h[rejo] = h[
'EkinF-original'].ProjectionX(rejo)
744 if r==
'bot': norm = hnorm[
'EkintopIn'].ProjectionX(
'norm')
745 else: norm = hnorm[
'Ekin'+r+
'In'].ProjectionX(
'norm')
746 h[rej] = h[
'EkinF'+r+
'Sens'].ProjectionX(rej)
747 h[rejo] = h[
'EkinF-original'+r+
'Sens'].ProjectionX(rejo)
752 h[rej].SetTitle(
';log10(Ekin) GeV; rejection')
753 h[rej].SetLineColor(ROOT.kBlue)
754 h[rej].SetLineWidth(2)
755 h[rejo].SetLineWidth(2)
756 h[rejo].SetLineColor(ROOT.kGreen)
757 h[rej].GetXaxis().SetRangeUser(-13.,-1.)
758 h[rej].SetMaximum(1.2)
759 h[rej].SetMinimum(1.E-4)
760 if k==0: tc = h[
'crosschecks'].cd()
765 h[rej].SetMinimum(1.E-6)
766 h[rej].SetTitle(r[0].upper()+r[1:])
769 h[rejo].Draw(
'histsame')
770 h[
'legR'+r]=ROOT.TLegend(0.11,0.74,0.72,0.82)
771 rc = h[
'legR'+r].AddEntry(h[rejo],
'reduction as function of original E_{kin} when entering shield',
'PL')
772 rc = h[
'legR'+r].AddEntry(h[rej],
'reduction as function of E_{kin} when leaving shield',
'PL')
773 h[
'legR'+r].Draw(
'same')
774 if k==0:
myPrint(h[
'crosschecks'],material+
'rejections'+thickness)
775 myPrint(h[
'trej'],material+
'Listrejections'+thickness+pas)
777 h[
'dangerZone']=ROOT.TGraph()
778 h[
'dangerZone'].SetPoint(0,-8.6,0.)
779 h[
'dangerZone'].SetPoint(1,-8.6,1.)
780 h[
'dangerZone'].SetPoint(2,-8.1,1.)
781 h[
'dangerZone'].SetPoint(3,-8.1,0.)
782 h[
'dangerZone'].SetFillStyle(1001)
783 h[
'dangerZone'].SetFillColor(ROOT.kYellow)
784 for r
in [
'rej',
'rejo']:
785 ut.bookCanvas(h,r+
'ection2',
'rejectionRate',900,600,1,1)
786 h[r+
'TopLeftRightBack'] = h[r+
'top'].Clone(r+
'TopLeftRightBack')
787 h[r+
'TopLeftRightBack'].Add(h[r+
'left'])
788 h[r+
'TopLeftRightBack'].Add(h[r+
'right'])
789 h[r+
'TopLeftRightBack'].Add(h[r+
'back'])
790 h[r+
'TopLeftRightBack'].Scale(1./4.)
791 h[r+
'TopLeftRightBack'].SetTitle(
'')
792 if r==
'rej': h[r+
'TopLeftRightBack'].GetXaxis().SetTitle(
'outgoing '+h[r+
'TopLeftRightBack'].GetXaxis().GetTitle())
793 if r==
'rejo': h[r+
'TopLeftRightBack'].GetXaxis().SetTitle(
'incoming '+h[r+
'TopLeftRightBack'].GetXaxis().GetTitle())
794 h[r+
'TopLeftRightBack'].SetLineColor(ROOT.kGreen)
795 h[r+
'bot'].SetLineColor(ROOT.kGray)
796 h[r+
'front'].SetLineColor(ROOT.kRed)
797 h[r+
'TopLeftRightBack'].SetMaximum(1.2)
798 h[r+
'TopLeftRightBack'].SetMinimum(1.E-6)
799 tc = h[r+
'ection2'].cd()
803 h[r+
'TopLeftRightBack'].Draw()
804 h[
'dangerZone'].Draw(
'sameF')
805 h[r+
'TopLeftRightBack'].Draw(
'same')
806 h[r+
'bot'].Draw(
'same')
807 h[r+
'front'].Draw(
'same')
808 h[r+
'legR2']=ROOT.TLegend(0.55,0.30,0.86,0.45)
809 rc = h[r+
'legR2'].AddEntry(h[r+
'TopLeftRightBack'],
'av. rejection top/left/right/back',
'PL')
810 rc = h[r+
'legR2'].AddEntry(h[r+
'bot'],
'rejction bottom, only concrete',
'PL')
811 rc = h[r+
'legR2'].AddEntry(h[r+
'front'],
'rejction front, with holes',
'PL')
812 h[r+
'legR2'].Draw(
'same')
813 myPrint(h[r+
'ection2'],material+
'Sum '+r+
'ections'+thickness+pas)
815 if pas==
'': ut.writeHists(h,options.inputFile.replace(
'.root',
'_pass1.root'))
818 for o
in [
'',
'-original']:
819 for T
in [
'cold',
'hot']:
824 for p
in projections:
825 if p!=
'Bot' and norm!=
'Front':
826 norm+=h[
'fluences'][
'entry'+T+p]
827 exit+=h[
'fluences'][
'exit'+T+o+p]
828 if p==
'Bot': concrete = h[
'fluences'][
'exit'+T+o+p]
829 elif p==
'Front': holes = h[
'fluences'][
'exit'+T+o+p]
834 print(
'%s %s region: %5.2F concrete: %5.2F holes: %5.2F x permille total: %5.2F x permille'%(o,T,exit/norm*1000,concrete/norm*1000,holes/norm*1000,(4*exit+concrete+holes)/(6*norm)*1000))