19 #include "G4ThreeVector.hh"
20 #include "G4SDManager.hh"
21 #include "G4Geantino.hh"
22 #include "G4ChargedGeantino.hh"
25 #include "CLHEP/Geometry/Transform3D.h"
32 : G4VSensitiveDetector(
name )
33 , m_HitColl( hitCollectionName )
48 double edep = aStep->GetTotalEnergyDeposit();
50 if(aStep->GetTrack()->GetDefinition()!=G4Geantino::GeantinoDefinition() &&
51 aStep->GetTrack()->GetDefinition()!=G4ChargedGeantino::ChargedGeantinoDefinition())
58 const G4TouchableHistory *myTouch =
dynamic_cast<const G4TouchableHistory*
>(aStep->GetPreStepPoint()->GetTouchable());
60 G4cout <<
"SctSensorSD::ProcessHits bad dynamic_cast" << G4endl;
66 G4ThreeVector coord1 = aStep->GetPreStepPoint()->GetPosition();
67 G4ThreeVector coord2 = aStep->GetPostStepPoint()->GetPosition();
73 const G4AffineTransform transformation = myTouch->GetHistory()->GetTopTransform();
74 G4ThreeVector localPosition1 = transformation.TransformPoint(coord1);
75 G4ThreeVector localPosition2 = transformation.TransformPoint(coord2);
79 HepGeom::Point3D<double> lP1,lP2;
107 aStep->GetPreStepPoint()->GetGlobalTime(),
114 int &brlEcap,
int &layerDisk,
int &
etaMod,
int &phiMod,
int &
side) {
122 const int sensorCopyNo = myTouch->GetVolume()->GetCopyNo();
125 for (
int i=0;
i<myTouch->GetHistoryDepth();
i++){
126 std::string detname=myTouch->GetVolume(
i)->GetLogicalVolume()->GetName();
127 int copyno=myTouch->GetVolume(
i)->GetCopyNo();
128 G4cout <<
"Volume "<<detname <<
" Copy Nr. " << copyno << G4endl;
134 if(sensorCopyNo/1000) {
136 if(sensorCopyNo == 1000) {
137 side = myTouch->GetVolume(1)->GetCopyNo();
138 etaMod = myTouch->GetVolume(2)->GetCopyNo();
139 phiMod = myTouch->GetVolume(3)->GetCopyNo();
140 layerDisk = myTouch->GetVolume(5)->GetCopyNo();
141 }
else if(sensorCopyNo == 1100) {
143 int etaModTmp = myTouch->GetVolume(1)->GetCopyNo();
144 int sign = (etaModTmp>=0)? +1 : -1;
145 side = std::abs(etaModTmp)%2;
147 phiMod = myTouch->GetVolume(2)->GetCopyNo();
148 layerDisk = myTouch->GetVolume(4)->GetCopyNo();
149 }
else if(sensorCopyNo/100 == 12) {
151 int iSegment = sensorCopyNo%100;
152 int sensorEnvCopyNo = myTouch->GetVolume(1)->GetCopyNo();
153 if (sensorEnvCopyNo == 1000) {
154 side = myTouch->GetVolume(2)->GetCopyNo();
155 etaMod = myTouch->GetVolume(3)->GetCopyNo() + iSegment;
156 phiMod = myTouch->GetVolume(4)->GetCopyNo();
157 layerDisk = myTouch->GetVolume(6)->GetCopyNo();
158 }
else if (sensorEnvCopyNo == 1100) {
160 int etaModTmp = myTouch->GetVolume(2)->GetCopyNo();
161 int sign = (etaModTmp>=0)? +1 : -1;
162 side = std::abs(etaModTmp)%2;
163 etaMod =
sign * std::abs(etaModTmp)/2 + iSegment;
164 phiMod = myTouch->GetVolume(3)->GetCopyNo();
165 layerDisk = myTouch->GetVolume(5)->GetCopyNo();
168 description <<
"ProcessHits: Unrecognized geometry in SCT sensitive detector. Please contact the maintainer of the SCT Detector Description.";
169 G4Exception(
"SctSensorSD",
"UnrecognizedSCTGeometry1", FatalException,
description);
174 description <<
"ProcessHits: Unrecognized geometry in SCT sensitive detector. Please contact the maintainer of the SCT Detector Description.";
175 G4Exception(
"SctSensorSD",
"UnrecognizedSCTGeometry2", FatalException,
description);
179 G4cout <<
"In the SCT Barrel" << G4endl;
180 G4cout <<
"----- side : " <<
side << G4endl;
181 G4cout <<
"----- eta_module : " <<
etaMod << G4endl;
182 G4cout <<
"----- phi_module : " << phiMod << G4endl;
183 G4cout <<
"----- layer : " << layerDisk << G4endl;
184 G4cout <<
"----- barrel_ec : " << brlEcap<< G4endl;
191 int sensorCopyNoTest = sensorCopyNo/100;
192 if(sensorCopyNoTest == 5 || sensorCopyNoTest == 6) {
193 int signZ = (coord1z > 0) ? 1 : -1;
195 side = myTouch->GetVolume(0)->GetCopyNo() % 2;
196 if (sensorCopyNoTest == 5) {
197 etaMod = myTouch->GetVolume(3)->GetCopyNo();
198 layerDisk = myTouch->GetVolume(4)->GetCopyNo();
200 etaMod = myTouch->GetVolume(2)->GetCopyNo();
201 layerDisk = myTouch->GetVolume(3)->GetCopyNo();
203 int phiNumber = myTouch->GetVolume(1)->GetCopyNo();
206 int maxModules = (phiNumber & 0x00ff0000) >> 16;
207 int moduleZero = (phiNumber & 0xff000000) >> 24;
208 phiMod = phiNumber & 0x0000ffff;
212 if (maxModules && signZ < 0) phiMod = (maxModules + moduleZero - phiMod) % maxModules;
216 G4cout <<
"In the SCT EndCap" << G4endl;
217 G4cout <<
"----- side : " <<
side << G4endl;
218 G4cout <<
"----- phi_module : " << phiMod<< G4endl;
219 G4cout <<
"----- eta_module : " <<
etaMod << G4endl;
220 G4cout <<
"----- layerDisk : " << layerDisk << G4endl;
221 G4cout <<
"----- barrel_ec : " << brlEcap << G4endl;
226 description <<
"ProcessHits: Unrecognized geometry in SCT sensitive detector. Please contact the maintainer of the SCT Detector Description.";
227 G4Exception(
"SctSensorSD",
"UnrecognizedSCTGeometry3", FatalException,
description);