This repository was archived by the owner on May 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdark_brem.py
More file actions
118 lines (94 loc) · 3.55 KB
/
Copy pathdark_brem.py
File metadata and controls
118 lines (94 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
"""Configuration module for dark brem simulation"""
class DarkBremModel() :
"""Storage for parameters of a dark brem model
All other models should inherit from this class
in order to keep the correct internal parameters.
Parameters
----------
name : str
Name of this dark brem model
"""
def __init__(self,name) :
self.name = name
def __str__(self) :
string = '%s {'%self.name
for key in self.__dict__ :
if key is not self.name :
string += ' %s=%s'%( key , self.__dict__[key] )
string += ' }'
return string
class G4DarkBreMModel(DarkBremModel) :
"""Configuration for the event library dark brem model
This model uses G4DarkBreM's library model. The library
can be a directory of LHE files, gzip-compressed LHE files,
a CSV processed by G4DarkBreM, or a gzip-compressed CSV
processed by G4DarkBreM.
Parameters
----------
library_path : str
Path to library holding the dark brem kinematics
Attributes
----------
method : str
Interpretation method for LHE files
threshold : float
Minimum energy [GeV] that electron should have for dark brem to have nonzero xsec
epsilon : float
Epsilon for dark brem xsec calculation
"""
def __init__(self, library_path) :
super().__init__('g4db')
self.library_path = library_path
self.method = 'forward_only'
self.threshold = 2.0 #GeV
self.epsilon = 0.01
# for legacy reasons, we define another name for the G4DB model
VertexLibraryModel = G4DarkBreMModel
class DarkBrem:
"""Storage for parameters of dark brem process
Attributes
----------
ap_mass : float
Mass of A' in MeV
enable : bool
Should we use the custom Geant4 dark brem process? (Default: No)
only_one_per_event : bool
Should we deactivate the process after one dark brem or allow for more than one? (Default: No)
cache_xsec : bool
Should we cache the xsec's computed from the model? (Default: yes)
model : DarkBremModel
The model that should be use for dark bremming
"""
def __init__(self) :
self.ap_mass = 0.
self.only_one_per_event = False
self.enable = False #off by default
self.cache_xsec = True
self.model = DarkBremModel('UNDEFINED')
def activate(self, ap_mass, model = None) :
"""Activate the dark brem process with the input A' mass [MeV] and dark brem model
If no dark brem model is given, we do not activate the process
and only define the A' mass. This allows for some backwards
compatibility by allowing users to use the LHEPrimaryGenerator
with A' particles.
"""
self.ap_mass = ap_mass
if model is not None :
if not isinstance(model,DarkBremModel) :
raise Exception('Dark brem process needs to be configured with an associated DarkBremModel.')
self.enable = True
self.model = model
def __str__(self):
"""Stringify the DarkBrem configuration
Returns
-------
str
A human-readable version of all its attributes
"""
string = "{ Enabled: %r"%self.enable
if self.enable :
string += ", Mass: %.1f MeV"%self.ap_mass
string += ", Only One Per Event: %r"%self.only_one_per_event
string += ", Model: %s"%self.model
string += " }"
return string