8 #include "G4Geantino.hh"
9 #include "G4ChargedGeantino.hh"
27 : G4VSensitiveDetector(
name )
29 , m_MDTHitColl( hitCollectionName )
32 , m_DEFAULT_TUBE_RADIUS( std::numeric_limits<
double>::
max() )
50 G4Track* currentTrack = aStep->GetTrack();
53 if (currentTrack->GetDefinition()->GetPDGCharge() == 0.0) {
54 if (currentTrack->GetDefinition()!=G4Geantino::GeantinoDefinition())
return true;
55 else if (currentTrack->GetDefinition()==G4ChargedGeantino::ChargedGeantinoDefinition())
return true;
58 G4VPhysicalVolume* physVolPostStep = aStep->GetPostStepPoint()->GetPhysicalVolume();
59 if (
nullptr == physVolPostStep)
return true;
65 localPosition.setZero();
68 const G4AffineTransform trans = currentTrack->GetTouchable()->GetHistory()->GetTopTransform();
72 G4ThreeVector globVrtx = aStep->GetPreStepPoint()->GetPosition();
75 double dist = globVrtx.mag();
76 double lightspeed = 299.792458;
77 double tOrigin = dist / lightspeed;
79 G4int trackid = aStep->GetTrack()->GetTrackID();
94 double globalDist = sqrt((
m_globH[0] - globVrtx[0])*(
m_globH[0] - globVrtx[0]) +
97 double tof = globalDist / lightspeed;
106 Amg::Vector3D localDirection( (localVertex2 - localVertex1) );
107 localDirection.z() = 0.;
110 if( (localVertex2.dot(localDirection)) * (localVertex1.dot(localDirection)) < 0 ) {
113 double Xpos = localVertex1[0];
114 double Ypos = localVertex1[1];
115 double Xdir = localDirection[0];
116 double Ydir = localDirection[1];
118 double Alpha = -1*(Xpos*Xdir + Ypos*Ydir)/(Xdir*Xdir + Ydir*Ydir);
120 localPosition = localVertex1 + Alpha*(localVertex2-localVertex1);
122 globalTime = aStep->GetPreStepPoint()->GetGlobalTime();
127 double dist1 = localVertex1.perp();
128 double dist2 = localVertex2.perp();
131 localPosition = localVertex1;
132 globalTime = aStep->GetPreStepPoint()->GetGlobalTime();
135 localPosition = localVertex2;
136 globalTime = aStep->GetPostStepPoint()->GetGlobalTime();
151 G4String namePreStepMat = aStep->GetPreStepPoint()->GetMaterial()->GetName();
152 G4String namePostStepMat = aStep->GetPostStepPoint()->GetMaterial()->GetName();
153 G4String nameSD = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetSensitiveDetector()->GetName();
156 if( ((nameSD) && (namePreStepMat != namePostStepMat)) || (currentTrack->GetTrackStatus() == fStopAndKill)){
159 const G4TouchableHistory* touchHist =
static_cast<const G4TouchableHistory*
>(aStep->GetPreStepPoint()->GetTouchable());
166 aStep->GetStepLength(),
167 aStep->GetTotalEnergyDeposit(),
168 currentTrack->GetDefinition()->GetPDGEncoding(),
169 aStep->GetPreStepPoint()->GetKineticEnergy());
186 bool isAssembly =
false;
188 for (
int i = touchHist->GetHistoryDepth();
i>=0;
i--) {
190 std::string::size_type npos;
191 std::string::size_type
loc1;
192 std::string::size_type
loc2;
193 std::string volName = touchHist->GetVolume(
i)->GetName();
196 if ((npos = volName.find(
"av_")) != std::string::npos &&
197 (npos = volName.find(
"impr_")) != std::string::npos) isAssembly =
true;
200 if ((npos = volName.find(
"station")) != std::string::npos && (!isAssembly)) {
202 volName.resize(npos-2);
203 int volCopyNo = touchHist->GetVolume(
i)->GetCopyNo();
204 volCopyNo=volCopyNo%1000;
210 else if ((npos = volName.find(
"component")) != std::string::npos && (!isAssembly)) {
213 if ((
loc1 = volName.find(
'[')) != std::string::npos) {
214 if ((
loc2 = volName.find(
']',
loc1+1)) != std::string::npos) {
215 std::istringstream istrvar(volName.substr(
loc1+1,
loc2-
loc1-1));
221 }
else if ((npos = volName.find(
"MDT")) != std::string::npos && isAssembly) {
239 if ((
loc1 = volName.find(
"Muon::")) != std::string::npos) {
243 int copyNr = touchHist->GetVolume(
i)->GetCopyNo();
244 int copyNrBase =
int(copyNr/100000);
246 int zi =
int((copyNrBase%1000)/100);
247 int fi =
int(copyNrBase%100);
248 if (
sideC == 1) zi = -zi;
253 if ((
loc1 = volName.find(
'[')) != std::string::npos) {
254 if ((
loc2 = volName.find(
']',
loc1+1)) != std::string::npos) {
255 std::istringstream istrvar(volName.substr(
loc1+1,
loc2-
loc1-1));
260 }
else if ((npos = volName.find(
"Drift")) != std::string::npos) {
261 tubeLayer = touchHist->GetVolume(
i)->GetCopyNo()/maxNTubesPerLayer;
262 tube = touchHist->GetVolume(
i)->GetCopyNo()%maxNTubesPerLayer;