TDCRPy 1.1.6__py3-none-any.whl → 1.3.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.1.6
3
+ Version: 1.3.0
4
4
  Summary: TDCR model
5
5
  Home-page: https://github.com/RomainCoulon/TDCRPy
6
6
  Author: RomainCoulon (Romain Coulon)
@@ -25,6 +25,7 @@ Requires-Dist: setuptools
25
25
  Requires-Dist: scipy
26
26
  Requires-Dist: configparser
27
27
  Requires-Dist: importlib.resources
28
+ Requires-Dist: matplotlib
28
29
 
29
30
  # TDCRPy
30
31
 
@@ -1,8 +1,8 @@
1
- tdcrpy/TDCRPy.py,sha256=1kG-hjft18Tp-IsRwebnBDdM1sgHqySvx7uDRNU8b9M,33821
2
- tdcrpy/TDCR_model_lib.py,sha256=QUMmKkUQxmY02xXoDe8b2iGBiMhFU35g7H1xcqUjBCo,64456
1
+ tdcrpy/TDCRPy.py,sha256=ahqrcIyi9ZQ89ZWqfBBilq0Y66xyYt0OIZ5x6C9Mo1g,50044
2
+ tdcrpy/TDCR_model_lib.py,sha256=eWD4jp8Bh1ytRJmzCNkJlbco4aQOIN1ZB3iWYlutxo8,67711
3
3
  tdcrpy/TDCRoptimize.py,sha256=ab1EzTNm2HALwKopitwX0BAS8v0pEgAXnye4NOUBazc,3132
4
4
  tdcrpy/__init__.py,sha256=pxZ5gMTFSEzeGQLzeRjy-Imu7bZIfhg9eqloOq5FTM4,130
5
- tdcrpy/config.toml,sha256=9cIERT8yqA0M-JH8AZJbIjlZj5KFZRrjG673sdi5dYM,1464
5
+ tdcrpy/config.toml,sha256=P46cM2uvxD5NgcVK0J6zE2kFnh5AmAww5CMgxgtWCKE,1541
6
6
  tdcrpy/MCNP-MATRIX/Spectra_for_analytical_model/dep_spectrum_C-14.txt,sha256=lio7tle1TdTU3kxunCYyyFKCLYM35uqQh2kRtIZkGQo,41268
7
7
  tdcrpy/MCNP-MATRIX/Spectra_for_analytical_model/dep_spectrum_Ca-45.txt,sha256=-2O4JbuyqHqVa_WglC3BQyADlNIwNlFQwslsGAtFNvc,41227
8
8
  tdcrpy/MCNP-MATRIX/Spectra_for_analytical_model/dep_spectrum_H-3.txt,sha256=LaiH6eD0gxEoCRVcLPkPmrXB-1fQif8kxVbmLNMJHlo,41274
@@ -60,8 +60,8 @@ tdcrpy/docs/_build/html/source/modules.html,sha256=gJrhuEaMQHkYGewGHPWGmgVsPgVV6
60
60
  tdcrpy/docs/_build/html/source/tdcrpy.html,sha256=VZV_LFdrCCIvYBXzsZE9mZx8iGa7ZjhEsXtE8BqqU9g,90373
61
61
  tdcrpy/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
62
  tdcrpy/test/test_tdcrpy.py,sha256=dWZpfvarkr8lr_K_zUakt2AOcF0FfCOjBOQPl4vnTWc,4116
63
- TDCRPy-1.1.6.dist-info/LICENCE.md,sha256=fuYzrZRiOAjJBzA1tsGQwojCgGROArb2Ec48GDTjlWM,1086
64
- TDCRPy-1.1.6.dist-info/METADATA,sha256=XVfl-723xPwL8RQ__Ptz9mOXuXy-let2wHyl36A7bNk,15902
65
- TDCRPy-1.1.6.dist-info/WHEEL,sha256=AtBG6SXL3KF_v0NxLf0ehyVOh0cold-JbJYXNGorC6Q,92
66
- TDCRPy-1.1.6.dist-info/top_level.txt,sha256=VgPJa9YJ7fi8wrr9qDJPLhu3tK1BcFRIP6Ib4r3BEfs,7
67
- TDCRPy-1.1.6.dist-info/RECORD,,
63
+ TDCRPy-1.3.0.dist-info/LICENCE.md,sha256=fuYzrZRiOAjJBzA1tsGQwojCgGROArb2Ec48GDTjlWM,1086
64
+ TDCRPy-1.3.0.dist-info/METADATA,sha256=OBMFgLB6kxsar_wlEWzthz3J0VqV7760cwyxqurFmGY,15929
65
+ TDCRPy-1.3.0.dist-info/WHEEL,sha256=AtBG6SXL3KF_v0NxLf0ehyVOh0cold-JbJYXNGorC6Q,92
66
+ TDCRPy-1.3.0.dist-info/top_level.txt,sha256=VgPJa9YJ7fi8wrr9qDJPLhu3tK1BcFRIP6Ib4r3BEfs,7
67
+ TDCRPy-1.3.0.dist-info/RECORD,,
tdcrpy/TDCRPy.py CHANGED
@@ -10,12 +10,14 @@ Bureau International des Poids et Mesures
10
10
 
11
11
  ## IMPORT PYTHON MODULES
12
12
  import tdcrpy.TDCR_model_lib as tl
13
+ # import TDCR_model_lib as tl
13
14
  import importlib.resources
14
15
  import configparser
15
16
  import numpy as np
16
17
  from tqdm import tqdm
18
+ from importlib.resources import files
17
19
 
18
- def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=False, barp=False):
20
+ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=False, barp=False, uncData=False):
19
21
  """
20
22
  This is the main function of the TDCRPy package running the Monte-Carlo Triple-to-Double Coincidence Ratio model.
21
23
  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.
@@ -25,6 +27,8 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
25
27
  --> In mode="eff", it calculates the efficiency of the TDCR system as a function of a value (triplet) of free parameter(s) L, the measurement data is not used;
26
28
 
27
29
  --> In mode="res", it calculates the residual of the TDCR model parametrized by a value (or triplet) of free parameter(s) L and the measurement data TD, TAB, TBC, TAC.
30
+
31
+ --> In mode="dis", the distributions of coincidence probability are retruned
28
32
 
29
33
  also, two configuration can be set:
30
34
 
@@ -67,13 +71,15 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
67
71
  V : float
68
72
  volume of the scintillator in ml.
69
73
  mode : string
70
- "res" to return the residual, "eff" to return efficiencies.
74
+ "res" to return the residual, "eff" to return efficiencies, "dis" to resturn distributions.
71
75
  mode2 : string
72
76
  "sym" for symetrical model, "asym" for symetrical model.
73
77
  Display : Boolean, optional
74
78
  "True" to display details on the decay sampling. The default is False.
75
79
  barp : Boolean, optional
76
- "True" to display the calculation progress. The default is True.
80
+ "True" to display the calculation progress. The default is False.
81
+ uncData : Boolean, optional
82
+ "True" to propagate uncertainty from decay data. The default is False.
77
83
 
78
84
  Returns
79
85
  -------
@@ -94,9 +100,10 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
94
100
  """
95
101
  if barp: tl.display_header()
96
102
  config = configparser.ConfigParser()
97
- with importlib.resources.path('tdcrpy', 'config.toml') as data_path:
98
- file_conf = data_path
103
+ with importlib.resources.as_file(files('tdcrpy').joinpath('config.toml')) as data_path:
104
+ file_conf = data_path
99
105
  config.read(file_conf)
106
+ tau=config["Inputs"].getfloat("tau")
100
107
  Y=config["Inputs"].getboolean("Y")
101
108
  radListPureBeta=config["Inputs"].get("radListPureBeta")
102
109
  radListPureBeta=radListPureBeta.replace(" ","")
@@ -145,6 +152,8 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
145
152
  DaughterVec = [] # Daughters -- indice 0
146
153
  Pdaughter = [] # Probabiblity related to daughters -- indice 1
147
154
  Transition_prob_sum = []
155
+ u_prob_trans = [] # uncertainty of the probabilities for each transition -- indice 10
156
+ trans_halfLife = [] # half life of the transition
148
157
 
149
158
  for rad_i in Rad:
150
159
  out_PenNuc = tl.readPenNuc2(rad_i)
