Skip to content

Commit

Permalink
New class inheriting from Geant4PhysicsListAction to separate out cel…
Browse files Browse the repository at this point in the history
…eritas pieces from DDG4
  • Loading branch information
SAKIB RAHMAN committed Dec 13, 2024
1 parent 7d49231 commit c25f07f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
20 changes: 19 additions & 1 deletion DDG4/celeritas/Celeritas.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <DDG4/Celeritas.h>
#include "Celeritas.h"

#include <G4Threading.hh>
#include <accel/AlongStepFactory.hh>
Expand All @@ -11,6 +11,8 @@
#include <G4Electron.hh>
#include <G4Positron.hh>
#include <G4Gamma.hh>
#include <G4VPhysicsConstructor.hh>
#include <G4PhysListFactory.hh>

#include <memory>

Expand Down Expand Up @@ -84,3 +86,19 @@ void EMPhysicsConstructor::ConstructProcess()
G4Positron::Definition()->SetTrackingManager(celer_tracking);
G4Gamma::Definition()->SetTrackingManager(celer_tracking);
}

struct EmptyPhysics : public G4VModularPhysicsList {
EmptyPhysics() = default; // Default constructor, does nothing
virtual ~EmptyPhysics() = default; // Virtual destructor, does nothing
};

G4VUserPhysicsList* CeleritasPhysicsListActionSequence::activateCeleritas() {
G4VModularPhysicsList* physics = ( m_extends.empty() )
? new EmptyPhysics()
: G4PhysListFactory().GetReferencePhysList(m_extends);

physics->ReplacePhysics(new EMPhysicsConstructor);

return physics;
}

15 changes: 14 additions & 1 deletion DDG4/celeritas/Celeritas.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef Celeritas_h
#define Celeritas_h 1

#include <DDG4/Geant4PhysicsList.h>
#include <accel/SimpleOffload.hh>
#include <G4EmStandardPhysics.hh>

Expand All @@ -9,7 +10,7 @@ namespace dd4hep {

/// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
namespace sim {

class EMPhysicsConstructor final : public G4EmStandardPhysics
{
public:
Expand All @@ -18,6 +19,18 @@ namespace dd4hep {
void ConstructProcess() override;
};

class CeleritasPhysicsListActionSequence : public
Geant4PhysicsListActionSequence {

public:
/// Standard constructor
CeleritasPhysicsListActionSequence(Geant4Context* context, const std::string& nam);
/// Default destructor
virtual ~CeleritasPhysicsListActionSequence();

G4VUserPhysicsList* activateCeleritas();
};

} /* End namespace sim */
} /* End namespace dd4hep*/

Expand Down
2 changes: 0 additions & 2 deletions DDG4/include/DDG4/Geant4PhysicsList.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,6 @@ namespace dd4hep {
virtual void enable(G4VUserPhysicsList* physics);
/// Extend physics list from factory:
G4VUserPhysicsList* extensionList();
/// Activate Celeritas tracking offload within EM physics constructor
G4VUserPhysicsList* activateCeleritas();
};

} // End namespace sim
Expand Down
12 changes: 0 additions & 12 deletions DDG4/src/Geant4PhysicsList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <DD4hep/InstanceCount.h>
#include <DD4hep/Printout.h>
#include <DD4hep/Plugins.h>
#include <DDG4/celeritas/Celeritas.h>

// Geant4 include files
#include <G4VPhysicsConstructor.hh>
Expand Down Expand Up @@ -375,17 +374,6 @@ G4VUserPhysicsList* Geant4PhysicsListActionSequence::extensionList() {
return physics;
}

G4VUserPhysicsList* Geant4PhysicsListActionSequence::activateCeleritas() {
G4VModularPhysicsList* physics = ( m_extends.empty() )
? new EmptyPhysics()
: G4PhysListFactory().GetReferencePhysList(m_extends);

physics->ReplacePhysics(new EMPhysicsConstructor);

return physics;
}


/// Install command control messenger if wanted
void Geant4PhysicsListActionSequence::installCommandMessenger() {
control()->addCall("dump", "Dump content of " + name(), Callback(this).make(&Geant4PhysicsListActionSequence::dump));
Expand Down

0 comments on commit c25f07f

Please sign in to comment.