|
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 "GeoModelKernel/throwExcept.h"
32 sTgcSensitiveDetector::sTgcSensitiveDetector(
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()) {
59 G4Track* currentTrack = aStep->GetTrack();
62 if (currentTrack->GetDefinition()->GetPDGCharge() == 0.0) {
63 if (currentTrack->GetDefinition()!= G4Geantino::GeantinoDefinition())
return true;
64 else if (currentTrack->GetDefinition()==G4ChargedGeantino::ChargedGeantinoDefinition())
return true;
69 if (currentTrack->GetVelocity() < velCutOff)
return true;
71 const G4TouchableHistory* touchHist =
static_cast<const G4TouchableHistory*
>(currentTrack->GetTouchable());
76 if (!trfStoreHandle.isValid()) {
80 gctx.setStore(std::make_unique<DetectorAlignStore>(*trfStoreHandle));
89 << touchHist->GetHistory()->GetTopVolume()->GetName()
100 std::optional<double> travelDist = Amg::intersect<3>(localPos, localDir, Amg::Vector3D::UnitZ(), 0.);
101 if (!travelDist)
return true;
102 const Amg::Vector3D locGapCross = localPos + (*travelDist) * localDir;
108 if (!etaHitID.is_valid()) {
112 const double globalTime = currentTrack->GetGlobalTime() + (*travelDist) / currentTrack->GetVelocity();
117 if (std::abs(locHitPos.z()) >
tolerance) {
119 <<
"Wrong gas gap picked");
129 hit->
setMass(currentTrack->GetDefinition()->GetPDGMass());
131 hit->
setPdgId(currentTrack->GetDefinition()->GetPDGEncoding());
151 <<
" gasGap: "<< (std::abs(locHitPos.z()) / readOutEle->
gasGapPitch()) + 1);
157 const G4TouchableHistory* touchHist)
const {
161 const std::string& stationVolume = touchHist->GetVolume(3)->GetName();
163 const std::vector<std::string> volumeTokens =
tokenize(stationVolume.substr(stationVolume.rfind(
"Q")),
"_");
165 if (volumeTokens.size() != 4) {
166 THROW_EXCEPTION(
"Cannot deduce the station name from "<<stationVolume);
169 const std::string stName = volumeTokens[0][1] ==
'S' ?
"STS" :
"STL";
170 const int stationEta =
atoi(volumeTokens[2]);
171 const int stationPhi =
atoi(volumeTokens[3]);
174 const Identifier detElIdMl1 = idHelper.channelID(idHelper.stationNameIndex(stName), stationEta, stationPhi, 1, 1,
175 sTgcIdHelper::sTgcChannelTypes::Strip, 1);
176 const Identifier detElIdMl2 = idHelper.multilayerID(detElIdMl1, 2);
179 if (!readOutElemMl1 || !readOutElemMl2) {
188 return std::abs(centerMl2.z()) -
tolerance <= std::abs(transformCenter.z()) ? readOutElemMl2 : readOutElemMl1;
Identifier getIdentifier(const ActsGeometryContext &gctx, const MuonGMR4::sTgcReadoutElement *readOutEle, const Amg::Vector3D &hitAtGapPlane, sTgcIdHelper::sTgcChannelTypes chType) const
int multilayer() const
Returns the multilayer of the sTgcReadoutElement.
virtual const sTgcIdHelper & stgcIdHelper() const =0
access to TgcIdHelper
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.
double gasGapPitch() const
Distance between 2 gas gaps.
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)
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...
const MuonGMR4::MuonDetectorManager * m_detMgr
Pointer to the underlying detector manager.
Eigen::Affine3d Transform3D
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.
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.
G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist) override final
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::sTgcReadoutElement * getReadoutElement(const ActsGeometryContext &gctx, const G4TouchableHistory *touchHist) const
Retrieves the matching readout element to a G4 hit.
void Initialize(G4HCofThisEvent *HCE) override final
member functions
SG::ReadHandleKey< ActsTrk::DetectorAlignStore > m_trfCacheKey
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)
void setGlobalTime(const float time)
Sets the time of the traversing particle.
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.