8 #include "G4Geantino.hh"
9 #include "G4ChargedGeantino.hh"
23 : G4VSensitiveDetector(
name )
24 , m_MDTHitColl( hitCollectionName )
27 , m_DEFAULT_TUBE_RADIUS( std::numeric_limits<
double>::
max() )
40 G4Track* currentTrack = aStep->GetTrack();
43 if (currentTrack->GetDefinition()->GetPDGCharge() == 0.0) {
44 if (currentTrack->GetDefinition()!=G4Geantino::GeantinoDefinition())
return true;
45 else if (currentTrack->GetDefinition()==G4ChargedGeantino::ChargedGeantinoDefinition())
return true;
48 G4VPhysicalVolume* physVolPostStep = aStep->GetPostStepPoint()->GetPhysicalVolume();
49 if (
nullptr == physVolPostStep)
return true;
55 localPosition.setZero();
58 const G4AffineTransform trans = currentTrack->GetTouchable()->GetHistory()->GetTopTransform();
66 Amg::Vector3D localDirection( (localVertex2 - localVertex1) );
67 localDirection.z() = 0.;
70 if( (localVertex2.dot(localDirection)) * (localVertex1.dot(localDirection)) < 0 ) {
73 double Xpos = localVertex1[0];
74 double Ypos = localVertex1[1];
75 double Xdir = localDirection[0];
76 double Ydir = localDirection[1];
78 double Alpha = -1*(Xpos*Xdir + Ypos*Ydir)/(Xdir*Xdir + Ydir*Ydir);
80 localPosition = localVertex1 + Alpha*(localVertex2-localVertex1);
82 globalTime = aStep->GetPreStepPoint()->GetGlobalTime();
87 double dist1 = localVertex1.perp();
88 double dist2 = localVertex2.perp();
91 localPosition = localVertex1;
92 globalTime = aStep->GetPreStepPoint()->GetGlobalTime();
95 localPosition = localVertex2;
96 globalTime = aStep->GetPostStepPoint()->GetGlobalTime();
107 G4String namePreStepMat = aStep->GetPreStepPoint()->GetMaterial()->GetName();
108 G4String namePostStepMat = aStep->GetPostStepPoint()->GetMaterial()->GetName();
109 G4String nameSD = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetSensitiveDetector()->GetName();
112 if( ((nameSD) && (namePreStepMat != namePostStepMat)) || (currentTrack->GetTrackStatus() == fStopAndKill)){
115 const G4TouchableHistory* touchHist =
static_cast<const G4TouchableHistory*
>(aStep->GetPreStepPoint()->GetTouchable());
122 aStep->GetStepLength(),
123 aStep->GetTotalEnergyDeposit(),
124 currentTrack->GetDefinition()->GetPDGEncoding(),
125 aStep->GetPreStepPoint()->GetKineticEnergy());
142 bool isAssembly =
false;
144 for (
int i = touchHist->GetHistoryDepth();
i>=0;
i--) {
146 std::string::size_type npos;
147 std::string::size_type
loc1;
148 std::string::size_type
loc2;
149 std::string volName = touchHist->GetVolume(
i)->GetName();
152 if ((npos = volName.find(
"av_")) != std::string::npos &&
153 (npos = volName.find(
"impr_")) != std::string::npos) isAssembly =
true;
156 if ((npos = volName.find(
"station")) != std::string::npos && (!isAssembly)) {
158 volName.resize(npos-2);
159 int volCopyNo = touchHist->GetVolume(
i)->GetCopyNo();
160 volCopyNo=volCopyNo%1000;
166 else if ((npos = volName.find(
"component")) != std::string::npos && (!isAssembly)) {
169 if ((
loc1 = volName.find(
'[')) != std::string::npos) {
170 if ((
loc2 = volName.find(
']',
loc1+1)) != std::string::npos) {
171 std::istringstream istrvar(volName.substr(
loc1+1,
loc2-
loc1-1));
177 }
else if ((npos = volName.find(
"MDT")) != std::string::npos && isAssembly) {
195 if ((
loc1 = volName.find(
"Muon::")) != std::string::npos) {
199 int copyNr = touchHist->GetVolume(
i)->GetCopyNo();
200 int copyNrBase =
int(copyNr/100000);
202 int zi =
int((copyNrBase%1000)/100);
203 int fi =
int(copyNrBase%100);
204 if (
sideC == 1) zi = -zi;
209 if ((
loc1 = volName.find(
'[')) != std::string::npos) {
210 if ((
loc2 = volName.find(
']',
loc1+1)) != std::string::npos) {
211 std::istringstream istrvar(volName.substr(
loc1+1,
loc2-
loc1-1));
216 }
else if ((npos = volName.find(
"Drift")) != std::string::npos) {
217 tubeLayer = touchHist->GetVolume(
i)->GetCopyNo()/maxNTubesPerLayer;
218 tube = touchHist->GetVolume(
i)->GetCopyNo()%maxNTubesPerLayer;