11 #include <arich/simulation/SensitiveDetector.h>
12 #include <arich/dataobjects/ARICHSimHit.h>
15 #include <G4OpBoundaryProcess.hh>
16 #include <G4ProcessManager.hh>
19 #include <simulation/kernel/UserInfo.h>
23 #include <framework/datastore/StoreArray.h>
24 #include <framework/datastore/RelationArray.h>
37 SensitiveDetector::SensitiveDetector():
38 Simulation::SensitiveDetectorBase(
"ARICH",
Const::ARICH)
45 hits.registerInDataStore();
46 particles.registerRelationTo(hits);
54 G4Track& track = *aStep->GetTrack();
55 if (track.GetDefinition()->GetParticleName() !=
"opticalphoton")
return false;
58 const G4double globalTime = track.GetGlobalTime();
60 const G4StepPoint& postStep = *aStep->GetPostStepPoint();
61 const G4ThreeVector& postworldPosition = postStep.GetPosition();
63 const G4StepPoint& preStep = *aStep->GetPreStepPoint();
64 const G4ThreeVector& preworldPosition = preStep.GetPosition();
68 if (postworldPosition.z() - preworldPosition.z() > 0) dir = +1;
71 if (dir == 1 && postStep.GetStepStatus() != fGeomBoundary) {
return false;}
72 if (dir == -1 && preStep.GetStepStatus() != fGeomBoundary) {
return false;}
74 if ((track.GetNextVolume())->GetName() ==
"ARICH.HAPDWall") {
75 track.SetTrackStatus(fStopAndKill);
80 G4OpBoundaryProcessStatus theStatus = Undefined;
82 G4ProcessManager* OpManager = G4OpticalPhoton::OpticalPhoton()->GetProcessManager();
85 G4int MAXofPostStepLoops =
86 OpManager->GetPostStepProcessVector()->entries();
87 G4ProcessVector* fPostStepDoItVector =
88 OpManager->GetPostStepProcessVector(typeDoIt);
89 for (G4int i = 0; i < MAXofPostStepLoops; i++) {
90 G4VProcess* fCurrentProcess = (*fPostStepDoItVector)[i];
91 G4OpBoundaryProcess* opProcess =
dynamic_cast<G4OpBoundaryProcess*
>(fCurrentProcess);
92 if (opProcess) { theStatus = opProcess->GetStatus();
break;}
97 if (theStatus == 3 && dir < 0)
return 0;
98 if (theStatus == 4 && dir < 0) {
if (gRandom->Uniform() < 0.5) track.SetTrackStatus(fStopAndKill);
return 0; }
104 if (info) applyQE = info->getStatus() < 2;
108 double energy = track.GetKineticEnergy() / CLHEP::eV;
111 double fraction = info->getFraction();
113 if (theStatus == 3) qeffi *=
m_simPar->getQEScaling();
114 if (gRandom->Uniform() * fraction > qeffi) {
116 if (theStatus == 3 && gRandom->Uniform() <
m_simPar->getWindowAbsorbtion()) track.SetTrackStatus(fStopAndKill);
122 const G4int moduleID = dir > 0 ? postStep.GetTouchableHandle()->GetReplicaNumber(1) :
123 preStep.GetTouchableHandle()->GetReplicaNumber(2);
125 if (moduleID <= 0)
return false;
129 G4ThreeVector localPosition = dir > 0 ? postStep.GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(
131 preStep.GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(preworldPosition);
134 const G4double energy = track.GetKineticEnergy() / CLHEP::eV;
140 TVector2 locpos(localPosition.x() / CLHEP::cm, localPosition.y() / CLHEP::cm);
150 track.SetTrackStatus(fStopAndKill);