|
ATLAS Offline Software
|
Go to the documentation of this file.
8 #include "G4ThreeVector.hh"
10 #include "G4Geantino.hh"
11 #include "G4ChargedGeantino.hh"
18 #include "GaudiKernel/SystemOfUnits.h"
19 #include "GeoModelHelpers/throwExcept.h"
29 TgcSensitiveDetector::TgcSensitiveDetector(
const std::string&
name,
30 const std::string& output_key,
31 const std::string& trf_storeKey,
33 G4VSensitiveDetector{
name},
35 m_writeHandle{output_key},
36 m_trfCacheKey{trf_storeKey},
38 m_trfCacheKey.initialize().ignore();
46 if (!
m_writeHandle.recordNonConst(std::make_unique<xAOD::MuonSimHitContainer>(),
47 std::make_unique<xAOD::MuonSimHitAuxContainer>()).isSuccess()) {
55 G4Track* currentTrack = aStep->GetTrack();
58 if (currentTrack->GetDefinition()->GetPDGCharge() == 0.0) {
59 if (currentTrack->GetDefinition()!= G4Geantino::GeantinoDefinition())
return true;
60 else if (currentTrack->GetDefinition()==G4ChargedGeantino::ChargedGeantinoDefinition())
return true;
65 if (currentTrack->GetVelocity() < velCutOff)
return true;
67 const G4TouchableHistory* touchHist =
static_cast<const G4TouchableHistory*
>(currentTrack->GetTouchable());
76 if (!trfStoreHandle.isValid()) {
80 gctx.setStore(std::make_unique<DetectorAlignStore>(*trfStoreHandle));
84 <<currentTrack->GetTouchable()->GetHistory()->GetTopVolume()->GetName()
92 std::optional<double> travelDist = Amg::intersect<3>(locPos,
locDir, Amg::Vector3D::UnitX(), 0);
102 if (!etaHitID.is_valid()) {
107 const double globalTime = currentTrack->GetGlobalTime() + (*travelDist) / currentTrack->GetVelocity();
113 if (std::abs(locHitPos.z()) >
tolerance) {
115 throw std::runtime_error(
"Picked wrong gas gap");
129 hit->
setMass(currentTrack->GetDefinition()->GetPDGMass());
131 hit->
setPdgId(currentTrack->GetDefinition()->GetPDGEncoding());
139 const std::string stationVolume = touchHist->GetVolume(2)->GetName();
144 const size_t nTokens{volumeTokens.size()};
146 const std::string
stationName{volumeTokens[nTokens-4].substr(0,3)};
154 return m_detMgr->getTgcReadoutElement(stationId);
161 const Identifier firstChan = idHelper.channelID(readOutEle->
identify(), 1, phiGap, 1);
171 return idHelper.channelID(readOutEle->
identify(),
gasGap, phiGap, 1);
const MuonGMR4::MuonDetectorManager * m_detMgr
Pointer to the underlying detector manager.
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)
SG::ReadHandleKey< ActsTrk::DetectorAlignStore > m_trfCacheKey
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)
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.
Eigen::Affine3d Transform3D
Class to provide easy MsgStream access and capabilities.
double gasGapPitch() const
Returns the thickness of the gasGap.
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.
Identifier getIdentifier(const ActsGeometryContext &gctx, const MuonGMR4::TgcReadoutElement *readOutEle, const Amg::Vector3D &hitAtGapPlane, bool phiGap) const
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 const TgcIdHelper & tgcIdHelper() const =0
access to TgcIdHelper
virtual std::string toString(const Identifier &id) const =0
print all fields to string
void releaseUnAlignedTrfs() const
Releases all cached transforms that are not connected with alignment.
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(),...
void Initialize(G4HCofThisEvent *HCE) override final
member functions
const MuonGMR4::TgcReadoutElement * getReadoutElement(const G4TouchableHistory *touchHist) const
Retrieves the matching readout element to a G4 hit.
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.
G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist) override final