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
void SetPressure(Double_t pressure) override
Defines the pressure of the gas.

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
Double_t GetLongitudinalDiffusion(Double_t E)
It returns the longitudinal diffusion in (cm)^1/2 for a given electric field in V/cm.
Double_t GetDriftVelocity(Double_t E)
It returns the drift velocity in cm/us for a given electric field in V/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)
 This method tries to find the gas filename given in the argument. More...
 
bool GasFileGenerationEnabled () const
 Returns true if the file generation is enabled. False otherwise.
 
bool GasFileLoaded () const
 Returns true if the gas file has been properly loaded. False otherwise.
 
Double_t GetAttachmentCoefficient () override
 
Double_t GetDriftVelocity () override
 Returns the drift velocity in mm/us.
 
Double_t GetGasComponentFraction (Int_t n)
 Returns the gas fraction in volume for component n.
 
TString GetGasComponentName (Int_t n)
 Returns the gas component n.
 
MediumMagboltz * GetGasMedium () const
 Return pointer to Garfield::MediumGas for gas properties.
 
TString GetGasMixture ()
 Returns a string defining the gas components and fractions.
 
void GetGasWorkFunction ()
 
TString GetGDMLMaterialRef () const
 Return reference name of the corresponding material in GDML file.
 
Double_t GetLongitudinalDiffusion () override
 Returns the longitudinal diffusion in (cm)^1/2.
 
Double_t GetMaxElectronEnergy () const
 
Int_t GetNofGases () const
 Returns the number of gas elements/compounds present in the gas mixture.
 
Double_t GetTownsendCoefficient () override
 
Double_t GetTransversalDiffusion () override
 Returns the transversal diffusion in (cm)^1/2.
 
void InitFromRootFile () override
 Method called after the object is retrieved from root file.
 
void Initialize () override
 Defines the metadata section name and initalizes the TRestDetectorGas members.
 
void LoadGasFile ()
 It loads a pre-generated gas file corresponding to the gas defined using the RML TRestDetectorGas section. More...
 
void PlotDriftVelocity (Double_t eMin, Double_t eMax, Int_t nSteps)
 It creates a TCanvas where it plots the drift velocity as a function of the electric field. More...
 
void PlotLongitudinalDiffusion (Double_t eMin, Double_t eMax, Int_t nSteps)
 It creates a TCanvas where it plots the longitudinal diffusion as a function of the electric field. More...
 
void PlotTownsendCoefficient (Double_t eMin, Double_t eMax, Int_t nSteps)
 It creates a TCanvas where it plots the townsend coefficient as a function of the electric field. More...
 
void PlotTransversalDiffusion (Double_t eMin, Double_t eMax, Int_t nSteps)
 It creates a TCanvas where it plots the transversal diffusion as a function of the electric field. More...
 
void PrintGasFileContent ()
 
void PrintGasInfo ()
 Prints the metadata information from the gas.
 
void PrintMetadata () override
 Prints the metadata information from the gas.
 
void SetMaxElectronEnergy (Double_t energy)
 Sets the maximum electron energy to be used in gas generation.
 
void SetPressure (Double_t pressure) override
 Defines the pressure of the gas. More...
 
void SetTemperature (Double_t temperature) override
 Defines the temperature of the gas.
 
 TRestDetectorGas ()
 TRestDetectorGas default constructor.
 
 TRestDetectorGas (const char *configFilename, std::string name="", bool gasGeneration=false, bool test=false)
 TRestDetectorGas constructor loading data from a config file. More...
 
Int_t Write (const char *name=0, Int_t option=0, Int_t bufsize=0) override
 overwriting the write() method with fStore considered
 
 ~TRestDetectorGas ()
 TRestDetectorGas default destructor.
 
- Public Member Functions inherited from TRestDetectorDriftVolume
 ClassDefOverride (TRestDetectorDriftVolume, 1)
 
virtual Double_t GetElectricField () const
 Returns the electric field in V/mm.
 
virtual Double_t GetElectronLifeTime ()
 
