TDCRPy 1.12.11__py3-none-any.whl → 1.12.12__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of TDCRPy might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: TDCRPy
3
- Version: 1.12.11
3
+ Version: 1.12.12
4
4
  Summary: TDCR model
5
5
  Home-page: https://pypi.org/project/TDCRPy/
6
6
  Author: RomainCoulon (Romain Coulon)
@@ -1,4 +1,4 @@
1
- tdcrpy/TDCRPy.py,sha256=BF5D-SXuYJvmpZ4WzGao1rktNkM6Udn6Tj3QB62XPnA,54209
1
+ tdcrpy/TDCRPy.py,sha256=FkVcr_YOu3dqp5BcQjxp9h6lRC-WitUF6jUr3-5Ffj0,65329
2
2
  tdcrpy/TDCRPy1.py,sha256=QTBZh5B5JWnGB0BQfD-cFmwA9W080OD4sG-aj50-ejo,38106
3
3
  tdcrpy/TDCR_model_lib.py,sha256=Vqbd-JVhGdF9BzW9axYwCHl2MOBfupCJ1ih5Nz_aXts,106906
4
4
  tdcrpy/TDCRoptimize.py,sha256=c2XIGveeLdVYYek4Rg6dygMvVA2xIrIkMb3L-_jUucM,6496
@@ -1081,8 +1081,8 @@ tdcrpy/docs/_build/html/source/modules.html,sha256=Jf-qxVBId0UgpwyvYuyjtMNG-ezPO
1081
1081
  tdcrpy/docs/_build/html/source/tdcrpy.html,sha256=-38lHMNFB22p1tWJEeN3yDqfDiCYE304vxDamO1-iRc,3779
1082
1082
  tdcrpy/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1083
1083
  tdcrpy/test/test_tdcrpy.py,sha256=JINqSEMFoNpptE4f3h6ZzTYW1rBx90KkaoQzltSg-No,4692
1084
- TDCRPy-1.12.11.dist-info/LICENCE.md,sha256=ZTpWyGU3qv_iwEpgvCijoCuCYpOPpyzJCgOk46WpUKU,1066
1085
- TDCRPy-1.12.11.dist-info/METADATA,sha256=ehz0XowQstuLX8J7AuXro9VcGc8C-5GOa-in_3YEhwg,15833
1086
- TDCRPy-1.12.11.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
1087
- TDCRPy-1.12.11.dist-info/top_level.txt,sha256=f4vzFFcKSEnonAACs0ZXuRczmroLLqtPTqXFymU_VU0,14
1088
- TDCRPy-1.12.11.dist-info/RECORD,,
1084
+ TDCRPy-1.12.12.dist-info/LICENCE.md,sha256=ZTpWyGU3qv_iwEpgvCijoCuCYpOPpyzJCgOk46WpUKU,1066
1085
+ TDCRPy-1.12.12.dist-info/METADATA,sha256=69f5ox0Jet4v5ocTEhc7tcDml7F_QKW0LyU_yqZKt7o,15833
1086
+ TDCRPy-1.12.12.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
1087
+ TDCRPy-1.12.12.dist-info/top_level.txt,sha256=f4vzFFcKSEnonAACs0ZXuRczmroLLqtPTqXFymU_VU0,14
1088
+ TDCRPy-1.12.12.dist-info/RECORD,,
tdcrpy/TDCRPy.py CHANGED
@@ -81,7 +81,7 @@ def relaxAtom(daughter_relax,particle_vec,energy_vec,rad,Display=False,uncData=F
81
81
  relaxation = False
82
82
  return particle_vec, energy_vec
83
83
 
84
- def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=False, barp=False, Smodel=True, uncData=False):
84
+ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=False, barp=False, Smodel=True, syst = "TDCR", record = False, uncData=False):
85
85
  """
86
86
  This is the main function of the TDCRPy package running the Monte-Carlo Triple-to-Double Coincidence Ratio model.
87
87
  The computation is made for a given solution containing a radionuclide (or a mixture of radionuclides), a given volume of scintillator V and a given Birks constant kB.
@@ -140,6 +140,8 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
140
140
  "True" to display details on the decay sampling. The default is False.
141
141
  barp : Boolean, optional
142
142
  "True" to display the calculation progress. The default is True.
143
+ record : Boolean, optional
144
+ "True" to record details of decay events. The default is False.
143
145
  Smodel : Boolean, optional
144
146
  "True" to run the stochastic TDCR model. False to run the analytical caclulation (available only for pure beta emitters).
145
147
 
@@ -159,7 +161,55 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
159
161
  Estimation of the efficiency of triple coincidences. (only in mode="eff")
160
162
  std_efficiency_T : float
161
163
  Standard uncertainty from calculation associated with the estimation of the efficiency of triple coincidences. (only in mode="eff")
164
+ mean_efficiency_D2 : float
165
+ Estimation of the efficiency of double coincidences for C/N systems. (only in mode="eff")
166
+ std_efficiency_D2 : float
167
+ Standard uncertainty from calculation associated with the estimation of the efficiency of double coincidences for C/N systems. (only in mode="eff")
162
168
  """
