diff --git a/CMakeLists.txt b/CMakeLists.txt index cbfa09b..18149ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,11 +24,11 @@ if(NOT Geant4_shared_FOUND) message(FATAL_ERROR "CaTS must use shared libraries") endif() -find_package(Boost REQUIRED COMPONENTS timer) -if(NOT BOOST_FOUND) -message(STATUS "${name} BOOST package not found. --> ${name} disabled") - return() -endif() +#find_package(Boost REQUIRED COMPONENTS timer) +#if(NOT BOOST_FOUND) +#message(STATUS "${name} BOOST package not found. --> ${name} disabled") +# return() +#endif() option(WITH_ROOT "Build example with ROOT" ON) @@ -95,8 +95,10 @@ file(GLOB evtdata ${PROJECT_SOURCE_DIR}/data/*) file(GLOB runscripts ${PROJECT_SOURCE_DIR}/scripts/run.sh ${PROJECT_SOURCE_DIR}/scripts/check.sh) add_executable(${name} ${name}.cc ${sources} ${headers}) -target_compile_definitions( ${name} PRIVATE WITH_G4OPTICKS WITH_ROOT) -target_link_libraries(${name} CaTSClassesDict Opticks::G4OK ${Geant4_LIBRARIES} ${ROOT_LIBRARIES} Boost::timer ) +#target_compile_definitions( ${name} PRIVATE WITH_G4OPTICKS WITH_ROOT) +#target_link_libraries(${name} CaTSClassesDict Opticks::G4OK ${Geant4_LIBRARIES} ${ROOT_LIBRARIES} Boost::timer ) +#target_link_libraries(${name} CaTSClassesDict ${Geant4_LIBRARIES} ${ROOT_LIBRARIES} ) +target_link_libraries(${name} ${Geant4_LIBRARIES} ) if(WITH_ROOT) add_executable(readPhotonHits readPhotonHits.cc ${sources} ${headers}) diff --git a/CaTS.cc b/CaTS.cc index 78469e4..6d31c53 100644 --- a/CaTS.cc +++ b/CaTS.cc @@ -50,7 +50,8 @@ #include "CaTS_Version.hh" #include "ActionInitialization.hh" #include "DetectorConstruction.hh" -#include "OpNoviceDetectorConstruction.hh" +// Compilation error - file not found +// #include "OpNoviceDetectorConstruction.hh" #include "PhysicsConfigurator.hh" #include "ConfigurationManager.hh" // Geant4 headers: @@ -126,7 +127,9 @@ int main(int argc, char** argv) { +#ifdef WITH_G4OPTICKS OPTICKS_LOG(argc, argv); +#endif G4VModularPhysicsList* phys = PhysicsConfigurator::getInstance()->Construct(physicsconf); G4String DumpFilename = gdmlfile + "_G4"; G4cout << "**********************************************************" << G4endl; diff --git a/include/ConfigurationManager.hh b/include/ConfigurationManager.hh index f6bcb99..68666ac 100644 --- a/include/ConfigurationManager.hh +++ b/include/ConfigurationManager.hh @@ -127,9 +127,23 @@ public: #endif void Print(); - inline void setEnable_verbose(bool enable_verbose) { - this->enable_verbose = enable_verbose; +// Clang Compilation warning +// /Users/ivana/work/packages/geant4/geant4-dev/examples/extended/CaTS/include/ConfigurationManager.hh:130:40: warning: declaration shadows a field of 'ConfigurationManager' [-Wshadow] +// inline void setEnable_verbose(bool enable_verbose) { +// ^ +// /Users/ivana/work/packages/geant4/geant4-dev/examples/extended/CaTS/include/ConfigurationManager.hh:68:10: note: previous declaration is here +// bool enable_verbose; // switch on/off diagnostic printouts +// ^ + // inline void setEnable_verbose(bool enable_verbose) { + // this->enable_verbose = enable_verbose; + // }; + inline void setEnable_verbose(bool value) { + enable_verbose = value; }; + // BETTER When using examples guideline, data membre starts with 'f': + // inline void setEnable_verbose(bool enable_verbose) { + // fenable_verbose = enable_verbose; + // }; inline bool isEnable_verbose() const { return enable_verbose; diff --git a/include/DRCalorimeterHit.hh b/include/DRCalorimeterHit.hh index 04dad75..2b34f81 100644 --- a/include/DRCalorimeterHit.hh +++ b/include/DRCalorimeterHit.hh @@ -115,6 +115,10 @@ public: unsigned int GetNceren() const; void SetEm_Edep(double em_Edep); double GetEm_Edep() const; +// Clang warning +// /Users/ivana/work/packages/geant4/geant4-dev/examples/extended/CaTS/include/DRCalorimeterHit.hh:118:5: warning: extra ';' inside a class [-Wextra-semi] +// ; +// ^ ; private: diff --git a/include/DetectorConstruction.hh b/include/DetectorConstruction.hh index 42112ec..ba71b27 100644 --- a/include/DetectorConstruction.hh +++ b/include/DetectorConstruction.hh @@ -56,20 +56,24 @@ class DetectorConstruction : public G4VUserDetectorConstruction { public: DetectorConstruction(G4String fname); - virtual ~DetectorConstruction(); + ~DetectorConstruction() override; + // Prefer deleted functions to private undefined ones. + DetectorConstruction & operator=(const DetectorConstruction &right) = delete; + DetectorConstruction(const DetectorConstruction&) = delete; + void ReadGDML(); - G4VPhysicalVolume* Construct(); - virtual void ConstructSDandField(); + // Prefer to declare virtual functions with override, + // virtual keyword can be then ommitted + G4VPhysicalVolume* Construct() override; + void ConstructSDandField() override; void UpdateGeometry(); private: - DetectorConstruction & operator=(const DetectorConstruction &right); - DetectorConstruction(const DetectorConstruction&); - G4String gdmlFile; - G4GDMLParser *parser; - ColorReader* fReader; - bool verbose; + // Data members were not initialized + G4GDMLParser* parser{nullptr}; + ColorReader* fReader{nullptr}; + bool verbose{false}; }; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... #endif diff --git a/include/PrimaryGeneratorAction.hh b/include/PrimaryGeneratorAction.hh index 30d8bcb..8abfdf1 100644 --- a/include/PrimaryGeneratorAction.hh +++ b/include/PrimaryGeneratorAction.hh @@ -61,7 +61,7 @@ private: G4String currentGeneratorName; std::map gentypeMap; PrimaryGeneratorActionMessenger* gunMessenger; - static PrimaryGeneratorAction* instance; + // static PrimaryGeneratorAction* instance; public: PrimaryGeneratorAction(); @@ -71,7 +71,8 @@ public: void SetGenerator(G4String genname); G4VPrimaryGenerator* GetGenerator() const; G4String GetGeneratorName() const; - static PrimaryGeneratorAction* getInstance(); + // Not needed; if used, should be thread local + // static PrimaryGeneratorAction* getInstance(); }; // ==================================================================== // inline functions diff --git a/include/RadiatorSD.hh b/include/RadiatorSD.hh index 2af82d0..e6faf58 100644 --- a/include/RadiatorSD.hh +++ b/include/RadiatorSD.hh @@ -53,6 +53,7 @@ class G4Step; class G4HCofThisEvent; class G4MaterialPropertiesTable; +class G4PhysicsOrderedFreeVector; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... class RadiatorSD : public G4VSensitiveDetector { @@ -66,29 +67,33 @@ public: virtual void EndOfEvent(G4HCofThisEvent* hitCollection); private: - G4int materialIndex; - const G4Material* aMaterial; - G4MaterialPropertiesTable* aMaterialPropertiesTable; - // - // properties related to Scintillation - // - G4MaterialPropertyVector* Fast_Intensity; - G4MaterialPropertyVector* Slow_Intensity; - G4double YieldRatio; // slowerRatio, - G4double FastTimeConstant; // TimeConstant, - G4double SlowTimeConstant; //slowerTimeConstant, - G4ScintillationType ScintillationType; - // - // properties related to Cerenkov - // - G4MaterialPropertyVector* Rindex; - G4PhysicsOrderedFreeVector* CerenkovAngleIntegrals; - const G4PhysicsTable* thePhysicsTable; - G4double Pmin{0}; - G4double Pmax{0}; - G4double dp{0}; - G4double nMax{0}; - bool first{true}; +// Clang warning +// /Users/ivana/work/packages/geant4/geant4-dev/examples/extended/CaTS/include/RadiatorSD.hh:70:11: warning: private field 'materialIndex' is not used [-Wunused-private-field] +// G4int materialIndex; +// ^ + // G4int materialIndex; + // const G4Material* aMaterial; + // G4MaterialPropertiesTable* aMaterialPropertiesTable; + // // + // // properties related to Scintillation + // // + // G4MaterialPropertyVector* Fast_Intensity; + // G4MaterialPropertyVector* Slow_Intensity; + // G4double YieldRatio; // slowerRatio, + // G4double FastTimeConstant; // TimeConstant, + // G4double SlowTimeConstant; //slowerTimeConstant, + // G4ScintillationType ScintillationType; + // // + // // properties related to Cerenkov + // // + // G4MaterialPropertyVector* Rindex; + // G4PhysicsOrderedFreeVector* CerenkovAngleIntegrals; + // const G4PhysicsTable* thePhysicsTable; + // G4double Pmin{0}; + // G4double Pmax{0}; + // G4double dp{0}; + // G4double nMax{0}; + // bool first{true}; bool verbose{false}; int tCphotons{0}; int tSphotons{0}; diff --git a/include/lArTPCSD.hh b/include/lArTPCSD.hh index fbce707..33d131b 100644 --- a/include/lArTPCSD.hh +++ b/include/lArTPCSD.hh @@ -53,6 +53,8 @@ class G4Step; class G4HCofThisEvent; class G4MaterialPropertiesTable; +// Missinf - compilation error +class G4PhysicsOrderedFreeVector; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... class lArTPCSD : public G4VSensitiveDetector { diff --git a/src/CalorimeterHit.cc b/src/CalorimeterHit.cc index 709249a..fed9b02 100644 --- a/src/CalorimeterHit.cc +++ b/src/CalorimeterHit.cc @@ -71,19 +71,21 @@ CalorimeterHit::~CalorimeterHit() = default; //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... CalorimeterHit::CalorimeterHit(const CalorimeterHit& right) : G4VHit() { - this->id = right.id; - this->Edep = right.Edep; - this->em_Edep = right.em_Edep; - this->time = right.time; - this->position = right.position; + // No need to call class member functions via this-> + id = right.id; + Edep = right.Edep; + em_Edep = right.em_Edep; + time = right.time; + position = right.position; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... const CalorimeterHit& CalorimeterHit::operator=(const CalorimeterHit& right) { - this->id = right.id; - this->Edep = right.Edep; - this->em_Edep = right.em_Edep; - this->time = right.time; - this->position = right.position; + // No need to call class member functions via this-> + id = right.id; + Edep = right.Edep; + em_Edep = right.em_Edep; + time = right.time; + position = right.position; return *this; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/src/CalorimeterSD.cc b/src/CalorimeterSD.cc index 8b44dae..370953f 100644 --- a/src/CalorimeterSD.cc +++ b/src/CalorimeterSD.cc @@ -74,15 +74,16 @@ void CalorimeterSD::Initialize(G4HCofThisEvent* hce) { } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... G4bool CalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) { - double edep = aStep->GetTotalEnergyDeposit() / CLHEP::MeV; + // auto can be used for all results from retrieving functions + auto edep = aStep->GetTotalEnergyDeposit() / CLHEP::MeV; if (edep == 0.) return false; - double time = aStep->GetPreStepPoint()->GetGlobalTime() / CLHEP::ns; - const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable(); - G4ThreeVector cellpos = touch->GetTranslation(); - unsigned int ID = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetCopyNo(); + auto time = aStep->GetPreStepPoint()->GetGlobalTime() / CLHEP::ns; + auto touch = aStep->GetPreStepPoint()->GetTouchable(); + auto cellpos = touch->GetTranslation(); + auto ID = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetCopyNo(); //std::cout<<"ID: "<GetTrack(); - G4String particleType = theTrack->GetDefinition()->GetParticleName(); + auto theTrack = aStep->GetTrack(); + auto particleType = theTrack->GetDefinition()->GetParticleName(); // // check if this cell has been hit before //fCalorimeterHitsCollection diff --git a/src/ColorReader.cc b/src/ColorReader.cc index 0410a6d..6e53dee 100644 --- a/src/ColorReader.cc +++ b/src/ColorReader.cc @@ -57,9 +57,9 @@ ColorReader::ColorReader() //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... ColorReader::~ColorReader() { - std::map::iterator pos; - for (pos = fAttribs.begin(); pos != fAttribs.end(); pos++) { - delete pos->second; + // Range based for loop (C++11) + structured bindings (C++17) + for ( auto [name, attribute] : fAttribs ) { + delete attribute; } } diff --git a/src/InteractionSD.cc b/src/InteractionSD.cc index 0562527..66c4809 100644 --- a/src/InteractionSD.cc +++ b/src/InteractionSD.cc @@ -66,8 +66,10 @@ InteractionSD::InteractionSD(G4String name) //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... InteractionSD::~InteractionSD() { - if (fFirstInter) delete fFirstInter; - if (fOtherInter) delete fOtherInter; +// - No need to test pointer before calling delete: +// if pointer is 0, delete call has no effect + delete fFirstInter; + delete fOtherInter; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/src/PrimaryGeneratorAction.cc b/src/PrimaryGeneratorAction.cc index bbae160..1396b9a 100644 --- a/src/PrimaryGeneratorAction.cc +++ b/src/PrimaryGeneratorAction.cc @@ -53,12 +53,12 @@ // Project headers: #include "PrimaryGeneratorAction.hh" #include "PrimaryGeneratorActionMessenger.hh" -PrimaryGeneratorAction* PrimaryGeneratorAction::instance = 0; -//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... -PrimaryGeneratorAction* PrimaryGeneratorAction::getInstance() { - if (instance == 0) instance = new PrimaryGeneratorAction(); - return instance; -} +// PrimaryGeneratorAction* PrimaryGeneratorAction::instance = 0; +// //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... +// PrimaryGeneratorAction* PrimaryGeneratorAction::getInstance() { +// if (instance == 0) instance = new PrimaryGeneratorAction(); +// return instance; +// } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... PrimaryGeneratorAction::PrimaryGeneratorAction() { const char* filename = "pythia_event.data"; @@ -78,14 +78,15 @@ PrimaryGeneratorAction::PrimaryGeneratorAction() { gunMessenger = new PrimaryGeneratorActionMessenger(this); currentGenerator = gentypeMap["particleGun"]; currentGeneratorName = "particleGun"; - instance = this; + // instance = this; } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... PrimaryGeneratorAction::~PrimaryGeneratorAction() { delete gunMessenger; - for (std::map::iterator ii = gentypeMap.begin(); ii != gentypeMap.end(); ++ii) { - delete (*ii).second; - gentypeMap.erase((*ii).first); + // Range based for loop (C++11) + structured bindings (C++17) + for (auto [genType, generator] : gentypeMap ) { + delete generator; + gentypeMap.erase(genType); } } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/src/StackingAction.cc b/src/StackingAction.cc index b5edea5..517d996 100644 --- a/src/StackingAction.cc +++ b/src/StackingAction.cc @@ -55,7 +55,8 @@ #include "G4VProcess.hh" #include "G4ClassificationOfNewTrack.hh" #include "G4PhysicalConstants.hh" -#include "G4PhysicsOrderedFreeVector.hh" +// Compilation error: 'G4PhysicsOrderedFreeVector.hh' file not found +// #include "G4PhysicsOrderedFreeVector.hh" #include "G4Material.hh" #include "G4MaterialPropertyVector.hh" #include "g4analysis.hh"