19 #include "G4ChargedGeantino.hh"
20 #include <G4EventManager.hh>
21 #include "G4Geantino.hh"
22 #include "G4SDManager.hh"
24 #include "G4ThreeVector.hh"
27 #include "CLHEP/Geometry/Transform3D.h"
28 #include "CLHEP/Units/SystemOfUnits.h"
33 : G4VSensitiveDetector(
name )
34 , m_HitCollName( hitCollectionName )
43 if(
auto* eventManger = G4EventManager::GetEventManager()){
54 if (verboseLevel>5) G4cout <<
"Process Hit" << G4endl;
56 G4double edep = aStep->GetTotalEnergyDeposit();
59 if(aStep->GetTrack()->GetDefinition() != G4Geantino::GeantinoDefinition() &&
60 aStep->GetTrack()->GetDefinition() != G4ChargedGeantino::ChargedGeantinoDefinition())
68 const G4TouchableHistory *myTouch =
dynamic_cast<const G4TouchableHistory*
>(aStep->GetPreStepPoint()->GetTouchable());
70 G4cout <<
"PixelSensorSD::ProcessHits bad dynamic_cast" << G4endl;
74 for (
int i=0;
i<myTouch->GetHistoryDepth();
i++){
75 std::string detname=myTouch->GetVolume(
i)->GetLogicalVolume()->GetName();
76 int copyno=myTouch->GetVolume(
i)->GetCopyNo();
77 G4cout <<
"Volume " <<detname <<
" Copy Nr. " << copyno << G4endl;
83 G4ThreeVector coord1 = aStep->GetPreStepPoint()->GetPosition();
84 G4ThreeVector coord2 = aStep->GetPostStepPoint()->GetPosition();
90 const G4AffineTransform transformation = myTouch->GetHistory()->GetTopTransform();
91 G4ThreeVector localPosition1 = transformation.TransformPoint(coord1);
92 G4ThreeVector localPosition2 = transformation.TransformPoint(coord2);
94 HepGeom::Point3D<double> lP1,lP2;
126 int BEcopyNo = myTouch->GetVolume()->GetCopyNo();
129 if(BEcopyNo == 100) {
132 etaMod = myTouch->GetVolume(1)->GetCopyNo();
136 phiMod = myTouch->GetVolume(2)->GetCopyNo();
140 LayerDisk = myTouch->GetVolume(3)->GetCopyNo();
145 G4cout <<
"In the Pixel Barrel" << G4endl;
146 G4cout <<
"----- Phi Module # " << phiMod << G4endl;
147 G4cout <<
"----- Eta Ladder # " <<
etaMod << G4endl;
148 G4cout <<
"----- Layer # " <<
LayerDisk << G4endl;
152 }
else if (BEcopyNo == 200) {
155 phiMod = myTouch->GetVolume(1)->GetCopyNo();
156 if (phiMod == 48) phiMod = 0;
161 LayerDisk = myTouch->GetVolume(2)->GetCopyNo();
164 BrlEcap = myTouch->GetVolume(3)->GetCopyNo();
170 BrlEcap = (coord1.z() > 0) ? 2 : -2;
175 G4cout <<
"In the Pixel EndCap" << G4endl;
176 G4cout <<
"----- PhiModule # " << phiMod << G4endl;
177 G4cout <<
"----- Disk # " <<
LayerDisk << G4endl;
178 G4cout <<
"----- Endcap # " << BrlEcap << G4endl;
182 }
else if (BEcopyNo == 300) {
185 phiMod = myTouch->GetVolume(1)->GetCopyNo();
188 etaMod = myTouch->GetVolume(2)->GetCopyNo()/2;
191 LayerDisk = myTouch->GetVolume(3)->GetCopyNo();
194 BrlEcap = myTouch->GetVolume(4)->GetCopyNo();
199 G4cout <<
"In the SLHC Pixel EndCap" << G4endl;
200 G4cout <<
"----- PhiModule # " << phiMod << G4endl;
201 G4cout <<
"----- Ring/Eta # " <<
etaMod << G4endl;
202 G4cout <<
"----- Disk # " <<
LayerDisk << G4endl;
203 G4cout <<
"----- Endcap # " << BrlEcap << G4endl;
206 }
else if(BEcopyNo == 400) {
215 LayerDisk = myTouch->GetVolume(1)->GetCopyNo();
218 phiMod = myTouch->GetVolume(3)->GetCopyNo();
221 BrlEcap = myTouch->GetVolume(4)->GetCopyNo();
225 G4cout <<
"In the DBM" << G4endl;
226 G4cout <<
"----- PhiModule # " << phiMod << G4endl;
227 G4cout <<
"----- Ring/Eta # " <<
etaMod << G4endl;
228 G4cout <<
"----- Disk # " <<
LayerDisk << G4endl;
229 G4cout <<
"----- Endcap # " << BrlEcap << G4endl;
232 }
else if(BEcopyNo == 500) {
234 std::string volName = myTouch->GetVolume()->GetName();
239 std::vector<std::string>
v;
240 std::istringstream
s(volName);
248 phiMod =
atoi(
v[2].c_str());
252 G4cout <<
"Volume name " << volName <<G4endl;
253 double xpos = coord1.x();
254 double ypos = coord1.y();
255 double zpos = coord1.z();
256 double r = sqrt(xpos*xpos+ypos*ypos);
257 G4cout <<
"In the Alpine " << G4endl;
258 G4cout <<
"----- PhiModule # " << phiMod << G4endl;
259 G4cout <<
"----- Ring/Eta # " <<
etaMod << G4endl;
260 G4cout <<
"----- Disk # " <<
LayerDisk << G4endl;
261 G4cout <<
"----- Endcap # " << BrlEcap << G4endl;
262 G4cout <<
"----- Pos # " <<
r<<
" "<<zpos << G4endl;
263 G4cout <<
"----- volume " << myTouch->GetVolume()->GetName()<< G4endl;
264 G4cout <<
" " << myTouch->GetVolume(1)->GetName()<<
" "<<
265 myTouch->GetVolume(2)->GetName()<<
" " << myTouch->GetVolume(3)->GetName()<<G4endl;
268 }
else if(BEcopyNo == 600) {
270 std::string volName = myTouch->GetVolume()->GetName();
275 std::vector<std::string>
v;
276 std::istringstream
s(volName);
282 BrlEcap =
atoi(
v[1].c_str());
284 phiMod =
atoi(
v[3].c_str());
288 double xpos = coord1.x();
289 double ypos = coord1.y();
290 double zpos = coord1.z();
291 double r = sqrt(xpos*xpos+ypos*ypos);
292 G4cout <<
"Volume name " << volName <<G4endl;
293 G4cout <<
"In the ITk EC ring " << G4endl;
294 G4cout <<
"----- PhiModule # " << phiMod << G4endl;
295 G4cout <<
"----- Ring/Eta # " <<
etaMod << G4endl;
296 G4cout <<
"----- Disk # " <<
LayerDisk << G4endl;
297 G4cout <<
"----- Endcap # " << BrlEcap << G4endl;
298 G4cout <<
"----- Pos # " <<
r<<
" "<<zpos << G4endl;
299 G4cout <<
"----- volume " << myTouch->GetVolume()->GetName()<< G4endl;
300 G4cout <<
" " << myTouch->GetVolume(1)->GetName()<<
" "<<
301 myTouch->GetVolume(2)->GetName()<<
" " << myTouch->GetVolume(3)->GetName()<<G4endl;
307 description <<
"ProcessHits: Unrecognized geometry in Pixel sensitive detector. Please contact the maintainer of the Pixel Detector Description.";
308 description <<
"If you are processing a GeoModelXML geometry, please ensure a PixelSensorGmxSD instance is used instead of this (PixelSensorSD).";
309 G4Exception(
"PixelSensorSD",
"UnrecognizedPixelGeometry", FatalException,
description);
318 aStep->GetPreStepPoint()->GetGlobalTime(),