Commit 024038c3 authored by Sarka Todorova's avatar Sarka Todorova Committed by Graeme Stewart
Browse files

merge with -00-00-22-branch (ISF_FatrasToolsG4-00-01-02)

parent 7a4a00c3
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/////////////////////////////////////////////////////////////////
// G4HadIntProcessor.h, (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
#ifndef ISF_FATRASTOOLSG4_G4HADINTPROCESSOR_H
#define ISF_FATRASTOOLSG4_G4HADINTPROCESSOR_H
// GaudiKernel & Athena
#include "AthenaBaseComps/AthAlgTool.h"
#include "AthenaKernel/IAtRndmGenSvc.h"
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/ServiceHandle.h"
// Fatras
#include "ISF_FatrasInterfaces/IHadronicInteractionProcessor.h"
//Barcode
#include "BarcodeInterfaces/PhysicsProcessCode.h"
// Geant4
#include "G4ThreeVector.hh"
// Trk
#include "TrkEventPrimitives/ParticleHypothesis.h"
// ISF
#include "ISF_Event/ITruthIncident.h"
#include "ISF_Event/ISFParticleVector.h"
// Forward Declarations
class TTree;
class G4DynamicParticle;
class G4VProcess;
class G4RunManager;
class G4VUserPhysicsList;
class G4LayerDetectorConstruction;
class G4LayerPrimaryGeneratorAction;
class G4LayerTrackingAction;
class G4Step;
class G4StepPoint;
class G4AtlasRunManager;
namespace Trk {
class Layer;
class CylinderVolumeBounds;
class TrackingGeometry;
class IEnergyLossUpdator;
class IMultipleScatteringUpdator;
class Material;
class MaterialProperties;
class ITrackingGeometrySvc;
}
namespace ISF {
class IParticleBroker;
class ITruthSvc;
class IG4RunManagerHelper;
}
namespace iFatras {
class IPhysicsValidationTool;
/** @class G4HadIntProcessor
Wrapper class for multiple scattering, energyloss, hadronic interaction
tool from Geant4.
@author Andreas.Salzburger@cern.ch
*/
class G4HadIntProcessor : virtual public iFatras::IHadronicInteractionProcessor,
public AthAlgTool {
public:
/** AlgTool constructor for G4HadIntProcessor*/
G4HadIntProcessor(const std::string&,const std::string&,const IInterface*);
/**Destructor*/
virtual ~G4HadIntProcessor();
/** AlgTool initailize method.*/
StatusCode initialize();
/** AlgTool finalize method */
StatusCode finalize();
/** interface for processing of the nuclear interactions */
bool hadronicInteraction(const Trk::TrackParameters& parm, double p, double E,
const Trk::MaterialProperties& mprop, double pathCorrection,
Trk::ParticleHypothesis particle=Trk::pion) const;
bool doHadronicInteraction(double time, const Trk::TrackParameters &parm,
const Trk::Material *ematprop,
Trk::ParticleHypothesis particle=Trk::pion,
bool processSecondaries=true) const;
/** interface for processing of the presampled nuclear interactions on layer*/
ISF::ISFParticleVector doHadIntOnLayer(const ISF::ISFParticle* parent, double time, const Trk::TrackParameters& parm,
const Trk::MaterialProperties *ematprop,
Trk::ParticleHypothesis particle=Trk::pion) const ;
private:
/** initialize G4RunManager on first call if not done by then */
bool initG4RunManager() const;
/** collect secondaries for layer material update */
ISF::ISFParticleVector getHadState(const ISF::ISFParticle* parent,
double time, const Trk::TrackParameters& parm,
const Trk::Material *ematprop) const;
//!< Initialize inleastic hadronic Geant4 processes
std::map<int,G4VProcess*>::iterator initProcessPDG(int pdg) const;
//!< retrieve TrackingGeometry (almost callback ready!)
StatusCode updateTrackingGeometry() const;
//!< random number service
ServiceHandle<IAtRndmGenSvc> m_rndGenSvc;
ToolHandle<ISF::IG4RunManagerHelper> m_g4RunManagerHelper;
//!< steering: enable elastic interactions?
bool m_doElastic;
/* scale factors for hadronic/electromagnetic interactions */
double m_hadIntProbScale;
// internal steering : clone type
double m_minEnergy;
mutable bool m_cloneParameters;
/** describe deflection parametric/do real deflection */
bool m_parametricScattering;
//!< Geant4 engine
mutable G4RunManager* m_g4runManager;
G4VUserPhysicsList* m_g4physicsList;
G4LayerDetectorConstruction* m_g4detector;
G4LayerPrimaryGeneratorAction* m_g4generatorAction;
G4LayerTrackingAction* m_g4trackingAction;
//!< Geant4 processes <PDGcode, process>
mutable std::map<int, G4VProcess*> m_g4HadrProcesses;
mutable std::map<int, G4VProcess*> m_g4HadrProcesses_Elastic;
//!< locally stored Geant4 instances (speeds up processing)
mutable G4DynamicParticle* m_g4dynPar;
mutable const G4ThreeVector* m_g4zeroPos;
mutable G4Step* m_g4step;
mutable G4StepPoint* m_g4stepPoint;
/** Tracking Geometry setup */
mutable const Trk::TrackingGeometry* m_trackingGeometry; //!< the tracking geometry owned by the navigator
ServiceHandle<Trk::ITrackingGeometrySvc> m_trackingGeometrySvc; //!< ServiceHandle to the TrackingGeometrySvc
std::string m_trackingGeometryName; //!< default name of the TrackingGeometry
/** ISF services & Tools */
ServiceHandle<ISF::IParticleBroker> m_particleBroker;
ServiceHandle<ISF::ITruthSvc> m_truthRecordSvc;
/** MCTruth process code for TruthIncidents created by this tool */
Barcode::PhysicsProcessCode m_processCode;
/** Random engine */
CLHEP::HepRandomEngine* m_randomEngine;
std::string m_randomEngineName; //!< Name of the random number stream
/** projection factor for the non-parametric scattering */
static double s_projectionFactor;
// ------------------------ Validation section ------------------------------------
bool m_validationMode;
ToolHandle<IPhysicsValidationTool> m_validationTool;
std::string m_validationTreeName; //!< validation tree name - to be acessed by this from root
std::string m_validationTreeDescription; //!< validation tree description - second argument in TTree
std::string m_validationTreeFolder; //!< stream/folder to for the TTree to be written out
TTree* m_validationTree; //!< Root Validation Tree
// ----------- ntuple branches
mutable int m_layerIndex; //!< ntuple variable : layer index of material effects update
mutable float m_tInX0; //!< nutple variable : t/X0
mutable float m_thetaMSproj; //!< ntuple variable : projected ms
mutable float m_thetaMSphi; //!< ntuple variable : ms in phi
mutable float m_thetaMStheta; //!< ntuple variable : ms in theta
mutable float m_deltaP; //!< nutple variable : energy loss
mutable float m_deltaPsigma; //!< ntuple variable : stragling on energy loss
bool m_bremValidation;
std::string m_bremValidationTreeName; //!< validation tree name - to be acessed by this from root
std::string m_bremValidationTreeDescription; //!< validation tree description - second argument in TTree
std::string m_bremValidationTreeFolder; //!< stream/folder to for the TTree to be written out
TTree* m_bremValidationTree; //!< Root Validation Tree
// ------ ntuple branches
mutable float m_bremPointX; //!< ntuple variable : brem point x coordinate
mutable float m_bremPointY; //!< ntuple variable : brem point y coordinate
mutable float m_bremPointR; //!< ntuple variable : brem point r distance
mutable float m_bremPointZ; //!< ntuple variable : brem point z coordinate
mutable float m_bremMotherEnergy; //!< ntuple variable : brem mother energy
mutable float m_bremPhotonEnergy; //!< ntuple variable : brem photon energy
mutable float m_bremPhotonAngle; //!< ntuple variable : brem photon angle
// --------------------------------------------------------------------------------
bool m_edValidation;
std::string m_edValidationTreeName; //!< validation tree name - to be acessed by this from root
std::string m_edValidationTreeDescription; //!< validation tree description - second argument in TTree
std::string m_edValidationTreeFolder; //!< stream/folder to for the TTree to be written out
TTree* m_edValidationTree; //!< Root Validation Tree
// ------ ntuple branches
mutable float m_edLayerIntersectX; //!< ntuple variable : energy deposit x coordinate
mutable float m_edLayerIntersectY; //!< ntuple variable : energy deposit y coordinate
mutable float m_edLayerIntersectZ; //!< ntuple variable : energy deposit z coordinate
mutable float m_edLayerIntersectR; //!< ntuple variable : energy deposit r coordinate
mutable float m_edLayerEnergyDeposit; //!< ntuple variable : energy despoit - value
mutable float m_edLayerSample; //!< ntuple variable : layer sample
};
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// G4ParticleDecayCreator.h, (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
#ifndef ISF_FATRASTOOLSG4_G4PARTICLEDECAYCREATOR_H
#define ISF_FATRASTOOLSG4_G4PARTICLEDECAYCREATOR_H
// Gaudi & Athena
#include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/ServiceHandle.h"
// iFatras
#include "ISF_FatrasInterfaces/IParticleDecayer.h"
// Amg
#include "GeoPrimitives/GeoPrimitives.h"
class StoreGateSvc;
class G4RunManager;
namespace ISF
{
class ISFParticle;
class IParticleBroker;
class IG4RunManagerHelper;
}
namespace iFatras
{
class PDGToG4Particle;
/** @class G4ParticleDecayCreator
G4 implementationof the IParticleDecayer interface from Fatras
@author Joerg.Mechnich -at- cern.ch, Andreas.Salzburger -at- cern.ch
*/
class G4ParticleDecayCreator: public AthAlgTool,
virtual public IParticleDecayer
{
public:
/**AlgTool constructor for G4ParticleDecayCreator*/
G4ParticleDecayCreator( const std::string&,
const std::string&,
const IInterface*);
/** AlgTool initailize method.*/
StatusCode initialize();
/** AlgTool finalize method */
StatusCode finalize();
/** implementation of IParticleDecayer method for particle decay */
std::vector<ISF::ISFParticle*> decayParticle(const ISF::ISFParticle& parent,
const Amg::Vector3D& vertex,
const Amg::Vector3D& mom,
int pdgCode,
double timeStamp = 0) const;
private:
/** initialize G4RunManager on first call if not done by then */
bool initG4RunManager() const;
/*---------------------------------------------------------------------
* Service & ToolHandles
*---------------------------------------------------------------------*/
ToolHandle<ISF::IG4RunManagerHelper> m_g4RunManagerHelper; //!< G4RunManager needs to be initialized before G4 tables are accessed
/** Handle on the PDGToG4Particle converter */
ToolHandle<PDGToG4Particle> m_pdgToG4Conv;
mutable G4RunManager* m_g4runManager; //!< for dummy G4 initialization
};
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// G4ParticleDecayHelper.h, (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
#ifndef ISF_FATRASTOOLSG4_G4PARTICLEDECAYHELPER_H
#define ISF_FATRASTOOLSG4_G4PARTICLEDECAYHELPER_H
// Gaudi & Athena
#include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/ServiceHandle.h"
#include "GaudiKernel/ToolHandle.h"
#include "AthenaKernel/IAtRndmGenSvc.h"
// ISF
#include "ISF_Event/ITruthIncident.h"
#include "ISF_Event/ISFParticleVector.h"
// iFatras
#include "ISF_FatrasInterfaces/IParticleDecayHelper.h"
// Trk
#include "TrkParameters/TrackParameters.h"
// STD
#include <vector>
#include <math.h>
class StoreGateSvc;
class G4RunManager;
namespace ISF {
class ISFParticle;
class IParticleBroker;
class ITruthSvc;
class IG4RunManagerHelper;
}
namespace Trk {
class Track;
class TrackingVolume;
class IMagneticFieldTool;
}
namespace iFatras {
class ITrackCreator;
class IParticleDecayer;
class PDGToG4Particle;
class IPhysicsValidationTool;
/** @class G4ParticleDecayHelper
This Tool is a helper tool wrapping the IParticleDecayCreator,
and organised the flight distance to
@author Andreas.Salzburger@cern.ch, Joerg.Mechnich@cern.ch
*/
class G4ParticleDecayHelper : public AthAlgTool,
virtual public IParticleDecayHelper {
public:
/**AlgTool constructor for ParticleDecayHelper*/
G4ParticleDecayHelper(const std::string&,const std::string&,const IInterface*);
/**Destructor*/
~G4ParticleDecayHelper();
/** AlgTool initailize method.*/
StatusCode initialize();
/** AlgTool finalize method */
StatusCode finalize();
/** free path estimator (-1 for stable particle) */
double freePath(const ISF::ISFParticle& isp) const;
/** decay */
void decay(const ISF::ISFParticle& isp) const;
private:
/** initialize G4RunManager on first call if not done by then */
bool initG4RunManager() const;
/** fill decay products: into broker svc, truth svc */
void handleDecayParticles(const ISF::ISFParticle& isp,
const ISF::ISFParticleVector& children) const;
/*------------------------------------------------------------
* ServiceHandles
*------------------------------------------------------------*/
ServiceHandle<ISF::IParticleBroker> m_particleBroker; //!< Broker Svc for ISF particles
ServiceHandle<ISF::ITruthSvc> m_truthRecordSvc; //!< Truth Svc for truth tree
ServiceHandle<IAtRndmGenSvc> m_rndmSvc; //!< Random Svc
CLHEP::HepRandomEngine* m_randomEngine; //!< Random engine (updated to streams)
std::string m_randomEngineName; //!< Name of the random number stream
std::string m_G4RandomEngineName; //!< Name of the random number stream for G4 tools
/*------------------------------------------------------------
* ToolHandles
*------------------------------------------------------------*/
ToolHandle<ISF::IG4RunManagerHelper> m_g4RunManagerHelper; //!< G4RunManager needs to be initialized before G4 tables are accessed
ToolHandle<IParticleDecayer> m_particleDecayCreator; //!< Handle for the G4ParticleDecayer AlgTool
ToolHandle<PDGToG4Particle> m_pdgToG4Conv; //!< Handle for the PDGToG4Particle converter tool
mutable G4RunManager* m_g4runManager; //!< for dummy G4 initialization
/** Validation output with histogram service */
bool m_validationMode; //!< turn validation mode on/off
ToolHandle<IPhysicsValidationTool> m_validationTool; //!< the ntuple
/*------------------------------------------------------------
* Statistics counter
*------------------------------------------------------------*/
mutable size_t m_nProcessedParticles;
mutable size_t m_nStableParticles;
mutable size_t m_nExitedParticles;
mutable size_t m_nDecayedParticles;
mutable size_t m_nChargedParticles;
mutable size_t m_nNeutralParticles;
/*---------------------------------------------------------------------
* Private static members
*---------------------------------------------------------------------*/
/** the speed of light in SI units */
static double s_speedOfLightSI;
};
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// G4ParticlePropertyTool.h, (c) ATLAS Detector Software
///////////////////////////////////////////////////////////////////
#ifndef ISF_FATRASTOOLSG4_G4PARTICLEPROPERTYTOOL_H
#define ISF_FATRASTOOLSG4_G4PARTICLEPROPERTYTOOL_H
// Gaudi & Athena
#include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/ToolHandle.h"
// Fatras
#include "ISF_FatrasInterfaces/IParticlePropertyTool.h"
namespace iFatras
{
class PDGToG4Particle;
/**
@class G4ParticlePropertyTool
This tool retrieves basic particle properties from PartPropSvc /
HepPDT
@author Joerg.Mechnich@cern.ch
*/
class G4ParticlePropertyTool : public AthAlgTool,
virtual public IParticlePropertyTool
{
public:
/**Constructor */
G4ParticlePropertyTool( const std::string&,
const std::string&,
const IInterface*);
/**Destructor*/
~G4ParticlePropertyTool();
/** AlgTool initailize method.*/
StatusCode initialize();
/** AlgTool finalize method */
StatusCode finalize();
/** get list of particles */
std::vector<std::pair<int,std::string> >
listOfParticles() const;
/** retrieve basic information of the particle */
StatusCode
basicInfo( int pdgCode, int* charge=0, double* mass=0) const;
private:
/*---------------------------------------------------------------------
* Private members
*---------------------------------------------------------------------*/
/*---------------------------------------------------------------------
* ToolHandles
*---------------------------------------------------------------------*/
ToolHandle<PDGToG4Particle> m_pdgToG4Conv;
};
}
#endif // FATRASINTERFACES_PARTICLEPROPERTYTOOL_H
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
// PDGToG4Particle.h, (c) ATLAS Detector software
///////////////////////////////////////////////////////////////////
#ifndef FATRASG4TOOLS_PDGTOG4PARTICLE_H
#define FATRASG4TOOLS_PDGTOG4PARTICLE_H
// Gaudi
#include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/MsgStream.h"
// STL
#include <map>
#include <vector>
#include <string>
class G4ParticleDefinition;
namespace iFatras
{
static const InterfaceID IID_PDGToG4Particle("PDGToG4Particle", 1, 0);
/** @class PDGToG4Particle
AlgTool to convert a pdgCode into a particle definition used by the G4 decayer
@author Joerg.Mechnich -at- cern.ch, Andreas.Salzburger -at- cern.ch
*/
class PDGToG4Particle : public AthAlgTool
{
public:
/** Default constructor */
PDGToG4Particle( const std::string&,
const std::string&,
const IInterface*);
virtual ~PDGToG4Particle();
/** AlgTool initailize method.*/
StatusCode initialize();
/** AlgTool finalize method */
StatusCode finalize();
/** AlgTool interface methods */
static const InterfaceID& interfaceID() { return IID_PDGToG4Particle; }
/**
Returns the G4ParticleDefinition of particle with PDG ID pdgCode,
0 otherwise.
*/
virtual G4ParticleDefinition* getParticleDefinition( int pdgCode) const;
/**
returns a vector of pdgid / particlename pairs containing all particles
*/
virtual std::vector<std::pair<int,std::string> > listOfParticles() const;
/** prints list of particles to stdout */
virtual void printListOfParticles( bool withDecayTableOnly=false) const;
typedef std::map<int,G4ParticleDefinition*> PDGG4ParticleMap;
private:
/*---------------------------------------------------------------------
* Static private members