TDCRPy 1.12.14__py3-none-any.whl → 1.13.0__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.14
3
+ Version: 1.13.0
4
4
  Summary: TDCR model
5
5
  Home-page: https://pypi.org/project/TDCRPy/
6
6
  Author: RomainCoulon (Romain Coulon)
@@ -1,6 +1,6 @@
1
- tdcrpy/TDCRPy.py,sha256=6Lvttr2ULiLE25Zh4MUfsyKM9k0eZv0PhzGP_0Kmcnw,65388
1
+ tdcrpy/TDCRPy.py,sha256=i16smPjN2GhbMfhdnTYNXwnyM0rncCszxjK5XCASPh0,69480
2
2
  tdcrpy/TDCRPy1.py,sha256=QTBZh5B5JWnGB0BQfD-cFmwA9W080OD4sG-aj50-ejo,38106
3
- tdcrpy/TDCR_model_lib.py,sha256=WYR2-z187MLDOHR_wdOGdOkKKLYuP2f1VE-pTQ3wAzc,107934
3
+ tdcrpy/TDCR_model_lib.py,sha256=GLxnYEmB-U-kIsrSwwvawKsltbMyOZESiE_DdRodxjQ,119180
4
4
  tdcrpy/TDCRoptimize.py,sha256=c2XIGveeLdVYYek4Rg6dygMvVA2xIrIkMb3L-_jUucM,6496
5
5
  tdcrpy/__init__.py,sha256=vQslGLsoZPIceaitnSHOqN6lUdjEyJ3YhfJ6tYdXt-s,127
6
6
  tdcrpy/config.toml,sha256=d_olKEgxfobBHkZ2wEj9EgKE7I8Wbpim9ZAsi5ImFxk,1470