@@ -163,7 +172,10 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
163
172
  DaughterVec.append(out_PenNuc[0]) # Daughters -- indice 0
164
173
  Pdaughter.append(out_PenNuc[1]) # Probabiblity related to daughters -- indice 1
165
174
  Transition_prob_sum.append(out_PenNuc[14])
166
-
175
+ u_prob_trans.append(out_PenNuc[16])
176
+ trans_halfLife.append(out_PenNuc[15])
177
+ # print("\n",trans_halfLife)
178
+
167
179
  efficiency_S = []
168
180
  efficiency_D = []
169
181
  efficiency_T = []
@@ -246,11 +258,24 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
246
258
  if Display: print("\t Subsequent isomeric transition(s)") # finish with the mother / now with the daughter
247
259
  while levelOftheDaughter > 0: # Go on the loop while the daughter nucleus is a its fundamental level (energy 0)
248
260
  i_level = levelNumber[index_rad][iDaughter].index([levelOftheDaughter]) # Find the position in the daughter level vector
261
+ print(trans_halfLife)
262
+ # test whether the decay occurs within the coincidence resolving time or not
263
+ if np.random.exponential(trans_halfLife[index_rad][iDaughter][i_branch][i_level], size=1)[0] > tau: splitEvent = True
264
+ else: splitEvent = False
265
+
249
266
  if transitionType[index_rad][iDaughter][i_level] != []:
250
267
  #====================================================================
251
268
  # Sampling of the transition in energy levels of the daughter nucleus
252
269
  #====================================================================
253
- probability_tran = tl.normalise(prob_trans[index_rad][iDaughter][i_level]) # normaliser la proba de transition
270
+ if uncData:
271
+ prob_trans_s=[]
272
+ for ipt, xpt in enumerate(prob_trans[index_rad][iDaughter][i_level]):
273
+ prob_trans_s.append(np.random.normal(xpt, u_prob_trans[index_rad][iDaughter][i_level][ipt], 1)[0])
274
+
275
+ probability_tran = tl.normalise(prob_trans_s) # normaliser la proba de transition
276
+ else:
277
+ probability_tran = tl.normalise(prob_trans[index_rad][iDaughter][i_level]) # normaliser la proba de transition
278
+
254
279
  index_t = tl.sampling(probability_tran) # indice de la transition
255
280
  if Display:
256
281
  print("\t\t Energy of the level = ", levelEnergy[index_rad][iDaughter][i_level][0], " keV")
@@ -319,190 +344,423 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
319
344
  II. LA RELAXATION ATOMIQUE
320
345
  ==========================
