89 #include "TRestAxionBufferGas.h"
92 #include "TRestSystemOfUnits.h"
117 RESTDebug <<
"Entering TRestAxionBufferGas constructor( cfgFileName, name )" <<
RESTendl;
153 while (gasDefinition) {
155 if (gasName.Contains(
"+")) {
156 TString gasDensity =
GetFieldValue(
"density", gasDefinition);
159 Double_t gasDensity = GetDblParameterWithUnits(
"density", gasDefinition);
193 std::vector<string> names =
Split((
string)gasMixture,
"+");
194 std::vector<string> densities;
195 if (gasDensities ==
"0")
198 densities =
Split((
string)gasDensities,
"+");
200 if (!densities.empty() && names.size() == densities.size()) {
201 for (
unsigned int n = 0; n < names.size(); n++) {
205 }
else if (densities.empty()) {
206 for (
unsigned int n = 0; n < names.size(); n++) {
210 this->
SetError(
"SetGasMixture. Number of gases does not match the densities!");
221 RESTError <<
"TRestAxionBufferGas::GetGasDensity. Gas name : " << gasName <<
" not found!"
240 TString factorFileName =
SearchFile((
string)gasName +
".nff");
242 RESTDebug <<
"TRestAxionBufferGas::ReadGasData. Reading factor file : " << factorFileName <<
RESTendl;
245 RESTError <<
"TRestAxionBufferGas::ReadGasData( " << gasName <<
" )" <<
RESTendl;
246 RESTError <<
"Gas factor file not found : " << factorFileName <<
RESTendl;
251 FILE* fin = fopen(factorFileName.Data(),
"rt");
255 std::vector<Double_t> energyFactor;
256 std::vector<Double_t> factor;
259 while (fscanf(fin,
"%lf\t%lf\n", &en, &value) != EOF) {
260 RESTDebug <<
"Energy : " << en <<
"keV -- Factor : " << value <<
RESTendl;
262 energyFactor.push_back(en);
263 factor.push_back(value);
266 RESTDebug <<
"Items read : " << energyFactor.size() <<
RESTendl;
271 TString absFileName =
SearchFile((
string)gasName +
".abs");
273 RESTDebug <<
"TRestAxionBufferGas::ReadGasData. Reading factor file : " << absFileName <<
RESTendl;
276 RESTError <<
"TRestAxionBufferGas::ReadGasData( " << gasName <<
" )" <<
RESTendl;
277 RESTError <<
"Gas absorption file not found : " << absFileName <<
RESTendl;
282 fin = fopen(absFileName.Data(),
"rt");
284 std::vector<Double_t> energyAbs;
285 std::vector<Double_t> absorption;
288 while (fscanf(fin,
"%lf\t%lf\n", &en, &value) != EOF) {
289 RESTDebug <<
"Energy : " << en <<
"keV -- Absorption : " << value <<
RESTendl;
291 energyAbs.push_back(en);
292 absorption.push_back(value);
295 RESTDebug <<
"Items read : " << energyAbs.size() <<
RESTendl;
321 RESTDebug <<
"TRestAxionBufferGas::GetFormFactor. Gas index = " << gasIndex <<
RESTendl;
323 if (gasIndex == -1) {
328 if (gasIndex == -1) {
329 RESTError <<
"TRestAxionBufferGas::GetFormFactor. Gas: " << gasName <<
" Not Found!" <<
RESTendl;
334 RESTDebug <<
"Energy index : " << energyIndex <<
RESTendl;
336 if (energyIndex == -1) {
337 RESTError <<
"TRestAxionBufferGas::GetFormFactor. Energy (" << energy <<
" keV) out of range"
350 double m = (y2 - y1) / (x2 - x1);
351 double n = y1 - m * x1;
353 if (m * energy + n < 0) {
354 RESTError <<
"TRestAxionBufferGas::GetAbsorptionCoefficient. Negative coefficient" <<
RESTendl;
355 cout <<
"y2 : " << y2 <<
" y1 : " << y1 << endl;
356 cout <<
"x2 : " << x2 <<
" x1 : " << x1 << endl;
357 cout <<
"m : " << m <<
" n : " << n << endl;
358 cout <<
"E : " << energy <<
" bin : " << energyIndex << endl;
362 return (m * energy + n);
370 Double_t attLength = 0;
399 Double_t photonMass = 0;
402 RESTError <<
"TRestAxionBufferGas::GetDensityForMass gas has not been defined!" <<
RESTendl;
405 Double_t W_value = 0;
413 RESTError <<
"Gas name : " <<
fBufferGasName[n] <<
" is not implemented in TRestBufferGas!!"
415 RESTError <<
"W value must be defined in TRestAxionBufferGas::GetPhotonMass" <<
RESTendl;
416 RESTError <<
"This gas will not contribute to the calculation of the photon mass!" <<
RESTendl;
423 return 28.77 * TMath::Sqrt(photonMass);
437 Double_t massDensity = 0;
440 RESTError <<
"TRestAxionBufferGas::GetDensityForMass gas has not been defined!" <<
RESTendl;
443 RESTError <<
"TRestAxionBufferGas::GetDensityForMass gas this method is only for sinale gas mixtures!"
446 Double_t W_value = 0;
454 RESTError <<
"Gas name : " <<
fBufferGasName[0] <<
" is not implemented in TRestAxionBufferGas!!"
456 RESTError <<
"W value must be defined in TRestAxionBufferGas::GetDensityForMass" <<
RESTendl;
457 RESTError <<
"This gas will not contribute to the calculation of the photon mass!" <<
RESTendl;
463 return massDensity /
units(
"g/cm^3");
472 RESTDebug <<
"TRestAxionBufferGas::GetAbsorptionCoefficient. Gas index = " << gasIndex <<
RESTendl;
474 if (gasIndex == -1) {
479 if (gasIndex == -1) {
480 RESTError <<
"TRestAxionBufferGas::GetAbsorptionCoefficient. Gas: " << gasName <<
" Not Found!"
486 RESTDebug <<
"Energy index : " << energyIndex <<
RESTendl;
488 if (energyIndex == -1) {
489 RESTError <<
"TRestAxionBufferGas::GetAbsorptionCoefficient. Energy out of range" <<
RESTendl;
498 double x2 =
fAbsEnergy[gasIndex][energyIndex + 1];
499 double x1 =
fAbsEnergy[gasIndex][energyIndex];
501 double m = (y2 - y1) / (x2 - x1);
502 double n = y1 - m * x1;
504 if (m * energy + n < 0) {
505 RESTError <<
"TRestAxionBufferGas::GetAbsorptionCoefficient. Negative coeffient" <<
RESTendl;
506 cout <<
"y2 : " << y2 <<
" y1 : " << y1 << endl;
507 cout <<
"x2 : " << x2 <<
" x1 : " << x1 << endl;
508 cout <<
"m : " << m <<
" n : " << n << endl;
509 cout <<
"E : " << energy <<
" bin : " << energyIndex << endl;
513 return (m * energy + n);
520 for (
unsigned int n = 0; n < enVector.size(); n++)
521 if (energy < enVector[n])
return n - 1;
532 for (
int n = 0; n < nGases; n++)
548 for (
unsigned int n = 0; n <
fAbsEnergy[gasIndex].size(); n++)
549 cout <<
"energy : " <<
fAbsEnergy[gasIndex][n]
560 for (
unsigned int n = 0; n <
fAbsEnergy[gasIndex].size(); n++)
573 RESTMetadata <<
"Buffer medium is vacuum" <<
RESTendl;
577 RESTMetadata <<
"Buffer gases inside mixture : " <<
RESTendl;
578 RESTMetadata <<
"---------------------------" <<
RESTendl;
583 RESTMetadata <<
" Form factor energy range : ( " <<
fFactorEnergy[n][0] <<
", "
585 RESTMetadata <<
" Absorption energy range : ( " <<
fAbsEnergy[n][0] <<
", "
591 RESTMetadata <<
"+++++++++++++++++++++++++++++++++++++++++++++++++" <<
RESTendl;
A metadata class to define the gas properties used in axion search calculations.
TRestAxionBufferGas()
Default constructor.
Int_t GetNumberOfGases()
It returns the number of gases in the mixture.
void Initialize()
Initialization of TRestAxionBufferGas members. It removes all gases.
void InitFromConfigFile()
Initialization of TRestAxionBufferGas field members through a RML file.
void PrintMetadata()
Prints on screen the information about the metadata members of TRestAxionBufferGas.
Double_t cmToeV(double l_Inv)
It transforms cm-1 to eV.
std::vector< std::vector< Double_t > > fGasFormFactor
Gas form factor.
void PrintFormFactorGasData(TString gasName)
Prints out the atomic form factors as function of the energy for the given gas component,...
std::vector< std::vector< Double_t > > fGasAbsCoefficient
Gas absorption coefficient in cm2/g.
Int_t GetEnergyIndex(std::vector< Double_t > enVector, Double_t energy)
It returns the vector element index, from enVector, that is just below the given input energy.
Double_t GetPhotonMass(double en)
It returns the equivalent photon mass (in eV) for the gas mixture at the given input energy expressed...
std::vector< std::vector< Double_t > > fFactorEnergy
Energy values for gas form factor in keV.
std::vector< Double_t > fBufferGasDensity
Gas density of the corresponding gasName in g/cm3.
Double_t GetGasDensity(TString gasName)
It returns the gas density - from the chosen gasName component - in g/cm3.
void ReadGasData(TString gasName)
It reads the data files from the corresponding gas component.
Double_t GetDensityForMass(double m_gamma, double en=4.2)
It returns the equivalent gas density for a given photon mass expressed in eV and a given axion energ...
void SetGasDensity(TString gasName, Double_t density)
It adds a new gas component to the mixture. If it already exists it will update its density.
Int_t FindGasIndex(TString gName)
It returns the internal index of the gas component given by gasName.
std::vector< TString > fBufferGasName
Name of the buffer gas (He, Ne, Ar, Xe, ..., etc )
void PrintAbsorptionGasData(TString gasName)
Prints out the absorption coefficients as function of the energy for the given gas component,...
Double_t GetPhotonAbsorptionLengthIneV(Double_t energy)
It returns the inverse of the absorption lenght, for the gas mixture, in eV, for the given energy in ...
void SetGasMixture(TString gasMixture, TString gasDensities="0")
It re-initializes the gas mixture to the one provided by argument.
std::vector< std::vector< Double_t > > fAbsEnergy
Energy values for gas absorption coefficient in keV.
Double_t GetAbsorptionCoefficient(TString gasName, Double_t energy)
It returns the absorption coefficient, in cm2/g, for the given gas component and energy in keV.
Double_t GetFormFactor(TString gasName, Double_t energy)
It returns the atomic form factor of the gasName component at the given energy.
Double_t GetPhotonAbsorptionLength(Double_t energy)
It returns the inverse of the absorption lenght, for the gas mixture, in cm-1, for the given energy i...
~TRestAxionBufferGas()
Default destructor.
@ REST_Info
+show most of the information for each steps
constexpr double PhMeterIneV
A meter in eV.
Int_t GetChar(std::string hint="Press a KEY to continue ...")
Helps to pause the program, printing a message before pausing.
std::vector< std::string > Split(std::string in, std::string separator, bool allowBlankString=false, bool removeWhiteSpaces=false, int startPos=-1)
Split the input string according to the given separator. Returning a vector of fragments.
This namespace defines the unit conversion for different units which are understood by REST.
Double_t GetValueInRESTUnits(std::string in)
It scales a physics measurement with its units into a REST default units value.