Skip to content

Commit

Permalink
Merge pull request #46 from rest-for-physics/GasMetadataValues_david
Browse files Browse the repository at this point in the history
TRestDetectorGas: Setting pressure for metadata values
  • Loading branch information
jgalan authored Sep 8, 2022
2 parents a873df7 + f774589 commit 9b37d6d
Show file tree
Hide file tree
Showing 22 changed files with 129 additions and 105 deletions.
3 changes: 2 additions & 1 deletion inc/TRestDetectorDaqChannelSwitchingProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ class TRestDetectorDaqChannelSwitchingProcess : public TRestEventProcess {
RESTMetadata << "module's daq channel re-definition: " << RESTendl;
auto iter = fFirstDaqChannelDef.begin();
while (iter != fFirstDaqChannelDef.end()) {
RESTMetadata << "module id: " << iter->first << " first daq channel: " << iter->second << RESTendl;
RESTMetadata << "module id: " << iter->first << " first daq channel: " << iter->second
<< RESTendl;
iter++;
}
RESTMetadata << RESTendl;
Expand Down
22 changes: 13 additions & 9 deletions inc/TRestDetectorGas.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,45 +176,49 @@ class TRestDetectorGas : public TRestDetectorDriftVolume {
if (fElectricField == 0) {
RESTWarning << "TRestDetectorGas::GetDriftVelocity. Warning fElectricField is zero!" << RESTendl;
RESTWarning << " - Use: TRestDetectorGas::SetElectricField( field[V/mm] ) to set the field value"
<< RESTendl;
<< RESTendl;
}
return GetDriftVelocity(fElectricField * units("V/cm")) / units("cm/us");
} // in standard unit mm/us

/// Returns the longitudinal diffusion in (cm)^1/2
Double_t GetLongitudinalDiffusion() const override {
if (fElectricField == 0) {
RESTWarning << "TRestDetectorGas::GetLongitudinalDiffusion. Warning fElectricField is zero!" << RESTendl;
RESTWarning << "TRestDetectorGas::GetLongitudinalDiffusion. Warning fElectricField is zero!"
<< RESTendl;
RESTWarning << " - Use: TRestDetectorGas::SetElectricField( field[V/mm] ) to set the field value"
<< RESTendl;
<< RESTendl;
}
return GetLongitudinalDiffusion(fElectricField * units("V/cm"));
}

/// Returns the transversal diffusion in (cm)^1/2
Double_t GetTransversalDiffusion() const override {
if (fElectricField == 0) {
RESTWarning << "TRestDetectorGas::GetTransversalDiffusion. Warning fElectricField is zero!" << RESTendl;
RESTWarning << "TRestDetectorGas::GetTransversalDiffusion. Warning fElectricField is zero!"
<< RESTendl;
RESTWarning << " - Use: TRestDetectorGas::SetElectricField( field[V/mm] ) to set the field value"
<< RESTendl;
<< RESTendl;
}
return GetTransversalDiffusion(fElectricField * units("V/cm"));
}

Double_t GetTownsendCoefficient() const override {
if (fElectricField == 0) {
RESTWarning << "TRestDetectorGas::GetTownsendCoefficient. Warning fElectricField is zero!" << RESTendl;
RESTWarning << "TRestDetectorGas::GetTownsendCoefficient. Warning fElectricField is zero!"
<< RESTendl;
RESTWarning << " - Use: TRestDetectorGas::SetElectricField( field[V/mm] ) to set the field value"
<< RESTendl;
<< RESTendl;
}
return GetTownsendCoefficient(fElectricField * units("V/cm"));
}

Double_t GetAttachmentCoefficient() const override {
if (fElectricField == 0) {
RESTWarning << "TRestDetectorGas::GetAttachmentCoefficient. Warning fElectricField is zero!" << RESTendl;
RESTWarning << "TRestDetectorGas::GetAttachmentCoefficient. Warning fElectricField is zero!"
<< RESTendl;
RESTWarning << " - Use: TRestDetectorGas::SetElectricField( field[V/mm] ) to set the field value"
<< RESTendl;
<< RESTendl;
}
return GetAttachmentCoefficient(fElectricField * units("V/cm"));
}
Expand Down
6 changes: 4 additions & 2 deletions inc/TRestDetectorHitsAnalysisProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ class TRestDetectorHitsAnalysisProcess : public TRestEventProcess {
RESTMetadata << " -------------------" << RESTendl;
RESTMetadata << " Fiducial parameters" << RESTendl;
RESTMetadata << " -------------------" << RESTendl;
RESTMetadata << " x0 : (" << fFid_x0.X() << " , " << fFid_x0.Y() << " , " << fFid_x0.Z() << ")" << RESTendl;
RESTMetadata << " x1 : (" << fFid_x1.X() << " , " << fFid_x1.Y() << " , " << fFid_x1.Z() << ")" << RESTendl;
RESTMetadata << " x0 : (" << fFid_x0.X() << " , " << fFid_x0.Y() << " , " << fFid_x0.Z() << ")"
<< RESTendl;
RESTMetadata << " x1 : (" << fFid_x1.X() << " , " << fFid_x1.Y() << " , " << fFid_x1.Z() << ")"
<< RESTendl;
RESTMetadata << " R : " << fFid_R << RESTendl;
RESTMetadata << " sX : " << fFid_sX << RESTendl;
RESTMetadata << " sY : " << fFid_sY << RESTendl;
Expand Down
6 changes: 3 additions & 3 deletions inc/TRestDetectorPositionMappingProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ class TRestDetectorPositionMappingProcess : public TRestEventProcess {

RESTMetadata << "the mode is:" << RESTendl;
RESTMetadata << (fApplyGainCorrection ? "> " : " ")
<< "Apply position correction std::map for spectrum " << RESTendl;
RESTMetadata << (fCreateGainMap ? "> " : " ") << "Create new correction std::map for each position"
<< RESTendl;
<< "Apply position correction std::map for spectrum " << RESTendl;
RESTMetadata << (fCreateGainMap ? "> " : " ")
<< "Create new correction std::map for each position" << RESTendl;
RESTMetadata << "output mapping file: " << fMappingSave << RESTendl;
RESTMetadata << "Energy cut for Threshold integral: " << any(fEnergyCutRange) << RESTendl;
RESTMetadata << "Energy cut for NGoodSignals: " << any(fNHitsCutRange) << RESTendl;
Expand Down
6 changes: 3 additions & 3 deletions inc/TRestDetectorSingleChannelAnalysisProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ class TRestDetectorSingleChannelAnalysisProcess : public TRestEventProcess {

RESTMetadata << "the mode is:" << RESTendl;
RESTMetadata << (fApplyGainCorrection ? "> " : " ")
<< "Apply channel correction std::map for spectrum " << RESTendl;
RESTMetadata << (fCreateGainMap ? "> " : " ") << "Create new correction std::map for each channel"
<< RESTendl;
<< "Apply channel correction std::map for spectrum " << RESTendl;
RESTMetadata << (fCreateGainMap ? "> " : " ")
<< "Create new correction std::map for each channel" << RESTendl;
RESTMetadata << "output mapping file: " << fCalibSave << RESTendl;
RESTMetadata << "Energy cut for Threshold integral: " << any(fThrIntegralCutRange) << RESTendl;
RESTMetadata << "Energy cut for NGoodSignals: " << any(fNGoodSignalsCutRange) << RESTendl;
Expand Down
2 changes: 1 addition & 1 deletion macros/REST_Detector_ViewHitsEvent.C
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "TRestBrowser.h"
#include "TRestTask.h"
#include "TRestDetectorHitsEvent.h"
#include "TRestTask.h"

#ifndef RestTask_ViewHitsEvents
#define RestTask_ViewHitsEvents
Expand Down
23 changes: 13 additions & 10 deletions src/TRestDetectorElectronDiffusionProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,28 @@ void TRestDetectorElectronDiffusionProcess::InitProcess() {
if (fGas == nullptr) {
if (fLonglDiffCoeff == -1 || fTransDiffCoeff == -1) {
RESTWarning << "Gas has not been initialized" << RESTendl;
RESTError << "TRestDetectorElectronDiffusionProcess: diffusion parameters are not defined in the rml "
"file!"
<< RESTendl;
RESTError
<< "TRestDetectorElectronDiffusionProcess: diffusion parameters are not defined in the rml "
"file!"
<< RESTendl;
exit(-1);
}
if (fWvalue == -1) {
RESTWarning << "Gas has not been initialized" << RESTendl;
RESTError << "TRestDetectorElectronDiffusionProcess: gas work function has not been defined in the "
"rml file!"
<< RESTendl;
RESTError
<< "TRestDetectorElectronDiffusionProcess: gas work function has not been defined in the "
"rml file!"
<< RESTendl;
exit(-1);
}
} else {
#ifndef USE_Garfield
RESTError << "A TRestDetectorGas definition was found but REST was not linked to Garfield libraries."
<< RESTendl;
RESTError << "Please, remove the TRestDetectorGas definition, and add gas parameters inside the process "
"TRestDetectorElectronDiffusionProcess"
<< RESTendl;
<< RESTendl;
RESTError
<< "Please, remove the TRestDetectorGas definition, and add gas parameters inside the process "
"TRestDetectorElectronDiffusionProcess"
<< RESTendl;
exit(1);
#endif
if (fGasPressure <= 0) fGasPressure = fGas->GetPressure();
Expand Down
12 changes: 8 additions & 4 deletions src/TRestDetectorGarfieldDriftProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ void TRestDetectorGarfieldDriftProcess::InitProcess() {
fGeometry->DefaultColors();
// fGeometry->UpdateElements();

cout << "TRestDetectorGarfieldDriftProcess GetVerboseLevel : " << static_cast<int>(this->GetVerboseLevel()) << endl;
cout << "TRestDetectorGarfieldDriftProcess GetVerboseLevel : "
<< static_cast<int>(this->GetVerboseLevel()) << endl;

// analyze GDML geometry to find major elements (gas volume, electrodes,
// readout)
Expand All @@ -176,7 +177,8 @@ void TRestDetectorGarfieldDriftProcess::InitProcess() {
itvol->Print();

TGeoMedium* itmed = itvol->GetMedium();
if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Info) cout << " * * itmed " << itmed->GetName() << endl;
if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Info)
cout << " * * itmed " << itmed->GetName() << endl;

// gas volume
if (fGas->GetGDMLMaterialRef() == itmed->GetName()) {
Expand All @@ -195,14 +197,16 @@ void TRestDetectorGarfieldDriftProcess::InitProcess() {
if ((strncmp(itvol->GetName(), "anodeVol", 8) == 0) ||
(strncmp(itvol->GetName(), "cathodeVol", 10) == 0)) {
fGeometry->SetDriftElecNode(itnode);
if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Info) cout << " -> cathode volume " << endl;
if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Info)
cout << " -> cathode volume " << endl;
cout << " -> cathode volume " << endl;
}

// micromegas readout electrode
if ((strncmp(itvol->GetName(), "micromegasVol", 13) == 0)) {
fGeometry->AddReadoutElecNode(itnode);
if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Info) cout << " -> readout volume " << endl;
if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Info)
cout << " -> readout volume " << endl;
cout << " -> readout volume " << endl;
}
}
Expand Down
47 changes: 25 additions & 22 deletions src/TRestDetectorGas.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,7 @@ void TRestDetectorGas::PlotTownsendCoefficient(Double_t eMin, Double_t eMax, Int
///
Double_t TRestDetectorGas::GetDriftVelocity(Double_t E) const {
RESTDebug << "Entering ... TRestDetectorGas::GetDriftVelocity( E=" << E << " )" << RESTendl;
this->SetPressure(fPressureInAtm);

#if defined USE_Garfield
if (fStatus != RESTGAS_GASFILE_LOADED) {
Expand Down Expand Up @@ -1061,6 +1062,7 @@ Double_t TRestDetectorGas::GetDriftVelocity(Double_t E) const {
///
Double_t TRestDetectorGas::GetLongitudinalDiffusion(Double_t E) const {
RESTDebug << "Entering ... TRestDetectorGas::GetLongitudinalDiffusion( E=" << E << " )" << RESTendl;
this->SetPressure(fPressureInAtm);

#if defined USE_Garfield
if (fStatus != RESTGAS_GASFILE_LOADED) {
Expand Down Expand Up @@ -1090,6 +1092,7 @@ Double_t TRestDetectorGas::GetLongitudinalDiffusion(Double_t E) const {
///
Double_t TRestDetectorGas::GetTransversalDiffusion(Double_t E) const {
RESTDebug << "Entering ... TRestDetectorGas::GetTransversalDiffusion( E=" << E << " )" << RESTendl;
this->SetPressure(fPressureInAtm);

#if defined USE_Garfield
if (fStatus != RESTGAS_GASFILE_LOADED) {
Expand Down Expand Up @@ -1119,20 +1122,20 @@ Double_t TRestDetectorGas::GetTransversalDiffusion(Double_t E) const {
///
Double_t TRestDetectorGas::GetTownsendCoefficient(Double_t E) const {
RESTDebug << "Entering ... TRestDetectorGas::GetTownsendCoefficient( E=" << E << " )" << RESTendl;
this->SetPressure(fPressureInAtm);

#if defined USE_Garfield
if (fStatus != RESTGAS_GASFILE_LOADED) {
RESTDebug << "-- Error : " << __PRETTY_FUNCTION__ << RESTendl;
RESTDebug << "-- Error : Gas file was not loaded!" << RESTendl;
return 0;
}
#if defined USE_Garfield if (fStatus != RESTGAS_GASFILE_LOADED) {
RESTDebug << "-- Error : " << __PRETTY_FUNCTION__ << RESTendl;
RESTDebug << "-- Error : Gas file was not loaded!" << RESTendl;
return 0;
}

RESTInfo << "Calling Garfield directly. Please be aware that the unit is different"
<< "from REST standard unit. E is V/cm. The return is V/cm" << RESTendl;
RESTInfo << "Calling Garfield directly. Please be aware that the unit is different"
<< "from REST standard unit. E is V/cm. The return is V/cm" << RESTendl;

Double_t alpha;
fGasMedium->ElectronTownsend(0., 0, -E, 0, 0, 0, alpha);
return alpha;
Double_t alpha;
fGasMedium->ElectronTownsend(0., 0, -E, 0, 0, 0, alpha);
return alpha;
#else
std::cout << "This REST is not complied with garfield, Do not use Townsend "
"Coefficient from TRestDetectorGas!"
Expand All @@ -1148,20 +1151,20 @@ Double_t TRestDetectorGas::GetTownsendCoefficient(Double_t E) const {
///
Double_t TRestDetectorGas::GetAttachmentCoefficient(Double_t E) const {
RESTDebug << "Entering ... TRestDetectorGas::GetAttachmentCoefficient( E=" << E << " )" << RESTendl;
this->SetPressure(fPressureInAtm);

#if defined USE_Garfield
if (fStatus != RESTGAS_GASFILE_LOADED) {
RESTDebug << "-- Error : " << __PRETTY_FUNCTION__ << RESTendl;
RESTDebug << "-- Error : Gas file was not loaded!" << RESTendl;
return 0;
}
#if defined USE_Garfield if (fStatus != RESTGAS_GASFILE_LOADED) {
RESTDebug << "-- Error : " << __PRETTY_FUNCTION__ << RESTendl;
RESTDebug << "-- Error : Gas file was not loaded!" << RESTendl;
return 0;
}

RESTInfo << "Calling Garfield directly. Please be aware that the unit is different"
<< "from REST standard unit. E is V/cm. The return is V/cm" << RESTendl;
RESTInfo << "Calling Garfield directly. Please be aware that the unit is different"
<< "from REST standard unit. E is V/cm. The return is V/cm" << RESTendl;

Double_t eta;
fGasMedium->ElectronAttachment(0., 0, -E, 0, 0, 0, eta);
return eta;
Double_t eta;
fGasMedium->ElectronAttachment(0., 0, -E, 0, 0, 0, eta);
return eta;
#else
std::cout << "This REST is not complied with garfield, Do not use Attachment "
"Coefficient from TRestDetectorGas!"
Expand Down
3 changes: 2 additions & 1 deletion src/TRestDetectorHits3DReconstructionProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ TRestEvent* TRestDetectorHits3DReconstructionProcess::ProcessEvent(TRestEvent* i

if (stripehits.size() > 50) {
RESTWarning << "(TRestDetectorHits3DReconstructionProcess) event id: " << fInputHitsEvent->GetID()
<< ", z: " << z << ", bad frame, too much hits! (" << stripehits.size() << ")" << RESTendl;
<< ", z: " << z << ", bad frame, too much hits! (" << stripehits.size() << ")"
<< RESTendl;
continue;
}

Expand Down
13 changes: 7 additions & 6 deletions src/TRestDetectorHitsToSignalProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,11 @@ void TRestDetectorHitsToSignalProcess::InitProcess() {
if (fGas != nullptr) {
#ifndef USE_Garfield
RESTError << "A TRestDetectorGas definition was found but REST was not linked to Garfield libraries."
<< RESTendl;
RESTError << "Please, remove the TRestDetectorGas definition, and add gas parameters inside the process "
"TRestDetectorHitsToSignalProcess"
<< RESTendl;
<< RESTendl;
RESTError
<< "Please, remove the TRestDetectorGas definition, and add gas parameters inside the process "
"TRestDetectorHitsToSignalProcess"
<< RESTendl;
if (!fGas->GetError()) fGas->SetError("REST was not compiled with Garfield.");
if (!this->GetError()) this->SetError("Attempt to use TRestDetectorGas without Garfield");
#endif
Expand Down Expand Up @@ -261,8 +262,8 @@ TRestEvent* TRestDetectorHitsToSignalProcess::ProcessEvent(TRestEvent* inputEven

} else {
if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Debug)
RESTDebug << "TRestDetectorHitsToSignalProcess. Readout channel not find for position (" << x
<< ", " << y << ", " << z << ")!" << RESTendl;
RESTDebug << "TRestDetectorHitsToSignalProcess. Readout channel not find for position ("
<< x << ", " << y << ", " << z << ")!" << RESTendl;
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/TRestDetectorPositionMappingProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ void TRestDetectorPositionMappingProcess::InitProcess() {
fGas = GetMetadata<TRestDetectorGas>();
if (fReadout == nullptr) {
if (fCreateGainMap) {
RESTError << "You must set a TRestDetectorReadout metadata object to create gain map!" << RESTendl;
RESTError << "You must set a TRestDetectorReadout metadata object to create gain map!"
<< RESTendl;
abort();
}
} else {
Expand All @@ -57,7 +58,8 @@ void TRestDetectorPositionMappingProcess::InitProcess() {

if (fApplyGainCorrection) {
if (fCalib == nullptr || fCalib->f2DGainMapping == nullptr) {
RESTError << "You must set a TRestDetectorGainMap metadata object to apply gain correction!" << RESTendl;
RESTError << "You must set a TRestDetectorGainMap metadata object to apply gain correction!"
<< RESTendl;
abort();
}
}
Expand Down
Loading

0 comments on commit 9b37d6d

Please sign in to comment.