321
346
  '''
322
- daughter_relax = DaughterVec[index_rad][iDaughter]
323
- for i_part in range(len(particle_vec)):
324
- relaxation = False
325
- if "Atom_K" in particle_vec[i_part] or "Atom_L" in particle_vec[i_part] or "Atom_M" in particle_vec[i_part]:
326
- relaxation = True
327
- while relaxation:
328
- tf,ef = tl.relaxation_atom(daughter_relax,Rad[index_rad],particle_vec[i_part])
329
- if tf == "XKA":
330
- particle_vec[i_part] = "Atom_L"
331
- particle_vec.append(tf)
332
- energy_vec.append(ef)
333
- relaxation = True
334
- elif tf == "XKB":
335
- particle_vec[i_part] = "Atom_M"
336
- particle_vec.append(tf)
337
- energy_vec.append(ef)
338
- relaxation = False
339
- elif tf == "XL":
340
- particle_vec[i_part] = "Atom_M"
341
- particle_vec.append(tf)
342
- energy_vec.append(ef)
343
- relaxation = False
344
- elif tf == "Auger K":
345
- particle_vec[i_part] = "Atom_L"
346
- particle_vec.append(tf)
347
- energy_vec.append(ef)
347
+
348
+ if splitEvent:
349
+ particle_vec2=[]
350
+ energy_vec2=[]
351
+
352
+ daughter_relax = DaughterVec[index_rad][iDaughter]
353
+ for i_part in range(len(particle_vec)):
354
+ relaxation = False
355
+ if "Atom_K" in particle_vec[i_part] or "Atom_L" in particle_vec[i_part] or "Atom_M" in particle_vec[i_part]:
348
356
  relaxation = True
349
- elif tf == "Auger L":
350
- particle_vec[i_part] = "Atom_M"
351
- particle_vec.append(tf)
352
- energy_vec.append(ef)
353
- relaxation = False
354
- else:
355
- if Display: print("untermined x or Auger")
356
- relaxation = False
357
- e_sum += ef
358
- if Display:
359
- print("\t Summary of the atomic relaxation")
357
+ while relaxation:
358
+ tf,ef = tl.relaxation_atom(daughter_relax,Rad[index_rad],particle_vec[i_part])
359
+ if tf == "XKA":
360
+ particle_vec[i_part] = "Atom_L"
361
+ particle_vec2.append(tf)
362
+ energy_vec2.append(ef)
363
+ relaxation = True
364
+ elif tf == "XKB":
365
+ particle_vec[i_part] = "Atom_M"
366
+ particle_vec2.append(tf)
367
+ energy_vec2.append(ef)
368
+ relaxation = False
369
+ elif tf == "XL":
370
+ particle_vec[i_part] = "Atom_M"
371
+ particle_vec2.append(tf)
372
+ energy_vec2.append(ef)
373
+ relaxation = False
374
+ elif tf == "Auger K":
375
+ particle_vec[i_part] = "Atom_L"
376
+ particle_vec2.append(tf)
377
+ energy_vec2.append(ef)
378
+ relaxation = True
379
+ elif tf == "Auger L":
380
+ particle_vec[i_part] = "Atom_M"
381
+ particle_vec2.append(tf)
382
+ energy_vec2.append(ef)
383
+ relaxation = False
384
+ else:
385
+ if Display: print("untermined x or Auger")
386
+ relaxation = False
387
+ e_sum += ef
388
+ if Display:
389
+ print("\t Summary of the atomic relaxation (prompt emission)")
390
+ for i, p in enumerate(particle_vec2):
391
+ if p[:4] != "Atom":
392
+ print(f"\t\t energy of {p} = ", round(energy_vec2[i],3), "keV")
393
+
394
+ '''
395
+ ==========================================================
396
+ III.a SPECTRES D'EMISSION
397
+ ==========================================================
398
+ '''
399
+
400
+ for i, p in enumerate(particle_vec2):
401
+ if p == "beta":
402
+ e_b,p_b = tl.readBetaShape(rad_i,"beta-",level_before_trans) # read the data of BetaShape
403
+ index_beta_energy = tl.sampling(p_b) # sampling energy of beta
404
+ particle_vec2[i] = "electron"
405
+ energy_vec2[i] = e_b[index_beta_energy]
406
+
407
+ if p == "beta+":
408
+ e_b,p_b = tl.readBetaShape(rad_i,"beta+",level_before_trans)
409
+ index_beta_energy = tl.sampling(p_b)
410
+ particle_vec2[i] = "positron"
411
+ energy_vec[i] = e_b[index_beta_energy]
412
+ particle_vec2.append("gamma")
413
+ particle_vec2.append("gamma")
414
+ energy_vec2.append(511)
415
+ energy_vec2.append(511)
416
+ energy_vec_initial2 = energy_vec2
417
+ if Display:
418
+ print("\t Summary of emitted particles from the promt atomic relaxation")
419
+ for i, p in enumerate(particle_vec2):
420
+ if p[:4] != "Atom": print(f"\t\t energy of {p} = ", round(energy_vec2[i],3), "keV")
421
+
422
+
360
423
  for i, p in enumerate(particle_vec):
361
- if p[:4] != "Atom":
362
- print(f"\t\t energy of {p} = ", round(energy_vec[i],3), "keV")
363
-
364
- '''
365
- ==========================================================
366
- III.a SPECTRES D'EMISSION
367
- ==========================================================
368
- '''
369
- # for i, p in enumerate(particle_vec):
370
- # if p == "beta":
371
- # e_b,p_b = tl.readBetaShape(rad_i,"beta-",level_before_trans) # read the data of BetaShape
372
- # index_beta_energy = tl.sampling(p_b) # sampling energy of beta
373
- # particle_vec[i] = "electron"
374
- # energy_vec[i] = e_b[index_beta_energy]
375
- # energy_vec[i] = tl.energie_dep_beta(energy_vec[i])
376
-
377
- # if p == "beta+":
378
- # e_b,p_b = tl.readBetaShape(rad_i,"beta+",level_before_trans)
379
- # index_beta_energy = tl.sampling(p_b)
380
- # particle_vec[i] = "positron"
381
- # energy_vec[i] = e_b[index_beta_energy]
382
- # energy_vec[i] = tl.energie_dep_beta(energy_vec[i]) # treated as beta-
383
- # particle_vec.append("gamma")
384
- # particle_vec.append("gamma")
385
- # energy_vec.append(511)
386
- # energy_vec.append(511)
387
-
388
- # if p == "gamma" or p == "XKA" or p == "XKB" or p == "XL":
389
- # energy_vec[i] = tl.energie_dep_gamma(energy_vec[i],v=V) # sampling energy free from photon
390
- # particle_vec[i] = "electron"
391
- # if p == "Auger K" or p == "Auger L":
392
- # particle_vec[i] = "electron"
393
- # energy_vec[i] = tl.energie_dep_beta(energy_vec[i])
394
- # if Display: print("\t Summary of the final charged particles")
395
- # if Display: print("\t\t particles : ", particle_vec)
396
- # if Display: print("\t\t energy after interaction : ", energy_vec, "keV")
397
-
398
- for i, p in enumerate(particle_vec):
399
- if p == "beta":
400
- e_b,p_b = tl.readBetaShape(rad_i,"beta-",level_before_trans) # read the data of BetaShape
401
- index_beta_energy = tl.sampling(p_b) # sampling energy of beta
402
- particle_vec[i] = "electron"
403
- energy_vec[i] = e_b[index_beta_energy]
424
+ if p == "beta":
425
+ e_b,p_b = tl.readBetaShape(rad_i,"beta-",level_before_trans) # read the data of BetaShape
426
+ index_beta_energy = tl.sampling(p_b) # sampling energy of beta
427
+ particle_vec[i] = "electron"
428
+ energy_vec[i] = e_b[index_beta_energy]
429
+
430
+ if p == "beta+":
431
+ e_b,p_b = tl.readBetaShape(rad_i,"beta+",level_before_trans)
432
+ index_beta_energy = tl.sampling(p_b)
433
+ particle_vec[i] = "positron"
434
+ energy_vec[i] = e_b[index_beta_energy]
435
+ particle_vec.append("gamma")
436
+ particle_vec.append("gamma")
437
+ energy_vec.append(511)
438
+ energy_vec.append(511)
439
+ energy_vec_initial = energy_vec
440
+ if Display:
441
+ print("\t Summary of emitted particles from the delayed nuclear relaxation")
442
+ for i, p in enumerate(particle_vec):
443
+ if p[:4] != "Atom": print(f"\t\t energy of {p} = ", round(energy_vec[i],3), "keV")
404
444
 
405
- if p == "beta+":
406
- e_b,p_b = tl.readBetaShape(rad_i,"beta+",level_before_trans)
407
- index_beta_energy = tl.sampling(p_b)
408
- particle_vec[i] = "positron"
409
- energy_vec[i] = e_b[index_beta_energy]
410
- particle_vec.append("gamma")
411
- particle_vec.append("gamma")
412
- energy_vec.append(511)
413
- energy_vec.append(511)
414
- energy_vec_initial = energy_vec
415
- if Display:
416
- print("\t Summary of emitted particles")
445
+
446
+ '''
447
+ ==========================================================
448
+ III.b INTERACTION RAYONNEMENT/MATIERE
449
+ ==========================================================
450
+ '''
451
+
452
+ for i, p in enumerate(particle_vec2):
453
+ if p == "electron":
454
+ energy_vec2[i] = tl.energie_dep_beta(energy_vec2[i])
455
+
456
+ if p == "beta+":
457
+ energy_vec2[i] = tl.energie_dep_beta(energy_vec2[i])
458
+
459
+ if p == "gamma" or p == "XKA" or p == "XKB" or p == "XL":
460
+ energy_vec2[i] = tl.energie_dep_gamma(energy_vec2[i],v=V) # sampling energy free from photon
461
+ particle_vec2[i] = "electron"
462
+
463
+ if p == "Auger K" or p == "Auger L":
464
+ particle_vec2[i] = "electron"
465
+ energy_vec2[i] = tl.energie_dep_beta(energy_vec2[i])
466
+
467
+ if Display:
468
+ print("\t Summary of the energy deposited by charged particles by the prompt atomic relaxation")
469
+ for i, p in enumerate(particle_vec2):
470
+ if p[:4] != "Atom": print(f"\t\t energy of {p} = ", round(energy_vec2[i],3), "keV")
471
+
472
+
417
473
  for i, p in enumerate(particle_vec):
418
- if p[:4] != "Atom": print(f"\t\t energy of {p} = ", round(energy_vec[i],3), "keV")
419
-
420
-
421
- '''
422
- ==========================================================
423
- III.b INTERACTION RAYONNEMENT/MATIERE
424
- ==========================================================
425
- '''
426
- for i, p in enumerate(particle_vec):
427
- if p == "electron":
428
- energy_vec[i] = tl.energie_dep_beta(energy_vec[i])
429
-
430
- if p == "beta+":
431
- energy_vec[i] = tl.energie_dep_beta(energy_vec[i])
432
-
433
- if p == "gamma" or p == "XKA" or p == "XKB" or p == "XL":
434
- energy_vec[i] = tl.energie_dep_gamma(energy_vec[i],v=V) # sampling energy free from photon
435
- particle_vec[i] = "electron"
474
+ if p == "electron":
475
+ energy_vec[i] = tl.energie_dep_beta(energy_vec[i])
476
+
477
+ if p == "beta+":
478
+ energy_vec[i] = tl.energie_dep_beta(energy_vec[i])
479
+
480
+ if p == "gamma" or p == "XKA" or p == "XKB" or p == "XL":
481
+ energy_vec[i] = tl.energie_dep_gamma(energy_vec[i],v=V) # sampling energy free from photon
482
+ particle_vec[i] = "electron"
483
+
484
+ if p == "Auger K" or p == "Auger L":
485
+ particle_vec[i] = "electron"
486
+ energy_vec[i] = tl.energie_dep_beta(energy_vec[i])
487
+
488
+ if Display:
489
+ print("\t Summary of the energy deposited by charged particles from the delayed nuclear relaxation")
490
+ for i, p in enumerate(particle_vec):
491
+ if p[:4] != "Atom": print(f"\t\t energy of {p} = ", round(energy_vec[i],3), "keV")
492
+
493
+ '''
494
+ ====================
495
+ IV. LA SCINTILLATION
496
+ Calculation of the scintillation quenching with the Birks Model
497
+ ====================
498
+ '''
499
+ if Display: print("\t Summary of the estimation of quenched energies by the prompt atomic relaxation")
500
+ e_quenching2=[]
501
+ for i, p in enumerate(particle_vec2):
502
+ if p == "alpha":
503
+ energy_vec2[i] = tl.Em_a(energy_vec2[i],kB,nE_alpha)
504
+ e_quenching2.append(energy_vec2[i])
505
+ elif p == "electron" or p == "positron":
506
+ energy_vec2[i] = tl.Em_e(energy_vec_initial2[i]*1e3,energy_vec2[i]*1e3,kB*1e3,nE_electron)*1e-3
507
+ e_quenching2.append(energy_vec2[i])
508
+ else:
509
+ e_quenching2.append(0)
510
+ if Display: print("\t\t Birks constant = ", kB, ' cm/keV')
511
+ if Display:
512
+ for i, p in enumerate(particle_vec2):
513
+ if p[:4] != "Atom": print(f"\t\t quenched energy of {p} = ", round(e_quenching2[i],3), "keV")
514
+
515
+
516
+ # changer l'intégration E_i - E_d à E_i
517
+ if Display: print("\t Summary of the estimation of quenched energies from the delayed nuclear relaxation")
518
+ e_quenching=[]
519
+ for i, p in enumerate(particle_vec):
520
+ if p == "alpha":
521
+ energy_vec[i] = tl.Em_a(energy_vec[i],kB,nE_alpha)
522
+ e_quenching.append(energy_vec[i])
523
+ elif p == "electron" or p == "positron":
524
+ energy_vec[i] = tl.Em_e(energy_vec_initial[i]*1e3,energy_vec[i]*1e3,kB*1e3,nE_electron)*1e-3
525
+ e_quenching.append(energy_vec[i])
526
+ else:
527
+ e_quenching.append(0)
528
+ if Display: print("\t\t Birks constant = ", kB, ' cm/keV')
529
+ if Display:
530
+ for i, p in enumerate(particle_vec):
531
+ if p[:4] != "Atom": print(f"\t\t quenched energy of {p} = ", round(e_quenching[i],3), "keV")
532
+
533
+ '''
534
+ ====================
535
+ V. LE MESURE TDCR
536
+ ====================
537
+ '''
538
+
539
+ if mode2=="sym":
540
+ p_nosingle = np.exp(-L*np.sum(np.asarray(e_quenching2))/3) # probability to have 0 electrons in a PMT
541
+ p_single = 1-p_nosingle # probability to have at least 1 electrons in a PMT
542
+ efficiency_S.append(p_single)
543
+ efficiency_T.append(p_single**3)
544
+ efficiency_D.append(3*(p_single)**2-2*efficiency_T[-1])
545
+ if Display: print("\t Summary of TDCR measurement (prompt)")
546
+ if Display: print("\t\t Free parameter = ", L, "keV-1")
547
+ if Display: print("\t\t Efficiency of single events = ", round(efficiency_S[-1],5))
548
+ if Display: print("\t\t Efficiency of double events = ", round(efficiency_D[-1],5))
549
+ if Display: print("\t\t Efficiency of triple events = ", round(efficiency_T[-1],5))
550
+ elif mode2=="asym":
551
+ pA_nosingle = np.exp(-L[0]*np.sum(np.asarray(e_quenching2))/3) # probability to have 0 electrons in a PMT
552
+ pA_single = 1-pA_nosingle # probability to have at least 1 electrons in a PMT
553
+ pB_nosingle = np.exp(-L[1]*np.sum(np.asarray(e_quenching2))/3) # probability to have 0 electrons in a PMT
554
+ pB_single = 1-pB_nosingle # probability to have at least 1 electrons in a PMT
555
+ pC_nosingle = np.exp(-L[2]*np.sum(np.asarray(e_quenching2))/3) # probability to have 0 electrons in a PMT
556
+ pC_single = 1-pC_nosingle # probability to have at least 1 electrons in a PMT
436
557
 
437
- if p == "Auger K" or p == "Auger L":
438
- particle_vec[i] = "electron"
439
- energy_vec[i] = tl.energie_dep_beta(energy_vec[i])
558
+ efficiency_AB.append(pA_single*pB_single)
559
+ efficiency_BC.append(pB_single*pC_single)
560
+ efficiency_AC.append(pA_single*pC_single)
561
+ efficiency_T.append(pA_single*pB_single*pC_single)
562
+ efficiency_D.append(efficiency_AB[-1]+efficiency_BC[-1]+efficiency_AC[-1]-2*efficiency_T[-1])
563
+ efficiency_S.append(pA_single+pB_single+pC_single-efficiency_D[-1]-efficiency_T[-1])
564
+ if Display: print("\t Summary of TDCR measurement (prompt)")
565
+ if Display: print("\t\t Free parameter PMT A: ", L[0], "keV-1")
566
+ if Display: print("\t\t Free parameter PMT B: ", L[1], "keV-1")
567
+ if Display: print("\t\t Free parameter PMT C: ", L[2], "keV-1")
568
+ if Display: print("\t\t Efficiency of single events: ", round(efficiency_S[-1],5))
569
+ if Display: print("\t\t Efficiency of double events: ", round(efficiency_D[-1],5))
570
+ if Display: print("\t\t Efficiency of triple events: ", round(efficiency_T[-1],5))
571
+
572
+
573
+ if mode2=="sym":
574
+ p_nosingle = np.exp(-L*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
575
+ p_single = 1-p_nosingle # probability to have at least 1 electrons in a PMT
576
+ efficiency_S.append(p_single)
577
+ efficiency_T.append(p_single**3)
578
+ efficiency_D.append(3*(p_single)**2-2*efficiency_T[-1])
579
+ if Display: print("\t Summary of TDCR measurement (delayed)")
580
+ if Display: print("\t\t Free parameter = ", L, "keV-1")
581
+ if Display: print("\t\t Efficiency of single events = ", round(efficiency_S[-1],5))
582
+ if Display: print("\t\t Efficiency of double events = ", round(efficiency_D[-1],5))
583
+ if Display: print("\t\t Efficiency of triple events = ", round(efficiency_T[-1],5))
584
+ elif mode2=="asym":
585
+ pA_nosingle = np.exp(-L[0]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
586
+ pA_single = 1-pA_nosingle # probability to have at least 1 electrons in a PMT
587
+ pB_nosingle = np.exp(-L[1]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
588
+ pB_single = 1-pB_nosingle # probability to have at least 1 electrons in a PMT
589
+ pC_nosingle = np.exp(-L[2]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
590
+ pC_single = 1-pC_nosingle # probability to have at least 1 electrons in a PMT
440
591
 
441
- if Display:
442
- print("\t Summary of the energy deposited by charged particles")
443
- for i, p in enumerate(particle_vec):
444
- if p[:4] != "Atom": print(f"\t\t energy of {p} = ", round(energy_vec[i],3), "keV")
445
-
446
- '''
447
- ====================
448
- IV. LA SCINTILLATION
449
- Calculation of the scintillation quenching with the Birks Model
450
- ====================
451
- '''
452
- # changer l'intégration E_i - E_d à E_i
453
- if Display: print("\t Summary of the estimation of quenched energies")
454
- e_quenching=[]
455
- for i, p in enumerate(particle_vec):
456
- if p == "alpha":
457
- energy_vec[i] = tl.Em_a(energy_vec[i],kB,nE_alpha)
458
- e_quenching.append(energy_vec[i])
459
- elif p == "electron" or p == "positron":
460
- energy_vec[i] = tl.Em_e(energy_vec_initial[i]*1e3,energy_vec[i]*1e3,kB*1e3,nE_electron)*1e-3
461
- e_quenching.append(energy_vec[i])
462
- else:
463
- e_quenching.append(0)
464
- if Display: print("\t\t Birks constant = ", kB, ' cm/keV')
465
- if Display:
592
+ efficiency_AB.append(pA_single*pB_single)
593
+ efficiency_BC.append(pB_single*pC_single)
594
+ efficiency_AC.append(pA_single*pC_single)
595
+ efficiency_T.append(pA_single*pB_single*pC_single)
596
+ efficiency_D.append(efficiency_AB[-1]+efficiency_BC[-1]+efficiency_AC[-1]-2*efficiency_T[-1])
597
+ efficiency_S.append(pA_single+pB_single+pC_single-efficiency_D[-1]-efficiency_T[-1])
598
+ if Display: print("\t Summary of TDCR measurement (delayed)")
599
+ if Display: print("\t\t Free parameter PMT A: ", L[0], "keV-1")
600
+ if Display: print("\t\t Free parameter PMT B: ", L[1], "keV-1")
601
+ if Display: print("\t\t Free parameter PMT C: ", L[2], "keV-1")
602
+ if Display: print("\t\t Efficiency of single events: ", round(efficiency_S[-1],5))
603
+ if Display: print("\t\t Efficiency of double events: ", round(efficiency_D[-1],5))
604
+ if Display: print("\t\t Efficiency of triple events: ", round(efficiency_T[-1],5))
605
+
606
+ else: # One decay event into the resolving time
607
+
608
+ daughter_relax = DaughterVec[index_rad][iDaughter]
609
+ for i_part in range(len(particle_vec)):
610
+ relaxation = False
611
+ if "Atom_K" in particle_vec[i_part] or "Atom_L" in particle_vec[i_part] or "Atom_M" in particle_vec[i_part]:
612
+ relaxation = True
613
+ while relaxation:
614
+ tf,ef = tl.relaxation_atom(daughter_relax,Rad[index_rad],particle_vec[i_part])
615
+ if tf == "XKA":
616
+ particle_vec[i_part] = "Atom_L"
617
+ particle_vec.append(tf)
618
+ energy_vec.append(ef)
619
+ relaxation = True
620
+ elif tf == "XKB":
621
+ particle_vec[i_part] = "Atom_M"
622
+ particle_vec.append(tf)
623
+ energy_vec.append(ef)
624
+ relaxation = False
625
+ elif tf == "XL":
626
+ particle_vec[i_part] = "Atom_M"
627
+ particle_vec.append(tf)
628
+ energy_vec.append(ef)
629
+ relaxation = False
630
+ elif tf == "Auger K":
631
+ particle_vec[i_part] = "Atom_L"
632
+ particle_vec.append(tf)
633
+ energy_vec.append(ef)
634
+ relaxation = True
635
+ elif tf == "Auger L":
636
+ particle_vec[i_part] = "Atom_M"
637
+ particle_vec.append(tf)
638
+ energy_vec.append(ef)
639
+ relaxation = False
640
+ else:
641
+ if Display: print("untermined x or Auger")
642
+ relaxation = False
643
+ e_sum += ef
644
+ if Display:
645
+ print("\t Summary of the atomic relaxation")
646
+ for i, p in enumerate(particle_vec):
647
+ if p[:4] != "Atom":
648
+ print(f"\t\t energy of {p} = ", round(energy_vec[i],3), "keV")
649
+
650
+ '''
651
+ ==========================================================
652
+ III.a SPECTRES D'EMISSION
653
+ ==========================================================
654
+ '''
655
+
466
656
  for i, p in enumerate(particle_vec):
467
- if p[:4] != "Atom": print(f"\t\t quenched energy of {p} = ", round(e_quenching[i],3), "keV")
657
+ if p == "beta":
658
+ e_b,p_b = tl.readBetaShape(rad_i,"beta-",level_before_trans) # read the data of BetaShape
659
+ index_beta_energy = tl.sampling(p_b) # sampling energy of beta
660
+ particle_vec[i] = "electron"
661
+ energy_vec[i] = e_b[index_beta_energy]
662
+
663
+ if p == "beta+":
664
+ e_b,p_b = tl.readBetaShape(rad_i,"beta+",level_before_trans)
665
+ index_beta_energy = tl.sampling(p_b)
666
+ particle_vec[i] = "positron"
667
+ energy_vec[i] = e_b[index_beta_energy]
668
+ particle_vec.append("gamma")
669
+ particle_vec.append("gamma")
670
+ energy_vec.append(511)
671
+ energy_vec.append(511)
672
+ energy_vec_initial = energy_vec
673
+ if Display:
674
+ print("\t Summary of emitted particles")
675
+ for i, p in enumerate(particle_vec):
676
+ if p[:4] != "Atom": print(f"\t\t energy of {p} = ", round(energy_vec[i],3), "keV")
468
677
 
469
- '''
470
- ====================
471
- V. LE MESURE TDCR
472
- ====================
473
- '''
474
- if mode2=="sym":
475
- p_nosingle = np.exp(-L*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
476
- p_single = 1-p_nosingle # probability to have at least 1 electrons in a PMT
477
- efficiency_S.append(p_single)
478
- efficiency_T.append(p_single**3)
479
- efficiency_D.append(3*(p_single)**2-2*efficiency_T[-1])
480
- if Display: print("\t Summary of TDCR measurement")
481
- if Display: print("\t\t Free parameter = ", L, "keV-1")
482
- if Display: print("\t\t Efficiency of single events = ", round(efficiency_S[-1],5))
483
- if Display: print("\t\t Efficiency of double events = ", round(efficiency_D[-1],5))
484
- if Display: print("\t\t Efficiency of triple events = ", round(efficiency_T[-1],5))
485
- elif mode2=="asym":
486
- pA_nosingle = np.exp(-L[0]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
487
- pA_single = 1-pA_nosingle # probability to have at least 1 electrons in a PMT
488
- pB_nosingle = np.exp(-L[1]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
489
- pB_single = 1-pB_nosingle # probability to have at least 1 electrons in a PMT
490
- pC_nosingle = np.exp(-L[2]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
491
- pC_single = 1-pC_nosingle # probability to have at least 1 electrons in a PMT
678
+
679
+ '''
680
+ ==========================================================
681
+ III.b INTERACTION RAYONNEMENT/MATIERE
682
+ ==========================================================
683
+ '''
684
+ for i, p in enumerate(particle_vec):
685
+ if p == "electron":
686
+ energy_vec[i] = tl.energie_dep_beta(energy_vec[i])
687
+
688
+ if p == "beta+":
689
+ energy_vec[i] = tl.energie_dep_beta(energy_vec[i])
690
+
691
+ if p == "gamma" or p == "XKA" or p == "XKB" or p == "XL":
692
+ energy_vec[i] = tl.energie_dep_gamma(energy_vec[i],v=V) # sampling energy free from photon
693
+ particle_vec[i] = "electron"
694
+
695
+ if p == "Auger K" or p == "Auger L":
696
+ particle_vec[i] = "electron"
697
+ energy_vec[i] = tl.energie_dep_beta(energy_vec[i])
698
+
699
+ if Display:
700
+ print("\t Summary of the energy deposited by charged particles")
701
+ for i, p in enumerate(particle_vec):
702
+ if p[:4] != "Atom": print(f"\t\t energy of {p} = ", round(energy_vec[i],3), "keV")
492
703
 
493
- efficiency_AB.append(pA_single*pB_single)
494
- efficiency_BC.append(pB_single*pC_single)
495
- efficiency_AC.append(pA_single*pC_single)
496
- efficiency_T.append(pA_single*pB_single*pC_single)
497
- efficiency_D.append(efficiency_AB[-1]+efficiency_BC[-1]+efficiency_AC[-1]-2*efficiency_T[-1])
498
- efficiency_S.append(pA_single+pB_single+pC_single-efficiency_D[-1]-efficiency_T[-1])
499
- if Display: print("\t Summary of TDCR measurement")
500
- if Display: print("\t\t Free parameter PMT A: ", L[0], "keV-1")
501
- if Display: print("\t\t Free parameter PMT B: ", L[1], "keV-1")
502
- if Display: print("\t\t Free parameter PMT C: ", L[2], "keV-1")
503
- if Display: print("\t\t Efficiency of single events: ", round(efficiency_S[-1],5))
504
- if Display: print("\t\t Efficiency of double events: ", round(efficiency_D[-1],5))
505
- if Display: print("\t\t Efficiency of triple events: ", round(efficiency_T[-1],5))
704
+ '''
705
+ ====================
706
+ IV. LA SCINTILLATION
707
+ Calculation of the scintillation quenching with the Birks Model
708
+ ====================
709
+ '''
710
+ # changer l'intégration E_i - E_d à E_i
711
+ if Display: print("\t Summary of the estimation of quenched energies")
712
+ e_quenching=[]
713
+ for i, p in enumerate(particle_vec):
714
+ if p == "alpha":
715
+ energy_vec[i] = tl.Em_a(energy_vec[i],kB,nE_alpha)
716
+ e_quenching.append(energy_vec[i])
717
+ elif p == "electron" or p == "positron":
718
+ energy_vec[i] = tl.Em_e(energy_vec_initial[i]*1e3,energy_vec[i]*1e3,kB*1e3,nE_electron)*1e-3
719
+ e_quenching.append(energy_vec[i])
720
+ else:
721
+ e_quenching.append(0)
722
+ if Display: print("\t\t Birks constant = ", kB, ' cm/keV')
723
+ if Display:
724
+ for i, p in enumerate(particle_vec):
725
+ if p[:4] != "Atom": print(f"\t\t quenched energy of {p} = ", round(e_quenching[i],3), "keV")
726
+
727
+ '''
728
+ ====================
729
+ V. LE MESURE TDCR
730
+ ====================
731
+ '''
732
+ if mode2=="sym":
733
+ p_nosingle = np.exp(-L*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
734
+ p_single = 1-p_nosingle # probability to have at least 1 electrons in a PMT
735
+ efficiency_S.append(p_single)
736
+ efficiency_T.append(p_single**3)
737
+ efficiency_D.append(3*(p_single)**2-2*efficiency_T[-1])
738
+ if Display: print("\t Summary of TDCR measurement")
739
+ if Display: print("\t\t Free parameter = ", L, "keV-1")
740
+ if Display: print("\t\t Efficiency of single events = ", round(efficiency_S[-1],5))
741
+ if Display: print("\t\t Efficiency of double events = ", round(efficiency_D[-1],5))
742
+ if Display: print("\t\t Efficiency of triple events = ", round(efficiency_T[-1],5))
743
+ elif mode2=="asym":
744
+ pA_nosingle = np.exp(-L[0]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
745
+ pA_single = 1-pA_nosingle # probability to have at least 1 electrons in a PMT
746
+ pB_nosingle = np.exp(-L[1]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
747
+ pB_single = 1-pB_nosingle # probability to have at least 1 electrons in a PMT
748
+ pC_nosingle = np.exp(-L[2]*np.sum(np.asarray(e_quenching))/3) # probability to have 0 electrons in a PMT
749
+ pC_single = 1-pC_nosingle # probability to have at least 1 electrons in a PMT
750
+
751
+ efficiency_AB.append(pA_single*pB_single)
752
+ efficiency_BC.append(pB_single*pC_single)
753
+ efficiency_AC.append(pA_single*pC_single)
754
+ efficiency_T.append(pA_single*pB_single*pC_single)
755
+ efficiency_D.append(efficiency_AB[-1]+efficiency_BC[-1]+efficiency_AC[-1]-2*efficiency_T[-1])
756
+ efficiency_S.append(pA_single+pB_single+pC_single-efficiency_D[-1]-efficiency_T[-1])
757
+ if Display: print("\t Summary of TDCR measurement")
758
+ if Display: print("\t\t Free parameter PMT A: ", L[0], "keV-1")
759
+ if Display: print("\t\t Free parameter PMT B: ", L[1], "keV-1")
760
+ if Display: print("\t\t Free parameter PMT C: ", L[2], "keV-1")
761
+ if Display: print("\t\t Efficiency of single events: ", round(efficiency_S[-1],5))
762
+ if Display: print("\t\t Efficiency of double events: ", round(efficiency_D[-1],5))
763
+ if Display: print("\t\t Efficiency of triple events: ", round(efficiency_T[-1],5))
506
764
 
507
765
  '''
