REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
Public Member Functions | Private Member Functions | Private Attributes
TRestDetectorGas Class Reference

Detailed Description

A specific metadata class to generate and read gas files using Magboltz interface

This metadata class allows to define an arbitrary gas mixture. TRestDetectorGas provides access to different gas properties, such as drift velocity, diffusion, townsend coefficients, etc. TRestDetectorGas is a re-implementation of Garfield::MediumMagboltz allowing to generate or read gas Magboltz files, from which the gas properties are extracted.

Gas definition

This class defines metadata members that can be used to define a gas mixture of any number of components, the gas conditions, as pressure or temperature, and few other parameters required by Garfield to perform the gas properties calculation.

The following code shows an example of the implementation of the TRestDetectorGas section definition in an RML file.

<TRestDetectorGas name="Xenon 10-10E3Vcm" title="Xenon">
<parameter name="pressure" value="1" />
<parameter name="temperature" value="293.15" />
<parameter name="maxElectronEnergy" value="400" />
<parameter name="W_value" value="21.9" />
<parameter name="nCollisions" value="10" />
<eField Emin="10" Emax="1000." nodes="20" />
<gasComponent name="xe" fraction="1" />

All those parameters are required for the Magboltz calculation. Any number of gas components can be defined by adding new gasComponent lines to the TRestDetectorGas section, assuring first that the addition of the gas fractions equals 1. Any gas component defined at the gases table in the Garfield++ user guide can be used in REST. We use the same gas component name convention.

Pre-generated gas files

The calculation of the gas properties is computationally expensive and time consuming. In order to avoid this calculation, we keep some gas files containing the summary of the gas properties inside the directory inputdata/gasFiles. These files cover different conditions of gas and can be used if a new TRestDetectorGas object meets the condition among one of them. The TRestDetectorGas sections that were used to generate those gas files can be found at $REST_PATH/data/definitions/gases.rml.

Gas files will be searched by TRestDetectorGas in the paths that can be defined inside our main RML file through the section "searchPath" at the globals section (see TRestMetadata description for additional details).

<globals>
<searchPath value="${REST_INPUTDATA}/definitions/"/>
...
</globals>

If no gas files are found meets the current gas conditon, TRestDetectorGas will perform a single E calculation in the next Get() method, including GetDriftVelocity()/GetLongitudinalDiffusion(), etc. This usually takes several minutes. After the calculation, Get() methods can quickly return the result if input drift field doesn't change.

Better saving in root file

In the new verison, we save TRestDetectorGas together with the gas file(as a TString). So when retrieved from a root file, TRestDetectorGas is immediately ready after calling the method InitFromRootFile(). This makes "importMetadata" much easier in TRestRun. So we recommend to migrate gasFiles to root files.

<TRestDetectorGas name="Xenon 10-10E3Vcm" title="Xenon">
<parameter name="pressure" value="1" />
<parameter name="temperature" value="293.15" />
<parameter name="maxElectronEnergy" value="400" />
<parameter name="W_value" value="21.9" />
<parameter name="nCollisions" value="10" />
<eField Emin="10" Emax="1000." nodes="20" />
<gasComponent name="xe" fraction="1" />
</TRestDetectorGas> //may be slow if gas file does not exist
<addMetadata name="Xenon 10-10E3Vcm" file="gases.root"/> //better to use in
future
...
Data provider and manager in REST.
Definition: TRestRun.h:18

Instantiating TRestDetectorGas

The most common use of TRestDetectorGas starts by creating an instance of TRestDetectorGas giving as argument the RML configuration file and the name of the TRestDetectorGas section describing the gas we are willing to use in our event processing.

TRestDetectorGas *gas = new TRestDetectorGas( "gases.rml", "GasName" );
TRestDetectorGas()
TRestDetectorGas default constructor.

where GasName must be an existing TRestDetectorGas section with that name, GasName could be for example Xenon 10-10E3Vcm, found at gases.rml.

By default, the gas generation is disabled. So that we are warned by default of the inexistence of a pre-generated gas file. To force the generation of a gas file (requiring few hours of computation time), we can specify it at construction time as follows.