virtual std::string GetMaterial () const
 
virtual Double_t GetPressure () const
 
virtual Double_t GetTemperature () const
 
virtual Double_t GetW () const
 
virtual Double_t GetWvalue () const
 
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.
 
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.
 
 TRestDetectorDriftVolume (const char *configFilename, std::string name="")
 
virtual void UpdateCondition ()
 

Private Member Functions

void AddGasComponent (std::string gasName, Double_t fraction)
 Adds a new element/compound to the gas. More...
 
std::string ConstructFilename ()
 Constructs the filename of the pre-generated gas file using the members defined in the RML file. More...
 
void GenerateGasFile ()
 Save a gas file with a structured file name.
 
Double_t GetAttachmentCoefficient (Double_t E)
 It returns the attachment coefficient for a given electric field in V/cm.
 
Double_t GetDriftVelocity (Double_t E)
 It returns the drift velocity in cm/us for a given electric field in V/cm.
 
Double_t GetLongitudinalDiffusion (Double_t E)
 It returns the longitudinal diffusion in (cm)^1/2 for a given electric field in V/cm.
 
Double_t GetTownsendCoefficient (Double_t E)
 It returns the townsend coefficient for a given electric field in V/cm.
 
Double_t GetTransversalDiffusion (Double_t E)
 It returns the transversal diffusion in (cm)^1/2 for a given electric field in V/cm.
 
void InitFromConfigFile () override
 Loads the gas parameters that define the gas calculation and properties. 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()

TRestDetectorGas::TRestDetectorGas ( const char *  configFilename,
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.

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

Member Function Documentation

◆ AddGasComponent()

void TRestDetectorGas::AddGasComponent ( std::string  gasName,
Double_t  fraction 
)
private

Adds a new element/compound to the gas.

This method is private to make gas intialization possible only through an RML file. This might change if necessary.

Parameters
gasNameA gas element/compound name valid in Garfield++.
fractionThe element fraction in volume.

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

◆ ConstructFilename()

string TRestDetectorGas::ConstructFilename ( )
private

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.

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

◆ 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.

◆ FindGasFile()

string TRestDetectorGas::FindGasFile ( std::string  name)

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

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

◆ 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.

◆ InitFromConfigFile()

void TRestDetectorGas::InitFromConfigFile ( )
overrideprivatevirtual

Loads the gas parameters that define the gas calculation and properties.

These parameters will be used to define the pre-generated gas filename. The method TRestDetectorGas::ConstructFilename is used to define the filename format.

Reimplemented from TRestDetectorDriftVolume.

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

◆ LoadGasFile()

void TRestDetectorGas::LoadGasFile ( )

It loads a pre-generated gas file corresponding to the gas defined using the RML TRestDetectorGas section.

If a pre-generated gas file is not found this method will launch the gas generation in case TRestDetectorGas::fGasGeneration is true. This must be activated using EnableGasGeneration() or at the class construction time.

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

◆ PlotDriftVelocity()

void TRestDetectorGas::PlotDriftVelocity ( Double_t  eMin,
Double_t  eMax,
Int_t  nSteps 
)

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

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

◆ PlotLongitudinalDiffusion()

void TRestDetectorGas::PlotLongitudinalDiffusion ( Double_t  eMin,
Double_t  eMax,
Int_t  nSteps 
)

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

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

◆ PlotTownsendCoefficient()

void TRestDetectorGas::PlotTownsendCoefficient ( Double_t  eMin,
Double_t  eMax,
Int_t  nSteps 
)

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

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

◆ PlotTransversalDiffusion()

void TRestDetectorGas::PlotTransversalDiffusion ( Double_t  eMin,
Double_t  eMax,
Int_t  nSteps 
)

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

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

◆ SetPressure()

void TRestDetectorGas::SetPressure ( Double_t  pressure)
override

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.

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

Field Documentation

◆ 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.

◆ 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.

◆ fStatus

Int_t TRestDetectorGas::fStatus
private

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

Definition at line 68 of file TRestDetectorGas.h.


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