508
766
  ====================
@@ -532,27 +790,12 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
532
790
  TBCmodel = mean_efficiency_T/mean_efficiency_BC
533
791
  TACmodel = mean_efficiency_T/mean_efficiency_AC
534
792
 
535
-
536
- # x = np.arange(np.mean(efficiency_T),1.001,0.001)
537
- # plt.figure("efficiency distribution")
538
- # plt.clf()
539
- # plt.hist(np.asarray(efficiency_D),bins=x,label="Efficiency of double coincidences")[0]
540
- # plt.hist(np.asarray(efficiency_T),bins=x,label="Efficiency of triple coincidences")[0]
541
- # plt.xlabel("Efficiency", fontsize = 14)
542
- # plt.ylabel(r"Number of counts", fontsize = 14)
543
- # plt.legend(fontsize = 12)
544
- # plt.savefig('Effdistribution.png')
545
-
546
- # x = np.arange(np.mean(tdcr),1.001,0.001)
547
- # plt.figure("TDCR distribution")
548
- # plt.clf()
549
- # plt.hist(np.asarray(tdcr),bins=x,label="Calculated TDCR")[0]
550
- # plt.plot(x,st.norm.pdf(x, TDCR_measure, u_TDCR_measure),label="measured TDCR")[0]
551
- # plt.xlabel("Efficiency", fontsize = 14)
552
- # plt.ylabel(r"Number of counts", fontsize = 14)
553
- # plt.legend(fontsize = 12)
554
- # plt.savefig('TDCRdistribution.png')
555
793
 