TRestDetectorGas *gas = new TRestDetectorGas( "config.rml", "GasName", true );

Using TRestDetectorGas to obtain gas properties

Once the gas file has been generated we can use it directly calling to the same RML gas section used to generate it.

TRestDetectorGas *gas = new TRestDetectorGas( "config.rml", "GasName" );

we can then modify some gas conditions as, i.e. the pressure,

gas->SetPressure( 5. ); // To set the gas pressure to 5 bar

then we could get the gas mixture properties, as drift velocity, or diffusion coefficients, at 5 bar by using

gas->GetDriftVelocity( 100. ); // To get the electron drift velocity at
100V/cm gas->GetLongitudinalDiffusion( 100. ); // To get the longitudinal
diffusion coefficient at 100V/cm

RESTsoft - Software for Rare Event Searches with TPCs

History of developments:

jan 2006: first concept (as MagboltzGas) Igor G. Irastorza

jul 2006: minor improvements for inclusion in RESTSoft (renamed as TMagboltzGas) Igor G. Irastorza

jul 2007: added a 3-compounds gas mixture constructor A. Tomas

apr 2012: minimal modifications for inclusion in new RESTSoft scheme A. Tomas

jun 2014: change name to TRestDetectorGas and minimal modifications for inclusion in new RESTSoft scheme Igor G. Irastorza

aug 2015: Major revision to introduce into REST v2.0. MediumMagboltz from Garfield++ is used now

Author
Igor G. Irastorza
Alfredo Tomas
Javier Galan

Definition at line 63 of file TRestDetectorGas.h.

#include <TRestDetectorGas.h>

Inheritance diagram for TRestDetectorGas:
TRestDetectorDriftVolume TRestMetadata

Public Member Functions

void CalcGarField (double Emin, double Emax, int n)
 
 ClassDefOverride (TRestDetectorGas, 3)
 
void EnableGasGeneration ()
 
std::string FindGasFile (std::string name)
 
bool GasFileGenerationEnabled () const
 Returns true if the file generation is enabled. False otherwise. More...
 
bool GasFileLoaded () const
 Returns true if the gas file has been properly loaded. False otherwise. More...
 
Double_t GetAttachmentCoefficient () override
 
Double_t GetDriftVelocity () override
 Returns the drift velocity in mm/us. More...
 
Double_t GetGasComponentFraction (Int_t n)
 Returns the gas fraction in volume for component n. More...
 
TString GetGasComponentName (Int_t n)
 Returns the gas component n. More...
 
Double_t GetGasFanoFactor () const
 Returns the gas fano factor.
 
MediumMagboltz * GetGasMedium () const
 Return pointer to Garfield::MediumGas for gas properties. More...
 
TString GetGasMixture ()
 
Double_t GetGasWorkFunction () const
 Returns the gas work function in eV.
 
void GetGasWorkFunctionOld ()
 
TString GetGDMLMaterialRef () const
 Return reference name of the corresponding material in GDML file. More...
 
Double_t GetLongitudinalDiffusion () override
 Returns the longitudinal diffusion in (cm)^1/2. More...
 
Double_t GetMaxElectronEnergy () const
 
Int_t GetNofGases () const
 Returns the number of gas elements/compounds present in the gas mixture. More...
 
Double_t GetTownsendCoefficient () override
 
Double_t GetTransversalDiffusion () override
 Returns the transversal diffusion in (cm)^1/2. More...
 
void InitFromRootFile () override
 Method called after the object is retrieved from root file. More...
 
void Initialize () override
 Making default settings. More...
 
void LoadGasFile ()
 
void PlotDriftVelocity (Double_t eMin, Double_t eMax, Int_t nSteps)
 
void PlotLongitudinalDiffusion (Double_t eMin, Double_t eMax, Int_t nSteps)
 
void PlotTownsendCoefficient (Double_t eMin, Double_t eMax, Int_t nSteps)
 
void PlotTransversalDiffusion (Double_t eMin, Double_t eMax, Int_t nSteps)
 
