ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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)
 
 ~ZDC_FiberSD ()
 
void Initialize (G4HCofThisEvent *) override final
 
G4bool ProcessHits (G4Step *, G4TouchableHistory *) override final
 
void EndOfAthenaEvent ()
 

Private Member Functions

 FRIEND_TEST (ZDC_FiberSDtest, ProcessHits)
 
 FRIEND_TEST (ZDC_FiberSDtest, Initialize)
 
 FRIEND_TEST (ZDC_FiberSDtest, StartOfAthenaEvent)
 
 FRIEND_TEST (ZDC_FiberSDtest, EndOfAthenaEvent)
 

Private Attributes

SG::WriteHandle< ZDC_SimFiberHit_Collectionm_HitColl
 
std::map< uint32_t, ZDC_SimFiberHit * > m_hitMap
 
float m_readoutPos
 

Detailed Description

Definition at line 24 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 19 of file ZDC_FiberSD.cxx.

20  : G4VSensitiveDetector(name), m_HitColl(hitCollectionName), m_readoutPos(readoutPos)
21 {
22 
23 }

◆ ~ZDC_FiberSD()

ZDC_FiberSD::~ZDC_FiberSD ( )

Definition at line 26 of file ZDC_FiberSD.cxx.

26  {
27 
28 }

Member Function Documentation

◆ EndOfAthenaEvent()

void ZDC_FiberSD::EndOfAthenaEvent ( )

Definition at line 164 of file ZDC_FiberSD.cxx.

165 {
166 
167  //Move the hits from the hit set to the hit container
168  if (!m_HitColl.isValid())
169  m_HitColl = std::make_unique<ZDC_SimFiberHit_Collection>(m_HitColl.name());
170 
171  for(auto hit : m_hitMap){
172  m_HitColl->Emplace(*(hit.second));
173  }
174 
175 
176  if (verboseLevel > 5){
177  G4cout << "ZDC_FiberSD::EndOfAthenaEvent(): Printing Final Energy(eV) deposited in Fibers " << G4endl;
178 
179  int photonCount = 0;
180  float energyTotal = 0;
181  for(auto hit : m_hitMap){
182  photonCount += hit.second->getNPhotons();
183  energyTotal += hit.second->getEdep();
184  }
185 
186  G4cout << "ZDC_FiberSD::EndOfAthenaEvent(): Final Energy(eV) deposited in Fiber "
187  << energyTotal << " ev and Number of Photons deposited = " << photonCount
188  << " across " << m_hitMap.size() << " volumes" << G4endl;
189 
190  }
191  //Reset hit container
192  m_hitMap.clear();
193 
194  return;
195 }

◆ FRIEND_TEST() [1/4]

ZDC_FiberSD::FRIEND_TEST ( ZDC_FiberSDtest  ,
EndOfAthenaEvent   
)
private

◆ FRIEND_TEST() [2/4]

ZDC_FiberSD::FRIEND_TEST ( ZDC_FiberSDtest  ,
Initialize   
)
private

◆ FRIEND_TEST() [3/4]

ZDC_FiberSD::FRIEND_TEST ( ZDC_FiberSDtest  ,
ProcessHits   
)
private

◆ FRIEND_TEST() [4/4]

ZDC_FiberSD::FRIEND_TEST ( ZDC_FiberSDtest  ,
StartOfAthenaEvent   
)
private

◆ Initialize()

void ZDC_FiberSD::Initialize ( G4HCofThisEvent *  )
finaloverride

Definition at line 30 of file ZDC_FiberSD.cxx.

31 {
32 }

◆ ProcessHits()

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

Definition at line 41 of file ZDC_FiberSD.cxx.

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

Member Data Documentation

◆ m_HitColl

SG::WriteHandle<ZDC_SimFiberHit_Collection> ZDC_FiberSD::m_HitColl
private

Definition at line 43 of file ZDC_FiberSD.h.

◆ m_hitMap

std::map< uint32_t, ZDC_SimFiberHit* > ZDC_FiberSD::m_hitMap
private

Definition at line 44 of file ZDC_FiberSD.h.

◆ m_readoutPos

float ZDC_FiberSD::m_readoutPos
private

Definition at line 45 of file ZDC_FiberSD.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
index
Definition: index.py:1
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
skel.it
it
Definition: skel.GENtoEVGEN.py:396
ZDC_FiberSD::m_readoutPos
float m_readoutPos
Definition: ZDC_FiberSD.h:45
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
AtlasHitsVector::Emplace
void Emplace(Args &&... args)
Definition: AtlasHitsVector.h:81
ParticleGun_EoverP_Config.momentum
momentum
Definition: ParticleGun_EoverP_Config.py:63
lumiFormat.i
int i
Definition: lumiFormat.py:85
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
DeMoScan.index
string index
Definition: DeMoScan.py:364
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
ZDC_FiberSD::m_hitMap
std::map< uint32_t, ZDC_SimFiberHit * > m_hitMap
Definition: ZDC_FiberSD.h:44
ZDC_FiberSD::m_HitColl
SG::WriteHandle< ZDC_SimFiberHit_Collection > m_HitColl
Definition: ZDC_FiberSD.h:43
ZDC_SimFiberHit
Definition: ZDC_SimFiberHit.h:11
Identifier
Definition: IdentifierFieldParser.cxx:14