794
+ '''
795
+ ======================
796
+ VI. RETURN THE RESULTS
797
+ ======================
798
+ '''
556
799
  if mode2=="sym":
557
800
  res=(TDCR_calcul-TD)**2
558
801
  elif mode2=="asym":
@@ -565,4 +808,25 @@ def TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=Fals
565
808
  print("Warning. too low number of MC trials - inaccurate estimation")
566
809
  return mean_efficiency_S, 1, mean_efficiency_D, 1, mean_efficiency_T, 1
567
810
  else:
568
- return mean_efficiency_S, std_efficiency_S, mean_efficiency_D, std_efficiency_D, mean_efficiency_T, std_efficiency_T
811
+ return mean_efficiency_S, std_efficiency_S, mean_efficiency_D, std_efficiency_D, mean_efficiency_T, std_efficiency_T
812
+ if mode =="dis":
813
+ return efficiency_S, efficiency_D, efficiency_T
814
+
815
+
816
+
817
+ # L = (1, 1, 1)
818
+ # TD = 0.977667386529166
819
+ # TAB = 0.992232838598821
820
+ # TBC = 0.992343419459002
821
+ # TAC = 0.99275350064608
822
+ # Rad="Co-60"
823
+ # pmf_1="1"
824
+ # N = 10
825
+ # kB =1.0e-5
826
+ # V = 10
827
+ # mode = "dis"
828
+ # mode2 = "asym"
829
+
830
+
831
+ # S,D,T = TDCRPy(L, TD, TAB, TBC, TAC, Rad, pmf_1, N, kB, V, mode, mode2, Display=True, barp=False, uncData=False)
832
+ # # tl.display_distrib(S,D,T)
tdcrpy/TDCR_model_lib.py CHANGED
@@ -13,6 +13,7 @@ Bureau International des Poids et Mesures
13
13
  """
14
14
 
15
15
  import importlib.resources
16
+ from importlib.resources import files
16
17
  import pkg_resources
17
18
  import configparser
18
19
  import numpy as np
@@ -21,14 +22,16 @@ import time
21
22
  import re
22
23
  import os
23
24
  import scipy.interpolate as interp
25
+ import matplotlib.pyplot as plt
24
26
 
25
27
  """