void PrintGasFileContent ()
 
void PrintGasInfo ()
 
void PrintMetadata () override
 Prints the metadata information from the gas. More...
 
void SetMaxElectronEnergy (Double_t energy)
 Sets the maximum electron energy to be used in gas generation. More...
 
void SetPressure (Double_t pressure) override
 
void SetTemperature (Double_t temperature) override
 
 TRestDetectorGas ()
 TRestDetectorGas default constructor. More...
 
 TRestDetectorGas (const char *configFilename, const std::string &name="", bool gasGeneration=false, bool test=false)
 TRestDetectorGas constructor loading data from a config file. More...
 
Int_t Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) override
 overwriting the write() method with fStore considered More...
 
- Public Member Functions inherited from TRestDetectorDriftVolume
 ClassDefOverride (TRestDetectorDriftVolume, 1)
 
virtual Double_t GetAttachmentCoefficient ()
 
virtual Double_t GetDriftVelocity ()
 Returns the drift velocity in mm/us. More...
 
virtual Double_t GetElectricField () const
 Returns the electric field in V/mm. More...
 
virtual Double_t GetElectronLifeTime ()
 
virtual Double_t GetLongitudinalDiffusion ()
 
virtual std::string GetMaterial () const
 
virtual Double_t GetPressure () const
 
virtual Double_t GetTemperature () const
 
virtual Double_t GetTownsendCoefficient ()
 
virtual Double_t GetTransversalDiffusion ()
 
virtual Double_t GetW () const
 
virtual Double_t GetWvalue () const
 
void InitFromConfigFile () override
 To make settings from rml file. This method must be implemented in the derived class. More...
 
void Initialize () override
 Making default settings. More...
 
void PrintMetadata () override
 Implemented it in the derived metadata class to print out specific metadata information. More...
 
virtual void SetAttachmentCoefficient (double value)
 
virtual void SetDriftVelocity (double value)
 
virtual void SetElectricField (double value)
 Sets the electric field. Must be given in V/mm. More...
 
virtual void SetElectronLifeTime (double value)
 
virtual void SetLongitudinalDiffusion (double value)
 
virtual void SetMaterial (std::string value)
 
virtual void SetPressure (double value)
 
virtual void SetTemperature (double value)
 
virtual void SetTownsendCoefficient (double value)
 
virtual void SetTransversalDiffusion (double value)
 
virtual void SetW (double value)
 Sets the electric field of the drift volume. Given in V/mm. More...
 
 TRestDetectorDriftVolume (const char *configFilename, std::string name="")
 
virtual void UpdateCondition ()
 

Private Member Functions

void AddGasComponent (const std::string &gasName, Double_t fraction)
 
std::string ConstructFilename ()
 
void GenerateGasFile ()
 
Double_t GetAttachmentCoefficient (Double_t E)
 
Double_t GetDriftVelocity (Double_t E)
 
Double_t GetLongitudinalDiffusion (Double_t E)
 
Double_t GetTownsendCoefficient (Double_t E)
 
Double_t GetTransversalDiffusion (Double_t E)
 
void InitFromConfigFile () override
 To make settings from rml file. This method must be implemented in the derived class. More...
 
void UploadGasToServer (std::string gasFilename)
 

Private Attributes

std::vector< Double_t > fAngles
 
std::vector< Double_t > fBFields
 
std::vector< Double_t > fEFields
 
Double_t fEmax
 
Double_t fEmin
 
Int_t fEnodes
 
std::vector< Double_t > fGasComponentFraction
 
std::vector< TString > fGasComponentName
 
TString fGasFileContent
 
TString fGasFilename
 
bool fGasGeneration
 
MediumMagboltz * fGasMedium
 
TString fGasOutputPath
 
TString fGasServer
 
TString fGDMLMaterialRef
 
Double_t fMaxElectronEnergy
 
Int_t fNCollisions
 
Int_t fNofGases
 
Int_t fStatus
 
Bool_t fTest = false
 

Additional Inherited Members