@@ -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.14.dist-info/LICENCE.md,sha256=ZTpWyGU3qv_iwEpgvCijoCuCYpOPpyzJCgOk46WpUKU,1066
1085
- TDCRPy-1.12.14.dist-info/METADATA,sha256=zMqiloAvp2aN0UeMAUoG3VXP71N7ZhaCLIZJnOhlFBQ,15833
1086
- TDCRPy-1.12.14.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
1087
- TDCRPy-1.12.14.dist-info/top_level.txt,sha256=f4vzFFcKSEnonAACs0ZXuRczmroLLqtPTqXFymU_VU0,14
1088
- TDCRPy-1.12.14.dist-info/RECORD,,
1084
+ TDCRPy-1.13.0.dist-info/LICENCE.md,sha256=ZTpWyGU3qv_iwEpgvCijoCuCYpOPpyzJCgOk46WpUKU,1066
1085
+ TDCRPy-1.13.0.dist-info/METADATA,sha256=369qvRM9JVEZlkH7YAB5j-DzZG8rmVnUVBQCp7QfVzY,15832
1086
+ TDCRPy-1.13.0.dist-info/WHEEL,sha256=HiCZjzuy6Dw0hdX5R3LCFPDmFS4BWl8H-8W39XfmgX4,91
1087
+ TDCRPy-1.13.0.dist-info/top_level.txt,sha256=f4vzFFcKSEnonAACs0ZXuRczmroLLqtPTqXFymU_VU0,14
1088
+ TDCRPy-1.13.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (72.1.0)
2
+ Generator: setuptools (72.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
tdcrpy/TDCRPy.py CHANGED
@@ -83,7 +83,7 @@ def relaxAtom(daughter_relax,particle_vec,energy_vec,rad,Display=False,uncData=F
83
83
  relaxation = False
84
84
  return particle_vec, energy_vec
85
85
 
86
- 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):
86
+ 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, readRecHist = False, uncData=False):
87
87
  """
88
88
  This is the main function of the TDCRPy package running the Monte-Carlo Triple-to-Double Coincidence Ratio model.
89
89
  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.
@@ -241,7 +241,85 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
241
241
  return out
242
242
  if mode == "eff":
243
243
  return out[0], 0, out[1], 0, out[2], 0
244
+
245
+ elif readRecHist:
246
+ efficiency_A2 = []
247
+ efficiency_B2 = []
248
+ efficiency_S = []
249
+ efficiency_D = []
250
+ efficiency_D2 = []
251
+ efficiency_T = []
252
+ efficiency_AB = []
253
+ efficiency_BC = []
254
+ efficiency_AC = []
255
+
256
+ temp_dir = tempfile.gettempdir()
257
+ recfile3 = os.path.join(temp_dir, "Temp_E2.txt")
258
+
259
+ with open(recfile3, "r") as file:
260
+
261
+ decaym = -1
262
+ e_quenching = []; e_quenching2 = []; evenement=1; t1=0
263
+ for line in file:
264
+ if line[0] != "#":
265
+ line = line.split(' ')
266
+ line = [element for element in line if element != ""]
267
+ decay = int(line[2])
268
+
269
+ if decay != decaym:
270
+ if decay>0:
271
+ # print(decay-1,e_quenching,e_quenching2, evenement)
272
+ efficiency0_S, efficiency0_D, efficiency0_T, efficiency0_D2 = tl.detectProbabilities(L, e_quenching, e_quenching2, t1, evenement, mode2, extDT, measTime)
273
+ efficiency_S.append(efficiency0_S)
274
+ efficiency_T.append(efficiency0_T)
275
+ efficiency_D.append(efficiency0_D)
276
+ efficiency_D2.append(efficiency0_D2)
277
+
278
+ # print(efficiency0_D, "\n")
279
+
280
+ energy = float(line[1])*1e-3
281
+ t1 = float(line[4])
282
+ decaym = decay
283
+ # print(decay, energy, t1, extDT)
284
+ e_quenching = []; e_quenching2 = []
285
+ evenement=1
286
+ e_quenching.append(energy)
287
+ else:
288
+ energy = float(line[1])*1e-3
289
+ t1 = float(line[4])
290
+ # print(decay, energy, t1, extDT)
291
+ if t1 > tau*1e-9:
292
+ evenement = evenement + 1
293
+ e_quenching2.append(energy)
294
+ else:
295
+ e_quenching.append(energy)
296
+
297
+ efficiency0_S, efficiency0_D, efficiency0_T, efficiency0_D2 = tl.detectProbabilities(L, e_quenching, e_quenching2, t1, evenement, mode2, extDT, measTime)
298
+ efficiency_S.append(efficiency0_S)
299
+ efficiency_T.append(efficiency0_T)
300
+ efficiency_D.append(efficiency0_D)
301
+ efficiency_D2.append(efficiency0_D2)
302
+
303
+ # print(efficiency_D)
304
+ outEff = tl.efficienciesEstimates(efficiency_S, efficiency_D, efficiency_T, efficiency_D2, N)
305
+ return outEff
306
+
307
+
308
+ # temp1, temp2, temp3, temp4 = tl.read_temp_files()
309
+ # ee_vec = tl.energyVectors3(temp3)
310
+ # # to be continued
311
+
244
312
  else:
313
+ efficiency_A2 = []
314
+ efficiency_B2 = []
315
+ efficiency_S = []
316
+ efficiency_D = []
317
+ efficiency_D2 = []
318
+ efficiency_T = []
319
+ efficiency_AB = []
320
+ efficiency_BC = []
321
+ efficiency_AC = []
322
+
245
323
  nE_electron = config["Inputs"].getint("nE_electron")
246
324
  nE_alpha = config["Inputs"].getint("nE_alpha")
247
325
  Rad=Rad.replace(" ","")
@@ -295,18 +373,7 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
295
373
  u_prob_trans.append(out_PenNuc[16])
296
374
  trans_halfLife.append(out_PenNuc[15])
297
375
  # print("\n",trans_halfLife)
298
-
299
- efficiency_A2 = []
300
- efficiency_B2 = []
301
- efficiency_S = []
302
- efficiency_D = []
303
- efficiency_D2 = []
304
- efficiency_T = []
305
- efficiency_AB = []
306
- efficiency_BC = []
307
- efficiency_AC = []
308
-
309
-
376
+
310
377
  if barp and not Display: NN = tqdm(range(N), desc="Processing", unit=" decays")
311
378
  else: NN = range(N)
312
379
  for idec in NN: # Main Loop - Monte Carlo trials
@@ -888,104 +955,113 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
888
955
  ====================
889
956
  V. LE MESURE TDCR
890
957
  ====================
891
- '''
892
- if mode2=="sym":
893
- if evenement !=1 and t1 > extDT*1e-6 and t1 < measTime*60:
894
- p_nosingle = np.exp(-L*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
895
- p_single = 1-p_nosingle # probability to have at least 1 electrons in a PMT
896
- p_nosingle2 = np.exp(-L*np.sum(np.asarray(e_quenching2))/3) # probability to have 0 electrons in a PMT
897
- p_single2 = 1-p_nosingle2
898
- efficiency_S.append(1-p_nosingle**3+1-p_nosingle2**3)
899
- efficiency_T.append(p_single**3+p_single2**3)
900
- efficiency_D.append(3*(p_single)**2-2*p_single**3+(3*(p_single2)**2-2*p_single2**3))
901
- efficiency_D2.append(p_single**2+p_single2**2)
902
- if Display: print(f"\n\t COUNTING--Sym \n\t\t Free parameter = {L} keV-1 \n\t Summary of TDCR measurement (prompt)")
903
- if Display: print("\t\t Free parameter = ", L, "keV-1")
904
- if Display: print("\t\t Efficiency of single events = ", round(1-p_nosingle**3,5))
905
- if Display: print("\t\t Efficiency of double events = ", round(3*(p_single)**2-2*p_single**3,5))
906
- if Display: print("\t\t Efficiency of triple events = ", round(p_single**3,5))
907
- if Display: print("\t Summary of TDCR measurement (delayed)")
908
- if Display: print("\t\t Efficiency of single events = ", round(1-p_nosingle2**3,5))
909
- if Display: print("\t\t Efficiency of double events = ", round(3*(p_single2)**2-2*p_single2**3,5))
910
- if Display: print("\t\t Efficiency of triple events = ", round(p_single2**3,5))
911
- if Display: print("\t Summary of TDCR measurement (prompt + delayed)")
912
- if Display: print("\t\t Efficiency of single events = ", round(1-p_nosingle**3+1-p_nosingle2**3,5))
913
- if Display: print("\t\t Efficiency of double events = ", round(3*(p_single)**2-2*p_single**3+(3*(p_single2)**2-2*p_single2**3),5))
914
- if Display: print("\t\t Efficiency of triple events = ", round(p_single**3+p_single2**3,5))
915
- else:
916
- p_nosingle = np.exp(-L*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
917
- p_single = 1-p_nosingle # probability to have at least 1 electrons in a PMT
918
- efficiency_S.append(1-p_nosingle**3)
919
- efficiency_T.append(p_single**3)
920
- efficiency_D.append(3*(p_single)**2-2*efficiency_T[-1])
921
- efficiency_D2.append(p_single**2)
922
- if Display: print(f"\n\t COUNTING--Sym \n\t\t Free parameter = {L} keV-1 \n\t Summary of TDCR measurement (prompt)")
923
- if Display: print("\t\t Efficiency of single events = ", round(efficiency_S[-1],5))
924
- if Display: print("\t\t Efficiency of double events = ", round(efficiency_D[-1],5))
925
- if Display: print("\t\t Efficiency of triple events = ", round(efficiency_T[-1],5))
958
+ '''
959
+ if evenement == 1: e_quenching2 = 0; t1=0
960
+ efficiency0_S, efficiency0_D, efficiency0_T, efficiency0_D2 = tl.detectProbabilities(L, e_quenching, e_quenching2, t1, evenement, mode2, extDT, measTime)
961
+ efficiency_S.append(efficiency0_S)
962
+ efficiency_T.append(efficiency0_T)
963
+ efficiency_D.append(efficiency0_D)
964
+ efficiency_D2.append(efficiency0_D2)
965
+ # print(e_quenching,efficiency0_D)
966
+
967
+
968
+ # if mode2=="sym":
969
+ # if evenement !=1 and t1 > extDT*1e-6 and t1 < measTime*60:
970
+ # p_nosingle = np.exp(-L*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
971
+ # p_single = 1-p_nosingle # probability to have at least 1 electrons in a PMT
972
+ # p_nosingle2 = np.exp(-L*np.sum(np.asarray(e_quenching2))/3) # probability to have 0 electrons in a PMT
973
+ # p_single2 = 1-p_nosingle2
974
+ # efficiency_S.append(1-p_nosingle**3+1-p_nosingle2**3)
975
+ # efficiency_T.append(p_single**3+p_single2**3)
976
+ # efficiency_D.append(3*(p_single)**2-2*p_single**3+(3*(p_single2)**2-2*p_single2**3))
977
+ # efficiency_D2.append(p_single**2+p_single2**2)
978
+ # if Display: print(f"\n\t COUNTING--Sym \n\t\t Free parameter = {L} keV-1 \n\t Summary of TDCR measurement (prompt)")
979
+ # if Display: print("\t\t Free parameter = ", L, "keV-1")
980
+ # if Display: print("\t\t Efficiency of single events = ", round(1-p_nosingle**3,5))
981
+ # if Display: print("\t\t Efficiency of double events = ", round(3*(p_single)**2-2*p_single**3,5))
982
+ # if Display: print("\t\t Efficiency of triple events = ", round(p_single**3,5))
983
+ # if Display: print("\t Summary of TDCR measurement (delayed)")
984
+ # if Display: print("\t\t Efficiency of single events = ", round(1-p_nosingle2**3,5))
985
+ # if Display: print("\t\t Efficiency of double events = ", round(3*(p_single2)**2-2*p_single2**3,5))
986
+ # if Display: print("\t\t Efficiency of triple events = ", round(p_single2**3,5))
987
+ # if Display: print("\t Summary of TDCR measurement (prompt + delayed)")
988
+ # if Display: print("\t\t Efficiency of single events = ", round(1-p_nosingle**3+1-p_nosingle2**3,5))
989
+ # if Display: print("\t\t Efficiency of double events = ", round(3*(p_single)**2-2*p_single**3+(3*(p_single2)**2-2*p_single2**3),5))
990
+ # if Display: print("\t\t Efficiency of triple events = ", round(p_single**3+p_single2**3,5))
991
+ # else:
992
+ # p_nosingle = np.exp(-L*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
993
+ # p_single = 1-p_nosingle # probability to have at least 1 electrons in a PMT
994
+ # efficiency_S.append(1-p_nosingle**3)
995
+ # efficiency_T.append(p_single**3)
996
+ # efficiency_D.append(3*(p_single)**2-2*efficiency_T[-1])
997
+ # efficiency_D2.append(p_single**2)
998
+ # if Display: print(f"\n\t COUNTING--Sym \n\t\t Free parameter = {L} keV-1 \n\t Summary of TDCR measurement (prompt)")
999
+ # if Display: print("\t\t Efficiency of single events = ", round(efficiency_S[-1],5))
1000
+ # if Display: print("\t\t Efficiency of double events = ", round(efficiency_D[-1],5))
1001
+ # if Display: print("\t\t Efficiency of triple events = ", round(efficiency_T[-1],5))
926
1002
 
927
- elif mode2=="asym":
928
- if evenement !=1 and t1 > extDT*1e-6 and t1 < measTime*60:
929
- pA_nosingle = np.exp(-L[0]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
930
- pA_single = 1-pA_nosingle # probability to have at least 1 electrons in a PMT
931
- pB_nosingle = np.exp(-L[1]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
932
- pB_single = 1-pB_nosingle # probability to have at least 1 electrons in a PMT
933
- pC_nosingle = np.exp(-L[2]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
934
- pC_single = 1-pC_nosingle # probability to have at least 1 electrons in a PMT
1003
+ # elif mode2=="asym":
1004
+ # if evenement !=1 and t1 > extDT*1e-6 and t1 < measTime*60:
1005
+ # pA_nosingle = np.exp(-L[0]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
1006
+ # pA_single = 1-pA_nosingle # probability to have at least 1 electrons in a PMT
1007
+ # pB_nosingle = np.exp(-L[1]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
1008
+ # pB_single = 1-pB_nosingle # probability to have at least 1 electrons in a PMT
1009
+ # pC_nosingle = np.exp(-L[2]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
1010
+ # pC_single = 1-pC_nosingle # probability to have at least 1 electrons in a PMT
935
1011
 
936
- pA_nosingle2 = np.exp(-L[0]*np.sum(np.asarray(e_quenching2))/3) # probability to have 0 electrons in a PMT
937
- pA_single2 = 1-pA_nosingle2 # probability to have at least 1 electrons in a PMT
938
- pB_nosingle2 = np.exp(-L[1]*np.sum(np.asarray(e_quenching2))/3) # probability to have 0 electrons in a PMT
939
- pB_single2 = 1-pB_nosingle2 # probability to have at least 1 electrons in a PMT
940
- pC_nosingle2 = np.exp(-L[2]*np.sum(np.asarray(e_quenching2))/3) # probability to have 0 electrons in a PMT
941
- pC_single2 = 1-pC_nosingle2 # probability to have at least 1 electrons in a PMT
1012
+ # pA_nosingle2 = np.exp(-L[0]*np.sum(np.asarray(e_quenching2))/3) # probability to have 0 electrons in a PMT
1013
+ # pA_single2 = 1-pA_nosingle2 # probability to have at least 1 electrons in a PMT
1014
+ # pB_nosingle2 = np.exp(-L[1]*np.sum(np.asarray(e_quenching2))/3) # probability to have 0 electrons in a PMT
1015
+ # pB_single2 = 1-pB_nosingle2 # probability to have at least 1 electrons in a PMT
1016
+ # pC_nosingle2 = np.exp(-L[2]*np.sum(np.asarray(e_quenching2))/3) # probability to have 0 electrons in a PMT
1017
+ # pC_single2 = 1-pC_nosingle2 # probability to have at least 1 electrons in a PMT
942
1018
 
943
- efficiency_A2.append(pA_single+pA_single2)
944
- efficiency_B2.append(pB_single+pB_single2)
945
- efficiency_AB.append(pA_single*pB_single+pA_single2*pB_single2)
946
- efficiency_BC.append(pB_single*pC_single+pB_single2*pC_single2)
947
- efficiency_AC.append(pA_single*pC_single+pA_single2*pC_single2)
948
- efficiency_T.append(pA_single*pB_single*pC_single+pA_single2*pB_single2*pC_single2)
949
- 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))
950
- #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))
951
- efficiency_S.append(1-pA_nosingle*pB_nosingle*pC_nosingle+1-pA_nosingle2*pB_nosingle2*pC_nosingle2)
952
- efficiency_D2.append(pA_single*pB_single+pA_single2*pB_single2)
1019
+ # efficiency_A2.append(pA_single+pA_single2)
1020
+ # efficiency_B2.append(pB_single+pB_single2)
1021
+ # efficiency_AB.append(pA_single*pB_single+pA_single2*pB_single2)
1022
+ # efficiency_BC.append(pB_single*pC_single+pB_single2*pC_single2)
1023
+ # efficiency_AC.append(pA_single*pC_single+pA_single2*pC_single2)
1024
+ # efficiency_T.append(pA_single*pB_single*pC_single+pA_single2*pB_single2*pC_single2)
1025
+ # 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))
1026
+ # #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))
1027
+ # efficiency_S.append(1-pA_nosingle*pB_nosingle*pC_nosingle+1-pA_nosingle2*pB_nosingle2*pC_nosingle2)
1028
+ # efficiency_D2.append(pA_single*pB_single+pA_single2*pB_single2)
953
1029
 
954
1030
 
955
1031
 
956
- 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)")
957
- #if Display: print("\t Summary of TDCR measurement (prompt)")
958
- if Display: print("\t\t Efficiency of single events: ", round(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,5))
959
- if Display: print("\t\t Efficiency of double events: ", round(pA_single*pB_single+pB_single*pC_single+pA_single*pC_single-2*pA_single*pB_single*pC_single,5))
960
- if Display: print("\t\t Efficiency of triple events: ", round(pA_single*pB_single*pC_single,5))
961
- if Display: print("\t Summary of TDCR measurement (delayed)")
962
- if Display: print("\t\t Efficiency of single events: ", round(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,5))
963
- if Display: print("\t\t Efficiency of double events: ", round(pA_single2*pB_single2+pB_single2*pC_single2+pA_single2*pC_single2-2*pA_single2*pB_single2*pC_single2,5))
964
- if Display: print("\t\t Efficiency of triple events: ", round(efficiency_S[-1],5))
965
- else:
966
- pA_nosingle = np.exp(-L[0]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
967
- pA_single = 1-pA_nosingle # probability to have at least 1 electrons in a PMT
968
- pB_nosingle = np.exp(-L[1]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
969
- pB_single = 1-pB_nosingle # probability to have at least 1 electrons in a PMT
970
- pC_nosingle = np.exp(-L[2]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
971
- pC_single = 1-pC_nosingle # probability to have at least 1 electrons in a PMT
1032
+ # 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)")
1033
+ # #if Display: print("\t Summary of TDCR measurement (prompt)")
1034
+ # if Display: print("\t\t Efficiency of single events: ", round(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,5))
1035
+ # if Display: print("\t\t Efficiency of double events: ", round(pA_single*pB_single+pB_single*pC_single+pA_single*pC_single-2*pA_single*pB_single*pC_single,5))
1036
+ # if Display: print("\t\t Efficiency of triple events: ", round(pA_single*pB_single*pC_single,5))
1037
+ # if Display: print("\t Summary of TDCR measurement (delayed)")
1038
+ # if Display: print("\t\t Efficiency of single events: ", round(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,5))
1039
+ # if Display: print("\t\t Efficiency of double events: ", round(pA_single2*pB_single2+pB_single2*pC_single2+pA_single2*pC_single2-2*pA_single2*pB_single2*pC_single2,5))
1040
+ # if Display: print("\t\t Efficiency of triple events: ", round(efficiency_S[-1],5))
1041
+ # else:
1042
+ # pA_nosingle = np.exp(-L[0]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
1043
+ # pA_single = 1-pA_nosingle # probability to have at least 1 electrons in a PMT
1044
+ # pB_nosingle = np.exp(-L[1]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
1045
+ # pB_single = 1-pB_nosingle # probability to have at least 1 electrons in a PMT
1046
+ # pC_nosingle = np.exp(-L[2]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
1047
+ # pC_single = 1-pC_nosingle # probability to have at least 1 electrons in a PMT
972
1048
 
973
- efficiency_A2.append(pA_single)
974
- efficiency_B2.append(pB_single)
975
- efficiency_AB.append(pA_single*pB_single)
976
- efficiency_BC.append(pB_single*pC_single)
977
- efficiency_AC.append(pA_single*pC_single)
978
- efficiency_T.append(pA_single*pB_single*pC_single)
979
- efficiency_D.append(efficiency_AB[-1]+efficiency_BC[-1]+efficiency_AC[-1]-2*efficiency_T[-1])
980
- efficiency_S.append(1-pA_nosingle*pB_nosingle*pC_nosingle)
981
- efficiency_D2.append(pA_single*pB_single)
982
- 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)")
983
- if Display: print("\t\t Free parameter PMT A: ", L[0], "keV-1")
984
- if Display: print("\t\t Free parameter PMT B: ", L[1], "keV-1")
985
- if Display: print("\t\t Free parameter PMT C: ", L[2], "keV-1")
986
- if Display: print("\t\t Efficiency of single events: ", round(efficiency_S[-1],5))
987
- if Display: print("\t\t Efficiency of double events: ", round(efficiency_D[-1],5))
988
- if Display: print("\t\t Efficiency of triple events: ", round(efficiency_T[-1],5))
1049
+ # efficiency_A2.append(pA_single)
1050
+ # efficiency_B2.append(pB_single)
1051
+ # efficiency_AB.append(pA_single*pB_single)
1052
+ # efficiency_BC.append(pB_single*pC_single)
1053
+ # efficiency_AC.append(pA_single*pC_single)
1054
+ # efficiency_T.append(pA_single*pB_single*pC_single)
1055
+ # efficiency_D.append(efficiency_AB[-1]+efficiency_BC[-1]+efficiency_AC[-1]-2*efficiency_T[-1])
1056
+ # efficiency_S.append(1-pA_nosingle*pB_nosingle*pC_nosingle)
1057
+ # efficiency_D2.append(pA_single*pB_single)
1058
+ # 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)")
1059
+ # if Display: print("\t\t Free parameter PMT A: ", L[0], "keV-1")
1060
+ # if Display: print("\t\t Free parameter PMT B: ", L[1], "keV-1")
1061
+ # if Display: print("\t\t Free parameter PMT C: ", L[2], "keV-1")
1062
+ # if Display: print("\t\t Efficiency of single events: ", round(efficiency_S[-1],5))
1063
+ # if Display: print("\t\t Efficiency of double events: ", round(efficiency_D[-1],5))
1064
+ # if Display: print("\t\t Efficiency of triple events: ", round(efficiency_T[-1],5))
989
1065
 
990
1066
  """
