48 G4Exception(
"MDTSensitiveDetector::ProcessHits",
"MDTHitCollectionMissing", FatalException,
49 "Hit collection not initialized; did SetupEvent run?");
52 G4Track* currentTrack = aStep->GetTrack();
55 if (currentTrack->GetDefinition()->GetPDGCharge() == 0.0) {
56 if (currentTrack->GetDefinition()!=G4Geantino::GeantinoDefinition())
return true;
57 else if (currentTrack->GetDefinition()==G4ChargedGeantino::ChargedGeantinoDefinition())
return true;
60 G4VPhysicalVolume* physVolPostStep = aStep->GetPostStepPoint()->GetPhysicalVolume();
61 if (
nullptr == physVolPostStep)
return true;
67 localPosition.setZero();
70 const G4AffineTransform trans = currentTrack->GetTouchable()->GetHistory()->GetTopTransform();
78 Amg::Vector3D localDirection( (localVertex2 - localVertex1) );
79 localDirection.z() = 0.;
82 if( (localVertex2.dot(localDirection)) * (localVertex1.dot(localDirection)) < 0 ) {
85 double Xpos = localVertex1[0];
86 double Ypos = localVertex1[1];
87 double Xdir = localDirection[0];
88 double Ydir = localDirection[1];
90 double Alpha = -1*(Xpos*Xdir + Ypos*Ydir)/(Xdir*Xdir + Ydir*Ydir);
92 localPosition = localVertex1 + Alpha*(localVertex2-localVertex1);
93 driftRadius = localPosition.perp();
94 globalTime = aStep->GetPreStepPoint()->GetGlobalTime();
99 double dist1 = localVertex1.perp();
100 double dist2 = localVertex2.perp();
103 localPosition = localVertex1;
104 globalTime = aStep->GetPreStepPoint()->GetGlobalTime();
107 localPosition = localVertex2;
108 globalTime = aStep->GetPostStepPoint()->GetGlobalTime();
119 G4String namePreStepMat = aStep->GetPreStepPoint()->GetMaterial()->GetName();
120 G4String namePostStepMat = aStep->GetPostStepPoint()->GetMaterial()->GetName();
121 G4String nameSD = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetSensitiveDetector()->GetName();
124 if( ((nameSD) && (namePreStepMat != namePostStepMat)) || (currentTrack->GetTrackStatus() == fStopAndKill)){
127 const G4TouchableHistory* touchHist =
static_cast<const G4TouchableHistory*
>(aStep->GetPreStepPoint()->GetTouchable());
135 aStep->GetStepLength(),
136 aStep->GetTotalEnergyDeposit(),
137 currentTrack->GetDefinition()->GetPDGEncoding(),
138 aStep->GetPreStepPoint()->GetKineticEnergy());
148 std::string stationName;
155 bool isAssembly =
false;
157 for (
int i = touchHist->GetHistoryDepth(); i>=0; i--) {
159 std::string::size_type npos;
160 std::string::size_type loc1;
161 std::string::size_type loc2;
162 std::string volName = touchHist->GetVolume(i)->GetName();
165 if ((npos = volName.find(
"av_")) != std::string::npos &&
166 (npos = volName.find(
"impr_")) != std::string::npos) isAssembly =
true;
169 if ((npos = volName.find(
"station")) != std::string::npos && (!isAssembly)) {
171 volName.resize(npos-2);
172 int volCopyNo = touchHist->GetVolume(i)->GetCopyNo();
173 volCopyNo=volCopyNo%1000;
174 stationName = volName;
175 stationEta = volCopyNo/100;
176 stationPhi = abs(volCopyNo%100);
179 else if ((npos = volName.find(
"component")) != std::string::npos && (!isAssembly)) {
182 if ((loc1 = volName.find(
'[')) != std::string::npos) {
183 if ((loc2 = volName.find(
']', loc1+1)) != std::string::npos) {
184 std::istringstream istrvar(volName.substr(loc1+1,loc2-loc1-1));
190 }
else if ((npos = volName.find(
"MDT")) != std::string::npos && isAssembly) {
208 if ((loc1 = volName.find(
"Muon::")) != std::string::npos) {
209 stationName = volName.substr(loc1+6,3);
212 int copyNr = touchHist->GetVolume(i)->GetCopyNo();
213 int copyNrBase = int(copyNr/100000);
214 int sideC = int(copyNrBase/10000);
215 int zi = int((copyNrBase%1000)/100);
216 int fi = int(copyNrBase%100);
217 if (sideC == 1) zi = -zi;
222 if ((loc1 = volName.find(
'[')) != std::string::npos) {
223 if ((loc2 = volName.find(
']', loc1+1)) != std::string::npos) {
224 std::istringstream istrvar(volName.substr(loc1+1,loc2-loc1-1));
229 }
else if ((npos = volName.find(
"Drift")) != std::string::npos) {
230 tubeLayer = touchHist->GetVolume(i)->GetCopyNo()/maxNTubesPerLayer;
231 tube = touchHist->GetVolume(i)->GetCopyNo()%maxNTubesPerLayer;
235 return m_muonHelper->BuildMdtHitId(stationName, stationPhi, stationEta, multilayer,tubeLayer, tube);