- Protected Attributes inherited from TRestDetectorDriftVolume
Double_t fAttachmentCoefficient
 
Double_t fDriftVelocity
 
Double_t fElectricField
 
Double_t fElectronLifeTime
 
Double_t fLongitudinalDiffusion
 
std::string fMaterial
 
Double_t fPressureInAtm
 
Double_t fTemperatureInK
 
Double_t fTownsendCoefficient
 
Double_t fTransversalDiffusion
 
Double_t fW
 

Constructor & Destructor Documentation

◆ TRestDetectorGas() [1/2]

TRestDetectorGas::TRestDetectorGas ( )

TRestDetectorGas default constructor.

Definition at line 231 of file src/TRestDetectorGas.cxx.

◆ TRestDetectorGas() [2/2]

TRestDetectorGas::TRestDetectorGas ( const char *  configFilename,
const std::string &  name = "",
bool  gasGeneration = false,
bool  test = false 
)

TRestDetectorGas constructor loading data from a config file.

This constructor will load the gas with properties defined inside the corresponding TRestDetectorGas section in an RML file. A pre-generated gas file will be loaded if found in TRestMetadata::GetSearchPath() which can be defined as an input parameter in the globals metadata section.

Parameters
configFilenameIt defines the path to an RML file containing a TRestDetectorGas section.
nameThe name of the TRestDetectorGas section to be read.
gasGenerationParameter allowing to activate the gas generation.

This method tries to find the gas filename given in the argument

First, this method will try to retrieve the gasFile from fGasServer. If the file is not found in the server, then we will try to find it locally. If not found, the gas will be generated if fGasGeneration has been enabled.

The gasFiles are retrieved by default from the gasFile server. In order to avoid this, and use locally generated gasFiles you need to set the metadata parameter fGasServer to none.

Returns
The filename with full path to the existing local filename

Returns a string defining the gas components and fractions.

Constructs the filename of the pre-generated gas file using the members defined in the RML file.

This method returns only the filename without including absolute or relative paths.

Save a gas file with a structured file name

Defines the pressure of the gas.

The gas pressure is used during gas file generation to define the E over P range. Once the gas file has been loaded, the pressure might be changed at any time, the gas properties requested will be valid for the given pressure.

Parameters
pressureThe new pressure of the gas in atm.

Defines the temperature of the gas.

It creates a TCanvas where it plots the drift velocity as a function of the electric field.

Parameters
eMinMinimum value of the electric field to be plotted in V/cm.
eMaxMaximum value of the electric field to be plotted in V/cm.
stepsNumber of points to be given to be drawn

It creates a TCanvas where it plots the longitudinal diffusion as a function of the electric field.

Parameters
eMinMinimum value of the electric field to be plotted in V/cm.
eMaxMaximum value of the electric field to be plotted in V/cm.
stepsNumber of points to be given to be drawn

It creates a TCanvas where it plots the transversal diffusion as a function of the electric field.

Parameters
eMinMinimum value of the electric field to be plotted in V/cm.
eMaxMaximum value of the electric field to be plotted in V/cm.
stepsNumber of points to be given to be drawn

It creates a TCanvas where it plots the townsend coefficient as a function of the electric field.

Parameters
eMinMinimum value of the electric field to be plotted in V/cm.
eMaxMaximum value of the electric field to be plotted in V/cm.
stepsNumber of points to be given to be drawn

It returns the drift velocity in cm/us for a given electric field in V/cm.

It returns the longitudinal diffusion in (cm)^1/2 for a given electric field in V/cm.

It returns the transversal diffusion in (cm)^1/2 for a given electric field in V/cm.

It returns the townsend coefficient for a given electric field in V/cm.

It returns the attachment coefficient for a given electric field in V/cm.

Prints the metadata information from the gas

Definition at line 249 of file src/TRestDetectorGas.cxx.

Member Function Documentation

◆ EnableGasGeneration()

void TRestDetectorGas::EnableGasGeneration ( )
inline

This enables the generation of the gas file if a non existing gas file is found.