26
28
  ======= Import ressource data =======
27
29
  """
28
30
 
29
31
  # import advanced configuration data
32
+
30
33
  config = configparser.ConfigParser()
31
- with importlib.resources.path('tdcrpy', 'config.toml') as data_path:
34
+ with importlib.resources.as_file(files('tdcrpy').joinpath('config.toml')) as data_path:
32
35
  file_conf = data_path
33
36
  config.read(file_conf)
34
37
  RHO = config["Inputs"].getfloat("density")
@@ -38,22 +41,26 @@ depthSpline = config["Inputs"].getint("depthSpline")
38
41
  Einterp = config["Inputs"].getfloat("Einterp")
39
42
 
40
43
  # import PenNuc data
41
- with importlib.resources.path('tdcrpy', 'decayData') as data_path:
44
+ with importlib.resources.as_file(files('tdcrpy').joinpath('decayData')) as data_path:
45
+ #with importlib.resources.path('tdcrpy', 'decayData') as data_path:
42
46
  file_pennuc = data_path / "All-nuclides_PenNuc.zip"
43
47
  z_PenNuc = zf.ZipFile(file_pennuc)
44
48
 
45
49
  # import BetaShape data
46
- with importlib.resources.path('tdcrpy', 'decayData') as data_path:
50
+ with importlib.resources.as_file(files('tdcrpy').joinpath('decayData')) as data_path:
51
+ #with importlib.resources.path('tdcrpy', 'decayData') as data_path:
47
52
  file_betashape = data_path / "All-nuclides_BetaShape.zip"
48
53
  z_betashape = zf.ZipFile(file_betashape)
49
54
 
50
55
  # import ENSDF data
51
- with importlib.resources.path('tdcrpy', 'decayData') as data_path:
56
+ with importlib.resources.as_file(files('tdcrpy').joinpath('decayData')) as data_path:
57
+ #with importlib.resources.path('tdcrpy', 'decayData') as data_path:
52
58
  file_ensdf = data_path / 'All-nuclides_Ensdf.zip'
53
59
  z_ensdf = zf.ZipFile(file_ensdf)
54
60
 
55
61
  # import photon interaction data (MCNP6 calculation)
56
- with importlib.resources.path('tdcrpy', 'MCNP-MATRIX') as data_path:
62
+ with importlib.resources.as_file(files('tdcrpy').joinpath('MCNP-MATRIX')) as data_path:
63
+ #with importlib.resources.path('tdcrpy', 'MCNP-MATRIX') as data_path:
57
64
  fp1 = data_path / 'matrice/fichier/matrice_10ml-photon_1_200k.txt' #gamma-10ml-1-200keV-niveau 0
58
65
  fp2 = data_path / 'matrice/fichier/matrice_10ml-photon_200_2000k.txt' #gamma-10ml-200-2000keV-niveau 1
59
66
  fp3 = data_path / 'matrice/fichier/matrice_10ml-photon_2000_10000k.txt' #gamma-10ml-2000-10000keV-niveau 2
@@ -63,7 +70,8 @@ with importlib.resources.path('tdcrpy', 'MCNP-MATRIX') as data_path:
63
70
  fe = data_path / 'matrice/fichier/E_depose.txt'
64
71
 
65
72
  # import electron interaction data (MCNP6 calculation)
66
- with importlib.resources.path('tdcrpy', 'MCNP-MATRIX') as data_path:
73
+ with importlib.resources.as_file(files('tdcrpy').joinpath('MCNP-MATRIX')) as data_path:
74
+ #with importlib.resources.path('tdcrpy', 'MCNP-MATRIX') as data_path:
67
75
  fe1 = data_path / 'matrice/fichier/matrice_10ml-beta-_1_200k.txt' # electron-10ml-1-200keV-niveau 0
68
76
  fe2 = data_path / 'matrice/fichier/matrice_10ml-beta-_200_2000k.txt' # electron-10ml-200-2000keV-niveau 1
69
77
  fe3 = data_path / 'matrice/fichier/matrice_10ml-beta-_2000_10000k.txt' # electron-10ml-2000-10000keV-niveau 2
@@ -72,7 +80,8 @@ with importlib.resources.path('tdcrpy', 'MCNP-MATRIX') as data_path:
72
80
  fe = data_path / 'matrice/fichier/E_depose.txt' # electron-10ml-énergie-niveau 'e'
73
81
 
74
82
  # import beta spectra calculated for the analytical model (BetaShape + MCNP6 calculation)
75
- with importlib.resources.path('tdcrpy', 'MCNP-MATRIX') as data_path:
83
+ with importlib.resources.as_file(files('tdcrpy').joinpath('MCNP-MATRIX')) as data_path:
84
+ #with importlib.resources.path('tdcrpy', 'MCNP-MATRIX') as data_path:
76
85
  sH3 = data_path / 'Spectra_for_analytical_model/dep_spectrum_H-3.txt'
77
86
  sC14 = data_path / 'Spectra_for_analytical_model/dep_spectrum_C-14.txt'
78
87
  sS35 = data_path / 'Spectra_for_analytical_model/dep_spectrum_S-35.txt'
@@ -85,7 +94,8 @@ with importlib.resources.path('tdcrpy', 'MCNP-MATRIX') as data_path:
85
94
  sPu241 = data_path / 'Spectra_for_analytical_model/dep_spectrum_Pu-241.txt'
86
95
 
87
96
  # import stopping power data for electron
88
- with importlib.resources.path('tdcrpy', 'Quenching') as data_path:
97
+ with importlib.resources.as_file(files('tdcrpy').joinpath('Quenching')) as data_path:
98
+ #with importlib.resources.path('tdcrpy', 'Quenching') as data_path:
89
99
  file_TanXia = open(data_path / "TandataUG.txt")
90
100
 
91
101
  data_TanXia=file_TanXia.read(); file_TanXia.close()
@@ -94,9 +104,10 @@ for i, x in enumerate(data_TanXia):
94
104
  if i<len(data_TanXia)-1: data_TanXia_f[i]=float(x)
95
105
 
96
106
  # import stopping power data for electron for alpha particle (ASTAR data)
97
- with importlib.resources.path('tdcrpy', 'Quenching') as data_path:
107
+ with importlib.resources.as_file(files('tdcrpy').joinpath('Quenching')) as data_path:
108
+ #with importlib.resources.path('tdcrpy', 'Quenching') as data_path:
98
109
  f_alpha = open(data_path / "alpha_toulene.txt")
99
-
110
+
100
111
  data_ASTAR = f_alpha.readlines()
101
112
  f_alpha.close()
102
113
  energy_alph = []
@@ -110,7 +121,8 @@ for i in range(np.size(data_ASTAR)):
110
121
 
111
122
  # import pre-calculated quenched energy tables
112
123
  kB_a = [6e-6, 7e-6, 8e-6, 9e-6, 1e-5, 1.1e-5, 1.2e-5, 1.3e-5, 1.4e-5, 1.5e-5] # cm/MeV
113
- with importlib.resources.path('tdcrpy', 'Quenching') as data_path:
124
+ with importlib.resources.as_file(files('tdcrpy').joinpath('Quenching')) as data_path:
125
+ #with importlib.resources.path('tdcrpy', 'Quenching') as data_path:
114
126
  Ei_alpha_fid = open(data_path / "inputVecteurAlpha.txt")
115
127
  Ei_alpha = Ei_alpha_fid.readlines()
116
128
  Ei_alpha = Ei_alpha[0].split(" ")
@@ -118,7 +130,8 @@ Ei_alpha = [float(x) for x in Ei_alpha[:-1]]
118
130
 
119
131
  Em_alpha = []
120
132
  for ikB in kB_a:
121
- with importlib.resources.path('tdcrpy', 'Quenching') as data_path:
133
+ with importlib.resources.as_file(files('tdcrpy').joinpath('Quenching')) as data_path:
134
+ #with importlib.resources.path('tdcrpy', 'Quenching') as data_path:
122
135
  tamptxt = "QuenchEnergyAlpha_"+str(ikB)+".txt"
123
136
  fid = open(data_path / tamptxt)
124
137
  line = fid.readlines()
@@ -127,7 +140,8 @@ for ikB in kB_a:
127
140
  Em_alpha.append(line)
128
141
 
129
142
  kB_e = [0.006, 0.007, 0.008, 0.009, 0.010, 0.011, 0.012, 0.013, 0.014, 0.015] # cm/MeV
130
- with importlib.resources.path('tdcrpy', 'Quenching') as data_path:
143
+ with importlib.resources.as_file(files('tdcrpy').joinpath('Quenching')) as data_path:
144
+ #with importlib.resources.path('tdcrpy', 'Quenching') as data_path:
131
145
  Ei_electron_fid = open(data_path / "inputVecteurElectron.txt")
132
146
  Ei_electron = Ei_electron_fid.readlines()
133
147
  Ei_electron = Ei_electron[0].split(" ")
@@ -135,7 +149,8 @@ Ei_electron = [float(x) for x in Ei_electron[:-1]]
135
149
 
136
150
  Em_electron = []
137
151
  for ikB in kB_e:
138
- with importlib.resources.path('tdcrpy', 'Quenching') as data_path:
152
+ with importlib.resources.as_file(files('tdcrpy').joinpath('Quenching')) as data_path:
153
+ #with importlib.resources.path('tdcrpy', 'Quenching') as data_path:
139
154
  tamptxt = "QuenchEnergyElectron_"+str(ikB)+".txt"
140
155
  fid = open(data_path / tamptxt)
141
156
  line = fid.readlines()
@@ -143,6 +158,7 @@ for ikB in kB_e:
143
158
  line = [float(x) for x in line[:-1]]
144
159
  Em_electron.append(line)
145
160
 
161
+
146
162
  """
