|
ATLAS Offline Software
|
Go to the documentation of this file.
7 #include "G4ThreeVector.hh"
9 #include "G4Geantino.hh"
10 #include "G4ChargedGeantino.hh"
17 #include "GaudiKernel/SystemOfUnits.h"
18 #include "GeoModelHelpers/throwExcept.h"
30 RpcSensitiveDetector::RpcSensitiveDetector(
const std::string&
name,
31 const std::string& output_key,
32 const std::string& trf_storeKey,
34 G4VSensitiveDetector{
name},
36 m_writeHandle{output_key},
37 m_trfCacheKey{trf_storeKey},
39 m_trfCacheKey.initialize().ignore();
47 if (!
m_writeHandle.recordNonConst(std::make_unique<xAOD::MuonSimHitContainer>(),
48 std::make_unique<xAOD::MuonSimHitAuxContainer>()).isSuccess()) {
57 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;
69 const G4TouchableHistory* touchHist =
static_cast<const G4TouchableHistory*
>(currentTrack->GetTouchable());
78 if (!trfStoreHandle.isValid()) {
82 gctx.setStore(std::make_unique<DetectorAlignStore>(*trfStoreHandle));
86 <<touchHist->GetHistory()->GetTopVolume()->GetName()
97 std::optional<double> travelDist = Amg::intersect<3>(localPos, localDir, Amg::Vector3D::UnitX(), 0.);
98 if (!travelDist)
return true;
99 const Amg::Vector3D locGapCross = localPos + (*travelDist) * localDir;
104 if (!etaHitID.is_valid()) {
108 const double globalTime = currentTrack->GetGlobalTime() + (*travelDist) / currentTrack->GetVelocity();
114 if (std::abs(locHitPos.z()) >
tolerance) {
116 throw std::runtime_error(
"Picked wrong gas gap");
126 hit->
setMass(currentTrack->GetDefinition()->GetPDGMass());
128 hit->
setPdgId(currentTrack->GetDefinition()->GetPDGEncoding());
151 <<
" gap width: "<<gapHalfWidth
152 <<
" gap length: "<<gapHalfLength);
157 return idHelper.channelID(readOutEle->
identify(),
163 const std::string stationVolume = touchHist->GetVolume(3)->GetName();
165 const std::vector<std::string> volumeTokens =
tokenize(stationVolume,
"_");
167 if (volumeTokens.size() != 7) {
168 THROW_EXCEPTION(
" Cannot deduce the station name from "<<stationVolume);
172 const std::string stName = volumeTokens[0].substr(0,3);
173 const int stationEta =
atoi(volumeTokens[2]);
174 const int stationPhi =
atoi(volumeTokens[3]);
177 const int doubletZ =
atoi(volumeTokens[6]);
180 const Identifier detElId = idHelper.padID(idHelper.stationNameIndex(stName),
int doubletPhiMax() const
Returns the maximum phi panel.
const MuonGMR4::RpcReadoutElement * getReadoutElement(const G4TouchableHistory *touchHist) const
Retrieves the matching readout element to a G4 hit.
double stripPhiLength() const
Returns the length of a phi strip.
void setIdentifier(const Identifier &id)
Sets the global ATLAS identifier.
SG::WriteHandle< xAOD::MuonSimHitContainer > m_writeHandle
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.
float round(const float toRound, const unsigned int decimals)
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)
Identifier getIdentifier(const ActsGeometryContext &gctx, const MuonGMR4::RpcReadoutElement *readOutEle, const Amg::Vector3D &hitAtGapPlane, bool phiGap) const
Extracts the gasGap Identifier of the hit expressed at the origin of the local gasGap system.
SG::ReadHandleKey< ActsTrk::DetectorAlignStore > m_trfCacheKey
ReadHandleKey to the DetectorAlignmentStore caching the relevant transformations needed in this event...
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...
int doubletPhi() const
Returns the doublet Phi field of the MuonReadoutElement identifier.
Eigen::Affine3d Transform3D
Class to provide easy MsgStream access and capabilities.
const MuonGMR4::MuonDetectorManager * m_detMgr
Pointer to the underlying detector manager.
int doubletZ() const
Returns the doublet Z field of the MuonReadoutElement identifier.
Include the GeoPrimitives which need to be put first.
G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist) override final
void setEnergyDeposit(const float deposit)
Sets the energy deposited by the traversing particle inside the gas volume.
void Initialize(G4HCofThisEvent *HCE) override final
member functions
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
virtual std::string toString(const Identifier &id) const =0
print all fields to string
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...
HepMcParticleLink GenerateParticleLink()
Generates a creates new HepMcParticleLink object on the stack based on GetUniqueID(),...
Polygon globalToLocal(const Polygon &pol, float z, const Trk::PlaneSurface &surf)
double stripEtaLength() const
Returns the length of an eta strip.
void setGlobalTime(const float time)
Sets the time of the traversing particle.
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.
virtual const RpcIdHelper & rpcIdHelper() const =0
access to RpcIdHelper
double gasGapPitch() const
Returns the thickness of a RPC gasgap.