|
ATLAS Offline Software
|
Go to the documentation of this file.
9 #include <GaudiKernel/SystemOfUnits.h>
35 return StatusCode::SUCCESS;
41 const EventContext & context = Gaudi::Hive::currentContext();
47 std::ofstream
file{std::string(Form(
"event%09zu-",++
m_event))+
"MuonSimHit.csv"};
48 const std::string delim =
",";
50 file<<
"StationName"<<delim;
51 file<<
"StationEta"<<delim;
52 file<<
"StationPhi"<<delim;
53 file<<
"LocalPositionExtrx"<<delim;
54 file<<
"LocalPositionExtry"<<delim;
55 file<<
"LocalPositionExtrz"<<delim;
56 file<<
"LocalDirectionx"<<delim;
57 file<<
"LocalDirectiony"<<delim;
58 file<<
"LocalDirectionz"<<std::endl;
61 std::set<TrueHitInChamb> usedStations{};
73 if (std::abs(simHit->pdgId()) != 13)
continue;
78 newHit.simHit = simHit;
86 const Amg::Vector3D localPos{toChamber * xAOD::toEigen(simHit->localPosition())};
87 newHit.lDir = toChamber.linear() * xAOD::toEigen(simHit->localDirection());
89 const std::optional<double> lambda = Amg::intersect<3>(localPos, newHit.lDir, Amg::Vector3D::UnitZ(), 0.);
90 newHit.lPos = localPos + (*lambda)*newHit.lDir;
92 auto insert_itr = usedStations.insert(newHit);
94 if (insert_itr.second)
continue;
99 if ((prevMuon.lPos - newHit.lPos).mag() >
tolerance ||
100 prevMuon.lDir.dot(newHit.lDir) < angleTolerance ) {
101 ATH_MSG_WARNING(
"Muon "<<newHit.simHit->genParticleLink()<<
" has a different ending point when it starts from "
104 <<
" -- vs. "<<
m_idHelperSvc->toString(newHit.simHit->identify())
112 file<<hit.simHit->pdgId()<<delim;
117 file<<hit.lPos.x()<<delim;
118 file<<hit.lPos.y()<<delim;
119 file<<hit.lPos.z()<<delim;
121 file<<hit.lDir.x()<<delim;
122 file<<hit.lDir.y()<<delim;
123 file<<hit.lDir.z()<<std::endl;
125 return StatusCode::SUCCESS;
def retrieve(aClass, aKey=None)
const SpectrometerSector * msSector() const
Returns the pointer to the envelope volume enclosing all chambers in the sector.
std::vector< Identifier > ID
const MuonGMR4::MuonDetectorManager * m_r4DetMgr
Access to the readout geometry.
StatusCode execute() override
The MuonReadoutElement is an abstract class representing the geometry representing the muon detector.
SG::ReadHandleKeyArray< xAOD::MuonSimHitContainer > m_inSimHitKey
#define ATH_MSG_VERBOSE(x)
int barcode() const
Return the barcode of the target particle.
Property holding a SG store/key/clid from which a ReadHandle is made.
const xAOD::MuonSimHit * simHit
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
const HepMcParticleLink & genParticleLink() const
Returns the link to the HepMC particle producing this hit.
::StatusCode StatusCode
StatusCode definition for legacy code.
Amg::Transform3D globalToLocalTrans(const ActsGeometryContext &gctx) const
Returns the global -> local transformation from the ATLAS global.
Eigen::Affine3d Transform3D
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
SimHitCsvDumperAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadHandleKey< ActsGeometryContext > m_geoCtxKey
Include the GeoPrimitives which need to be put first.
StatusCode initialize() override
Eigen::Matrix< double, 3, 1 > Vector3D
bool operator<(const TrueHitInChamb &other) const
This header ties the generic definitions in this package.
#define ATH_MSG_WARNING(x)
virtual IdentifierHash measurementHash(const Identifier &measId) const =0
Constructs the identifier hash from the full measurement Identifier.
const Amg::Transform3D & localToGlobalTrans(const ActsGeometryContext &ctx) const
Returns the local to global transformation into the ATLAS coordinate system.
Helper struct to map all muons in the same chamber.
const MuonReadoutElement * getReadoutElement(const Identifier &id) const
Returns a generic Muon readout element.