147
163
  ======= Library of functions =======
148
164
  """
@@ -239,7 +255,10 @@ def readPenNuc2(rad,z1=z_PenNuc):
239
255
  list of energy levels -- indice 13. It contains a sub-list for all possible branches of a given daughter nucleus and a sub-sub list related to possible decay mode of each branch.
240
256
  prob_tran_tot : list[list]
241
257
  list of sum of transition of each branches -- indice 14. It contains a sub-list for all possible branches of a given daughter nucleus and a sub-sub list related to possible decay mode of each branch.
242
-
258
+ half_life : list
259
+ list of half_life of meta state -- indice 15.
260
+ uncertainty_tot : list[list]
261
+ list of uncertainty of probability associated with transitions -- indice 16. It contains a sub-list for all possible branches of a given daughter nucleus and a sub-sub list related to possible decay mode of each branch.
243
262
  '''
244
263
  doc = rad + ".PenNuc.txt"
245
264
  with z1.open(doc) as file_P:
@@ -321,8 +340,10 @@ def readPenNuc2(rad,z1=z_PenNuc):
321
340
  desin_type_tot=[];desin_energy_tot=[];desin_prob_tot=[];desin_level_tot=[]
322
341
  tran_type_tot=[];tran_energy_tot=[];tran_prob_tot=[];tran_level_end_tot=[];
323
342
  tran_level_tot=[];level_energy_tot=[]
324
- prob_branch_tot=[];prob_tran_tot=[]
325
-
343
+ prob_branch_tot=[];prob_tran_tot=[]
344
+ uncertainty_tot = []
345
+ half_life_tot = []
346
+
326
347
  '''
327
348
  =============
328
349
  LOOP DAUGHTER
@@ -357,7 +378,10 @@ def readPenNuc2(rad,z1=z_PenNuc):
357
378
  tran_type_daug=[];tran_energy_daug=[];tran_prob_daug=[];tran_level_end_daug=[];
358
379
  tran_level_daug=[];level_energy_daug=[]
359
380
  prob_branch_daug=[];prob_tran_daug=[]
360
-
381
+ uncertainty = []
382
+ half_life = []
383
+
384
+
361
385
  for i3 in range(len(posi_end_i)-1):
362
386
  start_p1 = posi_end_i[i3]
363
387
  end_p1 = posi_end_i[i3+1]
@@ -376,7 +400,9 @@ def readPenNuc2(rad,z1=z_PenNuc):
376
400
  tran_type_b=[];tran_prob_b=[];tran_energy_b=[]; tran_level_end_b=[];
377
401
  tran_level_b=[];level_energy_b=[]
378
402
  desin_type_b=[];desin_energy_b=[];desin_prob_b=[];desin_level_b=[];
379
-
403
+ uncertainty_b = []
404
+ half_life_b = []
405
+
380
406
  for i4 in decayData[start_p1+1:end_p1]:
381
407
  if start_p1+1 == end_p1:
382
408
  break
@@ -414,10 +440,11 @@ def readPenNuc2(rad,z1=z_PenNuc):
414
440
  if "LED" == i4[0]:
415
441
  tran_level_b.append(int(i4[-1]))
416
442
  level_energy_b.append(float(i4[1]))
443
+ half_life_b.append(float(i4[4]))
417
444
  if i4[0] == "GA" or i4[0] == "EK" or i4[0] == "EL" or i4[0] == "EL1" or i4[0] == "EL2" or i4[0] == "EL3" or i4[0] == "EM" or i4[0] == "EN":
418
- #print(i4)
419
445
  tran_type_b.append(i4[0])
420
446
  tran_prob_b.append(float(i4[1]))
447
+ uncertainty_b.append(float(i4[2]))
421
448
  tran_energy_b.append(float(i4[3]))
422
449
  tran_level_end_b.append(int(i4[5]))
423
450
  if branch:
@@ -428,12 +455,14 @@ def readPenNuc2(rad,z1=z_PenNuc):
428
455
 
429
456
  if transition:
430
457
  tran_type_daug.append(tran_type_b)
458
+ uncertainty.append(uncertainty_b)
431
459
  tran_energy_daug.append(tran_energy_b)
432
460
  tran_prob_daug.append(tran_prob_b)
433
461
  tran_level_end_daug.append(tran_level_end_b)
434
462
  tran_level_daug.append(tran_level_b)
435
463
  level_energy_daug.append(level_energy_b)
436
-
464
+ half_life.append(half_life_b)
465
+
437
466
  if len(desin_prob_b)>0:
438
467
  desin_prob_array = np.array(desin_prob_b)
439
468
  prob_branch_i = np.sum(desin_prob_array)
@@ -454,11 +483,13 @@ def readPenNuc2(rad,z1=z_PenNuc):
454
483
 
455
484
  tran_type_daug.append([])
456
485
  tran_prob_daug.append([])
486
+ uncertainty.append([])
457
487
  tran_energy_daug.append([])
458
488
  tran_level_end_daug.append([])
459
489
  tran_level_daug.append([])
460
490
  level_energy_daug.append([])
461
491
  prob_tran_daug.append(0)
492
+ half_life.append([])
462
493
 
463
494
  desin_type_tot.append(desin_type_daug)
464
495
  desin_energy_tot.append(desin_energy_daug)
@@ -473,9 +504,14 @@ def readPenNuc2(rad,z1=z_PenNuc):
473
504
  level_energy_tot.append(level_energy_daug)
474
505
  prob_branch_tot.append(prob_branch_daug)
475
506
  prob_tran_tot.append(prob_tran_daug)
476
- out = [daughter,prob_daug,energy_Q,desin_type_tot,desin_energy_tot,desin_prob_tot,desin_level_tot,prob_branch_tot,tran_type_tot,tran_energy_tot,tran_prob_tot,tran_level_tot,tran_level_end_tot,level_energy_tot,prob_tran_tot]
507
+ half_life_tot.append(half_life)
508
+ uncertainty_tot.append(uncertainty)
509
+
510
+ out = [daughter,prob_daug,energy_Q,desin_type_tot,desin_energy_tot,desin_prob_tot,desin_level_tot,prob_branch_tot,tran_type_tot,tran_energy_tot,tran_prob_tot,tran_level_tot,tran_level_end_tot,level_energy_tot,prob_tran_tot,half_life_tot,uncertainty_tot]
477
511
  return out
478
512
 
513
+
514
+
479
515
  #================================== StoppingPower for alpha particle ===========================================
480
516
 
481
517
  def stoppingpowerA(e,rho=RHO,energy_alpha=energy_alph,dEdx_alpha=dEdx_alph):
@@ -1611,6 +1647,36 @@ distribution: https://pypi.org/project/TDCRPy \n\
1611
1647
  developement: https://github.com/RomainCoulon/TDCRPy \n\n\
1612
1648
  start calculation..."
1613
1649
 
1614
- # Start Calculation
1650
+ # Start Calculation
1615
1651
  print(header_text)
1616
1652
  print(header_text2)
1653
+
1654
+ def display_distrib(S, D, T):
1655
+ n=len(D)
1656
+ x = np.arange(0,1.1,0.01)
1657
+ D=np.asarray(D)
1658
+ T=np.asarray(T)
1659
+ meanD=np.mean(D)
1660
+ meanT=np.mean(T)
1661
+ # tdcr=T/D
1662
+ plt.figure("efficiency distribution")
1663
+ plt.clf()
1664
+ plt.hist(np.asarray(D),bins=x,label="Double coincidences")[0]
1665
+ plt.hist(np.asarray(T),bins=x,label="Triple coincidences")[0]
1666
+ plt.scatter(meanD,n,marker='o',s=200,color='orange',label="mean value for Double coincidences")
1667
+ plt.scatter(meanT,n,marker='o',s=200,color='blue',label="mean value for Triple coincidences")
1668
+ plt.yscale("log")
1669
+ plt.xlabel("Efficiency", fontsize = 14)
1670
+ plt.ylabel(r"Number of counts", fontsize = 14)
1671
+ plt.legend(fontsize = 12)
1672
+ plt.show()
1673
+ # plt.savefig('Effdistribution.png')
1674
+
1675
+ # plt.figure("TDCR distribution")
1676
+ # plt.clf()
1677
+ # plt.hist(np.asarray(tdcr),bins=x,label="calculated TDCR")[0]
1678
+ # # plt.plot(x,st.norm.pdf(x, TDCR_measure, u_TDCR_measure),label="measured TDCR")[0]
1679
+ # plt.xlabel("Efficiency", fontsize = 14)
1680
+ # plt.ylabel(r"Number of counts", fontsize = 14)
1681
+ # plt.legend(fontsize = 12)
1682
+ # # plt.savefig('TDCRdistribution.png')
tdcrpy/config.toml CHANGED
@@ -25,6 +25,10 @@ Z = 5.2
25
25
  # mean mass number of the scintillator (LS cocktail + aqueous solution)
26
26
  A = 11.04
27
27
 
28
+ ## PROPERTIES OF THE COUNTER
29
+ # Coincidence resolving time (ns)
30
+ tau = 50
31
+
28
32
  ## INTERPOLATION TO ESTIMATE THE QUENCHED ENERGY
29
33
  # depth (number of indexes on each side of the energy point) on which the spline interpolation is done.
30
34
  depthSpline = 5
File without changes