gVirtualXRay  2.0.10
VirtualX-RayImagingLibraryonGPU
Scintillator.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (c) 2022, Dr Franck P. Vidal (franck.p.vidal@fpvidal.net),
4 http://www.fpvidal.net/
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11 this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation and/or
15 other materials provided with the distribution.
16 
17 3. Neither the name of the Bangor University nor the names of its contributors
18 may be used to endorse or promote products derived from this software without
19 specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 
32 */
33 
34 
35 #ifndef __Scintillator_h
36 #define __Scintillator_h
37 
38 
68 //******************************************************************************
69 // Include
70 //******************************************************************************
71 #ifndef __gVirtualXRayConfig_h
73 #endif
74 
75 #include <string> // To store the material properties
76 #include <vector> // To store the energy response
77 #include <utility> // To create STL pairs
78 
79 #ifndef __PhotonCrossSection_h
81 #endif
82 
83 #ifndef __Types_h
84 #include "gVirtualXRay/Types.h"
85 #endif
86 
87 
88 //******************************************************************************
89 // namespace
90 //******************************************************************************
91 namespace gVirtualXRay {
92 
93 
94 //==============================================================================
100 //==============================================================================
102 //------------------------------------------------------------------------------
103 {
104 //******************************************************************************
105 public:
106  //--------------------------------------------------------------------------
108  //--------------------------------------------------------------------------
109  Scintillator();
110 
111 
112  //--------------------------------------------------------------------------
114  //--------------------------------------------------------------------------
115  ~Scintillator();
116 
117 
118  //--------------------------------------------------------------------------
120  //--------------------------------------------------------------------------
121  void release();
122 
123 
124  void setMaterial(const std::string& aMaterial);
125 
126 
127  //--------------------------------------------------------------------------
129 
132  //--------------------------------------------------------------------------
133  static std::vector<std::string> getSupportedScintillatorMaterials();
134 
135 
136  void setThickness(const RATIONAL_NUMBER& aThickness);
137 
138 
139  const std::string& getMaterial() const;
140 
141 
143 
144 
145  std::vector<std::pair<RATIONAL_NUMBER, RATIONAL_NUMBER> > getEnergyResponse() const;
146 
147 
148  static std::vector<std::pair<RATIONAL_NUMBER, RATIONAL_NUMBER> > getEnergyResponse(const std::string& aMaterial,
149  const RATIONAL_NUMBER& aThickness);
150 
151 
152  static RATIONAL_NUMBER getDensity(const std::string& aMaterial);
153 
154 
155  static std::string getCompound(const std::string& aMaterial);
156 
157 
158  //--------------------------------------------------------------------------
160 
165  //--------------------------------------------------------------------------
166  void loadEnergyResponse(const std::string& aFileName,
167  const RATIONAL_NUMBER& aUnitOfEnergy);
168 
169 
170  void setEnergyResponse(const std::vector<std::pair<float, float> >& anEnergyResponse);
171 
172 
173  void setEnergyResponse(const std::vector<std::pair<double, double> >& anEnergyResponse);
174 
175 
176  //--------------------------------------------------------------------------
178 
182  //--------------------------------------------------------------------------
183  RATIONAL_NUMBER applyEnergyResponse(const RATIONAL_NUMBER& anEnergy) const;
184 
185 
186 //******************************************************************************
187 protected:
188  //--------------------------------------------------------------------------
190 
193  //--------------------------------------------------------------------------
194  int findNearestEnergyIdx(const RATIONAL_NUMBER& anEnergy) const;
195 
196 
197  std::string m_material;
199 
201 
203  std::vector<std::pair<RATIONAL_NUMBER, RATIONAL_NUMBER> > m_p_energy_response;
204 
205 
206  // PhotonCrossSection m_photon_cross_section;
207 };
208 
209 
210 } // namespace gVirtualXRay
211 
212 
213 //******************************************************************************
214 #include "Scintillator.inl"
215 
216 
217 #endif // __Scintillator_h
RATIONAL_NUMBER m_thickness
Definition: Scintillator.h:200
Type declarations.
Scintillator is a class to generate the energy response due to the scintillator of the X-Ray detector...
Definition: Scintillator.h:101
static RATIONAL_NUMBER getDensity(const std::string &aMaterial)
int findNearestEnergyIdx(const RATIONAL_NUMBER &anEnergy) const
Find the index of the closest input energy in the energy response.
static std::vector< std::string > getSupportedScintillatorMaterials()
Accessor on the list of scintillator materials currently supported.
void setMaterial(const std::string &aMaterial)
RATIONAL_NUMBER getThickness()
const std::string & getMaterial() const
float RATIONAL_NUMBER
Type of data used to store real numbers.
Definition: Types.h:107
Class to manage photon cross sections of elements, compounds and mixtures.
RATIONAL_NUMBER m_density
Definition: Scintillator.h:198
std::vector< std::pair< RATIONAL_NUMBER, RATIONAL_NUMBER > > m_p_energy_response
Energy response. The keys of the map are the input energies.
Definition: Scintillator.h:203
static std::string getCompound(const std::string &aMaterial)
std::vector< std::pair< RATIONAL_NUMBER, RATIONAL_NUMBER > > getEnergyResponse() const
void setEnergyResponse(const std::vector< std::pair< float, float > > &anEnergyResponse)
void release()
Release the data.
void loadEnergyResponse(const std::string &aFileName, const RATIONAL_NUMBER &aUnitOfEnergy)
Load the energy response of the detector from a TSV file.
Scintillator()
Default constructor.
void setThickness(const RATIONAL_NUMBER &aThickness)
Class to generate the energy response due to the scintillator of the X-Ray detector.
RATIONAL_NUMBER applyEnergyResponse(const RATIONAL_NUMBER &anEnergy) const
Apply the energy response if any.