991
1067
  ==========================================================
@@ -994,7 +1070,6 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
994
1070
  """
995
1071
  if record:
996
1072
  with open(recfile4, "a") as file:
997
- print(idec)
998
1073
  if mode2=="sym":
999
1074
  file.write(f"{idec} {efficiency_S[-1]} {efficiency_D[-1]} {efficiency_T[-1]}\n")
1000
1075
  elif mode2=="asym":
@@ -1005,18 +1080,20 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
1005
1080
  VI. CALCULATION OF THE FINAL ESTIMATORS
1006
1081
  ====================
1007
1082
  '''
1008
- mean_efficiency_T = np.mean(efficiency_T) # average
1009
- std_efficiency_T = np.std(efficiency_T)/np.sqrt(N) # standard deviation
1010
- std_efficiency_T = np.sqrt(std_efficiency_T**2+1e-8) # combined with uncertainty due to quenching calculation
1011
- mean_efficiency_D = np.mean(efficiency_D)
1012
- std_efficiency_D = np.std(efficiency_D)/np.sqrt(N)
1013
- std_efficiency_D = np.sqrt(std_efficiency_D**2+1e-8)
1014
- mean_efficiency_D2 = np.mean(efficiency_D2)
1015
- std_efficiency_D2 = np.std(efficiency_D2)/np.sqrt(N)
1016
- std_efficiency_D2 = np.sqrt(std_efficiency_D2**2+1e-8)
1017
- mean_efficiency_S = np.mean(efficiency_S)
1018
- std_efficiency_S = np.std(efficiency_S)/np.sqrt(N)
1019
- std_efficiency_S = np.sqrt(std_efficiency_S**2+1e-8)
1083
+ mean_efficiency_S, std_efficiency_S, mean_efficiency_D, std_efficiency_D, mean_efficiency_T, std_efficiency_T, mean_efficiency_D2, std_efficiency_D2 = tl.efficienciesEstimates(efficiency_S, efficiency_D, efficiency_T, efficiency_D2,N)
1084
+
1085
+ # mean_efficiency_T = np.mean(efficiency_T) # average
1086
+ # std_efficiency_T = np.std(efficiency_T)/np.sqrt(N) # standard deviation
1087
+ # std_efficiency_T = np.sqrt(std_efficiency_T**2+1e-8) # combined with uncertainty due to quenching calculation
1088
+ # mean_efficiency_D = np.mean(efficiency_D)
1089
+ # std_efficiency_D = np.std(efficiency_D)/np.sqrt(N)
1090
+ # std_efficiency_D = np.sqrt(std_efficiency_D**2+1e-8)
1091
+ # mean_efficiency_D2 = np.mean(efficiency_D2)
1092
+ # std_efficiency_D2 = np.std(efficiency_D2)/np.sqrt(N)
1093
+ # std_efficiency_D2 = np.sqrt(std_efficiency_D2**2+1e-8)
1094
+ # mean_efficiency_S = np.mean(efficiency_S)
1095
+ # std_efficiency_S = np.std(efficiency_S)/np.sqrt(N)
1096
+ # std_efficiency_S = np.sqrt(std_efficiency_S**2+1e-8)
1020
1097
 
1021
1098
  if mode2=="sym":
1022
1099
  TDCR_calcul = mean_efficiency_T/mean_efficiency_D
@@ -1040,17 +1117,14 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
1040
1117
  if mode == "res":
1041
1118
  return res
1042
1119
  if mode == "eff":
1043
- if N<200:
1044
- print("Warning. too low number of MC trials - inaccurate estimation")
1045
- if syst == "TDCR":
1046
- return mean_efficiency_S, 1, mean_efficiency_D, 1, mean_efficiency_T, 1
1047
- elif syst =="CN":
1048
- return mean_efficiency_D2, 1
1049
- else:
1050
- if syst == "TDCR":
1051
- return mean_efficiency_S, std_efficiency_S, mean_efficiency_D, std_efficiency_D, mean_efficiency_T, std_efficiency_T
1052
- elif syst =="CN":
1053
- return mean_efficiency_D2, std_efficiency_D2
1120
+ # if N<200:
1121
+ # print("Warning. too low number of MC trials - inaccurate estimation")
1122
+ # if syst == "TDCR":
1123
+ # return mean_efficiency_S, 1, mean_efficiency_D, 1, mean_efficiency_T, 1
1124
+ # elif syst =="CN":
1125
+ # return mean_efficiency_D2, 1
1126
+ # else:
1127
+ return mean_efficiency_S, std_efficiency_S, mean_efficiency_D, std_efficiency_D, mean_efficiency_T, std_efficiency_T, mean_efficiency_D2, std_efficiency_D2
1054
1128
  if mode =="dis":
1055
1129
  return efficiency_S, efficiency_D, efficiency_T, efficiency_D2
1056
1130
 
@@ -1076,17 +1150,22 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
1076
1150
  # TAB = 0.992232838598821
1077
1151
  # TBC = 0.992343419459002
1078
1152
  # TAC = 0.99275350064608
1079
- # Rad="Lu-177"
1153
+ # Rad="Co-60"
1080
1154
  # pmf_1="1"
1081
- # N = 1000
1155
+ # N = 5
1082
1156
  # kB =1.0e-5
1083
1157
  # V = 10
1084
1158
  # mode = "eff"
1085
1159
  # mode2 = "sym"
1086
1160
 
1087
- # # out = TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=True, barp=False,uncData=False)
1088
- # # print("TDCR", out[4]/out[2])
1089
- # # print("Eff D", out[2])
1161
+ # # # out = TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=True, barp=False,uncData=False)
1162
+ # # # print("TDCR", out[4]/out[2])
1163
+ # # # print("Eff D", out[2])
1164
+
1090
1165
 
1166
+ # # 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)
1091
1167
 
1092
- # 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)
1168
+ # out = TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display = False, record = True, readRecHist = False)
1169
+ # print("result", out)
1170
+ # out = TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display = False, record = False, readRecHist = True)
1171
+ # print("result", out)
tdcrpy/TDCR_model_lib.py CHANGED
@@ -189,6 +189,96 @@ def read_temp_files(copy=False, path="C:"):
189
189
 
190
190
  return content1, content2, content3, content4,
191
191
 
192
+ def energyVectors1(temp):
193
+ temp = temp.split("\n")
194
+ row_m = ""
195
+ ee_vec, eg_vec, ep_vec, ea_vec = [], [], [], []
196
+ ee=0; eg=0; ep=0; ea=0
197
+ for row in temp:
198
+ if row=="": row = "#"
199
+ if row[0] != "#":
200
+ row = row.split(" ")
201
+ if "" in row: row.pop(2)
202
+ if row[0]=='1': ee+=float(row[1])*1e-3
203
+ if row[0]=='2': eg+=float(row[1])*1e-3
204
+ if row[0]=='3': ep+=float(row[1])*1e-3
205
+ if row[0]=='4': ea+=float(row[1])*1e-3
206
+ if row[2] != row_m:
207
+ ee_vec.append(ee)
208
+ eg_vec.append(eg)
209
+ ep_vec.append(ep)
210
+ ea_vec.append(ea)
211
+ eg=0; ee=0; ep=0; ea=0
212
+ #else: print(row)
213
+ ee_vec = [num for num in ee_vec if num != 0]
214
+ eg_vec = [num for num in eg_vec if num != 0]
215
+ ep_vec = [num for num in ep_vec if num != 0]
216
+ ea_vec = [num for num in ea_vec if num != 0]
217
+ return ee_vec, eg_vec, ep_vec, ea_vec
218
+
219
+ def energyVectors2(temp):
220
+ temp = temp.split("\n")
221
+ row_m = ""
222
+ ee_vec, ep_vec, ea_vec = [], [], []
223
+ ee=0; ep=0; ea=0
224
+ for row in temp:
225
+ if row=="": row = "#"
226
+ if row[0] != "#":
227
+ row = row.split(" ")
228
+ if "" in row: row.pop(2)
229
+ if row[0]=='1': ee+=float(row[1])*1e-3
230
+ if row[0]=='3': ep+=float(row[1])*1e-3
231
+ if row[0]=='4': ea+=float(row[1])*1e-3
232
+ if row[2] != row_m:
233
+ ee_vec.append(ee)
234
+ ep_vec.append(ep)
235
+ ea_vec.append(ea)
236
+ ee=0; ep=0; ea=0
237
+ #else: print(row)
238
+ ee_vec = [num for num in ee_vec if num != 0]
239
+ ep_vec = [num for num in ep_vec if num != 0]
240
+ ea_vec = [num for num in ea_vec if num != 0]
241
+ return ee_vec, ep_vec, ea_vec
242
+
243
+
244
+ def energyVectors3(temp):
245
+ temp = temp.split("\n")
246
+ row_m = ""
247
+ ee_vec = []; ee=0
248
+ for row in temp:
249
+ if row=="": row = "#"
250
+ if row[0] != "#":
251
+ row = row.split(" ")
252
+ if "" in row: row.pop(2)
253
+ ee+=float(row[1])*1e-3
254
+ if row[2] != row_m:
255
+ ee_vec.append(ee)
256
+ ee=0
257
+ #else: print(row)
258
+ ee_vec = [num for num in ee_vec if num != 0]
259
+ return ee_vec
260
+
261
+ def effVector(temp):
262
+ temp = temp.split("\n")
263
+ row_m = ""
264
+ s_vec, d_vec, t_vec = [], [], []
265
+ s=0; d=0; t=0
266
+ for row in temp:
267
+ if row=="": row = "#"
268
+ if row[0] != "#":
269
+ row = row.split(" ")
270
+ s+=float(row[1])
271
+ d+=float(row[2])
272
+ t+=float(row[3])
273
+ if row[0] != row_m:
274
+ s_vec.append(s)
275
+ d_vec.append(d)
276
+ t_vec.append(t)
277
+ s=0; d=0; t=0
278
+ #else: print(row)
279
+ return s_vec, d_vec, t_vec
280
+
281
+
192
282
  # import PenNuc data
193
283
  with importlib.resources.as_file(files('tdcrpy').joinpath('decayData')) as data_path:
194
284
  #with importlib.resources.path('tdcrpy', 'decayData') as data_path:
@@ -2740,7 +2830,122 @@ def buildBetaSpectra(rad, V, N, prt=False):
2740
2830
  else: file.write(f"{b}\t{p2[i]}\n")
2741
2831
  print("file written in local")
2742
2832
 
2833
+ def detectProbabilities(L, e_quenching, e_quenching2, t1, evenement, mode2, extDT, measTime):
2834
+ if mode2=="sym":
2835
+ # print(evenement !=1, t1 > extDT*1e-6, t1 < measTime*60)
2836
+ if evenement !=1 and t1 > extDT*1e-6 and t1 < measTime*60:
2837
+ # TDCR
2838
+ p_nosingle = np.exp(-L*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
2839
+ p_single = 1-p_nosingle # probability to have at least 1 electrons in a PMT
2840
+ p_nosingle2 = np.exp(-L*np.sum(np.asarray(e_quenching2))/3) # probability to have 0 electrons in a PMT
2841
+ p_single2 = 1-p_nosingle2
2842
+ efficiency0_S = 1-p_nosingle**3+1-p_nosingle2**3
2843
+ efficiency0_T = p_single**3+p_single2**3
2844
+ efficiency0_D = 3*(p_single)**2-2*p_single**3+(3*(p_single2)**2-2*p_single2**3)
2845
+
2846
+ # CN
2847
+ p_nosingle = np.exp(-L*np.sum(np.asarray(e_quenching))/2) # probability to have 0 electrons in a PMT
2848
+ p_single = 1-p_nosingle # probability to have at least 1 electrons in a PMT
2849
+ p_nosingle2 = np.exp(-L*np.sum(np.asarray(e_quenching2))/2) # probability to have 0 electrons in a PMT
2850
+ p_single2 = 1-p_nosingle2
2851
+ efficiency0_D2 = p_single**2+p_single2**2
2852
+ else:
2853
+ # TDCR
2854
+ p_nosingle = np.exp(-L*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
2855
+ p_single = 1-p_nosingle # probability to have at least 1 electrons in a PMT
2856
+ efficiency0_S = 1-p_nosingle**3
2857
+ efficiency0_T = p_single**3
2858
+ efficiency0_D = 3*(p_single)**2-2*efficiency0_T
2859
+
2860
+ # CN
2861
+ p_nosingle = np.exp(-L*np.sum(np.asarray(e_quenching))/2) # probability to have 0 electrons in a PMT
2862
+ p_single = 1-p_nosingle # probability to have at least 1 electrons in a PMT
2863
+ efficiency0_D2 = p_single**2
2864
+
2865
+
2866
+ elif mode2=="asym":
2867
+ if evenement !=1 and t1 > extDT*1e-6 and t1 < measTime*60:
2868
+ # TDCR
2869
+ pA_nosingle = np.exp(-L[0]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
2870
+ pA_single = 1-pA_nosingle # probability to have at least 1 electrons in a PMT
2871
+ pB_nosingle = np.exp(-L[1]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
2872
+ pB_single = 1-pB_nosingle # probability to have at least 1 electrons in a PMT
2873
+ pC_nosingle = np.exp(-L[2]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
2874
+ pC_single = 1-pC_nosingle # probability to have at least 1 electrons in a PMT
2875
+
2876
+ pA_nosingle2 = np.exp(-L[0]*np.sum(np.asarray(e_quenching2))/3) # probability to have 0 electrons in a PMT
2877
+ pA_single2 = 1-pA_nosingle2 # probability to have at least 1 electrons in a PMT
2878
+ pB_nosingle2 = np.exp(-L[1]*np.sum(np.asarray(e_quenching2))/3) # probability to have 0 electrons in a PMT
2879
+ pB_single2 = 1-pB_nosingle2 # probability to have at least 1 electrons in a PMT
2880
+ pC_nosingle2 = np.exp(-L[2]*np.sum(np.asarray(e_quenching2))/3) # probability to have 0 electrons in a PMT
2881
+ pC_single2 = 1-pC_nosingle2 # probability to have at least 1 electrons in a PMT
2882
+
2883
+ efficiency0_A2 = pA_single+pA_single2
2884
+ efficiency0_B2 = pB_single+pB_single2
2885
+ efficiency0_AB = pA_single*pB_single+pA_single2*pB_single2
2886
+ efficiency0_BC = pB_single*pC_single+pB_single2*pC_single2
2887
+ efficiency0_AC = pA_single*pC_single+pA_single2*pC_single2
2888
+ efficiency0_T = pA_single*pB_single*pC_single+pA_single2*pB_single2*pC_single2
2889
+ efficiency0_D = 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)
2890
+ #efficiency_S = 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)
2891
+ efficiency0_S = 1-pA_nosingle*pB_nosingle*pC_nosingle+1-pA_nosingle2*pB_nosingle2*pC_nosingle2
2892
+
2893
+
2894
+ # CN
2895
+ pA_nosingle = np.exp(-L[0]*np.sum(np.asarray(e_quenching))/2) # probability to have 0 electrons in a PMT
2896
+ pA_single = 1-pA_nosingle # probability to have at least 1 electrons in a PMT
2897
+ pB_nosingle = np.exp(-L[1]*np.sum(np.asarray(e_quenching))/2) # probability to have 0 electrons in a PMT
2898
+ pB_single = 1-pB_nosingle # probability to have at least 1 electrons in a PMT
2899
+
2900
+ pA_nosingle2 = np.exp(-L[0]*np.sum(np.asarray(e_quenching2))/2) # probability to have 0 electrons in a PMT
2901
+ pA_single2 = 1-pA_nosingle2 # probability to have at least 1 electrons in a PMT
2902
+ pB_nosingle2 = np.exp(-L[1]*np.sum(np.asarray(e_quenching2))/2) # probability to have 0 electrons in a PMT
2903
+ pB_single2 = 1-pB_nosingle2 # probability to have at least 1 electrons in a PMT
2904
+
2905
+ efficiency0_D2 = pA_single*pB_single+pA_single2*pB_single2
2906
+ else:
2907
+ # TDCR
2908
+ pA_nosingle = np.exp(-L[0]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
2909
+ pA_single = 1-pA_nosingle # probability to have at least 1 electrons in a PMT
2910
+ pB_nosingle = np.exp(-L[1]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
2911
+ pB_single = 1-pB_nosingle # probability to have at least 1 electrons in a PMT
2912
+ pC_nosingle = np.exp(-L[2]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
2913
+ pC_single = 1-pC_nosingle # probability to have at least 1 electrons in a PMT
2743
2914
 
2915
+ efficiency0_A2 = pA_single
2916
+ efficiency0_B2 = pB_single
2917
+ efficiency0_AB = pA_single*pB_single
2918
+ efficiency0_BC = pB_single*pC_single
2919
+ efficiency0_AC = pA_single*pC_single
2920
+ efficiency0_T = pA_single*pB_single*pC_single
2921
+ efficiency0_D = efficiency0_AB+efficiency0_BC+efficiency0_AC-2*efficiency0_T
2922
+ efficiency0_S = 1-pA_nosingle*pB_nosingle*pC_nosingle
2923
+
2924
+ # CN
2925
+ pA_nosingle = np.exp(-L[0]*np.sum(np.asarray(e_quenching))/2) # probability to have 0 electrons in a PMT
2926
+ pA_single = 1-pA_nosingle # probability to have at least 1 electrons in a PMT
2927
+ pB_nosingle = np.exp(-L[1]*np.sum(np.asarray(e_quenching))/2) # probability to have 0 electrons in a PMT
2928
+ pB_single = 1-pB_nosingle # probability to have at least 1 electrons in a PMT
2929
+ efficiency0_D2 = pA_single*pB_single
2930
+
2931
+ return efficiency0_S, efficiency0_D, efficiency0_T, efficiency0_D2
2932
+
2933
+
2934
+ def efficienciesEstimates(efficiency_S, efficiency_D, efficiency_T, efficiency_D2,N):
2935
+ mean_efficiency_T = np.mean(efficiency_T) # average
2936
+ std_efficiency_T = np.std(efficiency_T)/np.sqrt(N) # standard deviation
2937
+ mean_efficiency_D = np.mean(efficiency_D)
2938
+ std_efficiency_D = np.std(efficiency_D)/np.sqrt(N)
2939
+ mean_efficiency_D2 = np.mean(efficiency_D2)
2940
+ std_efficiency_D2 = np.std(efficiency_D2)/np.sqrt(N)
2941
+ mean_efficiency_S = np.mean(efficiency_S)
2942
+ std_efficiency_S = np.std(efficiency_S)/np.sqrt(N)
2943
+ return mean_efficiency_S, std_efficiency_S, mean_efficiency_D, std_efficiency_D, mean_efficiency_T, std_efficiency_T, mean_efficiency_D2, std_efficiency_D2
2944
+
2945
+
2946
+
2947
+
2948
+
2744
2949
  # N = 1e7
2745
2950
  # buildBetaSpectra('H-3', 16, N, prt=True); print('H-3 - done')
2746
2951
  # buildBetaSpectra('C-14', 16, N, prt=True); print('C-14 - done')