ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
BCMSensorSD Class Reference

#include <BCMSensorSD.h>

Inheritance diagram for BCMSensorSD:
Collaboration diagram for BCMSensorSD:

Public Member Functions

 BCMSensorSD (const std::string &name, const std::string &hitCollectionName)
 
G4bool ProcessHits (G4Step *, G4TouchableHistory *) override final
 
void Initialize (G4HCofThisEvent *) override final
 
template<class... Args>
void AddHit (Args &&... args)
 Templated method to stuff a single hit into the sensitive detector class. More...
 

Private Member Functions

 FRIEND_TEST (BCMSensorSDtest, ProcessHits)
 
 FRIEND_TEST (BCMSensorSDtest, AddHit)
 

Private Attributes

std::string m_HitCollName
 Name of the hit collection. More...
 
SiHitCollectionm_HitColl {nullptr}
 Pointer to the hit collection. More...
 

Detailed Description

Definition at line 23 of file BCMSensorSD.h.

Constructor & Destructor Documentation

◆ BCMSensorSD()

BCMSensorSD::BCMSensorSD ( const std::string &  name,
const std::string &  hitCollectionName 
)

Definition at line 31 of file BCMSensorSD.cxx.

32  : G4VSensitiveDetector( name )
33  , m_HitCollName( hitCollectionName )
34 {
35 }

Member Function Documentation

◆ AddHit()

template<class... Args>
void BCMSensorSD::AddHit ( Args &&...  args)
inline

Templated method to stuff a single hit into the sensitive detector class.

This could get rather tricky, but the idea is to allow fast simulations to use the very same SD classes as the standard simulation.

Definition at line 40 of file BCMSensorSD.h.

40 { m_HitColl->Emplace( args... ); }

◆ FRIEND_TEST() [1/2]

BCMSensorSD::FRIEND_TEST ( BCMSensorSDtest  ,
AddHit   
)
private

◆ FRIEND_TEST() [2/2]

BCMSensorSD::FRIEND_TEST ( BCMSensorSDtest  ,
ProcessHits   
)
private

◆ Initialize()

void BCMSensorSD::Initialize ( G4HCofThisEvent *  )
finaloverride

Definition at line 39 of file BCMSensorSD.cxx.

40 {
41  // ISF calls G4SDManager::PrepareNewEvent() before the Geant4 event loop starts...
42  if(auto* eventManger = G4EventManager::GetEventManager()){
43  if(auto* eventInfo = static_cast<AtlasG4EventUserInfo*>(eventManger->GetUserInformation())){
44  m_HitColl = eventInfo->GetHitCollectionMap()->Find<SiHitCollection>(m_HitCollName);
45  }
46  }
47 }

◆ ProcessHits()

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

Definition at line 49 of file BCMSensorSD.cxx.

