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

#include <BLMSensorSD.h>

Inheritance diagram for BLMSensorSD:
Collaboration diagram for BLMSensorSD:

Public Member Functions

 BLMSensorSD (const std::string &name, const std::string &hitCollectionName)
 
 ~BLMSensorSD ()
 
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 (BLMSensorSDtest, Initialize)
 
 FRIEND_TEST (BLMSensorSDtest, ProcessHits)
 
 FRIEND_TEST (BLMSensorSDtest, AddHit)
 

Private Attributes

SG::WriteHandle< SiHitCollectionm_HitColl
 

Detailed Description

Definition at line 24 of file BLMSensorSD.h.

Constructor & Destructor Documentation

◆ BLMSensorSD()

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

Definition at line 28 of file BLMSensorSD.cxx.

29  : G4VSensitiveDetector( name )
30  , m_HitColl( hitCollectionName )
31 {
32 }

◆ ~BLMSensorSD()

BLMSensorSD::~BLMSensorSD ( )
inline

Definition at line 34 of file BLMSensorSD.h.

34 {}

Member Function Documentation

◆ AddHit()

template<class... Args>
void BLMSensorSD::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 BLMSensorSD.h.

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

◆ FRIEND_TEST() [1/3]

BLMSensorSD::FRIEND_TEST ( BLMSensorSDtest  ,
AddHit   
)
private

◆ FRIEND_TEST() [2/3]

BLMSensorSD::FRIEND_TEST ( BLMSensorSDtest  ,
Initialize   
)
private

◆ FRIEND_TEST() [3/3]

BLMSensorSD::FRIEND_TEST ( BLMSensorSDtest  ,
ProcessHits   
)
private

◆ Initialize()

void BLMSensorSD::Initialize ( G4HCofThisEvent *  )
finaloverride

Definition at line 36 of file BLMSensorSD.cxx.

37 {
38  if (!m_HitColl.isValid()) m_HitColl = std::make_unique<SiHitCollection>();
39 }

◆ ProcessHits()

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

Definition at line 41 of file BLMSensorSD.cxx.

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

Member Data Documentation

◆ m_HitColl

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

Definition at line 49 of file BLMSensorSD.h.


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