169
+ if record:
170
+ recfile1 = "recordFiles/"+Rad+"_"+pmf_1+"_"+str(N)+".dhf1"
171
+ header_content1 = """# TDCRPy output: inital energies from nuclear decays
172
+ # Column 1: KPAR (1=electron, 2=photon, 3=positron, 4=alpha)
173
+ # Column 2: Energy in eV (> ECNUC)
174
+ # Column 3: Decay number mod 100, two digits
175
+ # Column 4: Cascade number mod 10, one digit
176
+ # Column 5: Particle age in seconds (since decay started)
177
+ # 2 3 4 5
178
+ """
179
+ with open(recfile1, "w") as file: file.write(header_content1)
180
+
181
+ recfile2 = "recordFiles/"+Rad+"_"+pmf_1+"_"+str(N)+".dhf2"
182
+ header_content2 = """# TDCRPy output: deposited energies from nuclear decays
183
+ # Column 1: KPAR (1=electron, 2=photon, 3=positron, 4=alpha)
184
+ # Column 2: Energy in eV (> ECNUC)
185
+ # Column 3: Decay number mod 100, two digits
186
+ # Column 4: Cascade number mod 10, one digit
187
+ # Column 5: Particle age in seconds (since decay started)
188
+ # 2 3 4 5
189
+ """
190
+ with open(recfile2, "w") as file: file.write(header_content2)
191
+
192
+ recfile3 = "recordFiles/"+Rad+"_"+pmf_1+"_"+str(N)+".dhf3"
193
+ header_content3 = """# TDCRPy output: deposited quenched energies from nuclear decays
194
+ # Column 1: KPAR (1=electron, 2=photon, 3=positron, 4=alpha)
195
+ # Column 2: Energy in eV (> ECNUC)
196
+ # Column 3: Decay number mod 100, two digits
197
+ # Column 4: Cascade number mod 10, one digit
198
+ # Column 5: Particle age in seconds (since decay started)
199
+ # 2 3 4 5
200
+ """
201
+ with open(recfile3, "w") as file: file.write(header_content3)
202
+
203
+ header_content4 = """# TDCRPy output: detection probabilities
204
+ # Column 1: Decay number mod 100, two digits
205
+ # Column 2: detection probability of single events
206
+ # Column 3: detection probability if double coincidences
207
+ # Column 4: detection probability if triple coincidences
208
+ # 2 3 4
209
+ """
210
+ recfile4 = "recordFiles/"+Rad+"_"+pmf_1+"_"+str(N)+".dhf4"
211
+ with open(recfile4, "w") as file: file.write(header_content4)
212
+
163
213
  if barp: tl.display_header()
164
214
  config = configparser.ConfigParser()
165
215
  with importlib.resources.as_file(files('tdcrpy').joinpath('config.toml')) as data_path:
@@ -243,8 +293,11 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
243
293
  trans_halfLife.append(out_PenNuc[15])
244
294
  # print("\n",trans_halfLife)
245
295
 
296
+ efficiency_A2 = []
297
+ efficiency_B2 = []
246
298
  efficiency_S = []
247
299
  efficiency_D = []
300
+ efficiency_D2 = []
248
301
  efficiency_T = []
249
302
  efficiency_AB = []
250
303
  efficiency_BC = []
@@ -253,7 +306,7 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
253
306
 
254
307
  if barp and not Display: NN = tqdm(range(N), desc="Processing", unit=" decays")
255
308
  else: NN = range(N)
256
- for i in NN: # Main Loop - Monte Carlo trials
309
+ for idec in NN: # Main Loop - Monte Carlo trials
257
310
  particle_vec=[]
258
311
  energy_vec=[]
259
312
  '''
@@ -263,7 +316,7 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
263
316
  '''
264
317
  index_rad = tl.sampling(pmf_1)
265
318
  rad_i = Rad[index_rad]
266
- if Display: print("\n\n Trial ",str(i+1),"- Sampled radionuclide: ", rad_i)
319
+ if Display: print("\n\n Trial ",str(idec+1),"- Sampled radionuclide: ", rad_i)
267
320
 
268
321
 
269
322
  '''
@@ -505,12 +558,12 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
505
558
 
506
559
  if Display:
507
560
  print("\n\t ATOMIC RECOMBINATION--Prompt")
508
- for i, p in enumerate(particle_vec):
561
+ for idisp, p in enumerate(particle_vec):
509
562
  if p[:4] != "Atom":
510
563
  if p=="beta" or p=="beta+":
511
- print(f'\t\t {p} transition of energy = {energy_vec[i]}, keV')
564
+ print(f'\t\t {p} transition of energy = {energy_vec[idisp]}, keV')
512
565
  else:
513
- print(f"\t\t emitted {p} of energy = {round(energy_vec[i],3)} keV")
566
+ print(f"\t\t emitted {p} of energy = {round(energy_vec[idisp],3)} keV")
514
567
  else:
515
568
  print(f'\t\t an electron left the {p[5:]} shell')
516
569
 
@@ -524,12 +577,12 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
524
577
 
525
578
  if Display:
526
579
  print("\n\t ATOMIC RECOMBINATION--Delay")
527
- for i, p in enumerate(particle_vec2):
580
+ for idisp, p in enumerate(particle_vec2):
528
581
  if p[:4] != "Atom":
529
582
  if p=="beta" or p=="beta+":
530
- print(f'\t\t {p} transition of energy = {energy_vec2[i]}, keV')
583
+ print(f'\t\t {p} transition of energy = {energy_vec2[idisp]}, keV')
531
584
  else:
532
- print(f"\t\t emitted {p} of energy = {round(energy_vec2[i],3)} keV")
585
+ print(f"\t\t emitted {p} of energy = {round(energy_vec2[idisp],3)} keV")
533
586
  else:
534
587
  print(f'\t\t an electron left the {p[5:]} shell')
535
588
 
@@ -540,155 +593,293 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
540
593
  '''
541
594
  if ("beta" in particle_vec) or ("beta+" in particle_vec):
542
595
  if Display: print("\n\t EMISSION OF BETA PARTICLES")
543
- for i, p in enumerate(particle_vec):
596
+ for ipart, p in enumerate(particle_vec):
544
597
  if p == "beta":
545
598
  e_b,p_b = tl.readBetaShape(rad_i,"beta-",level_before_trans) # read the data of BetaShape
546
599
  index_beta_energy = tl.sampling(p_b) # sampling in PDF
547
- particle_vec[i] = "electron"
548
- energy_vec[i] = e_b[index_beta_energy]
549
- if Display: print(f"\t\t emitted {p} of energy = {round(energy_vec[i],3)} keV")
600
+ particle_vec[ipart] = "electron"
601
+ energy_vec[ipart] = e_b[index_beta_energy]
602
+ if Display: print(f"\t\t emitted {p} of energy = {round(energy_vec[ipart],3)} keV")
550
603
 
551
604
  if p == "beta+":
552
605
  e_b,p_b = tl.readBetaShape(rad_i,"beta+",level_before_trans)
553
606
  index_beta_energy = tl.sampling(p_b) # sampling in PDF
554
- particle_vec[i] = "positron"
555
- energy_vec[i] = e_b[index_beta_energy]
607
+ particle_vec[ipart] = "positron"
608
+ energy_vec[ipart] = e_b[index_beta_energy]
556
609
  particle_vec.append("gamma")
557
610
  particle_vec.append("gamma")
558
611
  energy_vec.append(511)
559
612
  energy_vec.append(511)
560
- if Display: print(f"\t\t emitted {p} of energy = {round(energy_vec[i],3)} keV")
613
+ if Display: print(f"\t\t emitted {p} of energy = {round(energy_vec[ipart],3)} keV")
561
614
  #energy_vec_initial = energy_vec
562
615
  energy_vec_initial = energy_vec.copy()
616
+
617
+
618
+
619
+ """
620
+ ==========================================================
621
+ III.a.1 record initial energies in file
622
+ ==========================================================
623
+ """
624
+ if record:
625
+ with open(recfile1, "a") as file:
626
+ # t1w=0
627
+ for irec, p in enumerate(particle_vec):
628
+ writeOn = True
629
+
630
+ if p == "electron" or ("Auger" in p): col1 = "1"
631
+ elif p == "gamma" or ("X" in p): col1 = "2"
632
+ elif p == "beta+": col1 = "3"
633
+ elif p == "alpha": col1 = "4"
634
+ else: writeOn = False
635
+
636
+ # if ('t1' in globals()) or ('t1' in locals()): t1w+=t1
637
+
638
+ if writeOn:
639
+ if idec<10:
640
+ file.write(f"{col1} {energy_vec[irec]*1e3:.6E} {idec} 1 0\n")
641
+ else:
642
+ file.write(f"{col1} {energy_vec[irec]*1e3:.6E} {idec} 1 0\n")
643
+
644
+ if evenement != 1:
645
+ for irec, p in enumerate(particle_vec2):
646
+ writeOn = True
647
+
648
+ if p == "electron" or ("Auger" in p): col1 = "1"
649
+ elif p == "gamma" or ("X" in p): col1 = "2"
650
+ elif p == "beta+": col1 = "3"
651
+ elif p == "alpha": col1 = "4"
652
+ else: writeOn = False
653
+
654
+ # if ('t1' in globals()) or ('t1' in locals()): t1w+=t1
655
+
656
+ if writeOn:
657
+ if idec<10:
658
+ file.write(f"{col1} {energy_vec2[irec]*1e3:.6E} {idec} 1 {t1:.6E}\n")
659
+ else:
660
+ file.write(f"{col1} {energy_vec2[irec]*1e3:.6E} {idec} 1 {t1:.6E}\n")
661
+
662
+
663
+
563
664
  '''
564
665
  ==========================================================
565
666
  III.b INTERACTION RAYONNEMENT/MATIERE
566
667
  ==========================================================
567
668
  '''
568
669
 
569
- for i, p in enumerate(particle_vec):
670
+ for ipart, p in enumerate(particle_vec):
570
671
  if p == "electron":
571
- energy_vec[i] = tl.energie_dep_beta2(energy_vec[i],v=V)
672
+ energy_vec[ipart] = tl.energie_dep_beta2(energy_vec[ipart],v=V)
572
673
 
573
674
  if p == "beta+":
574
- energy_vec[i] = tl.energie_dep_beta2(energy_vec[i],v=V)
675
+ energy_vec[ipart] = tl.energie_dep_beta2(energy_vec[ipart],v=V)
575
676
 
576
677
  if p == "gamma" or p == "XKA" or p == "XKB" or p == "XL":
577
- p0 = particle_vec[i]
578
- Ei = energy_vec[i]
678
+ p0 = particle_vec[ipart]
679
+ Ei = energy_vec[ipart]
579
680
  Ed = tl.energie_dep_gamma2(Ei,v=V) # sampling energy free from photon
580
681
  if Ei == Ed: # effet photoelectrique
581
682
  energie_ele_emis,lacune_ph,element_ph = tl.interaction_scintillation(Ed)
582
683
  particule_emise_ph,energie_par_emise_ph,posi_lacune_ph,par_emise_ph = tl.relaxation_atom_ph(lacune_ph,element_ph,v=V)
583
684
  particle_vec = particle_vec + par_emise_ph
584
- energy_vec_initial[i]=energie_ele_emis
585
- energy_vec[i]=energie_ele_emis # energie du photoélectron primaire
685
+ energy_vec_initial[ipart]=energie_ele_emis
686
+ energy_vec[ipart]=energie_ele_emis # energie du photoélectron primaire
586
687
  energy_vec_initial = energy_vec_initial + energie_par_emise_ph
587
688
  energy_vec = energy_vec + energie_par_emise_ph
588
689
  elif Ed == Ei - 1022: # creation de paire
589
690
  #particle_vec[i] = 'electron'
590
691
  E_e = (Ei-1022)/2
591
- energy_vec[i] = E_e#tl.energie_dep_beta2(E_e,v=V)
692
+ energy_vec[ipart] = E_e#tl.energie_dep_beta2(E_e,v=V)
592
693
  particle_vec.append("positron")
593
694
  energy_vec.append(E_e)#tl.energie_dep_beta2(E_e,v=V))
594
695
  else: # diffusion Compton
595
- energy_vec[i]=Ed
596
- particle_vec[i] = "electron"
696
+ energy_vec[ipart]=Ed
697
+ particle_vec[ipart] = "electron"
597
698
 
598
699
  if "Auger" in p:
599
- particle_vec[i] = "electron"
600
- energy_vec[i] = tl.energie_dep_beta2(energy_vec[i],v=V)
700
+ particle_vec[ipart] = "electron"
701
+ energy_vec[ipart] = tl.energie_dep_beta2(energy_vec[ipart],v=V)
601
702
 
602
703
  if Display:
603
704
  print("\n\t INTERACTION--Prompt \n\t Summary of the energy deposited by charged particles")
604
- for i, p in enumerate(particle_vec):
605
- if p[:4] != "Atom" and energy_vec[i]!=0:
606
- if p == "gamma" or p == "XKA" or p == "XKB" or p == "XL": (f"\t\t the {p0} gives {energy_vec[i]} keV to a recoil electron")
607
- else: print(f"\t\t {p} of energy = {round(energy_vec[i],3)} keV")
705
+ for ipart, p in enumerate(particle_vec):
706
+ if p[:4] != "Atom" and energy_vec[ipart]!=0:
707
+ if p == "gamma" or p == "XKA" or p == "XKB" or p == "XL": (f"\t\t the {p0} gives {energy_vec[ipart]} keV to a recoil electron")
708
+ else: print(f"\t\t {p} of energy = {round(energy_vec[ipart],3)} keV")
608
709
 
609
710
 
610
711
  if evenement!=1:
611
712
  energy_vec_initial2 = energy_vec2.copy()
612
- for i, p in enumerate(particle_vec2):
713
+ for ipart, p in enumerate(particle_vec2):
613
714
  if p == "electron":
614
- energy_vec2[i] = tl.energie_dep_beta2(energy_vec2[i],v=V)
715
+ energy_vec2[ipart] = tl.energie_dep_beta2(energy_vec2[ipart],v=V)
615
716
 
616
717
  if p == "gamma" or p == "XKA" or p == "XKB" or p == "XL":
617
- p0 = particle_vec2[i]
618
- Ei_2 = energy_vec2[i]
718
+ p0 = particle_vec2[ipart]
719
+ Ei_2 = energy_vec2[ipart]
619
720
  Ed_2 = tl.energie_dep_gamma2(Ei_2,v=V) # sampling energy free from photon
620
721
  if Ei_2 == Ed_2: # effet photon-electrique
621
722
  energie_ele_emis2,lacune_ph2,element_ph2 = tl.interaction_scintillation(Ed_2)
622
723
  particule_emise_ph2,energie_par_emise_ph2,posi_lacune_ph2,par_emise_ph2 = tl.relaxation_atom_ph(lacune_ph2,element_ph2,v=V)
623
- energy_vec2[i]=energie_ele_emis2
624
- energy_vec_initial2[i]=energie_ele_emis2
724
+ energy_vec2[ipart]=energie_ele_emis2
725
+ energy_vec_initial2[ipart]=energie_ele_emis2
625
726
  energy_vec2 = energy_vec2 + energie_par_emise_ph2
626
727
  energy_vec_initial2 = energy_vec_initial2 + energie_par_emise_ph2
627
728
  particle_vec2 = particle_vec2 + par_emise_ph2
628
729
  elif Ed_2 == Ei_2 - 1022: # creation de paire
629
- #particle_vec2[i] = 'electron'
730
+ #particle_vec2[ipart] = 'electron'
630
731
  E_e = (Ei_2-1022)/2
631
- energy_vec2[i] = E_e#tl.energie_dep_beta2(E_e,v=V)
732
+ energy_vec2[ipart] = E_e#tl.energie_dep_beta2(E_e,v=V)
632
733
  particle_vec2.append("positron")
633
734
  energy_vec2.append(E_e)#tl.energie_dep_beta2(E_e,v=V))
634
735
  else: # diffusion Compton
635
- energy_vec2[i]=Ed_2
636
- particle_vec2[i] = "electron"
736
+ energy_vec2[ipart]=Ed_2
737
+ particle_vec2[ipart] = "electron"
637
738
  if Display:
638
- print(f"\t\t {p0} give energy {energy_vec2[i]} keV to electron")
739
+ print(f"\t\t {p0} give energy {energy_vec2[ipart]} keV to electron")
639
740
 
640
741
 
641
742
  if "Auger" in p:
642
- particle_vec2[i] = "electron"
643
- energy_vec2[i] = tl.energie_dep_beta2(energy_vec2[i],v=V)
743
+ particle_vec2[ipart] = "electron"
744
+ energy_vec2[ipart] = tl.energie_dep_beta2(energy_vec2[ipart],v=V)
644
745
 
645
746
  if Display:
646
747
  print("\n\t INTERACTION--Delay \n\t Summary of the energy deposited by charged particles")
647
- for i, p in enumerate(particle_vec2):
648
- if p[:4] != "Atom" and energy_vec2[i]!=0:
649
- if p == "gamma" or p == "XKA" or p == "XKB" or p == "XL": (f"\t\t the {p0} gives {energy_vec2[i]} keV to a recoil electron")
650
- else: print(f"\t\t {p} of energy = {round(energy_vec2[i],3)} keV")
748
+ for ipart, p in enumerate(particle_vec2):
749
+ if p[:4] != "Atom" and energy_vec2[ipart]!=0:
750
+ if p == "gamma" or p == "XKA" or p == "XKB" or p == "XL": (f"\t\t the {p0} gives {energy_vec2[ipart]} keV to a recoil electron")
751
+ else: print(f"\t\t {p} of energy = {round(energy_vec2[ipart],3)} keV")
651
752
 
652
- '''
653
- ====================
654
- IV. LA SCINTILLATION
655
- Calculation of the scintillation quenching with the Birks Model
656
- ====================
657
- '''
753
+ """
754
+ ==========================================================
755
+ III.b.1 record deposited energies in file
756
+ ==========================================================
757
+ """
758
+ if record:
759
+ with open(recfile2, "a") as file:
760
+ # t1w=0
761
+ for irec, p in enumerate(particle_vec):
762
+ writeOn = True
763
+
764
+ if p == "electron" or ("Auger" in p): col1 = "1"
765
+ elif p == "gamma" or ("X" in p): col1 = "2"
766
+ elif p == "beta+": col1 = "3"
767
+ elif p == "alpha": col1 = "4"
768
+ else: writeOn = False
769
+
770
+ # if ('t1' in globals()) or ('t1' in locals()): t1w+=t1
771
+
772
+ if writeOn:
773
+ if idec<10:
774
+ file.write(f"{col1} {energy_vec[irec]*1e3:.6E} {idec} 1 0\n")
775
+ else:
776
+ file.write(f"{col1} {energy_vec[irec]*1e3:.6E} {idec} 1 0\n")
777
+
778
+ if evenement != 1:
779
+ for irec, p in enumerate(particle_vec2):
780
+ writeOn = True
781
+
782
+ if p == "electron" or ("Auger" in p): col1 = "1"
783
+ elif p == "gamma" or ("X" in p): col1 = "2"
784
+ elif p == "beta+": col1 = "3"
785
+ elif p == "alpha": col1 = "4"
786
+ else: writeOn = False
787
+
788
+ # if ('t1' in globals()) or ('t1' in locals()): t1w+=t1
789
+
790
+ if writeOn:
791
+ if idec<10:
792
+ file.write(f"{col1} {energy_vec2[irec]*1e3:.6E} {idec} 1 {t1:.6E}\n")
793
+ else:
794
+ file.write(f"{col1} {energy_vec2[irec]*1e3:.6E} {idec} 1 {t1:.6E}\n")
795
+
796
+
797
+ '''
798
+ ====================
799
+ IV. LA SCINTILLATION
800
+ Calculation of the scintillation quenching with the Birks Model
801
+ ====================
802
+ '''
658
803
  if Display: print(f"\n\t SCINTILLATION--Prompt \n\t\t Birks constant = {kB} cm/keV\n\t Summary of the estimation of quenched energies")
659
804
  e_quenching=[]
660
- for i, p in enumerate(particle_vec):
805
+ for ipart, p in enumerate(particle_vec):
661
806
  if p == "alpha":
662
- energy_vec[i] = tl.Em_a(energy_vec[i],kB,nE_alpha)
663
- e_quenching.append(energy_vec[i])
807
+ energy_vec[ipart] = tl.Em_a(energy_vec[ipart],kB,nE_alpha)
808
+ e_quenching.append(energy_vec[ipart])
664
809
  elif p == "electron" or p == "positron":
665
- energy_vec[i] = tl.Em_e(energy_vec_initial[i]*1e3,energy_vec[i]*1e3,kB*1e3,nE_electron)*1e-3
666
- if micCorr: energy_vec[i] = energy_vec[i]*tl.micelleLoss(energy_vec_initial[i])
667
- e_quenching.append(energy_vec[i])
810
+ energy_vec[ipart] = tl.Em_e(energy_vec_initial[ipart]*1e3,energy_vec[ipart]*1e3,kB*1e3,nE_electron)*1e-3
811
+ if micCorr: energy_vec[ipart] = energy_vec[ipart]*tl.micelleLoss(energy_vec_initial[ipart])
812
+ e_quenching.append(energy_vec[ipart])
668
813
  else:
669
814
  e_quenching.append(0)
670
815
  if Display: print("\t\t Birks constant = ", kB, ' cm/keV')
671
816
  if Display:
672
- for i, p in enumerate(particle_vec):
817
+ for ipart, p in enumerate(particle_vec):
673
818
  #print(e_quenching[i])
674
- if p[:4] != "Atom": print(f"\t\t quenched energy of {p} = ", np.round(e_quenching[i],3), "keV")
819
+ if p[:4] != "Atom": print(f"\t\t quenched energy of {p} = ", np.round(e_quenching[ipart],3), "keV")
675
820
 
676
821
  if evenement!=1:
677
822
  if Display: print(f"\n\t SCINTILLATION--Delayed \n\t\t Birks constant = {kB} cm/keV\n\t Summary of the estimation of quenched energies")
678
823
  e_quenching2=[]
679
- for i, p in enumerate(particle_vec2):
824
+ for ipart, p in enumerate(particle_vec2):
680
825
  if p == "alpha":
681
- energy_vec2[i] = tl.Em_a(energy_vec2[i],kB,nE_alpha)
682
- e_quenching2.append(energy_vec2[i])
826
+ energy_vec2[ipart] = tl.Em_a(energy_vec2[ipart],kB,nE_alpha)
827
+ e_quenching2.append(energy_vec2[ipart])
683
828
  elif p == "electron" or p == "positron":
684
- energy_vec2[i] = tl.Em_e(energy_vec_initial2[i]*1e3,energy_vec2[i]*1e3,kB*1e3,nE_electron)*1e-3
685
- if micCorr: energy_vec2[i] = energy_vec2[i]*tl.micelleLoss(energy_vec_initial2[i])
686
- e_quenching2.append(energy_vec2[i])
829
+ energy_vec2[ipart] = tl.Em_e(energy_vec_initial2[ipart]*1e3,energy_vec2[ipart]*1e3,kB*1e3,nE_electron)*1e-3
830
+ if micCorr: energy_vec2[ipart] = energy_vec2[ipart]*tl.micelleLoss(energy_vec_initial2[ipart])
831
+ e_quenching2.append(energy_vec2[ipart])
687
832
  else:
688
833
  e_quenching2.append(0)
689
834
  if Display:
690
- for i, p in enumerate(particle_vec2):
691
- if p[:4] != "Atom": print(f"\t\t quenched energy of {p} = ", round(e_quenching2[i],3), "keV")
835
+ for ipart, p in enumerate(particle_vec2):
836
+ if p[:4] != "Atom": print(f"\t\t quenched energy of {p} = ", round(e_quenching2[ipart],3), "keV")
837
+
838
+
839
+ """
840
+ ==========================================================
841
+ IV.1 record deposited quenched energies in file
842
+ ==========================================================
843
+ """
844
+ if record:
845
+ with open(recfile3, "a") as file:
846
+ # t1w=0
847
+ for irec, p in enumerate(particle_vec):
848
+ writeOn = True
849
+
850
+ if p == "electron" or ("Auger" in p): col1 = "1"
851
+ elif p == "gamma" or ("X" in p): col1 = "2"
852
+ elif p == "beta+": col1 = "3"
853
+ elif p == "alpha": col1 = "4"
854
+ else: writeOn = False
855
+
856
+ # if ('t1' in globals()) or ('t1' in locals()): t1w+=t1
857
+
858
+ if writeOn:
859
+ if idec<10:
860
+ file.write(f"{col1} {e_quenching[irec]*1e3:.6E} {idec} 1 0\n")
861
+ else:
862
+ file.write(f"{col1} {e_quenching[irec]*1e3:.6E} {idec} 1 0\n")
863
+
864
+ if evenement != 1:
865
+ for irec, p in enumerate(particle_vec2):
866
+ writeOn = True
867
+
868
+ if p == "electron" or ("Auger" in p): col1 = "1"
869
+ elif p == "gamma" or ("X" in p): col1 = "2"
870
+ elif p == "beta+": col1 = "3"
871
+ elif p == "alpha": col1 = "4"
872
+ else: writeOn = False
873
+
874
+ # if ('t1' in globals()) or ('t1' in locals()): t1w+=t1
875
+
876
+ if writeOn:
877
+ if idec<10:
878
+ file.write(f"{col1} {e_quenching2[irec]*1e3:.6E} {idec} 1 {t1:.6E}\n")
879
+ else:
880
+ file.write(f"{col1} {e_quenching2[irec]*1e3:.6E} {idec} 1 {t1:.6E}\n")
881
+
882
+
692
883
 
693
884
  '''
694
885
  ====================
@@ -704,6 +895,7 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
704
895
  efficiency_S.append(1-p_nosingle**3+1-p_nosingle2**3)
705
896
  efficiency_T.append(p_single**3+p_single2**3)
706
897
  efficiency_D.append(3*(p_single)**2-2*p_single**3+(3*(p_single2)**2-2*p_single2**3))
898
+ efficiency_D2.append(p_single**2+p_single2**2)
707
899
  if Display: print(f"\n\t COUNTING--Sym \n\t\t Free parameter = {L} keV-1 \n\t Summary of TDCR measurement (prompt)")
708
900
  if Display: print("\t\t Free parameter = ", L, "keV-1")
709
901
  if Display: print("\t\t Efficiency of single events = ", round(1-p_nosingle**3,5))
@@ -723,6 +915,7 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
723
915
  efficiency_S.append(1-p_nosingle**3)
724
916
  efficiency_T.append(p_single**3)
725
917
  efficiency_D.append(3*(p_single)**2-2*efficiency_T[-1])
918
+ efficiency_D2.append(p_single**2)
726
919
  if Display: print(f"\n\t COUNTING--Sym \n\t\t Free parameter = {L} keV-1 \n\t Summary of TDCR measurement (prompt)")
727
920
  if Display: print("\t\t Efficiency of single events = ", round(efficiency_S[-1],5))
728
921
  if Display: print("\t\t Efficiency of double events = ", round(efficiency_D[-1],5))
@@ -744,6 +937,8 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
744
937
  pC_nosingle2 = np.exp(-L[2]*np.sum(np.asarray(e_quenching2))/3) # probability to have 0 electrons in a PMT
745
938
  pC_single2 = 1-pC_nosingle2 # probability to have at least 1 electrons in a PMT
746
939
 
940
+ efficiency_A2.append(pA_single+pA_single2)
941
+ efficiency_B2.append(pB_single+pB_single2)
747
942
  efficiency_AB.append(pA_single*pB_single+pA_single2*pB_single2)
748
943
  efficiency_BC.append(pB_single*pC_single+pB_single2*pC_single2)
749
944
  efficiency_AC.append(pA_single*pC_single+pA_single2*pC_single2)
@@ -751,6 +946,9 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
751
946
  efficiency_D.append(pA_single*pB_single+pB_single*pC_single+pA_single*pC_single-2*pA_single*pB_single*pC_single+(pA_single2*pB_single2+pB_single2*pC_single2+pA_single2*pC_single2-2*pA_single2*pB_single2*pC_single2))
752
947
  #efficiency_S.append(pA_single+pB_single+pC_single-pA_single*pB_single+pB_single*pC_single+pA_single*pC_single-2*pA_single*pB_single*pC_single-pA_single*pB_single*pC_single+(pA_single2+pB_single2+pC_single2-pA_single2*pB_single2+pB_single2*pC_single2+pA_single2*pC_single2-2*pA_single2*pB_single2*pC_single2-pA_single2*pB_single2*pC_single2))
753
948
  efficiency_S.append(1-pA_nosingle*pB_nosingle*pC_nosingle+1-pA_nosingle2*pB_nosingle2*pC_nosingle2)
949
+ efficiency_D2.append(pA_single*pB_single+pA_single2*pB_single2)
950
+
951
+
754
952
 
755
953
  if Display: print(f"\n\t COUNTING--Asym \n\t\t Free parameters (A,B,C) = {L[0]},{L[1]},{L[2]} keV-1 \n\t Summary of TDCR measurement (prompt)")
756
954
  #if Display: print("\t Summary of TDCR measurement (prompt)")
@@ -769,12 +967,15 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
769
967
  pC_nosingle = np.exp(-L[2]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
770
968
  pC_single = 1-pC_nosingle # probability to have at least 1 electrons in a PMT
771
969
 
970
+ efficiency_A2.append(pA_single)
971
+ efficiency_B2.append(pB_single)
772
972
  efficiency_AB.append(pA_single*pB_single)
773
973
  efficiency_BC.append(pB_single*pC_single)
774
974
  efficiency_AC.append(pA_single*pC_single)
775
975
  efficiency_T.append(pA_single*pB_single*pC_single)
776
976
  efficiency_D.append(efficiency_AB[-1]+efficiency_BC[-1]+efficiency_AC[-1]-2*efficiency_T[-1])
777
977
  efficiency_S.append(1-pA_nosingle*pB_nosingle*pC_nosingle)
978
+ efficiency_D2.append(pA_single*pB_single)
778
979
  if Display: print(f"\n\t COUNTING--Asym \n\t\t Free parameters (A,B,C) = {L[0]},{L[1]},{L[2]} keV-1 \n\t Summary of TDCR measurement (prompt)")
779
980
  if Display: print("\t\t Free parameter PMT A: ", L[0], "keV-1")
780
981
  if Display: print("\t\t Free parameter PMT B: ", L[1], "keV-1")
@@ -783,7 +984,19 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
783
984
  if Display: print("\t\t Efficiency of double events: ", round(efficiency_D[-1],5))
784
985
  if Display: print("\t\t Efficiency of triple events: ", round(efficiency_T[-1],5))
785
986
 
786
-
987
+ """
988
+ ==========================================================
989
+ V.1 record detection probabilities in file
990
+ ==========================================================
991
+ """
992
+ if record:
993
+ with open(recfile4, "a") as file:
994
+ print(idec)
995
+ if mode2=="sym":
996
+ file.write(f"{idec} {efficiency_S[-1]} {efficiency_D[-1]} {efficiency_T[-1]}\n")
997
+ elif mode2=="asym":
998
+ file.write(f"{idec} {efficiency_S[-1]} {efficiency_D[-1]} {efficiency_T[-1]} {efficiency_AB[-1]} {efficiency_BC[-1]} {efficiency_AC[-1]}\n")
999
+
787
1000
  '''