50 {
51  G4double edep = aStep->GetTotalEnergyDeposit();
52  edep *= CLHEP::MeV;
53 
54  //if there is no energy deposition skip everything
55  if(edep==0.)
56  {
57  if(aStep->GetTrack()->GetDefinition()!=G4Geantino::GeantinoDefinition() && aStep->GetTrack()->GetDefinition()!=G4ChargedGeantino::ChargedGeantinoDefinition()) return false;
58  }
59 
60  //Get the Touchable History:
61  const G4TouchableHistory *myTouch = dynamic_cast<const G4TouchableHistory*>(aStep->GetPreStepPoint()->GetTouchable());
62  if (not myTouch) {
63  G4cout << "BCMSensorSD::ProcessHits bad dynamic_cast" << G4endl;
64  return false;
65  }
66 
67  int BEcopyNo = myTouch->GetVolume()->GetCopyNo();
68 
69  // Get the hit coordinates. Start and End Point
70  G4ThreeVector coord1 = aStep->GetPreStepPoint()->GetPosition();
71  G4ThreeVector coord2 = aStep->GetPostStepPoint()->GetPosition();
72 
73  // Calculate the local step begin and end position.
74  // From a G4 FAQ:
75  // http://geant4-hn.slac.stanford.edu:5090/HyperNews/public/get/geometry/17/1.html
76  const G4AffineTransform transformation = myTouch->GetHistory()->GetTopTransform();
77  G4ThreeVector localPosition1 = transformation.TransformPoint(coord1);
78  G4ThreeVector localPosition2 = transformation.TransformPoint(coord2);
79 
80  HepGeom::Point3D<double> lP1,lP2;
81  lP1[SiHit::xEta] = localPosition1[2]*CLHEP::mm;
82  lP1[SiHit::xPhi] = localPosition1[1]*CLHEP::mm;
83  lP1[SiHit::xDep] = localPosition1[0]*CLHEP::mm;
84 
85  lP2[SiHit::xEta] = localPosition2[2]*CLHEP::mm;
86  lP2[SiHit::xPhi] = localPosition2[1]*CLHEP::mm;
87  lP2[SiHit::xDep] = localPosition2[0]*CLHEP::mm;
88 
89  //BCM hit stuff
90  if(BEcopyNo == 11950 || BEcopyNo == 11951)
91  {
92  TrackHelper trHelp(aStep->GetTrack());
93  //primary or not
94  int primaren = 0;
95  if(trHelp.IsPrimary())
96  primaren = 1;
97  else if(trHelp.IsRegeneratedPrimary())
98  primaren = 2;
99  else if(trHelp.IsSecondary())
100  primaren = 3;
101  else if(trHelp.IsRegisteredSecondary())
102  primaren = 4;
103 
104  int produced_in_diamond = 0;
105  if(aStep->GetTrack()->GetLogicalVolumeAtVertex()->GetName() == "Pixel::bcmDiamondLog")
106  produced_in_diamond = 1;
107  else if(aStep->GetTrack()->GetLogicalVolumeAtVertex()->GetName() == "Pixel::bcmModLog")
108  produced_in_diamond = 2;
109  else if(aStep->GetTrack()->GetLogicalVolumeAtVertex()->GetName() == "Pixel::bcmWallLog")
110  produced_in_diamond = 3;
111 
112  m_HitColl->Emplace(lP1, lP2, edep, aStep->GetPreStepPoint()->GetGlobalTime(), trHelp.GenerateParticleLink(),
113  0, 0, myTouch->GetVolume(1)->GetCopyNo()-951, BEcopyNo - 11950, primaren, produced_in_diamond);
114  }
115  return true;
116 }

Member Data Documentation

◆ m_HitColl

SiHitCollection* BCMSensorSD::m_HitColl {nullptr}
private

Pointer to the hit collection.

Definition at line 43 of file BCMSensorSD.h.

◆ m_HitCollName

std::string BCMSensorSD::m_HitCollName
private

Name of the hit collection.

Definition at line 42 of file BCMSensorSD.h.


The documentation for this class was generated from the following files:
AtlasG4EventUserInfo
This class is attached to G4Event objects as UserInformation. It holds a pointer to the HepMC::GenEve...
Definition: AtlasG4EventUserInfo.h:23
SiHit::xDep
@ xDep
Definition: SiHit.h:162
python.SystemOfUnits.mm
float mm
Definition: SystemOfUnits.py:98
python.CaloAddPedShiftConfig.args
args
Definition: CaloAddPedShiftConfig.py:47
SiHit::xPhi
@ xPhi
Definition: SiHit.h:162
AtlasHitsVector< SiHit >
BCMSensorSD::m_HitColl
SiHitCollection * m_HitColl
Pointer to the hit collection.
Definition: BCMSensorSD.h:43
python.SystemOfUnits.MeV
float MeV
Definition: SystemOfUnits.py:172
AtlasHitsVector::Emplace
void Emplace(Args &&... args)
Definition: AtlasHitsVector.h:80
TrackHelper
Definition: TrackHelper.h:14
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
SiHit::xEta
@ xEta
Definition: SiHit.h:162
BCMSensorSD::m_HitCollName
std::string m_HitCollName
Name of the hit collection.
Definition: BCMSensorSD.h:42