Definition at line 136 of file TRestDetectorGas.h.

◆ GasFileGenerationEnabled()

bool TRestDetectorGas::GasFileGenerationEnabled ( ) const
inline

Returns true if the file generation is enabled. False otherwise.

Definition at line 139 of file TRestDetectorGas.h.

◆ GasFileLoaded()

bool TRestDetectorGas::GasFileLoaded ( ) const
inline

Returns true if the gas file has been properly loaded. False otherwise.

Definition at line 142 of file TRestDetectorGas.h.

◆ GetAttachmentCoefficient()

Double_t TRestDetectorGas::GetAttachmentCoefficient ( )
inlineoverridevirtual

Reimplemented from TRestDetectorDriftVolume.

Definition at line 216 of file TRestDetectorGas.h.

◆ GetDriftVelocity()

Double_t TRestDetectorGas::GetDriftVelocity ( )
inlineoverridevirtual

Returns the drift velocity in mm/us.

Reimplemented from TRestDetectorDriftVolume.

Definition at line 175 of file TRestDetectorGas.h.

◆ GetGasComponentFraction()

Double_t TRestDetectorGas::GetGasComponentFraction ( Int_t  n)
inline

Returns the gas fraction in volume for component n.

Definition at line 229 of file TRestDetectorGas.h.

◆ GetGasComponentName()

TString TRestDetectorGas::GetGasComponentName ( Int_t  n)
inline

Returns the gas component n.

Definition at line 164 of file TRestDetectorGas.h.

◆ GetGasMedium()

MediumMagboltz * TRestDetectorGas::GetGasMedium ( ) const
inline

Return pointer to Garfield::MediumGas for gas properties.

Definition at line 246 of file TRestDetectorGas.h.

◆ GetGDMLMaterialRef()

TString TRestDetectorGas::GetGDMLMaterialRef ( ) const
inline

Return reference name of the corresponding material in GDML file.

Definition at line 249 of file TRestDetectorGas.h.

◆ GetLongitudinalDiffusion()

Double_t TRestDetectorGas::GetLongitudinalDiffusion ( )
inlineoverridevirtual

Returns the longitudinal diffusion in (cm)^1/2.

Reimplemented from TRestDetectorDriftVolume.

Definition at line 185 of file TRestDetectorGas.h.

◆ GetMaxElectronEnergy()

Double_t TRestDetectorGas::GetMaxElectronEnergy ( ) const
inline

Returns the maximum electron energy used by Magboltz for the gas properties calculation

Definition at line 158 of file TRestDetectorGas.h.

◆ GetNofGases()

Int_t TRestDetectorGas::GetNofGases ( ) const
inline

Returns the number of gas elements/compounds present in the gas mixture.

Definition at line 161 of file TRestDetectorGas.h.

◆ GetTownsendCoefficient()

Double_t TRestDetectorGas::GetTownsendCoefficient ( )
inlineoverridevirtual

Reimplemented from TRestDetectorDriftVolume.

Definition at line 206 of file TRestDetectorGas.h.

◆ GetTransversalDiffusion()

Double_t TRestDetectorGas::GetTransversalDiffusion ( )
inlineoverridevirtual

Returns the transversal diffusion in (cm)^1/2.

Reimplemented from TRestDetectorDriftVolume.

Definition at line 196 of file TRestDetectorGas.h.

◆ InitFromConfigFile()

void TRestDetectorGas::InitFromConfigFile ( )
overrideprivatevirtual

To make settings from rml file. This method must be implemented in the derived class.

Reimplemented from TRestDetectorDriftVolume.

◆ InitFromRootFile()

void TRestDetectorGas::InitFromRootFile ( )
overridevirtual

Method called after the object is retrieved from root file.

Reimplemented from TRestMetadata.

◆ Initialize()

void TRestDetectorGas::Initialize ( )
overridevirtual

Making default settings.

Reimplemented from TRestDetectorDriftVolume.

◆ PrintGasFileContent()

void TRestDetectorGas::PrintGasFileContent ( )
inline

