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)
 
 ~BCMSensorSD ()
 
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, Initialize)
 
 FRIEND_TEST (BCMSensorSDtest, ProcessHits)
 
 FRIEND_TEST (BCMSensorSDtest, AddHit)
 

Private Attributes

SG::WriteHandle< SiHitCollectionm_HitColl
 

Detailed Description

Definition at line 24 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_HitColl( hitCollectionName )
34 {
35 }

◆ ~BCMSensorSD()

BCMSensorSD::~BCMSensorSD ( )
inline

Definition at line 34 of file BCMSensorSD.h.

34 { /* I don't own myHitColl if all has gone well */ }

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 45 of file BCMSensorSD.h.

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

◆ FRIEND_TEST() [1/3]

BCMSensorSD::FRIEND_TEST ( BCMSensorSDtest  ,
AddHit   
)
private

◆ FRIEND_TEST() [2/3]

BCMSensorSD::FRIEND_TEST ( BCMSensorSDtest  ,
Initialize   
)
private

◆ FRIEND_TEST() [3/3]

BCMSensorSD::FRIEND_TEST ( BCMSensorSDtest  ,
ProcessHits   
)
private

◆ Initialize()

void BCMSensorSD::Initialize ( G4HCofThisEvent *  )
finaloverride

Definition at line 39 of file BCMSensorSD.cxx.

40 {
41  if (!m_HitColl.isValid()) m_HitColl = std::make_unique<SiHitCollection>();
42 }

◆ ProcessHits()

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

Definition at line 44 of file BCMSensorSD.cxx.

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

Member Data Documentation

◆ m_HitColl

SG::WriteHandle<SiHitCollection> BCMSensorSD::m_HitColl
private

Definition at line 49 of file BCMSensorSD.h.


The documentation for this class was generated from the following files:
BCMSensorSD::m_HitColl
SG::WriteHandle< SiHitCollection > m_HitColl
Definition: BCMSensorSD.h:49
python.SystemOfUnits.MeV
int MeV
Definition: SystemOfUnits.py:154
TrackHelper
Definition: TrackHelper.h:14
SiHit::xDep
@ xDep
Definition: SiHit.h:162
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SiHit::xEta
@ xEta
Definition: SiHit.h:162
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
SiHit::xPhi
@ xPhi
Definition: SiHit.h:162
python.CaloScaleNoiseConfig.args
args
Definition: CaloScaleNoiseConfig.py:80