|
ATLAS Offline Software
|
Go to the documentation of this file.
7 #include "G4ThreeVector.hh"
9 #include "G4Geantino.hh"
10 #include "G4ChargedGeantino.hh"
17 #include "GeoModelHelpers/throwExcept.h"
18 #include "GaudiKernel/SystemOfUnits.h"
32 MmSensitiveDetector::MmSensitiveDetector(
const std::string&
name,
33 const std::string& output_key,
34 const std::string& trf_storeKey,
36 G4VSensitiveDetector{
name},
38 m_writeHandle{output_key},
39 m_trfCacheKey{trf_storeKey},
41 m_trfCacheKey.initialize().ignore();
49 if (!
m_writeHandle.recordNonConst(std::make_unique<xAOD::MuonSimHitContainer>(),
50 std::make_unique<xAOD::MuonSimHitAuxContainer>()).isSuccess()) {
58 G4Track* currentTrack = aStep->GetTrack();
60 if (currentTrack->GetDefinition()->GetPDGCharge() == 0.0) {
61 if (currentTrack->GetDefinition()!= G4Geantino::GeantinoDefinition())
return true;
62 else if (currentTrack->GetDefinition()==G4ChargedGeantino::ChargedGeantinoDefinition())
return true;
67 if (currentTrack->GetVelocity() < velCutOff)
return true;
72 if (!trfStoreHandle.isValid()) {
76 gctx.setStore(std::make_unique<DetectorAlignStore>(*trfStoreHandle));
78 const G4TouchableHistory* touchHist =
static_cast<const G4TouchableHistory*
>(currentTrack->GetTouchable());
84 << touchHist->GetHistory()->GetTopVolume()->GetName()
95 std::optional<double> travelDist = Amg::intersect<3>(localPos, localDir, Amg::Vector3D::UnitX(), 0.);
96 if (!travelDist)
return true;
97 const Amg::Vector3D locGapCross = localPos + (*travelDist) * localDir;
102 if (!hitID.is_valid()) {
106 const double globalTime = currentTrack->GetGlobalTime() + (*travelDist) / currentTrack->GetVelocity();
118 hit->
setMass(currentTrack->GetDefinition()->GetPDGMass());
120 hit->
setPdgId(currentTrack->GetDefinition()->GetPDGEncoding());
135 <<std::abs(gapCentre.z() - hitAtGapPlane.z()));
136 if (std::abs(gapCentre.z() - hitAtGapPlane.z()) <
tolerance) {
147 const G4TouchableHistory* touchHist)
const {
149 const std::string& stationVolume = touchHist->GetVolume(4)->GetName();
151 const std::vector<std::string> volumeTokens =
tokenize(stationVolume.substr(stationVolume.rfind(
"NSW") + 4),
"_");
153 if (volumeTokens.size() != 4) {
154 THROW_EXCEPTION(
" Cannot deduce the station name from "<<stationVolume);
157 const std::string stName = volumeTokens[0][0] ==
'S' ?
"MMS" :
"MML";
158 const int stationEta =
atoi(volumeTokens[2]);
159 const int stationPhi =
atoi(volumeTokens[3]);
162 const Identifier detElIdMl1 = idHelper.channelID(idHelper.stationNameIndex(stName), stationEta, stationPhi, 1, 1, 1);
163 const Identifier detElIdMl2 = idHelper.multilayerID(detElIdMl1, 2);
166 if (!readOutElemMl1 || !readOutElemMl2) {
176 return std::abs(centerMl2.z()) -
tolerance <= std::abs(transformCenter.z()) ? readOutElemMl2 : readOutElemMl1;
void setIdentifier(const Identifier &id)
Sets the global ATLAS identifier.
unsigned int nGasGaps() const
Returns the number of gas gaps.
Identifier getIdentifier(const ActsGeometryContext &gctx, const MuonGMR4::MmReadoutElement *readOutEle, const Amg::Vector3D &hitAtGapPlane) const
Identify the gasGap layer of the hit.
std::vector< std::string > tokenize(const std::string &the_str, std::string_view delimiters)
Splits the string into smaller substrings.
void setPdgId(int id)
Sets the pdgID of the traversing particle.
Amg::Transform3D getTransform(const G4VTouchable *history, unsigned int level)
Extracts the local -> global transformation from a TouchableHistory at a given level.
MeasVector< N > toStorage(const AmgVector(N)&amgVec)
Converts the double precision of the AmgVector into the floating point storage precision of the MeasV...
virtual std::string toStringDetEl(const Identifier &id) const =0
print all fields up to detector element to string
void setLocalPosition(MeasVector< 3 > vec)
Sets the local position of the traversing particle.
Amg::Transform3D globalToLocalTrans(const ActsGeometryContext &ctx) const
Transformations to translate between local <-> global coordinates.
#define ATH_MSG_VERBOSE(x)
void setGenParticleLink(const HepMcParticleLink &link)
Sets the link to the HepMC particle producing this hit.
#define THROW_EXCEPTION(MSG)
virtual const MmIdHelper & mmIdHelper() const =0
access to CscIdHelper
def gap(flags, cells_name, *args, **kw)
SG::WriteHandle< xAOD::MuonSimHitContainer > m_writeHandle
void setMass(const float m)
set the rest-mass of the traversing particle
Amg::Vector3D Hep3VectorToEigen(const CLHEP::Hep3Vector &CLHEPvector)
Converts a CLHEP-based CLHEP::Hep3Vector into an Eigen-based Amg::Vector3D.
void setKineticEnergy(const float energy)
Sets the kinetic energy of the traversing particle.
Include the common definitions from the MuonReadoutGeometry.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
Eigen::Affine3d Transform3D
Identifier measurementId(const IdentifierHash &measHash) const override final
Converts the measurement hash back to the full Identifier.
Amg::Vector3D center(const ActsGeometryContext &ctx) const
Returns the detector center (Which is the same as the detector center of the first measurement layer)
Class to provide easy MsgStream access and capabilities.
G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist) override final
Include the GeoPrimitives which need to be put first.
void setEnergyDeposit(const float deposit)
Sets the energy deposited by the traversing particle inside the gas volume.
void setLocalDirection(MeasVector< 3 > vec)
Sets the local direction of the traversing particle.
Identifier identify() const override final
Return the athena identifier.
Eigen::Matrix< double, 3, 1 > Vector3D
const MuonGMR4::MmReadoutElement * getReadoutElement(const ActsGeometryContext &gctx, const G4TouchableHistory *touchHist) const
Retrieves the matching readout element to a G4 hit.
const Muon::IMuonIdHelperSvc * idHelperSvc() const
Returns a pointer to the central MuonIdHelperSvc.
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
SG::ReadHandleKey< ActsTrk::DetectorAlignStore > m_trfCacheKey
ReadHandleKey to the DetectorAlignmentStore caching the relevant transformations needed in this event...
HepMcParticleLink GenerateParticleLink()
Generates a creates new HepMcParticleLink object on the stack based on GetUniqueID(),...
void Initialize(G4HCofThisEvent *HCE) override final
member functions
const MuonGMR4::MuonDetectorManager * m_detMgr
Pointer to the underlying detector manager.
Polygon globalToLocal(const Polygon &pol, float z, const Trk::PlaneSurface &surf)
void setGlobalTime(const float time)
Sets the time of the traversing particle.
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.