15 #include <GeoModelKernel/throwExcept.h>
16 #include <GaudiKernel/SystemOfUnits.h>
26 const std::string stationVolume = touchHist->GetVolume(2)->GetName();
28 const std::vector<std::string> volumeTokens =
tokenize(stationVolume,
"_");
30 if (volumeTokens.size() != 5) {
31 THROW_EXCEPTION(
" Cannot deduce the station name from "<<stationVolume);
34 const std::string stName = volumeTokens[0].substr(0,3);
35 const int stationEta =
atoi(volumeTokens[2]);
36 const int stationPhi =
atoi(volumeTokens[3]);
38 const MdtIdHelper& idHelper{m_detMgr->idHelperSvc()->mdtIdHelper()};
40 const Identifier detElId = idHelper.multilayerID(idHelper.elementID(stName,stationEta, stationPhi),
multiLayer);
45 <<m_detMgr->idHelperSvc()->toStringDetEl(detElId)<<
" "<<stationVolume);
50 G4bool MdtSensitiveDetector::ProcessHits(G4Step* aStep,G4TouchableHistory* ) {
53 if (!processStep(aStep)) {
56 G4Track* currentTrack = aStep->GetTrack();
57 const G4StepPoint* preStep = aStep->GetPreStepPoint();
58 const G4TouchableHistory* touchHist =
static_cast<const G4TouchableHistory*
>(preStep->GetTouchable());
65 if (!
HitID.is_valid()) {
85 trackLocPos, trackLocDir).value_or(0);
86 if (std::abs(currentTrack->GetDefinition()->GetPDGEncoding()) == 11) {
87 lambda = std::clamp(lambda, 0., aStep->GetStepLength());
90 const Amg::Vector3D driftHit{trackLocPos + lambda * trackLocDir};
93 const double globalTime{preStep->GetGlobalTime() + lambda / currentTrack->GetVelocity()};
95 if (std::abs(currentTrack->GetDefinition()->GetPDGEncoding()) == 11) {
97 if (lastRecord && lastRecord->
localPosition().perp() < driftHit.perp()) {
105 <<
", barcode: "<<trkHelp.GenerateParticleLink().barcode()
106 <<
", "<<(*currentTrack) <<
", driftCircle: "<<
Amg::toString(driftHit, 4)
107 <<
", direction "<<
Amg::toString(trackLocDir, 4) <<
" to SimHit container ahead. ");
108 saveHit(
HitID, driftHit, trackLocDir, globalTime, aStep);
113 const G4TouchableHistory* touchHist)
const {
123 THROW_EXCEPTION(
"Tube hit in nirvana -- It seems that the tube position "
124 <<
Amg::toString(refTubePos, 2)<<
", perp: "<<refTubePos.perp()
125 <<
" is outside of the volume envelope "
126 <<m_detMgr->idHelperSvc()->toStringDetEl(readOutEle->
identify())<<
". ");
130 const double tubePitches = refTubePos.y() / readOutEle->
tubePitch();
139 if (closureCheck.translation().y() > 0) ++
tube;
148 THROW_EXCEPTION(
"Tube hit in Nirvana -- It seems that the tube position "
149 <<
Amg::toString(refTubePos, 2)<<
", perp: "<<refTubePos.perp()
150 <<
" is outside of the volume envelope "
151 <<m_detMgr->idHelperSvc()->toStringDetEl(readOutEle->
identify())<<
". "
152 <<
"Layer: "<<
layer<<
", tube: "<<
tube<<
" "
154 <<
"tube volume : "<<touchHist->GetVolume(0)->GetName()
155 <<
" mdt chamber: "<<touchHist->GetVolume(2)->GetName());