diff --git a/CMakeLists.txt b/CMakeLists.txt index bfd56990a..94e03ca7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,46 +1,29 @@ -set( LibraryVersion "1.6" ) +set(LibraryVersion "1.6") add_definitions(-DLIBRARY_VERSION="${LibraryVersion}") -#find garfield libs and includes -IF (NOT DEFINED REST_GARFIELD) +if (NOT DEFINED REST_GARFIELD OR NOT REST_GARFIELD) set(REST_GARFIELD OFF) -ENDIF () - -if (${REST_GARFIELD} MATCHES "ON") - add_definitions(-DUSE_Garfield) - - if (DEFINED ENV{GARFIELD_INSTALL}) - # Tested for Garfield af4a14516489babbd6e6df780edd58fedf7fa12b - message(STATUS "Using new Garfield CMake") - set(GARFIELD_INSTALL $ENV{GARFIELD_INSTALL}) - find_package(Garfield REQUIRED) - set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/include/Garfield) - set(external_libs ${external_libs} Garfield::Garfield) - # recommended CMake way does not work, we need to delete the "FindGarfield.cmake" script - elseif (DEFINED ENV{GARFIELD_HOME}) - # Old way, for backwards compatibility - message(STATUS "Using old Garfield CMake") - set(GARFIELD_INSTALL $ENV{GARFIELD_HOME}) - include(FindGarfieldOld) - message(STATUS Garfield_INCLUDE_DIRS ${Garfield_INCLUDE_DIRS}) - message(STATUS Garfield_INCLUDE_DIRS ${Garfield_INCLUDE_Heed_DIRS}) - message(STATUS Garfield_LIBRARIES ${Garfield_LIBRARIES}) - set(external_include_dirs ${external_include_dirs} ${Garfield_INCLUDE_DIRS}) - set(external_include_dirs ${external_include_dirs} ${Garfield_INCLUDE_Heed_DIRS}) - set(external_libs ${external_libs} ${Garfield_LIBRARIES}) - add_definitions(-DUSE_Garfield_OLD) - else () - message(FATAL_ERROR "Garfield not found") - endif () - - #set(GARFIELD_INSTALL $ENV{GARFIELD_INSTALL}) - message(STATUS "GARFIELD INSTALLATION: ${GARFIELD_INSTALL}") + message(STATUS "Garfield DISABLED") +endif () + +if (REST_GARFIELD) + message(STATUS "Garfield ENABLED") + + add_compile_definitions(REST_GARFIELD) + + # Tested for Garfield af4a14516489babbd6e6df780edd58fedf7fa12b + find_package(Garfield REQUIRED) + + set(GARFIELD_INSTALL $ENV{GARFIELD_INSTALL}) + set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/include/Garfield) + set(external_libs ${external_libs} Garfield::Garfield) + + message(STATUS "GARFIELD installation found at ${GARFIELD_INSTALL}") set(feature_added "Garfield") set(feature_added ${feature_added} PARENT_SCOPE) -else () - set(REST_GARFIELD OFF) -endif (${REST_GARFIELD} MATCHES "ON") + +endif () if (NOT ${REST_EVE} MATCHES "ON") set(excludes ${excludes} TRestDetectorHitsEventViewer) diff --git a/inc/TRestDetector.h b/inc/TRestDetector.h index 958ad36a2..9ece96beb 100644 --- a/inc/TRestDetector.h +++ b/inc/TRestDetector.h @@ -40,13 +40,11 @@ #include "TRestStringOutput.h" #include "TRestTools.h" -using namespace std; - //! An metadata class to store basic detector information class TRestDetector : public TRestMetadata { public: /// The detector name - string fDetectorName = "REST Detector"; + std::string fDetectorName = "REST Detector"; /// The detector drift voltage in V Double_t fDriftVoltage = -1; @@ -84,11 +82,11 @@ class TRestDetector : public TRestMetadata { Double_t fElectronicsThreshold = -1; /// The electronics gain in raw configuration format (hexadecimal) - string fElectronicsGain = "-1"; + std::string fElectronicsGain = "-1"; /// The electronics clock (sampling) in raw configuration format (hexadecimal) - string fElectronicsClock = "-1"; + std::string fElectronicsClock = "-1"; /// The electronics shaping in raw configuration format (hexadecimal) - string fElectronicsShaping = "-1"; + std::string fElectronicsShaping = "-1"; void InitFromConfigFile() { ReadAllParameters(); } @@ -96,7 +94,7 @@ class TRestDetector : public TRestMetadata { void UpdateMetadataMembers(); - // Constructors + // Constructor TRestDetector() {} // Destructor ~TRestDetector() {} diff --git a/inc/TRestDetectorDaqChannelSwitchingProcess.h b/inc/TRestDetectorDaqChannelSwitchingProcess.h index 05e449bb6..4a78157b9 100644 --- a/inc/TRestDetectorDaqChannelSwitchingProcess.h +++ b/inc/TRestDetectorDaqChannelSwitchingProcess.h @@ -13,9 +13,6 @@ #define RestCore_TRestDetectorDaqChannelSwitchingProcess #include - -//#include - #include #include #include diff --git a/inc/TRestDetectorGainMap.h b/inc/TRestDetectorGainMap.h index 5c97d752f..3bfe9e326 100644 --- a/inc/TRestDetectorGainMap.h +++ b/inc/TRestDetectorGainMap.h @@ -48,16 +48,16 @@ class TRestDetectorReadout; class TRestDetectorGainMap : public TRestMetadata { public: bool relative; - map fChannelGain; // [channel id, gain] - TH2F* f2DGainMapping = 0; //-> - TH3F* f3DGainMapping = 0; //-> + std::map fChannelGain; // [channel id, gain] + TH2F* f2DGainMapping = nullptr; //-> + TH3F* f3DGainMapping = nullptr; //-> void InitFromConfigFile(); - void SaveToText(string filename) {} - void ReadGainText(string filename) {} + void SaveToText(std::string filename) {} + void ReadGainText(std::string filename) {} - void DrawChannelGainMap(TRestDetectorReadoutModule* mod = 0); + void DrawChannelGainMap(TRestDetectorReadoutModule* mod = nullptr); ClassDef(TRestDetectorGainMap, 1); // Gas Parameters }; diff --git a/inc/TRestDetectorGarfieldDriftProcess.h b/inc/TRestDetectorGarfieldDriftProcess.h index 6c8cce099..b25c4ce4f 100644 --- a/inc/TRestDetectorGarfieldDriftProcess.h +++ b/inc/TRestDetectorGarfieldDriftProcess.h @@ -17,17 +17,11 @@ #include -#if defined USE_Garfield_OLD -#include "AvalancheMC.hh" -#include "ComponentBase.hh" -#include "Sensor.hh" -typedef AvalancheMC DRIFT_METHOD; -#elif USE_Garfield +#if defined REST_GARFIELD #include "AvalancheMC.hh" #include "Component.hh" #include "Sensor.hh" typedef AvalancheMC DRIFT_METHOD; -// TODO Could we have this as an option given through metadata? #endif #include @@ -47,7 +41,7 @@ class TRestDetectorGarfieldDriftProcess : public TRestEventProcess { TRestDetectorHitsEvent* fInputHitsEvent; //! TRestDetectorHitsEvent* fOutputHitsEvent; //! -#if defined USE_Garfield +#if defined REST_GARFIELD TRestDetectorReadout* fReadout; //! TRestDetectorGas* fGas; //! TRestDetectorGeometry* fGeometry; //! @@ -61,9 +55,8 @@ class TRestDetectorGarfieldDriftProcess : public TRestEventProcess { Int_t FindModule(Int_t readoutPlane, Double_t x, Double_t y); Int_t FindChannel(Int_t module, Double_t x, Double_t y); -#endif + protected: -#if defined USE_Garfield Double_t fGasPressure; // atm // Double_t fElectricField; // V/cm Double_t fDriftPotential; // V @@ -79,7 +72,7 @@ class TRestDetectorGarfieldDriftProcess : public TRestEventProcess { TRestEvent* ProcessEvent(TRestEvent* eventInput); -#if defined USE_Garfield +#if defined REST_GARFIELD void InitProcess(); void EndProcess(); @@ -110,8 +103,7 @@ class TRestDetectorGarfieldDriftProcess : public TRestEventProcess { // Destructor ~TRestDetectorGarfieldDriftProcess(); #endif - ClassDef(TRestDetectorGarfieldDriftProcess, - 1); // Template for a REST "event process" class inherited from - // TRestEventProcess + ClassDef(TRestDetectorGarfieldDriftProcess, 1); }; + #endif diff --git a/inc/TRestDetectorGas.h b/inc/TRestDetectorGas.h index 44ad0a057..03777a4c0 100644 --- a/inc/TRestDetectorGas.h +++ b/inc/TRestDetectorGas.h @@ -22,6 +22,7 @@ #ifndef RestCore_TRestDetectorGas #define RestCore_TRestDetectorGas + #include #include @@ -40,14 +41,13 @@ #include "TSystem.h" #include "TVector3.h" -#if defined USE_Garfield +#if defined REST_GARFIELD #include "ComponentConstant.hh" #include "GeometrySimple.hh" #include "MediumMagboltz.hh" #include "Sensor.hh" #include "SolidBox.hh" #include "TrackHeed.hh" -using namespace Garfield; #else class MediumMagboltz; #endif @@ -110,13 +110,13 @@ class TRestDetectorGas : public TRestDetectorDriftVolume { Bool_t fTest = false; //! void InitFromConfigFile(); - string ConstructFilename(); + std::string ConstructFilename(); void AddGasComponent(std::string gasName, Double_t fraction); void GenerateGasFile(); - void UploadGasToServer(string gasFilename); + void UploadGasToServer(std::string gasFilename); Double_t GetDriftVelocity(Double_t E); Double_t GetLongitudinalDiffusion(Double_t E); @@ -126,7 +126,7 @@ class TRestDetectorGas : public TRestDetectorDriftVolume { public: TRestDetectorGas(); - TRestDetectorGas(const char* cfgFileName, string name = "", bool gasGeneration = false, + TRestDetectorGas(const char* cfgFileName, std::string name = "", bool gasGeneration = false, bool test = false); ~TRestDetectorGas(); @@ -144,7 +144,7 @@ class TRestDetectorGas : public TRestDetectorDriftVolume { void LoadGasFile(); - string FindGasFile(string name); + std::string FindGasFile(std::string name); void CalcGarField(double Emin, double Emax, int n); @@ -162,8 +162,8 @@ class TRestDetectorGas : public TRestDetectorDriftVolume { /// Returns the gas component *n*. TString GetGasComponentName(Int_t n) { if (n >= GetNofGases()) { - cout << "REST WARNING. Gas name component n=" << n << " requested. But only " << GetNofGases() - << " component(s) in the mixture." << endl; + std::cout << "REST WARNING. Gas name component n=" << n << " requested. But only " + << GetNofGases() << " component(s) in the mixture." << std::endl; return ""; } return fGasComponentName[n]; @@ -250,12 +250,12 @@ class TRestDetectorGas : public TRestDetectorDriftVolume { void PlotTransversalDiffusion(Double_t eMin, Double_t eMax, Int_t nSteps); void PlotTownsendCoefficient(Double_t eMin, Double_t eMax, Int_t nSteps); void PrintGasInfo(); - void PrintGasFileContent() { cout << fGasFileContent << endl; }; + void PrintGasFileContent() { std::cout << fGasFileContent << std::endl; }; /// Prints the metadata information from the gas void PrintMetadata() { PrintGasInfo(); } - ClassDef(TRestDetectorGas, 3); // Gas Parameters + ClassDef(TRestDetectorGas, 3); }; #endif diff --git a/inc/TRestDetectorGeometry.h b/inc/TRestDetectorGeometry.h index d8ecefbd0..5e1909656 100644 --- a/inc/TRestDetectorGeometry.h +++ b/inc/TRestDetectorGeometry.h @@ -26,41 +26,27 @@ #include "TRestDetectorGas.h" -#if defined USE_Garfield +#if defined REST_GARFIELD -#if defined USE_Garfield_OLD -#include "ComponentBase.hh" -#else -#include "Component.hh" -#endif - -#include "GeometryRoot.hh" -#include "Sensor.hh" - -#if defined USE_Garfield_OLD -typedef Garfield::ComponentBase Component; -#else -typedef Garfield::Component Component; -#endif +#include +#include +#include #endif -using namespace std; - class TRestDetectorGeometry : public TGeoManager { protected: -#if defined USE_Garfield - Garfield::GeometryRoot* fGfGeometry; //!///< Pointer to Garfield::GeometryRoot object of the - //! geometry - vector vGfComponent; //!///< Vector of pointers to Garfield Component object - vector vGfSensor; //!///< Vector of pointers to Garfield Sensor object - TGeoNode* fDriftElec; //!///< pointer to drift electrode - vector vReadoutElec; //!///< vector of pointers to readout planes - +#if defined REST_GARFIELD + Garfield::GeometryRoot* fGfGeometry = + nullptr; //!///< Pointer to Garfield::GeometryRoot object of the geometry + std::vector vGfComponent; //!///< Vector of pointers to Garfield Component object + std::vector vGfSensor; //!///< Vector of pointers to Garfield Sensor object + TGeoNode* fDriftElec = nullptr; //!///< pointer to drift electrode + std::vector vReadoutElec; //!///< vector of pointers to readout planes #endif public: - // Construtor + // Constructor TRestDetectorGeometry(); // Destructor virtual ~TRestDetectorGeometry(); @@ -68,8 +54,7 @@ class TRestDetectorGeometry : public TGeoManager { /// initialize Garfield::GeometryRoot geometry object void InitGfGeometry(); -#if defined USE_Garfield - +#if defined REST_GARFIELD /// Return pointer to Garfield::GeometryRoot geometry object Garfield::GeometryRoot* GetGfGeometry() { return fGfGeometry; } @@ -79,7 +64,7 @@ class TRestDetectorGeometry : public TGeoManager { } /// Set Garfield field component - void AddGfComponent(Component* c) { + void AddGfComponent(Garfield::Component* c) { c->SetGeometry(fGfGeometry); vGfComponent.push_back(c); } @@ -108,14 +93,14 @@ class TRestDetectorGeometry : public TGeoManager { } /// Get i^th Gf component - Component* GetGfComponent(unsigned int i) { + Garfield::Component* GetGfComponent(unsigned int i) { if (i < vGfComponent.size()) return vGfComponent[i]; else return nullptr; } - /// Getnumber of Gf components + /// Get number of Gf components int GetNbOfGfComponent() { return vGfComponent.size(); } /// Get i^th Gf sensor @@ -126,7 +111,7 @@ class TRestDetectorGeometry : public TGeoManager { return nullptr; } - /// Getnumber of Gf sensors + /// Get number of Gf sensors int GetNbOfGfSensor() { return vGfSensor.size(); } /// Get Gf Medium at position @@ -138,7 +123,7 @@ class TRestDetectorGeometry : public TGeoManager { void PrintGeometry(); - ClassDef(TRestDetectorGeometry, 1); // REST event superclass + ClassDef(TRestDetectorGeometry, 1); }; #endif diff --git a/inc/TRestDetectorHitsAnalysisProcess.h b/inc/TRestDetectorHitsAnalysisProcess.h index e65ec6057..fbefda64b 100644 --- a/inc/TRestDetectorHitsAnalysisProcess.h +++ b/inc/TRestDetectorHitsAnalysisProcess.h @@ -23,10 +23,8 @@ #ifndef RestCore_TRestDetectorHitsAnalysisProcess #define RestCore_TRestDetectorHitsAnalysisProcess -#include - #include - +#include #include #include #include diff --git a/inc/TRestDetectorHitsGaussAnalysisProcess.h b/inc/TRestDetectorHitsGaussAnalysisProcess.h index f6640d5c5..d6c3ad0b6 100644 --- a/inc/TRestDetectorHitsGaussAnalysisProcess.h +++ b/inc/TRestDetectorHitsGaussAnalysisProcess.h @@ -23,10 +23,8 @@ #ifndef RestCore_TRestDetectorHitsGaussAnalysisProcess #define RestCore_TRestDetectorHitsGaussAnalysisProcess -#include - #include - +#include #include #include #include diff --git a/src/TRestDetectorElectronDiffusionProcess.cxx b/src/TRestDetectorElectronDiffusionProcess.cxx index 6afdc7af1..5fc7ce5d6 100644 --- a/src/TRestDetectorElectronDiffusionProcess.cxx +++ b/src/TRestDetectorElectronDiffusionProcess.cxx @@ -39,7 +39,6 @@ void TRestDetectorElectronDiffusionProcess::LoadDefaultConfig() { fGasPressure = 1; } -//______________________________________________________________________________ void TRestDetectorElectronDiffusionProcess::Initialize() { SetSectionName(this->ClassName()); SetLibraryVersion(LIBRARY_VERSION); @@ -65,7 +64,6 @@ void TRestDetectorElectronDiffusionProcess::LoadConfig(string cfgFilename, strin if (LoadConfigFromFile(cfgFilename, name)) LoadDefaultConfig(); } -//______________________________________________________________________________ void TRestDetectorElectronDiffusionProcess::InitProcess() { fRandom = new TRandom3(fSeed); @@ -86,7 +84,7 @@ void TRestDetectorElectronDiffusionProcess::InitProcess() { exit(-1); } } else { -#ifndef USE_Garfield +#ifndef REST_GARFIELD ferr << "A TRestDetectorGas definition was found but REST was not linked to Garfield libraries." << endl; ferr << "Please, remove the TRestDetectorGas definition, and add gas parameters inside the process " @@ -114,7 +112,6 @@ void TRestDetectorElectronDiffusionProcess::InitProcess() { } } -//______________________________________________________________________________ TRestEvent* TRestDetectorElectronDiffusionProcess::ProcessEvent(TRestEvent* evInput) { fInputHitsEvent = (TRestDetectorHitsEvent*)evInput; fOutputHitsEvent->SetEventInfo(fInputHitsEvent); @@ -222,7 +219,6 @@ TRestEvent* TRestDetectorElectronDiffusionProcess::ProcessEvent(TRestEvent* evIn return fOutputHitsEvent; } -//______________________________________________________________________________ void TRestDetectorElectronDiffusionProcess::EndProcess() { // Function to be executed once at the end of the process // (after all events have been processed) @@ -232,7 +228,6 @@ void TRestDetectorElectronDiffusionProcess::EndProcess() { // TRestEventProcess::EndProcess(); } -//______________________________________________________________________________ void TRestDetectorElectronDiffusionProcess::InitFromConfigFile() { fGasPressure = GetDblParameterWithUnits("gasPressure", -1.); fElectricField = GetDblParameterWithUnits("electricField", -1.); @@ -242,7 +237,7 @@ void TRestDetectorElectronDiffusionProcess::InitFromConfigFile() { if (fLonglDiffCoeff == -1) fLonglDiffCoeff = StringToDouble(GetParameter("longDiff", "-1")); else { - warning << "longitudinalDiffusionCoeffient is now OBSOLETE! It will soon dissapear." << endl; + warning << "longitudinalDiffusionCoefficient is now OBSOLETE! It will soon disappear." << endl; warning << " Please use the shorter form of this parameter : longDiff" << endl; } @@ -250,7 +245,7 @@ void TRestDetectorElectronDiffusionProcess::InitFromConfigFile() { if (fTransDiffCoeff == -1) fTransDiffCoeff = StringToDouble(GetParameter("transDiff", "-1")); else { - warning << "transversalDiffusionCoeffient is now OBSOLETE! It will soon dissapear." << endl; + warning << "transversalDiffusionCoefficient is now OBSOLETE! It will soon disappear." << endl; warning << " Please use the shorter form of this parameter : transDiff" << endl; } fMaxHits = StringToInteger(GetParameter("maxHits", "1000")); diff --git a/src/TRestDetectorGarfieldDriftProcess.cxx b/src/TRestDetectorGarfieldDriftProcess.cxx index bfc0dd394..570151b9c 100644 --- a/src/TRestDetectorGarfieldDriftProcess.cxx +++ b/src/TRestDetectorGarfieldDriftProcess.cxx @@ -14,12 +14,12 @@ /// march 2017: Damien Neyret ///_______________________________________________________________________________ +#include "TRestDetectorGarfieldDriftProcess.h" + #include #include -#include "TRestDetectorGarfieldDriftProcess.h" - -#if defined USE_Garfield +#if defined REST_GARFIELD #include "ComponentConstant.hh" #include "TGDMLParse.h" using namespace Garfield; @@ -31,12 +31,10 @@ using namespace std; const double cmTomm = 10.; -ClassImp(TRestDetectorGarfieldDriftProcess) -//______________________________________________________________________________ -#if defined USE_Garfield - TRestDetectorGarfieldDriftProcess::TRestDetectorGarfieldDriftProcess() - : fRandom(0), fGfSensor(0) { +ClassImp(TRestDetectorGarfieldDriftProcess); +#if defined REST_GARFIELD +TRestDetectorGarfieldDriftProcess::TRestDetectorGarfieldDriftProcess() : fRandom(0), fGfSensor(0) { Initialize(); } @@ -60,13 +58,10 @@ TRestDetectorGarfieldDriftProcess::TRestDetectorGarfieldDriftProcess(char* cfgFi // TRestDetectorGarfieldDriftProcess default constructor } -//______________________________________________________________________________ - -// TRestDetectorGarfieldDriftProcess destructor TRestDetectorGarfieldDriftProcess::~TRestDetectorGarfieldDriftProcess() { - if (fReadout != NULL) delete fReadout; + if (fReadout) delete fReadout; if (fGeometry) delete fGeometry; - fGeometry = NULL; + fGeometry = nullptr; delete fOutputHitsEvent; } @@ -89,7 +84,6 @@ void TRestDetectorGarfieldDriftProcess::LoadConfig(string cfgFilename, string na } } -//______________________________________________________________________________ #endif void TRestDetectorGarfieldDriftProcess::Initialize() { @@ -97,20 +91,19 @@ void TRestDetectorGarfieldDriftProcess::Initialize() { SetLibraryVersion(LIBRARY_VERSION); fRandom = new TRandom3(0); - fInputHitsEvent = NULL; + fInputHitsEvent = nullptr; fOutputHitsEvent = new TRestDetectorHitsEvent(); -#if defined USE_Garfield - fReadout = NULL; - fGas = NULL; - fGeometry = NULL; +#if defined REST_GARFIELD + fReadout = nullptr; + fGas = nullptr; + fGeometry = nullptr; fPEReduction = 1.; fStopDistance = 2; // default distance from readout to stop drift set to 2mm #endif } -//______________________________________________________________________________ -#if defined USE_Garfield +#if defined REST_GARFIELD void TRestDetectorGarfieldDriftProcess::InitProcess() { // Function to be executed once at the beginning of process // (before starting the process of the events) @@ -344,7 +337,7 @@ Int_t TRestDetectorGarfieldDriftProcess::FindModule(Int_t readoutPlane, Double_t #endif TRestEvent* TRestDetectorGarfieldDriftProcess::ProcessEvent(TRestEvent* evInput) { -#if defined USE_Garfield +#if defined REST_GARFIELD fInputHitsEvent = (TRestDetectorHitsEvent*)evInput; double x, y, z, energy; @@ -440,9 +433,7 @@ TRestEvent* TRestDetectorGarfieldDriftProcess::ProcessEvent(TRestEvent* evInput) #endif } -#if defined USE_Garfield - -//______________________________________________________________________________ +#if defined REST_GARFIELD void TRestDetectorGarfieldDriftProcess::EndProcess() { // Function to be executed once at the end of the process @@ -453,8 +444,6 @@ void TRestDetectorGarfieldDriftProcess::EndProcess() { // TRestEventProcess::EndProcess(); } -//______________________________________________________________________________ - void TRestDetectorGarfieldDriftProcess::InitFromConfigFile() { fGasPressure = StringToDouble(GetParameter("gasPressure", "-1")); // fElectricField = GetDblParameterWithUnits( "electricField" ); diff --git a/src/TRestDetectorGas.cxx b/src/TRestDetectorGas.cxx index cae3f2e9d..793563dd9 100644 --- a/src/TRestDetectorGas.cxx +++ b/src/TRestDetectorGas.cxx @@ -254,7 +254,7 @@ TRestDetectorGas::TRestDetectorGas(const char* cfgFileName, string name, bool ga if (strcmp(cfgFileName, "server") == 0) { LoadConfigFromElement(StringToElement(""), - NULL); + nullptr); } else { fConfigFileName = cfgFileName; LoadConfigFromFile(fConfigFileName, name); @@ -269,7 +269,7 @@ TRestDetectorGas::TRestDetectorGas(const char* cfgFileName, string name, bool ga TRestDetectorGas::~TRestDetectorGas() { debug << "Entering ... TRestDetectorGas() destructor." << endl; -#if defined USE_Garfield +#if defined REST_GARFIELD delete fGasMedium; #endif } @@ -297,10 +297,10 @@ void TRestDetectorGas::Initialize() { fGasFilename = ""; fGasFileContent = ""; -#if defined USE_Garfield +#if defined REST_GARFIELD fGasMedium = new Garfield::MediumMagboltz(); #else - fGasMedium = NULL; + fGasMedium = nullptr; #endif ///////////////////// ///////////////////// ///////////////////// @@ -326,7 +326,7 @@ void TRestDetectorGas::Initialize() { void TRestDetectorGas::LoadGasFile() { debug << "Entering ... TRestDetectorGas::LoadGasFile()." << endl; -#if defined USE_Garfield +#if defined REST_GARFIELD debug << "fGasFilename = " << fGasFilename << endl; if (!TRestTools::fileExists((string)(fGasFilename))) { ferr << __PRETTY_FUNCTION__ << endl; @@ -360,7 +360,7 @@ void TRestDetectorGas::CalcGarField(double Emin, double Emax, int n) { debug << "Entering ... TRestDetectorGas::CalcGarField( Emin=" << Emin << " , Emax=" << Emax << " )" << endl; -#if defined USE_Garfield +#if defined REST_GARFIELD if (fEnodes <= 0) { cout << "REST ERROR : The number of nodes is not a positive number!!. Gas " "file generation cancelled." @@ -450,7 +450,7 @@ void TRestDetectorGas::AddGasComponent(string gasName, Double_t fraction) { // However, I tested with Xe+TMA and I got an error message that TMA // photoncrossection database is not available void TRestDetectorGas::GetGasWorkFunction() { -#if defined USE_Garfield +#if defined REST_GARFIELD essential << __PRETTY_FUNCTION__ << endl; essential << "This method has never been validated to operate properly" << endl; essential << "If we manage to make it work we could use this method to " @@ -520,7 +520,7 @@ void TRestDetectorGas::InitFromConfigFile() { // add gas component TiXmlElement* gasComponentDefinition = GetElement("gasComponent"); - while (gasComponentDefinition != NULL) { + while (gasComponentDefinition) { string gasName = GetFieldValue("name", gasComponentDefinition); Double_t gasFraction = StringToDouble(GetFieldValue("fraction", gasComponentDefinition)); AddGasComponent(gasName, gasFraction); @@ -593,7 +593,7 @@ void TRestDetectorGas::InitFromConfigFile() { } fStatus = RESTGAS_CFG_LOADED; -#if defined USE_Garfield +#if defined REST_GARFIELD // calling garfield, either to generate gas file or load existing gas file if (fGasGeneration) { essential << "Starting gas generation" << endl; @@ -831,7 +831,7 @@ string TRestDetectorGas::ConstructFilename() { void TRestDetectorGas::GenerateGasFile() { debug << "Entering ... TRestDetectorGas::GenerateGasFile( )" << endl; -#if defined USE_Garfield +#if defined REST_GARFIELD fGasFilename = ConstructFilename(); debug << " TRestDetectorGas::GenerateGasFile. fGasFilename = " << fGasFilename << endl; @@ -876,7 +876,7 @@ void TRestDetectorGas::SetPressure(Double_t pressure) { debug << "Entering ... TRestDetectorGas::SetPressure( pressure=" << pressure << " )" << endl; fPressureInAtm = pressure; -#if defined USE_Garfield +#if defined REST_GARFIELD fGasMedium->SetPressure(fPressureInAtm * REST_Units::torr); #endif } @@ -887,7 +887,7 @@ void TRestDetectorGas::SetTemperature(Double_t temperature) { debug << "Entering ... TRestDetectorGas::SetPressure( temperature=" << temperature << " )" << endl; fTemperatureInK = temperature; -#if defined USE_Garfield +#if defined REST_GARFIELD fGasMedium->SetTemperature(temperature); #endif } @@ -1030,7 +1030,7 @@ void TRestDetectorGas::PlotTownsendCoefficient(Double_t eMin, Double_t eMax, Int Double_t TRestDetectorGas::GetDriftVelocity(Double_t E) { debug << "Entering ... TRestDetectorGas::GetDriftVelocity( E=" << E << " )" << endl; -#if defined USE_Garfield +#if defined REST_GARFIELD if (fStatus != RESTGAS_GASFILE_LOADED) { debug << "-- Error : " << __PRETTY_FUNCTION__ << endl; debug << "-- Error : Gas file was not loaded!" << endl; @@ -1059,7 +1059,7 @@ Double_t TRestDetectorGas::GetDriftVelocity(Double_t E) { Double_t TRestDetectorGas::GetLongitudinalDiffusion(Double_t E) { debug << "Entering ... TRestDetectorGas::GetLongitudinalDiffusion( E=" << E << " )" << endl; -#if defined USE_Garfield +#if defined REST_GARFIELD if (fStatus != RESTGAS_GASFILE_LOADED) { debug << "-- Error : " << __PRETTY_FUNCTION__ << endl; debug << "-- Error : Gas file was not loaded!" << endl; @@ -1088,7 +1088,7 @@ Double_t TRestDetectorGas::GetLongitudinalDiffusion(Double_t E) { Double_t TRestDetectorGas::GetTransversalDiffusion(Double_t E) { debug << "Entering ... TRestDetectorGas::GetTransversalDiffusion( E=" << E << " )" << endl; -#if defined USE_Garfield +#if defined REST_GARFIELD if (fStatus != RESTGAS_GASFILE_LOADED) { debug << "-- Error : " << __PRETTY_FUNCTION__ << endl; debug << "-- Error : Gas file was not loaded!" << endl; @@ -1117,7 +1117,7 @@ Double_t TRestDetectorGas::GetTransversalDiffusion(Double_t E) { Double_t TRestDetectorGas::GetTownsendCoefficient(Double_t E) { debug << "Entering ... TRestDetectorGas::GetTownsendCoefficient( E=" << E << " )" << endl; -#if defined USE_Garfield +#if defined REST_GARFIELD if (fStatus != RESTGAS_GASFILE_LOADED) { debug << "-- Error : " << __PRETTY_FUNCTION__ << endl; debug << "-- Error : Gas file was not loaded!" << endl; @@ -1146,7 +1146,7 @@ Double_t TRestDetectorGas::GetTownsendCoefficient(Double_t E) { Double_t TRestDetectorGas::GetAttachmentCoefficient(Double_t E) { debug << "Entering ... TRestDetectorGas::GetAttachmentCoefficient( E=" << E << " )" << endl; -#if defined USE_Garfield +#if defined REST_GARFIELD if (fStatus != RESTGAS_GASFILE_LOADED) { debug << "-- Error : " << __PRETTY_FUNCTION__ << endl; debug << "-- Error : Gas file was not loaded!" << endl; @@ -1188,7 +1188,8 @@ void TRestDetectorGas::PrintGasInfo() { metadata << "Temperature : " << fTemperatureInK << " K" << endl; metadata << "Electric Field : " << fElectricField * units("V/cm") << " V/cm " << endl; metadata << "W-value : " << fW << " eV" << endl; - metadata << "Drift velocity : " << GetDriftVelocity(fElectricField * units("V/cm")) / units("cm/us") << " mm/us " << endl; + metadata << "Drift velocity : " << GetDriftVelocity(fElectricField * units("V/cm")) / units("cm/us") + << " mm/us " << endl; metadata << "Max. Electron energy : " << fMaxElectronEnergy << " eV" << endl; metadata << "Field grid nodes : " << fEnodes << endl; metadata << "Efield range : ( " << fEmin << " , " << fEmax << " ) V/cm " << endl; diff --git a/src/TRestDetectorGeometry.cxx b/src/TRestDetectorGeometry.cxx index 30932cfd7..0bb6ae66c 100644 --- a/src/TRestDetectorGeometry.cxx +++ b/src/TRestDetectorGeometry.cxx @@ -17,45 +17,39 @@ ///_______________________________________________________________________________ #include "TRestDetectorGeometry.h" + using namespace std; ClassImp(TRestDetectorGeometry); -//______________________________________________________________________________ - -TRestDetectorGeometry::TRestDetectorGeometry() - : TGeoManager() //, fGfGeometry(0), fDriftElec(0) -{ -#if defined USE_Garfield - // TRestDetectorGeometry default constructor - vReadoutElec.clear(); - vGfComponent.clear(); - vGfSensor.clear(); -#endif -} - -//______________________________________________________________________________ +TRestDetectorGeometry::TRestDetectorGeometry() : TGeoManager() {} TRestDetectorGeometry::~TRestDetectorGeometry() { -#if defined USE_Garfield - // TRestDetectorGeometry destructor +#if defined REST_GARFIELD + for (auto item : vReadoutElec) { + delete item; + } vReadoutElec.clear(); + + for (auto item : vGfSensor) { + delete item; + } vGfSensor.clear(); + + for (auto item : vGfComponent) { + delete item; + } vGfComponent.clear(); #endif } -//------------------------------------------------------------------------------ - void TRestDetectorGeometry::InitGfGeometry() { -#if defined USE_Garfield +#if defined REST_GARFIELD fGfGeometry = new Garfield::GeometryRoot(); fGfGeometry->SetGeometry(this); #endif } -//------------------------------------------------------------------------------ - void TRestDetectorGeometry::PrintGeometry() { cout << "--------------------------------------" << endl; cout << "Volumes : " << this->GetListOfVolumes()->GetEntries() << endl; diff --git a/src/TRestDetectorHitsToSignalProcess.cxx b/src/TRestDetectorHitsToSignalProcess.cxx index ec59bc781..162b091a1 100644 --- a/src/TRestDetectorHitsToSignalProcess.cxx +++ b/src/TRestDetectorHitsToSignalProcess.cxx @@ -170,8 +170,8 @@ void TRestDetectorHitsToSignalProcess::Initialize() { /// void TRestDetectorHitsToSignalProcess::InitProcess() { fGas = GetMetadata(); - if (fGas != NULL) { -#ifndef USE_Garfield + if (fGas) { +#ifndef REST_GARFIELD ferr << "A TRestDetectorGas definition was found but REST was not linked to Garfield libraries." << endl; ferr << "Please, remove the TRestDetectorGas definition, and add gas parameters inside the process " @@ -279,4 +279,3 @@ TRestEvent* TRestDetectorHitsToSignalProcess::ProcessEvent(TRestEvent* evInput) return fSignalEvent; } - diff --git a/src/TRestDetectorSignalToHitsProcess.cxx b/src/TRestDetectorSignalToHitsProcess.cxx index eae2335f3..39aba52dc 100644 --- a/src/TRestDetectorSignalToHitsProcess.cxx +++ b/src/TRestDetectorSignalToHitsProcess.cxx @@ -164,8 +164,8 @@ void TRestDetectorSignalToHitsProcess::Initialize() { /// void TRestDetectorSignalToHitsProcess::InitProcess() { fGas = GetMetadata(); - if (fGas != NULL) { -#ifndef USE_Garfield + if (fGas) { +#ifndef REST_GARFIELD ferr << "A TRestDetectorGas definition was found but REST was not linked to Garfield libraries." << endl; ferr << "Please, remove the TRestDetectorGas definition, and add gas parameters inside the process " @@ -356,4 +356,3 @@ TRestEvent* TRestDetectorSignalToHitsProcess::ProcessEvent(TRestEvent* evInput) return fHitsEvent; } -