Definition at line 262 of file TRestDetectorGas.h.

◆ PrintMetadata()

void TRestDetectorGas::PrintMetadata ( )
inlineoverridevirtual

Prints the metadata information from the gas.

Reimplemented from TRestDetectorDriftVolume.

Definition at line 265 of file TRestDetectorGas.h.

◆ SetMaxElectronEnergy()

void TRestDetectorGas::SetMaxElectronEnergy ( Double_t  energy)
inline

Sets the maximum electron energy to be used in gas generation.

Definition at line 255 of file TRestDetectorGas.h.

◆ Write()

Int_t TRestDetectorGas::Write ( const char *  name = nullptr,
Int_t  option = 0,
Int_t  bufsize = 0 
)
overridevirtual

overwriting the write() method with fStore considered

Reimplemented from TRestMetadata.

Field Documentation

◆ fAngles

std::vector<Double_t> TRestDetectorGas::fAngles
private

Definition at line 93 of file TRestDetectorGas.h.

◆ fBFields

std::vector<Double_t> TRestDetectorGas::fBFields
private

Definition at line 91 of file TRestDetectorGas.h.

◆ fEFields

std::vector<Double_t> TRestDetectorGas::fEFields
private

Definition at line 89 of file TRestDetectorGas.h.

◆ fEmax

Double_t TRestDetectorGas::fEmax
private

Definition at line 84 of file TRestDetectorGas.h.

◆ fEmin

Double_t TRestDetectorGas::fEmin
private

Definition at line 86 of file TRestDetectorGas.h.

◆ fEnodes

Int_t TRestDetectorGas::fEnodes
private

Definition at line 83 of file TRestDetectorGas.h.

◆ fGasComponentFraction

std::vector<Double_t> TRestDetectorGas::fGasComponentFraction
private

Definition at line 80 of file TRestDetectorGas.h.

◆ fGasComponentName

std::vector<TString> TRestDetectorGas::fGasComponentName
private

Definition at line 78 of file TRestDetectorGas.h.

◆ fGasFileContent

TString TRestDetectorGas::fGasFileContent
private

The remote server from where we retrieve the gasFiles. If it is set to none local files will be used.

Definition at line 109 of file TRestDetectorGas.h.

◆ fGasFilename

TString TRestDetectorGas::fGasFilename
private

Definition at line 71 of file TRestDetectorGas.h.

◆ fGasGeneration

bool TRestDetectorGas::fGasGeneration
private

Definition at line 98 of file TRestDetectorGas.h.

◆ fGasMedium

MediumMagboltz* TRestDetectorGas::fGasMedium
private

Definition at line 65 of file TRestDetectorGas.h.

◆ fGasOutputPath

TString TRestDetectorGas::fGasOutputPath
private

If true, and the pre-generated Magboltz gas file is not found, it will allow to launch the gas generation.

Definition at line 102 of file TRestDetectorGas.h.

◆ fGasServer

TString TRestDetectorGas::fGasServer
private

A std::string to store the output path where a new generated gas file will be written

Definition at line 105 of file TRestDetectorGas.h.

◆ fGDMLMaterialRef

TString TRestDetectorGas::fGDMLMaterialRef
private

Definition at line 95 of file TRestDetectorGas.h.

◆ fMaxElectronEnergy

Double_t TRestDetectorGas::fMaxElectronEnergy
private

Definition at line 75 of file TRestDetectorGas.h.

◆ fNCollisions

Int_t TRestDetectorGas::fNCollisions
private

Definition at line 74 of file TRestDetectorGas.h.

◆ fNofGases

Int_t TRestDetectorGas::fNofGases
private

Definition at line 72 of file TRestDetectorGas.h.

◆ fStatus

Int_t TRestDetectorGas::fStatus
private

Pointer to Garfield::MediumMagboltz class giving access to gas properties

Definition at line 68 of file TRestDetectorGas.h.

◆ fTest

Bool_t TRestDetectorGas::fTest = false
private

Definition at line 111 of file TRestDetectorGas.h.


The documentation for this class was generated from the following files: