ATLAS Offline Software
Loading...
Searching...
No Matches
ZDC_FiberSD Class Reference

#include <ZDC_FiberSD.h>

Inheritance diagram for ZDC_FiberSD:
Collaboration diagram for ZDC_FiberSD:

Public Member Functions

 ZDC_FiberSD (const G4String &name, const G4String &hitCollectionName, const float &readoutPos)
void Initialize (G4HCofThisEvent *) override final
G4bool ProcessHits (G4Step *, G4TouchableHistory *) override final

Private Member Functions

 FRIEND_TEST (ZDC_FiberSDtest, ProcessHits)
ZDC_SimFiberHitCollectionBuildergetHitCollection () const

Private Attributes

std::string m_hitCollectionName
ZDC_SimFiberHitCollectionBuilderm_HitColl {}
float m_readoutPos

Detailed Description

Definition at line 22 of file ZDC_FiberSD.h.

Constructor & Destructor Documentation

◆ ZDC_FiberSD()

ZDC_FiberSD::ZDC_FiberSD ( const G4String & name,
const G4String & hitCollectionName,
const float & readoutPos )

Definition at line 23 of file ZDC_FiberSD.cxx.

24 : G4VSensitiveDetector(name), m_hitCollectionName(hitCollectionName), m_readoutPos(readoutPos)
25{
26
27}
float m_readoutPos
Definition ZDC_FiberSD.h:40
std::string m_hitCollectionName
Definition ZDC_FiberSD.h:37

Member Function Documentation

◆ FRIEND_TEST()

ZDC_FiberSD::FRIEND_TEST ( ZDC_FiberSDtest ,
ProcessHits  )
private

◆ getHitCollection()

ZDC_SimFiberHitCollectionBuilder * ZDC_FiberSD::getHitCollection ( ) const
private

Definition at line 160 of file ZDC_FiberSD.cxx.

161{
162 auto* eventInfo = AtlasG4EventUserInfo::GetEventUserInfo();
163 if (!eventInfo) {
164 return nullptr;
165 }
166 auto hitCollections = eventInfo->GetHitCollectionMap();
167 return hitCollections ? hitCollections->Find<ZDC_SimFiberHitCollectionBuilder>(m_hitCollectionName) : nullptr;
168}
static AtlasG4EventUserInfo * GetEventUserInfo()

◆ Initialize()

void ZDC_FiberSD::Initialize ( G4HCofThisEvent * )
finaloverride

Definition at line 29 of file ZDC_FiberSD.cxx.

30{
32}
ZDC_SimFiberHitCollectionBuilder * m_HitColl
Definition ZDC_FiberSD.h:39
ZDC_SimFiberHitCollectionBuilder * getHitCollection() const

◆ ProcessHits()

G4bool ZDC_FiberSD::ProcessHits ( G4Step * aStep,
G4TouchableHistory *  )
finaloverride

Definition at line 41 of file ZDC_FiberSD.cxx.

42{
43 if (!m_HitColl) {
45 if (!m_HitColl) {
46 return false;
47 }
48 }
49
50 G4ThreeVector pos = aStep->GetTrack()->GetPosition();
51 G4ThreeVector momentum = aStep->GetPreStepPoint()->GetMomentum();
52
53 /*************************************************
54 * Reject everything but optical photons
55 **************************************************/
56 if (aStep->GetTrack()->GetDefinition() != G4OpticalPhoton::OpticalPhotonDefinition()){
57 return true;
58 }
59
60
61 /*************************************************
62 * Reject downward going photons
63 **************************************************/
64 if (momentum.y() < 0.0){
65 aStep->GetTrack()->SetTrackStatus(fStopAndKill);
66 return true;
67 }
68
69
70 /*************************************************
71 * Reject photons not at the boundary of two volumes
72 **************************************************/
73 G4StepPoint *endPoint = aStep->GetPostStepPoint();
74 if (endPoint->GetStepStatus() != fGeomBoundary)
75 return true;
76
77
78 /*************************************************
79 * Reject photons that are reflected back down
80 * from the top of the fiber
81 **************************************************/
82
83 // Get the refractive index
84 G4MaterialPropertiesTable *MPT = aStep->GetPreStepPoint()->GetMaterial()->GetMaterialPropertiesTable();
85 if (!MPT) //Safety check
86 return true;
87 G4MaterialPropertyVector *RindexMPV = MPT->GetProperty(kRINDEX);
88 if (!RindexMPV)//Safety check
89 return true;
90
91 G4double Rindex;
92 size_t index = 0;
93 double photonEnergy = aStep->GetTrack()->GetDynamicParticle()->GetTotalMomentum();
94 Rindex = RindexMPV->Value(photonEnergy, index);
95
96 //Determine the photon's angle from the vertical axis
97 G4ThreeVector momDir = aStep->GetPreStepPoint()->GetMomentumDirection();
98 G4double angleFromY = atan(sqrt(1 - pow(momDir.y(), 2.0)) / momDir.y());
99
100 // kill the photon if angle is greater than TIR critical angle
101 // We're assuming the fiber's top face's normal vector is parallel to the y axis
102 if (angleFromY > asin(1.0 / Rindex)){
103 aStep->GetTrack()->SetTrackStatus(fStopAndKill);
104 return true;
105 }
106
107 /*************************************************
108 * Reject photons that are not totally internally
109 * reflected inside the fiber
110 **************************************************/
111
112 G4bool isTIR = false;
113 G4ProcessVector *postStepDoItVector = G4OpticalPhoton::OpticalPhotonDefinition()->GetProcessManager()->GetPostStepProcessVector(typeDoIt);
114 G4int n_proc = postStepDoItVector->entries();
115 for (G4int i = 0; i < n_proc; ++i){
116 G4OpBoundaryProcess *opProc = dynamic_cast<G4OpBoundaryProcess *>((*postStepDoItVector)[i]);
117 if (opProc && opProc->GetStatus() == TotalInternalReflection){
118 isTIR = true;
119 break;
120 }
121 }
122
123 if(!isTIR){
124 aStep->GetTrack()->SetTrackStatus(fStopAndKill);
125 return true;
126 }
127
128 /*************************************************
129 * Simulate absorption by calculating the photon's
130 * remaining path length and rolling a random number
131 * against its absorption chance
132 **************************************************/
133 G4MaterialPropertyVector *AbsMPV = MPT->GetProperty(kABSLENGTH);
134 G4double Absorption = AbsMPV->Value(aStep->GetTrack()->GetDynamicParticle()->GetTotalMomentum(), index);
135
136 G4double pathLength = (m_readoutPos - pos.y()) / cos(angleFromY);
137 G4double absChance = 1 - exp(-pathLength / Absorption);
138
139 // This check amounts to if(absorbed)
140 if (CLHEP::RandFlat::shoot(0.0, 1.0) < absChance){
141 aStep->GetTrack()->SetTrackStatus(fStopAndKill);
142 return true;
143 }
144
145 /*************************************************
146 * Record the survivors
147 **************************************************/
148
149 Identifier id;
150 id = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetCopyNo();
151 m_HitColl->AddHit(id, photonEnergy);
152
153 /*************************************************
154 * Put the survivors out of their misery
155 **************************************************/
156 aStep->GetTrack()->SetTrackStatus(fStopAndKill);
157 return true;
158}
str index
Definition DeMoScan.py:362
constexpr int pow(int x)
Definition conifer.h:27

Member Data Documentation

◆ m_HitColl

ZDC_SimFiberHitCollectionBuilder* ZDC_FiberSD::m_HitColl {}
private

Definition at line 39 of file ZDC_FiberSD.h.

39{};

◆ m_hitCollectionName

std::string ZDC_FiberSD::m_hitCollectionName
private

Definition at line 37 of file ZDC_FiberSD.h.

◆ m_readoutPos

float ZDC_FiberSD::m_readoutPos
private

Definition at line 40 of file ZDC_FiberSD.h.


The documentation for this class was generated from the following files: