Import Geant4 11.3.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2024-06-28 13:08:51 +02:00
parent f7b23877ed
commit e58e650b32
5232 changed files with 239416 additions and 244360 deletions
@@ -50,18 +50,18 @@
// -- Physics list, and tool to modify it and activate fast simulation:
//---------------------------------------------------------------------
#include "FTFP_BERT.hh"
#include "G4FastSimulationPhysics.hh"
#include "G4UImanager.hh"
#include "G4FastSimulationPhysics.hh"
#include "G4RunManagerFactory.hh"
#include "G4UImanager.hh"
// ----------------------------------------------------------------
// -- Action initialization (includes the primary generator action:
// ----------------------------------------------------------------
#include "Par01ActionInitialization.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "G4VisExecutive.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -69,7 +69,7 @@ int main(int argc, char** argv)
{
// Instantiate G4UIExecutive if interactive mode
G4UIExecutive* ui = nullptr;
if ( argc == 1 ) {
if (argc == 1) {
ui = new G4UIExecutive(argc, argv);
}
@@ -95,9 +95,9 @@ int main(int argc, char** argv)
// -- Create a physics list (note : FTFP_BERT is a G4VModularPhysicsList
// -- which allows to use the subsequent G4FastSimulationPhysics tool to
// -- activate the fast simulation):
auto physicsList = new FTFP_BERT;
auto physicsList = new FTFP_BERT;
// -- Create helper tool, used to activate the fast simulation:
auto fastSimulationPhysics = new G4FastSimulationPhysics();
auto fastSimulationPhysics = new G4FastSimulationPhysics();
fastSimulationPhysics->BeVerbose();
// -- activation of fast simulation for particles having fast simulation models
// -- attached in the mass geometry:
@@ -106,17 +106,17 @@ int main(int argc, char** argv)
fastSimulationPhysics->ActivateFastSimulation("gamma");
// -- activation of fast simulation for particles having fast simulation models
// -- attached in the parallel geometry:
fastSimulationPhysics->ActivateFastSimulation("pi+","pionGhostWorld");
fastSimulationPhysics->ActivateFastSimulation("pi-","pionGhostWorld");
fastSimulationPhysics->ActivateFastSimulation("pi+", "pionGhostWorld");
fastSimulationPhysics->ActivateFastSimulation("pi-", "pionGhostWorld");
// -- Attach the fast simulation physics constructor to the physics list:
physicsList->RegisterPhysics( fastSimulationPhysics );
physicsList->RegisterPhysics(fastSimulationPhysics);
// -- Finally passes the physics list to the run manager:
runManager->SetUserInitialization(physicsList);
//-------------------------------
// UserAction classes
//-------------------------------
runManager->SetUserInitialization( new Par01ActionInitialization );
runManager->SetUserInitialization(new Par01ActionInitialization);
// Initialize Run manager
runManager->Initialize();
@@ -126,22 +126,20 @@ int main(int argc, char** argv)
//----------------
G4cout << "Instantiating Visualization Manager......." << G4endl;
G4VisManager* visManager = new G4VisExecutive;
visManager -> Initialize ();
visManager->Initialize();
if(ui)
{
if (ui) {
//--------------------------
// Define (G)UI
//--------------------------
ui->SessionStart();
delete ui;
}
else
{
else {
G4String command = "/control/execute ";
G4String fileName = argv[1];
G4UImanager * UImanager = G4UImanager::GetUIpointer();
UImanager->ApplyCommand(command+fileName);
G4UImanager* UImanager = G4UImanager::GetUIpointer();
UImanager->ApplyCommand(command + fileName);
}
// Free the store: user actions, physics_list and detector_description are
File diff suppressed because it is too large Load Diff
@@ -46,5 +46,3 @@ class Par01ActionInitialization : public G4VUserActionInitialization
};
#endif
@@ -32,61 +32,50 @@
#ifndef Par01CalorimeterHit_h
#define Par01CalorimeterHit_h 1
#include "G4VHit.hh"
#include "G4THitsCollection.hh"
#include "G4Allocator.hh"
#include "G4ThreeVector.hh"
#include "G4LogicalVolume.hh"
#include "G4Transform3D.hh"
#include "G4RotationMatrix.hh"
#include "G4THitsCollection.hh"
#include "G4ThreeVector.hh"
#include "G4Transform3D.hh"
#include "G4VHit.hh"
class Par01CalorimeterHit : public G4VHit
{
public:
Par01CalorimeterHit();
Par01CalorimeterHit(G4LogicalVolume* logVol);
~Par01CalorimeterHit();
Par01CalorimeterHit(const Par01CalorimeterHit &right);
const Par01CalorimeterHit& operator=(const Par01CalorimeterHit &right);
G4bool operator==(const Par01CalorimeterHit &right) const;
inline void *operator new(size_t);
inline void operator delete(void *aHit);
void *operator new(size_t,void*p){return p;}
public:
Par01CalorimeterHit();
Par01CalorimeterHit(G4LogicalVolume* logVol);
~Par01CalorimeterHit();
Par01CalorimeterHit(const Par01CalorimeterHit& right);
const Par01CalorimeterHit& operator=(const Par01CalorimeterHit& right);
G4bool operator==(const Par01CalorimeterHit& right) const;
inline void* operator new(size_t);
inline void operator delete(void* aHit);
void* operator new(size_t, void* p) { return p; }
#ifndef G4NOT_ISO_DELETES
void operator delete(void *,void*){}
void operator delete(void*, void*) {}
#endif
// methods from base class
virtual void Draw();
virtual void Print();
private:
G4double fEdep;
G4ThreeVector fPosition;
G4RotationMatrix fRot;
const G4LogicalVolume* fLogV;
public:
inline void SetEdep(G4double de)
{ fEdep = de; };
inline void AddEdep(G4double de)
{ fEdep += de; };
inline G4double GetEdep()
{ return fEdep; };
inline void SetPos(G4ThreeVector xyz)
{ fPosition = xyz; };
inline G4ThreeVector GetPos()
{ return fPosition; };
inline void SetRot(G4RotationMatrix rmat)
{ fRot = rmat; };
inline G4RotationMatrix GetRot()
{ return fRot; };
inline const G4LogicalVolume * GetLogV()
{ return fLogV; };
// methods from base class
virtual void Draw();
virtual void Print();
private:
G4double fEdep;
G4ThreeVector fPosition;
G4RotationMatrix fRot;
const G4LogicalVolume* fLogV;
public:
inline void SetEdep(G4double de) { fEdep = de; };
inline void AddEdep(G4double de) { fEdep += de; };
inline G4double GetEdep() { return fEdep; };
inline void SetPos(G4ThreeVector xyz) { fPosition = xyz; };
inline G4ThreeVector GetPos() { return fPosition; };
inline void SetRot(G4RotationMatrix rmat) { fRot = rmat; };
inline G4RotationMatrix GetRot() { return fRot; };
inline const G4LogicalVolume* GetLogV() { return fLogV; };
};
typedef G4THitsCollection<Par01CalorimeterHit> Par01CalorimeterHitsCollection;
@@ -95,14 +84,14 @@ extern G4ThreadLocal G4Allocator<Par01CalorimeterHit>* Par01CalorimeterHitAlloca
inline void* Par01CalorimeterHit::operator new(size_t)
{
if(!Par01CalorimeterHitAllocator) Par01CalorimeterHitAllocator =
new G4Allocator<Par01CalorimeterHit>;
return (void *) Par01CalorimeterHitAllocator->MallocSingle();
if (!Par01CalorimeterHitAllocator)
Par01CalorimeterHitAllocator = new G4Allocator<Par01CalorimeterHit>;
return (void*)Par01CalorimeterHitAllocator->MallocSingle();
}
inline void Par01CalorimeterHit::operator delete(void *aHit)
inline void Par01CalorimeterHit::operator delete(void* aHit)
{
Par01CalorimeterHitAllocator->FreeSingle((Par01CalorimeterHit*) aHit);
Par01CalorimeterHitAllocator->FreeSingle((Par01CalorimeterHit*)aHit);
}
#endif
@@ -34,31 +34,28 @@
#include "Par01CalorimeterHit.hh"
#include "G4VSensitiveDetector.hh"
#include "G4Step.hh"
#include "G4VSensitiveDetector.hh"
class Par01CalorimeterSD : public G4VSensitiveDetector
{
public:
Par01CalorimeterSD(G4String name, G4int nCells, G4String colName);
~Par01CalorimeterSD();
virtual void Initialize(G4HCofThisEvent*HCE);
virtual G4bool ProcessHits(G4Step*aStep,G4TouchableHistory*ROhist);
virtual void EndOfEvent(G4HCofThisEvent*HCE);
virtual void clear();
virtual void DrawAll();
virtual void PrintAll();
private:
Par01CalorimeterHitsCollection *fCalCollection;
int* fCellID;
int fNumberOfCells;
int fHCID;
public:
Par01CalorimeterSD(G4String name, G4int nCells, G4String colName);
~Par01CalorimeterSD();
virtual void Initialize(G4HCofThisEvent* HCE);
virtual G4bool ProcessHits(G4Step* aStep, G4TouchableHistory* ROhist);
virtual void EndOfEvent(G4HCofThisEvent* HCE);
virtual void clear();
virtual void DrawAll();
virtual void PrintAll();
private:
Par01CalorimeterHitsCollection* fCalCollection;
int* fCellID;
int fNumberOfCells;
int fHCID;
};
#endif
@@ -39,21 +39,19 @@ class Par01DetectorMessenger;
class Par01DetectorConstruction : public G4VUserDetectorConstruction
{
public:
Par01DetectorConstruction();
virtual ~Par01DetectorConstruction();
public:
virtual G4VPhysicalVolume* Construct();
virtual void ConstructSDandField();
public:
Par01DetectorConstruction();
virtual ~Par01DetectorConstruction();
private:
G4LogicalVolume* fCrystalLog;
G4LogicalVolume* fTowerLog;
G4int fnX, fnY;
G4int fnXhad, fnYhad;
public:
virtual G4VPhysicalVolume* Construct();
virtual void ConstructSDandField();
private:
G4LogicalVolume* fCrystalLog;
G4LogicalVolume* fTowerLog;
G4int fnX, fnY;
G4int fnXhad, fnYhad;
};
#endif
@@ -28,7 +28,7 @@
//
//
//
//
//
//----------------------------------------------
// Parameterisation of e+/e-/gamma producing hits
// The hits are the same as defined in the detailed
@@ -39,52 +39,48 @@
#include "Par01EnergySpot.hh"
#include "G4VFastSimulationModel.hh"
#include "G4Step.hh"
#include "G4TouchableHandle.hh"
#include "G4VFastSimulationModel.hh"
#include <vector>
class Par01EMShowerModel : public G4VFastSimulationModel
{
public:
//-------------------------
// Constructor, destructor
//-------------------------
Par01EMShowerModel (G4String, G4Region*);
Par01EMShowerModel (G4String);
~Par01EMShowerModel ();
public:
//-------------------------
// Constructor, destructor
//-------------------------
Par01EMShowerModel(G4String, G4Region*);
Par01EMShowerModel(G4String);
~Par01EMShowerModel();
//------------------------------
// Virtual methods of the base
// class to be coded by the user
//------------------------------
//------------------------------
// Virtual methods of the base
// class to be coded by the user
//------------------------------
// -- IsApplicable
virtual G4bool IsApplicable(const G4ParticleDefinition&);
// -- ModelTrigger
virtual G4bool ModelTrigger(const G4FastTrack &);
// -- User method DoIt
virtual void DoIt(const G4FastTrack&, G4FastStep&);
// -- IsApplicable
virtual G4bool IsApplicable(const G4ParticleDefinition&);
// -- ModelTrigger
virtual G4bool ModelTrigger(const G4FastTrack&);
// -- User method DoIt
virtual void DoIt(const G4FastTrack&, G4FastStep&);
private:
void AssignSpotAndCallHit(const Par01EnergySpot &eSpot);
void FillFakeStep(const Par01EnergySpot &eSpot);
void Explode(const G4FastTrack&);
void BuildDetectorResponse();
private:
G4Step *fFakeStep;
G4StepPoint *fFakePreStepPoint, *fFakePostStepPoint;
G4TouchableHandle fTouchableHandle;
G4Navigator *fpNavigator;
G4bool fNaviSetup;
G4Material* fCsI;
private:
void AssignSpotAndCallHit(const Par01EnergySpot& eSpot);
void FillFakeStep(const Par01EnergySpot& eSpot);
void Explode(const G4FastTrack&);
void BuildDetectorResponse();
std::vector<Par01EnergySpot> feSpotList;
private:
G4Step* fFakeStep;
G4StepPoint *fFakePreStepPoint, *fFakePostStepPoint;
G4TouchableHandle fTouchableHandle;
G4Navigator* fpNavigator;
G4bool fNaviSetup;
G4Material* fCsI;
std::vector<Par01EnergySpot> feSpotList;
};
#endif
@@ -36,31 +36,30 @@ class G4Colour;
class Par01EnergySpot
{
public:
Par01EnergySpot();
Par01EnergySpot(const G4ThreeVector& point, G4double E);
~Par01EnergySpot();
public:
Par01EnergySpot();
Par01EnergySpot(const G4ThreeVector& point, G4double E);
~Par01EnergySpot();
inline void SetEnergy(const G4double& E) {fEnergy = E;}
inline G4double GetEnergy() const {return fEnergy;}
inline void SetEnergy(const G4double& E) { fEnergy = E; }
inline G4double GetEnergy() const { return fEnergy; }
inline void SetPosition(const G4ThreeVector& point) {fPoint = point;}
inline G4ThreeVector GetPosition() const {return fPoint;}
inline void SetPosition(const G4ThreeVector& point) { fPoint = point; }
inline G4ThreeVector GetPosition() const { return fPoint; }
G4bool operator==(const Par01EnergySpot& eSpot) const
{
return (fEnergy==eSpot.fEnergy && fPoint==eSpot.fPoint) ? 1 : 0;
}
G4bool operator==(const Par01EnergySpot& eSpot) const
{
return (fEnergy == eSpot.fEnergy && fPoint == eSpot.fPoint) ? 1 : 0;
}
// Draw:
void Draw(G4Colour* color = 0);
// Print:
void Print();
// Draw:
void Draw(G4Colour* color = 0);
// Print:
void Print();
private:
G4double fEnergy;
G4ThreeVector fPoint;
private:
G4double fEnergy;
G4ThreeVector fPoint;
};
#endif
@@ -33,15 +33,15 @@
#include "G4VUserParallelWorld.hh"
class Par01ParallelWorldForPion : public G4VUserParallelWorld {
public:
Par01ParallelWorldForPion(G4String worldName);
~Par01ParallelWorldForPion();
private:
virtual void Construct();
virtual void ConstructSD();
class Par01ParallelWorldForPion : public G4VUserParallelWorld
{
public:
Par01ParallelWorldForPion(G4String worldName);
~Par01ParallelWorldForPion();
private:
virtual void Construct();
virtual void ConstructSD();
};
#endif
@@ -28,7 +28,7 @@
//
//
//
//
//
//----------------------------------------
// Simple example of a "parameterisation".
//----------------------------------------
@@ -39,24 +39,23 @@
class Par01PiModel : public G4VFastSimulationModel
{
public:
//-------------------------
// Constructor, destructor
//-------------------------
Par01PiModel (G4Region *anEnvelope);
~Par01PiModel();
public:
//-------------------------
// Constructor, destructor
//-------------------------
Par01PiModel(G4Region* anEnvelope);
~Par01PiModel();
//------------------------------
// Virtual methods of the base
// class to be coded by the user
//------------------------------
// -- IsApplicable
virtual G4bool IsApplicable(const G4ParticleDefinition&);
// -- ModelTrigger
virtual G4bool ModelTrigger(const G4FastTrack &);
// -- User method DoIt
virtual void DoIt(const G4FastTrack&, G4FastStep&);
//------------------------------
// Virtual methods of the base
// class to be coded by the user
//------------------------------
// -- IsApplicable
virtual G4bool IsApplicable(const G4ParticleDefinition&);
// -- ModelTrigger
virtual G4bool ModelTrigger(const G4FastTrack&);
// -- User method DoIt
virtual void DoIt(const G4FastTrack&, G4FastStep&);
};
#endif
@@ -28,7 +28,7 @@
//
//
//
//
//
//----------------------------------------------
// Parameterisation for pi+/pi- producing hits.
//----------------------------------------------
@@ -37,47 +37,47 @@
#include "Par01EnergySpot.hh"
#include "G4VFastSimulationModel.hh"
#include "G4Step.hh"
#include "G4TouchableHandle.hh"
#include "G4VFastSimulationModel.hh"
#include <vector>
class Par01PionShowerModel : public G4VFastSimulationModel
{
public:
//-------------------------
// Constructor, destructor
//-------------------------
Par01PionShowerModel (G4String, G4Region*);
Par01PionShowerModel (G4String);
~Par01PionShowerModel ();
public:
//-------------------------
// Constructor, destructor
//-------------------------
Par01PionShowerModel(G4String, G4Region*);
Par01PionShowerModel(G4String);
~Par01PionShowerModel();
//------------------------------
// Virtual methods of the base
// class to be coded by the user
//------------------------------
//------------------------------
// Virtual methods of the base
// class to be coded by the user
//------------------------------
// -- IsApplicable
virtual G4bool IsApplicable(const G4ParticleDefinition&);
// -- ModelTrigger
virtual G4bool ModelTrigger(const G4FastTrack &);
// -- User method DoIt
virtual void DoIt(const G4FastTrack&, G4FastStep&);
// -- IsApplicable
virtual G4bool IsApplicable(const G4ParticleDefinition&);
// -- ModelTrigger
virtual G4bool ModelTrigger(const G4FastTrack&);
// -- User method DoIt
virtual void DoIt(const G4FastTrack&, G4FastStep&);
private:
void AssignSpotAndCallHit(const Par01EnergySpot &eSpot);
void FillFakeStep(const Par01EnergySpot &eSpot);
void Explode(const G4FastTrack&);
void BuildDetectorResponse();
private:
G4Step *fFakeStep;
G4StepPoint *fFakePreStepPoint, *fFakePostStepPoint;
G4TouchableHandle fTouchableHandle;
G4Navigator *fpNavigator;
G4bool fNaviSetup;
private:
void AssignSpotAndCallHit(const Par01EnergySpot& eSpot);
void FillFakeStep(const Par01EnergySpot& eSpot);
void Explode(const G4FastTrack&);
void BuildDetectorResponse();
std::vector<Par01EnergySpot> feSpotList;
private:
G4Step* fFakeStep;
G4StepPoint *fFakePreStepPoint, *fFakePostStepPoint;
G4TouchableHandle fTouchableHandle;
G4Navigator* fpNavigator;
G4bool fNaviSetup;
std::vector<Par01EnergySpot> feSpotList;
};
#endif
@@ -52,5 +52,3 @@ class Par01PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
};
#endif
@@ -28,31 +28,29 @@
/// \brief Implementation of the Par01ActionInitialization class
#include "Par01ActionInitialization.hh"
#include "Par01PrimaryGeneratorAction.hh"
#include "Par01PrimaryGeneratorAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par01ActionInitialization::Par01ActionInitialization()
: G4VUserActionInitialization()
{}
Par01ActionInitialization::Par01ActionInitialization() : G4VUserActionInitialization() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par01ActionInitialization::~Par01ActionInitialization()
{;}
{
;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par01ActionInitialization::BuildForMaster() const
{
}
void Par01ActionInitialization::BuildForMaster() const {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par01ActionInitialization::Build() const
{
SetUserAction(new Par01PrimaryGeneratorAction);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -31,13 +31,13 @@
#include "Par01CalorimeterHit.hh"
#include "G4VVisManager.hh"
#include "G4Colour.hh"
#include "G4VisAttributes.hh"
#include "G4LogicalVolume.hh"
#include "G4VVisManager.hh"
#include "G4VisAttributes.hh"
#include "G4ios.hh"
G4ThreadLocal G4Allocator<Par01CalorimeterHit>* Par01CalorimeterHitAllocator=nullptr;
G4ThreadLocal G4Allocator<Par01CalorimeterHit>* Par01CalorimeterHitAllocator = nullptr;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -48,42 +48,44 @@ Par01CalorimeterHit::Par01CalorimeterHit()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par01CalorimeterHit::Par01CalorimeterHit(G4LogicalVolume* logVol)
:fLogV(logVol)
{;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par01CalorimeterHit::~Par01CalorimeterHit()
{;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par01CalorimeterHit::Par01CalorimeterHit(const Par01CalorimeterHit &right)
: G4VHit()
Par01CalorimeterHit::Par01CalorimeterHit(G4LogicalVolume* logVol) : fLogV(logVol)
{
fEdep = right.fEdep;
fPosition = right.fPosition;
fRot = right.fRot;
fLogV = right.fLogV;
;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const Par01CalorimeterHit& Par01CalorimeterHit::operator=(const Par01CalorimeterHit &right)
Par01CalorimeterHit::~Par01CalorimeterHit()
{
fEdep = right.fEdep;
;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par01CalorimeterHit::Par01CalorimeterHit(const Par01CalorimeterHit& right) : G4VHit()
{
fEdep = right.fEdep;
fPosition = right.fPosition;
fRot = right.fRot;
fLogV = right.fLogV;
fRot = right.fRot;
fLogV = right.fLogV;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const Par01CalorimeterHit& Par01CalorimeterHit::operator=(const Par01CalorimeterHit& right)
{
fEdep = right.fEdep;
fPosition = right.fPosition;
fRot = right.fRot;
fLogV = right.fLogV;
return *this;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool Par01CalorimeterHit::operator==(const Par01CalorimeterHit &right) const
G4bool Par01CalorimeterHit::operator==(const Par01CalorimeterHit& right) const
{
return (this==&right) ? true : false;
return (this == &right) ? true : false;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -91,24 +93,19 @@ G4bool Par01CalorimeterHit::operator==(const Par01CalorimeterHit &right) const
void Par01CalorimeterHit::Draw()
{
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if(pVVisManager)
{
G4Transform3D trans(fRot,fPosition);
if (pVVisManager) {
G4Transform3D trans(fRot, fPosition);
G4VisAttributes attribs;
const G4VisAttributes* pVA = fLogV->GetVisAttributes();
if(pVA) attribs = *pVA;
G4Colour colour(1.,0.,0.);
if (pVA) attribs = *pVA;
G4Colour colour(1., 0., 0.);
attribs.SetColour(colour);
attribs.SetForceWireframe(false);
attribs.SetForceSolid(true);
pVVisManager->Draw(*fLogV,attribs,trans);
pVVisManager->Draw(*fLogV, attribs, trans);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par01CalorimeterHit::Print()
{
}
void Par01CalorimeterHit::Print() {}
@@ -30,26 +30,23 @@
//
#include "Par01CalorimeterSD.hh"
#include "Par01CalorimeterHit.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4Track.hh"
#include "G4ParticleDefinition.hh"
#include "G4SDManager.hh"
#include "G4Track.hh"
#include "G4VPhysicalVolume.hh"
#include "G4ios.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par01CalorimeterSD::Par01CalorimeterSD( G4String name,
G4int nCells,
G4String colName )
: G4VSensitiveDetector(name),
fNumberOfCells(nCells),
fHCID(-1)
Par01CalorimeterSD::Par01CalorimeterSD(G4String name, G4int nCells, G4String colName)
: G4VSensitiveDetector(name), fNumberOfCells(nCells), fHCID(-1)
{
G4String HCname;
collectionName.insert(HCname=colName);
collectionName.insert(HCname = colName);
fCellID = new G4int[fNumberOfCells];
}
@@ -57,19 +54,17 @@ Par01CalorimeterSD::Par01CalorimeterSD( G4String name,
Par01CalorimeterSD::~Par01CalorimeterSD()
{
delete [] fCellID;
delete[] fCellID;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par01CalorimeterSD::Initialize(G4HCofThisEvent*)
{
fCalCollection = new Par01CalorimeterHitsCollection
(SensitiveDetectorName,collectionName[0]);
for(G4int j=0;j<fNumberOfCells;j++)
{
fCellID[j] = -1;
}
fCalCollection = new Par01CalorimeterHitsCollection(SensitiveDetectorName, collectionName[0]);
for (G4int j = 0; j < fNumberOfCells; j++) {
fCellID[j] = -1;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -77,59 +72,53 @@ void Par01CalorimeterSD::Initialize(G4HCofThisEvent*)
G4bool Par01CalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
{
G4double edep = aStep->GetTotalEnergyDeposit();
if(edep<=0.) return false;
auto hist = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable());
if (edep <= 0.) return false;
auto hist = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable());
const G4VPhysicalVolume* physVol = hist->GetVolume();
G4int copyID = hist->GetReplicaNumber();
if(fCellID[copyID]==-1)
{
Par01CalorimeterHit* calHit =
new Par01CalorimeterHit(physVol->GetLogicalVolume());
calHit->SetEdep( edep );
G4AffineTransform aTrans = hist->GetHistory()->GetTopTransform();
aTrans.Invert();
calHit->SetPos(aTrans.NetTranslation());
calHit->SetRot(aTrans.NetRotation());
G4int icell = fCalCollection->insert( calHit );
fCellID[copyID] = icell - 1;
if(verboseLevel>0)
{ G4cout << " New Calorimeter Hit on CellID " << copyID << G4endl; }
if (fCellID[copyID] == -1) {
Par01CalorimeterHit* calHit = new Par01CalorimeterHit(physVol->GetLogicalVolume());
calHit->SetEdep(edep);
G4AffineTransform aTrans = hist->GetHistory()->GetTopTransform();
aTrans.Invert();
calHit->SetPos(aTrans.NetTranslation());
calHit->SetRot(aTrans.NetRotation());
G4int icell = fCalCollection->insert(calHit);
fCellID[copyID] = icell - 1;
if (verboseLevel > 0) {
G4cout << " New Calorimeter Hit on CellID " << copyID << G4endl;
}
else
{
(*fCalCollection)[fCellID[copyID]]->AddEdep( edep );
if(verboseLevel>0)
{ G4cout << " Energy added to CellID " << copyID << G4endl; }
}
else {
(*fCalCollection)[fCellID[copyID]]->AddEdep(edep);
if (verboseLevel > 0) {
G4cout << " Energy added to CellID " << copyID << G4endl;
}
}
return true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par01CalorimeterSD::EndOfEvent(G4HCofThisEvent*HCE)
void Par01CalorimeterSD::EndOfEvent(G4HCofThisEvent* HCE)
{
if(fHCID<0)
{ fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); }
HCE->AddHitsCollection( fHCID, fCalCollection );
if (fHCID < 0) {
fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
}
HCE->AddHitsCollection(fHCID, fCalCollection);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par01CalorimeterSD::clear()
{
}
void Par01CalorimeterSD::clear() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par01CalorimeterSD::DrawAll()
{
}
void Par01CalorimeterSD::DrawAll() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par01CalorimeterSD::PrintAll()
{
}
void Par01CalorimeterSD::PrintAll() {}
@@ -29,135 +29,122 @@
//
//
#include "Par01DetectorConstruction.hh"
#include "Par01CalorimeterSD.hh"
#include "Par01EMShowerModel.hh"
#include "Par01PiModel.hh"
#include "G4Box.hh"
#include "G4Colour.hh"
#include "G4Element.hh"
#include "G4ElementTable.hh"
#include "G4LogicalVolume.hh"
#include "G4Material.hh"
#include "G4MaterialTable.hh"
#include "G4Element.hh"
#include "G4ProductionCuts.hh"
#include "G4ElementTable.hh"
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4LogicalVolume.hh"
#include "G4ThreeVector.hh"
#include "G4PVPlacement.hh"
#include "G4SDManager.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "G4SystemOfUnits.hh"
#include "G4NistManager.hh"
#include "G4PVPlacement.hh"
#include "G4ProductionCuts.hh"
#include "G4RegionStore.hh"
#include "G4SDManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4ThreeVector.hh"
#include "G4Tubs.hh"
#include "G4VisAttributes.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par01DetectorConstruction::Par01DetectorConstruction()
{;}
{
;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par01DetectorConstruction::~Par01DetectorConstruction()
{;}
{
;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* Par01DetectorConstruction::Construct()
{
G4cout << "\nPar01DetectorConstruction....\n" << G4endl;
//--------- Material definition ---------
// Get nist material manager
G4NistManager* nistManager = G4NistManager::Instance();
// Build materials
G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
G4Material* csi = nistManager->FindOrBuildMaterial("G4_CESIUM_IODIDE");
G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
G4Material* csi = nistManager->FindOrBuildMaterial("G4_CESIUM_IODIDE");
G4Material* helium = nistManager->FindOrBuildMaterial("G4_He");
G4Material* iron = nistManager->FindOrBuildMaterial("G4_Fe");
G4Material* iron = nistManager->FindOrBuildMaterial("G4_Fe");
//--------- G4VSolid, G4LogicalVolume, G4VPhysicalVolume ---------
//--------------
// World:
//--------------
G4Box *WorldBox= new G4Box("WorldBox",400*cm, 400*cm, 400*cm);
G4LogicalVolume *WorldLog=new G4LogicalVolume(WorldBox,air,
"WorldLogical", 0, 0, 0);
G4PVPlacement *WorldPhys=new G4PVPlacement(0,G4ThreeVector(),
"WorldPhysical",
WorldLog,
0,false,0);
G4Box* WorldBox = new G4Box("WorldBox", 400 * cm, 400 * cm, 400 * cm);
G4LogicalVolume* WorldLog = new G4LogicalVolume(WorldBox, air, "WorldLogical", 0, 0, 0);
G4PVPlacement* WorldPhys =
new G4PVPlacement(0, G4ThreeVector(), "WorldPhysical", WorldLog, 0, false, 0);
// Size of detectors:
G4double detectSize = 125*cm;
G4double detectSize = 125 * cm;
//-----------------------------
// "Drift Chamber":
// Not used in parameterisation.
//-----------------------------
// -- Logical volume:
G4Box *driftChamberBox
= new G4Box("DriftChamberSolid", detectSize, detectSize, 40*cm);
G4LogicalVolume *driftChamberLog
= new G4LogicalVolume(driftChamberBox,helium,
"DriftChamberLogical", 0, 0, 0);
G4Box* driftChamberBox = new G4Box("DriftChamberSolid", detectSize, detectSize, 40 * cm);
G4LogicalVolume* driftChamberLog =
new G4LogicalVolume(driftChamberBox, helium, "DriftChamberLogical", 0, 0, 0);
// -- Placement:
// G4PVPlacement *driftChamberPhys =
new G4PVPlacement(0,G4ThreeVector(0., 0., 50*cm),
"DriftChamberPhysical",
driftChamberLog,
WorldPhys,false,0);
new G4PVPlacement(0, G4ThreeVector(0., 0., 50 * cm), "DriftChamberPhysical", driftChamberLog,
WorldPhys, false, 0);
//--------------------------
// "Calorimeter": used in
// parameterisation below
//--------------------------
// -- Logical volume:
G4Box *calorimeterBox
= new G4Box("CalorimeterSolid", detectSize, detectSize, 20*cm);
G4LogicalVolume *calorimeterLog = new G4LogicalVolume(calorimeterBox,air,
"CalorimeterLogical", 0, 0, 0);
G4Box* calorimeterBox = new G4Box("CalorimeterSolid", detectSize, detectSize, 20 * cm);
G4LogicalVolume* calorimeterLog =
new G4LogicalVolume(calorimeterBox, air, "CalorimeterLogical", 0, 0, 0);
// -- Placement:
G4PVPlacement *calorimeterPhys = new G4PVPlacement(0,G4ThreeVector(0., 0., 120*cm),
"CalorimeterPhysical",
calorimeterLog,
WorldPhys,false,0);
G4PVPlacement* calorimeterPhys = new G4PVPlacement(
0, G4ThreeVector(0., 0., 120 * cm), "CalorimeterPhysical", calorimeterLog, WorldPhys, false, 0);
//--------------------------------------
// The calorimeter is filled with
// crystals:
//--------------------------------------
// -- Logical volume:
G4double CrystalX = 2.5*cm;
G4double CrystalX = 2.5 * cm;
G4double CrystalY = CrystalX;
G4double CrystalZ = 20*cm;
G4Box *CrystalSolid = new G4Box("CrystalSolid", CrystalX, CrystalY, CrystalZ);
fCrystalLog = new G4LogicalVolume(CrystalSolid,csi,
"CrystalLogical", 0, 0, 0);
G4String tName1("Crystal"); // Allow all target physicals to share
G4double CrystalZ = 20 * cm;
G4Box* CrystalSolid = new G4Box("CrystalSolid", CrystalX, CrystalY, CrystalZ);
fCrystalLog = new G4LogicalVolume(CrystalSolid, csi, "CrystalLogical", 0, 0, 0);
G4String tName1("Crystal"); // Allow all target physicals to share
// same name (delayed copy)
// -- and placements inside the calorimeter:
G4int copyNo=0;
G4int copyNo = 0;
G4double xTlate, yTlate;
fnX = 48;
fnY = 48;
for (G4int j = 0; j < fnY; j++)
{
yTlate = -detectSize + 3*CrystalY + j*2*CrystalY;
for (G4int i = 0; i < fnX; i++)
{
xTlate = -detectSize + 3*CrystalX + i*2*CrystalX;
new G4PVPlacement(0,G4ThreeVector(xTlate,yTlate,0*cm),
tName1,
fCrystalLog,
calorimeterPhys,false,copyNo++);
}
for (G4int j = 0; j < fnY; j++) {
yTlate = -detectSize + 3 * CrystalY + j * 2 * CrystalY;
for (G4int i = 0; i < fnX; i++) {
xTlate = -detectSize + 3 * CrystalX + i * 2 * CrystalX;
new G4PVPlacement(0, G4ThreeVector(xTlate, yTlate, 0 * cm), tName1, fCrystalLog,
calorimeterPhys, false, copyNo++);
}
}
//--------------------------
// "Hadron Calorimeter": used
@@ -165,97 +152,85 @@ G4VPhysicalVolume* Par01DetectorConstruction::Construct()
// a parallel geometry
//--------------------------
// -- Logical volume:
G4Box *hadCaloBox
= new G4Box("HadCaloSolid", detectSize, detectSize, 50*cm);
G4LogicalVolume *hadCaloLog = new G4LogicalVolume(hadCaloBox,air,
"HadCaloLogical", 0, 0, 0);
G4Box* hadCaloBox = new G4Box("HadCaloSolid", detectSize, detectSize, 50 * cm);
G4LogicalVolume* hadCaloLog = new G4LogicalVolume(hadCaloBox, air, "HadCaloLogical", 0, 0, 0);
// -- Placement:
G4PVPlacement *hadCaloPhys = new G4PVPlacement(0,G4ThreeVector(0., 0., 200*cm),
"HadCaloPhysical",
hadCaloLog,
WorldPhys,false,0);
G4PVPlacement* hadCaloPhys = new G4PVPlacement(
0, G4ThreeVector(0., 0., 200 * cm), "HadCaloPhysical", hadCaloLog, WorldPhys, false, 0);
//--------------------------------------
// The calorimeter is filled with
// towers:
//--------------------------------------
// -- Logical volume:
G4double TowerX = 5*cm;
G4double TowerX = 5 * cm;
G4double TowerY = TowerX;
G4double TowerZ = 45*cm;
G4Box *TowerSolid = new G4Box("TowerSolid", TowerX, TowerY, TowerZ);
fTowerLog = new G4LogicalVolume(TowerSolid,iron,
"TowerLogical", 0, 0, 0);
G4double TowerZ = 45 * cm;
G4Box* TowerSolid = new G4Box("TowerSolid", TowerX, TowerY, TowerZ);
fTowerLog = new G4LogicalVolume(TowerSolid, iron, "TowerLogical", 0, 0, 0);
G4String tName2("Tower");
// -- and placements inside the calorimeter:
copyNo=0;
copyNo = 0;
fnXhad = 23;
fnYhad = 23;
for (G4int jj = 0; jj < fnYhad; jj++)
{
yTlate = -detectSize + 3*TowerY + jj*2*TowerY;
for (G4int i = 0; i < fnXhad; i++)
{
xTlate = -detectSize + 3*TowerX + i*2*TowerX;
new G4PVPlacement(0,G4ThreeVector(xTlate,yTlate,0*cm),
tName2,
fTowerLog,
hadCaloPhys,false,copyNo++);
}
for (G4int jj = 0; jj < fnYhad; jj++) {
yTlate = -detectSize + 3 * TowerY + jj * 2 * TowerY;
for (G4int i = 0; i < fnXhad; i++) {
xTlate = -detectSize + 3 * TowerX + i * 2 * TowerX;
new G4PVPlacement(0, G4ThreeVector(xTlate, yTlate, 0 * cm), tName2, fTowerLog, hadCaloPhys,
false, copyNo++);
}
// -- Makes the calorimeterLog volume becoming a G4Region:
G4Region* caloRegion = new G4Region("EM_calo_region");
caloRegion->AddRootLogicalVolume(calorimeterLog);
std::vector<double> cuts;
cuts.push_back(1.0*mm);cuts.push_back(1.0*mm);cuts.push_back(1.0*mm);cuts.push_back(1.0*mm);
caloRegion->SetProductionCuts(new G4ProductionCuts());
caloRegion->GetProductionCuts()->SetProductionCuts(cuts);
}
// Makes had. calo a region to:
G4Region* hadRegion = new G4Region("HAD_calo_region");
hadRegion->AddRootLogicalVolume(hadCaloLog);
cuts.clear();
cuts.push_back(1.0*cm);cuts.push_back(1.0*cm);cuts.push_back(1.0*cm);cuts.push_back(1.0*cm);
hadRegion->SetProductionCuts(new G4ProductionCuts());
hadRegion->GetProductionCuts()->SetProductionCuts(cuts);
// -- Makes the calorimeterLog volume becoming a G4Region:
G4Region* caloRegion = new G4Region("EM_calo_region");
caloRegion->AddRootLogicalVolume(calorimeterLog);
std::vector<double> cuts;
cuts.push_back(1.0 * mm);
cuts.push_back(1.0 * mm);
cuts.push_back(1.0 * mm);
cuts.push_back(1.0 * mm);
caloRegion->SetProductionCuts(new G4ProductionCuts());
caloRegion->GetProductionCuts()->SetProductionCuts(cuts);
// Makes had. calo a region to:
G4Region* hadRegion = new G4Region("HAD_calo_region");
hadRegion->AddRootLogicalVolume(hadCaloLog);
cuts.clear();
cuts.push_back(1.0 * cm);
cuts.push_back(1.0 * cm);
cuts.push_back(1.0 * cm);
cuts.push_back(1.0 * cm);
hadRegion->SetProductionCuts(new G4ProductionCuts());
hadRegion->GetProductionCuts()->SetProductionCuts(cuts);
//--------- Visualization attributes -------------------------------
WorldLog->SetVisAttributes(G4VisAttributes::GetInvisible());
auto driftchamberTubeVisAtt
= new G4VisAttributes(G4Colour(0.0,1.0,0.0));
auto driftchamberTubeVisAtt = new G4VisAttributes(G4Colour(0.0, 1.0, 0.0));
driftchamberTubeVisAtt->SetForceWireframe(true);
driftChamberLog->SetVisAttributes(driftchamberTubeVisAtt);
auto calorimeterBoxVisAtt
= new G4VisAttributes(G4Colour(0.0,0.0,1.0));
auto calorimeterBoxVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0));
calorimeterBoxVisAtt->SetForceWireframe(true);
calorimeterLog->SetVisAttributes(calorimeterBoxVisAtt);
auto crystalVisAtt
= new G4VisAttributes(G4Colour(1.0,0.0,0.0));
auto crystalVisAtt = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0));
crystalVisAtt->SetForceWireframe(true);
fCrystalLog->SetVisAttributes(crystalVisAtt);
auto hadCaloBoxVisAtt
= new G4VisAttributes(G4Colour(1.0,0.0,1.0));
auto hadCaloBoxVisAtt = new G4VisAttributes(G4Colour(1.0, 0.0, 1.0));
hadCaloBoxVisAtt->SetForceWireframe(true);
hadCaloLog->SetVisAttributes(hadCaloBoxVisAtt);
auto towerVisAtt
= new G4VisAttributes(G4Colour(0.5,0.0,1.0));
auto towerVisAtt = new G4VisAttributes(G4Colour(0.5, 0.0, 1.0));
towerVisAtt->SetForceWireframe(true);
fTowerLog->SetVisAttributes(towerVisAtt);
//------------------------------------------------------------------
//-----------------------
// Returns the pointer to
// the physical world:
@@ -270,23 +245,21 @@ void Par01DetectorConstruction::ConstructSDandField()
//--------- Sensitive detector -------------------------------------
G4SDManager* SDman = G4SDManager::GetSDMpointer();
G4String calorimeterSDname = "Par01/Calorimeter";
Par01CalorimeterSD* CalorimeterSD = new Par01CalorimeterSD( calorimeterSDname,
fnX*fnY,
"CalCollection" );
SDman->AddNewDetector( CalorimeterSD );
fCrystalLog->SetSensitiveDetector(CalorimeterSD);
Par01CalorimeterSD* CalorimeterSD =
new Par01CalorimeterSD(calorimeterSDname, fnX * fnY, "CalCollection");
SDman->AddNewDetector(CalorimeterSD);
fCrystalLog->SetSensitiveDetector(CalorimeterSD);
G4String hadCalorimeterSDname = "Par01/HadronCalorimeter";
Par01CalorimeterSD* HadCalorimeterSD = new Par01CalorimeterSD( hadCalorimeterSDname,
fnXhad*fnYhad,
"HadCollection" );
SDman->AddNewDetector( HadCalorimeterSD );
fTowerLog->SetSensitiveDetector(HadCalorimeterSD);
Par01CalorimeterSD* HadCalorimeterSD =
new Par01CalorimeterSD(hadCalorimeterSDname, fnXhad * fnYhad, "HadCollection");
SDman->AddNewDetector(HadCalorimeterSD);
fTowerLog->SetSensitiveDetector(HadCalorimeterSD);
// --------------- fast simulation ----------------------------
G4RegionStore* regionStore = G4RegionStore::GetInstance();
G4Region* caloRegion = regionStore->GetRegion("EM_calo_region");
// builds a model and sets it to the envelope of the calorimeter:
new Par01EMShowerModel("emShowerModel",caloRegion);
new Par01EMShowerModel("emShowerModel", caloRegion);
}
@@ -29,46 +29,45 @@
//
//
#include "Par01EMShowerModel.hh"
#include "Par01EnergySpot.hh"
#include "Randomize.hh"
#include "G4Electron.hh"
#include "G4Positron.hh"
#include "G4Gamma.hh"
#include "G4NistManager.hh"
#include "G4PhysicalConstants.hh"
#include "G4Positron.hh"
#include "G4SystemOfUnits.hh"
#include "G4TouchableHandle.hh"
#include "G4TransportationManager.hh"
#include "G4VSensitiveDetector.hh"
#include "G4TouchableHandle.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include "G4NistManager.hh"
#include "Randomize.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par01EMShowerModel::Par01EMShowerModel(G4String modelName, G4Region* envelope)
: G4VFastSimulationModel(modelName, envelope)
: G4VFastSimulationModel(modelName, envelope)
{
fFakeStep = new G4Step();
fFakePreStepPoint = fFakeStep->GetPreStepPoint();
fFakeStep = new G4Step();
fFakePreStepPoint = fFakeStep->GetPreStepPoint();
fFakePostStepPoint = fFakeStep->GetPostStepPoint();
fTouchableHandle = new G4TouchableHistory();
fpNavigator = new G4Navigator();
fNaviSetup = false;
fCsI = nullptr;
fTouchableHandle = new G4TouchableHistory();
fpNavigator = new G4Navigator();
fNaviSetup = false;
fCsI = nullptr;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par01EMShowerModel::Par01EMShowerModel(G4String modelName)
: G4VFastSimulationModel(modelName)
Par01EMShowerModel::Par01EMShowerModel(G4String modelName) : G4VFastSimulationModel(modelName)
{
fFakeStep = new G4Step();
fFakePreStepPoint = fFakeStep->GetPreStepPoint();
fFakeStep = new G4Step();
fFakePreStepPoint = fFakeStep->GetPreStepPoint();
fFakePostStepPoint = fFakeStep->GetPostStepPoint();
fTouchableHandle = new G4TouchableHistory();
fpNavigator = new G4Navigator();
fNaviSetup = false;
fCsI = nullptr;
fTouchableHandle = new G4TouchableHistory();
fpNavigator = new G4Navigator();
fNaviSetup = false;
fCsI = nullptr;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -83,10 +82,9 @@ Par01EMShowerModel::~Par01EMShowerModel()
G4bool Par01EMShowerModel::IsApplicable(const G4ParticleDefinition& particleType)
{
return
&particleType == G4Electron::ElectronDefinition() ||
&particleType == G4Positron::PositronDefinition() ||
&particleType == G4Gamma::GammaDefinition();
return &particleType == G4Electron::ElectronDefinition()
|| &particleType == G4Positron::PositronDefinition()
|| &particleType == G4Gamma::GammaDefinition();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -94,13 +92,12 @@ G4bool Par01EMShowerModel::IsApplicable(const G4ParticleDefinition& particleType
G4bool Par01EMShowerModel::ModelTrigger(const G4FastTrack& fastTrack)
{
// Applies the parameterisation above 100 MeV:
return fastTrack.GetPrimaryTrack()->GetKineticEnergy() > 100*MeV;
return fastTrack.GetPrimaryTrack()->GetKineticEnergy() > 100 * MeV;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par01EMShowerModel::DoIt(const G4FastTrack& fastTrack,
G4FastStep& fastStep)
void Par01EMShowerModel::DoIt(const G4FastTrack& fastTrack, G4FastStep& fastStep)
{
// Kill the parameterised particle:
fastStep.KillPrimaryTrack();
@@ -109,10 +106,9 @@ void Par01EMShowerModel::DoIt(const G4FastTrack& fastTrack,
// split into "energy spots" energy according to the shower shape:
Explode(fastTrack);
// and put those energy spots into the crystals:
BuildDetectorResponse();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -125,24 +121,26 @@ void Par01EMShowerModel::Explode(const G4FastTrack& fastTrack)
// Reduced quantities:
// -- critical energy in CsI:
G4double Ec = 800*MeV/(54. + 1.2); // 54 = mean Z of CsI
G4double Ec = 800 * MeV / (54. + 1.2); // 54 = mean Z of CsI
G4double Energy = fastTrack.GetPrimaryTrack()->GetKineticEnergy();
G4double y = Energy/Ec;
G4double y = Energy / Ec;
// compute value of parameter "a" of longitudinal profile, b assumed = 0.5
G4double a, tmax, b(0.5), C;
if (fastTrack.GetPrimaryTrack()->GetDefinition() == G4Gamma::GammaDefinition()) C = 0.5;
else C = -0.5;
if (fastTrack.GetPrimaryTrack()->GetDefinition() == G4Gamma::GammaDefinition())
C = 0.5;
else
C = -0.5;
tmax = 1.0 * (std::log(y) + C);
a = 1.0 + b*tmax;
a = 1.0 + b * tmax;
// t : reduced quantity = z/X0:
G4double t, bt;
if ( fCsI == nullptr ) fCsI = G4NistManager::Instance()->FindOrBuildMaterial("G4_CESIUM_IODIDE");
G4double X0 = fCsI->GetRadlen();
G4double t, bt;
if (fCsI == nullptr) fCsI = G4NistManager::Instance()->FindOrBuildMaterial("G4_CESIUM_IODIDE");
G4double X0 = fCsI->GetRadlen();
// Moliere radius:
G4double Es = 21*MeV;
G4double Rm = X0*Es/Ec;
G4double Es = 21 * MeV;
G4double Rm = X0 * Es / Ec;
// axis of the shower, in global reference frame:
G4ThreeVector xShower, yShower, zShower;
@@ -153,41 +151,40 @@ void Par01EMShowerModel::Explode(const G4FastTrack& fastTrack)
G4ThreeVector sShower = fastTrack.GetPrimaryTrack()->GetPosition();
// We shoot 100 spots of energy:
G4int nSpots = 100;
G4double deposit = Energy/double(nSpots);
G4int nSpots = 100;
G4double deposit = Energy / double(nSpots);
Par01EnergySpot eSpot;
eSpot.SetEnergy(deposit);
G4ThreeVector ePoint;
G4double z, r, phi;
feSpotList.clear();
for (int i = 0; i < nSpots; i++)
{
// Longitudinal profile:
// -- shoot z according to Gamma distribution:
bt = G4RandGamma::shoot(a,1.0);
t = bt/b;
z = t*X0;
// transverse profile:
// we set 90% of energy in one Rm,
// the rest between 1 and 3.5 Rm:
G4double xr = G4UniformRand();
if (xr < 0.9) r = xr/0.9*Rm;
else r = ((xr - 0.9)/0.1*2.5 + 1.0)*Rm;
phi = G4UniformRand()*twopi;
for (int i = 0; i < nSpots; i++) {
// Longitudinal profile:
// -- shoot z according to Gamma distribution:
bt = G4RandGamma::shoot(a, 1.0);
t = bt / b;
z = t * X0;
// build the position:
ePoint = sShower +
z*zShower +
r*std::cos(phi)*xShower + r*std::sin(phi)*yShower;
// and the energy spot:
eSpot.SetPosition(ePoint);
// transverse profile:
// we set 90% of energy in one Rm,
// the rest between 1 and 3.5 Rm:
G4double xr = G4UniformRand();
if (xr < 0.9)
r = xr / 0.9 * Rm;
else
r = ((xr - 0.9) / 0.1 * 2.5 + 1.0) * Rm;
phi = G4UniformRand() * twopi;
// Records the eSpot:
feSpotList.push_back(eSpot);
}
// build the position:
ePoint = sShower + z * zShower + r * std::cos(phi) * xShower + r * std::sin(phi) * yShower;
// and the energy spot:
eSpot.SetPosition(ePoint);
// Records the eSpot:
feSpotList.push_back(eSpot);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -195,21 +192,20 @@ void Par01EMShowerModel::Explode(const G4FastTrack& fastTrack)
void Par01EMShowerModel::BuildDetectorResponse()
{
// Does the assignation of the energy spots to the sensitive volumes:
for (size_t i = 0; i < feSpotList.size(); i++)
{
// Draw the energy spot:
// feSpotList[i].Draw();
// feSpotList[i].Print();
// "converts" the energy spot into the fake
// G4Step to pass to sensitive detector:
AssignSpotAndCallHit(feSpotList[i]);
}
for (size_t i = 0; i < feSpotList.size(); i++) {
// Draw the energy spot:
// feSpotList[i].Draw();
// feSpotList[i].Print();
// "converts" the energy spot into the fake
// G4Step to pass to sensitive detector:
AssignSpotAndCallHit(feSpotList[i]);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par01EMShowerModel::AssignSpotAndCallHit(const Par01EnergySpot &eSpot)
void Par01EMShowerModel::AssignSpotAndCallHit(const Par01EnergySpot& eSpot)
{
//
// "converts" the energy spot into the fake
@@ -221,47 +217,36 @@ void Par01EMShowerModel::AssignSpotAndCallHit(const Par01EnergySpot &eSpot)
// call sensitive part: taken/adapted from the stepping:
// Send G4Step information to Hit/Dig if the volume is sensitive
//
G4VPhysicalVolume* pCurrentVolume =
fFakeStep->GetPreStepPoint()->GetPhysicalVolume();
G4VPhysicalVolume* pCurrentVolume = fFakeStep->GetPreStepPoint()->GetPhysicalVolume();
G4VSensitiveDetector* pSensitive;
if( pCurrentVolume != nullptr )
{
pSensitive = pCurrentVolume->GetLogicalVolume()->
GetSensitiveDetector();
if( pSensitive != nullptr )
{
pSensitive->Hit(fFakeStep);
}
if (pCurrentVolume != nullptr) {
pSensitive = pCurrentVolume->GetLogicalVolume()->GetSensitiveDetector();
if (pSensitive != nullptr) {
pSensitive->Hit(fFakeStep);
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par01EMShowerModel::FillFakeStep(const Par01EnergySpot &eSpot)
void Par01EMShowerModel::FillFakeStep(const Par01EnergySpot& eSpot)
{
//-----------------------------------------------------------
// find in which volume the spot is.
//-----------------------------------------------------------
if (!fNaviSetup)
{
fpNavigator->
SetWorldVolume(G4TransportationManager::GetTransportationManager()->
GetNavigatorForTracking()->GetWorldVolume());
fpNavigator->
LocateGlobalPointAndUpdateTouchableHandle(eSpot.GetPosition(),
G4ThreeVector(0.,0.,0.),
fTouchableHandle,
false);
fNaviSetup = true;
}
else
{
fpNavigator->
LocateGlobalPointAndUpdateTouchableHandle(eSpot.GetPosition(),
G4ThreeVector(0.,0.,0.),
fTouchableHandle);
}
if (!fNaviSetup) {
fpNavigator->SetWorldVolume(G4TransportationManager::GetTransportationManager()
->GetNavigatorForTracking()
->GetWorldVolume());
fpNavigator->LocateGlobalPointAndUpdateTouchableHandle(
eSpot.GetPosition(), G4ThreeVector(0., 0., 0.), fTouchableHandle, false);
fNaviSetup = true;
}
else {
fpNavigator->LocateGlobalPointAndUpdateTouchableHandle(
eSpot.GetPosition(), G4ThreeVector(0., 0., 0.), fTouchableHandle);
}
//--------------------------------------
// Fills attribute of the G4Step needed
// by our sensitive detector:
@@ -30,17 +30,19 @@
//
#include "Par01EnergySpot.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "G4Polyline.hh"
#include "G4VVisManager.hh"
#include "G4Step.hh"
#include "G4SystemOfUnits.hh"
#include "G4VVisManager.hh"
#include "G4VisAttributes.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par01EnergySpot::Par01EnergySpot()
{;}
{
;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -53,45 +55,46 @@ Par01EnergySpot::Par01EnergySpot(const G4ThreeVector& point, G4double E)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par01EnergySpot::~Par01EnergySpot()
{;}
{
;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par01EnergySpot::Draw(G4Colour *color)
void Par01EnergySpot::Draw(G4Colour* color)
{
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if (pVVisManager)
{
G4Polyline polyline;
G4Colour colour(1.,.5,.5);
if (color != nullptr) colour = *color;
polyline.SetVisAttributes(colour);
G4ThreeVector pp(fPoint);
// Draw a "home made" marker:
// Will be better by using a real Marker:
pp.setZ(pp.z()+1*cm);
polyline.push_back(pp);
pp.setZ(pp.z()-2*cm);
polyline.push_back(pp);
pp = fPoint;
polyline.push_back(pp);
pp.setX(pp.x()+1*cm);
polyline.push_back(pp);
pp.setX(pp.x()-2*cm);
polyline.push_back(pp);
pp = fPoint;
polyline.push_back(pp);
pp.setY(pp.y()+1*cm);
polyline.push_back(pp);
pp.setY(pp.y()-2*cm);
polyline.push_back(pp);
pVVisManager -> Draw(polyline);
}
if (pVVisManager) {
G4Polyline polyline;
G4Colour colour(1., .5, .5);
if (color != nullptr) colour = *color;
polyline.SetVisAttributes(colour);
G4ThreeVector pp(fPoint);
// Draw a "home made" marker:
// Will be better by using a real Marker:
pp.setZ(pp.z() + 1 * cm);
polyline.push_back(pp);
pp.setZ(pp.z() - 2 * cm);
polyline.push_back(pp);
pp = fPoint;
polyline.push_back(pp);
pp.setX(pp.x() + 1 * cm);
polyline.push_back(pp);
pp.setX(pp.x() - 2 * cm);
polyline.push_back(pp);
pp = fPoint;
polyline.push_back(pp);
pp.setY(pp.y() + 1 * cm);
polyline.push_back(pp);
pp.setY(pp.y() - 2 * cm);
polyline.push_back(pp);
pVVisManager->Draw(polyline);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par01EnergySpot::Print()
{
G4cout << " Par01EnergySpot {E = " << fEnergy << "; Position = " << fPoint << " }"<< G4endl;
G4cout << " Par01EnergySpot {E = " << fEnergy << "; Position = " << fPoint << " }" << G4endl;
}
@@ -28,28 +28,32 @@
//
//
#include "Par01ParallelWorldForPion.hh"
#include "Par01PionShowerModel.hh"
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
#include "G4Region.hh"
#include "G4PVPlacement.hh"
#include "G4ThreeVector.hh"
#include "G4SystemOfUnits.hh"
#include "G4NistManager.hh"
#include "G4PVPlacement.hh"
#include "G4Region.hh"
#include "G4RegionStore.hh"
#include "G4SystemOfUnits.hh"
#include "G4ThreeVector.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par01ParallelWorldForPion::Par01ParallelWorldForPion(G4String worldName)
: G4VUserParallelWorld(worldName)
{;}
{
;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par01ParallelWorldForPion::~Par01ParallelWorldForPion()
{;}
{
;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -57,48 +61,42 @@ void Par01ParallelWorldForPion::Construct()
{
// -- Get nist material manager
G4NistManager* nistManager = G4NistManager::Instance();
// Build materials
G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
// -------------------------------
// Build parallel/ghost geometry:
// -------------------------------
// -- Obtain clone of mass geometry world from GetWorld() base class utility:
G4VPhysicalVolume* ghostWorld = GetWorld();
// -- Why needed ? No default ?
ghostWorld->GetLogicalVolume()->SetMaterial(air);
G4Region* parallelWorldRegion = new G4Region("ParallelWorldRegion");
parallelWorldRegion->AddRootLogicalVolume(ghostWorld->GetLogicalVolume());
// -- Create box for encompassing Elec.+Had. calorimeters together:
G4double detectSize = 125*cm;
G4Box *ghostBox
= new G4Box("GhostBox", detectSize+5*cm, detectSize+5*cm, 80*cm);
G4double detectSize = 125 * cm;
G4Box* ghostBox = new G4Box("GhostBox", detectSize + 5 * cm, detectSize + 5 * cm, 80 * cm);
// -- Build the subsequent logical volume:
G4LogicalVolume* ghostLogical
= new G4LogicalVolume(ghostBox,
air, // -- no material : IMPOSSIBLE !!!
"GhostLogical",
0, 0, 0);
G4LogicalVolume* ghostLogical = new G4LogicalVolume(ghostBox,
air, // -- no material : IMPOSSIBLE !!!
"GhostLogical", 0, 0, 0);
// -- And place this logical volume in the parallel geometry:
new G4PVPlacement(0,G4ThreeVector(0., 0., 175*cm),
"GhostPhysical",
ghostLogical,
ghostWorld,false,0);
new G4PVPlacement(0, G4ThreeVector(0., 0., 175 * cm), "GhostPhysical", ghostLogical, ghostWorld,
false, 0);
// -----------------------
// Setup fast simulation:
// -----------------------
// -- Make Elec+Had logical volume becoming a region:
G4cout << "Declaring region..." << G4endl;
G4Region* ghostRegion = new G4Region("GhostCalorimeterRegion");
G4cout << "... region declared. Setting it the ghostLogical volume..." << G4endl;
ghostRegion->AddRootLogicalVolume(ghostLogical);
G4cout << "... succes.\n" << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -106,9 +104,8 @@ void Par01ParallelWorldForPion::Construct()
void Par01ParallelWorldForPion::ConstructSD()
{
G4RegionStore* regionStore = G4RegionStore::GetInstance();
G4Region* ghostRegion = regionStore->GetRegion("GhostCalorimeterRegion");
// -- Attach fast simulation model (create the G4FastSimulationManager if needed):
new Par01PionShowerModel("ghostPionShowerModel",ghostRegion);
new Par01PionShowerModel("ghostPionShowerModel", ghostRegion);
}
@@ -30,76 +30,76 @@
//
#include "Par01PiModel.hh"
#include "G4Gamma.hh"
#include "G4PionMinus.hh"
#include "G4PionPlus.hh"
#include "G4Gamma.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par01PiModel::Par01PiModel(G4Region *anEnvelope) :
G4VFastSimulationModel("Par01PiModel",anEnvelope)
{;}
Par01PiModel::Par01PiModel(G4Region* anEnvelope)
: G4VFastSimulationModel("Par01PiModel", anEnvelope)
{
;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par01PiModel::~Par01PiModel()
{;}
{
;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool Par01PiModel::IsApplicable(const G4ParticleDefinition& particleType)
{
return
&particleType == G4PionMinus::PionMinusDefinition() ||
&particleType == G4PionPlus::PionPlusDefinition();
return &particleType == G4PionMinus::PionMinusDefinition()
|| &particleType == G4PionPlus::PionPlusDefinition();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool Par01PiModel::ModelTrigger(const G4FastTrack& fastTrack) {
G4bool Par01PiModel::ModelTrigger(const G4FastTrack& fastTrack)
{
//-------------------------------------------------------------
// UserTrigger() method: method which has to decide if
// the parameterisation has to be applied.
// Here ModelTrigger() asks the user (ie you) a 0/1 answer.
//
// Note that quantities like the local/global position/direction etc..
// are available at this level via the fastTrack parameter (allowing
// are available at this level via the fastTrack parameter (allowing
// to check distance from boundaries, see below to allow the decision)
//--------------------------------------------------------------
G4cout << "\nPar01PiModel::ModelTrigger() called:" << G4endl;
G4cout << "--------------------------------" << G4endl;
G4cout << "(particle is a " << fastTrack.GetPrimaryTrack()->
GetDefinition()->GetParticleName() << " )\n" << G4endl;
G4cout << "--------------------------------" << G4endl;
G4cout << "(particle is a " << fastTrack.GetPrimaryTrack()->GetDefinition()->GetParticleName()
<< " )\n"
<< G4endl;
// -- Examples of available informations:
// -- position:
G4cout << " Track position: " <<
fastTrack.GetPrimaryTrack()->GetPosition() << "(global coord.)" <<
fastTrack.GetPrimaryTrackLocalPosition() << "(in envelope coord.)"
<< G4endl;
G4cout << " Track position: " << fastTrack.GetPrimaryTrack()->GetPosition()
<< "(global coord.)" << fastTrack.GetPrimaryTrackLocalPosition() << "(in envelope coord.)"
<< G4endl;
// -- direction:
G4cout << " Track direction:" <<
fastTrack.GetPrimaryTrack()->GetMomentum().unit() <<
"(global coord.)" <<
fastTrack.GetPrimaryTrackLocalDirection() << "(in envelope coord.)" <<
G4endl;
G4cout << " Track direction:" << fastTrack.GetPrimaryTrack()->GetMomentum().unit()
<< "(global coord.)" << fastTrack.GetPrimaryTrackLocalDirection() << "(in envelope coord.)"
<< G4endl;
return true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par01PiModel::DoIt(const G4FastTrack& fastTrack,
G4FastStep& fastStep)
//--------------------------------------------------------
//
// User method to code the parameterisation properly said.
//
//--------------------------------------------------------
void Par01PiModel::DoIt(const G4FastTrack& fastTrack, G4FastStep& fastStep)
//--------------------------------------------------------
//
// User method to code the parameterisation properly said.
//
//--------------------------------------------------------
{
//------------------------------------------------
// The primary track continues along its direction.
// One secondary (a photon) is added:
@@ -113,48 +113,43 @@ void Par01PiModel::DoIt(const G4FastTrack& fastTrack,
//------------------------------
G4ThreeVector position;
G4double distance;
distance = fastTrack.GetEnvelopeSolid()->
DistanceToOut(fastTrack.GetPrimaryTrackLocalPosition(),
fastTrack.GetPrimaryTrackLocalDirection());
position = fastTrack.GetPrimaryTrackLocalPosition() +
distance*fastTrack.GetPrimaryTrackLocalDirection();
distance = fastTrack.GetEnvelopeSolid()->DistanceToOut(fastTrack.GetPrimaryTrackLocalPosition(),
fastTrack.GetPrimaryTrackLocalDirection());
position =
fastTrack.GetPrimaryTrackLocalPosition() + distance * fastTrack.GetPrimaryTrackLocalDirection();
// -- set final position:
fastStep.ProposePrimaryTrackFinalPosition(position);
//---------------------------
// Secondary:
// Adds one "secondary":
//---------------------------
// -- First, user has to say how many secondaries will be created:
fastStep.SetNumberOfSecondaryTracks(1);
//------------------------
// -- Build the secondary:
//------------------------
// -- direction:
G4ParticleMomentum direction(fastTrack.GetPrimaryTrackLocalDirection());
direction.setZ(direction.z()*0.5);
direction.setY(direction.y()+direction.z()*0.1);
direction = direction.unit(); // necessary ?
direction.setZ(direction.z() * 0.5);
direction.setY(direction.y() + direction.z() * 0.1);
direction = direction.unit(); // necessary ?
// -- dynamics (Note that many constructors exists for G4DynamicParticle
// -- see prototype/particle+matter/particles/management/include/G4DynamicParticle.hh)
G4DynamicParticle dynamique(G4Gamma::GammaDefinition(),
direction,
fastTrack.GetPrimaryTrack()->
GetKineticEnergy()/2.);
G4DynamicParticle dynamique(G4Gamma::GammaDefinition(), direction,
fastTrack.GetPrimaryTrack()->GetKineticEnergy() / 2.);
// -- position:
G4double Dist;
Dist = fastTrack.GetEnvelopeSolid()->
DistanceToOut(fastTrack.GetPrimaryTrackLocalPosition(),
direction);
Dist = fastTrack.GetEnvelopeSolid()->DistanceToOut(fastTrack.GetPrimaryTrackLocalPosition(),
direction);
G4ThreeVector posi;
posi = fastTrack.GetPrimaryTrackLocalPosition() + Dist*direction;
posi = fastTrack.GetPrimaryTrackLocalPosition() + Dist * direction;
//------------------------------------
//-- Creation of the secondary Track:
//------------------------------------
fastStep.CreateSecondaryTrack(dynamique, posi,
fastTrack.GetPrimaryTrack()->GetGlobalTime());
fastStep.CreateSecondaryTrack(dynamique, posi, fastTrack.GetPrimaryTrack()->GetGlobalTime());
}
@@ -29,44 +29,42 @@
//
//
#include "Par01PionShowerModel.hh"
#include "Par01EnergySpot.hh"
#include "Randomize.hh"
#include "G4PionMinus.hh"
#include "G4PionPlus.hh"
#include "G4TransportationManager.hh"
#include "G4VSensitiveDetector.hh"
#include "G4TouchableHistory.hh"
#include "G4Colour.hh"
#include "G4PhysicalConstants.hh"
#include "G4PionMinus.hh"
#include "G4PionPlus.hh"
#include "G4SystemOfUnits.hh"
#include "G4TouchableHistory.hh"
#include "G4TransportationManager.hh"
#include "G4VSensitiveDetector.hh"
#include "Randomize.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par01PionShowerModel::Par01PionShowerModel(G4String modelName, G4Region* envelope)
: G4VFastSimulationModel(modelName, envelope)
: G4VFastSimulationModel(modelName, envelope)
{
fFakeStep = new G4Step();
fFakePreStepPoint = fFakeStep->GetPreStepPoint();
fFakeStep = new G4Step();
fFakePreStepPoint = fFakeStep->GetPreStepPoint();
fFakePostStepPoint = fFakeStep->GetPostStepPoint();
fTouchableHandle = new G4TouchableHistory();
fpNavigator = new G4Navigator();
fNaviSetup = false;
fTouchableHandle = new G4TouchableHistory();
fpNavigator = new G4Navigator();
fNaviSetup = false;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par01PionShowerModel::Par01PionShowerModel(G4String modelName)
: G4VFastSimulationModel(modelName)
Par01PionShowerModel::Par01PionShowerModel(G4String modelName) : G4VFastSimulationModel(modelName)
{
fFakeStep = new G4Step();
fFakePreStepPoint = fFakeStep->GetPreStepPoint();
fFakeStep = new G4Step();
fFakePreStepPoint = fFakeStep->GetPreStepPoint();
fFakePostStepPoint = fFakeStep->GetPostStepPoint();
fTouchableHandle = new G4TouchableHistory();
fpNavigator = new G4Navigator();
fNaviSetup = false;
fTouchableHandle = new G4TouchableHistory();
fpNavigator = new G4Navigator();
fNaviSetup = false;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -81,9 +79,8 @@ Par01PionShowerModel::~Par01PionShowerModel()
G4bool Par01PionShowerModel::IsApplicable(const G4ParticleDefinition& particleType)
{
return
&particleType == G4PionMinus::PionMinusDefinition() ||
&particleType == G4PionPlus::PionPlusDefinition();
return &particleType == G4PionMinus::PionMinusDefinition()
|| &particleType == G4PionPlus::PionPlusDefinition();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -97,8 +94,7 @@ G4bool Par01PionShowerModel::ModelTrigger(const G4FastTrack&)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par01PionShowerModel::DoIt(const G4FastTrack& fastTrack,
G4FastStep& fastStep)
void Par01PionShowerModel::DoIt(const G4FastTrack& fastTrack, G4FastStep& fastStep)
{
// G4cout << "Par01PionShowerModel::DoIt" << G4endl;
@@ -109,7 +105,7 @@ void Par01PionShowerModel::DoIt(const G4FastTrack& fastTrack,
// split into "energy spots" energy according to the shower shape:
Explode(fastTrack);
// and put those energy spots into the crystals:
BuildDetectorResponse();
}
@@ -126,25 +122,23 @@ void Par01PionShowerModel::Explode(const G4FastTrack& fastTrack)
// center of the shower, we put at the middle of the ghost:
G4ThreeVector showerCenter;
G4double distOut;
distOut = fastTrack.GetEnvelopeSolid()->
DistanceToOut(fastTrack.GetPrimaryTrackLocalPosition(),
fastTrack.GetPrimaryTrackLocalDirection());
showerCenter = fastTrack.GetPrimaryTrackLocalPosition() +
(distOut/2.)*fastTrack.GetPrimaryTrackLocalDirection();
distOut = fastTrack.GetEnvelopeSolid()->DistanceToOut(fastTrack.GetPrimaryTrackLocalPosition(),
fastTrack.GetPrimaryTrackLocalDirection());
showerCenter = fastTrack.GetPrimaryTrackLocalPosition()
+ (distOut / 2.) * fastTrack.GetPrimaryTrackLocalDirection();
showerCenter = fastTrack.GetInverseAffineTransformation()->
TransformPoint(showerCenter);
showerCenter = fastTrack.GetInverseAffineTransformation()->TransformPoint(showerCenter);
// axis of the shower, in global reference frame:
G4ThreeVector xShower, yShower, zShower;
zShower = fastTrack.GetPrimaryTrack()->GetMomentumDirection();
xShower = zShower.orthogonal();
yShower = zShower.cross(xShower);
// shoot the energy spots:
G4double Energy = fastTrack.GetPrimaryTrack()->GetKineticEnergy();
G4int nSpot = 50;
G4double deposit = Energy/double(nSpot);
G4double deposit = Energy / double(nSpot);
Par01EnergySpot eSpot;
eSpot.SetEnergy(deposit);
G4ThreeVector ePoint;
@@ -153,17 +147,14 @@ void Par01PionShowerModel::Explode(const G4FastTrack& fastTrack)
feSpotList.clear();
G4double z, r, phi;
for (int i = 0; i < nSpot; i++)
{
z = G4RandGauss::shoot(0,20*cm);
r = G4RandGauss::shoot(0,10*cm);
phi = G4UniformRand()*twopi;
ePoint = showerCenter +
z*zShower +
r*std::cos(phi)*xShower + r*std::sin(phi)*yShower;
eSpot.SetPosition(ePoint);
feSpotList.push_back(eSpot);
}
for (int i = 0; i < nSpot; i++) {
z = G4RandGauss::shoot(0, 20 * cm);
r = G4RandGauss::shoot(0, 10 * cm);
phi = G4UniformRand() * twopi;
ePoint = showerCenter + z * zShower + r * std::cos(phi) * xShower + r * std::sin(phi) * yShower;
eSpot.SetPosition(ePoint);
feSpotList.push_back(eSpot);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -171,22 +162,21 @@ void Par01PionShowerModel::Explode(const G4FastTrack& fastTrack)
void Par01PionShowerModel::BuildDetectorResponse()
{
// Does the assignation of the energy spots to the sensitive volumes:
for (size_t i = 0; i < feSpotList.size(); i++)
{
// Draw the energy spot:
// G4Colour red(1.,0.,0.);
// feSpotList[i].Draw(&red);
// feSpotList[i].Print();
// "converts" the energy spot into the fake
// G4Step to pass to sensitive detector:
AssignSpotAndCallHit(feSpotList[i]);
}
for (size_t i = 0; i < feSpotList.size(); i++) {
// Draw the energy spot:
// G4Colour red(1.,0.,0.);
// feSpotList[i].Draw(&red);
// feSpotList[i].Print();
// "converts" the energy spot into the fake
// G4Step to pass to sensitive detector:
AssignSpotAndCallHit(feSpotList[i]);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par01PionShowerModel::AssignSpotAndCallHit(const Par01EnergySpot &eSpot)
void Par01PionShowerModel::AssignSpotAndCallHit(const Par01EnergySpot& eSpot)
{
//
// "converts" the energy spot into the fake
@@ -198,47 +188,36 @@ void Par01PionShowerModel::AssignSpotAndCallHit(const Par01EnergySpot &eSpot)
// call sensitive part: taken/adapted from the stepping:
// Send G4Step information to Hit/Dig if the volume is sensitive
//
G4VPhysicalVolume* pCurrentVolume =
fFakeStep->GetPreStepPoint()->GetPhysicalVolume();
G4VPhysicalVolume* pCurrentVolume = fFakeStep->GetPreStepPoint()->GetPhysicalVolume();
G4VSensitiveDetector* pSensitive;
if( pCurrentVolume != nullptr )
{
pSensitive = pCurrentVolume->GetLogicalVolume()->
GetSensitiveDetector();
if( pSensitive != nullptr )
{
pSensitive->Hit(fFakeStep);
}
if (pCurrentVolume != nullptr) {
pSensitive = pCurrentVolume->GetLogicalVolume()->GetSensitiveDetector();
if (pSensitive != nullptr) {
pSensitive->Hit(fFakeStep);
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par01PionShowerModel::FillFakeStep(const Par01EnergySpot &eSpot)
void Par01PionShowerModel::FillFakeStep(const Par01EnergySpot& eSpot)
{
//-----------------------------------------------------------
// find in which volume the spot is.
//-----------------------------------------------------------
if (!fNaviSetup)
{
fpNavigator->
SetWorldVolume(G4TransportationManager::GetTransportationManager()->
GetNavigatorForTracking()->GetWorldVolume());
fpNavigator->
LocateGlobalPointAndUpdateTouchableHandle(eSpot.GetPosition(),
G4ThreeVector(0.,0.,0.),
fTouchableHandle,
false);
fNaviSetup = true;
}
else
{
fpNavigator->
LocateGlobalPointAndUpdateTouchableHandle(eSpot.GetPosition(),
G4ThreeVector(0.,0.,0.),
fTouchableHandle);
}
if (!fNaviSetup) {
fpNavigator->SetWorldVolume(G4TransportationManager::GetTransportationManager()
->GetNavigatorForTracking()
->GetWorldVolume());
fpNavigator->LocateGlobalPointAndUpdateTouchableHandle(
eSpot.GetPosition(), G4ThreeVector(0., 0., 0.), fTouchableHandle, false);
fNaviSetup = true;
}
else {
fpNavigator->LocateGlobalPointAndUpdateTouchableHandle(
eSpot.GetPosition(), G4ThreeVector(0., 0., 0.), fTouchableHandle);
}
//--------------------------------------
// Fills attribute of the G4Step needed
// by our sensitive detector:
@@ -32,11 +32,11 @@
#include "Par01PrimaryGeneratorAction.hh"
#include "G4Event.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "globals.hh"
#include "G4SystemOfUnits.hh"
#include "globals.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -47,13 +47,12 @@ Par01PrimaryGeneratorAction::Par01PrimaryGeneratorAction()
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4String particleName;
G4ParticleDefinition* particle
= particleTable->FindParticle(particleName="geantino");
G4ParticleDefinition* particle = particleTable->FindParticle(particleName = "geantino");
fParticleGun->SetParticleDefinition(particle);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,1.,0.));
fParticleGun->SetParticleEnergy(100.*GeV);
fParticleGun->SetParticlePosition(G4ThreeVector(0.*cm,-300.*cm,0.*cm));
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0., 1., 0.));
fParticleGun->SetParticleEnergy(100. * GeV);
fParticleGun->SetParticlePosition(G4ThreeVector(0. * cm, -300. * cm, 0. * cm));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -75,5 +74,4 @@ void Par01PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
G4ParticleGun* Par01PrimaryGeneratorAction::GetParticleGun()
{
return fParticleGun;
}
}
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gdml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd">
<gdml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd">
<define/>
@@ -73,18 +73,18 @@
</materials>
<solids>
<tube aunit="deg" deltaphi="360" lunit="mm" name="TrackerBarrel" rmax="1490" rmin="500" startphi="0" z="6000"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="ECalBarrel0x7ff5f9e7b300" rmax="2990" rmin="1500" startphi="0" z="6000"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="TrackerBarrel" rmax="1490" rmin="500" startphi="0" z="6000"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="ECalBarrel0x7ff5f9e7b300" rmax="2990" rmin="1500" startphi="0" z="6000"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="ECalEndCap_10x7ff5f9e7b630" rmax="2990" rmin="1500" startphi="0" z="2000"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="ECalEndCap_20x7ff5f9e7bc30" rmax="2990" rmin="1500" startphi="0" z="2000"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="ECalForward_10x7ff5f9e7c050" rmax="3000" rmin="500" startphi="0" z="1000"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="ECalForward_20x7ff5f9e7c330" rmax="3000" rmin="500" startphi="0" z="1000"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="ECalForward_20x7ff5f9e7c330" rmax="3000" rmin="500" startphi="0" z="1000"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="HCalBarrel0x7ff5f9e7cf80" rmax="8000" rmin="3000" startphi="0" z="6000"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="HCalEndCap_10x7ff5f9e7d3d0" rmax="8000" rmin="3000" startphi="0" z="2000"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="HCalEndCap_20x7ff5f9e7d6b0" rmax="8000" rmin="3000" startphi="0" z="2000"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="HCalForward_10x7ff5f9e7b840" rmax="4000" rmin="500" startphi="0" z="2000"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="HCalForward_20x7ff5f9e7dc40" rmax="4000" rmin="500" startphi="0" z="2000"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="HCalForward_20x7ff5f9e7dc40" rmax="4000" rmin="500" startphi="0" z="2000"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="MuonEndCap_10x7ff5f9e7eec0" rmax="15500" rmin="3000" startphi="0" z="100"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="MuonEndCap_20x7ff5f9e7f1a0" rmax="15500" rmin="3000" startphi="0" z="100"/>
@@ -97,155 +97,155 @@
<tube aunit="deg" deltaphi="360" lunit="mm" name="MuonForward_30x7ff5f9e806d0" rmax="5000" rmin="500" startphi="0" z="100"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="MuonForward_40x7ff5f9e809a0" rmax="5000" rmin="500" startphi="0" z="100"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="MuonForward_50x7ff5f9e80c70" rmax="5000" rmin="500" startphi="0" z="100"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="MuonForward_60x7ff5f9e80f40" rmax="5000" rmin="500" startphi="0" z="100"/>
<tube aunit="deg" deltaphi="360" lunit="mm" name="MuonForward_60x7ff5f9e80f40" rmax="5000" rmin="500" startphi="0" z="100"/>
<box lunit="mm" name="world_volume0x7ff5f9e788a0" x="100000" y="100000" z="200000"/>
</solids>
<structure>
<!-- Tracker -->
<structure>
<!-- Tracker -->
<volume name="TrackerBarrelLog">
<materialref ref="Beryllium0x7ff5f9e3baf0"/>
<solidref ref="TrackerBarrel"/>
<solidref ref="TrackerBarrel"/>
<auxiliary auxtype="FastSimModel" auxvalue="TrackerBarrel"/>
</volume>
<!-- EM Calorimeters -->
</volume>
<!-- EM Calorimeters -->
<volume name="ECalBarrel0x7ff5f9e7b420">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="ECalBarrel0x7ff5f9e7b300"/>
<solidref ref="ECalBarrel0x7ff5f9e7b300"/>
<auxiliary auxtype="FastSimModel" auxvalue="ECalBarrel"/>
</volume>
</volume>
<volume name="ECalEndCap_10x7ff5f9e7b710">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="ECalEndCap_10x7ff5f9e7b630"/>
<solidref ref="ECalEndCap_10x7ff5f9e7b630"/>
<auxiliary auxtype="FastSimModel" auxvalue="ECalEndCap1"/>
</volume>
<volume name="ECalEndCap_20x7ff5f9e7bd10">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="ECalEndCap_20x7ff5f9e7bc30"/>
<solidref ref="ECalEndCap_20x7ff5f9e7bc30"/>
<auxiliary auxtype="FastSimModel" auxvalue="ECalEndCap2"/>
</volume>
<volume name="ECalForward_10x7ff5f9e7c130">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="ECalForward_10x7ff5f9e7c050"/>
<solidref ref="ECalForward_10x7ff5f9e7c050"/>
<auxiliary auxtype="FastSimModel" auxvalue="ECalForward1"/>
</volume>
<volume name="ECalForward_20x7ff5f9e7c490">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="ECalForward_20x7ff5f9e7c330"/>
<solidref ref="ECalForward_20x7ff5f9e7c330"/>
<auxiliary auxtype="FastSimModel" auxvalue="ECalForward2"/>
</volume>
<!-- Hadron Calorimeters -->
</volume>
<!-- Hadron Calorimeters -->
<volume name="HCalBarrel0x7ff5f9e7d060">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="HCalBarrel0x7ff5f9e7cf80"/>
<solidref ref="HCalBarrel0x7ff5f9e7cf80"/>
<auxiliary auxtype="FastSimModel" auxvalue="HCalBarrel"/>
</volume>
<volume name="HCalEndCap_10x7ff5f9e7d4b0">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="HCalEndCap_10x7ff5f9e7d3d0"/>
<solidref ref="HCalEndCap_10x7ff5f9e7d3d0"/>
<auxiliary auxtype="FastSimModel" auxvalue="HCalEndCap1"/>
</volume>
<volume name="HCalEndCap_20x7ff5f9e7d790">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="HCalEndCap_20x7ff5f9e7d6b0"/>
<solidref ref="HCalEndCap_20x7ff5f9e7d6b0"/>
<auxiliary auxtype="FastSimModel" auxvalue="HCalEndCap2"/>
</volume>
<volume name="HCalForward_10x7ff5f9e7daf0">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="HCalForward_10x7ff5f9e7b840"/>
<solidref ref="HCalForward_10x7ff5f9e7b840"/>
<auxiliary auxtype="FastSimModel" auxvalue="HCalForward1"/>
</volume>
<volume name="HCalForward_20x7ff5f9e7b9d0">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="HCalForward_20x7ff5f9e7dc40"/>
<solidref ref="HCalForward_20x7ff5f9e7dc40"/>
<auxiliary auxtype="FastSimModel" auxvalue="HCalForward2"/>
</volume>
<!-- Muon Detectors -->
</volume>
<!-- Muon Detectors -->
<volume name="MuonEndCap_10x7ff5f9e7efa0">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="MuonEndCap_10x7ff5f9e7eec0"/>
<solidref ref="MuonEndCap_10x7ff5f9e7eec0"/>
<auxiliary auxtype="FastSimModel" auxvalue="MuonEndCap1"/>
</volume>
<volume name="MuonEndCap_20x7ff5f9e7f280">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="MuonEndCap_20x7ff5f9e7f1a0"/>
<solidref ref="MuonEndCap_20x7ff5f9e7f1a0"/>
<auxiliary auxtype="FastSimModel" auxvalue="MuonEndCap2"/>
</volume>
<volume name="MuonEndCap_30x7ff5f9e7f550">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="MuonEndCap_30x7ff5f9e7f470"/>
<solidref ref="MuonEndCap_30x7ff5f9e7f470"/>
<auxiliary auxtype="FastSimModel" auxvalue="MuonEndCap3"/>
</volume>
<volume name="MuonEndCap_40x7ff5f9e7f820">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="MuonEndCap_40x7ff5f9e7f740"/>
<solidref ref="MuonEndCap_40x7ff5f9e7f740"/>
<auxiliary auxtype="FastSimModel" auxvalue="MuonEndCap4"/>
</volume>
<volume name="MuonEndCap_50x7ff5f9e7faf0">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="MuonEndCap_50x7ff5f9e7fa10"/>
<solidref ref="MuonEndCap_50x7ff5f9e7fa10"/>
<auxiliary auxtype="FastSimModel" auxvalue="MuonEndCap5"/>
</volume>
<volume name="MuonEndCap_60x7ff5f9e7fdc0">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="MuonEndCap_60x7ff5f9e7fce0"/>
<solidref ref="MuonEndCap_60x7ff5f9e7fce0"/>
<auxiliary auxtype="FastSimModel" auxvalue="MuonEndCap6"/>
</volume>
<volume name="MuonForward_10x7ff5f9e80200">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="MuonForward_10x7ff5f9e80120"/>
<solidref ref="MuonForward_10x7ff5f9e80120"/>
<auxiliary auxtype="FastSimModel" auxvalue="MuonForward1"/>
</volume>
<volume name="MuonForward_20x7ff5f9e804e0">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="MuonForward_20x7ff5f9e80400"/>
<solidref ref="MuonForward_20x7ff5f9e80400"/>
<auxiliary auxtype="FastSimModel" auxvalue="MuonForward2"/>
</volume>
<volume name="MuonForward_30x7ff5f9e807b0">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="MuonForward_30x7ff5f9e806d0"/>
<solidref ref="MuonForward_30x7ff5f9e806d0"/>
<auxiliary auxtype="FastSimModel" auxvalue="MuonForward3"/>
</volume>
<volume name="MuonForward_40x7ff5f9e80a80">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="MuonForward_40x7ff5f9e809a0"/>
<solidref ref="MuonForward_40x7ff5f9e809a0"/>
<auxiliary auxtype="FastSimModel" auxvalue="MuonForward4"/>
</volume>
<volume name="MuonForward_50x7ff5f9e80d50">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="MuonForward_50x7ff5f9e80c70"/>
<solidref ref="MuonForward_50x7ff5f9e80c70"/>
<auxiliary auxtype="FastSimModel" auxvalue="MuonForward5"/>
</volume>
<volume name="MuonForward_60x7ff5f9e81020">
<materialref ref="Aluminum0x7ff5f9e42670"/>
<solidref ref="MuonForward_60x7ff5f9e80f40"/>
<solidref ref="MuonForward_60x7ff5f9e80f40"/>
<auxiliary auxtype="FastSimModel" auxvalue="MuonForward6"/>
</volume>
<!-- World and Physical Volumes -->
</volume>
<!-- World and Physical Volumes -->
<volume name="world_volume0x7ff5f9e77ca0">
<materialref ref="Air0x7ff5f9e72ea0"/>
<solidref ref="world_volume0x7ff5f9e788a0"/>
<!-- Tracker -->
<solidref ref="world_volume0x7ff5f9e788a0"/>
<!-- Tracker -->
<physvol name="TrackerBarrelVol">
<volumeref ref="TrackerBarrelLog"/>
</physvol>
<!-- EM Calorimeters -->
<!-- EM Calorimeters -->
<physvol name="ECalBarrel0x7ff5f9e7b560">
<volumeref ref="ECalBarrel0x7ff5f9e7b420"/>
@@ -265,9 +265,9 @@
<physvol name="ECalForward_20x7ff5f9e7c2e0">
<volumeref ref="ECalForward_20x7ff5f9e7c490"/>
<position name="ECalForward_20x7ff5f9e7c2e0_pos" unit="mm" x="0" y="0" z="-23700"/>
</physvol>
<!-- Hadron Calorimeters -->
</physvol>
<!-- Hadron Calorimeters -->
<physvol name="HCalBarrel0x7ff5f9e7d190">
<volumeref ref="HCalBarrel0x7ff5f9e7d060"/>
@@ -287,9 +287,9 @@
<physvol name="HCalForward_20x7ff5f9e7ba60">
<volumeref ref="HCalForward_20x7ff5f9e7b9d0"/>
<position name="HCalForward_20x7ff5f9e7ba60_pos" unit="mm" x="0" y="0" z="-27000"/>
</physvol>
<!-- Muon Detectors -->
</physvol>
<!-- Muon Detectors -->
<physvol name="MuonEndCap_10x7ff5f9e7f0d0">
<volumeref ref="MuonEndCap_10x7ff5f9e7efa0"/>
@@ -338,13 +338,13 @@
<physvol name="MuonForward_60x7ff5f9e81140">
<volumeref ref="MuonForward_60x7ff5f9e81020"/>
<position name="MuonForward_60x7ff5f9e81140_pos" unit="mm" x="0" y="0" z="-31500"/>
</physvol>
</physvol>
</volume>
</volume>
</structure>
<setup name="Default" version="1.0">
<world ref="world_volume0x7ff5f9e77ca0"/>
@@ -39,23 +39,21 @@
//
//-------------------------------------------------------------------
#include "G4Types.hh"
#include "G4UImanager.hh"
#include "G4RunManagerFactory.hh"
#include "Par02ActionInitialization.hh"
#include "Par02DetectorConstruction.hh"
#include "Par02PhysicsList.hh"
#include "Par02ActionInitialization.hh"
#include "G4VisExecutive.hh"
#include "G4RunManagerFactory.hh"
#include "G4Types.hh"
#include "G4UIExecutive.hh"
#include "G4UImanager.hh"
#include "G4VisExecutive.hh"
int main( int argc, char** argv ) {
int main(int argc, char** argv)
{
// Instantiate G4UIExecutive if interactive mode
G4UIExecutive* ui = nullptr;
if ( argc == 1 ) {
if (argc == 1) {
ui = new G4UIExecutive(argc, argv);
}
@@ -67,16 +65,16 @@ int main( int argc, char** argv ) {
// Detector/mass geometry:
auto detector = new Par02DetectorConstruction();
runManager->SetUserInitialization( detector );
runManager->SetUserInitialization(detector);
// PhysicsList (including G4FastSimulationManagerProcess)
auto physicsList = new Par02PhysicsList;
runManager->SetUserInitialization( physicsList );
runManager->SetUserInitialization(physicsList);
//-------------------------------
// UserAction classes
//-------------------------------
runManager->SetUserInitialization( new Par02ActionInitialization );
runManager->SetUserInitialization(new Par02ActionInitialization);
// Initialize Run manager
runManager->Initialize();
@@ -88,17 +86,18 @@ int main( int argc, char** argv ) {
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();
if ( ui ) {
if (ui) {
//--------------------------
// Define (G)UI
//--------------------------
ui->SessionStart();
delete ui;
} else {
}
else {
G4String command = "/control/execute ";
G4String fileName = argv[1];
G4UImanager * UImanager = G4UImanager::GetUIpointer();
UImanager->ApplyCommand( command+fileName );
G4UImanager* UImanager = G4UImanager::GetUIpointer();
UImanager->ApplyCommand(command + fileName);
}
// Free the store: user actions, physics_list and detector_description are
@@ -11,7 +11,7 @@ Environment variable "G4FORCE_RUN_MANAGER_TYPE" enabled with value == Serial. Fo
**************************************************************
Geant4 version Name: geant4-11-02-patch-02 (21-June-2024)
Geant4 version Name: geant4-11-02-ref-06 (28-June-2024)
Copyright : Geant4 Collaboration
References : NIM A 506 (2003), 250-303
: IEEE-TNS 53 (2006), 270-278
@@ -74,14 +74,21 @@ Registered graphics systems are:
RayTracerX (RayTracerX)
Qt3D (Qt3D)
TOOLSSG_X11_GLES (TSG_X11_GLES, TSGX11, TSG_XT_GLES_FALLBACK)
TOOLSSG_X11_ZB (TSG_X11_ZB, TSGX11ZB)
TOOLSSG_XT_GLES (TSG_XT_GLES, TSGXt, TSG_QT_GLES_FALLBACK)
TOOLSSG_XT_ZB (TSG_XT_ZB, TSGXtZB)
TOOLSSG_QT_GLES (TSG_QT_GLES, TSGQt, TSG)
TOOLSSG_QT_ZB (TSG_QT_ZB, TSGQtZB)
Default graphics system is: TSG_OFFSCREEN (based on batch session).
Default window size hint is: 600x600-0+0 (based on G4VisManager initialisation).
Note: Parameters specified on the command line will override these defaults.
Use "vis/open" without parameters to get these defaults.
You may choose a graphics system (driver) with a parameter of
the command "/vis/open" or "/vis/sceneHandler/create",
or you may omit the driver parameter and choose at run time:
- by argument in the construction of G4VisExecutive
- by environment variable "G4VIS_DEFAULT_DRIVER"
- by entry in "~/.g4session"
- by build flags.
- Note: This feature is not allowed in batch mode.
For further information see "examples/basic/B1/exampleB1.cc"
and "vis.mac".
Registering model factories...
@@ -36,36 +36,36 @@
/// Actions initialization.
///
/// Initialization of all user defined actions as well as mandatory
/// particle generator.
/// particle generator.
/// Based on G4 examples/extended/parametrisations/Par01/include/
/// Par01ActionInitialization.hh .
/// @author Anna Zaborowska
class Par02ActionInitialization : public G4VUserActionInitialization {
class Par02ActionInitialization : public G4VUserActionInitialization
{
public:
/// A default constructor: sets the output file name fFileName
/// A default constructor: sets the output file name fFileName
/// (passed to Par02RunAction) to DefaultOutput.root as well as
/// flag fSmear (passed to Par02EventAction) to true indicating
/// that smearing will be performed.
Par02ActionInitialization();
/// A constructor: sets the flag fSmear (passed to Par02EventAction)
/// to true indicating that smearing will be performed.
/// @param aOutName The output file name passed to Par02RunAction.
Par02ActionInitialization( const G4String aOutName );
Par02ActionInitialization(const G4String aOutName);
/// A constructor.
/// @param aOutName The output file name passed to Par02RunAction.
/// @param aSmear The flag indicating if smearing should be done,
/// passed to Par02EventAction.
Par02ActionInitialization( const G4String aOutName, const G4String aSmear );
Par02ActionInitialization(const G4String aOutName, const G4String aSmear);
virtual ~Par02ActionInitialization();
virtual void BuildForMaster() const;
/// A method where all the user actions are created.
/// A method where all the user actions are created.
/// One of them, Par02PrimaryGeneratorAction is a mandatory class.
virtual void Build() const;
@@ -73,10 +73,9 @@ class Par02ActionInitialization : public G4VUserActionInitialization {
/// An output file name. Passed in Build() to the Par02RunAction.
G4String fFileName;
/// A flag indicating if smearing should be performed.
/// Passed in Build() to the Par02EventAction.
/// A flag indicating if smearing should be performed.
/// Passed in Build() to the Par02EventAction.
G4bool fSmear;
};
#endif
@@ -30,31 +30,31 @@
#ifndef PAR02_DETECTOR_CONSTRUCTION_H
#define PAR02_DETECTOR_CONSTRUCTION_H
#include "Par02FastSimModelTracker.hh"
#include "Par02FastSimModelEMCal.hh"
#include "Par02FastSimModelHCal.hh"
#include "Par02FastSimModelTracker.hh"
#include "tls.hh"
#include "G4GlobalMagFieldMessenger.hh"
#include "G4LogicalVolume.hh"
#include "G4VUserDetectorConstruction.hh"
#include "globals.hh"
#include "tls.hh"
#include "G4GlobalMagFieldMessenger.hh"
/// Construction of detector geometry.
///
/// A mandatory initialization class of the detector setup.
/// Detector construction allows to use the geometry read from a GDML file.
/// A mandatory initialization class of the detector setup.
/// Detector construction allows to use the geometry read from a GDML file.
/// Based on G4 examples/persistency/gdml/G01/include/G01DetectorConstruction.hh .
/// @author Anna Zaborowska
class Par02DetectorConstruction : public G4VUserDetectorConstruction {
class Par02DetectorConstruction : public G4VUserDetectorConstruction
{
public:
/// A default constructor.
Par02DetectorConstruction();
virtual ~Par02DetectorConstruction();
/// A method invoked by G4RunManager::Initialize()
/// @return A pointer to the world volume.
virtual G4VPhysicalVolume* Construct();
@@ -63,20 +63,19 @@ class Par02DetectorConstruction : public G4VUserDetectorConstruction {
virtual void ConstructSDandField();
/// A vector of the tracking detector regions
std::vector< G4Region* > fTrackerList;
std::vector<G4Region*> fTrackerList;
/// A vector of the the electromagnetic calorimeter regions
std::vector< G4Region* > fECalList;
std::vector<G4Region*> fECalList;
/// A vector of the the hadronic calorimeter regions
std::vector< G4Region* > fHCalList;
std::vector<G4Region*> fHCalList;
/// A vector of the muon detector regions
std::vector< G4Region* > fMuonList;
std::vector<G4Region*> fMuonList;
/// Messenger of the magnetic field
G4GlobalMagFieldMessenger* fMagFieldMessenger;
};
#endif
@@ -38,35 +38,44 @@
/// (dependent on the detector, parametrisation type and particle momentum).
/// @author Anna Zaborowska
class Par02DetectorParametrisation {
class Par02DetectorParametrisation
{
public:
/// A default constructor.
Par02DetectorParametrisation();
~Par02DetectorParametrisation();
/// A parametrisation type (CMS, ATLAS, ALEPH).
enum Parametrisation { eCMS, eATLAS, eALEPH };
enum Parametrisation
{
eCMS,
eATLAS,
eALEPH
};
/// A detector type (tracking detector, electromagnetic calorimeter,
/// hadronic calorimeter).
enum Detector { eTRACKER, eEMCAL, eHCAL };
enum Detector
{
eTRACKER,
eEMCAL,
eHCAL
};
/// Gets the resolution of a detector for a given particle.
/// @param aDetector A detector type.
/// @param aParametrisation A parametrisation type.
/// @param aMomentum A particle momentum.
G4double GetResolution( Detector aDetector, Parametrisation aParametrisation,
G4double aMomentum );
G4double GetResolution(Detector aDetector, Parametrisation aParametrisation,
G4double aMomentum);
/// Gets the efficiency of a detector for a given particle.
/// @param aDetector A detector type.
/// @param aParametrisation A parametrisation type.
/// @param aMomentum A particle momentum.
G4double GetEfficiency( Detector aDetector, Parametrisation aParametrisation,
G4double aMomentum );
G4double GetEfficiency(Detector aDetector, Parametrisation aParametrisation,
G4double aMomentum);
};
#endif
@@ -37,37 +37,35 @@
///
/// Defines the action at the beginning and at the end of each event.
/// It is invoked by a G4EventManager when a G4Event object is sent
/// (which contains primary vertices and particles created by the
/// (which contains primary vertices and particles created by the
/// Par02PrimaryGeneratorAction).
/// @author Anna Zaborowska
class Par02EventAction : public G4UserEventAction {
class Par02EventAction : public G4UserEventAction
{
public:
/// A default constructor.
/// A default constructor.
/// Sets the flag fSmear to true indicating that smearing will be performed.
Par02EventAction();
/// A constructor.
/// @param aSmear The flag indicating if smearing has to be done.
Par02EventAction( G4bool aSmear );
Par02EventAction(G4bool aSmear);
virtual ~Par02EventAction();
/// Defines the actions at the beginning of the event.
/// It sets the Par02EventInformation with fSmear flag.
/// Defines the actions at the beginning of the event.
/// It sets the Par02EventInformation with fSmear flag.
/// It creates all the ntuples defined in Par02Output singleton class.
virtual void BeginOfEventAction( const G4Event* );
virtual void BeginOfEventAction(const G4Event*);
/// Defines the actions at the end of the event.
virtual void EndOfEventAction( const G4Event* );
virtual void EndOfEventAction(const G4Event*);
private:
/// A flag indicating if smearing should be performed.
/// A flag indicating if smearing should be performed.
/// Passed to Par02EventInformation in BeginOfEventAction(const G4Event*).
G4bool fSmear;
};
#endif
@@ -38,34 +38,32 @@
/// Describes the information that can be associated with a G4Event class object.
/// @author Anna Zaborowska
class Par02EventInformation : public G4VUserEventInformation {
class Par02EventInformation : public G4VUserEventInformation
{
public:
/// A default constructor. Sets flag fDoSmearing to true.
Par02EventInformation();
/// A constructor.
/// @param aSmear The flag indicating if smearing should be done.
Par02EventInformation( G4bool aSmear );
Par02EventInformation(G4bool aSmear);
virtual ~Par02EventInformation();
/// Prints event information.
virtual void Print() const;
/// Sets the flag indicating if smearing should be done.
/// @param aSmear A boolean flag.
void SetDoSmearing( G4bool aSmear );
void SetDoSmearing(G4bool aSmear);
/// Gets the flag indicating if smearing should be done.
G4bool GetDoSmearing();
private:
/// A flag indicating if smearing should be performed.
/// A flag indicating if smearing should be performed.
/// It is read by implementations of G4VFastSimulationModel.
G4bool fDoSmearing;
};
#endif
@@ -30,65 +30,64 @@
#ifndef PAR02_EMCAL_FAST_SIM_MODEL_H
#define PAR02_EMCAL_FAST_SIM_MODEL_H
#include "G4VFastSimulationModel.hh"
#include "Par02DetectorParametrisation.hh"
#include "G4Step.hh"
#include "G4VFastSimulationModel.hh"
/// Shortcut to the ordinary tracking for electromagnetic calorimeters.
///
/// The fast simulation model describes what should be done instead of a
/// normal tracking. Instead of the ordinary tracking, a particle deposits
/// its energy at the entrance to the electromagnetic calorimeter and its value
/// is smeared (by Par02Smearer::SmearMomentum()). Based on G4
/// is smeared (by Par02Smearer::SmearMomentum()). Based on G4
/// examples/extended/parametrisations/Par01/include/Par01EMShowerModel.hh .
/// @author Anna Zaborowska
class Par02FastSimModelEMCal : public G4VFastSimulationModel {
class Par02FastSimModelEMCal : public G4VFastSimulationModel
{
public:
/// A constructor.
/// @param aModelName A name of the fast simulation model.
/// @param aEnvelope A region where the model can take over the ordinary tracking.
/// @param aParamType A parametrisation type.
Par02FastSimModelEMCal( G4String aModelName, G4Region* aEnvelope,
Par02DetectorParametrisation::Parametrisation aParamType );
Par02FastSimModelEMCal(G4String aModelName, G4Region* aEnvelope,
Par02DetectorParametrisation::Parametrisation aParamType);
/// A constructor.
/// @param aModelName A name of the fast simulation model.
/// @param aEnvelope A region where the model can take over the ordinary tracking.
Par02FastSimModelEMCal( G4String aModelName, G4Region* aEnvelope );
Par02FastSimModelEMCal(G4String aModelName, G4Region* aEnvelope);
/// A constructor.
/// @param aModelName A name of the fast simulation model.
Par02FastSimModelEMCal( G4String aModelName );
Par02FastSimModelEMCal(G4String aModelName);
~Par02FastSimModelEMCal();
/// Checks if this model should be applied to this particle type.
/// @param aParticle A particle definition (type).
virtual G4bool IsApplicable( const G4ParticleDefinition& aParticle );
virtual G4bool IsApplicable(const G4ParticleDefinition& aParticle);
/// Checks if the model should be applied, taking into account the
/// kinematics of a track.
/// @param aFastTrack A track.
virtual G4bool ModelTrigger( const G4FastTrack & aFastTrack );
/// Smears the energy deposit and saves it, together with the
virtual G4bool ModelTrigger(const G4FastTrack& aFastTrack);
/// Smears the energy deposit and saves it, together with the
/// position of the deposit, the electromagnetic calorimeter resolution
/// and efficiency to the Par02PrimaryParticleInformation.
/// @param aFastTrack A track.
/// @param aFastStep A step.
virtual void DoIt( const G4FastTrack& aFastTrack, G4FastStep& aFastStep );
virtual void DoIt(const G4FastTrack& aFastTrack, G4FastStep& aFastStep);
private:
/// A pointer to Par02DetectorParametrisation used to get the efficiency and
/// resolution of the detector for a given particle and parametrisation type.
Par02DetectorParametrisation* fCalculateParametrisation;
/// A parametrisation type.
Par02DetectorParametrisation::Parametrisation fParametrisation;
};
#endif
@@ -30,58 +30,58 @@
#ifndef PAR02_HCAL_FAST_SIM_MODEL_H
#define PAR02_HCAL_FAST_SIM_MODEL_H
#include "G4VFastSimulationModel.hh"
#include "Par02DetectorParametrisation.hh"
#include "G4Step.hh"
#include "G4VFastSimulationModel.hh"
/// Shortcut to the ordinary tracking for hadronic calorimeters.
///
/// Fast simulation model describes what should be done instead of a
/// normal tracking. Instead of the ordinary tracking, a particle deposits
/// its energy at the entrance to the hadronic calorimeter and its value
/// is smeared (by Par02Smearer::SmearMomentum()). Based on G4
/// is smeared (by Par02Smearer::SmearMomentum()). Based on G4
/// examples/extended/parametrisations/Par01/include/Par01EMShowerModel.hh .
/// @author Anna Zaborowska
class Par02FastSimModelHCal : public G4VFastSimulationModel {
class Par02FastSimModelHCal : public G4VFastSimulationModel
{
public:
/// A constructor.
/// @param aModelName A name of the fast simulation model.
/// @param aEnvelope A region where the model can take over the ordinary tracking.
/// @param aParamType A parametrisation type.
Par02FastSimModelHCal( G4String aModelName, G4Region* aEnvelope,
Par02DetectorParametrisation::Parametrisation aParamType );
Par02FastSimModelHCal(G4String aModelName, G4Region* aEnvelope,
Par02DetectorParametrisation::Parametrisation aParamType);
/// A constructor.
/// @param aModelName A name of the fast simulation model.
/// @param aEnvelope A region where the model can take over the ordinary tracking.
Par02FastSimModelHCal( G4String aModelName, G4Region* aEnvelope );
Par02FastSimModelHCal(G4String aModelName, G4Region* aEnvelope);
/// A constructor.
/// @param aModelName A name of the fast simulation model.
Par02FastSimModelHCal( G4String aModelName );
Par02FastSimModelHCal(G4String aModelName);
~Par02FastSimModelHCal();
/// Checks if this model should be applied to this particle type.
/// @param aParticle A particle definition (type).
virtual G4bool IsApplicable( const G4ParticleDefinition& aParticle );
virtual G4bool IsApplicable(const G4ParticleDefinition& aParticle);
/// Checks if the model should be applied, taking into account the
/// kinematics of a track.
/// @param aFastTrack A track.
virtual G4bool ModelTrigger( const G4FastTrack& aFastTrack );
virtual G4bool ModelTrigger(const G4FastTrack& aFastTrack);
/// Smears the energy deposit and saves it, together with the
/// position of the deposit, the hadronic calorimeter resolution and
/// efficiency to the Par02PrimaryParticleInformation.
/// @param aFastTrack A track.
/// @param aFastStep A step.
virtual void DoIt( const G4FastTrack& aFastTrack, G4FastStep& aFastStep );
virtual void DoIt(const G4FastTrack& aFastTrack, G4FastStep& aFastStep);
private:
/// A pointer to Par02DetectorParametrisation used to get the efficiency and
/// resolution of the detector for a given particle and parametrisation type.
Par02DetectorParametrisation* fCalculateParametrisation;
@@ -91,4 +91,3 @@ class Par02FastSimModelHCal : public G4VFastSimulationModel {
};
#endif
@@ -30,70 +30,69 @@
#ifndef PAR02_TRACKER_FAST_SIM_MODEL_H
#define PAR02_TRACKER_FAST_SIM_MODEL_H
#include "G4VFastSimulationModel.hh"
#include "Par02DetectorParametrisation.hh"
#include "G4Step.hh"
#include "G4Navigator.hh"
#include "G4Step.hh"
#include "G4VFastSimulationModel.hh"
/// Shortcut to the ordinary tracking for tracking detectors.
///
/// The fast simulation model describes what should be done instead of a
/// normal tracking. Instead of the ordinary tracking, a particle momentum
/// at the entrance of the tracking detector is smeared
/// at the entrance of the tracking detector is smeared
/// (by Par02Smearer::SmearMomentum()) and the particle is placed at the
/// tracking detector exit, at the place it would reach without the change
/// of its momentum. Based on G4
/// of its momentum. Based on G4
/// examples/extended/parametrisations/Par01/include/Par01EMShowerModel.hh .
/// @author Anna Zaborowska
class Par02FastSimModelTracker : public G4VFastSimulationModel {
class Par02FastSimModelTracker : public G4VFastSimulationModel
{
public:
/// A constructor.
/// @param aModelName A name of the fast simulation model.
/// @param aEnvelope A region where the model can take over the ordinary tracking.
/// @param aParamType A parametrisation type.
Par02FastSimModelTracker( G4String aModelName, G4Region* aEnvelope,
Par02DetectorParametrisation::Parametrisation aParamType );
Par02FastSimModelTracker(G4String aModelName, G4Region* aEnvelope,
Par02DetectorParametrisation::Parametrisation aParamType);
/// A constructor.
/// @param aModelName A name of the fast simulation model.
/// @param aEnvelope A region where the model can take over the ordinary tracking.
Par02FastSimModelTracker( G4String aModelName, G4Region* aEnvelope );
Par02FastSimModelTracker(G4String aModelName, G4Region* aEnvelope);
/// A constructor.
/// @param aModelName A name of the fast simulation model.
Par02FastSimModelTracker( G4String aModelName );
Par02FastSimModelTracker(G4String aModelName);
~Par02FastSimModelTracker();
/// Checks if this model should be applied to this particle type.
/// @param aParticle A particle definition (type).
virtual G4bool IsApplicable( const G4ParticleDefinition& aParticle );
virtual G4bool IsApplicable(const G4ParticleDefinition& aParticle);
/// Checks if the model should be applied taking into account the kinematics
/// of a track.
/// @param aFastTrack A track.
virtual G4bool ModelTrigger( const G4FastTrack& aFastTrack );
virtual G4bool ModelTrigger(const G4FastTrack& aFastTrack);
/// Calculates the final position (at the outer boundary of the tracking detector)
/// of a particle with the momentum at the entrance of the tracking detector.
/// Smears the particle momentum and saves it, together with the tracking detector
/// resolution and efficiency to the Par02PrimaryParticleInformation.
/// @param aFastTrack A track.
/// @param aFastStep A step.
virtual void DoIt( const G4FastTrack& aFastTrack, G4FastStep& aFastStep );
virtual void DoIt(const G4FastTrack& aFastTrack, G4FastStep& aFastStep);
private:
/// A pointer to Par02DetectorParametrisation used to get the efficiency and
/// resolution of the tracking detector for a given particle and
/// parametrisation type.
Par02DetectorParametrisation* fCalculateParametrisation;
/// A parametrisation type.
Par02DetectorParametrisation::Parametrisation fParametrisation;
};
#endif
@@ -39,49 +39,56 @@
/// Root output file.
/// @author Anna Zaborowska
class Par02Output {
class Par02Output
{
public:
/// Indicates to which ntuple to save the information.
enum SaveType { eNoSave, eSaveMC, eSaveTracker, eSaveEMCal, eSaveHCal };
enum SaveType
{
eNoSave,
eSaveMC,
eSaveTracker,
eSaveEMCal,
eSaveHCal
};
/// Allows the access to the unique Par02Output object.
/// @return A pointer to the Par02Output class.
static Par02Output* Instance();
/// Sets the file name of the output root file.
/// @param name The name of the file.
void SetFileName( G4String name );
void SetFileName(G4String name);
/// Gets the file name of the output root file.
/// @return The name of the file.
G4String GetFileName();
/// Sets fFileNameWithRunNo that indicates whether to add the run number
/// to the file name.
/// @param app If add the run number.
void AppendName( G4bool app );
void AppendName(G4bool app);
/// Calls the G4AnalysisManager::Instance(). It sets the file name of the
/// output file based on fFileName and fFileNameWithRunNo and opens the file.
/// @param runID A run number (to be added to file name if fFileNameWithRunNo
/// is true).
void StartAnalysis( G4int runID );
/// Calls the G4AnalysisManager::Instance().
void StartAnalysis(G4int runID);
/// Calls the G4AnalysisManager::Instance().
/// It writes to the output file and close it.
void EndAnalysis();
/// Creates Ntuples used to store information about particle (its ID, PDG code,
/// energy deposits, etc.). To be called for each event in Par02EventAction.
void CreateNtuples();
/// Creates histograms to combine information from all the events in the run.
/// To be called for each run in Par02RunAction.
void CreateHistograms();
/// Saves the information about the particle (track).
/// @param aWhatToSave enum indicating what kind of information to store
/// @param aWhatToSave enum indicating what kind of information to store
/// (in which ntuple).
/// @param aPartID A unique ID within event (taken Geant TrackID).
/// @param aPDG A PDG code of a particle.
@@ -89,39 +96,36 @@ class Par02Output {
/// position of energy deposit in calorimeter).
/// @param aResolution A resolution of the detector that was used.
/// @param aEfficiency An efficiency of the detector that was used.
/// @param aEnergy An energy deposit (for calorimeters only:
/// @param aEnergy An energy deposit (for calorimeters only:
/// Par02Output::SaveType::eEMCal or Par02Output::SaveType::eHCal).
void SaveTrack( SaveType aWhatToSave, G4int aPartID, G4int aPDG,
G4ThreeVector aVector, G4double aResolution = 0,
G4double aEfficiency = 1, G4double aEnergy = 0 ) ;
void SaveTrack(SaveType aWhatToSave, G4int aPartID, G4int aPDG, G4ThreeVector aVector,
G4double aResolution = 0, G4double aEfficiency = 1, G4double aEnergy = 0);
/// Fills the histogram.
/// @param HNo Number of a histogram (decided by the order of creation
/// in CreateHistograms(), the first one is 0).
/// @param value A value to be filled into the histogram.
void FillHistogram( G4int HNo, G4double value ) const;
void FillHistogram(G4int HNo, G4double value) const;
~Par02Output();
protected:
/// A default, protected constructor (due to singleton pattern).
Par02Output();
private:
/// The pointer to the only Par02Output class object.
static Par02Output* fPar02Output;
/// Current ntuple Id
/// Current ntuple Id
static G4ThreadLocal G4int fCurrentNtupleId;
/// A name of the output root file.
G4String fFileName;
/// If true, a run number should be added to the file. Default: false.
G4bool fFileNameWithRunNo;
/// A control value of particle ID to ensure that data saved to various ntuples
/// match the same particle. It is set when Monte Carlo information is saved
/// and checked for all the detectors.
@@ -129,4 +133,3 @@ class Par02Output {
};
#endif
@@ -35,25 +35,24 @@
/// Construction of a physics list.
///
/// A mandatory initialization class of the physics list.
/// A mandatory initialization class of the physics list.
/// For the purposes of fast simulation, only transportation, decays and
/// parametrisation is used. Based on G4
/// parametrisation is used. Based on G4
/// examples/extended/parametrisations/Par01/include/Par01PhysicsList.hh .
/// @author Anna Zaborowska
class Par02PhysicsList : public G4VUserPhysicsList {
class Par02PhysicsList : public G4VUserPhysicsList
{
public:
/// A default constructor. Sets the default cut value.
Par02PhysicsList();
virtual ~Par02PhysicsList();
protected:
/// Constructs particles: bosons, leptons, mesons, baryons and ions.
virtual void ConstructParticle();
/// Constructs physics processes: particle transportation, decays,
/// parametrisation (for the purpose of fast parametric simulation).
virtual void ConstructProcess();
@@ -66,13 +65,13 @@ class Par02PhysicsList : public G4VUserPhysicsList {
/// Constructs all leptons.
virtual void ConstructLeptons();
/// Constructs all mesons.
virtual void ConstructMesons();
/// Constructs all barions.
virtual void ConstructBaryons();
/// Constructs light ions.
virtual void ConstructIons();
@@ -81,12 +80,11 @@ class Par02PhysicsList : public G4VUserPhysicsList {
/// Adds decay process.
virtual void ConstructGeneral();
/// Adds the particle transport.
/// Adds the particle transport.
/// G4CoupledTransportation is used to allow the calculation of the expected
/// position of the particle within a G4VFastSimulationModel.
virtual void AddTransportation();
};
#endif
@@ -42,12 +42,13 @@ class G4Event;
/// event generator Pythia8 is used as generator and it is interfaced
/// to Geant4 via HepMC.
class Par02PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction {
class Par02PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
Par02PrimaryGeneratorAction();
~Par02PrimaryGeneratorAction();
virtual void GeneratePrimaries( G4Event* anEvent );
virtual void GeneratePrimaries(G4Event* anEvent);
G4ParticleGun* GetParticleGun();
private:
@@ -55,4 +56,3 @@ class Par02PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction {
};
#endif
@@ -30,8 +30,8 @@
#ifndef PAR02_PRIMARY_PARTICLE_INFORMATION_H
#define PAR02_PRIMARY_PARTICLE_INFORMATION_H
#include "G4VUserPrimaryParticleInformation.hh"
#include "G4ThreeVector.hh"
#include "G4VUserPrimaryParticleInformation.hh"
#include "globals.hh"
/// Primary particle information
@@ -40,181 +40,170 @@
/// class object.
/// @author Anna Zaborowska
class Par02PrimaryParticleInformation : public G4VUserPrimaryParticleInformation {
class Par02PrimaryParticleInformation : public G4VUserPrimaryParticleInformation
{
public:
/// A constructor.
/// @param aID A unique particle ID within event.
/// @param aPDG A PDG code of the particle.
/// @param aMomentum An initial particle momentum (at the primary vertex).
Par02PrimaryParticleInformation( G4int aID, G4int aPDG, G4ThreeVector aMomentum );
Par02PrimaryParticleInformation(G4int aID, G4int aPDG, G4ThreeVector aMomentum);
virtual ~Par02PrimaryParticleInformation();
/// Prints the information about the particle.
virtual void Print() const;
/// Sets the initial particle momentum (from particle generator).
/// @param aMomentum The particle momentum.
inline void SetMCMomentum( G4ThreeVector aMomentum ) { fMomentumMC = aMomentum; };
inline void SetMCMomentum(G4ThreeVector aMomentum) { fMomentumMC = aMomentum; };
/// Gets the initial particle momentum (from particle generator).
inline G4ThreeVector GetMCMomentum() { return fMomentumMC; };
/// Sets the particle momentum at the entrance to the tracker detector.
/// @param aMomentum The particle momentum.
inline void SetTrackerMomentum( G4ThreeVector aMomentum )
{ fMomentumTracker = aMomentum; };
inline void SetTrackerMomentum(G4ThreeVector aMomentum) { fMomentumTracker = aMomentum; };
/// Gets the particle momentum at the entrance to the tracker detector.
inline G4ThreeVector GetTrackerMomentum() { return fMomentumTracker; }
/// Sets the tracker detector resolution.
/// Sets the tracker detector resolution.
/// Currently equal to -1 if AtlFast type of smearing is used.
/// @param aResolution The detector resolution
/// @param aResolution The detector resolution
/// (particle type and momentum dependent).
inline void SetTrackerResolution( G4double aResolution )
{ fResolutionTracker = aResolution; };
/// Gets the tracking detector resolution.
inline void SetTrackerResolution(G4double aResolution) { fResolutionTracker = aResolution; };
/// Gets the tracking detector resolution.
/// Currently equal to -1 if AtlFast type of smearing is used.
inline G4double GetTrackerResolution() { return fResolutionTracker; };
/// Sets the tracking detector efficiency.
/// Sets the tracking detector efficiency.
/// Currently not used (efficiency is 1).
/// @param aEfficiency The detector efficiency.
inline void SetTrackerEfficiency( G4double aEfficiency )
{ fEfficiencyTracker = aEfficiency; };
/// Gets the tracker detector efficiency.
inline void SetTrackerEfficiency(G4double aEfficiency) { fEfficiencyTracker = aEfficiency; };
/// Gets the tracker detector efficiency.
/// Currently not used (efficiency is 1).
inline G4double GetTrackerEfficiency() { return fEfficiencyTracker; };
/// Sets the position of the energy deposit in the electromagnetic calorimeter.
/// @param aPosition The position of the energy deposit.
inline void SetEMCalPosition( G4ThreeVector aPosition )
{ fPositionEMCal = aPosition; };
inline void SetEMCalPosition(G4ThreeVector aPosition) { fPositionEMCal = aPosition; };
/// Gets the position of the energy deposit in the electromagnetic calorimeter.
inline G4ThreeVector GetEMCalPosition() { return fPositionEMCal; };
/// Sets the energy deposit in the electromagnetic calorimeter.
/// @param aEnergy The energy deposited in the detector.
inline void SetEMCalEnergy( G4double aEnergy ) { fEnergyEMCal = aEnergy; };
inline void SetEMCalEnergy(G4double aEnergy) { fEnergyEMCal = aEnergy; };
/// Sets the energy deposit in the electromagnetic calorimeter.
inline G4double GetEMCalEnergy() { return fEnergyEMCal; };
/// Sets the electromagnetic calorimeter resolution.
/// Sets the electromagnetic calorimeter resolution.
/// Currently equal to -1 if AtlFast type of smearing is used.
/// @param aResolution The calorimeter resolution
/// @param aResolution The calorimeter resolution
/// (particle type and momentum dependent).
inline void SetEMCalResolution( G4double aResolution )
{ fResolutionEMCal = aResolution; };
/// Gets the electromagnetic calorimeter resolution.
inline void SetEMCalResolution(G4double aResolution) { fResolutionEMCal = aResolution; };
/// Gets the electromagnetic calorimeter resolution.
/// Currently equal to -1 if AtlFast type of smearing is used.
inline G4double GetEMCalResolution() { return fResolutionEMCal; };
/// Sets the electromagnetic calorimeter efficiency.
/// Sets the electromagnetic calorimeter efficiency.
/// Currently not used (efficiency is 1).
/// @param aEfficiency The detector efficiency.
inline void SetEMCalEfficiency( G4double aEfficiency )
{ fEfficiencyEMCal = aEfficiency; };
/// Gets the electromagnetic calorimeter efficiency.
inline void SetEMCalEfficiency(G4double aEfficiency) { fEfficiencyEMCal = aEfficiency; };
/// Gets the electromagnetic calorimeter efficiency.
/// Currently not used (efficiency is 1).
inline G4double GetEMCalEfficiency() { return fEfficiencyEMCal; };
/// Sets the position of the energy deposit in the hadronic calorimeter.
/// @param aPosition The position of the energy deposit.
inline void SetHCalPosition( G4ThreeVector aPosition )
{ fPositionHCal = aPosition; };
inline void SetHCalPosition(G4ThreeVector aPosition) { fPositionHCal = aPosition; };
/// Gets the position of the energy deposit in the hadronic calorimeter.
inline G4ThreeVector GetHCalPosition() { return fPositionHCal; };
/// Sets the energy deposit in the hadronic calorimeter.
/// @param aEnergy The energy deposited in the detector.
inline void SetHCalEnergy( G4double aEnergy ) { fEnergyHCal = aEnergy; };
inline void SetHCalEnergy(G4double aEnergy) { fEnergyHCal = aEnergy; };
/// Sets the energy deposit in the hadronic calorimeter.
inline G4double GetHCalEnergy() { return fEnergyHCal; };
/// Sets the hadronic calorimeter resolution.
/// Sets the hadronic calorimeter resolution.
/// Currently equal to -1 if AtlFast type of smearing is used.
/// @param aResolution The calorimeter resolution
/// @param aResolution The calorimeter resolution
/// (particle type and momentum dependent).
inline void SetHCalResolution( G4double aResolution )
{ fResolutionHCal = aResolution; };
/// Gets the hadronic calorimeter resolution.
inline void SetHCalResolution(G4double aResolution) { fResolutionHCal = aResolution; };
/// Gets the hadronic calorimeter resolution.
/// Currently equal to -1 if AtlFast type of smearing is used.
inline G4double GetHCalResolution() { return fResolutionHCal; };
/// Sets the hadronic calorimeter efficiency.
/// Sets the hadronic calorimeter efficiency.
/// Currently not used (efficiency is 1).
/// @param aEfficiency The detector efficiency.
inline void SetHCalEfficiency( G4double aEfficiency )
{ fEfficiencyHCal = aEfficiency; };
/// Gets the hadronic calorimeter efficiency.
inline void SetHCalEfficiency(G4double aEfficiency) { fEfficiencyHCal = aEfficiency; };
/// Gets the hadronic calorimeter efficiency.
/// Currently not used (efficiency is 1).
inline G4double GetHCalEfficiency() { return fEfficiencyHCal; };
/// Gets the particle unique ID (within event). Can be set only in the constructor.
inline G4int GetPartID() const { return fPartID; };
/// Gets the standard PDG code. Can be set only in the constructor.
inline G4int GetPDG() const { return fPDG; };
private:
/// A particle unique ID.
G4int fPartID;
/// A particle type (PDG code).
G4int fPDG;
/// A particle initial momentum (from particle generator).
G4ThreeVector fMomentumMC;
/// A particle momentum at the entrance to the tracking detector.
G4ThreeVector fMomentumTracker;
/// A resolution of the tracking detector.
G4double fResolutionTracker;
/// An efficiency of the tracking detector.
/// Currently not used (equal to 1).
G4double fEfficiencyTracker;
/// A position of the energy deposited in the electromagnetic calorimeter.
G4ThreeVector fPositionEMCal;
/// An energy deposited in the electromagnetic calorimeter.
G4double fEnergyEMCal;
/// The resolution of the electromagnetic calorimeter.
G4double fResolutionEMCal;
/// The efficiency of the electromagnetic calorimeter.
/// The efficiency of the electromagnetic calorimeter.
/// Currently not used (equal to 1).
G4double fEfficiencyEMCal;
/// A position of the energy deposited in the hadronic calorimeter.
G4ThreeVector fPositionHCal;
/// An energy deposited in the hadronic calorimeter.
G4double fEnergyHCal;
/// The resolution of the hadronic calorimeter.
G4double fResolutionHCal;
/// The efficiency of the hadronic calorimeter.
/// The efficiency of the hadronic calorimeter.
/// Currently not used (equal to 1).
G4double fEfficiencyHCal;
};
#endif
@@ -38,30 +38,29 @@ class G4Run;
/// Run action (before/after run processing).
///
/// Defines the action at the beginning and at the end of each run.
/// Content of G4Run cannot be changed.
/// Content of G4Run cannot be changed.
/// The class needs to be set in G4RunManager::SetUserAction().
/// @author Anna Zaborowska
class Par02RunAction : public G4UserRunAction {
class Par02RunAction : public G4UserRunAction
{
public:
/// A default constructor.
/// @param OutName The output root file name
/// @param OutName The output root file name
/// (it will store all the events within one run).
Par02RunAction( const G4String OutName = "SimpleOutput" );
Par02RunAction(const G4String OutName = "SimpleOutput");
virtual ~Par02RunAction();
/// Defines the actions at the beginning of the run.
/// Defines the actions at the beginning of the run.
/// It starts the analysis (create output root file) and create all the
/// histograms defined in Par02Output singleton class.
virtual void BeginOfRunAction( const G4Run* );
/// Defines the actions at the end of the run.
virtual void BeginOfRunAction(const G4Run*);
/// Defines the actions at the end of the run.
/// It ends the analysis (write and close output root file) via Par02Output
/// singleton class.
virtual void EndOfRunAction( const G4Run* );
virtual void EndOfRunAction(const G4Run*);
};
#endif
@@ -30,11 +30,12 @@
#ifndef PAR02_SMEARER_H
#define PAR02_SMEARER_H
#include "Par02Output.hh"
#include "globals.hh"
#include "G4Track.hh"
#include "CLHEP/Random/JamesRandom.h"
#include "CLHEP/Random/RandGauss.h"
#include "Par02Output.hh"
#include "G4Track.hh"
#include "globals.hh"
/// Smearing of the particle momentum or energy.
///
@@ -43,54 +44,51 @@
/// the momentum (energy) is smeared with Gaussian distribution.
/// @author Anna Zaborowska
class Par02Smearer {
class Par02Smearer
{
public:
/// Allows the access to the unique Par02Smearer class object.
/// @return A pointer to the Par02Smearer class.
static Par02Smearer* Instance();
/// Smears the momentum with a given resolution.
/// @param aTrack A track to smear.
/// @param aResolution A resolution. Gaussian smearing is done with a
/// @param aResolution A resolution. Gaussian smearing is done with a
/// given resolution as a standard deviation.
G4ThreeVector SmearMomentum( const G4Track* aTrack, G4double aResolution = -1 );
G4ThreeVector SmearMomentum(const G4Track* aTrack, G4double aResolution = -1);
/// Smears the energy deposit with a given resolution.
/// @param aTrack A track to smear.
/// @param aResolution A resolution. Gaussian smearing is done with a
/// given resolution as a standard deviation.
G4double SmearEnergy( const G4Track* aTrack, G4double aResolution = -1 );
G4double SmearEnergy(const G4Track* aTrack, G4double aResolution = -1);
/// First possible type of smearing. Smears the momentum with a given resolution.
/// @param aTrackOriginal A track to smear.
/// @param aResolution A resolution taken as a standard deviation of a
/// Gaussian distribution.
G4ThreeVector SmearGaussian( const G4Track* aTrackOriginal, G4double aResolution );
G4ThreeVector SmearGaussian(const G4Track* aTrackOriginal, G4double aResolution);
/// Returns a random number from a Gaussian distribution.
/// @param aMean The mean of the Gaussian distribution.
/// @param aStandardDeviation The standard deviation of a Gaussian distribution.
G4double Gauss( G4double aMean, G4double aStandardDeviation );
G4double Gauss(G4double aMean, G4double aStandardDeviation);
protected:
/// A default constructor.
Par02Smearer();
~Par02Smearer();
private:
/// A pointer to Par02Smearer object.
static Par02Smearer* fPar02Smearer;
/// CLHEP random engine.
CLHEP::HepRandomEngine* fRandomEngine;
/// CLHEP random engine used in gaussian smearing.
CLHEP::RandGauss* fRandomGauss;
};
#endif
@@ -39,9 +39,9 @@
/// The class needs to be set in G4RunManager::SetUserAction().
/// @author Anna Zaborowska
class Par02TrackingAction : public G4UserTrackingAction {
class Par02TrackingAction : public G4UserTrackingAction
{
public:
/// A default constructor.
Par02TrackingAction();
@@ -49,14 +49,13 @@ class Par02TrackingAction : public G4UserTrackingAction {
/// Defines the actions at the start of processing the track.
/// It checks the pseudorapidity range and if the particle is a primary.
virtual void PreUserTrackingAction( const G4Track* track );
/// Defines the actions at the end of processing the track.
virtual void PreUserTrackingAction(const G4Track* track);
/// Defines the actions at the end of processing the track.
/// It saves the information of MC data (PDG code, initial momentum),
/// tracker (momentum), EMCal and HCal (energy deposit and its position)
/// as well as resolution and efficiency for all the detectors.
virtual void PostUserTrackingAction( const G4Track* track );
virtual void PostUserTrackingAction(const G4Track* track);
};
#endif
@@ -28,28 +28,31 @@
/// \brief Implementation of the Par02ActionInitialization class
#include "Par02ActionInitialization.hh"
#include "Par02EventAction.hh"
#include "Par02PrimaryGeneratorAction.hh"
#include "Par02RunAction.hh"
#include "Par02EventAction.hh"
#include "Par02TrackingAction.hh"
#include "G4UIcommand.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02ActionInitialization::Par02ActionInitialization() :
G4VUserActionInitialization(), fFileName( "DefaultOutput" ), fSmear( true ) {}
Par02ActionInitialization::Par02ActionInitialization()
: G4VUserActionInitialization(), fFileName("DefaultOutput"), fSmear(true)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02ActionInitialization::Par02ActionInitialization( const G4String aOutName,
const G4String aSmear ) :
G4VUserActionInitialization(), fFileName( aOutName ),
fSmear( G4UIcommand::ConvertToBool( aSmear ) ) {}
Par02ActionInitialization::Par02ActionInitialization(const G4String aOutName, const G4String aSmear)
: G4VUserActionInitialization(), fFileName(aOutName), fSmear(G4UIcommand::ConvertToBool(aSmear))
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02ActionInitialization::Par02ActionInitialization( const G4String aOutName ) :
G4VUserActionInitialization(), fFileName( aOutName ), fSmear( true ) {}
Par02ActionInitialization::Par02ActionInitialization(const G4String aOutName)
: G4VUserActionInitialization(), fFileName(aOutName), fSmear(true)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -57,18 +60,19 @@ Par02ActionInitialization::~Par02ActionInitialization() = default;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02ActionInitialization::BuildForMaster() const {
SetUserAction( new Par02RunAction( fFileName ) );
void Par02ActionInitialization::BuildForMaster() const
{
SetUserAction(new Par02RunAction(fFileName));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02ActionInitialization::Build() const {
SetUserAction( new Par02PrimaryGeneratorAction );
SetUserAction( new Par02RunAction( fFileName ) );
SetUserAction( new Par02EventAction( fSmear ) );
SetUserAction( new Par02TrackingAction );
void Par02ActionInitialization::Build() const
{
SetUserAction(new Par02PrimaryGeneratorAction);
SetUserAction(new Par02RunAction(fFileName));
SetUserAction(new Par02EventAction(fSmear));
SetUserAction(new Par02TrackingAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -28,13 +28,13 @@
/// \brief Implementation of the Par02DetectorConstruction class
#include "Par02DetectorConstruction.hh"
#include "G4ProductionCuts.hh"
#include "G4SystemOfUnits.hh"
#include "G4RegionStore.hh"
#include "G4AutoDelete.hh"
#include "G4GDMLParser.hh"
#include "G4AutoDelete.hh"
#include "G4GlobalMagFieldMessenger.hh"
#include "G4AutoDelete.hh"
#include "G4ProductionCuts.hh"
#include "G4RegionStore.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -46,66 +46,65 @@ Par02DetectorConstruction::~Par02DetectorConstruction() = default;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* Par02DetectorConstruction::Construct() {
G4VPhysicalVolume* Par02DetectorConstruction::Construct()
{
G4GDMLParser parser;
parser.Read( "Par02FullDetector.gdml" );
parser.Read("Par02FullDetector.gdml");
G4cout << "Geometry loaded from file .......Par02FullDetector.gdml " << G4endl;
// This GDML detector description uses the auxiliary information part to store
// information regarding which Geant4 volumes have a fast simulation model.
const G4GDMLAuxMapType* aAuxMap = parser.GetAuxMap();
for ( G4GDMLAuxMapType::const_iterator iter = aAuxMap->begin();
iter != aAuxMap->end(); ++iter ) {
for ( G4GDMLAuxListType::const_iterator vit = (*iter).second.begin();
vit != (*iter).second.end(); ++vit ) {
if ( (*vit).type == "FastSimModel" ) {
for (G4GDMLAuxMapType::const_iterator iter = aAuxMap->begin(); iter != aAuxMap->end(); ++iter) {
for (G4GDMLAuxListType::const_iterator vit = (*iter).second.begin();
vit != (*iter).second.end(); ++vit)
{
if ((*vit).type == "FastSimModel") {
G4LogicalVolume* myvol = (*iter).first;
if ( ( myvol->GetName() ).find( "Tracker" ) != std::string::npos ) {
fTrackerList.push_back( new G4Region( myvol->GetName() ) );
fTrackerList.back()->AddRootLogicalVolume( myvol );
if ((myvol->GetName()).find("Tracker") != std::string::npos) {
fTrackerList.push_back(new G4Region(myvol->GetName()));
fTrackerList.back()->AddRootLogicalVolume(myvol);
G4cout << G4endl << "tracker !!!" << G4endl;
} else if ( ( myvol->GetName() ).find( "HCal" ) != std::string::npos ) {
fHCalList.push_back( new G4Region( myvol->GetName() ) );
fHCalList.back()->AddRootLogicalVolume( myvol );
}
else if ((myvol->GetName()).find("HCal") != std::string::npos) {
fHCalList.push_back(new G4Region(myvol->GetName()));
fHCalList.back()->AddRootLogicalVolume(myvol);
G4cout << G4endl << "hcal !!!" << G4endl;
} else if ( ( myvol->GetName() ).find( "ECal" ) != std::string::npos ) {
fECalList.push_back( new G4Region( myvol->GetName() ) );
fECalList.back()->AddRootLogicalVolume( myvol );
}
else if ((myvol->GetName()).find("ECal") != std::string::npos) {
fECalList.push_back(new G4Region(myvol->GetName()));
fECalList.back()->AddRootLogicalVolume(myvol);
G4cout << G4endl << "ecal !!!" << G4endl;
} else if ( ( myvol->GetName() ).find( "Muon" ) != std::string::npos ) {
fMuonList.push_back( new G4Region( myvol->GetName() ) );
fMuonList.back()->AddRootLogicalVolume( myvol );
} else {
}
else if ((myvol->GetName()).find("Muon") != std::string::npos) {
fMuonList.push_back(new G4Region(myvol->GetName()));
fMuonList.back()->AddRootLogicalVolume(myvol);
}
else {
G4cout << G4endl << "NOT A KNOWN DETECTOR !!!" << G4endl;
}
}
}
}
for ( G4int iterTracker = 0; iterTracker < G4int( fTrackerList.size() );
iterTracker++ ) {
fTrackerList[ iterTracker ]->SetProductionCuts( new G4ProductionCuts() );
fTrackerList[ iterTracker ]->GetProductionCuts()->SetProductionCut
( 1.0* ( ( *fTrackerList[ iterTracker ]->GetRootLogicalVolumeIterator() )->
GetMaterial()->GetRadlen() ) );
fTrackerList[ iterTracker ]->GetProductionCuts()->
SetProductionCut( 1.0*m, idxG4GammaCut );
for (G4int iterTracker = 0; iterTracker < G4int(fTrackerList.size()); iterTracker++) {
fTrackerList[iterTracker]->SetProductionCuts(new G4ProductionCuts());
fTrackerList[iterTracker]->GetProductionCuts()->SetProductionCut(
1.0
* ((*fTrackerList[iterTracker]->GetRootLogicalVolumeIterator())->GetMaterial()->GetRadlen()));
fTrackerList[iterTracker]->GetProductionCuts()->SetProductionCut(1.0 * m, idxG4GammaCut);
}
for ( G4int iterECal = 0; iterECal < G4int( fECalList.size() ); iterECal++ ) {
fECalList[ iterECal ]->SetProductionCuts( new G4ProductionCuts() );
fECalList[ iterECal ]->GetProductionCuts()->SetProductionCut
( 0.5* ( ( *fECalList[ iterECal ]->GetRootLogicalVolumeIterator() )->
GetMaterial()->GetRadlen() ) );
fECalList[ iterECal ]->GetProductionCuts()->
SetProductionCut( 0.1*m, idxG4GammaCut );
for (G4int iterECal = 0; iterECal < G4int(fECalList.size()); iterECal++) {
fECalList[iterECal]->SetProductionCuts(new G4ProductionCuts());
fECalList[iterECal]->GetProductionCuts()->SetProductionCut(
0.5 * ((*fECalList[iterECal]->GetRootLogicalVolumeIterator())->GetMaterial()->GetRadlen()));
fECalList[iterECal]->GetProductionCuts()->SetProductionCut(0.1 * m, idxG4GammaCut);
}
for ( G4int iterHCal = 0; iterHCal < G4int( fHCalList.size() ); iterHCal++ ) {
fHCalList[ iterHCal ]->SetProductionCuts( new G4ProductionCuts() );
fHCalList[ iterHCal ]->GetProductionCuts()->SetProductionCut(
0.5* ( ( *fHCalList[iterHCal]->GetRootLogicalVolumeIterator() )->
GetMaterial()->GetRadlen() ) );
fHCalList[ iterHCal ]->GetProductionCuts()->
SetProductionCut( 1.0*m, idxG4GammaCut );
for (G4int iterHCal = 0; iterHCal < G4int(fHCalList.size()); iterHCal++) {
fHCalList[iterHCal]->SetProductionCuts(new G4ProductionCuts());
fHCalList[iterHCal]->GetProductionCuts()->SetProductionCut(
0.5 * ((*fHCalList[iterHCal]->GetRootLogicalVolumeIterator())->GetMaterial()->GetRadlen()));
fHCalList[iterHCal]->GetProductionCuts()->SetProductionCut(1.0 * m, idxG4GammaCut);
}
// Returns the pointer to the physical world.
@@ -114,37 +113,34 @@ G4VPhysicalVolume* Par02DetectorConstruction::Construct() {
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02DetectorConstruction::ConstructSDandField() {
for ( G4int iterTracker = 0; iterTracker < G4int( fTrackerList.size() );
iterTracker++ ) {
void Par02DetectorConstruction::ConstructSDandField()
{
for (G4int iterTracker = 0; iterTracker < G4int(fTrackerList.size()); iterTracker++) {
// Bound the fast simulation model for the tracker subdetector
// to all the corresponding Geant4 regions
Par02FastSimModelTracker* fastSimModelTracker
= new Par02FastSimModelTracker( "fastSimModelTracker", fTrackerList[ iterTracker ],
Par02DetectorParametrisation::eCMS );
Par02FastSimModelTracker* fastSimModelTracker = new Par02FastSimModelTracker(
"fastSimModelTracker", fTrackerList[iterTracker], Par02DetectorParametrisation::eCMS);
// Register the fast simulation model for deleting
G4AutoDelete::Register(fastSimModelTracker);
}
for ( G4int iterECal = 0; iterECal < G4int( fECalList.size() ); iterECal++ ) {
for (G4int iterECal = 0; iterECal < G4int(fECalList.size()); iterECal++) {
// Bound the fast simulation model for the electromagnetic calorimeter
// to all the corresponding Geant4 regions
Par02FastSimModelEMCal* fastSimModelEMCal
= new Par02FastSimModelEMCal( "fastSimModelEMCal", fECalList[ iterECal ],
Par02DetectorParametrisation::eCMS );
Par02FastSimModelEMCal* fastSimModelEMCal = new Par02FastSimModelEMCal(
"fastSimModelEMCal", fECalList[iterECal], Par02DetectorParametrisation::eCMS);
// Register the fast simulation model for deleting
G4AutoDelete::Register(fastSimModelEMCal);
}
for ( G4int iterHCal = 0; iterHCal < G4int( fHCalList.size() ); iterHCal++ ) {
for (G4int iterHCal = 0; iterHCal < G4int(fHCalList.size()); iterHCal++) {
// Bound the fast simulation model for the hadronic calorimeter
// to all the corresponding Geant4 regions
Par02FastSimModelHCal* fastSimModelHCal
= new Par02FastSimModelHCal( "fastSimModelHCal", fHCalList[ iterHCal ],
Par02DetectorParametrisation::eCMS );
Par02FastSimModelHCal* fastSimModelHCal = new Par02FastSimModelHCal(
"fastSimModelHCal", fHCalList[iterHCal], Par02DetectorParametrisation::eCMS);
// Register the fast simulation model for deleting
G4AutoDelete::Register( fastSimModelHCal );
G4AutoDelete::Register(fastSimModelHCal);
}
// Currently we don't have a fast muon simulation model to be bound
// to all the corresponding Geant4 regions.
@@ -153,9 +149,8 @@ void Par02DetectorConstruction::ConstructSDandField() {
// Add global magnetic field
G4ThreeVector fieldValue = G4ThreeVector();
fMagFieldMessenger = new G4GlobalMagFieldMessenger( fieldValue );
fMagFieldMessenger = new G4GlobalMagFieldMessenger(fieldValue);
fMagFieldMessenger->SetVerboseLevel(1);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -28,6 +28,7 @@
/// \brief Implementation of the Par02DetectorParametrisation class
#include "Par02DetectorParametrisation.hh"
#include "G4SystemOfUnits.hh"
#include "G4UnitsTable.hh"
@@ -41,51 +42,53 @@ Par02DetectorParametrisation::~Par02DetectorParametrisation() = default;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double Par02DetectorParametrisation::GetResolution( Detector aDetector,
Parametrisation aParam,
G4double aMomentum ) {
G4double Par02DetectorParametrisation::GetResolution(Detector aDetector, Parametrisation aParam,
G4double aMomentum)
{
aMomentum /= GeV; // To make sure momentum's unit is GeV
G4double res = 1.0;
if ( aParam == eCMS ) {
switch ( aDetector ) {
case Par02DetectorParametrisation::eTRACKER :
if (aParam == eCMS) {
switch (aDetector) {
case Par02DetectorParametrisation::eTRACKER:
res = 0.013;
break;
case Par02DetectorParametrisation::eEMCAL :
res = std::sqrt( std::pow( 0.03 / std::sqrt( aMomentum ), 2 ) // stochastic
+ std::pow( 0.12 / aMomentum, 2 ) // noise
+ std::pow( 0.003, 2 ) ); // constant
case Par02DetectorParametrisation::eEMCAL:
res = std::sqrt(std::pow(0.03 / std::sqrt(aMomentum), 2) // stochastic
+ std::pow(0.12 / aMomentum, 2) // noise
+ std::pow(0.003, 2)); // constant
break;
case Par02DetectorParametrisation::eHCAL :
res = std::sqrt( std::pow( 1.1 / std::sqrt( aMomentum ), 2 ) // stochastic
+ std::pow( 0.09, 2 ) ); // constant
case Par02DetectorParametrisation::eHCAL:
res = std::sqrt(std::pow(1.1 / std::sqrt(aMomentum), 2) // stochastic
+ std::pow(0.09, 2)); // constant
break;
}
} else if ( aParam == eATLAS ) {
switch ( aDetector ) {
case Par02DetectorParametrisation::eTRACKER :
}
else if (aParam == eATLAS) {
switch (aDetector) {
case Par02DetectorParametrisation::eTRACKER:
res = 0.01;
break;
case Par02DetectorParametrisation::eEMCAL :
res = std::sqrt( std::pow( 0.1 / std::sqrt( aMomentum ), 2 ) // stochastic
+ std::pow( 0.0017, 2 ) ); // constant
case Par02DetectorParametrisation::eEMCAL:
res = std::sqrt(std::pow(0.1 / std::sqrt(aMomentum), 2) // stochastic
+ std::pow(0.0017, 2)); // constant
break;
case Par02DetectorParametrisation::eHCAL :
res = std::sqrt( std::pow( 0.55 / std::sqrt( aMomentum ), 2 ) // stochastic
+ std::pow( 0.06, 2 ) ); // constant
case Par02DetectorParametrisation::eHCAL:
res = std::sqrt(std::pow(0.55 / std::sqrt(aMomentum), 2) // stochastic
+ std::pow(0.06, 2)); // constant
break;
}
} else if ( aParam == eALEPH ) {
switch ( aDetector ) {
case Par02DetectorParametrisation::eTRACKER :
}
else if (aParam == eALEPH) {
switch (aDetector) {
case Par02DetectorParametrisation::eTRACKER:
res = 0.01;
break;
case Par02DetectorParametrisation::eEMCAL :
res = std::sqrt( std::pow( 0.18 / std::sqrt( aMomentum ), 2 ) // stochastic
+ std::pow( 0.009, 2 ) ); // constant
case Par02DetectorParametrisation::eEMCAL:
res = std::sqrt(std::pow(0.18 / std::sqrt(aMomentum), 2) // stochastic
+ std::pow(0.009, 2)); // constant
break;
case Par02DetectorParametrisation::eHCAL :
res = 0.85 / std::sqrt( aMomentum ); // stochastic
case Par02DetectorParametrisation::eHCAL:
res = 0.85 / std::sqrt(aMomentum); // stochastic
break;
}
}
@@ -94,19 +97,19 @@ G4double Par02DetectorParametrisation::GetResolution( Detector aDetector,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double Par02DetectorParametrisation::GetEfficiency( Detector aDetector,
Parametrisation /*aParam*/,
G4double /*aMomentum*/ ) {
G4double Par02DetectorParametrisation::GetEfficiency(Detector aDetector, Parametrisation /*aParam*/,
G4double /*aMomentum*/)
{
// For the time being, we set the efficiency to 1.0
G4double eff = 1.0;
switch ( aDetector ) {
case Par02DetectorParametrisation::eTRACKER :
switch (aDetector) {
case Par02DetectorParametrisation::eTRACKER:
eff = 1.0;
break;
case Par02DetectorParametrisation::eEMCAL :
case Par02DetectorParametrisation::eEMCAL:
eff = 1.0;
break;
case Par02DetectorParametrisation::eHCAL :
case Par02DetectorParametrisation::eHCAL:
eff = 1.0;
break;
}
@@ -114,4 +117,3 @@ G4double Par02DetectorParametrisation::GetEfficiency( Detector aDetector,
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -28,23 +28,25 @@
/// \brief Implementation of the Par02EventAction class
#include "Par02EventAction.hh"
#include "Par02EventInformation.hh"
#include "Par02RunAction.hh"
#include "Par02Output.hh"
#include "G4RunManager.hh"
#include "Par02RunAction.hh"
#include "G4Event.hh"
#include "G4RunManager.hh"
#include "G4UnitsTable.hh"
#include "Randomize.hh"
#include <iomanip>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02EventAction::Par02EventAction() : G4UserEventAction(), fSmear( 1 ) {}
Par02EventAction::Par02EventAction() : G4UserEventAction(), fSmear(1) {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02EventAction::Par02EventAction( G4bool aSmear ) :
G4UserEventAction(), fSmear( aSmear ) {}
Par02EventAction::Par02EventAction(G4bool aSmear) : G4UserEventAction(), fSmear(aSmear) {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -52,15 +54,14 @@ Par02EventAction::~Par02EventAction() = default;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02EventAction::BeginOfEventAction( const G4Event* /*aEvent*/ ) {
G4EventManager::GetEventManager()->SetUserInformation(
new Par02EventInformation( fSmear ) );
void Par02EventAction::BeginOfEventAction(const G4Event* /*aEvent*/)
{
G4EventManager::GetEventManager()->SetUserInformation(new Par02EventInformation(fSmear));
Par02Output::Instance()->CreateNtuples();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02EventAction::EndOfEventAction( const G4Event* /*aEvent*/ ) {}
void Par02EventAction::EndOfEventAction(const G4Event* /*aEvent*/) {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -31,11 +31,11 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02EventInformation::Par02EventInformation() : fDoSmearing( true ) {}
Par02EventInformation::Par02EventInformation() : fDoSmearing(true) {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02EventInformation::Par02EventInformation( G4bool aSmear ): fDoSmearing( aSmear ) {}
Par02EventInformation::Par02EventInformation(G4bool aSmear) : fDoSmearing(aSmear) {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -43,22 +43,23 @@ Par02EventInformation::~Par02EventInformation() = default;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02EventInformation::SetDoSmearing( G4bool aSmear ) {
void Par02EventInformation::SetDoSmearing(G4bool aSmear)
{
fDoSmearing = aSmear;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool Par02EventInformation::GetDoSmearing() {
G4bool Par02EventInformation::GetDoSmearing()
{
return fDoSmearing;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02EventInformation::Print() const {
G4cout << "Par02EventInformation: " << G4endl
<< "do smearing: " << fDoSmearing << G4endl;
void Par02EventInformation::Print() const
{
G4cout << "Par02EventInformation: " << G4endl << "do smearing: " << fDoSmearing << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -28,42 +28,46 @@
/// \brief Implementation of the Par02FastSimModelEMCal class
#include "Par02FastSimModelEMCal.hh"
#include "Par02EventInformation.hh"
#include "Par02Output.hh"
#include "Par02PrimaryParticleInformation.hh"
#include "Par02Smearer.hh"
#include "Par02Output.hh"
#include "G4Track.hh"
#include "G4Event.hh"
#include "G4RunManager.hh"
#include "G4AnalysisManager.hh"
#include "Randomize.hh"
#include "G4SystemOfUnits.hh"
#include "G4Electron.hh"
#include "G4Positron.hh"
#include "G4Event.hh"
#include "G4Gamma.hh"
#include "G4Positron.hh"
#include "G4RunManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4Track.hh"
#include "Randomize.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02FastSimModelEMCal::Par02FastSimModelEMCal( G4String aModelName,
G4Region* aEnvelope, Par02DetectorParametrisation::Parametrisation aType ) :
G4VFastSimulationModel( aModelName, aEnvelope ), fCalculateParametrisation(),
fParametrisation( aType ) {}
Par02FastSimModelEMCal::Par02FastSimModelEMCal(G4String aModelName, G4Region* aEnvelope,
Par02DetectorParametrisation::Parametrisation aType)
: G4VFastSimulationModel(aModelName, aEnvelope),
fCalculateParametrisation(),
fParametrisation(aType)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02FastSimModelEMCal::Par02FastSimModelEMCal( G4String aModelName,
G4Region* aEnvelope ) :
G4VFastSimulationModel( aModelName, aEnvelope ), fCalculateParametrisation(),
fParametrisation( Par02DetectorParametrisation::eCMS ) {}
Par02FastSimModelEMCal::Par02FastSimModelEMCal(G4String aModelName, G4Region* aEnvelope)
: G4VFastSimulationModel(aModelName, aEnvelope),
fCalculateParametrisation(),
fParametrisation(Par02DetectorParametrisation::eCMS)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02FastSimModelEMCal::Par02FastSimModelEMCal( G4String aModelName ) :
G4VFastSimulationModel( aModelName ), fCalculateParametrisation(),
fParametrisation( Par02DetectorParametrisation::eCMS ) {}
Par02FastSimModelEMCal::Par02FastSimModelEMCal(G4String aModelName)
: G4VFastSimulationModel(aModelName),
fCalculateParametrisation(),
fParametrisation(Par02DetectorParametrisation::eCMS)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -71,74 +75,87 @@ Par02FastSimModelEMCal::~Par02FastSimModelEMCal() = default;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool Par02FastSimModelEMCal::IsApplicable(
const G4ParticleDefinition& aParticleType ) {
G4bool Par02FastSimModelEMCal::IsApplicable(const G4ParticleDefinition& aParticleType)
{
// Applicable for electrons, positrons, and gammas
return &aParticleType == G4Electron::Definition() ||
&aParticleType == G4Positron::Definition() ||
&aParticleType == G4Gamma::Definition();
return &aParticleType == G4Electron::Definition() || &aParticleType == G4Positron::Definition()
|| &aParticleType == G4Gamma::Definition();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool Par02FastSimModelEMCal::ModelTrigger( const G4FastTrack& /*aFastTrack*/ ) {
G4bool Par02FastSimModelEMCal::ModelTrigger(const G4FastTrack& /*aFastTrack*/)
{
return true; // No kinematical restrictions to apply the parametrisation
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02FastSimModelEMCal::DoIt( const G4FastTrack& aFastTrack,
G4FastStep& aFastStep ) {
//G4cout << " ________EMCal model triggered _________" << G4endl;
void Par02FastSimModelEMCal::DoIt(const G4FastTrack& aFastTrack, G4FastStep& aFastStep)
{
// G4cout << " ________EMCal model triggered _________" << G4endl;
// Kill the parameterised particle at the entrance of the electromagnetic calorimeter
aFastStep.KillPrimaryTrack();
aFastStep.ProposePrimaryTrackPathLength( 0.0 );
aFastStep.ProposePrimaryTrackPathLength(0.0);
G4double Edep = aFastTrack.GetPrimaryTrack()->GetKineticEnergy();
// Consider only primary tracks (do nothing else for secondary e-, e+, gammas)
G4ThreeVector Pos = aFastTrack.GetPrimaryTrack()->GetPosition();
if ( ! aFastTrack.GetPrimaryTrack()->GetParentID() ) {
auto info = (Par02EventInformation*)
G4EventManager::GetEventManager()->GetUserInformation();
if ( info->GetDoSmearing() ) {
if (!aFastTrack.GetPrimaryTrack()->GetParentID()) {
auto info = (Par02EventInformation*)G4EventManager::GetEventManager()->GetUserInformation();
if (info->GetDoSmearing()) {
// Smearing according to the electromagnetic calorimeter resolution
G4ThreeVector Porg = aFastTrack.GetPrimaryTrack()->GetMomentum();
G4double res = fCalculateParametrisation->GetResolution(
Par02DetectorParametrisation::eEMCAL, fParametrisation, Porg.mag() );
G4double eff = fCalculateParametrisation->GetEfficiency(
Par02DetectorParametrisation::eEMCAL, fParametrisation, Porg.mag() );
G4double res = fCalculateParametrisation->GetResolution(Par02DetectorParametrisation::eEMCAL,
fParametrisation, Porg.mag());
G4double eff = fCalculateParametrisation->GetEfficiency(Par02DetectorParametrisation::eEMCAL,
fParametrisation, Porg.mag());
G4double Esm;
Esm = std::abs( Par02Smearer::Instance()->
SmearEnergy( aFastTrack.GetPrimaryTrack(), res ) );
Par02Output::Instance()->FillHistogram( 1, (Esm/MeV) / (Edep/MeV) );
Esm = std::abs(Par02Smearer::Instance()->SmearEnergy(aFastTrack.GetPrimaryTrack(), res));
Par02Output::Instance()->FillHistogram(1, (Esm / MeV) / (Edep / MeV));
// Setting the values of Pos, Esm, res and eff
( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
GetUserInformation() ) )->SetEMCalPosition( Pos );
( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
GetUserInformation() ) )->SetEMCalEnergy( Esm );
( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
GetUserInformation() ) )->SetEMCalResolution( res );
( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
GetUserInformation() ) )->SetEMCalEfficiency( eff );
((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
aFastTrack.GetPrimaryTrack()
->GetDynamicParticle()
->GetPrimaryParticle())
->GetUserInformation()))
->SetEMCalPosition(Pos);
((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
aFastTrack.GetPrimaryTrack()
->GetDynamicParticle()
->GetPrimaryParticle())
->GetUserInformation()))
->SetEMCalEnergy(Esm);
((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
aFastTrack.GetPrimaryTrack()
->GetDynamicParticle()
->GetPrimaryParticle())
->GetUserInformation()))
->SetEMCalResolution(res);
((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
aFastTrack.GetPrimaryTrack()
->GetDynamicParticle()
->GetPrimaryParticle())
->GetUserInformation()))
->SetEMCalEfficiency(eff);
// The (smeared) energy of the particle is deposited in the step
// (which corresponds to the entrance of the electromagnetic calorimeter)
aFastStep.ProposeTotalEnergyDeposited( Esm );
} else {
aFastStep.ProposeTotalEnergyDeposited(Esm);
}
else {
// No smearing: simply setting the value of Edep
( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
GetUserInformation() ) )->SetEMCalEnergy( Edep );
((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
aFastTrack.GetPrimaryTrack()
->GetDynamicParticle()
->GetPrimaryParticle())
->GetUserInformation()))
->SetEMCalEnergy(Edep);
// The (initial) energy of the particle is deposited in the step
// (which corresponds to the entrance of the electromagnetic calorimeter)
aFastStep.ProposeTotalEnergyDeposited( Edep );
aFastStep.ProposeTotalEnergyDeposited(Edep);
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -28,38 +28,43 @@
/// \brief Implementation of the Par02FastSimModelHCal class
#include "Par02FastSimModelHCal.hh"
#include "Par02EventInformation.hh"
#include "Par02Output.hh"
#include "Par02PrimaryParticleInformation.hh"
#include "Par02Smearer.hh"
#include "Par02Output.hh"
#include "G4Track.hh"
#include "G4AnalysisManager.hh"
#include "G4Event.hh"
#include "G4RunManager.hh"
#include "G4AnalysisManager.hh"
#include "Randomize.hh"
#include "G4SystemOfUnits.hh"
#include "G4Track.hh"
#include "Randomize.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02FastSimModelHCal::Par02FastSimModelHCal( G4String aModelName,
G4Region* aEnvelope, Par02DetectorParametrisation::Parametrisation aType ) :
G4VFastSimulationModel( aModelName, aEnvelope ), fCalculateParametrisation(),
fParametrisation( aType ) {}
Par02FastSimModelHCal::Par02FastSimModelHCal(G4String aModelName, G4Region* aEnvelope,
Par02DetectorParametrisation::Parametrisation aType)
: G4VFastSimulationModel(aModelName, aEnvelope),
fCalculateParametrisation(),
fParametrisation(aType)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02FastSimModelHCal::Par02FastSimModelHCal( G4String aModelName,
G4Region* aEnvelope ) :
G4VFastSimulationModel( aModelName, aEnvelope ), fCalculateParametrisation(),
fParametrisation( Par02DetectorParametrisation::eCMS ) {}
Par02FastSimModelHCal::Par02FastSimModelHCal(G4String aModelName, G4Region* aEnvelope)
: G4VFastSimulationModel(aModelName, aEnvelope),
fCalculateParametrisation(),
fParametrisation(Par02DetectorParametrisation::eCMS)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02FastSimModelHCal::Par02FastSimModelHCal( G4String aModelName ) :
G4VFastSimulationModel( aModelName ), fCalculateParametrisation(),
fParametrisation( Par02DetectorParametrisation::eCMS ) {}
Par02FastSimModelHCal::Par02FastSimModelHCal(G4String aModelName)
: G4VFastSimulationModel(aModelName),
fCalculateParametrisation(),
fParametrisation(Par02DetectorParametrisation::eCMS)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -67,78 +72,77 @@ Par02FastSimModelHCal::~Par02FastSimModelHCal() = default;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool Par02FastSimModelHCal::IsApplicable( const G4ParticleDefinition& aParticleType ) {
G4bool Par02FastSimModelHCal::IsApplicable(const G4ParticleDefinition& aParticleType)
{
G4bool isOk = false;
// Applicable to all hadrons, i.e. any particle made of quarks
if ( aParticleType.GetQuarkContent(1) +
aParticleType.GetQuarkContent(2) +
aParticleType.GetQuarkContent(3) +
aParticleType.GetQuarkContent(4) +
aParticleType.GetQuarkContent(5) +
aParticleType.GetQuarkContent(6) != 0 ) {
if (aParticleType.GetQuarkContent(1) + aParticleType.GetQuarkContent(2)
+ aParticleType.GetQuarkContent(3) + aParticleType.GetQuarkContent(4)
+ aParticleType.GetQuarkContent(5) + aParticleType.GetQuarkContent(6)
!= 0)
{
isOk = true;
}
return isOk;
return isOk;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool Par02FastSimModelHCal::ModelTrigger( const G4FastTrack& /*aFastTrack*/ ) {
G4bool Par02FastSimModelHCal::ModelTrigger(const G4FastTrack& /*aFastTrack*/)
{
return true; // No kinematical restrictions to apply the parametrisation
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02FastSimModelHCal::DoIt( const G4FastTrack& aFastTrack,
G4FastStep& aFastStep ) {
//G4cout << " ________HCal model triggered _________" << G4endl;
void Par02FastSimModelHCal::DoIt(const G4FastTrack& aFastTrack, G4FastStep& aFastStep)
{
// G4cout << " ________HCal model triggered _________" << G4endl;
// Kill the parameterised particle at the entrance of the hadronic calorimeter
aFastStep.KillPrimaryTrack();
aFastStep.ProposePrimaryTrackPathLength( 0.0 );
aFastStep.ProposePrimaryTrackPathLength(0.0);
G4double Edep = aFastTrack.GetPrimaryTrack()->GetKineticEnergy();
// Consider only primary tracks (do nothing else for secondary hadrons)
G4ThreeVector Pos = aFastTrack.GetPrimaryTrack()->GetPosition();
if ( ! aFastTrack.GetPrimaryTrack()->GetParentID() ) {
auto info = (Par02EventInformation*)
G4EventManager::GetEventManager()->GetUserInformation();
if ( info->GetDoSmearing() ) {
if (!aFastTrack.GetPrimaryTrack()->GetParentID()) {
auto info = (Par02EventInformation*)G4EventManager::GetEventManager()->GetUserInformation();
if (info->GetDoSmearing()) {
// Smearing according to the hadronic calorimeter resolution
G4ThreeVector Porg = aFastTrack.GetPrimaryTrack()->GetMomentum();
G4double res = fCalculateParametrisation->
GetResolution( Par02DetectorParametrisation::eHCAL,
fParametrisation, Porg.mag() );
G4double eff = fCalculateParametrisation->
GetEfficiency( Par02DetectorParametrisation::eHCAL,
fParametrisation, Porg.mag() );
G4double res = fCalculateParametrisation->GetResolution(Par02DetectorParametrisation::eHCAL,
fParametrisation, Porg.mag());
G4double eff = fCalculateParametrisation->GetEfficiency(Par02DetectorParametrisation::eHCAL,
fParametrisation, Porg.mag());
G4double Esm;
Esm = std::abs( Par02Smearer::Instance()->
SmearEnergy( aFastTrack.GetPrimaryTrack(), res ) );
Par02Output::Instance()->FillHistogram( 2, (Esm/MeV) / (Edep/MeV) );
Esm = std::abs(Par02Smearer::Instance()->SmearEnergy(aFastTrack.GetPrimaryTrack(), res));
Par02Output::Instance()->FillHistogram(2, (Esm / MeV) / (Edep / MeV));
// Setting the values of Pos, Esm, res and eff
auto primaryInfo=
static_cast<Par02PrimaryParticleInformation*>(
( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
GetUserInformation() ) ;
primaryInfo->SetHCalPosition( Pos );
primaryInfo->SetHCalEnergy( Esm );
primaryInfo->SetHCalResolution( res );
primaryInfo->SetHCalEfficiency( eff );
auto primaryInfo = static_cast<Par02PrimaryParticleInformation*>(
(aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle())
->GetUserInformation());
primaryInfo->SetHCalPosition(Pos);
primaryInfo->SetHCalEnergy(Esm);
primaryInfo->SetHCalResolution(res);
primaryInfo->SetHCalEfficiency(eff);
// The (smeared) energy of the particle is deposited in the step
// (which corresponds to the entrance of the hadronic calorimeter)
aFastStep.ProposeTotalEnergyDeposited( Esm );
} else {
aFastStep.ProposeTotalEnergyDeposited(Esm);
}
else {
// No smearing: simply setting the value of Edep
( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
GetUserInformation() ) )->SetHCalEnergy( Edep );
((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
aFastTrack.GetPrimaryTrack()
->GetDynamicParticle()
->GetPrimaryParticle())
->GetUserInformation()))
->SetHCalEnergy(Edep);
// The (initial) energy of the particle is deposited in the step
// (which corresponds to the entrance of the hadronic calorimeter)
aFastStep.ProposeTotalEnergyDeposited( Edep );
aFastStep.ProposeTotalEnergyDeposited(Edep);
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -28,46 +28,49 @@
/// \brief Implementation of the Par02FastSimModelTracker class
#include "Par02FastSimModelTracker.hh"
#include "Par02EventInformation.hh"
#include "Par02Output.hh"
#include "Par02PrimaryParticleInformation.hh"
#include "Par02Smearer.hh"
#include "Par02Output.hh"
#include "G4Track.hh"
#include "G4Event.hh"
#include "G4RunManager.hh"
#include "G4AnalysisManager.hh"
#include "Randomize.hh"
#include "G4Electron.hh"
#include "G4Positron.hh"
#include "G4Gamma.hh"
#include "G4PathFinder.hh"
#include "G4Event.hh"
#include "G4FieldTrack.hh"
#include "G4FieldTrackUpdator.hh"
#include "G4Gamma.hh"
#include "G4PathFinder.hh"
#include "G4Positron.hh"
#include "G4RunManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4Track.hh"
#include "Randomize.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02FastSimModelTracker::Par02FastSimModelTracker( G4String aModelName,
G4Region* aEnvelope, Par02DetectorParametrisation::Parametrisation aType ) :
G4VFastSimulationModel( aModelName, aEnvelope ), fCalculateParametrisation(),
fParametrisation( aType ) {}
Par02FastSimModelTracker::Par02FastSimModelTracker(
G4String aModelName, G4Region* aEnvelope, Par02DetectorParametrisation::Parametrisation aType)
: G4VFastSimulationModel(aModelName, aEnvelope),
fCalculateParametrisation(),
fParametrisation(aType)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02FastSimModelTracker::Par02FastSimModelTracker( G4String aModelName,
G4Region* aEnvelope ) :
G4VFastSimulationModel( aModelName, aEnvelope ), fCalculateParametrisation(),
fParametrisation( Par02DetectorParametrisation::eCMS ) {}
Par02FastSimModelTracker::Par02FastSimModelTracker(G4String aModelName, G4Region* aEnvelope)
: G4VFastSimulationModel(aModelName, aEnvelope),
fCalculateParametrisation(),
fParametrisation(Par02DetectorParametrisation::eCMS)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02FastSimModelTracker::Par02FastSimModelTracker( G4String aModelName ) :
G4VFastSimulationModel( aModelName ), fCalculateParametrisation(),
fParametrisation( Par02DetectorParametrisation::eCMS ) {}
Par02FastSimModelTracker::Par02FastSimModelTracker(G4String aModelName)
: G4VFastSimulationModel(aModelName),
fCalculateParametrisation(),
fParametrisation(Par02DetectorParametrisation::eCMS)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -75,86 +78,89 @@ Par02FastSimModelTracker::~Par02FastSimModelTracker() = default;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool Par02FastSimModelTracker::IsApplicable( const G4ParticleDefinition&
aParticleType ) {
G4bool Par02FastSimModelTracker::IsApplicable(const G4ParticleDefinition& aParticleType)
{
return aParticleType.GetPDGCharge() != 0; // Applicable for all charged particles
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool Par02FastSimModelTracker::ModelTrigger( const G4FastTrack& /*aFastTrack*/ ) {
G4bool Par02FastSimModelTracker::ModelTrigger(const G4FastTrack& /*aFastTrack*/)
{
return true; // No kinematical restrictions to apply the parametrisation
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02FastSimModelTracker::DoIt( const G4FastTrack& aFastTrack,
G4FastStep& aFastStep ) {
void Par02FastSimModelTracker::DoIt(const G4FastTrack& aFastTrack, G4FastStep& aFastStep)
{
G4cout << " ________Tracker model triggered _________" << G4endl;
// Calculate the final position (at the outer boundary of the tracking detector)
// of the particle with the momentum at the entrance of the tracking detector.
G4Track track = * aFastTrack.GetPrimaryTrack();
G4FieldTrack aFieldTrack( '0' );
G4FieldTrackUpdator::Update( &aFieldTrack, &track );
G4Track track = *aFastTrack.GetPrimaryTrack();
G4FieldTrack aFieldTrack('0');
G4FieldTrackUpdator::Update(&aFieldTrack, &track);
G4double retSafety = -1.0;
ELimited retStepLimited;
G4FieldTrack endTrack( 'a' );
G4double currentMinimumStep = 10.0*m; // Temporary: change that to sth connected
// to particle momentum.
G4FieldTrack endTrack('a');
G4double currentMinimumStep = 10.0 * m; // Temporary: change that to sth connected
// to particle momentum.
G4PathFinder* fPathFinder = G4PathFinder::GetInstance();
/*G4double lengthAlongCurve = */
fPathFinder->ComputeStep( aFieldTrack,
currentMinimumStep,
0,
aFastTrack.GetPrimaryTrack()->GetCurrentStepNumber(),
retSafety,
retStepLimited,
endTrack,
aFastTrack.GetPrimaryTrack()->GetVolume() );
/*G4double lengthAlongCurve = */
fPathFinder->ComputeStep(aFieldTrack, currentMinimumStep, 0,
aFastTrack.GetPrimaryTrack()->GetCurrentStepNumber(), retSafety,
retStepLimited, endTrack, aFastTrack.GetPrimaryTrack()->GetVolume());
// Place the particle at the tracking detector exit
// Place the particle at the tracking detector exit
// (at the place it would reach without the change of its momentum).
aFastStep.ProposePrimaryTrackFinalPosition( endTrack.GetPosition() );
aFastStep.ProposePrimaryTrackFinalPosition(endTrack.GetPosition());
// Consider only primary tracks (do nothing else for secondary charged particles)
G4ThreeVector Porg = aFastTrack.GetPrimaryTrack()->GetMomentum();
if ( ! aFastTrack.GetPrimaryTrack()->GetParentID() ) {
auto info = (Par02EventInformation*)
G4EventManager::GetEventManager()->GetUserInformation();
if ( info->GetDoSmearing() ) {
if (!aFastTrack.GetPrimaryTrack()->GetParentID()) {
auto info = (Par02EventInformation*)G4EventManager::GetEventManager()->GetUserInformation();
if (info->GetDoSmearing()) {
// Smearing according to the tracking detector resolution
G4double res = fCalculateParametrisation->
GetResolution( Par02DetectorParametrisation::eTRACKER,
fParametrisation, Porg.mag() );
G4double eff = fCalculateParametrisation->
GetEfficiency( Par02DetectorParametrisation::eTRACKER,
fParametrisation, Porg.mag() );
G4double res = fCalculateParametrisation->GetResolution(
Par02DetectorParametrisation::eTRACKER, fParametrisation, Porg.mag());
G4double eff = fCalculateParametrisation->GetEfficiency(
Par02DetectorParametrisation::eTRACKER, fParametrisation, Porg.mag());
G4ThreeVector Psm;
Psm = Par02Smearer::Instance()->
SmearMomentum( aFastTrack.GetPrimaryTrack(), res );
Par02Output::Instance()->FillHistogram( 0, ((Psm.mag()/MeV) / (Porg.mag()/MeV)) );
Psm = Par02Smearer::Instance()->SmearMomentum(aFastTrack.GetPrimaryTrack(), res);
Par02Output::Instance()->FillHistogram(0, ((Psm.mag() / MeV) / (Porg.mag() / MeV)));
// Setting the values of Psm, res and eff
( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
GetUserInformation() ) )->SetTrackerMomentum( Psm );
( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
GetUserInformation() ) )->SetTrackerResolution( res );
( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
GetUserInformation() ) )->SetTrackerEfficiency( eff );
} else {
((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
aFastTrack.GetPrimaryTrack()
->GetDynamicParticle()
->GetPrimaryParticle())
->GetUserInformation()))
->SetTrackerMomentum(Psm);
((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
aFastTrack.GetPrimaryTrack()
->GetDynamicParticle()
->GetPrimaryParticle())
->GetUserInformation()))
->SetTrackerResolution(res);
((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
aFastTrack.GetPrimaryTrack()
->GetDynamicParticle()
->GetPrimaryParticle())
->GetUserInformation()))
->SetTrackerEfficiency(eff);
}
else {
// No smearing: simply setting the value of Porg
( (Par02PrimaryParticleInformation*) ( const_cast< G4PrimaryParticle* >
( aFastTrack.GetPrimaryTrack()->GetDynamicParticle()->GetPrimaryParticle() )->
GetUserInformation() ) )->SetTrackerMomentum( Porg );
((Par02PrimaryParticleInformation*)(const_cast<G4PrimaryParticle*>(
aFastTrack.GetPrimaryTrack()
->GetDynamicParticle()
->GetPrimaryParticle())
->GetUserInformation()))
->SetTrackerMomentum(Porg);
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -28,13 +28,14 @@
/// \brief Implementation of the Par02Output class
#include "Par02Output.hh"
#include "Par02EventInformation.hh"
#include "G4AnalysisManager.hh"
#include "G4Event.hh"
#include "G4RunManager.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "G4AnalysisManager.hh"
#include "G4UnitsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -44,7 +45,8 @@ G4ThreadLocal G4int Par02Output::fCurrentID = 0;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02Output::Par02Output() : fFileNameWithRunNo( false ) {
Par02Output::Par02Output() : fFileNameWithRunNo(false)
{
fFileName = "DefaultOutput.root";
}
@@ -54,8 +56,9 @@ Par02Output::~Par02Output() = default;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02Output* Par02Output::Instance() {
if ( ! fPar02Output ) {
Par02Output* Par02Output::Instance()
{
if (!fPar02Output) {
fPar02Output = new Par02Output();
}
return fPar02Output;
@@ -63,39 +66,44 @@ Par02Output* Par02Output::Instance() {
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02Output::SetFileName( G4String aName ) {
void Par02Output::SetFileName(G4String aName)
{
fFileName = aName;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02Output::AppendName( G4bool aApp ) {
void Par02Output::AppendName(G4bool aApp)
{
fFileNameWithRunNo = aApp;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4String Par02Output::GetFileName() {
G4String Par02Output::GetFileName()
{
return fFileName;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02Output::StartAnalysis( G4int aRunID ) {
void Par02Output::StartAnalysis(G4int aRunID)
{
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
if ( fFileNameWithRunNo ) {
fFileName += "_run";
fFileName += G4UIcommand::ConvertToString( aRunID );
if (fFileNameWithRunNo) {
fFileName += "_run";
fFileName += G4UIcommand::ConvertToString(aRunID);
}
analysisManager->SetDefaultFileType("root");
analysisManager->SetVerboseLevel( 1 );
analysisManager->SetFileName( fFileName );
analysisManager->OpenFile( fFileName );
analysisManager->SetVerboseLevel(1);
analysisManager->SetFileName(fFileName);
analysisManager->OpenFile(fFileName);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02Output::EndAnalysis() {
void Par02Output::EndAnalysis()
{
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
analysisManager->Write();
analysisManager->CloseFile();
@@ -103,40 +111,41 @@ void Par02Output::EndAnalysis() {
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02Output::CreateNtuples() {
void Par02Output::CreateNtuples()
{
const G4Event* event = G4RunManager::GetRunManager()->GetCurrentEvent();
G4String evName = "Event_";
evName += G4UIcommand::ConvertToString( event->GetEventID() );
evName += G4UIcommand::ConvertToString(event->GetEventID());
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
fCurrentNtupleId = analysisManager->CreateNtuple( evName, evName );
fCurrentNtupleId = analysisManager->CreateNtuple(evName, evName);
analysisManager->CreateNtupleIColumn( "particleID" ); // column Id = 0
analysisManager->CreateNtupleIColumn( "PID" ); // column Id = 1
analysisManager->CreateNtupleDColumn( "MC_pX" ); // column Id = 2
analysisManager->CreateNtupleDColumn( "MC_pY" ); // column Id = 3
analysisManager->CreateNtupleDColumn( "MC_pZ" ); // column Id = 4
analysisManager->CreateNtupleIColumn("particleID"); // column Id = 0
analysisManager->CreateNtupleIColumn("PID"); // column Id = 1
analysisManager->CreateNtupleDColumn("MC_pX"); // column Id = 2
analysisManager->CreateNtupleDColumn("MC_pY"); // column Id = 3
analysisManager->CreateNtupleDColumn("MC_pZ"); // column Id = 4
analysisManager->CreateNtupleDColumn( "tracker_res" ); // column Id = 5
analysisManager->CreateNtupleDColumn( "tracker_eff" ); // column Id = 6
analysisManager->CreateNtupleDColumn( "tracker_pX" ); // column Id = 7
analysisManager->CreateNtupleDColumn( "tracker_pY" ); // column Id = 8
analysisManager->CreateNtupleDColumn( "tracker_pZ" ); // column Id = 9
analysisManager->CreateNtupleDColumn("tracker_res"); // column Id = 5
analysisManager->CreateNtupleDColumn("tracker_eff"); // column Id = 6
analysisManager->CreateNtupleDColumn("tracker_pX"); // column Id = 7
analysisManager->CreateNtupleDColumn("tracker_pY"); // column Id = 8
analysisManager->CreateNtupleDColumn("tracker_pZ"); // column Id = 9
analysisManager->CreateNtupleDColumn( "emcal_res" ); // column Id = 10
analysisManager->CreateNtupleDColumn( "emcal_eff" ); // column Id = 11
analysisManager->CreateNtupleDColumn( "emcal_X" ); // column Id = 12
analysisManager->CreateNtupleDColumn( "emcal_Y" ); // column Id = 13
analysisManager->CreateNtupleDColumn( "emcal_Z" ); // column Id = 14
analysisManager->CreateNtupleDColumn( "emcal_E" ); // column Id = 15
analysisManager->CreateNtupleDColumn("emcal_res"); // column Id = 10
analysisManager->CreateNtupleDColumn("emcal_eff"); // column Id = 11
analysisManager->CreateNtupleDColumn("emcal_X"); // column Id = 12
analysisManager->CreateNtupleDColumn("emcal_Y"); // column Id = 13
analysisManager->CreateNtupleDColumn("emcal_Z"); // column Id = 14
analysisManager->CreateNtupleDColumn("emcal_E"); // column Id = 15
analysisManager->CreateNtupleDColumn( "hcal_res" ); // column Id = 16
analysisManager->CreateNtupleDColumn( "hcal_eff" ); // column Id = 17
analysisManager->CreateNtupleDColumn( "hcal_X" ); // column Id = 18
analysisManager->CreateNtupleDColumn( "hcal_Y" ); // column Id = 19
analysisManager->CreateNtupleDColumn( "hcal_Z" ); // column Id = 20
analysisManager->CreateNtupleDColumn( "hcal_E" ); // column Id = 21
analysisManager->CreateNtupleDColumn("hcal_res"); // column Id = 16
analysisManager->CreateNtupleDColumn("hcal_eff"); // column Id = 17
analysisManager->CreateNtupleDColumn("hcal_X"); // column Id = 18
analysisManager->CreateNtupleDColumn("hcal_Y"); // column Id = 19
analysisManager->CreateNtupleDColumn("hcal_Z"); // column Id = 20
analysisManager->CreateNtupleDColumn("hcal_E"); // column Id = 21
analysisManager->FinishNtuple( fCurrentNtupleId );
analysisManager->FinishNtuple(fCurrentNtupleId);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -144,69 +153,69 @@ void Par02Output::CreateNtuples() {
void Par02Output::CreateHistograms()
{
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
analysisManager->CreateH1( "Pdiff", "momentum smeared in tracker", 100, 0.8, 1.2 );
analysisManager->SetH1XAxisTitle( 0, "p_{smeared}/p_{true}" );
analysisManager->SetH1YAxisTitle( 0, "Entries" );
analysisManager->CreateH1( "EMCalEdiff", "energy smeared in EMCal", 100, 0.8, 1.2 );
analysisManager->SetH1XAxisTitle( 1, "E_{smeared}/E_{true}" );
analysisManager->SetH1YAxisTitle( 1, "Entries" );
analysisManager->CreateH1( "HCalEdiff", "energy smeared in HCal", 100, 0.0, 2.0 );
analysisManager->SetH1XAxisTitle( 2, "E_{smeared}/E_{true}" );
analysisManager->SetH1YAxisTitle( 2, "Entries" );
analysisManager->CreateH1("Pdiff", "momentum smeared in tracker", 100, 0.8, 1.2);
analysisManager->SetH1XAxisTitle(0, "p_{smeared}/p_{true}");
analysisManager->SetH1YAxisTitle(0, "Entries");
analysisManager->CreateH1("EMCalEdiff", "energy smeared in EMCal", 100, 0.8, 1.2);
analysisManager->SetH1XAxisTitle(1, "E_{smeared}/E_{true}");
analysisManager->SetH1YAxisTitle(1, "Entries");
analysisManager->CreateH1("HCalEdiff", "energy smeared in HCal", 100, 0.0, 2.0);
analysisManager->SetH1XAxisTitle(2, "E_{smeared}/E_{true}");
analysisManager->SetH1YAxisTitle(2, "Entries");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02Output::SaveTrack( SaveType aWhatToSave, G4int aPartID, G4int aPDG,
G4ThreeVector aVector, G4double aResolution,
G4double aEfficiency, G4double aEnergy ) {
void Par02Output::SaveTrack(SaveType aWhatToSave, G4int aPartID, G4int aPDG, G4ThreeVector aVector,
G4double aResolution, G4double aEfficiency, G4double aEnergy)
{
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
switch( aWhatToSave ) {
case Par02Output::eNoSave :
switch (aWhatToSave) {
case Par02Output::eNoSave:
break;
case Par02Output::eSaveMC : {
analysisManager->FillNtupleIColumn( fCurrentNtupleId, 0, aPartID );
analysisManager->FillNtupleIColumn( fCurrentNtupleId, 1, aPDG );
analysisManager->FillNtupleDColumn( fCurrentNtupleId, 2, aVector.x() );
analysisManager->FillNtupleDColumn( fCurrentNtupleId, 3, aVector.y() );
analysisManager->FillNtupleDColumn( fCurrentNtupleId, 4, aVector.z() );
case Par02Output::eSaveMC: {
analysisManager->FillNtupleIColumn(fCurrentNtupleId, 0, aPartID);
analysisManager->FillNtupleIColumn(fCurrentNtupleId, 1, aPDG);
analysisManager->FillNtupleDColumn(fCurrentNtupleId, 2, aVector.x());
analysisManager->FillNtupleDColumn(fCurrentNtupleId, 3, aVector.y());
analysisManager->FillNtupleDColumn(fCurrentNtupleId, 4, aVector.z());
fCurrentID = aPartID;
break;
}
case Par02Output::eSaveTracker : {
if ( aPartID != fCurrentID ) G4cout <<
" Wrong particle - trying to save Tracker information of different particle"
<< G4endl;
analysisManager->FillNtupleDColumn( fCurrentNtupleId, 5, aResolution );
analysisManager->FillNtupleDColumn( fCurrentNtupleId, 6, aEfficiency );
analysisManager->FillNtupleDColumn( fCurrentNtupleId, 7, aVector.x() );
analysisManager->FillNtupleDColumn( fCurrentNtupleId, 8, aVector.y() );
analysisManager->FillNtupleDColumn( fCurrentNtupleId, 9, aVector.z() );
case Par02Output::eSaveTracker: {
if (aPartID != fCurrentID)
G4cout << " Wrong particle - trying to save Tracker information of different particle"
<< G4endl;
analysisManager->FillNtupleDColumn(fCurrentNtupleId, 5, aResolution);
analysisManager->FillNtupleDColumn(fCurrentNtupleId, 6, aEfficiency);
analysisManager->FillNtupleDColumn(fCurrentNtupleId, 7, aVector.x());
analysisManager->FillNtupleDColumn(fCurrentNtupleId, 8, aVector.y());
analysisManager->FillNtupleDColumn(fCurrentNtupleId, 9, aVector.z());
break;
}
case Par02Output::eSaveEMCal : {
if ( aPartID != fCurrentID ) G4cout <<
" Wrong particle - trying to save EMCal information of different particle"
<< G4endl;
analysisManager->FillNtupleDColumn( fCurrentNtupleId, 10, aResolution );
analysisManager->FillNtupleDColumn( fCurrentNtupleId, 11, aEfficiency );
analysisManager->FillNtupleDColumn( fCurrentNtupleId, 12, aVector.x() );
analysisManager->FillNtupleDColumn( fCurrentNtupleId, 13, aVector.y() );
analysisManager->FillNtupleDColumn( fCurrentNtupleId, 14, aVector.z() );
analysisManager->FillNtupleDColumn( fCurrentNtupleId, 15, aEnergy );
case Par02Output::eSaveEMCal: {
if (aPartID != fCurrentID)
G4cout << " Wrong particle - trying to save EMCal information of different particle"
<< G4endl;
analysisManager->FillNtupleDColumn(fCurrentNtupleId, 10, aResolution);
analysisManager->FillNtupleDColumn(fCurrentNtupleId, 11, aEfficiency);
analysisManager->FillNtupleDColumn(fCurrentNtupleId, 12, aVector.x());
analysisManager->FillNtupleDColumn(fCurrentNtupleId, 13, aVector.y());
analysisManager->FillNtupleDColumn(fCurrentNtupleId, 14, aVector.z());
analysisManager->FillNtupleDColumn(fCurrentNtupleId, 15, aEnergy);
break;
}
case Par02Output::eSaveHCal : {
if ( aPartID != fCurrentID ) G4cout <<
" Wrong particle - trying to save HCal information of different particle"
<< G4endl;
analysisManager->FillNtupleDColumn( fCurrentNtupleId, 16, aResolution );
analysisManager->FillNtupleDColumn( fCurrentNtupleId, 17, aEfficiency );
analysisManager->FillNtupleDColumn( fCurrentNtupleId, 18, aVector.x() );
analysisManager->FillNtupleDColumn( fCurrentNtupleId, 19, aVector.y() );
analysisManager->FillNtupleDColumn( fCurrentNtupleId, 20, aVector.z() );
analysisManager->FillNtupleDColumn( fCurrentNtupleId, 21, aEnergy );
analysisManager->AddNtupleRow( fCurrentNtupleId );
case Par02Output::eSaveHCal: {
if (aPartID != fCurrentID)
G4cout << " Wrong particle - trying to save HCal information of different particle"
<< G4endl;
analysisManager->FillNtupleDColumn(fCurrentNtupleId, 16, aResolution);
analysisManager->FillNtupleDColumn(fCurrentNtupleId, 17, aEfficiency);
analysisManager->FillNtupleDColumn(fCurrentNtupleId, 18, aVector.x());
analysisManager->FillNtupleDColumn(fCurrentNtupleId, 19, aVector.y());
analysisManager->FillNtupleDColumn(fCurrentNtupleId, 20, aVector.z());
analysisManager->FillNtupleDColumn(fCurrentNtupleId, 21, aEnergy);
analysisManager->AddNtupleRow(fCurrentNtupleId);
break;
}
}
@@ -214,10 +223,10 @@ void Par02Output::SaveTrack( SaveType aWhatToSave, G4int aPartID, G4int aPDG,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02Output::FillHistogram( G4int aHistNo, G4double aValue ) const {
void Par02Output::FillHistogram(G4int aHistNo, G4double aValue) const
{
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
analysisManager->FillH1( aHistNo, aValue );
analysisManager->FillH1(aHistNo, aValue);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -28,48 +28,45 @@
/// \brief Implementation of the Par02PhysicsList class
#include "Par02PhysicsList.hh"
#include "globals.hh"
#include "G4ParticleDefinition.hh"
#include "G4ProcessManager.hh"
#include "G4ProcessVector.hh"
#include "G4ParticleTypes.hh"
#include "G4ParticleTable.hh"
#include "G4BaryonConstructor.hh"
#include "G4ComptonScattering.hh"
#include "G4Decay.hh"
#include "G4FastSimulationManagerProcess.hh"
#include "G4GammaConversion.hh"
#include "G4IonConstructor.hh"
#include "G4LeptonConstructor.hh"
#include "G4Material.hh"
#include "G4MaterialTable.hh"
#include "G4ios.hh"
#include "G4SystemOfUnits.hh"
#include <iomanip>
#include "G4FastSimulationManagerProcess.hh"
#include "G4Decay.hh"
#include "G4LeptonConstructor.hh"
#include "G4MesonConstructor.hh"
#include "G4BaryonConstructor.hh"
#include "G4IonConstructor.hh"
#include "G4ComptonScattering.hh"
#include "G4GammaConversion.hh"
#include "G4PhotoElectricEffect.hh"
#include "G4eMultipleScattering.hh"
#include "G4MuMultipleScattering.hh"
#include "G4hMultipleScattering.hh"
#include "G4eIonisation.hh"
#include "G4eBremsstrahlung.hh"
#include "G4eplusAnnihilation.hh"
#include "G4MuIonisation.hh"
#include "G4MuBremsstrahlung.hh"
#include "G4MuIonisation.hh"
#include "G4MuMultipleScattering.hh"
#include "G4MuPairProduction.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleTypes.hh"
#include "G4PhotoElectricEffect.hh"
#include "G4ProcessManager.hh"
#include "G4ProcessVector.hh"
#include "G4SystemOfUnits.hh"
#include "G4eBremsstrahlung.hh"
#include "G4eIonisation.hh"
#include "G4eMultipleScattering.hh"
#include "G4eplusAnnihilation.hh"
#include "G4hIonisation.hh"
#include "G4hMultipleScattering.hh"
#include "G4ios.hh"
#include "globals.hh"
#include <iomanip>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02PhysicsList::Par02PhysicsList() : G4VUserPhysicsList() {
SetVerboseLevel( 1 );
defaultCutValue = 0.1*m;
Par02PhysicsList::Par02PhysicsList() : G4VUserPhysicsList()
{
SetVerboseLevel(1);
defaultCutValue = 0.1 * m;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -78,7 +75,8 @@ Par02PhysicsList::~Par02PhysicsList() = default;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02PhysicsList::ConstructParticle() {
void Par02PhysicsList::ConstructParticle()
{
// In this method, static member functions should be called for all particles
// which you want to use.
// This ensures that objects of these particle types will be created in the program.
@@ -91,7 +89,8 @@ void Par02PhysicsList::ConstructParticle() {
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02PhysicsList::ConstructBosons() {
void Par02PhysicsList::ConstructBosons()
{
G4Geantino::GeantinoDefinition();
G4ChargedGeantino::ChargedGeantinoDefinition();
G4Gamma::GammaDefinition();
@@ -100,35 +99,40 @@ void Par02PhysicsList::ConstructBosons() {
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02PhysicsList::ConstructLeptons() {
void Par02PhysicsList::ConstructLeptons()
{
G4LeptonConstructor pConstructor;
pConstructor.ConstructParticle();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02PhysicsList::ConstructMesons() {
void Par02PhysicsList::ConstructMesons()
{
G4MesonConstructor pConstructor;
pConstructor.ConstructParticle();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02PhysicsList::ConstructBaryons() {
G4BaryonConstructor pConstructor;
void Par02PhysicsList::ConstructBaryons()
{
G4BaryonConstructor pConstructor;
pConstructor.ConstructParticle();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02PhysicsList::ConstructIons() {
void Par02PhysicsList::ConstructIons()
{
G4IonConstructor pConstructor;
pConstructor.ConstructParticle();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02PhysicsList::ConstructProcess() {
void Par02PhysicsList::ConstructProcess()
{
AddTransportation();
AddParameterisation();
ConstructGeneral();
@@ -136,57 +140,59 @@ void Par02PhysicsList::ConstructProcess() {
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02PhysicsList::AddTransportation() {
//UseCoupledTransportation();
void Par02PhysicsList::AddTransportation()
{
// UseCoupledTransportation();
G4VUserPhysicsList::AddTransportation();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02PhysicsList::ConstructGeneral() {
auto theDecayProcess = new G4Decay();
auto particleIterator=GetParticleIterator();
void Par02PhysicsList::ConstructGeneral()
{
auto theDecayProcess = new G4Decay();
auto particleIterator = GetParticleIterator();
particleIterator->reset();
while ( (*particleIterator)() ) {
while ((*particleIterator)()) {
G4ParticleDefinition* particle = particleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
if ( theDecayProcess->IsApplicable( *particle ) ) {
pmanager->AddProcess( theDecayProcess );
if (theDecayProcess->IsApplicable(*particle)) {
pmanager->AddProcess(theDecayProcess);
// set ordering for PostStepDoIt and AtRestDoIt
pmanager->SetProcessOrdering( theDecayProcess, idxPostStep );
pmanager->SetProcessOrdering( theDecayProcess, idxAtRest );
pmanager->SetProcessOrdering(theDecayProcess, idxPostStep);
pmanager->SetProcessOrdering(theDecayProcess, idxAtRest);
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02PhysicsList::AddParameterisation() {
G4FastSimulationManagerProcess* fastSimProcess =
new G4FastSimulationManagerProcess( "G4FSMP" );
void Par02PhysicsList::AddParameterisation()
{
G4FastSimulationManagerProcess* fastSimProcess = new G4FastSimulationManagerProcess("G4FSMP");
// Registers the fastSimProcess with all the particles as a discrete and
// continuous process (this works in all cases; in the case that parallel
// geometries are not used, as in this example, it would be enough to
// add it as a discrete process).
auto particleIterator=GetParticleIterator();
auto particleIterator = GetParticleIterator();
particleIterator->reset();
while ( (*particleIterator)() ) {
while ((*particleIterator)()) {
G4ParticleDefinition* particle = particleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
//pmanager->AddDiscreteProcess( fastSimProcess ); // No parallel geometry
pmanager->AddProcess( fastSimProcess, -1, 0, 0 ); // General
// pmanager->AddDiscreteProcess( fastSimProcess ); // No parallel geometry
pmanager->AddProcess(fastSimProcess, -1, 0, 0); // General
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02PhysicsList::SetCuts() {
if ( verboseLevel > 1 ) {
void Par02PhysicsList::SetCuts()
{
if (verboseLevel > 1) {
G4cout << "Par02PhysicsList::SetCuts:";
}
SetCutsWithDefault();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -28,41 +28,45 @@
/// \brief Implementation of the Par02PrimaryGeneratorAction class
#include "Par02PrimaryGeneratorAction.hh"
#include "Par02PrimaryParticleInformation.hh"
#include "G4Event.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "Par02PrimaryParticleInformation.hh"
#include "globals.hh"
#include "G4SystemOfUnits.hh"
#include "globals.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02PrimaryGeneratorAction::Par02PrimaryGeneratorAction() {
Par02PrimaryGeneratorAction::Par02PrimaryGeneratorAction()
{
G4int n_particle = 1;
fParticleGun = new G4ParticleGun( n_particle );
fParticleGun = new G4ParticleGun(n_particle);
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4String particleName;
G4ParticleDefinition* particle =
particleTable->FindParticle( particleName = "geantino" );
fParticleGun->SetParticleDefinition( particle );
G4ParticleDefinition* particle = particleTable->FindParticle(particleName = "geantino");
fParticleGun->SetParticleDefinition(particle);
fParticleGun->SetParticleMomentumDirection( G4ThreeVector( 0.0, 1.0, 0.0 ) );
fParticleGun->SetParticleEnergy( 100.0*GeV );
fParticleGun->SetParticlePosition( G4ThreeVector( 0.0, 0.0, 0.0 ) );
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.0, 1.0, 0.0));
fParticleGun->SetParticleEnergy(100.0 * GeV);
fParticleGun->SetParticlePosition(G4ThreeVector(0.0, 0.0, 0.0));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02PrimaryGeneratorAction::~Par02PrimaryGeneratorAction() {
Par02PrimaryGeneratorAction::~Par02PrimaryGeneratorAction()
{
delete fParticleGun;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02PrimaryGeneratorAction::GeneratePrimaries( G4Event* anEvent ) {
fParticleGun->GeneratePrimaryVertex( anEvent );
void Par02PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
fParticleGun->GeneratePrimaryVertex(anEvent);
// Loop over the vertices, and then over primary particles,
// and for each primary particle create an info object, in
@@ -71,26 +75,23 @@ void Par02PrimaryGeneratorAction::GeneratePrimaries( G4Event* anEvent ) {
// of a trivial particle gun generator, but it is useful in the more
// realistic case of a Monte Carlo event generator like Pythia8.
G4int count_particles = 0;
for ( G4int ivtx = 0; ivtx < anEvent->GetNumberOfPrimaryVertex(); ivtx++ ) {
for ( G4int ipp = 0; ipp < anEvent->GetPrimaryVertex( ivtx )->GetNumberOfParticle();
ipp++ ) {
G4PrimaryParticle* primary_particle =
anEvent->GetPrimaryVertex( ivtx )->GetPrimary( ipp );
if ( primary_particle ) {
primary_particle->SetUserInformation( new Par02PrimaryParticleInformation(
count_particles, primary_particle->GetPDGcode(),
primary_particle->GetMomentum() ) );
count_particles++;
for (G4int ivtx = 0; ivtx < anEvent->GetNumberOfPrimaryVertex(); ivtx++) {
for (G4int ipp = 0; ipp < anEvent->GetPrimaryVertex(ivtx)->GetNumberOfParticle(); ipp++) {
G4PrimaryParticle* primary_particle = anEvent->GetPrimaryVertex(ivtx)->GetPrimary(ipp);
if (primary_particle) {
primary_particle->SetUserInformation(new Par02PrimaryParticleInformation(
count_particles, primary_particle->GetPDGcode(), primary_particle->GetMomentum()));
count_particles++;
}
}
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ParticleGun* Par02PrimaryGeneratorAction::GetParticleGun() {
G4ParticleGun* Par02PrimaryGeneratorAction::GetParticleGun()
{
return fParticleGun;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -31,12 +31,23 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02PrimaryParticleInformation::Par02PrimaryParticleInformation(
G4int aPartID, G4int aPDG, G4ThreeVector aMomentum ) :
fPartID( aPartID ), fPDG( aPDG ), fMomentumMC( aMomentum ),
fMomentumTracker( 0 ), fResolutionTracker( 0 ), fEfficiencyTracker( 0 ),
fPositionEMCal( 0 ), fEnergyEMCal( 0 ), fResolutionEMCal( 0 ), fEfficiencyEMCal( 0 ),
fPositionHCal( 0 ), fEnergyHCal( 0 ), fResolutionHCal( 0 ), fEfficiencyHCal( 0 ) {}
Par02PrimaryParticleInformation::Par02PrimaryParticleInformation(G4int aPartID, G4int aPDG,
G4ThreeVector aMomentum)
: fPartID(aPartID),
fPDG(aPDG),
fMomentumMC(aMomentum),
fMomentumTracker(0),
fResolutionTracker(0),
fEfficiencyTracker(0),
fPositionEMCal(0),
fEnergyEMCal(0),
fResolutionEMCal(0),
fEfficiencyEMCal(0),
fPositionHCal(0),
fEnergyHCal(0),
fResolutionHCal(0),
fEfficiencyHCal(0)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -44,20 +55,18 @@ Par02PrimaryParticleInformation::~Par02PrimaryParticleInformation() = default;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02PrimaryParticleInformation::Print() const {
void Par02PrimaryParticleInformation::Print() const
{
G4cout << "Par02PrimaryParticleInformation: PDG code " << fPDG << G4endl
<< "Particle unique ID: " << fPartID << G4endl
<< "MC momentum: " << fMomentumMC << G4endl
<< "Particle unique ID: " << fPartID << G4endl << "MC momentum: " << fMomentumMC << G4endl
<< "Tracker momentum: " << fMomentumTracker << G4endl
<< "Tracker resolution: " << fResolutionTracker << G4endl
<< "Tracker efficiency: " << fEfficiencyTracker << G4endl
<< "EMCal energy: " << fEnergyEMCal << " at " << fPositionEMCal << G4endl
<< "EMCal resolution: " << fResolutionEMCal << G4endl
<< "EMCal efficiency: " << fEfficiencyEMCal << G4endl
<< "HCal energy: " << fEnergyHCal << " at "<< fPositionHCal << G4endl
<< "HCal resolution: " << fResolutionHCal << G4endl
<< "EMCal efficiency: " << fEfficiencyEMCal << G4endl << "HCal energy: " << fEnergyHCal
<< " at " << fPositionHCal << G4endl << "HCal resolution: " << fResolutionHCal << G4endl
<< "HCal efficiency: " << fEfficiencyHCal << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -27,41 +27,45 @@
/// \file Par02RunAction.cc
/// \brief Implementation of the Par02RunAction class
#include "Par02Output.hh"
#include "Par02RunAction.hh"
#include "Par02Output.hh"
#include "G4Run.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "G4UnitsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02RunAction::Par02RunAction( const G4String aOutName ) :
G4UserRunAction() {
Par02Output::Instance()->SetFileName( aOutName );
Par02RunAction::Par02RunAction(const G4String aOutName) : G4UserRunAction()
{
Par02Output::Instance()->SetFileName(aOutName);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02RunAction::~Par02RunAction() {
#ifdef G4MULTITHREADED
if ( isMaster ) delete Par02Output::Instance();
#else
Par02RunAction::~Par02RunAction()
{
#ifdef G4MULTITHREADED
if (isMaster) delete Par02Output::Instance();
#else
delete Par02Output::Instance();
#endif
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02RunAction::BeginOfRunAction( const G4Run* aRun ) {
Par02Output::Instance()->StartAnalysis( aRun->GetRunID() );
void Par02RunAction::BeginOfRunAction(const G4Run* aRun)
{
Par02Output::Instance()->StartAnalysis(aRun->GetRunID());
Par02Output::Instance()->CreateHistograms();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02RunAction::EndOfRunAction( const G4Run* /*aRun*/ ) {
void Par02RunAction::EndOfRunAction(const G4Run* /*aRun*/)
{
Par02Output::Instance()->EndAnalysis();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -28,13 +28,16 @@
/// \brief Implementation of the Par02Smearer class
#include "Par02Smearer.hh"
#include "Par02PrimaryParticleInformation.hh"
#include "G4FieldManager.hh"
#include "G4PrimaryParticle.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "G4TransportationManager.hh"
#include "G4FieldManager.hh"
#include "G4UniformMagField.hh"
#include "G4UnitsTable.hh"
#include <ctime>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -43,10 +46,11 @@ Par02Smearer* Par02Smearer::fPar02Smearer = nullptr;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02Smearer::Par02Smearer() {
time_t seed = time( NULL );
fRandomEngine = new CLHEP::HepJamesRandom( static_cast< long >( seed ) );
fRandomGauss = new CLHEP::RandGauss( fRandomEngine );
Par02Smearer::Par02Smearer()
{
time_t seed = time(NULL);
fRandomEngine = new CLHEP::HepJamesRandom(static_cast<long>(seed));
fRandomGauss = new CLHEP::RandGauss(fRandomEngine);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -55,8 +59,9 @@ Par02Smearer::~Par02Smearer() = default;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par02Smearer* Par02Smearer::Instance() {
if ( ! fPar02Smearer ) {
Par02Smearer* Par02Smearer::Instance()
{
if (!fPar02Smearer) {
fPar02Smearer = new Par02Smearer();
}
return fPar02Smearer;
@@ -64,22 +69,23 @@ Par02Smearer* Par02Smearer::Instance() {
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ThreeVector Par02Smearer::SmearMomentum( const G4Track* aTrackOriginal,
G4double aResolution ) {
return SmearGaussian( aTrackOriginal, aResolution );
G4ThreeVector Par02Smearer::SmearMomentum(const G4Track* aTrackOriginal, G4double aResolution)
{
return SmearGaussian(aTrackOriginal, aResolution);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double Par02Smearer::SmearEnergy( const G4Track* aTrackOriginal,
G4double aResolution ) {
G4double Par02Smearer::SmearEnergy(const G4Track* aTrackOriginal, G4double aResolution)
{
G4double newE = -1.0;
while ( newE < 0.0 ) { // To ensure that the resulting value is not negative
// (vital for energy smearing, does not change direction
// for momentum smearing)
if ( aResolution != -1.0 ) {
newE = aTrackOriginal->GetKineticEnergy() * Gauss( 1.0, aResolution );
} else {
while (newE < 0.0) { // To ensure that the resulting value is not negative
// (vital for energy smearing, does not change direction
// for momentum smearing)
if (aResolution != -1.0) {
newE = aTrackOriginal->GetKineticEnergy() * Gauss(1.0, aResolution);
}
else {
newE = aTrackOriginal->GetKineticEnergy();
}
}
@@ -88,20 +94,20 @@ G4double Par02Smearer::SmearEnergy( const G4Track* aTrackOriginal,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ThreeVector Par02Smearer::SmearGaussian( const G4Track* aTrackOriginal,
G4double aResolution ) {
G4ThreeVector Par02Smearer::SmearGaussian(const G4Track* aTrackOriginal, G4double aResolution)
{
G4ThreeVector originP = aTrackOriginal->GetMomentum();
G4ThreeVector originPos = aTrackOriginal->GetPosition();
G4double rdm = Gauss( 1.0, aResolution );
G4ThreeVector smearedMom( originP.x()*rdm, originP.y()*rdm, originP.z()*rdm );
G4double rdm = Gauss(1.0, aResolution);
G4ThreeVector smearedMom(originP.x() * rdm, originP.y() * rdm, originP.z() * rdm);
return smearedMom;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double Par02Smearer::Gauss( G4double aMean, G4double aStandardDeviation ) {
return fRandomGauss->fire( aMean, aStandardDeviation );
G4double Par02Smearer::Gauss(G4double aMean, G4double aStandardDeviation)
{
return fRandomGauss->fire(aMean, aStandardDeviation);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -28,17 +28,18 @@
/// \brief Implementation of the Par02TrackingAction class
#include "Par02TrackingAction.hh"
#include "Par02EventInformation.hh"
#include "Par02PrimaryParticleInformation.hh"
#include "Par02Output.hh"
#include "G4ThreeVector.hh"
#include "Par02EventInformation.hh"
#include "Par02Output.hh"
#include "Par02PrimaryParticleInformation.hh"
#include "G4EventManager.hh"
#include "G4RunManager.hh"
#include "Randomize.hh"
#include "G4SystemOfUnits.hh"
#include "G4ThreeVector.hh"
#include "G4TrackingManager.hh"
#include "Randomize.hh"
#include <iomanip>
#include <vector>
@@ -52,48 +53,38 @@ Par02TrackingAction::~Par02TrackingAction() = default;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02TrackingAction::PreUserTrackingAction( const G4Track* aTrack ) {
void Par02TrackingAction::PreUserTrackingAction(const G4Track* aTrack)
{
// Kill the tracks that have a small transverse momentum or that are not
// in the central region.
if ( aTrack->GetMomentum().perp() < 1.0*MeV ||
std::abs( aTrack->GetMomentum().pseudoRapidity() ) > 5.5 ) {
( (G4Track*) aTrack )->SetTrackStatus( fStopAndKill );
if (aTrack->GetMomentum().perp() < 1.0 * MeV
|| std::abs(aTrack->GetMomentum().pseudoRapidity()) > 5.5)
{
((G4Track*)aTrack)->SetTrackStatus(fStopAndKill);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par02TrackingAction::PostUserTrackingAction( const G4Track* aTrack ) {
if ( aTrack->GetTrackStatus() == fStopAndKill && aTrack->GetParentID() == 0 ) {
auto info = (Par02PrimaryParticleInformation*)
aTrack->GetDynamicParticle()->GetPrimaryParticle()->GetUserInformation();
//info->Print();
Par02Output::Instance()->SaveTrack( Par02Output::eSaveMC,
info->GetPartID(),
info->GetPDG(),
info->GetMCMomentum()/MeV );
Par02Output::Instance()->SaveTrack( Par02Output::eSaveTracker,
info->GetPartID(),
info->GetPDG(),
info->GetTrackerMomentum()/MeV,
info->GetTrackerResolution(),
info->GetTrackerEfficiency() );
Par02Output::Instance()->SaveTrack( Par02Output::eSaveEMCal,
info->GetPartID(),
info->GetPDG(),
info->GetEMCalPosition()/mm,
info->GetEMCalResolution(),
info->GetEMCalEfficiency(),
info->GetEMCalEnergy()/MeV );
Par02Output::Instance()->SaveTrack( Par02Output::eSaveHCal,
info->GetPartID(),
info->GetPDG(),
info->GetHCalPosition()/mm,
info->GetHCalResolution(),
info->GetHCalEfficiency(),
info->GetHCalEnergy()/MeV );
void Par02TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
{
if (aTrack->GetTrackStatus() == fStopAndKill && aTrack->GetParentID() == 0) {
auto info = (Par02PrimaryParticleInformation*)aTrack->GetDynamicParticle()
->GetPrimaryParticle()
->GetUserInformation();
// info->Print();
Par02Output::Instance()->SaveTrack(Par02Output::eSaveMC, info->GetPartID(), info->GetPDG(),
info->GetMCMomentum() / MeV);
Par02Output::Instance()->SaveTrack(Par02Output::eSaveTracker, info->GetPartID(), info->GetPDG(),
info->GetTrackerMomentum() / MeV,
info->GetTrackerResolution(), info->GetTrackerEfficiency());
Par02Output::Instance()->SaveTrack(Par02Output::eSaveEMCal, info->GetPartID(), info->GetPDG(),
info->GetEMCalPosition() / mm, info->GetEMCalResolution(),
info->GetEMCalEfficiency(), info->GetEMCalEnergy() / MeV);
Par02Output::Instance()->SaveTrack(Par02Output::eSaveHCal, info->GetPartID(), info->GetPDG(),
info->GetHCalPosition() / mm, info->GetHCalResolution(),
info->GetHCalEfficiency(), info->GetHCalEnergy() / MeV);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -11,7 +11,7 @@ Environment variable "G4FORCE_RUN_MANAGER_TYPE" enabled with value == Serial. Fo
**************************************************************
Geant4 version Name: geant4-11-02-patch-02 (21-June-2024)
Geant4 version Name: geant4-11-02-ref-06 (28-June-2024)
Copyright : Geant4 Collaboration
References : NIM A 506 (2003), 250-303
: IEEE-TNS 53 (2006), 270-278
@@ -45,14 +45,21 @@ Registered graphics systems are:
RayTracerX (RayTracerX)
Qt3D (Qt3D)
TOOLSSG_X11_GLES (TSG_X11_GLES, TSGX11, TSG_XT_GLES_FALLBACK)
TOOLSSG_X11_ZB (TSG_X11_ZB, TSGX11ZB)
TOOLSSG_XT_GLES (TSG_XT_GLES, TSGXt, TSG_QT_GLES_FALLBACK)
TOOLSSG_XT_ZB (TSG_XT_ZB, TSGXtZB)
TOOLSSG_QT_GLES (TSG_QT_GLES, TSGQt, TSG)
TOOLSSG_QT_ZB (TSG_QT_ZB, TSGQtZB)
Default graphics system is: TSG_OFFSCREEN (based on batch session).
Default window size hint is: 600x600-0+0 (based on G4VisManager initialisation).
Note: Parameters specified on the command line will override these defaults.
Use "vis/open" without parameters to get these defaults.
You may choose a graphics system (driver) with a parameter of
the command "/vis/open" or "/vis/sceneHandler/create",
or you may omit the driver parameter and choose at run time:
- by argument in the construction of G4VisExecutive
- by environment variable "G4VIS_DEFAULT_DRIVER"
- by entry in "~/.g4session"
- by build flags.
- Note: This feature is not allowed in batch mode.
For further information see "examples/basic/B1/exampleB1.cc"
and "vis.mac".
Registering model factories...
@@ -379,7 +386,7 @@ Min energy per nucleon for multifragmentation 200 GeV
Limit excitation energy for Fermi BreakUp 20 MeV
Level density (1/MeV) 0.075
Use simple level density model 1
Use discrete excitation energy of the residual 1
Use discrete excitation energy of the residual 0
Time limit for long lived isomeres 1 ns
Isomer production flag 1
Internal e- conversion flag 1
@@ -36,18 +36,19 @@
//
//-------------------------------------------------------------------
#include "Par03DetectorConstruction.hh"
#include "Par03ActionInitialisation.hh"
#include "G4RunManagerFactory.hh"
#include "G4Types.hh"
#include "G4UImanager.hh"
#include "FTFP_BERT.hh"
#include "G4HadronicProcessStore.hh"
#include "Par03ActionInitialisation.hh"
#include "Par03DetectorConstruction.hh"
#include "G4EmParameters.hh"
#include "G4FastSimulationPhysics.hh"
#include "G4VisExecutive.hh"
#include "G4HadronicProcessStore.hh"
#include "G4RunManagerFactory.hh"
#include "G4Types.hh"
#include "G4UIExecutive.hh"
#include "G4UImanager.hh"
#include "G4VisExecutive.hh"
#include <sstream>
int main(int argc, char** argv)
@@ -60,32 +61,27 @@ int main(int argc, char** argv)
" [option(s)] \n No additional arguments triggers an interactive mode "
"executing vis.mac macro. \n Options:\n\t-h\t\tdisplay this help "
"message\n\t-m MACRO\ttriggers a batch mode executing MACRO\n");
for(G4int i = 1; i < argc; ++i)
{
for (G4int i = 1; i < argc; ++i) {
G4String argument(argv[i]);
if(argument == "-h" || argument == "--help")
{
if (argument == "-h" || argument == "--help") {
G4cout << helpMsg << G4endl;
return 0;
}
else if(argument == "-m")
{
batchMacroName = G4String(argv[i + 1]);
else if (argument == "-m") {
batchMacroName = G4String(argv[i + 1]);
useInteractiveMode = false;
++i;
}
else
{
G4Exception("main", "Unknown argument", FatalErrorInArgument,
("Unknown argument passed to " + G4String(argv[0]) + " : " +
argument + "\n" + helpMsg)
.c_str());
else {
G4Exception(
"main", "Unknown argument", FatalErrorInArgument,
("Unknown argument passed to " + G4String(argv[0]) + " : " + argument + "\n" + helpMsg)
.c_str());
}
}
// Initialization of default Run manager
auto* runManager =
G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
auto* runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
// Detector geometry:
auto detector = new Par03DetectorConstruction();
@@ -118,15 +114,13 @@ int main(int argc, char** argv)
visManager->Initialize();
G4UImanager* UImanager = G4UImanager::GetUIpointer();
if(useInteractiveMode)
{
auto ui = new G4UIExecutive(argc, argv);
if (useInteractiveMode) {
auto ui = new G4UIExecutive(argc, argv);
UImanager->ApplyCommand("/control/execute vis.mac");
ui->SessionStart();
delete ui;
}
else
{
else {
G4String command = "/control/execute ";
UImanager->ApplyCommand(command + batchMacroName);
}
@@ -40,18 +40,18 @@ class Par03DetectorConstruction;
class Par03ActionInitialisation : public G4VUserActionInitialization
{
public:
Par03ActionInitialisation(Par03DetectorConstruction* aDetector);
~Par03ActionInitialisation();
/// Create all user actions.
virtual void Build() const final;
/// Create run action in the master thread to allow analysis merging.
virtual void BuildForMaster() const final;
public:
Par03ActionInitialisation(Par03DetectorConstruction* aDetector);
~Par03ActionInitialisation();
/// Create all user actions.
virtual void Build() const final;
/// Create run action in the master thread to allow analysis merging.
virtual void BuildForMaster() const final;
private:
/// Pointer to detector to be passed to event and run actions in order to
/// retrieve detector dimensions
Par03DetectorConstruction* fDetector;
private:
/// Pointer to detector to be passed to event and run actions in order to
/// retrieve detector dimensions
Par03DetectorConstruction* fDetector;
};
#endif /* PAR03ACTIONINITIALISATION_HH */
@@ -26,9 +26,9 @@
#ifndef PAR03DETECTORCONSTRUCTION_H
#define PAR03DETECTORCONSTRUCTION_H
#include "G4VUserDetectorConstruction.hh"
#include "G4SystemOfUnits.hh"
#include "G4Material.hh"
#include "G4SystemOfUnits.hh"
#include "G4VUserDetectorConstruction.hh"
class Par03DetectorMessenger;
class G4LogicalVolume;
@@ -51,61 +51,61 @@ class G4LogicalVolume;
class Par03DetectorConstruction : public G4VUserDetectorConstruction
{
public:
Par03DetectorConstruction();
virtual ~Par03DetectorConstruction();
public:
Par03DetectorConstruction();
virtual ~Par03DetectorConstruction();
virtual G4VPhysicalVolume* Construct() final;
virtual void ConstructSDandField() final;
virtual G4VPhysicalVolume* Construct() final;
virtual void ConstructSDandField() final;
// Set radius of the cylindrical detector
void SetRadius(G4double aRadius);
// Get radius of the cylindrical detector
inline G4double GetRadius() const { return fDetectorRadius; };
// Set length of the cylindrical detector (along z-axis)
void SetLength(G4double aLength);
// Get length of the cylindrical detector (along z-axis)
inline G4double GetLength() const { return fDetectorLength; };
// Set material of the detector (from NIST materials)
void SetMaterial(const G4String& aMaterial);
// Get name of the material of the detector
inline G4String GetMaterial() const { return fDetectorMaterial->GetName(); };
// Set radius of the cylindrical detector
void SetRadius(G4double aRadius);
// Get radius of the cylindrical detector
inline G4double GetRadius() const { return fDetectorRadius; };
// Set length of the cylindrical detector (along z-axis)
void SetLength(G4double aLength);
// Get length of the cylindrical detector (along z-axis)
inline G4double GetLength() const { return fDetectorLength; };
// Set material of the detector (from NIST materials)
void SetMaterial(const G4String& aMaterial);
// Get name of the material of the detector
inline G4String GetMaterial() const { return fDetectorMaterial->GetName(); };
// Set number of readout cells along z-axis
inline void SetNbOfLayers(G4int aNumber) { fNbOfLayers = aNumber; };
// Get number of readout cells along z-axis
inline G4int GetNbOfLayers() const { return fNbOfLayers; };
// Set number of readout cells along radius of cylinder
inline void SetNbOfRhoCells(G4int aNumber) { fNbOfRhoCells = aNumber; };
// Get number of readout cells along radius of cylinder
inline G4int GetNbOfRhoCells() const { return fNbOfRhoCells; };
// Set number of readout cells in azimuthal angle
inline void SetNbOfPhiCells(G4int aNumber) { fNbOfPhiCells = aNumber; };
// Get number of readout cells in azimuthal angle
inline G4int GetNbOfPhiCells() const { return fNbOfPhiCells; };
// Set number of readout cells along z-axis
inline void SetNbOfLayers(G4int aNumber) { fNbOfLayers = aNumber; };
// Get number of readout cells along z-axis
inline G4int GetNbOfLayers() const { return fNbOfLayers; };
// Set number of readout cells along radius of cylinder
inline void SetNbOfRhoCells(G4int aNumber) { fNbOfRhoCells = aNumber; };
// Get number of readout cells along radius of cylinder
inline G4int GetNbOfRhoCells() const { return fNbOfRhoCells; };
// Set number of readout cells in azimuthal angle
inline void SetNbOfPhiCells(G4int aNumber) { fNbOfPhiCells = aNumber; };
// Get number of readout cells in azimuthal angle
inline G4int GetNbOfPhiCells() const { return fNbOfPhiCells; };
// Print detector information
void Print() const;
// Print detector information
void Print() const;
private:
/// Messenger that allows to modify geometry
Par03DetectorMessenger* fDetectorMessenger;
/// Logical volume of replicated cell
G4LogicalVolume* fLogicCell = nullptr;
/// World size (in each X, Y, Z dimension)
G4double fWorldSize = 10 * m;
/// Radius of the cylindrical detector
G4double fDetectorRadius = 10 * cm;
/// Length of the cylindrical detector (along z axis)
G4double fDetectorLength = 30 * cm;
/// Material of the detector
G4Material* fDetectorMaterial = nullptr;
/// Number of layers = slices along z axis
G4int fNbOfLayers = 10;
/// Number of cells along radius
G4int fNbOfRhoCells = 10;
/// Number of cells in azimuthal angle
G4int fNbOfPhiCells = 10;
private:
/// Messenger that allows to modify geometry
Par03DetectorMessenger* fDetectorMessenger;
/// Logical volume of replicated cell
G4LogicalVolume* fLogicCell = nullptr;
/// World size (in each X, Y, Z dimension)
G4double fWorldSize = 10 * m;
/// Radius of the cylindrical detector
G4double fDetectorRadius = 10 * cm;
/// Length of the cylindrical detector (along z axis)
G4double fDetectorLength = 30 * cm;
/// Material of the detector
G4Material* fDetectorMaterial = nullptr;
/// Number of layers = slices along z axis
G4int fNbOfLayers = 10;
/// Number of cells along radius
G4int fNbOfRhoCells = 10;
/// Number of cells in azimuthal angle
G4int fNbOfPhiCells = 10;
};
#endif /* PAR03DETECTORCONSTRUCTION_H */
@@ -47,37 +47,37 @@ class G4UIcmdWithAString;
class Par03DetectorMessenger : public G4UImessenger
{
public:
Par03DetectorMessenger(Par03DetectorConstruction*);
~Par03DetectorMessenger();
public:
Par03DetectorMessenger(Par03DetectorConstruction*);
~Par03DetectorMessenger();
/// Invokes appropriate methods based on the typed command
virtual void SetNewValue(G4UIcommand*, G4String) final;
/// Retrieves the current settings
virtual G4String GetCurrentValue(G4UIcommand*) final;
/// Invokes appropriate methods based on the typed command
virtual void SetNewValue(G4UIcommand*, G4String) final;
/// Retrieves the current settings
virtual G4String GetCurrentValue(G4UIcommand*) final;
private:
/// Detector construction to setup
Par03DetectorConstruction* fDetector = nullptr;
/// Command to set the directory common to all messengers in this example
/// /Par03
G4UIdirectory* fExampleDir = nullptr;
/// Command to set the directory for detector settings /Par03/detector
G4UIdirectory* fDetectorDir = nullptr;
/// Command printing current settings
G4UIcmdWithoutParameter* fPrintCmd;
/// Command to set the detector radius
G4UIcmdWithADoubleAndUnit* fDetectorRadiusCmd = nullptr;
/// Command to set the detector length
G4UIcmdWithADoubleAndUnit* fDetectorLengthCmd = nullptr;
/// Command to set the detector material
G4UIcmdWithAString* fDetectorMaterialCmd = nullptr;
/// Command to set the number of layers
G4UIcmdWithAnInteger* fNbLayersCmd = nullptr;
/// Command to set the number of radial cells
G4UIcmdWithAnInteger* fNbRhoCellsCmd = nullptr;
/// Command to set the number of cells in azimuthal angle
G4UIcmdWithAnInteger* fNbPhiCellsCmd = nullptr;
private:
/// Detector construction to setup
Par03DetectorConstruction* fDetector = nullptr;
/// Command to set the directory common to all messengers in this example
/// /Par03
G4UIdirectory* fExampleDir = nullptr;
/// Command to set the directory for detector settings /Par03/detector
G4UIdirectory* fDetectorDir = nullptr;
/// Command printing current settings
G4UIcmdWithoutParameter* fPrintCmd;
/// Command to set the detector radius
G4UIcmdWithADoubleAndUnit* fDetectorRadiusCmd = nullptr;
/// Command to set the detector length
G4UIcmdWithADoubleAndUnit* fDetectorLengthCmd = nullptr;
/// Command to set the detector material
G4UIcmdWithAString* fDetectorMaterialCmd = nullptr;
/// Command to set the number of layers
G4UIcmdWithAnInteger* fNbLayersCmd = nullptr;
/// Command to set the number of radial cells
G4UIcmdWithAnInteger* fNbRhoCellsCmd = nullptr;
/// Command to set the number of cells in azimuthal angle
G4UIcmdWithAnInteger* fNbPhiCellsCmd = nullptr;
};
#endif
@@ -47,37 +47,37 @@ class G4UIcmdWithAnInteger;
class Par03EMShowerMessenger : public G4UImessenger
{
public:
Par03EMShowerMessenger(Par03EMShowerModel* aModel);
~Par03EMShowerMessenger();
public:
Par03EMShowerMessenger(Par03EMShowerModel* aModel);
~Par03EMShowerMessenger();
public:
/// Invokes appropriate methods based on the typed command
virtual void SetNewValue(G4UIcommand* aCommand, G4String aNewValues) final;
/// Retrieves the current settings
virtual G4String GetCurrentValue(G4UIcommand* aCommand) final;
public:
/// Invokes appropriate methods based on the typed command
virtual void SetNewValue(G4UIcommand* aCommand, G4String aNewValues) final;
/// Retrieves the current settings
virtual G4String GetCurrentValue(G4UIcommand* aCommand) final;
private:
/// Model to setup
Par03EMShowerModel* fModel;
/// Command to set the up a directory for model settings /Par03/fastSim
G4UIdirectory* fDirectory;
/// Command printing current settings
G4UIcmdWithoutParameter* fPrintCmd;
/// Command to set the sigma parameter of the Gaussian distribution describing
/// the transverse profile
G4UIcmdWithADoubleAndUnit* fSigmaCmd;
/// Command to set the alpha parameter of the Gamma distribution describing
/// the longitudinal profile
G4UIcmdWithADouble* fAlphaCmd;
/// Command to set the beta parameter of the Gamma distribution describing the
/// longitudinal profile
G4UIcmdWithADouble* fBetaCmd;
/// Command to set the number of (same energy) deposits to be created by
/// fast simulation
G4UIcmdWithAnInteger* fNbOfHitsCmd;
/// Command to set the maximum shower depth
G4UIcmdWithADouble* fLongMaxDepthCmd;
private:
/// Model to setup
Par03EMShowerModel* fModel;
/// Command to set the up a directory for model settings /Par03/fastSim
G4UIdirectory* fDirectory;
/// Command printing current settings
G4UIcmdWithoutParameter* fPrintCmd;
/// Command to set the sigma parameter of the Gaussian distribution describing
/// the transverse profile
G4UIcmdWithADoubleAndUnit* fSigmaCmd;
/// Command to set the alpha parameter of the Gamma distribution describing
/// the longitudinal profile
G4UIcmdWithADouble* fAlphaCmd;
/// Command to set the beta parameter of the Gamma distribution describing the
/// longitudinal profile
G4UIcmdWithADouble* fBetaCmd;
/// Command to set the number of (same energy) deposits to be created by
/// fast simulation
G4UIcmdWithAnInteger* fNbOfHitsCmd;
/// Command to set the maximum shower depth
G4UIcmdWithADouble* fLongMaxDepthCmd;
};
#endif /* PAR03EMSHOWERMESSENGER_HH */
@@ -69,99 +69,96 @@ class G4FastSimHitMaker;
class Par03EMShowerModel : public G4VFastSimulationModel
{
public:
Par03EMShowerModel(G4String, G4Region*);
Par03EMShowerModel(G4String);
~Par03EMShowerModel();
public:
Par03EMShowerModel(G4String, G4Region*);
Par03EMShowerModel(G4String);
~Par03EMShowerModel();
/// There are no kinematics constraints. True is returned.
virtual G4bool ModelTrigger(const G4FastTrack&) final;
/// Model is applicable to electrons, positrons, and photons.
virtual G4bool IsApplicable(const G4ParticleDefinition&) final;
/// Take particle out of the full simulation (kill it at the entrance
/// depositing all the energy). Calculate energy deposited in the detector
/// according to Gamma distribution (along the particle direction) and
/// Gaussian distribution in the transverse direction. Mean of the Gaussian is
/// centred on the shower axis. Create energy deposits on a cylindrical mesh.
/// Parameters of the mesh (size, number of cells) and of the distributions
/// (alpha, beta for Gamma, sigma for Gaussian) can be set with UI commands.
virtual void DoIt(const G4FastTrack&, G4FastStep&) final;
/// There are no kinematics constraints. True is returned.
virtual G4bool ModelTrigger(const G4FastTrack&) final;
/// Model is applicable to electrons, positrons, and photons.
virtual G4bool IsApplicable(const G4ParticleDefinition&) final;
/// Take particle out of the full simulation (kill it at the entrance
/// depositing all the energy). Calculate energy deposited in the detector
/// according to Gamma distribution (along the particle direction) and
/// Gaussian distribution in the transverse direction. Mean of the Gaussian is
/// centred on the shower axis. Create energy deposits on a cylindrical mesh.
/// Parameters of the mesh (size, number of cells) and of the distributions
/// (alpha, beta for Gamma, sigma for Gaussian) can be set with UI commands.
virtual void DoIt(const G4FastTrack&, G4FastStep&) final;
/// Print current settings.
void Print() const;
/// Set standard deviation of a Gaussian distribution that describes the
/// transverse shower profile.
inline void SetSigma(const G4double aSigma) { fSigma = aSigma; };
/// Get standard deviation of a Gaussian distribution that describes the
/// transverse shower profile.
inline G4double GetSigma() const { return fSigma; };
/// Set alpha parameter of a Gamma distribution that describes the
/// longitudinal shower profile.
inline void SetAlpha(const G4double aAlpha) { fAlpha = aAlpha; };
/// Get alpha parameter of a Gamma distribution that describes the
/// longitudinal shower profile.
inline G4double GetAlpha() const { return fAlpha; };
/// Set beta parameter of a Gamma distribution that describes the longitudinal
/// shower profile.
inline void SetBeta(const G4double aBeta) { fBeta = aBeta; };
/// Get beta parameter of a Gamma distribution that describes the longitudinal
/// shower profile.
inline G4double GetBeta() const { return fBeta; };
/// Set number of (same energy) hits created in the parametrisation.
inline void SetNbOfHits(const G4int aNumber) { fNbOfHits = aNumber; };
/// Get number of (same energy) hits created in the parametrisation.s
inline G4int GetNbOfHits() const { return fNbOfHits; };
/// Set maximum depth of shower created in fast simulation. It is expressed in
/// units of radiaton length.
inline void SetLongMaxDepth(const G4double aDepth)
{
fLongMaxDepth = aDepth;
};
/// Get maximum depth of shower created in fast simulation. It is expressed in
/// units of radiaton length.
inline G4double GetLongMaxDepth() const { return fLongMaxDepth; };
/// Print current settings.
void Print() const;
/// Set standard deviation of a Gaussian distribution that describes the
/// transverse shower profile.
inline void SetSigma(const G4double aSigma) { fSigma = aSigma; };
/// Get standard deviation of a Gaussian distribution that describes the
/// transverse shower profile.
inline G4double GetSigma() const { return fSigma; };
/// Set alpha parameter of a Gamma distribution that describes the
/// longitudinal shower profile.
inline void SetAlpha(const G4double aAlpha) { fAlpha = aAlpha; };
/// Get alpha parameter of a Gamma distribution that describes the
/// longitudinal shower profile.
inline G4double GetAlpha() const { return fAlpha; };
/// Set beta parameter of a Gamma distribution that describes the longitudinal
/// shower profile.
inline void SetBeta(const G4double aBeta) { fBeta = aBeta; };
/// Get beta parameter of a Gamma distribution that describes the longitudinal
/// shower profile.
inline G4double GetBeta() const { return fBeta; };
/// Set number of (same energy) hits created in the parametrisation.
inline void SetNbOfHits(const G4int aNumber) { fNbOfHits = aNumber; };
/// Get number of (same energy) hits created in the parametrisation.s
inline G4int GetNbOfHits() const { return fNbOfHits; };
/// Set maximum depth of shower created in fast simulation. It is expressed in
/// units of radiaton length.
inline void SetLongMaxDepth(const G4double aDepth) { fLongMaxDepth = aDepth; };
/// Get maximum depth of shower created in fast simulation. It is expressed in
/// units of radiaton length.
inline G4double GetLongMaxDepth() const { return fLongMaxDepth; };
private:
/// Gamma distribution
inline G4double Gamma(G4double x, G4double alpha, G4double beta)
{
return (std::pow(beta, alpha) / std::tgamma(alpha) * std::pow(x, alpha - 1) *
std::exp(-beta * x));
}
/// Gaussian distribution
inline G4double Gaussian(G4double x, G4double sigma = 1, G4double x0 = 0)
{
G4double tmp = (x - x0) / sigma;
return (1.0 / (std::sqrt(2 * CLHEP::pi) * sigma)) * std::exp(-tmp * tmp / 2);
}
private:
/// Gamma distribution
inline G4double Gamma(G4double x, G4double alpha, G4double beta)
{
return (std::pow(beta, alpha) / std::tgamma(alpha) * std::pow(x, alpha - 1)
* std::exp(-beta * x));
}
/// Gaussian distribution
inline G4double Gaussian(G4double x, G4double sigma = 1, G4double x0 = 0)
{
G4double tmp = (x - x0) / sigma;
return (1.0 / (std::sqrt(2 * CLHEP::pi) * sigma)) * std::exp(-tmp * tmp / 2);
}
private:
/// Messenger for configuration
Par03EMShowerMessenger* fMessenger;
/// Helper class for creation of hits within the sensitive detector
std::unique_ptr<G4FastSimHitMaker> fHitMaker;
/// Standard deviation of the Gaussian distribution
/// Can be changed with UI command `/Par03/fastSim/transverseProfile/sigma
/// <sigma>`
/// If sigma is smaller than 0, it will be estimated from the detector
/// material (Moliere radius).
G4double fSigma = -1;
/// Alpha parameter of the Gamma distribution
/// Can be changed with UI command `/Par03/fastSim/longitudunalProfile/alpha
/// <alpha>`
/// If alpha is smaller than 0, it will be estimated from particle energy and
/// the detector material.
G4double fAlpha = -1;
/// Beta parameter of the Gamma distribution
/// Can be changed with UI command `/Par03/fastSim/longitudinalProfile/beta
/// <beta>`
G4double fBeta = 0.5;
/// Number of (same energy) hits created by the parametrisation. Can be
/// changed with UI command `/Par03/fastSim/numberOfHits <number>`
G4int fNbOfHits = 100;
/// Maximum depth of a shower created in fast simulation.
/// It is expressed in units of radiation length. Can be changed with UI
/// command `/Par03/fastSim/longitudinalProfile/maxDepth <depth>`
G4double fLongMaxDepth = 30;
private:
/// Messenger for configuration
Par03EMShowerMessenger* fMessenger;
/// Helper class for creation of hits within the sensitive detector
std::unique_ptr<G4FastSimHitMaker> fHitMaker;
/// Standard deviation of the Gaussian distribution
/// Can be changed with UI command `/Par03/fastSim/transverseProfile/sigma
/// <sigma>`
/// If sigma is smaller than 0, it will be estimated from the detector
/// material (Moliere radius).
G4double fSigma = -1;
/// Alpha parameter of the Gamma distribution
/// Can be changed with UI command `/Par03/fastSim/longitudunalProfile/alpha
/// <alpha>`
/// If alpha is smaller than 0, it will be estimated from particle energy and
/// the detector material.
G4double fAlpha = -1;
/// Beta parameter of the Gamma distribution
/// Can be changed with UI command `/Par03/fastSim/longitudinalProfile/beta
/// <beta>`
G4double fBeta = 0.5;
/// Number of (same energy) hits created by the parametrisation. Can be
/// changed with UI command `/Par03/fastSim/numberOfHits <number>`
G4int fNbOfHits = 100;
/// Maximum depth of a shower created in fast simulation.
/// It is expressed in units of radiation length. Can be changed with UI
/// command `/Par03/fastSim/longitudinalProfile/maxDepth <depth>`
G4double fLongMaxDepth = 30;
};
#endif /* PAR03EMSHOWERMODEL_HH */
@@ -26,8 +26,8 @@
#ifndef PAR03EVENTACTION_HH
#define PAR03EVENTACTION_HH
#include "G4UserEventAction.hh"
#include "G4Timer.hh"
#include "G4UserEventAction.hh"
class Par03DetectorConstruction;
@@ -42,27 +42,27 @@ class Par03DetectorConstruction;
class Par03EventAction : public G4UserEventAction
{
public:
Par03EventAction(Par03DetectorConstruction* aDetector);
virtual ~Par03EventAction();
public:
Par03EventAction(Par03DetectorConstruction* aDetector);
virtual ~Par03EventAction();
/// Timer is started
virtual void BeginOfEventAction(const G4Event* aEvent) final;
/// Hits collection is retrieved, analysed, and histograms are filled.
virtual void EndOfEventAction(const G4Event* aEvent) final;
/// Timer is started
virtual void BeginOfEventAction(const G4Event* aEvent) final;
/// Hits collection is retrieved, analysed, and histograms are filled.
virtual void EndOfEventAction(const G4Event* aEvent) final;
private:
/// ID of a hit collection to analyse
G4int fHitCollectionID;
/// Timer measurement
G4Timer fTimer;
/// Pointer to detector construction to retrieve (once) the detector
/// dimensions
Par03DetectorConstruction* fDetector;
/// Size of cell along Z axis
G4double fCellSizeZ = 0;
/// Size of cell along radius of cylinder
G4double fCellSizeRho = 0;
private:
/// ID of a hit collection to analyse
G4int fHitCollectionID;
/// Timer measurement
G4Timer fTimer;
/// Pointer to detector construction to retrieve (once) the detector
/// dimensions
Par03DetectorConstruction* fDetector;
/// Size of cell along Z axis
G4double fCellSizeZ = 0;
/// Size of cell along radius of cylinder
G4double fCellSizeRho = 0;
};
#endif /* PAR03EVENTACTION_HH */
@@ -26,11 +26,11 @@
#ifndef PAR03HIT_HH
#define PAR03HIT_HH
#include "G4VHit.hh"
#include "G4THitsCollection.hh"
#include "G4Allocator.hh"
#include "G4ThreeVector.hh"
#include "G4RotationMatrix.hh"
#include "G4THitsCollection.hh"
#include "G4ThreeVector.hh"
#include "G4VHit.hh"
class G4AttDef;
class G4AttValue;
@@ -50,83 +50,83 @@ class G4LogicalVolume;
class Par03Hit : public G4VHit
{
public:
Par03Hit();
Par03Hit(const Par03Hit& aRight);
virtual ~Par03Hit();
public:
Par03Hit();
Par03Hit(const Par03Hit& aRight);
virtual ~Par03Hit();
const Par03Hit& operator=(const Par03Hit& aRight);
int operator==(const Par03Hit& aRight) const;
const Par03Hit& operator=(const Par03Hit& aRight);
int operator==(const Par03Hit& aRight) const;
inline void* operator new(size_t);
inline void operator delete(void* aHit);
/// Visualise hits. If pointer to the logical volume was set, cell shape is
/// drawn taking into account proper radial position (taken from fRhoId)
virtual void Draw();
/// Retrieve atributes' names in order to allow filtering
virtual const std::map<G4String, G4AttDef>* GetAttDefs() const;
/// Create attributes for the visualisation.
virtual std::vector<G4AttValue>* CreateAttValues() const;
/// Print hit properties.
virtual void Print();
/// Set position
inline void SetPos(G4ThreeVector aXYZ) { fPos = aXYZ; }
/// Get position
inline G4ThreeVector GetPos() const { return fPos; }
/// Set rotation
inline void SetRot(G4RotationMatrix aXYZ) { fRot = aXYZ; }
/// Get rotation
inline G4RotationMatrix GetRot() const { return fRot; }
/// Set energy
inline void SetEdep(G4double aEdep) { fEdep = aEdep; }
/// Add energy to previous value
inline void AddEdep(G4double aEdep) { fEdep += aEdep; }
/// Get energy
inline G4double GetEdep() const { return fEdep; }
/// Set Z id of the cell in the readout segmentation
inline void SetZid(G4int aZ) { fZId = aZ; }
/// Get Z id of the cell in the readout segmentation
inline G4int GetZid() const { return fZId; }
/// Set Rho id of the cell in the readout segmentation
inline void SetRhoId(G4int aRho) { fRhoId = aRho; }
/// Get rho id of the cell in the readout segmentation
inline G4int GetRhoId() const { return fRhoId; }
/// Set phi id of the cell in the readout segmentation
inline void SetPhiId(G4int aPhi) { fPhiId = aPhi; }
/// Get phi id of the cell in the readout segmentation
inline G4int GetPhiId() const { return fPhiId; }
/// Set time
inline void SetTime(G4double aTime) { fTime = aTime; }
/// Get time
inline G4double GetTime() const { return fTime; }
/// Set type (0 = full sim, 1 = fast sim)
inline void SetType(G4int aType) { fType = aType; }
/// Get type (0 = full sim, 1 = fast sim)
inline G4int GetType() const { return fType; }
// Set pointer to cell logical volume
inline void SetLogV(G4LogicalVolume* aLogVol) { fLogVol = aLogVol; }
// Get pointer to cell logical volume
inline const G4LogicalVolume* GetLogVol() { return fLogVol; }
inline void* operator new(size_t);
inline void operator delete(void* aHit);
/// Visualise hits. If pointer to the logical volume was set, cell shape is
/// drawn taking into account proper radial position (taken from fRhoId)
virtual void Draw();
/// Retrieve atributes' names in order to allow filtering
virtual const std::map<G4String, G4AttDef>* GetAttDefs() const;
/// Create attributes for the visualisation.
virtual std::vector<G4AttValue>* CreateAttValues() const;
/// Print hit properties.
virtual void Print();
/// Set position
inline void SetPos(G4ThreeVector aXYZ) { fPos = aXYZ; }
/// Get position
inline G4ThreeVector GetPos() const { return fPos; }
/// Set rotation
inline void SetRot(G4RotationMatrix aXYZ) { fRot = aXYZ; }
/// Get rotation
inline G4RotationMatrix GetRot() const { return fRot; }
/// Set energy
inline void SetEdep(G4double aEdep) { fEdep = aEdep; }
/// Add energy to previous value
inline void AddEdep(G4double aEdep) { fEdep += aEdep; }
/// Get energy
inline G4double GetEdep() const { return fEdep; }
/// Set Z id of the cell in the readout segmentation
inline void SetZid(G4int aZ) { fZId = aZ; }
/// Get Z id of the cell in the readout segmentation
inline G4int GetZid() const { return fZId; }
/// Set Rho id of the cell in the readout segmentation
inline void SetRhoId(G4int aRho) { fRhoId = aRho; }
/// Get rho id of the cell in the readout segmentation
inline G4int GetRhoId() const { return fRhoId; }
/// Set phi id of the cell in the readout segmentation
inline void SetPhiId(G4int aPhi) { fPhiId = aPhi; }
/// Get phi id of the cell in the readout segmentation
inline G4int GetPhiId() const { return fPhiId; }
/// Set time
inline void SetTime(G4double aTime) { fTime = aTime; }
/// Get time
inline G4double GetTime() const { return fTime; }
/// Set type (0 = full sim, 1 = fast sim)
inline void SetType(G4int aType) { fType = aType; }
/// Get type (0 = full sim, 1 = fast sim)
inline G4int GetType() const { return fType; }
// Set pointer to cell logical volume
inline void SetLogV(G4LogicalVolume* aLogVol) { fLogVol = aLogVol; }
// Get pointer to cell logical volume
inline const G4LogicalVolume* GetLogVol() { return fLogVol; }
public:
/// Energy deposit
G4double fEdep = 0;
/// Z ID of readout cell
G4int fZId = -1;
/// Rho ID of readout cell
G4int fRhoId = -1;
/// Phi ID of readout cell
G4int fPhiId = -1;
/// Position
G4ThreeVector fPos;
/// Rotation
G4RotationMatrix fRot;
/// Time
G4double fTime = -1;
/// Type: 0 = full sim, 1 = fast sim
G4int fType = -1;
/// Pointer to logical volume for visualisation
G4LogicalVolume* fLogVol = nullptr;
public:
/// Energy deposit
G4double fEdep = 0;
/// Z ID of readout cell
G4int fZId = -1;
/// Rho ID of readout cell
G4int fRhoId = -1;
/// Phi ID of readout cell
G4int fPhiId = -1;
/// Position
G4ThreeVector fPos;
/// Rotation
G4RotationMatrix fRot;
/// Time
G4double fTime = -1;
/// Type: 0 = full sim, 1 = fast sim
G4int fType = -1;
/// Pointer to logical volume for visualisation
G4LogicalVolume* fLogVol = nullptr;
};
typedef G4THitsCollection<Par03Hit> Par03HitsCollection;
@@ -135,14 +135,13 @@ extern G4ThreadLocal G4Allocator<Par03Hit>* Par03HitAllocator;
inline void* Par03Hit::operator new(size_t)
{
if(!Par03HitAllocator)
Par03HitAllocator = new G4Allocator<Par03Hit>;
return (void*) Par03HitAllocator->MallocSingle();
if (!Par03HitAllocator) Par03HitAllocator = new G4Allocator<Par03Hit>;
return (void*)Par03HitAllocator->MallocSingle();
}
inline void Par03Hit::operator delete(void* aHit)
{
Par03HitAllocator->FreeSingle((Par03Hit*) aHit);
Par03HitAllocator->FreeSingle((Par03Hit*)aHit);
}
#endif /* PAR03HIT_HH */
@@ -41,15 +41,15 @@ class G4Event;
class Par03PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
Par03PrimaryGeneratorAction();
virtual ~Par03PrimaryGeneratorAction();
public:
Par03PrimaryGeneratorAction();
virtual ~Par03PrimaryGeneratorAction();
virtual void GeneratePrimaries(G4Event*) final;
virtual void GeneratePrimaries(G4Event*) final;
private:
/// Particle gun
G4ParticleGun* fParticleGun;
private:
/// Particle gun
G4ParticleGun* fParticleGun;
};
#endif /* PAR03PRIMARYGENERATORACTION_HH */
@@ -41,20 +41,20 @@ class Par03DetectorConstruction;
class Par03RunAction : public G4UserRunAction
{
public:
/// Constructor. Defines the histograms.
Par03RunAction(Par03DetectorConstruction* aDetector);
virtual ~Par03RunAction();
public:
/// Constructor. Defines the histograms.
Par03RunAction(Par03DetectorConstruction* aDetector);
virtual ~Par03RunAction();
/// Open the file for the analysis
virtual void BeginOfRunAction(const G4Run*) final;
/// Write and close the file
virtual void EndOfRunAction(const G4Run*) final;
/// Open the file for the analysis
virtual void BeginOfRunAction(const G4Run*) final;
/// Write and close the file
virtual void EndOfRunAction(const G4Run*) final;
private:
/// Pointer to detector construction to retrieve the detector dimensions to
/// setup the histograms
Par03DetectorConstruction* fDetector;
private:
/// Pointer to detector construction to retrieve the detector dimensions to
/// setup the histograms
Par03DetectorConstruction* fDetector;
};
#endif /* PAR03RUNACTION_HH */
@@ -48,38 +48,35 @@ class G4TouchableHistory;
*
*/
class Par03SensitiveDetector
: public G4VSensitiveDetector
, public G4VFastSimSensitiveDetector
class Par03SensitiveDetector : public G4VSensitiveDetector, public G4VFastSimSensitiveDetector
{
public:
Par03SensitiveDetector(G4String aName);
Par03SensitiveDetector(G4String aName, G4int aNumLayers, G4int aNumPhi,
G4int aNumRho);
virtual ~Par03SensitiveDetector();
/// Create hit collection
virtual void Initialize(G4HCofThisEvent* HCE) final;
/// Process energy deposit from the full simulation.
virtual G4bool ProcessHits(G4Step* aStep, G4TouchableHistory* aROhist) final;
/// Process energy deposit from the fast simulation.
virtual G4bool ProcessHits(const G4FastHit* aHit, const G4FastTrack* aTrack,
G4TouchableHistory* aROhist) final;
/// Process energy deposit - common part for full and fast simulation
/// It is invoked from ProcessHits() methods, and sets basic hit properties
/// (position, etc.), common for hit from fast and full simulation.
Par03Hit* RetrieveAndSetupHit(G4TouchableHistory* aTouchable);
public:
Par03SensitiveDetector(G4String aName);
Par03SensitiveDetector(G4String aName, G4int aNumLayers, G4int aNumPhi, G4int aNumRho);
virtual ~Par03SensitiveDetector();
/// Create hit collection
virtual void Initialize(G4HCofThisEvent* HCE) final;
/// Process energy deposit from the full simulation.
virtual G4bool ProcessHits(G4Step* aStep, G4TouchableHistory* aROhist) final;
/// Process energy deposit from the fast simulation.
virtual G4bool ProcessHits(const G4FastHit* aHit, const G4FastTrack* aTrack,
G4TouchableHistory* aROhist) final;
/// Process energy deposit - common part for full and fast simulation
/// It is invoked from ProcessHits() methods, and sets basic hit properties
/// (position, etc.), common for hit from fast and full simulation.
Par03Hit* RetrieveAndSetupHit(G4TouchableHistory* aTouchable);
private:
/// Collection of hits
Par03HitsCollection* fHitsCollection = nullptr;
/// ID of collection of hits
G4int fHitCollectionID = -1;
/// Number of readout cells along z axis
G4int fCellNoZ = 10;
/// Number of readout cells along radius of cylinder
G4int fCellNoRho = 10;
/// Number of readout cells along azimuthal angle
G4int fCellNoPhi = 10;
private:
/// Collection of hits
Par03HitsCollection* fHitsCollection = nullptr;
/// ID of collection of hits
G4int fHitCollectionID = -1;
/// Number of readout cells along z axis
G4int fCellNoZ = 10;
/// Number of readout cells along radius of cylinder
G4int fCellNoRho = 10;
/// Number of readout cells along azimuthal angle
G4int fCellNoPhi = 10;
};
#endif /* PAR03SENSITIVEDETECTOR_HH */
@@ -24,14 +24,13 @@
// ********************************************************************
//
#include "Par03ActionInitialisation.hh"
#include "Par03PrimaryGeneratorAction.hh"
#include "Par03EventAction.hh"
#include "Par03PrimaryGeneratorAction.hh"
#include "Par03RunAction.hh"
Par03ActionInitialisation::Par03ActionInitialisation(
Par03DetectorConstruction* aDetector)
: G4VUserActionInitialization()
, fDetector(aDetector)
Par03ActionInitialisation::Par03ActionInitialisation(Par03DetectorConstruction* aDetector)
: G4VUserActionInitialization(), fDetector(aDetector)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -24,36 +24,33 @@
// ********************************************************************
//
#include "Par03DetectorConstruction.hh"
#include "Par03DetectorMessenger.hh"
#include "Par03SensitiveDetector.hh"
#include "Par03EMShowerModel.hh"
#include "G4NistManager.hh"
#include "G4Material.hh"
#include "Par03DetectorMessenger.hh"
#include "Par03EMShowerModel.hh"
#include "Par03SensitiveDetector.hh"
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4LogicalVolume.hh"
#include "G4Material.hh"
#include "G4NistManager.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "G4VisAttributes.hh"
#include "G4RunManager.hh"
#include "G4SDManager.hh"
#include "G4UnitsTable.hh"
#include "G4Region.hh"
#include "G4RegionStore.hh"
#include "G4RunManager.hh"
#include "G4SDManager.hh"
#include "G4Tubs.hh"
#include "G4UnitsTable.hh"
#include "G4VisAttributes.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par03DetectorConstruction::Par03DetectorConstruction()
: G4VUserDetectorConstruction()
Par03DetectorConstruction::Par03DetectorConstruction() : G4VUserDetectorConstruction()
{
fDetectorMessenger = new Par03DetectorMessenger(this);
G4NistManager* nistManager = G4NistManager::Instance();
fDetectorMaterial = nistManager->FindOrBuildMaterial("G4_Fe");
fDetectorMaterial = nistManager->FindOrBuildMaterial("G4_Fe");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -66,51 +63,50 @@ G4VPhysicalVolume* Par03DetectorConstruction::Construct()
{
//--------- Material definition ---------
G4NistManager* nistManager = G4NistManager::Instance();
G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
//--------- Derived dimensions ---------
G4double full2Pi = 2. * CLHEP::pi * rad;
G4double full2Pi = 2. * CLHEP::pi * rad;
G4double layerThickness = fDetectorLength / fNbOfLayers;
G4double cellPhi = full2Pi / fNbOfPhiCells;
G4double cellDR = fDetectorRadius / fNbOfRhoCells;
G4double cellPhi = full2Pi / fNbOfPhiCells;
G4double cellDR = fDetectorRadius / fNbOfRhoCells;
//--------- World ---------
auto fSolidWorld = new G4Box("World", // name
fWorldSize / 2., // half-width in X
fWorldSize / 2., // half-width in Y
fWorldSize / 2.); // half-width in Z
auto fLogicWorld = new G4LogicalVolume(fSolidWorld, // solid
air, // material
"World"); // name
auto fPhysicWorld = new G4PVPlacement(0, // no rotation
auto fSolidWorld = new G4Box("World", // name
fWorldSize / 2., // half-width in X
fWorldSize / 2., // half-width in Y
fWorldSize / 2.); // half-width in Z
auto fLogicWorld = new G4LogicalVolume(fSolidWorld, // solid
air, // material
"World"); // name
auto fPhysicWorld = new G4PVPlacement(0, // no rotation
G4ThreeVector(), // at (0,0,0)
fLogicWorld, // logical volume
"World", // name
0, // mother volume
false, // not used
999, // copy number
true); // copy number
fLogicWorld, // logical volume
"World", // name
0, // mother volume
false, // not used
999, // copy number
true); // copy number
//--------- Detector envelope ---------
auto fSolidDetector = new G4Tubs("Detector", // name
0, // inner radius
fDetectorRadius, // outer radius
fDetectorLength / 2., // half-width in Z
0, // start angle
full2Pi); // delta angle
auto fSolidDetector = new G4Tubs("Detector", // name
0, // inner radius
fDetectorRadius, // outer radius
fDetectorLength / 2., // half-width in Z
0, // start angle
full2Pi); // delta angle
auto fLogicDetector = new G4LogicalVolume(fSolidDetector, // solid
fDetectorMaterial, // material
"Detector"); // name
new G4PVPlacement(
0, // no rotation
G4ThreeVector(0, 0,
fDetectorLength / 2), // detector face starts at (0,0,0)
fLogicDetector, // logical volume
"Detector", // name
fLogicWorld, // mother volume
false, // not used
99, // copy number
true); // check overlaps
"Detector"); // name
new G4PVPlacement(0, // no rotation
G4ThreeVector(0, 0,
fDetectorLength / 2), // detector face starts at (0,0,0)
fLogicDetector, // logical volume
"Detector", // name
fLogicWorld, // mother volume
false, // not used
99, // copy number
true); // check overlaps
// Region for fast simulation
auto detectorRegion = new G4Region("DetectorRegion");
@@ -118,88 +114,88 @@ G4VPhysicalVolume* Par03DetectorConstruction::Construct()
//--------- Readout geometry ---------
// Layers (along z)
auto fSolidLayer = new G4Tubs("Layer", // name
0, // inner radius
fDetectorRadius, // outer radius
layerThickness / 2., // half-width in Z
0, // start angle
full2Pi); // delta angle
auto fSolidLayer = new G4Tubs("Layer", // name
0, // inner radius
fDetectorRadius, // outer radius
layerThickness / 2., // half-width in Z
0, // start angle
full2Pi); // delta angle
auto fLogicLayer = new G4LogicalVolume(fSolidLayer, // solid
air, // material
"Layer"); // name
if(fNbOfLayers > 1)
new G4PVReplica("Layer", // name
fLogicLayer, // logical volume
fLogicDetector, // mother volume
kZAxis, // axis of replication
fNbOfLayers, // number of replicas
air, // material
"Layer"); // name
if (fNbOfLayers > 1)
new G4PVReplica("Layer", // name
fLogicLayer, // logical volume
fLogicDetector, // mother volume
kZAxis, // axis of replication
fNbOfLayers, // number of replicas
layerThickness); // width of single replica
else
new G4PVPlacement(0, // no rotation
new G4PVPlacement(0, // no rotation
G4ThreeVector(), // place at centre of mother volume
fLogicLayer, // logical volume
"Layer", // name
fLogicDetector, // mother volume
false, // not used
0, // copy number
true); // check overlaps
fLogicLayer, // logical volume
"Layer", // name
fLogicDetector, // mother volume
false, // not used
0, // copy number
true); // check overlaps
// Layer segment (division in phi)
auto fSolidRow = new G4Tubs("Row", // name
0, // inner radius
fDetectorRadius, // outer radius
auto fSolidRow = new G4Tubs("Row", // name
0, // inner radius
fDetectorRadius, // outer radius
layerThickness / 2., // half-width in Z
0, // start angle
cellPhi); // delta angle
0, // start angle
cellPhi); // delta angle
auto fLogicRow = new G4LogicalVolume(fSolidRow, // solid
air, // material
auto fLogicRow = new G4LogicalVolume(fSolidRow, // solid
air, // material
"Segment"); // name
if(fNbOfPhiCells > 1)
new G4PVReplica("Segment", // name
fLogicRow, // logical volume
fLogicLayer, // mother volume
kPhi, // axis of replication
if (fNbOfPhiCells > 1)
new G4PVReplica("Segment", // name
fLogicRow, // logical volume
fLogicLayer, // mother volume
kPhi, // axis of replication
fNbOfPhiCells, // number of replicas
cellPhi); // width of single replica
cellPhi); // width of single replica
else
new G4PVPlacement(0, // no rotation
new G4PVPlacement(0, // no rotation
G4ThreeVector(), // place at centre of mother volume
fLogicRow, // logical volume
"Row", // name
fLogicLayer, // mother volume
false, // not used
0, // copy number
true); // check overlaps
fLogicRow, // logical volume
"Row", // name
fLogicLayer, // mother volume
false, // not used
0, // copy number
true); // check overlaps
// Final cells (segment slices in radius)
// No volume can be placed inside a radial replication
auto fSolidCell = new G4Tubs("Cell", // name
0, // inner radius
cellDR, // outer radius
auto fSolidCell = new G4Tubs("Cell", // name
0, // inner radius
cellDR, // outer radius
layerThickness / 2., // half-width in Z
0, // start angle
cellPhi); // delta angle
0, // start angle
cellPhi); // delta angle
fLogicCell = new G4LogicalVolume(fSolidCell, // solid
fLogicCell = new G4LogicalVolume(fSolidCell, // solid
fDetectorMaterial, // material
"Cell"); // name
if(fNbOfRhoCells > 1)
new G4PVReplica("Cell", // name
fLogicCell, // logical volume
fLogicRow, // mother volume
kRho, // axis of replication
"Cell"); // name
if (fNbOfRhoCells > 1)
new G4PVReplica("Cell", // name
fLogicCell, // logical volume
fLogicRow, // mother volume
kRho, // axis of replication
fNbOfRhoCells, // number of replicas
cellDR); // width of single replica
cellDR); // width of single replica
else
new G4PVPlacement(0, // no rotation
new G4PVPlacement(0, // no rotation
G4ThreeVector(), // place at centre of mother volume
fLogicCell, // logical volume
"Cell", // name
fLogicRow, // mother volume
false, // not used
0, // copy number
true); // check overlaps
fLogicCell, // logical volume
"Cell", // name
fLogicRow, // mother volume
false, // not used
0, // copy number
true); // check overlaps
//--------- Visualisation settings ---------
fLogicWorld->SetVisAttributes(G4VisAttributes::GetInvisible());
@@ -218,13 +214,12 @@ G4VPhysicalVolume* Par03DetectorConstruction::Construct()
void Par03DetectorConstruction::ConstructSDandField()
{
Par03SensitiveDetector* caloSD = new Par03SensitiveDetector(
"sensitiveDetector", fNbOfLayers, fNbOfPhiCells, fNbOfRhoCells);
Par03SensitiveDetector* caloSD =
new Par03SensitiveDetector("sensitiveDetector", fNbOfLayers, fNbOfPhiCells, fNbOfRhoCells);
G4SDManager::GetSDMpointer()->AddNewDetector(caloSD);
SetSensitiveDetector(fLogicCell, caloSD);
auto detectorRegion =
G4RegionStore::GetInstance()->GetRegion("DetectorRegion");
auto detectorRegion = G4RegionStore::GetInstance()->GetRegion("DetectorRegion");
new Par03EMShowerModel("model", detectorRegion);
}
@@ -236,9 +231,8 @@ void Par03DetectorConstruction::Print() const
<< "\n--- Detector material:\t" << fDetectorMaterial->GetName()
<< "\n--- Detector length:\t" << G4BestUnit(fDetectorLength, "Length")
<< "\n--- Detector radius:\t" << G4BestUnit(fDetectorRadius, "Length")
<< "\n--- Number of layers:\t" << fNbOfLayers
<< "\n--- Number of R-cells:\t" << fNbOfRhoCells
<< "\n--- Number of phi-cells:\t" << fNbOfPhiCells << G4endl;
<< "\n--- Number of layers:\t" << fNbOfLayers << "\n--- Number of R-cells:\t"
<< fNbOfRhoCells << "\n--- Number of phi-cells:\t" << fNbOfPhiCells << G4endl;
G4cout << "-----------------------------------------------------" << G4endl;
}
@@ -248,11 +242,11 @@ void Par03DetectorConstruction::SetMaterial(const G4String& aName)
{
// search material by its name
G4Material* material = G4NistManager::Instance()->FindOrBuildMaterial(aName);
if(material)
if (material)
fDetectorMaterial = material;
else
G4Exception("Par03DetectorConstruction::SetMaterial()", "InvalidSetup",
FatalException, ("Unknown material name: " + aName).c_str());
G4Exception("Par03DetectorConstruction::SetMaterial()", "InvalidSetup", FatalException,
("Unknown material name: " + aName).c_str());
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
}
@@ -261,11 +255,10 @@ void Par03DetectorConstruction::SetMaterial(const G4String& aName)
void Par03DetectorConstruction::SetRadius(G4double aRadius)
{
// check if fits within world volume
if(aRadius >= fWorldSize / 2.)
G4Exception("Par03DetectorConstruction::SetRadius()", "InvalidSetup",
FatalException,
("Detector radius cannot be larger than the world size (" +
G4String(G4BestUnit(fWorldSize / 2., "Length")) + ")")
if (aRadius >= fWorldSize / 2.)
G4Exception("Par03DetectorConstruction::SetRadius()", "InvalidSetup", FatalException,
("Detector radius cannot be larger than the world size ("
+ G4String(G4BestUnit(fWorldSize / 2., "Length")) + ")")
.c_str());
fDetectorRadius = aRadius;
}
@@ -274,11 +267,10 @@ void Par03DetectorConstruction::SetRadius(G4double aRadius)
void Par03DetectorConstruction::SetLength(G4double aLength)
{
// check if fits within world volume
if(aLength >= fWorldSize / 2.)
G4Exception("Par03DetectorConstruction::SetLength()", "InvalidSetup",
FatalException,
("Detector length cannot be larger than the world size (" +
G4String(G4BestUnit(fWorldSize / 2., "Length")) + ")")
if (aLength >= fWorldSize / 2.)
G4Exception("Par03DetectorConstruction::SetLength()", "InvalidSetup", FatalException,
("Detector length cannot be larger than the world size ("
+ G4String(G4BestUnit(fWorldSize / 2., "Length")) + ")")
.c_str());
fDetectorLength = aLength;
}
@@ -24,20 +24,19 @@
// ********************************************************************
//
#include "Par03DetectorMessenger.hh"
#include "Par03DetectorConstruction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIdirectory.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par03DetectorMessenger::Par03DetectorMessenger(
Par03DetectorConstruction* aDetector)
: G4UImessenger()
, fDetector(aDetector)
Par03DetectorMessenger::Par03DetectorMessenger(Par03DetectorConstruction* aDetector)
: G4UImessenger(), fDetector(aDetector)
{
fExampleDir = new G4UIdirectory("/Par03/");
fExampleDir->SetGuidance("UI commands specific to this example");
@@ -48,51 +47,43 @@ Par03DetectorMessenger::Par03DetectorMessenger(
fPrintCmd = new G4UIcmdWithoutParameter("/Par03/detector/print", this);
fPrintCmd->SetGuidance("Print current settings.");
fDetectorRadiusCmd =
new G4UIcmdWithADoubleAndUnit("/Par03/detector/setDetectorRadius", this);
fDetectorRadiusCmd->SetGuidance(
"Set tranverse size of the detector (cylinder radius)");
fDetectorRadiusCmd = new G4UIcmdWithADoubleAndUnit("/Par03/detector/setDetectorRadius", this);
fDetectorRadiusCmd->SetGuidance("Set tranverse size of the detector (cylinder radius)");
fDetectorRadiusCmd->SetParameterName("Size", false);
fDetectorRadiusCmd->SetRange("Size>0.");
fDetectorRadiusCmd->SetUnitCategory("Length");
fDetectorRadiusCmd->AvailableForStates(G4State_PreInit);
fDetectorRadiusCmd->SetToBeBroadcasted(false);
fDetectorLengthCmd =
new G4UIcmdWithADoubleAndUnit("/Par03/detector/setDetectorLength", this);
fDetectorLengthCmd->SetGuidance(
"Set length of the detector (cylinder length)");
fDetectorLengthCmd = new G4UIcmdWithADoubleAndUnit("/Par03/detector/setDetectorLength", this);
fDetectorLengthCmd->SetGuidance("Set length of the detector (cylinder length)");
fDetectorLengthCmd->SetParameterName("Size", false);
fDetectorLengthCmd->SetRange("Size>0.");
fDetectorLengthCmd->SetUnitCategory("Length");
fDetectorLengthCmd->AvailableForStates(G4State_PreInit);
fDetectorLengthCmd->SetToBeBroadcasted(false);
fDetectorMaterialCmd =
new G4UIcmdWithAString("/Par03/detector/setDetectorMaterial", this);
fDetectorMaterialCmd = new G4UIcmdWithAString("/Par03/detector/setDetectorMaterial", this);
fDetectorMaterialCmd->SetGuidance("Material of the detector.");
fDetectorMaterialCmd->SetParameterName("Name", false);
fDetectorMaterialCmd->AvailableForStates(G4State_PreInit);
fDetectorMaterialCmd->SetToBeBroadcasted(false);
fNbLayersCmd =
new G4UIcmdWithAnInteger("/Par03/detector/setNbOfLayers", this);
fNbLayersCmd = new G4UIcmdWithAnInteger("/Par03/detector/setNbOfLayers", this);
fNbLayersCmd->SetGuidance("Set number of layers.");
fNbLayersCmd->SetParameterName("NbLayers", false);
fNbLayersCmd->SetRange("NbLayers>0");
fNbLayersCmd->AvailableForStates(G4State_PreInit);
fNbLayersCmd->SetToBeBroadcasted(false);
fNbRhoCellsCmd =
new G4UIcmdWithAnInteger("/Par03/detector/setNbOfRhoCells", this);
fNbRhoCellsCmd = new G4UIcmdWithAnInteger("/Par03/detector/setNbOfRhoCells", this);
fNbRhoCellsCmd->SetGuidance("Set number of cells along radius.");
fNbRhoCellsCmd->SetParameterName("NbRhoCells", false);
fNbRhoCellsCmd->SetRange("NbRhoCells>0");
fNbRhoCellsCmd->AvailableForStates(G4State_PreInit);
fNbRhoCellsCmd->SetToBeBroadcasted(false);
fNbPhiCellsCmd =
new G4UIcmdWithAnInteger("/Par03/detector/setNbOfPhiCells", this);
fNbPhiCellsCmd = new G4UIcmdWithAnInteger("/Par03/detector/setNbOfPhiCells", this);
fNbPhiCellsCmd->SetGuidance("Set number of cells in azimuthal angle.");
fNbPhiCellsCmd->SetParameterName("NbPhiCells", false);
fNbPhiCellsCmd->SetRange("NbPhiCells>0");
@@ -117,35 +108,27 @@ Par03DetectorMessenger::~Par03DetectorMessenger()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par03DetectorMessenger::SetNewValue(G4UIcommand* aCommand,
G4String aNewValue)
void Par03DetectorMessenger::SetNewValue(G4UIcommand* aCommand, G4String aNewValue)
{
if(aCommand == fPrintCmd)
{
if (aCommand == fPrintCmd) {
fDetector->Print();
}
else if(aCommand == fDetectorRadiusCmd)
{
else if (aCommand == fDetectorRadiusCmd) {
fDetector->SetRadius(fDetectorRadiusCmd->GetNewDoubleValue(aNewValue));
}
else if(aCommand == fDetectorLengthCmd)
{
else if (aCommand == fDetectorLengthCmd) {
fDetector->SetLength(fDetectorRadiusCmd->GetNewDoubleValue(aNewValue));
}
else if(aCommand == fDetectorMaterialCmd)
{
else if (aCommand == fDetectorMaterialCmd) {
fDetector->SetMaterial(aNewValue);
}
else if(aCommand == fNbLayersCmd)
{
else if (aCommand == fNbLayersCmd) {
fDetector->SetNbOfLayers(fNbLayersCmd->GetNewIntValue(aNewValue));
}
else if(aCommand == fNbRhoCellsCmd)
{
else if (aCommand == fNbRhoCellsCmd) {
fDetector->SetNbOfRhoCells(fNbRhoCellsCmd->GetNewIntValue(aNewValue));
}
else if(aCommand == fNbPhiCellsCmd)
{
else if (aCommand == fNbPhiCellsCmd) {
fDetector->SetNbOfPhiCells(fNbPhiCellsCmd->GetNewIntValue(aNewValue));
}
}
@@ -156,28 +139,22 @@ G4String Par03DetectorMessenger::GetCurrentValue(G4UIcommand* aCommand)
{
G4String cv;
if(aCommand == fDetectorRadiusCmd)
{
if (aCommand == fDetectorRadiusCmd) {
cv = fDetectorRadiusCmd->ConvertToString(fDetector->GetRadius(), "mm");
}
else if(aCommand == fDetectorLengthCmd)
{
else if (aCommand == fDetectorLengthCmd) {
cv = fDetectorLengthCmd->ConvertToString(fDetector->GetLength(), "mm");
}
else if(aCommand == fDetectorMaterialCmd)
{
else if (aCommand == fDetectorMaterialCmd) {
cv = fDetector->GetMaterial();
}
else if(aCommand == fNbLayersCmd)
{
else if (aCommand == fNbLayersCmd) {
cv = fNbLayersCmd->ConvertToString(fDetector->GetNbOfLayers());
}
else if(aCommand == fNbPhiCellsCmd)
{
else if (aCommand == fNbPhiCellsCmd) {
cv = fNbPhiCellsCmd->ConvertToString(fDetector->GetNbOfPhiCells());
}
else if(aCommand == fNbRhoCellsCmd)
{
else if (aCommand == fNbRhoCellsCmd) {
cv = fNbRhoCellsCmd->ConvertToString(fDetector->GetNbOfRhoCells());
}
return cv;
@@ -23,38 +23,34 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
#include "Par03EMShowerModel.hh"
#include "Par03EMShowerMessenger.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithADouble.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "Par03EMShowerModel.hh"
Par03EMShowerMessenger::Par03EMShowerMessenger(Par03EMShowerModel* aModel)
: fModel(aModel)
#include "G4UIcmdWithADouble.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIdirectory.hh"
Par03EMShowerMessenger::Par03EMShowerMessenger(Par03EMShowerModel* aModel) : fModel(aModel)
{
fDirectory = new G4UIdirectory("/Par03/fastSim/");
fDirectory->SetGuidance(
"Set mesh parameters for the example fast sim model.");
fDirectory->SetGuidance("Set mesh parameters for the example fast sim model.");
fPrintCmd = new G4UIcmdWithoutParameter("/Par03/fastSim/print", this);
fPrintCmd->SetGuidance("Print current settings.");
fSigmaCmd = new G4UIcmdWithADoubleAndUnit(
"/Par03/fastSim/transverseProfile/sigma", this);
fSigmaCmd = new G4UIcmdWithADoubleAndUnit("/Par03/fastSim/transverseProfile/sigma", this);
fSigmaCmd->SetGuidance("Set sigma parameter of 2D Gaussian distribution.");
fSigmaCmd->SetParameterName("Sigma", false);
fSigmaCmd->SetUnitCategory("Length");
fAlphaCmd =
new G4UIcmdWithADouble("/Par03/fastSim/longitudinalProfile/alpha", this);
fAlphaCmd = new G4UIcmdWithADouble("/Par03/fastSim/longitudinalProfile/alpha", this);
fAlphaCmd->SetGuidance("Set alpha parameter of Gamma distribution.");
fAlphaCmd->SetParameterName("Alpha", false);
fBetaCmd =
new G4UIcmdWithADouble("/Par03/fastSim/longitudinalProfile/beta", this);
fBetaCmd = new G4UIcmdWithADouble("/Par03/fastSim/longitudinalProfile/beta", this);
fBetaCmd->SetGuidance("Set beta parameter of Gamma distribution.");
fBetaCmd->SetParameterName("Beta", false);
@@ -65,10 +61,8 @@ Par03EMShowerMessenger::Par03EMShowerMessenger(Par03EMShowerModel* aModel)
"the sensitive detector.");
fNbOfHitsCmd->SetParameterName("Number", false);
fLongMaxDepthCmd =
new G4UIcmdWithADouble("/Par03/fastSim/longitudinalProfile/maxDepth", this);
fLongMaxDepthCmd->SetGuidance(
"Set maximum shower depth used in parametrisation.");
fLongMaxDepthCmd = new G4UIcmdWithADouble("/Par03/fastSim/longitudinalProfile/maxDepth", this);
fLongMaxDepthCmd->SetGuidance("Set maximum shower depth used in parametrisation.");
fLongMaxDepthCmd->SetGuidance("Expressed in units of radiation length.");
fLongMaxDepthCmd->SetParameterName("Depth", false);
}
@@ -88,31 +82,24 @@ Par03EMShowerMessenger::~Par03EMShowerMessenger()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par03EMShowerMessenger::SetNewValue(G4UIcommand* aCommand,
G4String aNewValues)
void Par03EMShowerMessenger::SetNewValue(G4UIcommand* aCommand, G4String aNewValues)
{
if(aCommand == fPrintCmd)
{
if (aCommand == fPrintCmd) {
fModel->Print();
}
else if(aCommand == fSigmaCmd)
{
else if (aCommand == fSigmaCmd) {
fModel->SetSigma(fSigmaCmd->GetNewDoubleValue(aNewValues));
}
else if(aCommand == fAlphaCmd)
{
else if (aCommand == fAlphaCmd) {
fModel->SetAlpha(fAlphaCmd->GetNewDoubleValue(aNewValues));
}
else if(aCommand == fBetaCmd)
{
else if (aCommand == fBetaCmd) {
fModel->SetBeta(fBetaCmd->GetNewDoubleValue(aNewValues));
}
else if(aCommand == fNbOfHitsCmd)
{
else if (aCommand == fNbOfHitsCmd) {
fModel->SetNbOfHits(fNbOfHitsCmd->GetNewIntValue(aNewValues));
}
else if(aCommand == fLongMaxDepthCmd)
{
else if (aCommand == fLongMaxDepthCmd) {
fModel->SetLongMaxDepth(fLongMaxDepthCmd->GetNewDoubleValue(aNewValues));
}
}
@@ -123,24 +110,19 @@ G4String Par03EMShowerMessenger::GetCurrentValue(G4UIcommand* aCommand)
{
G4String cv;
if(aCommand == fSigmaCmd)
{
if (aCommand == fSigmaCmd) {
cv = fSigmaCmd->ConvertToString(fModel->GetSigma());
}
else if(aCommand == fAlphaCmd)
{
else if (aCommand == fAlphaCmd) {
cv = fAlphaCmd->ConvertToString(fModel->GetAlpha());
}
else if(aCommand == fBetaCmd)
{
else if (aCommand == fBetaCmd) {
cv = fBetaCmd->ConvertToString(fModel->GetBeta());
}
else if(aCommand == fNbOfHitsCmd)
{
else if (aCommand == fNbOfHitsCmd) {
cv = fNbOfHitsCmd->ConvertToString(fModel->GetNbOfHits());
}
else if(aCommand == fLongMaxDepthCmd)
{
else if (aCommand == fLongMaxDepthCmd) {
cv = fLongMaxDepthCmd->ConvertToString(fModel->GetLongMaxDepth());
}
return cv;
@@ -24,29 +24,30 @@
// ********************************************************************
//
#include "Par03EMShowerModel.hh"
#include "Par03EMShowerMessenger.hh"
#include "G4Electron.hh"
#include "G4Positron.hh"
#include "G4FastHit.hh"
#include "G4FastSimHitMaker.hh"
#include "G4Gamma.hh"
#include "G4Positron.hh"
#include "G4SystemOfUnits.hh"
#include "G4UnitsTable.hh"
#include "G4FastHit.hh"
#include "Randomize.hh"
#include "G4FastSimHitMaker.hh"
Par03EMShowerModel::Par03EMShowerModel(G4String aModelName, G4Region* aEnvelope)
: G4VFastSimulationModel(aModelName, aEnvelope)
, fMessenger(new Par03EMShowerMessenger(this))
, fHitMaker(new G4FastSimHitMaker)
: G4VFastSimulationModel(aModelName, aEnvelope),
fMessenger(new Par03EMShowerMessenger(this)),
fHitMaker(new G4FastSimHitMaker)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par03EMShowerModel::Par03EMShowerModel(G4String aModelName)
: G4VFastSimulationModel(aModelName)
, fMessenger(new Par03EMShowerMessenger(this))
, fHitMaker(new G4FastSimHitMaker)
: G4VFastSimulationModel(aModelName),
fMessenger(new Par03EMShowerMessenger(this)),
fHitMaker(new G4FastSimHitMaker)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -55,12 +56,11 @@ Par03EMShowerModel::~Par03EMShowerModel() = default;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool Par03EMShowerModel::IsApplicable(
const G4ParticleDefinition& aParticleType)
G4bool Par03EMShowerModel::IsApplicable(const G4ParticleDefinition& aParticleType)
{
return &aParticleType == G4Electron::ElectronDefinition() ||
&aParticleType == G4Positron::PositronDefinition() ||
&aParticleType == G4Gamma::GammaDefinition();
return &aParticleType == G4Electron::ElectronDefinition()
|| &aParticleType == G4Positron::PositronDefinition()
|| &aParticleType == G4Gamma::GammaDefinition();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -68,8 +68,7 @@ G4bool Par03EMShowerModel::IsApplicable(
G4bool Par03EMShowerModel::ModelTrigger(const G4FastTrack& aFastTrack)
{
// Check energy
if(aFastTrack.GetPrimaryTrack()->GetKineticEnergy() < 1 * GeV)
{
if (aFastTrack.GetPrimaryTrack()->GetKineticEnergy() < 1 * GeV) {
return false;
}
// Check length of detector
@@ -77,14 +76,13 @@ G4bool Par03EMShowerModel::ModelTrigger(const G4FastTrack& aFastTrack)
// will fit inside. Required max shower depth is defined by fLongMaxDepth, and
// can be changed with UI command `/Par03/fastSim/longitudinalProfile/maxDepth
G4double X0 = aFastTrack.GetPrimaryTrack()->GetMaterial()->GetRadlen();
auto particleDirection = aFastTrack.GetPrimaryTrackLocalDirection();
auto particlePosition = aFastTrack.GetPrimaryTrackLocalPosition();
G4double detectorDepthInMM = aFastTrack.GetEnvelopeSolid()->DistanceToOut(
particlePosition, particleDirection);
auto particleDirection = aFastTrack.GetPrimaryTrackLocalDirection();
auto particlePosition = aFastTrack.GetPrimaryTrackLocalPosition();
G4double detectorDepthInMM =
aFastTrack.GetEnvelopeSolid()->DistanceToOut(particlePosition, particleDirection);
G4double detectorDepthInX0 = detectorDepthInMM / X0;
// check if detector depth is sufficient to create showers
if(detectorDepthInX0 < fLongMaxDepth)
{
if (detectorDepthInX0 < fLongMaxDepth) {
return false;
}
return true;
@@ -92,8 +90,7 @@ G4bool Par03EMShowerModel::ModelTrigger(const G4FastTrack& aFastTrack)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par03EMShowerModel::DoIt(const G4FastTrack& aFastTrack,
G4FastStep& aFastStep)
void Par03EMShowerModel::DoIt(const G4FastTrack& aFastTrack, G4FastStep& aFastStep)
{
// Remove particle from further processing by G4
aFastStep.KillPrimaryTrack();
@@ -102,42 +99,37 @@ void Par03EMShowerModel::DoIt(const G4FastTrack& aFastTrack,
// No need to create any deposit, it will be handled by this model (and
// G4FastSimHitMaker that will call the sensitive detector)
aFastStep.ProposeTotalEnergyDeposited(0);
auto particlePosition = aFastTrack.GetPrimaryTrackLocalPosition();
auto particlePosition = aFastTrack.GetPrimaryTrackLocalPosition();
auto particleDirection = aFastTrack.GetPrimaryTrackLocalDirection();
// Calculate how to create energy deposits
// Following PDG 33.5 chapter
// material calculation assumes homogeneous detector (true for Par03 example)
auto material = aFastTrack.GetPrimaryTrack()->GetMaterial();
auto material = aFastTrack.GetPrimaryTrack()->GetMaterial();
G4double materialX0 = material->GetRadlen();
G4double materialZ = material->GetZ();
G4double materialZ = material->GetZ();
// EC estimation follows PDG fit to solids in Fig. 33.14 (rms 2.2%)
G4double materialEc = 610 * MeV / (materialZ + 1.24);
// RM estimation follows PDG Eq. (33.37) (rms 2.2%)
G4double materialRM = 21.2052 * MeV * materialX0 / materialEc;
G4double particleY = energy / materialEc;
G4double particleY = energy / materialEc;
// Estimate shower maximum and alpha parameter of Gamma distribution
// that describes the longitudinal profile (PDG Eq. (33.35))
// unless alpha is specified by UI command
if(fAlpha < 0)
{
if (fAlpha < 0) {
// from PDG Eq. (33.36)
G4double particleTmax = std::log(particleY);
if(aFastTrack.GetPrimaryTrack()->GetParticleDefinition() ==
G4Gamma::GammaDefinition())
{
if (aFastTrack.GetPrimaryTrack()->GetParticleDefinition() == G4Gamma::GammaDefinition()) {
particleTmax += 0.5;
}
else
{
else {
particleTmax -= 0.5;
}
fAlpha = particleTmax * fBeta + 1;
}
// Unless sigma of Gaussian distribution describing the transverse profile
// is specified by UI command, use value calculated from Moliere Radius
if(fSigma < 0)
{
if (fSigma < 0) {
// 90% of shower is contained within 1 * R_M
// 1.645 * std dev of Gaussian contains 90%
fSigma = materialRM / 1.645;
@@ -146,13 +138,12 @@ void Par03EMShowerModel::DoIt(const G4FastTrack& aFastTrack,
// Calculate rotation matrix along the particle momentum direction
// It will rotate the shower axes to match the incoming particle direction
G4RotationMatrix rotMatrix = G4RotationMatrix();
double particleTheta = particleDirection.theta();
double particlePhi = particleDirection.phi();
double epsilon = 1e-3;
double particleTheta = particleDirection.theta();
double particlePhi = particleDirection.phi();
double epsilon = 1e-3;
rotMatrix.rotateY(particleTheta);
// do not use (random) phi if x==y==0
if(!(std::fabs(particleDirection.x()) < epsilon &&
std::fabs(particleDirection.y()) < epsilon))
if (!(std::fabs(particleDirection.x()) < epsilon && std::fabs(particleDirection.y()) < epsilon))
rotMatrix.rotateZ(particlePhi);
// Create hits
@@ -160,21 +151,19 @@ void Par03EMShowerModel::DoIt(const G4FastTrack& aFastTrack,
// then get random numbers from uniform distribution for azimuthal angle, and
// from Gaussian for radius
G4ThreeVector position;
G4double gammaMax = Gamma((fAlpha - 1) / fBeta, fAlpha, fBeta);
G4double gammaMax = Gamma((fAlpha - 1) / fBeta, fAlpha, fBeta);
G4int generatedHits = 0;
while(generatedHits < fNbOfHits)
{
while (generatedHits < fNbOfHits) {
G4double random1 = G4UniformRand() * fLongMaxDepth;
G4double random2 = G4UniformRand() * gammaMax;
if(Gamma(random1, fAlpha, fBeta) >= random2)
{
if (Gamma(random1, fAlpha, fBeta) >= random2) {
// Generate corresponding rho (phi) from Gaussian (flat) distribution
G4double phiPosition = G4UniformRand() * 2 * CLHEP::pi;
G4double rhoPosition = G4RandGauss::shoot(0, fSigma);
position = particlePosition +
rotMatrix * G4ThreeVector(rhoPosition * std::sin(phiPosition),
rhoPosition * std::cos(phiPosition),
random1 * materialX0);
position = particlePosition
+ rotMatrix
* G4ThreeVector(rhoPosition * std::sin(phiPosition),
rhoPosition * std::cos(phiPosition), random1 * materialX0);
// Create energy deposit in the detector
// This will call appropriate sensitive detector class
fHitMaker->make(G4FastHit(position, energy / fNbOfHits), aFastTrack);
@@ -190,17 +179,16 @@ void Par03EMShowerModel::Print() const
G4cout << "Par03EMShowerModel: " << G4endl;
G4cout << "Gaussian distribution (transverse plane): \tmu = 0, sigma = "
<< G4BestUnit(fSigma, "Length") << G4endl;
if(fSigma < 0)
if (fSigma < 0)
G4cout << "Negative sigma value means that it will be recalculated "
"from the value of the Moliere radius of the detector material, "
"taking into account that 90% of the area below the Gaussian "
"distribution (from mu - 1.645 sigma to mu + 1.645 sigma) "
"corresponds to area within 1 Moliere radius."
<< G4endl;
G4cout << "Gamma distribution (along shower axis): \talpha = " << fAlpha
<< ", beta = " << fBeta << ", max depth = " << fLongMaxDepth << " X0"
<< G4endl;
if(fAlpha < 0)
G4cout << "Gamma distribution (along shower axis): \talpha = " << fAlpha << ", beta = " << fBeta
<< ", max depth = " << fLongMaxDepth << " X0" << G4endl;
if (fAlpha < 0)
G4cout << "Negative alpha value means that it will be recalculated "
"from the critical energy of the detector material, particle "
"type, and beta parameter.\n alpha = beta * T_max, where T_max = "
@@ -24,20 +24,18 @@
// ********************************************************************
//
#include "Par03EventAction.hh"
#include "Par03Hit.hh"
#include "Par03DetectorConstruction.hh"
#include "Par03Hit.hh"
#include "G4AnalysisManager.hh"
#include "G4SDManager.hh"
#include "G4HCofThisEvent.hh"
#include "G4Event.hh"
#include "G4EventManager.hh"
#include "G4HCofThisEvent.hh"
#include "G4SDManager.hh"
Par03EventAction::Par03EventAction(Par03DetectorConstruction* aDetector)
: G4UserEventAction()
, fHitCollectionID(-1)
, fTimer()
, fDetector(aDetector)
: G4UserEventAction(), fHitCollectionID(-1), fTimer(), fDetector(aDetector)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -46,7 +44,10 @@ Par03EventAction::~Par03EventAction() = default;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Par03EventAction::BeginOfEventAction(const G4Event*) { fTimer.Start(); }
void Par03EventAction::BeginOfEventAction(const G4Event*)
{
fTimer.Start();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -54,71 +55,62 @@ void Par03EventAction::EndOfEventAction(const G4Event* aEvent)
{
fTimer.Stop();
// Get hits collection ID (only once)
if(fHitCollectionID == -1)
{
if (fHitCollectionID == -1) {
fHitCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("hits");
}
// Get hits collection
auto hitsCollection = static_cast<Par03HitsCollection*>(
aEvent->GetHCofThisEvent()->GetHC(fHitCollectionID));
auto hitsCollection =
static_cast<Par03HitsCollection*>(aEvent->GetHCofThisEvent()->GetHC(fHitCollectionID));
if(hitsCollection == nullptr)
{
if (hitsCollection == nullptr) {
G4ExceptionDescription msg;
msg << "Cannot access hitsCollection ID " << fHitCollectionID;
G4Exception("Par03EventAction::GetHitsCollection()", "MyCode0001",
FatalException, msg);
G4Exception("Par03EventAction::GetHitsCollection()", "MyCode0001", FatalException, msg);
}
// Get analysis manager
auto analysisManager = G4AnalysisManager::Instance();
// Retrieve only once detector dimensions
if(fCellSizeZ == 0)
{
fCellSizeZ = fDetector->GetLength() / fDetector->GetNbOfLayers();
if (fCellSizeZ == 0) {
fCellSizeZ = fDetector->GetLength() / fDetector->GetNbOfLayers();
fCellSizeRho = fDetector->GetRadius() / fDetector->GetNbOfRhoCells();
}
// Retrieve information from primary vertex and primary particle
// To calculate shower axis and entry point to the detector
auto primaryVertex = G4EventManager::GetEventManager()
->GetConstCurrentEvent()
->GetPrimaryVertex();
auto primaryParticle = primaryVertex->GetPrimary(0);
auto primaryVertex =
G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetPrimaryVertex();
auto primaryParticle = primaryVertex->GetPrimary(0);
G4double primaryEnergy = primaryParticle->GetTotalEnergy();
// Estimate from vertex and particle direction the entry point to the detector
// Calculate entrance point to the detector located at z = 0
auto primaryDirection = primaryParticle->GetMomentumDirection();
auto primaryEntrance = primaryVertex->GetPosition() -
primaryVertex->GetPosition().z() * primaryDirection;
auto primaryEntrance =
primaryVertex->GetPosition() - primaryVertex->GetPosition().z() * primaryDirection;
G4double cosDirection = std::cos(primaryDirection.theta());
G4double sinDirection = std::sin(primaryDirection.theta());
// Fill histograms
Par03Hit* hit = nullptr;
G4double hitEn = 0;
Par03Hit* hit = nullptr;
G4double hitEn = 0;
G4double totalEnergy = 0;
G4int hitZ = -1;
G4int hitRho = -1;
G4int hitType = -1;
G4int hitZ = -1;
G4int hitRho = -1;
G4int hitType = -1;
G4double tDistance = 0., rDistance = 0.;
G4double tFirstMoment = 0., tSecondMoment = 0.;
G4double rFirstMoment = 0., rSecondMoment = 0.;
for(size_t iHit = 0; iHit < hitsCollection->entries(); iHit++)
{
hit = static_cast<Par03Hit*>(hitsCollection->GetHit(iHit));
hitZ = hit->GetZid();
hitRho = hit->GetRhoId();
hitEn = hit->GetEdep();
for (size_t iHit = 0; iHit < hitsCollection->entries(); iHit++) {
hit = static_cast<Par03Hit*>(hitsCollection->GetHit(iHit));
hitZ = hit->GetZid();
hitRho = hit->GetRhoId();
hitEn = hit->GetEdep();
hitType = hit->GetType();
if(hitEn > 0)
{
if (hitEn > 0) {
totalEnergy += hitEn;
tDistance =
hitZ * fCellSizeZ * cosDirection +
(hitRho * fCellSizeRho - primaryEntrance.perp()) * sinDirection;
rDistance =
hitZ * fCellSizeZ * (-sinDirection) +
(hitRho * fCellSizeRho - primaryEntrance.perp()) * cosDirection;
tDistance = hitZ * fCellSizeZ * cosDirection
+ (hitRho * fCellSizeRho - primaryEntrance.perp()) * sinDirection;
rDistance = hitZ * fCellSizeZ * (-sinDirection)
+ (hitRho * fCellSizeRho - primaryEntrance.perp()) * cosDirection;
tFirstMoment += hitEn * tDistance;
rFirstMoment += hitEn * rDistance;
analysisManager->FillH1(4, tDistance, hitEn);
@@ -136,18 +128,16 @@ void Par03EventAction::EndOfEventAction(const G4Event* aEvent)
analysisManager->FillH1(7, rFirstMoment);
// Second loop over hits to calculate second moments
for(size_t iHit = 0; iHit < hitsCollection->entries(); iHit++)
{
hit = static_cast<Par03Hit*>(hitsCollection->GetHit(iHit));
hitEn = hit->GetEdep();
hitZ = hit->GetZid();
for (size_t iHit = 0; iHit < hitsCollection->entries(); iHit++) {
hit = static_cast<Par03Hit*>(hitsCollection->GetHit(iHit));
hitEn = hit->GetEdep();
hitZ = hit->GetZid();
hitRho = hit->GetRhoId();
if(hitEn > 0)
{
tDistance = hitZ * fCellSizeZ * cosDirection +
(hitRho * fCellSizeRho - primaryEntrance.r()) * sinDirection;
rDistance = hitZ * fCellSizeZ * (-sinDirection) +
(hitRho * fCellSizeRho - primaryEntrance.r()) * cosDirection;
if (hitEn > 0) {
tDistance = hitZ * fCellSizeZ * cosDirection
+ (hitRho * fCellSizeRho - primaryEntrance.r()) * sinDirection;
rDistance = hitZ * fCellSizeZ * (-sinDirection)
+ (hitRho * fCellSizeRho - primaryEntrance.r()) * cosDirection;
tSecondMoment += hitEn * std::pow(tDistance - tFirstMoment, 2);
rSecondMoment += hitEn * std::pow(rDistance - rFirstMoment, 2);
}
@@ -25,22 +25,20 @@
//
#include "Par03Hit.hh"
#include "G4VisAttributes.hh"
#include "G4Tubs.hh"
#include "G4Colour.hh"
#include "G4AttDefStore.hh"
#include "G4AttDef.hh"
#include "G4AttDefStore.hh"
#include "G4AttValue.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "G4VVisManager.hh"
#include "G4Colour.hh"
#include "G4LogicalVolume.hh"
#include "G4SystemOfUnits.hh"
#include "G4Tubs.hh"
#include "G4UnitsTable.hh"
#include "G4VVisManager.hh"
#include "G4VisAttributes.hh"
G4ThreadLocal G4Allocator<Par03Hit>* Par03HitAllocator;
Par03Hit::Par03Hit()
: G4VHit()
{}
Par03Hit::Par03Hit() : G4VHit() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -48,17 +46,16 @@ Par03Hit::~Par03Hit() = default;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par03Hit::Par03Hit(const Par03Hit& aRight)
: G4VHit()
Par03Hit::Par03Hit(const Par03Hit& aRight) : G4VHit()
{
fEdep = aRight.fEdep;
fZId = aRight.fZId;
fRhoId = aRight.fRhoId;
fPhiId = aRight.fPhiId;
fTime = aRight.fTime;
fPos = aRight.fPos;
fRot = aRight.fRot;
fType = aRight.fType;
fEdep = aRight.fEdep;
fZId = aRight.fZId;
fRhoId = aRight.fRhoId;
fPhiId = aRight.fPhiId;
fTime = aRight.fTime;
fPos = aRight.fPos;
fRot = aRight.fRot;
fType = aRight.fType;
fLogVol = aRight.fLogVol;
}
@@ -66,14 +63,14 @@ Par03Hit::Par03Hit(const Par03Hit& aRight)
const Par03Hit& Par03Hit::operator=(const Par03Hit& aRight)
{
fEdep = aRight.fEdep;
fZId = aRight.fZId;
fRhoId = aRight.fRhoId;
fPhiId = aRight.fPhiId;
fTime = aRight.fTime;
fPos = aRight.fPos;
fRot = aRight.fRot;
fType = aRight.fType;
fEdep = aRight.fEdep;
fZId = aRight.fZId;
fRhoId = aRight.fRhoId;
fPhiId = aRight.fPhiId;
fTime = aRight.fTime;
fPos = aRight.fPos;
fRot = aRight.fRot;
fType = aRight.fType;
fLogVol = aRight.fLogVol;
return *this;
}
@@ -82,8 +79,7 @@ const Par03Hit& Par03Hit::operator=(const Par03Hit& aRight)
int Par03Hit::operator==(const Par03Hit& aRight) const
{
return (fRhoId == aRight.fRhoId && fPhiId == aRight.fPhiId &&
fZId == aRight.fZId);
return (fRhoId == aRight.fRhoId && fPhiId == aRight.fPhiId && fZId == aRight.fZId);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -92,25 +88,20 @@ void Par03Hit::Draw()
{
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
// Hits can be filtered out in visualisation
if(!pVVisManager->FilterHit(*this))
return;
if (!pVVisManager->FilterHit(*this)) return;
// Do not draw empty hits
if(fEdep < 0)
return;
if(pVVisManager)
{
if (fEdep < 0) return;
if (pVVisManager) {
G4Transform3D trans(fRot, fPos);
G4VisAttributes attribs;
// Create default dimensions
G4Tubs solid("draw", 0, 1 * cm, 1 * cm, 0, 0.05 * CLHEP::pi);
if(fLogVol)
{
if (fLogVol) {
const G4VisAttributes* pVA = fLogVol->GetVisAttributes();
if(pVA)
attribs = *pVA;
if (pVA) attribs = *pVA;
// Cannot use directly fLogVol due to rho parametrisation (change of
// solid!) Recalculation of radius is needed
solid = *dynamic_cast<G4Tubs*>(fLogVol->GetSolid());
solid = *dynamic_cast<G4Tubs*>(fLogVol->GetSolid());
double dR = solid.GetOuterRadius() - solid.GetInnerRadius();
solid.SetInnerRadius(solid.GetInnerRadius() + fRhoId * dR);
solid.SetOuterRadius(solid.GetOuterRadius() + fRhoId * dR);
@@ -131,18 +122,13 @@ void Par03Hit::Draw()
const std::map<G4String, G4AttDef>* Par03Hit::GetAttDefs() const
{
G4bool isNew;
std::map<G4String, G4AttDef>* store =
G4AttDefStore::GetInstance("Par03Hit", isNew);
if(isNew)
{
(*store)["HitType"] =
G4AttDef("HitType", "Hit Type", "Physics", "", "G4String");
(*store)["Energy"] = G4AttDef("Energy", "Energy Deposited", "Physics",
"G4BestUnit", "G4double");
(*store)["Time"] =
G4AttDef("Time", "Time", "Physics", "G4BestUnit", "G4double");
(*store)["Pos"] =
G4AttDef("Pos", "Position", "Physics", "G4BestUnit", "G4ThreeVector");
std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("Par03Hit", isNew);
if (isNew) {
(*store)["HitType"] = G4AttDef("HitType", "Hit Type", "Physics", "", "G4String");
(*store)["Energy"] =
G4AttDef("Energy", "Energy Deposited", "Physics", "G4BestUnit", "G4double");
(*store)["Time"] = G4AttDef("Time", "Time", "Physics", "G4BestUnit", "G4double");
(*store)["Pos"] = G4AttDef("Pos", "Position", "Physics", "G4BestUnit", "G4ThreeVector");
}
return store;
}
@@ -163,7 +149,6 @@ std::vector<G4AttValue>* Par03Hit::CreateAttValues() const
void Par03Hit::Print()
{
std::cout << "\tHit " << fEdep / MeV << " MeV at " << fPos / cm
<< " cm (R,phi,z)= (" << fRhoId << ", " << fPhiId << ", " << fZId
<< "), " << fTime << " ns" << std::endl;
std::cout << "\tHit " << fEdep / MeV << " MeV at " << fPos / cm << " cm (R,phi,z)= (" << fRhoId
<< ", " << fPhiId << ", " << fZId << "), " << fTime << " ns" << std::endl;
}
@@ -30,16 +30,14 @@
#include "G4SystemOfUnits.hh"
Par03PrimaryGeneratorAction::Par03PrimaryGeneratorAction()
: G4VUserPrimaryGeneratorAction()
, fParticleGun(nullptr)
: G4VUserPrimaryGeneratorAction(), fParticleGun(nullptr)
{
G4int n_particle = 1;
fParticleGun = new G4ParticleGun(n_particle);
fParticleGun = new G4ParticleGun(n_particle);
// Default particle properties
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4String particleName;
G4ParticleDefinition* particle =
particleTable->FindParticle(particleName = "e-");
G4ParticleDefinition* particle = particleTable->FindParticle(particleName = "e-");
fParticleGun->SetParticleDefinition(particle);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0., 0., 1.));
fParticleGun->SetParticleEnergy(10. * GeV);
@@ -48,7 +46,10 @@ Par03PrimaryGeneratorAction::Par03PrimaryGeneratorAction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par03PrimaryGeneratorAction::~Par03PrimaryGeneratorAction() { delete fParticleGun; }
Par03PrimaryGeneratorAction::~Par03PrimaryGeneratorAction()
{
delete fParticleGun;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -24,13 +24,13 @@
// ********************************************************************
//
#include "Par03RunAction.hh"
#include "Par03DetectorConstruction.hh"
#include "G4AnalysisManager.hh"
Par03RunAction::Par03RunAction(Par03DetectorConstruction* aDetector)
: G4UserRunAction()
, fDetector(aDetector)
: G4UserRunAction(), fDetector(aDetector)
{
// Create analysis manager
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
@@ -49,9 +49,9 @@ Par03RunAction::~Par03RunAction() = default;
void Par03RunAction::BeginOfRunAction(const G4Run*)
{
// Get detector dimensions
G4int cellNumZ = fDetector->GetNbOfLayers();
G4int cellNumRho = fDetector->GetNbOfRhoCells();
G4double cellSizeZ = fDetector->GetLength() / cellNumZ;
G4int cellNumZ = fDetector->GetNbOfLayers();
G4int cellNumRho = fDetector->GetNbOfRhoCells();
G4double cellSizeZ = fDetector->GetLength() / cellNumZ;
G4double cellSizeRho = fDetector->GetRadius() / cellNumRho;
// Default max value of energy stored in histogram (in GeV)
G4double maxEnergy = 100;
@@ -60,50 +60,36 @@ void Par03RunAction::BeginOfRunAction(const G4Run*)
auto analysisManager = G4AnalysisManager::Instance();
// Creating control histograms
analysisManager->CreateH1("energyParticle",
"Primary energy;E_{MC} (GeV);Entries", 256, 0,
analysisManager->CreateH1("energyParticle", "Primary energy;E_{MC} (GeV);Entries", 256, 0,
1.1 * maxEnergy);
analysisManager->CreateH1("energyDeposited",
"Deposited energy;E_{MC} (GeV);Entries", 256, 0,
analysisManager->CreateH1("energyDeposited", "Deposited energy;E_{MC} (GeV);Entries", 256, 0,
1.1 * maxEnergy);
analysisManager->CreateH1(
"energyRatio",
"Ratio of energy deposited to primary;E_{dep} / E_{MC};Entries", 1024, 0,
1);
analysisManager->CreateH1("time", "Simulation time; time (s);Entries", 2048,
0, 30);
analysisManager->CreateH1(
"longProfile", "Longitudinal profile;t (mm);#LTE#GT (MeV)", cellNumZ,
-0.5 * cellSizeZ, (cellNumZ - 0.5) * cellSizeZ);
analysisManager->CreateH1(
"transProfile", "Transverse profile;r (mm);#LTE#GT (MeV)", cellNumRho,
-0.5 * cellSizeRho, (cellNumRho - 0.5) * cellSizeRho);
analysisManager->CreateH1(
"longFirstMoment",
"First moment of longitudinal distribution;#LT#lambda#GT (mm);Entries",
1024, -0.5 * cellSizeZ,
cellNumZ * cellSizeZ / 2); // arbitrary scaling of max value on axis
"energyRatio", "Ratio of energy deposited to primary;E_{dep} / E_{MC};Entries", 1024, 0, 1);
analysisManager->CreateH1("time", "Simulation time; time (s);Entries", 2048, 0, 30);
analysisManager->CreateH1("longProfile", "Longitudinal profile;t (mm);#LTE#GT (MeV)", cellNumZ,
-0.5 * cellSizeZ, (cellNumZ - 0.5) * cellSizeZ);
analysisManager->CreateH1("transProfile", "Transverse profile;r (mm);#LTE#GT (MeV)", cellNumRho,
-0.5 * cellSizeRho, (cellNumRho - 0.5) * cellSizeRho);
analysisManager->CreateH1("longFirstMoment",
"First moment of longitudinal distribution;#LT#lambda#GT (mm);Entries",
1024, -0.5 * cellSizeZ,
cellNumZ * cellSizeZ / 2); // arbitrary scaling of max value on axis
analysisManager->CreateH1("transFirstMoment",
"First moment of transverse distribution;#LTr#GT "
"(mm);Entries",
1024, -0.5 * cellSizeRho,
cellNumRho * cellSizeRho /
10); // arbitrary scaling of max value on axis
cellNumRho * cellSizeRho
/ 10); // arbitrary scaling of max value on axis
analysisManager->CreateH1(
"longSecondMoment",
"Second moment of longitudinal distribution;#LT#lambda^{2}#GT "
"(mm^{2});Entries",
1024, 0,
std::pow(cellNumZ * cellSizeZ, 2) /
25); // arbitrary scaling of max value on axis
1024, 0, std::pow(cellNumZ * cellSizeZ, 2) / 25); // arbitrary scaling of max value on axis
analysisManager->CreateH1(
"transSecondMoment",
"Second moment of transverse distribution;#LTr^{2}#GT (mm^{2});Entries",
1024, 0,
std::pow(cellNumRho * cellSizeRho, 2) /
25); // arbitrary scaling of max value on axis
analysisManager->CreateH1(
"hitType", "hit type;type (0=full, 1= fast);Entries", 2, -0.5, 1.5);
"transSecondMoment", "Second moment of transverse distribution;#LTr^{2}#GT (mm^{2});Entries",
1024, 0, std::pow(cellNumRho * cellSizeRho, 2) / 25); // arbitrary scaling of max value on axis
analysisManager->CreateH1("hitType", "hit type;type (0=full, 1= fast);Entries", 2, -0.5, 1.5);
// Open an output file
analysisManager->OpenFile();
@@ -24,27 +24,24 @@
// ********************************************************************
//
#include "Par03SensitiveDetector.hh"
#include "Par03Hit.hh"
#include "G4HCofThisEvent.hh"
#include "G4SDManager.hh"
#include "G4Step.hh"
#include "G4TouchableHistory.hh"
#include "G4Track.hh"
#include "G4Step.hh"
#include "G4SDManager.hh"
Par03SensitiveDetector::Par03SensitiveDetector(G4String aName)
: G4VSensitiveDetector(aName)
Par03SensitiveDetector::Par03SensitiveDetector(G4String aName) : G4VSensitiveDetector(aName)
{
collectionName.insert("hits");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par03SensitiveDetector::Par03SensitiveDetector(G4String aName, G4int aNumLayers,
G4int aNumRho, G4int aNumPhi)
: G4VSensitiveDetector(aName)
, fCellNoZ(aNumLayers)
, fCellNoRho(aNumRho)
, fCellNoPhi(aNumPhi)
Par03SensitiveDetector::Par03SensitiveDetector(G4String aName, G4int aNumLayers, G4int aNumRho,
G4int aNumPhi)
: G4VSensitiveDetector(aName), fCellNoZ(aNumLayers), fCellNoRho(aNumRho), fCellNoPhi(aNumPhi)
{
collectionName.insert("hits");
}
@@ -57,21 +54,17 @@ Par03SensitiveDetector::~Par03SensitiveDetector() = default;
void Par03SensitiveDetector::Initialize(G4HCofThisEvent* aHCE)
{
fHitsCollection =
new Par03HitsCollection(SensitiveDetectorName, collectionName[0]);
if(fHitCollectionID < 0)
{
fHitCollectionID =
G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection);
fHitsCollection = new Par03HitsCollection(SensitiveDetectorName, collectionName[0]);
if (fHitCollectionID < 0) {
fHitCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection);
}
aHCE->AddHitsCollection(fHitCollectionID, fHitsCollection);
// fill calorimeter hits with zero energy deposition
for(G4int iphi = 0; iphi < fCellNoPhi; iphi++)
for(G4int irho = 0; irho < fCellNoRho; irho++)
for(G4int iz = 0; iz < fCellNoZ; iz++)
{
auto hit = new Par03Hit();
for (G4int iphi = 0; iphi < fCellNoPhi; iphi++)
for (G4int irho = 0; irho < fCellNoRho; irho++)
for (G4int iz = 0; iz < fCellNoZ; iz++) {
auto hit = new Par03Hit();
fHitsCollection->insert(hit);
}
}
@@ -81,11 +74,9 @@ void Par03SensitiveDetector::Initialize(G4HCofThisEvent* aHCE)
G4bool Par03SensitiveDetector::ProcessHits(G4Step* aStep, G4TouchableHistory*)
{
G4double edep = aStep->GetTotalEnergyDeposit();
if(edep == 0.)
return true;
if (edep == 0.) return true;
auto aTouchable =
(G4TouchableHistory*) (aStep->GetPreStepPoint()->GetTouchable());
auto aTouchable = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable());
auto hit = RetrieveAndSetupHit(aTouchable);
@@ -94,27 +85,23 @@ G4bool Par03SensitiveDetector::ProcessHits(G4Step* aStep, G4TouchableHistory*)
// Fill time information from G4Step
// If it's already filled, choose hit with earliest global time
if(hit->GetTime() == -1 ||
hit->GetTime() > aStep->GetTrack()->GetGlobalTime())
if (hit->GetTime() == -1 || hit->GetTime() > aStep->GetTrack()->GetGlobalTime())
hit->SetTime(aStep->GetTrack()->GetGlobalTime());
// Set hit type to full simulation (only if hit is not already marked as fast
// sim)
if(hit->GetType() != 1)
hit->SetType(0);
if (hit->GetType() != 1) hit->SetType(0);
return true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool Par03SensitiveDetector::ProcessHits(const G4FastHit* aHit,
const G4FastTrack* aTrack,
G4bool Par03SensitiveDetector::ProcessHits(const G4FastHit* aHit, const G4FastTrack* aTrack,
G4TouchableHistory* aTouchable)
{
G4double edep = aHit->GetEnergy();
if(edep == 0.)
return true;
if (edep == 0.) return true;
auto hit = RetrieveAndSetupHit(aTouchable);
@@ -123,9 +110,7 @@ G4bool Par03SensitiveDetector::ProcessHits(const G4FastHit* aHit,
// Fill time information from G4FastTrack
// If it's already filled, choose hit with earliest global time
if(hit->GetTime() == -1 ||
hit->GetTime() > aTrack->GetPrimaryTrack()->GetGlobalTime())
{
if (hit->GetTime() == -1 || hit->GetTime() > aTrack->GetPrimaryTrack()->GetGlobalTime()) {
hit->SetTime(aTrack->GetPrimaryTrack()->GetGlobalTime());
}
@@ -138,27 +123,22 @@ G4bool Par03SensitiveDetector::ProcessHits(const G4FastHit* aHit,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Par03Hit* Par03SensitiveDetector::RetrieveAndSetupHit(
G4TouchableHistory* aTouchable)
Par03Hit* Par03SensitiveDetector::RetrieveAndSetupHit(G4TouchableHistory* aTouchable)
{
G4int rhoNo = aTouchable->GetCopyNumber(0); // cell
G4int phiNo = aTouchable->GetCopyNumber(1); // segment
G4int zNo = aTouchable->GetCopyNumber(2); // layer
G4int zNo = aTouchable->GetCopyNumber(2); // layer
std::size_t hitID = fCellNoRho * fCellNoZ * phiNo + fCellNoZ * rhoNo + zNo;
if(hitID >= fHitsCollection->entries())
{
G4Exception(
"Par03SensitiveDetector::RetrieveAndSetupHit()", "InvalidSetup",
FatalException,
"Size of hit collection in Par03SensitiveDetector is smaller than the "
"number of cells created in Par03DetectorConstruction!");
if (hitID >= fHitsCollection->entries()) {
G4Exception("Par03SensitiveDetector::RetrieveAndSetupHit()", "InvalidSetup", FatalException,
"Size of hit collection in Par03SensitiveDetector is smaller than the "
"number of cells created in Par03DetectorConstruction!");
}
Par03Hit* hit = (*fHitsCollection)[hitID];
if(hit->GetRhoId() < 0)
{
if (hit->GetRhoId() < 0) {
hit->SetRhoId(rhoNo);
hit->SetPhiId(phiNo);
hit->SetZid(zNo);
@@ -6,13 +6,13 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2024-06-18 Gabriele Cosmo (expar04-V11-01-04)
## 2024-06-18 Gabriele Cosmo (expar04-V11-02-02)
- Bump scikit-learn version from [GitHub Dependabot PR](https://github.com/Geant4/geant4/pull/73)
## 2024-06-13 Gabriele Cosmo (expar04-V11-01-03)
## 2024-06-13 Gabriele Cosmo (expar04-V11-02-01)
- Bump pymysql version from [GitHub Dependabot PR](https://github.com/Geant4/geant4/pull/72)
## 2024-03-11 Ben Morgan
## 2024-03-11 Ben Morgan (expar04-V11-02-00)
- Bump scipy version from [GitHub Dependabot PR](https://github.com/Geant4/geant4/pull/66)
## 2023-10-25 Dalila Salamani (expar04-V11-01-02)
@@ -35,31 +35,31 @@
// for fast simulation in calorimeters.
//
//-------------------------------------------------------------------
#include "FTFP_BERT.hh" // for FTFP_BERT
#include "FTFP_BERT.hh" // for FTFP_BERT
#include "Par04ActionInitialisation.hh" // for Par04ActionInitialisation
#include "Par04DetectorConstruction.hh" // for Par04DetectorConstruction
#include "Par04ParallelFastWorld.hh"
#include "Par04ParallelFullWorld.hh"
#include "G4EmParameters.hh" // for G4EmParameters
#include "G4FastSimulationPhysics.hh" // for G4FastSimulationPhysics
#include "G4HadronicProcessStore.hh" // for G4HadronicProcessStore
#include "G4EmParameters.hh" // for G4EmParameters
#include "G4Exception.hh" // for G4Exception
#include "G4ExceptionSeverity.hh" // for FatalErrorInArgument
#include "G4FastSimulationPhysics.hh" // for G4FastSimulationPhysics
#include "G4HadronicProcessStore.hh" // for G4HadronicProcessStore
#include "G4ParallelWorldPhysics.hh"
#include "G4RunManagerFactory.hh" // for G4RunManagerFactory, G4RunMa...
#include "G4Types.hh" // for G4bool, G4int
#include "G4UIExecutive.hh" // for G4UIExecutive
#include "G4UImanager.hh" // for G4UImanager
#include "G4VisExecutive.hh" // for G4VisExecutive
#include "G4RunManager.hh" // for G4RunManager
#include "G4RunManagerFactory.hh" // for G4RunManagerFactory, G4RunMa...
#include "G4String.hh" // for G4String
#include "G4Types.hh" // for G4bool, G4int
#include "G4UIExecutive.hh" // for G4UIExecutive
#include "G4UImanager.hh" // for G4UImanager
#include "G4VisExecutive.hh" // for G4VisExecutive
#include "G4VisManager.hh" // for G4VisManager
#include "G4ios.hh" // for G4cout, G4endl
#include "G4Exception.hh" // for G4Exception
#include "G4ExceptionSeverity.hh" // for FatalErrorInArgument
#include "G4RunManager.hh" // for G4RunManager
#include "G4String.hh" // for G4String
#include "G4VisManager.hh" // for G4VisManager
#include "G4ios.hh" // for G4cout, G4endl
#include <ctime> // for time
#include <sstream> // for char_traits, operator<<, bas...
#include <string> // for allocator, operator+, operat...
#include <ctime> // for time
#include <sstream> // for char_traits, operator<<, bas...
#include <string> // for allocator, operator+, operat...
int main(int argc, char** argv)
{
@@ -77,90 +77,79 @@ int main(int argc, char** argv)
"\n\t-r\t\trun manager type (0=serial,1=MT,2=tasking)"
"\n\t-t\t\tnumber of threads for MT mode (no change for other modes)."
);
if(argc < 2 ) {
if (argc < 2) {
G4Exception("main", "No arguments", FatalErrorInArgument,
("No arguments passed to " + G4String(argv[0]) + "\n" + helpMsg)
.c_str());
("No arguments passed to " + G4String(argv[0]) + "\n" + helpMsg).c_str());
}
for(G4int i = 1; i < argc; ++i)
{
for (G4int i = 1; i < argc; ++i) {
G4String argument(argv[i]);
if(argument == "-h" || argument == "--help")
{
if (argument == "-h" || argument == "--help") {
G4cout << helpMsg << G4endl;
return 0;
}
else if(argument == "-m")
{
batchMacroName = G4String(argv[i + 1]);
else if (argument == "-m") {
batchMacroName = G4String(argv[i + 1]);
++i;
}
else if(argument == "-i")
{
else if (argument == "-i") {
useInteractiveMode = true;
}
else if(argument == "-r")
{
else if (argument == "-r") {
G4int tmp = atoi(argv[i + 1]);
++i;
switch (tmp) {
case 0:
runManagerTypeInt = tmp;
runManagerType = G4RunManagerType::Serial;
break;
case 1:
runManagerTypeInt = tmp;
runManagerType = G4RunManagerType::MTOnly;
break;
case 2:
runManagerTypeInt = tmp;
runManagerType = G4RunManagerType::Tasking;
break;
default:
G4Exception("main", "Wrong Run Manager type", FatalErrorInArgument,
"Choose 0 (serial, default), 1 (MT), 2 (tasking)");
break;
case 0:
runManagerTypeInt = tmp;
runManagerType = G4RunManagerType::Serial;
break;
case 1:
runManagerTypeInt = tmp;
runManagerType = G4RunManagerType::MTOnly;
break;
case 2:
runManagerTypeInt = tmp;
runManagerType = G4RunManagerType::Tasking;
break;
default:
G4Exception("main", "Wrong Run Manager type", FatalErrorInArgument,
"Choose 0 (serial, default), 1 (MT), 2 (tasking)");
break;
}
}
else if(argument == "-t")
{
else if (argument == "-t") {
numOfThreadsOrTasks = atoi(argv[i + 1]);
++i;
}
else
{
G4Exception("main", "Unknown argument", FatalErrorInArgument,
("Unknown argument passed to " + G4String(argv[0]) + " : " +
argument + "\n" + helpMsg)
.c_str());
else {
G4Exception(
"main", "Unknown argument", FatalErrorInArgument,
("Unknown argument passed to " + G4String(argv[0]) + " : " + argument + "\n" + helpMsg)
.c_str());
}
}
//choose the Random engine
// choose the Random engine
CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine());
//set random seed with system time
// set random seed with system time
G4long seed = time(NULL);
CLHEP::HepRandom::setTheSeed(seed);
// Instantiate G4UIExecutive if interactive mode
G4UIExecutive* ui = nullptr;
if(useInteractiveMode)
{
if (useInteractiveMode) {
ui = new G4UIExecutive(argc, argv);
runManagerType = G4RunManagerType::Serial;
}
// Initialization of default Run manager
auto* runManager =
G4RunManagerFactory::CreateRunManager(runManagerType);
if(runManagerTypeInt == 1)
runManager->SetNumberOfThreads(numOfThreadsOrTasks);
auto* runManager = G4RunManagerFactory::CreateRunManager(runManagerType);
if (runManagerTypeInt == 1) runManager->SetNumberOfThreads(numOfThreadsOrTasks);
// Detector geometry:
auto detector = new Par04DetectorConstruction();
auto parallelWorldFull = new Par04ParallelFullWorld("parallelWorldFullSim", detector);
auto parallelWorldFast = new Par04ParallelFastWorld("parallelWorldFastSim", detector,
parallelWorldFull);
auto parallelWorldFast =
new Par04ParallelFastWorld("parallelWorldFastSim", detector, parallelWorldFull);
detector->RegisterParallelWorld(parallelWorldFull);
detector->RegisterParallelWorld(parallelWorldFast);
runManager->SetUserInitialization(detector);
@@ -175,8 +164,8 @@ int main(int argc, char** argv)
fastSimulationPhysics->ActivateFastSimulation("gamma");
physicsList->RegisterPhysics(fastSimulationPhysics);
// Add parallel world for readout
physicsList->RegisterPhysics( new G4ParallelWorldPhysics("parallelWorldFullSim") );
physicsList->RegisterPhysics( new G4ParallelWorldPhysics("parallelWorldFastSim") );
physicsList->RegisterPhysics(new G4ParallelWorldPhysics("parallelWorldFullSim"));
physicsList->RegisterPhysics(new G4ParallelWorldPhysics("parallelWorldFastSim"));
// reduce verbosity of physics lists
G4EmParameters::Instance()->SetVerbose(0);
runManager->SetUserInitialization(physicsList);
@@ -193,21 +182,17 @@ int main(int argc, char** argv)
visManager->Initialize();
G4UImanager* UImanager = G4UImanager::GetUIpointer();
if(useInteractiveMode)
{
if(batchMacroName.empty())
{
if (useInteractiveMode) {
if (batchMacroName.empty()) {
G4Exception("main", "Unknown macro name", FatalErrorInArgument,
("No macro name passed to " + G4String(argv[0]))
.c_str());
("No macro name passed to " + G4String(argv[0])).c_str());
}
G4String command = "/control/execute ";
UImanager->ApplyCommand(command + batchMacroName);
ui->SessionStart();
delete ui;
}
else
{
else {
G4String command = "/control/execute ";
UImanager->ApplyCommand(command + batchMacroName);
}
@@ -11,7 +11,7 @@ Environment variable "G4FORCE_RUN_MANAGER_TYPE" enabled with value == Serial. Fo
**************************************************************
Geant4 version Name: geant4-11-02-patch-02 (21-June-2024)
Geant4 version Name: geant4-11-02-ref-06 (28-June-2024)
Copyright : Geant4 Collaboration
References : NIM A 506 (2003), 250-303
: IEEE-TNS 53 (2006), 270-278
@@ -45,14 +45,21 @@ Registered graphics systems are:
RayTracerX (RayTracerX)
Qt3D (Qt3D)
TOOLSSG_X11_GLES (TSG_X11_GLES, TSGX11, TSG_XT_GLES_FALLBACK)
TOOLSSG_X11_ZB (TSG_X11_ZB, TSGX11ZB)
TOOLSSG_XT_GLES (TSG_XT_GLES, TSGXt, TSG_QT_GLES_FALLBACK)
TOOLSSG_XT_ZB (TSG_XT_ZB, TSGXtZB)
TOOLSSG_QT_GLES (TSG_QT_GLES, TSGQt, TSG)
TOOLSSG_QT_ZB (TSG_QT_ZB, TSGQtZB)
Default graphics system is: TSG_OFFSCREEN (based on batch session).
Default window size hint is: 600x600-0+0 (based on G4VisManager initialisation).
Note: Parameters specified on the command line will override these defaults.
Use "vis/open" without parameters to get these defaults.
You may choose a graphics system (driver) with a parameter of
the command "/vis/open" or "/vis/sceneHandler/create",
or you may omit the driver parameter and choose at run time:
- by argument in the construction of G4VisExecutive
- by environment variable "G4VIS_DEFAULT_DRIVER"
- by entry in "~/.g4session"
- by build flags.
- Note: This feature is not allowed in batch mode.
For further information see "examples/basic/B1/exampleB1.cc"
and "vis.mac".
Registering model factories...
@@ -41,20 +41,20 @@ class Par04ParallelFullWorld;
class Par04ActionInitialisation : public G4VUserActionInitialization
{
public:
Par04ActionInitialisation(Par04DetectorConstruction* aDetector,
Par04ParallelFullWorld* aParallel);
~Par04ActionInitialisation();
/// Create all user actions.
virtual void Build() const final;
/// Create run action in the master thread to allow analysis merging.
virtual void BuildForMaster() const final;
public:
Par04ActionInitialisation(Par04DetectorConstruction* aDetector,
Par04ParallelFullWorld* aParallel);
~Par04ActionInitialisation();
/// Create all user actions.
virtual void Build() const final;
/// Create run action in the master thread to allow analysis merging.
virtual void BuildForMaster() const final;
private:
/// Pointer to detector to be passed to event and run actions in order to
/// retrieve detector dimensions
Par04DetectorConstruction* fDetector = nullptr;
Par04ParallelFullWorld* fParallel = nullptr;
private:
/// Pointer to detector to be passed to event and run actions in order to
/// retrieve detector dimensions
Par04DetectorConstruction* fDetector = nullptr;
Par04ParallelFullWorld* fParallel = nullptr;
};
#endif /* PAR04ACTIONINITIALISATION_HH */
@@ -26,9 +26,10 @@
#ifndef PAR04DEFINEMESHMODEL_HH
#define PAR04DEFINEMESHMODEL_HH
#include <G4String.hh> // for G4String
#include <G4Types.hh> // for G4bool
#include "G4VFastSimulationModel.hh" // for G4VFastSimulationModel
#include <G4String.hh> // for G4String
#include <G4Types.hh> // for G4bool
class G4FastStep;
class G4FastTrack;
class G4ParticleDefinition;
@@ -46,20 +47,20 @@ class G4Region;
class Par04DefineMeshModel : public G4VFastSimulationModel
{
public:
Par04DefineMeshModel(G4String, G4Region*);
Par04DefineMeshModel(G4String);
~Par04DefineMeshModel();
public:
Par04DefineMeshModel(G4String, G4Region*);
Par04DefineMeshModel(G4String);
~Par04DefineMeshModel();
/// Check if particle is entering the volume. Check particle energy. It must be
/// no smaller than 99% of the primary particle energy. This is to ensure that in case of
/// prior interactions, particle energy does not differ (much) from the assumed
/// energy.
virtual G4bool ModelTrigger(const G4FastTrack&) final;
/// Model is applicable to all particles.
virtual G4bool IsApplicable(const G4ParticleDefinition&) final;
/// Check particle direction, entrance point, and store it in event information.
/// Then go back to the full simulation.
virtual void DoIt(const G4FastTrack&, G4FastStep&) final;
/// Check if particle is entering the volume. Check particle energy. It must be
/// no smaller than 99% of the primary particle energy. This is to ensure that in case of
/// prior interactions, particle energy does not differ (much) from the assumed
/// energy.
virtual G4bool ModelTrigger(const G4FastTrack&) final;
/// Model is applicable to all particles.
virtual G4bool IsApplicable(const G4ParticleDefinition&) final;
/// Check particle direction, entrance point, and store it in event information.
/// Then go back to the full simulation.
virtual void DoIt(const G4FastTrack&, G4FastStep&) final;
};
#endif /* PAR04DEFINEMESHMODEL_HH */
@@ -26,16 +26,17 @@
#ifndef PAR04DETECTORCONSTRUCTION_H
#define PAR04DETECTORCONSTRUCTION_H
#include <CLHEP/Units/SystemOfUnits.h> // for cm, mm, pi, rad
#include <G4String.hh> // for G4String
#include <G4Types.hh> // for G4double, G4bool, G4int
#include <array> // for array
#include <cstddef> // for size_t
#include <vector> // for vector
#include "G4Material.hh" // for G4Material
#include "G4SystemOfUnits.hh" // for cm, mm, rad
#include "G4ThreeVector.hh" // for G4ThreeVector
#include "G4Material.hh" // for G4Material
#include "G4SystemOfUnits.hh" // for cm, mm, rad
#include "G4ThreeVector.hh" // for G4ThreeVector
#include "G4VUserDetectorConstruction.hh" // for G4VUserDetectorConstruction
#include <CLHEP/Units/SystemOfUnits.h> // for cm, mm, pi, rad
#include <G4String.hh> // for G4String
#include <G4Types.hh> // for G4double, G4bool, G4int
#include <array> // for array
#include <cstddef> // for size_t
#include <vector> // for vector
class G4LogicalVolume;
class G4VPhysicalVolume;
class Par04DetectorMessenger;
@@ -71,88 +72,93 @@ class Par04DetectorMessenger;
class Par04DetectorConstruction : public G4VUserDetectorConstruction
{
public:
Par04DetectorConstruction();
virtual ~Par04DetectorConstruction();
public:
Par04DetectorConstruction();
virtual ~Par04DetectorConstruction();
virtual G4VPhysicalVolume* Construct() final;
virtual void ConstructSDandField() final;
virtual G4VPhysicalVolume* Construct() final;
virtual void ConstructSDandField() final;
/// Set inner radius of the cylindrical detector
void SetInnerRadius(G4double aInnerRadius);
/// Get inner radius of the cylindrical detector
inline G4double GetInnerRadius() const { return fDetectorInnerRadius; };
/// Set length radius of the cylindrical detector
void SetLength(G4double aLength);
/// Get length of the cylindrical detector (along z-axis)
inline G4double GetLength() const { return fDetectorLength; };
/// Set number of layers
inline void SetNbOfLayers(G4int aNumber) { fNbOfLayers = aNumber; };
/// Get number of layers
inline G4int GetNbOfLayers() const { return fNbOfLayers; };
/// Set inner radius of the cylindrical detector
void SetInnerRadius(G4double aInnerRadius);
/// Get inner radius of the cylindrical detector
inline G4double GetInnerRadius() const { return fDetectorInnerRadius; };
/// Set length radius of the cylindrical detector
void SetLength(G4double aLength);
/// Get length of the cylindrical detector (along z-axis)
inline G4double GetLength() const { return fDetectorLength; };
/// Set number of layers
inline void SetNbOfLayers(G4int aNumber) { fNbOfLayers = aNumber; };
/// Get number of layers
inline G4int GetNbOfLayers() const { return fNbOfLayers; };
/// Set material of the layer (from NIST materials)
void SetAbsorberMaterial(const std::size_t aLayer, const G4String& aMaterial);
/// Get name of the material of the layer
inline G4String GetAbsorberMaterial(const std::size_t aLayer) const
{
return fAbsorberMaterial[aLayer]->GetName();
};
/// Set thickness of the layer
void SetAbsorberThickness(const std::size_t aLayer, const G4double aThickness);
/// Get thickness of the layer
inline G4double GetAbsorberThickness(const std::size_t aLayer) const
{
return fAbsorberThickness[aLayer];
};
/// Set sensitivity of the layer
void SetAbsorberSensitivity(const std::size_t aLayer, const G4bool aSensitivity);
/// Get sensitivity of the layer
inline G4bool GetAbsorberSensitivity(const std::size_t aLayer) const
{
return fAbsorberSensitivity[aLayer];
};
/// Set material of the layer (from NIST materials)
void SetAbsorberMaterial(const std::size_t aLayer, const G4String& aMaterial);
/// Get name of the material of the layer
inline G4String GetAbsorberMaterial(const std::size_t aLayer) const
{
return fAbsorberMaterial[aLayer]->GetName();
};
/// Set thickness of the layer
void SetAbsorberThickness(const std::size_t aLayer, const G4double aThickness);
/// Get thickness of the layer
inline G4double GetAbsorberThickness(const std::size_t aLayer) const
{
return fAbsorberThickness[aLayer];
};
/// Set sensitivity of the layer
void SetAbsorberSensitivity(const std::size_t aLayer, const G4bool aSensitivity);
/// Get sensitivity of the layer
inline G4bool GetAbsorberSensitivity(const std::size_t aLayer) const
{
return fAbsorberSensitivity[aLayer];
};
/// Set number of Mesh cells in cylindrical coordinates (r, phi, z)
inline void SetMeshNbOfCells(G4ThreeVector aNb) { fMeshNbOfCells = aNb; };
/// Set number of Mesh cells in cylindrical coordinates along one of the axis
/// @param[in] aIndex index of cylindrical axis (0,1,2) = (r, phi, z)
inline void SetMeshNbOfCells(std::size_t aIndex, G4double aNb) { fMeshNbOfCells[aIndex] = aNb; };
/// Get number of Mesh cells in cylindrical coordinates (r, phi, z)
inline G4ThreeVector GetMeshNbOfCells() const { return fMeshNbOfCells; };
/// Set size of Mesh cells in cylindrical coordinates (r, phi, z)
inline void SetMeshSizeOfCells(G4ThreeVector aNb) { fMeshSizeOfCells = aNb; };
/// Set size of Mesh cells in cylindrical coordinates along one of the axis
/// @param[in] aIndex index of cylindrical axis (0,1,2) = (r, phi, z)
inline void SetMeshSizeOfCells(std::size_t aIndex, G4double aNb)
{ fMeshSizeOfCells[aIndex] = aNb; };
/// Get size of Mesh cells in cylindrical coordinates (r, phi, z)
inline G4ThreeVector GetMeshSizeOfCells() const { return fMeshSizeOfCells; };
/// Set number of Mesh cells in cylindrical coordinates (r, phi, z)
inline void SetMeshNbOfCells(G4ThreeVector aNb) { fMeshNbOfCells = aNb; };
/// Set number of Mesh cells in cylindrical coordinates along one of the axis
/// @param[in] aIndex index of cylindrical axis (0,1,2) = (r, phi, z)
inline void SetMeshNbOfCells(std::size_t aIndex, G4double aNb)
{
fMeshNbOfCells[aIndex] = aNb;
};
/// Get number of Mesh cells in cylindrical coordinates (r, phi, z)
inline G4ThreeVector GetMeshNbOfCells() const { return fMeshNbOfCells; };
/// Set size of Mesh cells in cylindrical coordinates (r, phi, z)
inline void SetMeshSizeOfCells(G4ThreeVector aNb) { fMeshSizeOfCells = aNb; };
/// Set size of Mesh cells in cylindrical coordinates along one of the axis
/// @param[in] aIndex index of cylindrical axis (0,1,2) = (r, phi, z)
inline void SetMeshSizeOfCells(std::size_t aIndex, G4double aNb)
{
fMeshSizeOfCells[aIndex] = aNb;
};
/// Get size of Mesh cells in cylindrical coordinates (r, phi, z)
inline G4ThreeVector GetMeshSizeOfCells() const { return fMeshSizeOfCells; };
/// Print detector information
void Print() const;
/// Print detector information
void Print() const;
private:
/// Messenger that allows to modify geometry
Par04DetectorMessenger* fDetectorMessenger = nullptr;
/// Inner radius of the cylindrical detector
G4double fDetectorInnerRadius = 80 * cm;
/// Length of the cylindrical detector (along z axis)
G4double fDetectorLength = 24 * cm;
/// Logical volume(s) of the sensitive absorbers
std::vector<G4LogicalVolume*> fLayerLogical;
/// Material(s) of the layers
std::array<G4Material*, 2> fAbsorberMaterial = { nullptr, nullptr };
/// Thickness(es) of the layers
std::array<G4double, 2> fAbsorberThickness = { 1 * cm, 0 };
/// Sensitivity of the layers
std::array<G4bool, 2> fAbsorberSensitivity = { true, 0 };
/// Number of layers = slices along z axis
G4int fNbOfLayers = 24;
/// Mesh number of cells (Nr, Nphi, Nz)
G4ThreeVector fMeshNbOfCells = { 40, 50, 48 };
/// Mesh size of cells (dr, dphi, dz).
G4ThreeVector fMeshSizeOfCells = { 5 * mm, 2 * CLHEP::pi / 50 * CLHEP::rad, 5 * mm };
private:
/// Messenger that allows to modify geometry
Par04DetectorMessenger* fDetectorMessenger = nullptr;
/// Inner radius of the cylindrical detector
G4double fDetectorInnerRadius = 80 * cm;
/// Length of the cylindrical detector (along z axis)
G4double fDetectorLength = 24 * cm;
/// Logical volume(s) of the sensitive absorbers
std::vector<G4LogicalVolume*> fLayerLogical;
/// Material(s) of the layers
std::array<G4Material*, 2> fAbsorberMaterial = {nullptr, nullptr};
/// Thickness(es) of the layers
std::array<G4double, 2> fAbsorberThickness = {1 * cm, 0};
/// Sensitivity of the layers
std::array<G4bool, 2> fAbsorberSensitivity = {true, 0};
/// Number of layers = slices along z axis
G4int fNbOfLayers = 24;
/// Mesh number of cells (Nr, Nphi, Nz)
G4ThreeVector fMeshNbOfCells = {40, 50, 48};
/// Mesh size of cells (dr, dphi, dz).
G4ThreeVector fMeshSizeOfCells = {5 * mm, 2 * CLHEP::pi / 50 * CLHEP::rad, 5 * mm};
};
#endif /* PAR04DETECTORCONSTRUCTION_H */
@@ -27,8 +27,9 @@
#ifndef PAR04DETECTORMESSENGER_H
#define PAR04DETECTORMESSENGER_H
#include <G4String.hh> // for G4String
#include "G4UImessenger.hh" // for G4UImessenger
#include <G4String.hh> // for G4String
class G4UIcmdWithADoubleAndUnit;
class G4UIcmdWithAnInteger;
class G4UIcmdWithoutParameter;
@@ -47,45 +48,45 @@ class Par04DetectorConstruction;
class Par04DetectorMessenger : public G4UImessenger
{
public:
Par04DetectorMessenger(Par04DetectorConstruction*);
~Par04DetectorMessenger();
public:
Par04DetectorMessenger(Par04DetectorConstruction*);
~Par04DetectorMessenger();
/// Invokes appropriate methods based on the typed command
virtual void SetNewValue(G4UIcommand*, G4String) final;
/// Retrieves the current settings
virtual G4String GetCurrentValue(G4UIcommand*) final;
/// Invokes appropriate methods based on the typed command
virtual void SetNewValue(G4UIcommand*, G4String) final;
/// Retrieves the current settings
virtual G4String GetCurrentValue(G4UIcommand*) final;
private:
/// Detector construction to setup
Par04DetectorConstruction* fDetector = nullptr;
/// Command to set the directory common to all messengers in this example
/// /Par04
G4UIdirectory* fExampleDir = nullptr;
/// Command to set the directory for detector settings /Par04/detector
G4UIdirectory* fDetectorDir = nullptr;
/// Command printing current settings
G4UIcmdWithoutParameter* fPrintCmd;
/// Command to set the detector inner radius
G4UIcmdWithADoubleAndUnit* fDetectorInnerRadiusCmd = nullptr;
/// Command to set the detector length
G4UIcmdWithADoubleAndUnit* fDetectorLengthCmd = nullptr;
/// Command to set the number of layers
G4UIcmdWithAnInteger* fNbLayersCmd = nullptr;
/// Commanbd to set the absorbers within layers (material, thickness, sensitivity)
G4UIcommand* fAbsorCmd = nullptr;
/// Command to set the directory for sensitive detector settings /Par04/mesh
G4UIdirectory* fMeshDir = nullptr;
/// Command to set the number of cells in the cylindrical readout mesh (along rho axis)
G4UIcmdWithAnInteger* fMeshNbRhoCellsCmd = nullptr;
/// Command to set the number of cells in the cylindrical readout mesh (along phi axis)
G4UIcmdWithAnInteger* fMeshNbPhiCellsCmd = nullptr;
/// Command to set the number of cells in the cylindrical readout mesh (along z axis)
G4UIcmdWithAnInteger* fMeshNbZCellsCmd = nullptr;
/// Command to the size of cells in the cylindrical readout mesh (along rho axis)
G4UIcmdWithADoubleAndUnit* fMeshSizeRhoCellsCmd = nullptr;
/// Command to the size of cells in the cylindrical readout mesh (along z axis)
G4UIcmdWithADoubleAndUnit* fMeshSizeZCellsCmd = nullptr;
private:
/// Detector construction to setup
Par04DetectorConstruction* fDetector = nullptr;
/// Command to set the directory common to all messengers in this example
/// /Par04
G4UIdirectory* fExampleDir = nullptr;
/// Command to set the directory for detector settings /Par04/detector
G4UIdirectory* fDetectorDir = nullptr;
/// Command printing current settings
G4UIcmdWithoutParameter* fPrintCmd;
/// Command to set the detector inner radius
G4UIcmdWithADoubleAndUnit* fDetectorInnerRadiusCmd = nullptr;
/// Command to set the detector length
G4UIcmdWithADoubleAndUnit* fDetectorLengthCmd = nullptr;
/// Command to set the number of layers
G4UIcmdWithAnInteger* fNbLayersCmd = nullptr;
/// Commanbd to set the absorbers within layers (material, thickness, sensitivity)
G4UIcommand* fAbsorCmd = nullptr;
/// Command to set the directory for sensitive detector settings /Par04/mesh
G4UIdirectory* fMeshDir = nullptr;
/// Command to set the number of cells in the cylindrical readout mesh (along rho axis)
G4UIcmdWithAnInteger* fMeshNbRhoCellsCmd = nullptr;
/// Command to set the number of cells in the cylindrical readout mesh (along phi axis)
G4UIcmdWithAnInteger* fMeshNbPhiCellsCmd = nullptr;
/// Command to set the number of cells in the cylindrical readout mesh (along z axis)
G4UIcmdWithAnInteger* fMeshNbZCellsCmd = nullptr;
/// Command to the size of cells in the cylindrical readout mesh (along rho axis)
G4UIcmdWithADoubleAndUnit* fMeshSizeRhoCellsCmd = nullptr;
/// Command to the size of cells in the cylindrical readout mesh (along z axis)
G4UIcmdWithADoubleAndUnit* fMeshSizeZCellsCmd = nullptr;
};
#endif
@@ -26,10 +26,11 @@
#ifndef PAR04EVENTACTION_HH
#define PAR04EVENTACTION_HH
#include <G4Types.hh> // for G4int, G4double
#include <vector> // for vector
#include "G4Timer.hh" // for G4Timer
#include "G4Timer.hh" // for G4Timer
#include "G4UserEventAction.hh" // for G4UserEventAction
#include <G4Types.hh> // for G4int, G4double
#include <vector> // for vector
class G4Event;
class Par04DetectorConstruction;
class Par04ParallelFullWorld;
@@ -46,69 +47,70 @@ class Par04ParallelFullWorld;
class Par04EventAction : public G4UserEventAction
{
public:
Par04EventAction(Par04DetectorConstruction* aDetector, Par04ParallelFullWorld* aParallel);
virtual ~Par04EventAction();
public:
Par04EventAction(Par04DetectorConstruction* aDetector, Par04ParallelFullWorld* aParallel);
virtual ~Par04EventAction();
/// Timer is started
virtual void BeginOfEventAction(const G4Event* aEvent) final;
/// Hits collection is retrieved, analysed, and histograms are filled.
virtual void EndOfEventAction(const G4Event* aEvent) final;
inline std::vector<G4double>& GetCalEdep() { return fCalEdep; }
inline std::vector<G4int>& GetCalRho() { return fCalRho; }
inline std::vector<G4int>& GetCalPhi() { return fCalPhi; }
inline std::vector<G4int>& GetCalZ() { return fCalZ; }
inline std::vector<G4double>& GetPhysicalCalEdep() { return fCalPhysicalEdep; }
inline std::vector<G4int>& GetPhysicalCalLayer() { return fCalPhysicalLayer; }
inline std::vector<G4int>& GetPhysicalCalSlice() { return fCalPhysicalSlice; }
inline std::vector<G4int>& GetPhysicalCalRow() { return fCalPhysicalRow; }
void StartTimer();
void StopTimer();
private:
/// ID of a hit collection to analyse
G4int fHitCollectionID = -1;
G4int fPhysicalFullHitCollectionID = -1;
G4int fPhysicalFastHitCollectionID = -1;
/// Timer measurement from Geant4
G4Timer fTimer;
/// Pointer to detector construction to retrieve (once) the detector
/// dimensions and size of readout
Par04DetectorConstruction* fDetector = nullptr;
Par04ParallelFullWorld* fParallel = nullptr;
/// Size of cell along Z axis
G4double fCellSizeZ = 0;
/// Size of cell along radius of cylinder
G4double fCellSizeRho = 0;
/// Size of cell in azimuthal angle
G4double fCellSizePhi = 0;
/// Number of readout cells along radius
G4int fCellNbRho = 0;
/// Number of readout cells in azimuthal angle
G4int fCellNbPhi = 0;
/// Number of readout cells along z axis
G4int fCellNbZ = 0;
/// Number of physical readout layers
G4int fPhysicalNbLayers = 0;
/// Number of physical readout slices
G4int fPhysicalNbSlices = 0;
/// Number of physical readout rows
G4int fPhysicalNbRows = 0;
/// Cell energy deposits to be stored in ntuple
std::vector<G4double> fCalEdep;
/// Cell ID of radius to be stored in ntuple
std::vector<G4int> fCalRho;
/// Cell ID of azimuthal angle to be stored in ntuple
std::vector<G4int> fCalPhi;
/// Cell ID of z axis to be stored in ntuple
std::vector<G4int> fCalZ;
/// Physical cell energy deposits to be stored in ntuple
std::vector<G4double> fCalPhysicalEdep;
/// Physical layer ID to be stored in ntuple
std::vector<G4int> fCalPhysicalLayer;
/// Physical slice ID to be stored in ntuple
std::vector<G4int> fCalPhysicalSlice;
/// Physical row ID to be stored in ntuple
std::vector<G4int> fCalPhysicalRow;
/// Timer is started
virtual void BeginOfEventAction(const G4Event* aEvent) final;
/// Hits collection is retrieved, analysed, and histograms are filled.
virtual void EndOfEventAction(const G4Event* aEvent) final;
inline std::vector<G4double>& GetCalEdep() { return fCalEdep; }
inline std::vector<G4int>& GetCalRho() { return fCalRho; }
inline std::vector<G4int>& GetCalPhi() { return fCalPhi; }
inline std::vector<G4int>& GetCalZ() { return fCalZ; }
inline std::vector<G4double>& GetPhysicalCalEdep() { return fCalPhysicalEdep; }
inline std::vector<G4int>& GetPhysicalCalLayer() { return fCalPhysicalLayer; }
inline std::vector<G4int>& GetPhysicalCalSlice() { return fCalPhysicalSlice; }
inline std::vector<G4int>& GetPhysicalCalRow() { return fCalPhysicalRow; }
void StartTimer();
void StopTimer();
private:
/// ID of a hit collection to analyse
G4int fHitCollectionID = -1;
G4int fPhysicalFullHitCollectionID = -1;
G4int fPhysicalFastHitCollectionID = -1;
/// Timer measurement from Geant4
G4Timer fTimer;
/// Pointer to detector construction to retrieve (once) the detector
/// dimensions and size of readout
Par04DetectorConstruction* fDetector = nullptr;
Par04ParallelFullWorld* fParallel = nullptr;
/// Size of cell along Z axis
G4double fCellSizeZ = 0;
/// Size of cell along radius of cylinder
G4double fCellSizeRho = 0;
/// Size of cell in azimuthal angle
G4double fCellSizePhi = 0;
/// Number of readout cells along radius
G4int fCellNbRho = 0;
/// Number of readout cells in azimuthal angle
G4int fCellNbPhi = 0;
/// Number of readout cells along z axis
G4int fCellNbZ = 0;
/// Number of physical readout layers
G4int fPhysicalNbLayers = 0;
/// Number of physical readout slices
G4int fPhysicalNbSlices = 0;
/// Number of physical readout rows
G4int fPhysicalNbRows = 0;
/// Cell energy deposits to be stored in ntuple
std::vector<G4double> fCalEdep;
/// Cell ID of radius to be stored in ntuple
std::vector<G4int> fCalRho;
/// Cell ID of azimuthal angle to be stored in ntuple
std::vector<G4int> fCalPhi;
/// Cell ID of z axis to be stored in ntuple
std::vector<G4int> fCalZ;
/// Physical cell energy deposits to be stored in ntuple
std::vector<G4double> fCalPhysicalEdep;
/// Physical layer ID to be stored in ntuple
std::vector<G4int> fCalPhysicalLayer;
/// Physical slice ID to be stored in ntuple
std::vector<G4int> fCalPhysicalSlice;
/// Physical row ID to be stored in ntuple
std::vector<G4int> fCalPhysicalRow;
};
#endif /* PAR04EVENTACTION_HH */
@@ -26,9 +26,10 @@
#ifndef PAR04EVENTINFORMATION_HH
#define PAR04EVENTINFORMATION_HH
#include <G4Types.hh> // for G4bool
#include "G4ThreeVector.hh" // for G4ThreeVector
#include "G4VUserEventInformation.hh" // for G4VUserEventInformation
#include "G4ThreeVector.hh" // for G4ThreeVector
#include "G4VUserEventInformation.hh" // for G4VUserEventInformation
#include <G4Types.hh> // for G4bool
/**
* @brief Event information
@@ -41,32 +42,32 @@
class Par04EventInformation : public G4VUserEventInformation
{
public:
Par04EventInformation();
virtual ~Par04EventInformation();
public:
Par04EventInformation();
virtual ~Par04EventInformation();
/// Set particle direction
inline void SetDirection(const G4ThreeVector& aDirection) { fDirection = aDirection; };
/// Get particle direction
inline G4ThreeVector GetDirection() const { return fDirection; };
/// Set particle position
inline void SetPosition(const G4ThreeVector& aPosition) { fPosition = aPosition; };
/// Get particle position
inline G4ThreeVector GetPosition() const { return fPosition; };
/// Set flag
inline void SetFlag(G4bool aFlag) { fIfSet = aFlag; };
/// Get flag
inline G4bool GetFlag() const { return fIfSet; };
/// Print
void Print() const final;
/// Set particle direction
inline void SetDirection(const G4ThreeVector& aDirection) { fDirection = aDirection; };
/// Get particle direction
inline G4ThreeVector GetDirection() const { return fDirection; };
/// Set particle position
inline void SetPosition(const G4ThreeVector& aPosition) { fPosition = aPosition; };
/// Get particle position
inline G4ThreeVector GetPosition() const { return fPosition; };
/// Set flag
inline void SetFlag(G4bool aFlag) { fIfSet = aFlag; };
/// Get flag
inline G4bool GetFlag() const { return fIfSet; };
/// Print
void Print() const final;
private:
/// Particle direction. By default equal to the default particle gun direction.
G4ThreeVector fDirection = { 0, 1, 0 };
/// Particle position. By default equal to the default inner radius.
G4ThreeVector fPosition = { 0, 800, 0 };
/// Flag
G4bool fIfSet = false;
private:
/// Particle direction. By default equal to the default particle gun direction.
G4ThreeVector fDirection = {0, 1, 0};
/// Particle position. By default equal to the default inner radius.
G4ThreeVector fPosition = {0, 800, 0};
/// Flag
G4bool fIfSet = false;
};
#endif /* PAR04EVENTINFORMATION_HH */
@@ -26,16 +26,17 @@
#ifndef PAR04HIT_HH
#define PAR04HIT_HH
#include <stddef.h> // for size_t
#include <G4Types.hh> // for G4int, G4double
#include <map> // for map
#include <tls.hh> // for G4ThreadLocal
#include <vector> // for vector
#include "G4Allocator.hh" // for G4Allocator
#include "G4RotationMatrix.hh" // for G4RotationMatrix
#include "G4THitsCollection.hh" // for G4THitsCollection
#include "G4ThreeVector.hh" // for G4ThreeVector
#include "G4VHit.hh" // for G4VHit
#include "G4Allocator.hh" // for G4Allocator
#include "G4RotationMatrix.hh" // for G4RotationMatrix
#include "G4THitsCollection.hh" // for G4THitsCollection
#include "G4ThreeVector.hh" // for G4ThreeVector
#include "G4VHit.hh" // for G4VHit
#include <G4Types.hh> // for G4int, G4double
#include <map> // for map
#include <stddef.h> // for size_t
#include <tls.hh> // for G4ThreadLocal
#include <vector> // for vector
class G4AttDef;
class G4AttValue;
class G4LogicalVolume;
@@ -55,91 +56,91 @@ class G4String;
class Par04Hit : public G4VHit
{
public:
Par04Hit();
Par04Hit(const Par04Hit& aRight);
virtual ~Par04Hit();
public:
Par04Hit();
Par04Hit(const Par04Hit& aRight);
virtual ~Par04Hit();
const Par04Hit& operator=(const Par04Hit& aRight);
int operator==(const Par04Hit& aRight) const;
const Par04Hit& operator=(const Par04Hit& aRight);
int operator==(const Par04Hit& aRight) const;
inline void* operator new(size_t);
inline void operator delete(void* aHit);
/// Visualise hits. If pointer to the logical volume was set, cell shape is
/// drawn taking into account proper radial position (taken from fRhoId)
virtual void Draw() final;
/// Retrieve atributes' names in order to allow filtering
virtual const std::map<G4String, G4AttDef>* GetAttDefs() const final;
/// Create attributes for the visualisation.
virtual std::vector<G4AttValue>* CreateAttValues() const final;
/// Print hit properties.
virtual void Print() final;
/// Set position
inline void SetPos(G4ThreeVector aXYZ) { fPos = aXYZ; }
/// Get position
inline G4ThreeVector GetPos() const { return fPos; }
/// Set rotation
inline void SetRot(G4RotationMatrix aXYZ) { fRot = aXYZ; }
/// Get rotation
inline G4RotationMatrix GetRot() const { return fRot; }
/// Set energy
inline void SetEdep(G4double aEdep) { fEdep = aEdep; }
/// Add energy to previous value
inline void AddEdep(G4double aEdep) { fEdep += aEdep; }
/// Get energy
inline G4double GetEdep() const { return fEdep; }
/// Set number of deposits per hit/cell
inline void SetNdep(G4int aNdep) { fNdep = aNdep; }
/// Add number of deposits to previous value, by defualt increment
inline void AddNdep(G4int aNdep = 1) { fNdep += aNdep; }
/// Get number of deposits per hit/cell
inline G4int GetNdep() const { return fNdep; }
/// Set Z id of the cell in the readout segmentation
inline void SetZid(G4int aZ) { fZId = aZ; }
/// Get Z id of the cell in the readout segmentation
inline G4int GetZid() const { return fZId; }
/// Set Rho id of the cell in the readout segmentation
inline void SetRhoId(G4int aRho) { fRhoId = aRho; }
/// Get rho id of the cell in the readout segmentation
inline G4int GetRhoId() const { return fRhoId; }
/// Set phi id of the cell in the readout segmentation
inline void SetPhiId(G4int aPhi) { fPhiId = aPhi; }
/// Get phi id of the cell in the readout segmentation
inline G4int GetPhiId() const { return fPhiId; }
/// Set time
inline void SetTime(G4double aTime) { fTime = aTime; }
/// Get time
inline G4double GetTime() const { return fTime; }
/// Set type (0 = full sim, 1 = fast sim)
inline void SetType(G4int aType) { fType = aType; }
/// Get type (0 = full sim, 1 = fast sim)
inline G4int GetType() const { return fType; }
// Set pointer to cell logical volume
inline void SetLogV(G4LogicalVolume* aLogVol) { fLogVol = aLogVol; }
// Get pointer to cell logical volume
inline const G4LogicalVolume* GetLogVol() { return fLogVol; }
inline void* operator new(size_t);
inline void operator delete(void* aHit);
/// Visualise hits. If pointer to the logical volume was set, cell shape is
/// drawn taking into account proper radial position (taken from fRhoId)
virtual void Draw() final;
/// Retrieve atributes' names in order to allow filtering
virtual const std::map<G4String, G4AttDef>* GetAttDefs() const final;
/// Create attributes for the visualisation.
virtual std::vector<G4AttValue>* CreateAttValues() const final;
/// Print hit properties.
virtual void Print() final;
/// Set position
inline void SetPos(G4ThreeVector aXYZ) { fPos = aXYZ; }
/// Get position
inline G4ThreeVector GetPos() const { return fPos; }
/// Set rotation
inline void SetRot(G4RotationMatrix aXYZ) { fRot = aXYZ; }
/// Get rotation
inline G4RotationMatrix GetRot() const { return fRot; }
/// Set energy
inline void SetEdep(G4double aEdep) { fEdep = aEdep; }
/// Add energy to previous value
inline void AddEdep(G4double aEdep) { fEdep += aEdep; }
/// Get energy
inline G4double GetEdep() const { return fEdep; }
/// Set number of deposits per hit/cell
inline void SetNdep(G4int aNdep) { fNdep = aNdep; }
/// Add number of deposits to previous value, by defualt increment
inline void AddNdep(G4int aNdep = 1) { fNdep += aNdep; }
/// Get number of deposits per hit/cell
inline G4int GetNdep() const { return fNdep; }
/// Set Z id of the cell in the readout segmentation
inline void SetZid(G4int aZ) { fZId = aZ; }
/// Get Z id of the cell in the readout segmentation
inline G4int GetZid() const { return fZId; }
/// Set Rho id of the cell in the readout segmentation
inline void SetRhoId(G4int aRho) { fRhoId = aRho; }
/// Get rho id of the cell in the readout segmentation
inline G4int GetRhoId() const { return fRhoId; }
/// Set phi id of the cell in the readout segmentation
inline void SetPhiId(G4int aPhi) { fPhiId = aPhi; }
/// Get phi id of the cell in the readout segmentation
inline G4int GetPhiId() const { return fPhiId; }
/// Set time
inline void SetTime(G4double aTime) { fTime = aTime; }
/// Get time
inline G4double GetTime() const { return fTime; }
/// Set type (0 = full sim, 1 = fast sim)
inline void SetType(G4int aType) { fType = aType; }
/// Get type (0 = full sim, 1 = fast sim)
inline G4int GetType() const { return fType; }
// Set pointer to cell logical volume
inline void SetLogV(G4LogicalVolume* aLogVol) { fLogVol = aLogVol; }
// Get pointer to cell logical volume
inline const G4LogicalVolume* GetLogVol() { return fLogVol; }
public:
/// Energy deposit
G4double fEdep = 0;
/// Counter of deposits in a hit/cell
G4int fNdep = 0;
/// Z ID of readout cell
G4int fZId = -1;
/// Rho ID of readout cell
G4int fRhoId = -1;
/// Phi ID of readout cell
G4int fPhiId = -1;
/// Position
G4ThreeVector fPos = { -1, -1, -1 };
/// Rotation
G4RotationMatrix fRot;
/// Time
G4double fTime = -1;
/// Type: 0 = full sim, 1 = fast sim
G4int fType = -1;
/// Pointer to logical volume for visualisation
G4LogicalVolume* fLogVol = nullptr;
public:
/// Energy deposit
G4double fEdep = 0;
/// Counter of deposits in a hit/cell
G4int fNdep = 0;
/// Z ID of readout cell
G4int fZId = -1;
/// Rho ID of readout cell
G4int fRhoId = -1;
/// Phi ID of readout cell
G4int fPhiId = -1;
/// Position
G4ThreeVector fPos = {-1, -1, -1};
/// Rotation
G4RotationMatrix fRot;
/// Time
G4double fTime = -1;
/// Type: 0 = full sim, 1 = fast sim
G4int fType = -1;
/// Pointer to logical volume for visualisation
G4LogicalVolume* fLogVol = nullptr;
};
typedef G4THitsCollection<Par04Hit> Par04HitsCollection;
@@ -148,14 +149,13 @@ extern G4ThreadLocal G4Allocator<Par04Hit>* Par04HitAllocator;
inline void* Par04Hit::operator new(size_t)
{
if(!Par04HitAllocator)
Par04HitAllocator = new G4Allocator<Par04Hit>;
return (void*) Par04HitAllocator->MallocSingle();
if (!Par04HitAllocator) Par04HitAllocator = new G4Allocator<Par04Hit>;
return (void*)Par04HitAllocator->MallocSingle();
}
inline void Par04Hit::operator delete(void* aHit)
{
Par04HitAllocator->FreeSingle((Par04Hit*) aHit);
Par04HitAllocator->FreeSingle((Par04Hit*)aHit);
}
#endif /* PAR04HIT_HH */
@@ -24,11 +24,12 @@
// ********************************************************************
//
#ifdef USE_INFERENCE
#ifndef PAR04INFERENCEINTERFACE_HH
#define PAR04INFERENCEINTERFACE_HH
# ifndef PAR04INFERENCEINTERFACE_HH
# define PAR04INFERENCEINTERFACE_HH
#include "globals.hh"
#include <vector>
# include "globals.hh"
# include <vector>
/**
* @brief Inference interface
@@ -39,16 +40,16 @@
class Par04InferenceInterface
{
public:
virtual ~Par04InferenceInterface(){};
public:
virtual ~Par04InferenceInterface() {};
/// Run inference
/// @param[in] aGenVector Input latent space and conditions
/// @param[out] aEnergies Model output = generated shower energies
/// @param[in] aSize Size of the output
virtual void RunInference(std::vector<float> aGenVector, std::vector<G4double>& aEnergies,
int aSize) = 0;
/// Run inference
/// @param[in] aGenVector Input latent space and conditions
/// @param[out] aEnergies Model output = generated shower energies
/// @param[in] aSize Size of the output
virtual void RunInference(std::vector<float> aGenVector, std::vector<G4double>& aEnergies,
int aSize) = 0;
};
#endif /* PAR04INFERENCEINTERFACE_HH */
# endif /* PAR04INFERENCEINTERFACE_HH */
#endif
@@ -24,11 +24,12 @@
// ********************************************************************
//
#ifdef USE_INFERENCE
#ifndef PAR04INFERENCEMESSENGER_H
#define PAR04INFERENCEMESSENGER_H
# ifndef PAR04INFERENCEMESSENGER_H
# define PAR04INFERENCEMESSENGER_H
#include "G4UImessenger.hh" // for G4UImessenger
#include <G4String.hh> // for G4String
# include "G4UImessenger.hh" // for G4UImessenger
# include <G4String.hh> // for G4String
class G4UIcmdWithADoubleAndUnit;
class G4UIcmdWithAString;
class G4UIcmdWithAnInteger;
@@ -47,62 +48,63 @@ class Par04InferenceSetup;
*
*/
class Par04InferenceMessenger : public G4UImessenger {
public:
Par04InferenceMessenger(Par04InferenceSetup *);
~Par04InferenceMessenger();
/// Invokes appropriate methods based on the typed command
virtual void SetNewValue(G4UIcommand *, G4String) final;
/// Retrieves the current settings
virtual G4String GetCurrentValue(G4UIcommand *) final;
class Par04InferenceMessenger : public G4UImessenger
{
public:
Par04InferenceMessenger(Par04InferenceSetup*);
~Par04InferenceMessenger();
/// Invokes appropriate methods based on the typed command
virtual void SetNewValue(G4UIcommand*, G4String) final;
/// Retrieves the current settings
virtual G4String GetCurrentValue(G4UIcommand*) final;
private:
/// Inference to setup
Par04InferenceSetup *fInference = nullptr;
/// Command to set the directory common to all inference messengers in this
/// example /Par04
G4UIdirectory *fExampleDir = nullptr;
/// Command to set the directory for inference settings /Par04/inference
G4UIdirectory *fInferenceDir = nullptr;
/// Command to set the inference library
G4UIcmdWithAString *fInferenceLibraryCmd = nullptr;
/// Command to set fModelPathNameCmd
G4UIcmdWithAString *fModelPathNameCmd = nullptr;
/// Command to set the fSizeLatentVectorCmd
G4UIcmdWithAnInteger *fSizeLatentVectorCmd = nullptr;
/// Command to set the fSizeConditionVectorCmd
G4UIcmdWithAnInteger *fSizeConditionVectorCmd = nullptr;
/// Command to set the fProfileFlagCmd
G4UIcmdWithAnInteger *fProfileFlagCmd = nullptr;
/// Command to set the fOptimizationFlagCmd
G4UIcmdWithAnInteger *fOptimizationFlagCmd = nullptr;
/// Command to set the number of cells in the cylindrical readout mesh (along
/// rho axis)
G4UIcmdWithAnInteger *fMeshNbRhoCellsCmd = nullptr;
/// Command to set the number of cells in the cylindrical readout mesh (along
/// phi axis)
G4UIcmdWithAnInteger *fMeshNbPhiCellsCmd = nullptr;
/// Command to set the number of cells in the cylindrical readout mesh (along
/// z axis)
G4UIcmdWithAnInteger *fMeshNbZCellsCmd = nullptr;
/// Command to the size of cells in the cylindrical readout mesh (along rho
/// axis)
G4UIcmdWithADoubleAndUnit *fMeshSizeRhoCellsCmd = nullptr;
/// Command to the size of cells in the cylindrical readout mesh (along z
/// axis)
G4UIcmdWithADoubleAndUnit *fMeshSizeZCellsCmd = nullptr;
/// Commands to set execution provider flags
/// GPU
G4UIcmdWithAnInteger *fCudaFlagCmd = nullptr;
/// Cuda Commands
G4UIdirectory *fCudaOptionsDir = nullptr;
G4UIcmdWithAString *fCudaDeviceIdCmd = nullptr;
G4UIcmdWithAString *fCudaGpuMemLimitCmd = nullptr;
G4UIcmdWithAString *fCudaArenaExtendedStrategyCmd = nullptr;
G4UIcmdWithAString *fCudaCudnnConvAlgoSearchCmd = nullptr;
G4UIcmdWithAString *fCudaDoCopyInDefaultStreamCmd = nullptr;
G4UIcmdWithAString *fCudaCudnnConvUseMaxWorkspaceCmd = nullptr;
private:
/// Inference to setup
Par04InferenceSetup* fInference = nullptr;
/// Command to set the directory common to all inference messengers in this
/// example /Par04
G4UIdirectory* fExampleDir = nullptr;
/// Command to set the directory for inference settings /Par04/inference
G4UIdirectory* fInferenceDir = nullptr;
/// Command to set the inference library
G4UIcmdWithAString* fInferenceLibraryCmd = nullptr;
/// Command to set fModelPathNameCmd
G4UIcmdWithAString* fModelPathNameCmd = nullptr;
/// Command to set the fSizeLatentVectorCmd
G4UIcmdWithAnInteger* fSizeLatentVectorCmd = nullptr;
/// Command to set the fSizeConditionVectorCmd
G4UIcmdWithAnInteger* fSizeConditionVectorCmd = nullptr;
/// Command to set the fProfileFlagCmd
G4UIcmdWithAnInteger* fProfileFlagCmd = nullptr;
/// Command to set the fOptimizationFlagCmd
G4UIcmdWithAnInteger* fOptimizationFlagCmd = nullptr;
/// Command to set the number of cells in the cylindrical readout mesh (along
/// rho axis)
G4UIcmdWithAnInteger* fMeshNbRhoCellsCmd = nullptr;
/// Command to set the number of cells in the cylindrical readout mesh (along
/// phi axis)
G4UIcmdWithAnInteger* fMeshNbPhiCellsCmd = nullptr;
/// Command to set the number of cells in the cylindrical readout mesh (along
/// z axis)
G4UIcmdWithAnInteger* fMeshNbZCellsCmd = nullptr;
/// Command to the size of cells in the cylindrical readout mesh (along rho
/// axis)
G4UIcmdWithADoubleAndUnit* fMeshSizeRhoCellsCmd = nullptr;
/// Command to the size of cells in the cylindrical readout mesh (along z
/// axis)
G4UIcmdWithADoubleAndUnit* fMeshSizeZCellsCmd = nullptr;
/// Commands to set execution provider flags
/// GPU
G4UIcmdWithAnInteger* fCudaFlagCmd = nullptr;
/// Cuda Commands
G4UIdirectory* fCudaOptionsDir = nullptr;
G4UIcmdWithAString* fCudaDeviceIdCmd = nullptr;
G4UIcmdWithAString* fCudaGpuMemLimitCmd = nullptr;
G4UIcmdWithAString* fCudaArenaExtendedStrategyCmd = nullptr;
G4UIcmdWithAString* fCudaCudnnConvAlgoSearchCmd = nullptr;
G4UIcmdWithAString* fCudaDoCopyInDefaultStreamCmd = nullptr;
G4UIcmdWithAString* fCudaCudnnConvUseMaxWorkspaceCmd = nullptr;
};
#endif
# endif
#endif
@@ -24,16 +24,18 @@
// ********************************************************************
//
#ifdef USE_INFERENCE
#ifndef PAR04INFEERENCESETUP_HH
#define PAR04INFEERENCESETUP_HH
# ifndef PAR04INFEERENCESETUP_HH
# define PAR04INFEERENCESETUP_HH
#include "CLHEP/Units/SystemOfUnits.h" // for mm
#include "G4ThreeVector.hh" // for G4ThreeVector
#include <G4String.hh> // for G4String
#include <G4SystemOfUnits.hh> // for mm
#include <G4Types.hh> // for G4int, G4double, G4bool, G4f...
#include <memory> // for unique_ptr
#include <vector> // for vector
# include "CLHEP/Units/SystemOfUnits.h" // for mm
# include "G4ThreeVector.hh" // for G4ThreeVector
# include <G4String.hh> // for G4String
# include <G4SystemOfUnits.hh> // for mm
# include <G4Types.hh> // for G4int, G4double, G4bool, G4f...
# include <memory> // for unique_ptr
# include <vector> // for vector
class Par04DetectorConstruction;
class Par04InferenceInterface;
class Par04InferenceMessenger;
@@ -53,206 +55,190 @@ class Par04InferenceMessenger;
*
**/
class Par04InferenceSetup {
public:
Par04InferenceSetup();
~Par04InferenceSetup();
class Par04InferenceSetup
{
public:
Par04InferenceSetup();
~Par04InferenceSetup();
/// Geometry setup
/// Check if inference should be performed for the particle
/// @param[in] aEnergy Particle's energy
G4bool IfTrigger(G4double aEnergy);
/// Set mesh size.
/// @param aSize (x,y,x) size for Carthesian coordinates, or (R, phi, z) for
/// cylindrical coordinates.
inline void SetMeshSize(const G4ThreeVector &aSize) { fMeshSize = aSize; };
/// Get mesh size.
/// @return G4ThreeVector (x,y,x) size for Carthesian coordinates, or (R, phi,
/// z) for cylindrical coordinates.
inline G4ThreeVector GetMeshSize() const { return fMeshSize; };
/// Set number of mesh cells.
/// @param aSize (x,y,x) size for Carthesian coordinates, or (R, phi, z) for
/// cylindrical coordinates.
inline void SetMeshNumber(const G4ThreeVector &aSize) {
fMeshNumber = aSize;
};
/// Get number of mesh cells.
/// @return G4ThreeVector (x,y,x) size for Carthesian coordinates, or (R, phi,
/// z) for cylindrical coordinates.
inline G4ThreeVector GetMeshNumber() const { return fMeshNumber; };
/// Set size of the condition vector
inline void SetSizeConditionVector(G4int aNumber) {
fSizeConditionVector = aNumber;
};
/// Get size of the condition vector
inline G4int GetSizeConditionVector() const { return fSizeConditionVector; };
/// Set size of the latent space vector
inline void SetSizeLatentVector(G4int aNumber) {
fSizeLatentVector = aNumber;
};
/// Get size of the latent space vector
inline G4int GetSizeLatentVector() const { return fSizeLatentVector; };
/// Set path and name of the model
inline void SetModelPathName(G4String aName) { fModelPathName = aName; };
/// Get path and name of the model
inline G4String GetModelPathName() const { return fModelPathName; };
/// Set profiling flag
inline void SetProfileFlag(G4int aNumber) { fProfileFlag = aNumber; };
/// Get profiling flag
inline G4int GetProfileFlag() const { return fProfileFlag; };
/// Set optimization flag
inline void SetOptimizationFlag(G4int aNumber) {
fOptimizationFlag = aNumber;
};
/// Get optimization flag
inline G4int GetOptimizationFlag() const { return fOptimizationFlag; };
/// Get name of the inference library
inline G4String GetInferenceLibrary() const { return fInferenceLibrary; };
/// Set name of the inference library and create a pointer to chosen inference
/// interface
void SetInferenceLibrary(G4String aName);
/// Check settings of the inference library
void CheckInferenceLibrary();
/// Set number of Mesh cells in cylindrical coordinates (r, phi, z)
inline void SetMeshNbOfCells(G4ThreeVector aNb) { fMeshNumber = aNb; };
/// Set number of Mesh cells in cylindrical coordinates
/// @param[in] aIndex index of cylindrical axis (0,1,2) = (r, phi, z)
inline void SetMeshNbOfCells(G4int aIndex, G4double aNb) {
fMeshNumber[aIndex] = aNb;
};
/// Get number of Mesh cells in cylindrical coordinates (r, phi, z)
inline G4ThreeVector GetMeshNbOfCells() const { return fMeshNumber; };
/// Set size of Mesh cells in cylindrical coordinates (r, phi, z)
inline void SetMeshSizeOfCells(G4ThreeVector aNb) { fMeshSize = aNb; };
/// Set size of Mesh cells in cylindrical coordinates
/// @param[in] aIndex index of cylindrical axis (0,1,2) = (r, phi, z)
inline void SetMeshSizeOfCells(G4int aIndex, G4double aNb) {
fMeshSize[aIndex] = aNb;
};
/// Get size of Mesh cells in cylindrical coordinates (r, phi, z)
inline G4ThreeVector GetMeshSizeOfCells() const { return fMeshSize; };
/// Setting execution providers flags
/// GPU
inline void SetCudaFlag(G4int aNumber) { fCudaFlag = aNumber; };
inline G4int GetCudaFlag() const { return fCudaFlag; };
/// Setting execution providers Options
/// Cuda
inline void SetCudaDeviceId(G4String aNumber) { fCudaDeviceId = aNumber; };
inline G4String GetCudaDeviceId() const { return fCudaDeviceId; };
inline void SetCudaGpuMemLimit(G4String aNumber) {
fCudaGpuMemLimit = aNumber;
};
inline G4String GetCudaGpuMemLimit() const { return fCudaGpuMemLimit; };
inline void SetCudaArenaExtendedStrategy(G4String aNumber) {
fCudaArenaExtendedStrategy = aNumber;
};
inline G4String GetCudaArenaExtendedStrategy() const {
return fCudaArenaExtendedStrategy;
};
inline void SetCudaCudnnConvAlgoSearch(G4String aNumber) {
fCudaCudnnConvAlgoSearch = aNumber;
};
inline G4String GetCudaCudnnConvAlgoSearch() const {
return fCudaCudnnConvAlgoSearch;
};
inline void SetCudaDoCopyInDefaultStream(G4String aNumber) {
fCudaDoCopyInDefaultStream = aNumber;
};
inline G4String GetCudaDoCopyInDefaultStream() const {
return fCudaDoCopyInDefaultStream;
};
inline void SetCudaCudnnConvUseMaxWorkspace(G4String aNumber) {
fCudaCudnnConvUseMaxWorkspace = aNumber;
};
inline G4String GetCudaCudnnConvUseMaxWorkspace() const {
return fCudaCudnnConvUseMaxWorkspace;
};
/// Geometry setup
/// Check if inference should be performed for the particle
/// @param[in] aEnergy Particle's energy
G4bool IfTrigger(G4double aEnergy);
/// Set mesh size.
/// @param aSize (x,y,x) size for Carthesian coordinates, or (R, phi, z) for
/// cylindrical coordinates.
inline void SetMeshSize(const G4ThreeVector& aSize) { fMeshSize = aSize; };
/// Get mesh size.
/// @return G4ThreeVector (x,y,x) size for Carthesian coordinates, or (R, phi,
/// z) for cylindrical coordinates.
inline G4ThreeVector GetMeshSize() const { return fMeshSize; };
/// Set number of mesh cells.
/// @param aSize (x,y,x) size for Carthesian coordinates, or (R, phi, z) for
/// cylindrical coordinates.
inline void SetMeshNumber(const G4ThreeVector& aSize) { fMeshNumber = aSize; };
/// Get number of mesh cells.
/// @return G4ThreeVector (x,y,x) size for Carthesian coordinates, or (R, phi,
/// z) for cylindrical coordinates.
inline G4ThreeVector GetMeshNumber() const { return fMeshNumber; };
/// Set size of the condition vector
inline void SetSizeConditionVector(G4int aNumber) { fSizeConditionVector = aNumber; };
/// Get size of the condition vector
inline G4int GetSizeConditionVector() const { return fSizeConditionVector; };
/// Set size of the latent space vector
inline void SetSizeLatentVector(G4int aNumber) { fSizeLatentVector = aNumber; };
/// Get size of the latent space vector
inline G4int GetSizeLatentVector() const { return fSizeLatentVector; };
/// Set path and name of the model
inline void SetModelPathName(G4String aName) { fModelPathName = aName; };
/// Get path and name of the model
inline G4String GetModelPathName() const { return fModelPathName; };
/// Set profiling flag
inline void SetProfileFlag(G4int aNumber) { fProfileFlag = aNumber; };
/// Get profiling flag
inline G4int GetProfileFlag() const { return fProfileFlag; };
/// Set optimization flag
inline void SetOptimizationFlag(G4int aNumber) { fOptimizationFlag = aNumber; };
/// Get optimization flag
inline G4int GetOptimizationFlag() const { return fOptimizationFlag; };
/// Get name of the inference library
inline G4String GetInferenceLibrary() const { return fInferenceLibrary; };
/// Set name of the inference library and create a pointer to chosen inference
/// interface
void SetInferenceLibrary(G4String aName);
/// Check settings of the inference library
void CheckInferenceLibrary();
/// Set number of Mesh cells in cylindrical coordinates (r, phi, z)
inline void SetMeshNbOfCells(G4ThreeVector aNb) { fMeshNumber = aNb; };
/// Set number of Mesh cells in cylindrical coordinates
/// @param[in] aIndex index of cylindrical axis (0,1,2) = (r, phi, z)
inline void SetMeshNbOfCells(G4int aIndex, G4double aNb) { fMeshNumber[aIndex] = aNb; };
/// Get number of Mesh cells in cylindrical coordinates (r, phi, z)
inline G4ThreeVector GetMeshNbOfCells() const { return fMeshNumber; };
/// Set size of Mesh cells in cylindrical coordinates (r, phi, z)
inline void SetMeshSizeOfCells(G4ThreeVector aNb) { fMeshSize = aNb; };
/// Set size of Mesh cells in cylindrical coordinates
/// @param[in] aIndex index of cylindrical axis (0,1,2) = (r, phi, z)
inline void SetMeshSizeOfCells(G4int aIndex, G4double aNb) { fMeshSize[aIndex] = aNb; };
/// Get size of Mesh cells in cylindrical coordinates (r, phi, z)
inline G4ThreeVector GetMeshSizeOfCells() const { return fMeshSize; };
/// Setting execution providers flags
/// GPU
inline void SetCudaFlag(G4int aNumber) { fCudaFlag = aNumber; };
inline G4int GetCudaFlag() const { return fCudaFlag; };
/// Setting execution providers Options
/// Cuda
inline void SetCudaDeviceId(G4String aNumber) { fCudaDeviceId = aNumber; };
inline G4String GetCudaDeviceId() const { return fCudaDeviceId; };
inline void SetCudaGpuMemLimit(G4String aNumber) { fCudaGpuMemLimit = aNumber; };
inline G4String GetCudaGpuMemLimit() const { return fCudaGpuMemLimit; };
inline void SetCudaArenaExtendedStrategy(G4String aNumber)
{
fCudaArenaExtendedStrategy = aNumber;
};
inline G4String GetCudaArenaExtendedStrategy() const { return fCudaArenaExtendedStrategy; };
inline void SetCudaCudnnConvAlgoSearch(G4String aNumber)
{
fCudaCudnnConvAlgoSearch = aNumber;
};
inline G4String GetCudaCudnnConvAlgoSearch() const { return fCudaCudnnConvAlgoSearch; };
inline void SetCudaDoCopyInDefaultStream(G4String aNumber)
{
fCudaDoCopyInDefaultStream = aNumber;
};
inline G4String GetCudaDoCopyInDefaultStream() const { return fCudaDoCopyInDefaultStream; };
inline void SetCudaCudnnConvUseMaxWorkspace(G4String aNumber)
{
fCudaCudnnConvUseMaxWorkspace = aNumber;
};
inline G4String GetCudaCudnnConvUseMaxWorkspace() const
{
return fCudaCudnnConvUseMaxWorkspace;
};
/// Execute inference
/// @param[out] aDepositsEnergies of inferred energies deposited in the
/// detector
/// @param[in] aParticleEnergy Energy of initial particle
void GetEnergies(std::vector<G4double> &aEnergies, G4double aParticleEnergy,
G4float aInitialAngle);
/// Execute inference
/// @param[out] aDepositsEnergies of inferred energies deposited in the
/// detector
/// @param[in] aParticleEnergy Energy of initial particle
void GetEnergies(std::vector<G4double>& aEnergies, G4double aParticleEnergy,
G4float aInitialAngle);
/// Calculate positions
/// @param[out] aDepositsPositions Vector of positions corresponding to
/// energies deposited in the detector
/// @param[in] aParticlePosition Initial particle position which is centre of
/// transverse plane of the mesh
/// and beginning of the mesh in the longitudinal direction
/// @param[in] aParticleDirection Initial particle direction for the mesh
/// rotation
void GetPositions(std::vector<G4ThreeVector> &aDepositsPositions,
G4ThreeVector aParticlePosition,
G4ThreeVector aParticleDirection);
/// Calculate positions
/// @param[out] aDepositsPositions Vector of positions corresponding to
/// energies deposited in the detector
/// @param[in] aParticlePosition Initial particle position which is centre of
/// transverse plane of the mesh
/// and beginning of the mesh in the longitudinal direction
/// @param[in] aParticleDirection Initial particle direction for the mesh
/// rotation
void GetPositions(std::vector<G4ThreeVector>& aDepositsPositions,
G4ThreeVector aParticlePosition, G4ThreeVector aParticleDirection);
private:
/// Cell's size: (x,y,x) for Carthesian, and (R, phi, z) for cylindrical
/// coordinates Can be changed with UI command `/example/mesh/size <x y z>/<r
/// phi z> <unit>`. For cylindrical coordinates phi is ignored and calculated
/// from fMeshNumber.
G4ThreeVector fMeshSize =
G4ThreeVector(2.325 * CLHEP::mm, 1, 3.4 * CLHEP::mm);
/// Number of cells: (x,y,x) for Carthesian, and (R, phi, z) for cylindrical
/// coordinates. Can be changed with UI command `/example/mesh/number <Nx Ny
/// Nz>/<Nr Nphi Nz>`
G4ThreeVector fMeshNumber = G4ThreeVector(18, 50, 45);
/// Inference interface
std::unique_ptr<Par04InferenceInterface> fInferenceInterface;
/// Inference messenger
Par04InferenceMessenger *fInferenceMessenger;
/// Maximum particle energy value (in MeV) in the training range
float fMaxEnergy = 1024000.0;
/// Maximum particle angle (in degrees) in the training range
float fMaxAngle = 90.0;
/// Name of the inference library
G4String fInferenceLibrary = "ONNX";
/// Size of the latent space vector
G4int fSizeLatentVector = 10;
/// Size of the condition vector
G4int fSizeConditionVector = 4;
/// Name of the inference library
G4String fModelPathName = "MLModels/Generator.onnx";
/// ONNX specific
/// Profiling flag
G4bool fProfileFlag = false;
/// Optimization flag
G4bool fOptimizationFlag = false;
/// Optimization file
G4String fModelSavePath = "MLModels/Optimized-Generator.onnx";
/// Profiling file
G4String fProfilingOutputSavePath = "opt.json";
/// Intra-operation number of threads
G4int fIntraOpNumThreads = 1;
/// Flags for execution providers
/// GPU
G4bool fCudaFlag = false;
/// Execution Provider Options
/// Cuda options
G4String fCudaDeviceId = "0";
G4String fCudaGpuMemLimit = "2147483648";
G4String fCudaArenaExtendedStrategy = "kSameAsRequested";
G4String fCudaCudnnConvAlgoSearch = "DEFAULT";
G4String fCudaDoCopyInDefaultStream = "1";
G4String fCudaCudnnConvUseMaxWorkspace = "1";
std::vector<const char *> cuda_keys{
private:
/// Cell's size: (x,y,x) for Carthesian, and (R, phi, z) for cylindrical
/// coordinates Can be changed with UI command `/example/mesh/size <x y z>/<r
/// phi z> <unit>`. For cylindrical coordinates phi is ignored and calculated
/// from fMeshNumber.
G4ThreeVector fMeshSize = G4ThreeVector(2.325 * CLHEP::mm, 1, 3.4 * CLHEP::mm);
/// Number of cells: (x,y,x) for Carthesian, and (R, phi, z) for cylindrical
/// coordinates. Can be changed with UI command `/example/mesh/number <Nx Ny
/// Nz>/<Nr Nphi Nz>`
G4ThreeVector fMeshNumber = G4ThreeVector(18, 50, 45);
/// Inference interface
std::unique_ptr<Par04InferenceInterface> fInferenceInterface;
/// Inference messenger
Par04InferenceMessenger* fInferenceMessenger;
/// Maximum particle energy value (in MeV) in the training range
float fMaxEnergy = 1024000.0;
/// Maximum particle angle (in degrees) in the training range
float fMaxAngle = 90.0;
/// Name of the inference library
G4String fInferenceLibrary = "ONNX";
/// Size of the latent space vector
G4int fSizeLatentVector = 10;
/// Size of the condition vector
G4int fSizeConditionVector = 4;
/// Name of the inference library
G4String fModelPathName = "MLModels/Generator.onnx";
/// ONNX specific
/// Profiling flag
G4bool fProfileFlag = false;
/// Optimization flag
G4bool fOptimizationFlag = false;
/// Optimization file
G4String fModelSavePath = "MLModels/Optimized-Generator.onnx";
/// Profiling file
G4String fProfilingOutputSavePath = "opt.json";
/// Intra-operation number of threads
G4int fIntraOpNumThreads = 1;
/// Flags for execution providers
/// GPU
G4bool fCudaFlag = false;
/// Execution Provider Options
/// Cuda options
G4String fCudaDeviceId = "0";
G4String fCudaGpuMemLimit = "2147483648";
G4String fCudaArenaExtendedStrategy = "kSameAsRequested";
G4String fCudaCudnnConvAlgoSearch = "DEFAULT";
G4String fCudaDoCopyInDefaultStream = "1";
G4String fCudaCudnnConvUseMaxWorkspace = "1";
std::vector<const char*> cuda_keys{
"device_id",
"gpu_mem_limit",
"arena_extend_strategy",
"cudnn_conv_algo_search",
"do_copy_in_default_stream",
"cudnn_conv_use_max_workspace",
};
std::vector<const char *> cuda_values{
};
std::vector<const char*> cuda_values{
fCudaDeviceId.c_str(),
fCudaGpuMemLimit.c_str(),
fCudaArenaExtendedStrategy.c_str(),
fCudaCudnnConvAlgoSearch.c_str(),
fCudaDoCopyInDefaultStream.c_str(),
fCudaCudnnConvUseMaxWorkspace.c_str(),
};
};
};
#endif /* PAR04INFEERENCESETUP_HH */
# endif /* PAR04INFEERENCESETUP_HH */
#endif
@@ -25,17 +25,18 @@
//
#ifdef USE_INFERENCE_LWTNN
#ifndef PAR04LWTNNINFERENCE_HH
#define PAR04LWTNNINFERENCE_HH
# ifndef PAR04LWTNNINFERENCE_HH
# define PAR04LWTNNINFERENCE_HH
#include <G4String.hh> // for G4String
#include <G4Types.hh> // for G4double
#include <map> // for map, map<>::value_compare
#include <memory> // for unique_ptr
#include <string> // for string, basic_string, operator<
#include <vector> // for vector
#include "Par04InferenceInterface.hh" // for Par04InferenceInterface
#include "lwtnn/LightweightGraph.hh" // for LightweightGraph
# include "Par04InferenceInterface.hh" // for Par04InferenceInterface
# include "lwtnn/LightweightGraph.hh" // for LightweightGraph
# include <G4String.hh> // for G4String
# include <G4Types.hh> // for G4double
# include <map> // for map, map<>::value_compare
# include <memory> // for unique_ptr
# include <string> // for string, basic_string, operator<
# include <vector> // for vector
/**
* @brief Inference using the LWTNN library.
@@ -48,22 +49,22 @@
class Par04LwtnnInference : public Par04InferenceInterface
{
public:
Par04LwtnnInference(G4String);
Par04LwtnnInference();
public:
Par04LwtnnInference(G4String);
Par04LwtnnInference();
/// Run inference
/// @param[in] aGenVector Input latent space and conditions
/// @param[out] aEnergies Model output = generated shower energies
/// @param[in] aSize Size of the output
void RunInference(std::vector<float> aGenVector, std::vector<G4double>& aEnergies, int aSize);
/// Run inference
/// @param[in] aGenVector Input latent space and conditions
/// @param[out] aEnergies Model output = generated shower energies
/// @param[in] aSize Size of the output
void RunInference(std::vector<float> aGenVector, std::vector<G4double>& aEnergies, int aSize);
private:
/// LWTNN graph , Network input and output vectors
std::unique_ptr<lwt::LightweightGraph> fGraph;
typedef std::map<std::string, std::map<std::string, double>> fNetworkInputs;
typedef std::map<std::string, double> fNetworkOutputs;
private:
/// LWTNN graph , Network input and output vectors
std::unique_ptr<lwt::LightweightGraph> fGraph;
typedef std::map<std::string, std::map<std::string, double>> fNetworkInputs;
typedef std::map<std::string, double> fNetworkOutputs;
};
#endif /* PAR04LWTNNINFERENCE_HH */
# endif /* PAR04LWTNNINFERENCE_HH */
#endif
@@ -24,15 +24,16 @@
// ********************************************************************
//
#ifdef USE_INFERENCE
#ifndef PAR04MLFASTSIMMODEL_HH
#define PAR04MLFASTSIMMODEL_HH
# ifndef PAR04MLFASTSIMMODEL_HH
# define PAR04MLFASTSIMMODEL_HH
#include <G4String.hh> // for G4String
#include <G4ThreeVector.hh> // for G4ThreeVector
#include <G4Types.hh> // for G4bool, G4double
#include <memory> // for unique_ptr
#include <vector> // for vector
#include "G4VFastSimulationModel.hh" // for G4VFastSimulationModel
# include "G4VFastSimulationModel.hh" // for G4VFastSimulationModel
# include <G4String.hh> // for G4String
# include <G4ThreeVector.hh> // for G4ThreeVector
# include <G4Types.hh> // for G4bool, G4double
# include <memory> // for unique_ptr
# include <vector> // for vector
class G4FastSimHitMaker;
class G4FastStep;
class G4FastHit;
@@ -53,31 +54,31 @@ class Par04InferenceSetup;
class Par04MLFastSimModel : public G4VFastSimulationModel
{
public:
Par04MLFastSimModel(G4String, G4Region*);
Par04MLFastSimModel(G4String);
~Par04MLFastSimModel();
/// There are no kinematics constraints. True is returned.
virtual G4bool ModelTrigger(const G4FastTrack&) final;
/// Model is applicable to electrons, positrons, and photons.
virtual G4bool IsApplicable(const G4ParticleDefinition&) final;
/// Take particle out of the full simulation (kill it at the entrance
/// depositing all the energy). Calculate energy deposited in the detector
/// from the NN model inference.
virtual void DoIt(const G4FastTrack&, G4FastStep&) final;
public:
Par04MLFastSimModel(G4String, G4Region*);
Par04MLFastSimModel(G4String);
~Par04MLFastSimModel();
/// There are no kinematics constraints. True is returned.
virtual G4bool ModelTrigger(const G4FastTrack&) final;
/// Model is applicable to electrons, positrons, and photons.
virtual G4bool IsApplicable(const G4ParticleDefinition&) final;
/// Take particle out of the full simulation (kill it at the entrance
/// depositing all the energy). Calculate energy deposited in the detector
/// from the NN model inference.
virtual void DoIt(const G4FastTrack&, G4FastStep&) final;
private:
/// Inference model that is NN aware
Par04InferenceSetup* fInference;
/// Inference model that is NN aware
/// Helper class for creation of hits within the sensitive detector
std::unique_ptr<G4FastSimHitMaker> fHitMaker;
std::unique_ptr<G4FastSimHitMaker> fParallelHitMaker;
/// Vector of energy values
std::vector<G4double> fEnergies;
/// Vector of positions corresponding to energy values (const for one NN
/// model)
std::vector<G4ThreeVector> fPositions;
private:
/// Inference model that is NN aware
Par04InferenceSetup* fInference;
/// Inference model that is NN aware
/// Helper class for creation of hits within the sensitive detector
std::unique_ptr<G4FastSimHitMaker> fHitMaker;
std::unique_ptr<G4FastSimHitMaker> fParallelHitMaker;
/// Vector of energy values
std::vector<G4double> fEnergies;
/// Vector of positions corresponding to energy values (const for one NN
/// model)
std::vector<G4ThreeVector> fPositions;
};
#endif /* PAR04INFERENCEMODEL_HH */
# endif /* PAR04INFERENCEMODEL_HH */
#endif
@@ -25,15 +25,17 @@
//
#ifdef USE_INFERENCE_ONNX
#ifndef PAR04ONNXINFERENCE_HH
#define PAR04ONNXINFERENCE_HH
#include <core/session/onnxruntime_c_api.h> // for OrtMemoryInfo
#include <G4String.hh> // for G4String
#include <G4Types.hh> // for G4int, G4double
#include <memory> // for unique_ptr
#include <vector> // for vector
#include "Par04InferenceInterface.hh" // for Par04InferenceInterface
#include "core/session/onnxruntime_cxx_api.h" // for Env, Session, SessionO...
# ifndef PAR04ONNXINFERENCE_HH
# define PAR04ONNXINFERENCE_HH
# include "Par04InferenceInterface.hh" // for Par04InferenceInterface
# include "core/session/onnxruntime_cxx_api.h" // for Env, Session, SessionO...
# include <G4String.hh> // for G4String
# include <G4Types.hh> // for G4int, G4double
# include <memory> // for unique_ptr
# include <vector> // for vector
# include <core/session/onnxruntime_c_api.h> // for OrtMemoryInfo
/**
* @brief Inference using the ONNX runtime.
@@ -46,36 +48,35 @@
class Par04OnnxInference : public Par04InferenceInterface
{
public:
Par04OnnxInference(G4String, G4int, G4int, G4int,
G4int, // For Execution Provider Runtime Flags (for now only CUDA)
std::vector<const char *> &cuda_keys,
std::vector<const char *> &cuda_values,
G4String, G4String);
public:
Par04OnnxInference(G4String, G4int, G4int, G4int,
G4int, // For Execution Provider Runtime Flags (for now only CUDA)
std::vector<const char*>& cuda_keys, std::vector<const char*>& cuda_values,
G4String, G4String);
Par04OnnxInference();
Par04OnnxInference();
/// Run inference
/// @param[in] aGenVector Input latent space and conditions
/// @param[out] aEnergies Model output = generated shower energies
/// @param[in] aSize Size of the output
void RunInference(std::vector<float> aGenVector, std::vector<G4double>& aEnergies, int aSize);
/// Run inference
/// @param[in] aGenVector Input latent space and conditions
/// @param[out] aEnergies Model output = generated shower energies
/// @param[in] aSize Size of the output
void RunInference(std::vector<float> aGenVector, std::vector<G4double>& aEnergies, int aSize);
private:
/// Pointer to the ONNX enviroment
std::unique_ptr<Ort::Env> fEnv;
/// Pointer to the ONNX inference session
std::unique_ptr<Ort::Session> fSession;
/// ONNX settings
Ort::SessionOptions fSessionOptions;
/// ONNX memory info
const OrtMemoryInfo* fInfo;
struct MemoryInfo;
/// the input names represent the names given to the model
/// when defining the model's architecture (if applicable)
/// they can also be retrieved from model.summary()
std::vector<const char*> fInames;
private:
/// Pointer to the ONNX enviroment
std::unique_ptr<Ort::Env> fEnv;
/// Pointer to the ONNX inference session
std::unique_ptr<Ort::Session> fSession;
/// ONNX settings
Ort::SessionOptions fSessionOptions;
/// ONNX memory info
const OrtMemoryInfo* fInfo;
struct MemoryInfo;
/// the input names represent the names given to the model
/// when defining the model's architecture (if applicable)
/// they can also be retrieved from model.summary()
std::vector<const char*> fInames;
};
#endif /* PAR04ONNXINFERENCE_HH */
# endif /* PAR04ONNXINFERENCE_HH */
#endif
@@ -26,14 +26,16 @@
#ifndef PAR04PARALLELFASTSENSITIVEDETECTOR_HH
#define PAR04PARALLELFASTSENSITIVEDETECTOR_HH
#include <CLHEP/Units/SystemOfUnits.h> // for m, pi
#include <G4String.hh> // for G4String
#include <G4Types.hh> // for G4bool, G4int
#include "G4SystemOfUnits.hh" // for m
#include "G4ThreeVector.hh" // for G4ThreeVector
#include "Par04Hit.hh" // for Par04Hit (ptr only), Par04...
#include "G4SystemOfUnits.hh" // for m
#include "G4ThreeVector.hh" // for G4ThreeVector
#include "G4VFastSimSensitiveDetector.hh" // for G4VFastSimSensitiveDetector
#include "G4VSensitiveDetector.hh" // for G4VSensitiveDetector
#include "Par04Hit.hh" // for Par04Hit (ptr only), Par04...
#include "G4VSensitiveDetector.hh" // for G4VSensitiveDetector
#include <CLHEP/Units/SystemOfUnits.h> // for m, pi
#include <G4String.hh> // for G4String
#include <G4Types.hh> // for G4bool, G4int
#include <unordered_map>
class G4FastHit;
class G4FastTrack;
@@ -47,33 +49,30 @@ class G4TouchableHistory;
*
*/
class Par04ParallelFastSensitiveDetector
: public G4VSensitiveDetector,
public G4VFastSimSensitiveDetector
class Par04ParallelFastSensitiveDetector : public G4VSensitiveDetector,
public G4VFastSimSensitiveDetector
{
public:
Par04ParallelFastSensitiveDetector(G4String aName);
Par04ParallelFastSensitiveDetector(G4String aName,
G4int aNbOfLayers,
G4int aNbOfSlices);
virtual ~Par04ParallelFastSensitiveDetector();
/// Create hit collection
virtual void Initialize(G4HCofThisEvent* HCE) final;
/// Process energy deposit from the full simulation.
virtual G4bool ProcessHits(G4Step* aStep, G4TouchableHistory* aROhist) final;
virtual G4bool ProcessHits(const G4FastHit* aHit, const G4FastTrack* aTrack,
G4TouchableHistory* aROhist) final;
virtual void EndOfEvent(G4HCofThisEvent* aHC) final;
public:
Par04ParallelFastSensitiveDetector(G4String aName);
Par04ParallelFastSensitiveDetector(G4String aName, G4int aNbOfLayers, G4int aNbOfSlices);
virtual ~Par04ParallelFastSensitiveDetector();
/// Create hit collection
virtual void Initialize(G4HCofThisEvent* HCE) final;
/// Process energy deposit from the full simulation.
virtual G4bool ProcessHits(G4Step* aStep, G4TouchableHistory* aROhist) final;
virtual G4bool ProcessHits(const G4FastHit* aHit, const G4FastTrack* aTrack,
G4TouchableHistory* aROhist) final;
virtual void EndOfEvent(G4HCofThisEvent* aHC) final;
private:
/// Collection of hits
Par04HitsCollection* fHitsCollection = nullptr;
std::unordered_map<G4int, std::unique_ptr<Par04Hit>> fHitsMap;
/// ID of collection of hits
G4int fHitCollectionID = -1;
/// Number of readout cells
G4int fNbOfLayers = 1;
G4int fNbOfSlices = 1;
private:
/// Collection of hits
Par04HitsCollection* fHitsCollection = nullptr;
std::unordered_map<G4int, std::unique_ptr<Par04Hit>> fHitsMap;
/// ID of collection of hits
G4int fHitCollectionID = -1;
/// Number of readout cells
G4int fNbOfLayers = 1;
G4int fNbOfSlices = 1;
};
#endif /* PAR04PARALLELSENSITIVEDETECTOR_HH */
@@ -27,6 +27,7 @@
#define PAR04PARALLELFASTWORLD_HH
#include "Par04DetectorConstruction.hh"
#include "G4VUserParallelWorld.hh"
#include "globals.hh"
@@ -37,26 +38,25 @@ class G4VPhysicalVolume;
class Par04ParallelFastWorld : public G4VUserParallelWorld
{
public:
Par04ParallelFastWorld(G4String aWorldName,
const Par04DetectorConstruction* aMassDetector,
const Par04ParallelFullWorld* aParallelFull);
~Par04ParallelFastWorld();
virtual void Construct() final;
virtual void ConstructSD() final;
void Print();
public:
Par04ParallelFastWorld(G4String aWorldName, const Par04DetectorConstruction* aMassDetector,
const Par04ParallelFullWorld* aParallelFull);
~Par04ParallelFastWorld();
private:
/// Messenger that allows to modify geometry
const Par04DetectorConstruction* fMassDetector;
const Par04ParallelFullWorld* fParallelFull;
std::vector<G4LogicalVolume*> fLogicalCell;
G4int fNbOfLayers = 1;
G4int fNbOfSlices = 1;
G4int fNbOfRows = 1;
G4double fLayerThickness = 0;
virtual void Construct() final;
virtual void ConstructSD() final;
void Print();
private:
/// Messenger that allows to modify geometry
const Par04DetectorConstruction* fMassDetector;
const Par04ParallelFullWorld* fParallelFull;
std::vector<G4LogicalVolume*> fLogicalCell;
G4int fNbOfLayers = 1;
G4int fNbOfSlices = 1;
G4int fNbOfRows = 1;
G4double fLayerThickness = 0;
};
#endif
@@ -26,14 +26,16 @@
#ifndef PAR04PARALLELFULLSENSITIVEDETECTOR_HH
#define PAR04PARALLELFULLSENSITIVEDETECTOR_HH
#include <CLHEP/Units/SystemOfUnits.h> // for m, pi
#include <G4String.hh> // for G4String
#include <G4Types.hh> // for G4bool, G4int
#include "G4SystemOfUnits.hh" // for m
#include "G4ThreeVector.hh" // for G4ThreeVector
#include "Par04Hit.hh" // for Par04Hit (ptr only), Par04...
#include "G4SystemOfUnits.hh" // for m
#include "G4ThreeVector.hh" // for G4ThreeVector
#include "G4VFastSimSensitiveDetector.hh" // for G4VFastSimSensitiveDetector
#include "G4VSensitiveDetector.hh" // for G4VSensitiveDetector
#include "Par04Hit.hh" // for Par04Hit (ptr only), Par04...
#include "G4VSensitiveDetector.hh" // for G4VSensitiveDetector
#include <CLHEP/Units/SystemOfUnits.h> // for m, pi
#include <G4String.hh> // for G4String
#include <G4Types.hh> // for G4bool, G4int
#include <unordered_map>
class G4HCofThisEvent;
class G4Step;
@@ -45,30 +47,29 @@ class G4TouchableHistory;
*
*/
class Par04ParallelFullSensitiveDetector
: public G4VSensitiveDetector
class Par04ParallelFullSensitiveDetector : public G4VSensitiveDetector
{
public:
Par04ParallelFullSensitiveDetector(G4String aName);
Par04ParallelFullSensitiveDetector(G4String aName,
G4int aNbOfLayers, G4int aNbOfSlices, G4int aNbOfRows);
virtual ~Par04ParallelFullSensitiveDetector();
/// Create hit collection
virtual void Initialize(G4HCofThisEvent* HCE) final;
/// Process energy deposit from the full simulation.
virtual G4bool ProcessHits(G4Step* aStep, G4TouchableHistory* aROhist) final;
virtual void EndOfEvent(G4HCofThisEvent* aHC) final;
public:
Par04ParallelFullSensitiveDetector(G4String aName);
Par04ParallelFullSensitiveDetector(G4String aName, G4int aNbOfLayers, G4int aNbOfSlices,
G4int aNbOfRows);
virtual ~Par04ParallelFullSensitiveDetector();
/// Create hit collection
virtual void Initialize(G4HCofThisEvent* HCE) final;
/// Process energy deposit from the full simulation.
virtual G4bool ProcessHits(G4Step* aStep, G4TouchableHistory* aROhist) final;
virtual void EndOfEvent(G4HCofThisEvent* aHC) final;
private:
/// Collection of hits
Par04HitsCollection* fHitsCollection = nullptr;
std::unordered_map<G4int, std::unique_ptr<Par04Hit>> fHitsMap;
/// ID of collection of hits
G4int fHitCollectionID = -1;
/// Number of readout cells
G4int fNbOfLayers = 1;
G4int fNbOfSlices = 1;
G4int fNbOfRows = 1;
private:
/// Collection of hits
Par04HitsCollection* fHitsCollection = nullptr;
std::unordered_map<G4int, std::unique_ptr<Par04Hit>> fHitsMap;
/// ID of collection of hits
G4int fHitCollectionID = -1;
/// Number of readout cells
G4int fNbOfLayers = 1;
G4int fNbOfSlices = 1;
G4int fNbOfRows = 1;
};
#endif /* PAR04PARALLELSENSITIVEDETECTOR_HH */
@@ -27,6 +27,7 @@
#define PAR04PARALLELFULLWORLD_HH
#include "Par04DetectorConstruction.hh"
#include "G4VUserParallelWorld.hh"
#include "globals.hh"
@@ -36,36 +37,35 @@ class G4VPhysicalVolume;
class Par04ParallelFullWorld : public G4VUserParallelWorld
{
public:
Par04ParallelFullWorld(G4String aWorldName, const Par04DetectorConstruction* aMassDetector);
~Par04ParallelFullWorld();
virtual void Construct() final;
virtual void ConstructSD() final;
public:
Par04ParallelFullWorld(G4String aWorldName, const Par04DetectorConstruction* aMassDetector);
~Par04ParallelFullWorld();
/// Set number of slices
inline void SetNbOfSlices(G4int aNumber) { fNbOfSlices = aNumber; };
/// Get number of slices
inline G4int GetNbOfSlices() const { return fNbOfSlices; };
/// Set number of rows
inline void SetNbOfRows(G4int aNumber) { fNbOfRows = aNumber; };
/// Get number of rows
inline G4int GetNbOfRows() const { return fNbOfRows; };
/// Get number of layers
inline G4int GetNbOfLayers() const { return fNbOfLayers; };
void Print();
virtual void Construct() final;
virtual void ConstructSD() final;
private:
/// Messenger that allows to modify geometry
Par04ParallelMessenger* fParallelMessenger = nullptr;
const Par04DetectorConstruction* fMassDetector;
std::vector<G4LogicalVolume*> fLogicalCell;
G4int fNbOfLayers = 1;
G4int fNbOfSlices = 1;
G4int fNbOfRows = 1;
G4double fLayerThickness = 0;
/// Set number of slices
inline void SetNbOfSlices(G4int aNumber) { fNbOfSlices = aNumber; };
/// Get number of slices
inline G4int GetNbOfSlices() const { return fNbOfSlices; };
/// Set number of rows
inline void SetNbOfRows(G4int aNumber) { fNbOfRows = aNumber; };
/// Get number of rows
inline G4int GetNbOfRows() const { return fNbOfRows; };
/// Get number of layers
inline G4int GetNbOfLayers() const { return fNbOfLayers; };
void Print();
private:
/// Messenger that allows to modify geometry
Par04ParallelMessenger* fParallelMessenger = nullptr;
const Par04DetectorConstruction* fMassDetector;
std::vector<G4LogicalVolume*> fLogicalCell;
G4int fNbOfLayers = 1;
G4int fNbOfSlices = 1;
G4int fNbOfRows = 1;
G4double fLayerThickness = 0;
};
#endif
@@ -27,8 +27,9 @@
#ifndef PAR04PARALLELMESSENGER_H
#define PAR04PARALLELMESSENGER_H
#include <G4String.hh> // for G4String
#include "G4UImessenger.hh" // for G4UImessenger
#include <G4String.hh> // for G4String
class G4UIcmdWithADoubleAndUnit;
class G4UIcmdWithAnInteger;
class G4UIcmdWithoutParameter;
@@ -47,29 +48,29 @@ class Par04ParallelFullWorld;
class Par04ParallelMessenger : public G4UImessenger
{
public:
Par04ParallelMessenger(Par04ParallelFullWorld*);
~Par04ParallelMessenger();
public:
Par04ParallelMessenger(Par04ParallelFullWorld*);
~Par04ParallelMessenger();
/// Invokes appropriate methods based on the typed command
virtual void SetNewValue(G4UIcommand*, G4String) final;
/// Retrieves the current settings
virtual G4String GetCurrentValue(G4UIcommand*) final;
/// Invokes appropriate methods based on the typed command
virtual void SetNewValue(G4UIcommand*, G4String) final;
/// Retrieves the current settings
virtual G4String GetCurrentValue(G4UIcommand*) final;
private:
/// Parallel world to setup
Par04ParallelFullWorld* fParallel = nullptr;
/// Command to set the directory common to all messengers in this example
/// /Par04
G4UIdirectory* fExampleDir = nullptr;
/// Command to set the directory for parallel settings /Par04/parallel
G4UIdirectory* fParallelDir = nullptr;
/// Command printing current settings
G4UIcmdWithoutParameter* fPrintCmd;
/// Command to set the number of slices
G4UIcmdWithAnInteger* fNbSlicesCmd = nullptr;
/// Command to set the number of rows
G4UIcmdWithAnInteger* fNbRowsCmd = nullptr;
private:
/// Parallel world to setup
Par04ParallelFullWorld* fParallel = nullptr;
/// Command to set the directory common to all messengers in this example
/// /Par04
G4UIdirectory* fExampleDir = nullptr;
/// Command to set the directory for parallel settings /Par04/parallel
G4UIdirectory* fParallelDir = nullptr;
/// Command printing current settings
G4UIcmdWithoutParameter* fPrintCmd;
/// Command to set the number of slices
G4UIcmdWithAnInteger* fNbSlicesCmd = nullptr;
/// Command to set the number of rows
G4UIcmdWithAnInteger* fNbRowsCmd = nullptr;
};
#endif
@@ -40,16 +40,16 @@ class G4ParticleGun;
class Par04PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
Par04PrimaryGeneratorAction();
virtual ~Par04PrimaryGeneratorAction();
public:
Par04PrimaryGeneratorAction();
virtual ~Par04PrimaryGeneratorAction();
/// Generate primary particles
virtual void GeneratePrimaries(G4Event*) final;
/// Generate primary particles
virtual void GeneratePrimaries(G4Event*) final;
private:
/// Particle gun
G4ParticleGun* fParticleGun = nullptr;
private:
/// Particle gun
G4ParticleGun* fParticleGun = nullptr;
};
#endif /* PAR04PRIMARYGENERATORACTION_HH */
@@ -26,19 +26,21 @@
#ifndef PAR04RUNACTION_HH
#define PAR04RUNACTION_HH
#include "G4UserRunAction.hh"
#include "Par04EventInformation.hh" // for Par04EventInformation
#include "Par04PrimaryGeneratorAction.hh"
#include <CLHEP/Units/SystemOfUnits.h> // for GeV
#include <G4String.hh> // for G4String
#include <G4ThreeVector.hh> // for G4ThreeVector
#include <G4Types.hh> // for G4int
#include "G4Event.hh" // for G4Event
#include "G4ParticleGun.hh" // for G4ParticleGun
#include "G4ParticleTable.hh" // for G4ParticleTable
#include "G4SystemOfUnits.hh" // for GeV
#include "G4UserRunAction.hh"
#include <CLHEP/Units/SystemOfUnits.h> // for GeV
#include <G4String.hh> // for G4String
#include <G4ThreeVector.hh> // for G4ThreeVector
#include <G4Types.hh> // for G4int
#include <G4VUserPrimaryGeneratorAction.hh> // for G4VUserPrimaryGeneratorA...
#include <string> // for basic_string
#include "G4Event.hh" // for G4Event
#include "G4ParticleGun.hh" // for G4ParticleGun
#include "G4ParticleTable.hh" // for G4ParticleTable
#include "G4SystemOfUnits.hh" // for GeV
#include "Par04EventInformation.hh" // for Par04EventInformation
#include <string> // for basic_string
class G4ParticleDefinition;
class Par04EventAction;
class G4Run;
@@ -56,25 +58,25 @@ class Par04DetectorConstruction;
class Par04RunAction : public G4UserRunAction
{
public:
/// Constructor. Defines the histograms.
Par04RunAction(Par04DetectorConstruction* aDetector, Par04EventAction* aEventAction);
virtual ~Par04RunAction();
public:
/// Constructor. Defines the histograms.
Par04RunAction(Par04DetectorConstruction* aDetector, Par04EventAction* aEventAction);
virtual ~Par04RunAction();
/// Open the file for the analysis
virtual void BeginOfRunAction(const G4Run*) final;
/// Write and close the file
virtual void EndOfRunAction(const G4Run*) final;
/// Open the file for the analysis
virtual void BeginOfRunAction(const G4Run*) final;
/// Write and close the file
virtual void EndOfRunAction(const G4Run*) final;
private:
/// Pointer to detector construction to retrieve the detector dimensions to
/// setup the histograms
Par04DetectorConstruction* fDetector;
/// Pointer to event action to save hits
Par04EventAction* fEventAction;
/// Timer measurement
std::chrono::steady_clock::time_point fChronoStart;
std::chrono::steady_clock::time_point fChronoEnd;
private:
/// Pointer to detector construction to retrieve the detector dimensions to
/// setup the histograms
Par04DetectorConstruction* fDetector;
/// Pointer to event action to save hits
Par04EventAction* fEventAction;
/// Timer measurement
std::chrono::steady_clock::time_point fChronoStart;
std::chrono::steady_clock::time_point fChronoEnd;
};
#endif /* PAR04RUNACTION_HH */

Some files were not shown because too many files have changed in this diff Show More