|
ATLAS Offline Software
|
Go to the documentation of this file.
10 #include <G4Geantino.hh>
11 #include <G4ChargedGeantino.hh>
16 #include <GeoModelHelpers/throwExcept.h>
18 #include <GaudiKernel/SystemOfUnits.h>
26 MdtSensitiveDetector::MdtSensitiveDetector(
const std::string&
name,
27 const std::string& output_key,
28 const std::string& trfStore_key,
30 G4VSensitiveDetector{
name},
32 m_writeHandle{output_key},
33 m_trfCacheKey{trfStore_key},
35 m_trfCacheKey.initialize().ignore();
43 if (!
m_writeHandle.recordNonConst(std::make_unique<xAOD::MuonSimHitContainer>(),
44 std::make_unique<xAOD::MuonSimHitAuxContainer>()).isSuccess()) {
52 const std::string stationVolume = touchHist->GetVolume(2)->GetName();
54 const std::vector<std::string> volumeTokens =
tokenize(stationVolume,
"_");
56 if (volumeTokens.size() != 5) {
57 THROW_EXCEPTION(
" Cannot deduce the station name from "<<stationVolume);
60 const std::string stName = volumeTokens[0].substr(0,3);
61 const int stationEta =
atoi(volumeTokens[2]);
62 const int stationPhi =
atoi(volumeTokens[3]);
66 const Identifier detElId = idHelper.multilayerID(idHelper.elementID(stName,stationEta, stationPhi),
multiLayer);
77 G4Track* currentTrack = aStep->GetTrack();
80 if (currentTrack->GetDefinition()->GetPDGCharge() == 0.0) {
81 if (currentTrack->GetDefinition()!= G4Geantino::GeantinoDefinition())
return true;
82 else if (currentTrack->GetDefinition() != G4ChargedGeantino::ChargedGeantinoDefinition())
return true;
88 if (currentTrack->GetVelocity() < velCutOff)
return true;
90 const G4TouchableHistory* touchHist =
static_cast<const G4TouchableHistory*
>(currentTrack->GetTouchable());
96 if (!trfStoreHandle.isValid()) {
100 gctx.setStore(std::make_unique<DetectorAlignStore>(*trfStoreHandle));
103 if (!
HitID.is_valid()) {
119 trackLocPos, trackLocDir).value_or(0);
121 const Amg::Vector3D driftHit{trackLocPos + lambda * trackLocDir};
123 const double globalTime{currentTrack->GetGlobalTime() + lambda / currentTrack->GetVelocity()};
128 <<
", barcode: "<<trHelp.GenerateParticleLink().barcode()
129 <<
", "<<(*currentTrack)
132 <<
" to SimHit container ahead. ");
139 hit->
setMass(currentTrack->GetDefinition()->GetPDGMass());
141 hit->
setPdgId(currentTrack->GetDefinition()->GetPDGEncoding());
150 const G4TouchableHistory* touchHist)
const {
160 THROW_EXCEPTION(
"Tube hit in nirvana -- It seems that the tube position "
161 <<
Amg::toString(refTubePos, 2)<<
", perp: "<<refTubePos.perp()
162 <<
" is outside of the volume envelope "
167 const double tubePitches = refTubePos.y() / readOutEle->
tubePitch();
176 if (closureCheck.translation().y() > 0) ++
tube;
185 THROW_EXCEPTION(
"Tube hit in Nirvana -- It seems that the tube position "
186 <<
Amg::toString(refTubePos, 2)<<
", perp: "<<refTubePos.perp()
187 <<
" is outside of the volume envelope "
189 <<
"Layer: "<<
layer<<
", tube: "<<
tube<<
" "
191 <<
"tube volume : "<<touchHist->GetVolume(0)->GetName()
192 <<
" mdt chamber: "<<touchHist->GetVolume(2)->GetName());
void setIdentifier(const Identifier &id)
Sets the global ATLAS identifier.
unsigned int numTubesInLay() const
Returns the number of tubes per layer.
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.
static IdentifierHash measurementHash(unsigned int layerNumber, unsigned int tubeNumber)
Transform the layer and tube number to the measurementHash.
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...
const MuonGMR4::MuonDetectorManager * m_detMgr
Pointer to the underlying detector manager.
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.
void Initialize(G4HCofThisEvent *HCE) override final
member functions
#define ATH_MSG_VERBOSE(x)
void setGenParticleLink(const HepMcParticleLink &link)
Sets the link to the HepMC particle producing this hit.
#define THROW_EXCEPTION(MSG)
@ u
Enums for curvilinear frames.
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.
Identifier measurementId(const IdentifierHash &measHash) const override final
Converts the measurement hash back to the full Identifier.
const MuonGMR4::MdtReadoutElement * getReadoutElement(const G4TouchableHistory *touchHist) const
Retrieves the matching readout element to a G4 hit.
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...
Identifier getIdentifier(const ActsGeometryContext &gctx, const MuonGMR4::MdtReadoutElement *reElement, const G4TouchableHistory *touchHist) const
Retrieves from the Readoutelement & the touchable history the Identifier.
Eigen::Affine3d Transform3D
Class to provide easy MsgStream access and capabilities.
bool isIdentity(const Amg::Transform3D &trans)
Checks whether the transformation is the Identity transformation.
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.
virtual const MdtIdHelper & mdtIdHelper() const =0
access to MdtIdHelper
void setLocalDirection(MeasVector< 3 > vec)
Sets the local direction of the traversing particle.
Identifier identify() const override final
Return the athena identifier.
double tubePitch() const
Returns the pitch between 2 tubes in a layer.
Eigen::Matrix< double, 3, 1 > Vector3D
virtual std::string toString(const Identifier &id) const =0
print all fields to string
#define ATH_MSG_WARNING(x)
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...
Handle class for reading from StoreGate.
SG::ReadHandleKey< ActsTrk::DetectorAlignStore > m_trfCacheKey
ReadHandleKey to the DetectorAlignmentStore caching the relevant transformations needed in this event...
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.
SG::WriteHandle< xAOD::MuonSimHitContainer > m_writeHandle