788
1001
  ====================
789
1002
  VI. CALCULATION OF THE FINAL ESTIMATORS
@@ -795,6 +1008,9 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
795
1008
  mean_efficiency_D = np.mean(efficiency_D)
796
1009
  std_efficiency_D = np.std(efficiency_D)/np.sqrt(N)
797
1010
  std_efficiency_D = np.sqrt(std_efficiency_D**2+1e-8)
1011
+ mean_efficiency_D2 = np.mean(efficiency_D2)
1012
+ std_efficiency_D2 = np.std(efficiency_D2)/np.sqrt(N)
1013
+ std_efficiency_D2 = np.sqrt(std_efficiency_D2**2+1e-8)
798
1014
  mean_efficiency_S = np.mean(efficiency_S)
799
1015
  std_efficiency_S = np.std(efficiency_S)/np.sqrt(N)
800
1016
  std_efficiency_S = np.sqrt(std_efficiency_S**2+1e-8)
@@ -823,11 +1039,17 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
823
1039
  if mode == "eff":
824
1040
  if N<200:
825
1041
  print("Warning. too low number of MC trials - inaccurate estimation")
826
- return mean_efficiency_S, 1, mean_efficiency_D, 1, mean_efficiency_T, 1
1042
+ if syst == "TDCR":
1043
+ return mean_efficiency_S, 1, mean_efficiency_D, 1, mean_efficiency_T, 1
1044
+ elif syst =="CN":
1045
+ return mean_efficiency_D2, 1
827
1046
  else:
828
- return mean_efficiency_S, std_efficiency_S, mean_efficiency_D, std_efficiency_D, mean_efficiency_T, std_efficiency_T
1047
+ if syst == "TDCR":
1048
+ return mean_efficiency_S, std_efficiency_S, mean_efficiency_D, std_efficiency_D, mean_efficiency_T, std_efficiency_T
1049
+ elif syst =="CN":
1050
+ return mean_efficiency_D2, std_efficiency_D2
829
1051
  if mode =="dis":
830
- return efficiency_S, efficiency_D, efficiency_T
1052
+ return efficiency_S, efficiency_D, efficiency_T, efficiency_D2
831
1053
 
832
1054
  # L = 1
833
1055
  # TD = 0.977667386529166
@@ -846,20 +1068,22 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
846
1068
 
847
1069
  # print(out)
848
1070
 
849
- # L = 1
850
- # TD = 0.977667386529166
851
- # TAB = 0.992232838598821
852
- # TBC = 0.992343419459002
853
- # TAC = 0.99275350064608
854
- # Rad="Fe-55"
855
- # pmf_1="1"
856
- # N = 1000
857
- # kB =1.0e-5
858
- # V = 10
859
- # mode = "eff"
860
- # mode2 = "sym"
1071
+ L = 1
1072
+ TD = 0.977667386529166
1073
+ TAB = 0.992232838598821
1074
+ TBC = 0.992343419459002
1075
+ TAC = 0.99275350064608
1076
+ Rad="Lu-177"
1077
+ pmf_1="1"
1078
+ N = 1000
1079
+ kB =1.0e-5
1080
+ V = 10
1081
+ mode = "eff"
1082
+ mode2 = "sym"
861
1083
 
862
1084
  # out = TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=True, barp=False,uncData=False)
863
1085
  # print("TDCR", out[4]/out[2])
864
1086
  # print("Eff D", out[2])
865
1087
 
1088
+
1089
+ out = TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, 20, kB, V, mode, mode2, Display=True, barp=False, Smodel=True, syst = "TDCR", record = "phf1", uncData=False)