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

#include <HGTDSensorGmxSD.h>

Inheritance diagram for HGTDSensorGmxSD:
Collaboration diagram for HGTDSensorGmxSD:

Public Member Functions

 HGTDSensorGmxSD (const std::string &name, const std::string &hitCollectionName, GeoModelIO::ReadGeoModel *sqlreader=nullptr)
virtual ~HGTDSensorGmxSD ()
G4bool ProcessHits (G4Step *, G4TouchableHistory *) override final
void Initialize (G4HCofThisEvent *) override final

Private Attributes

SG::WriteHandle< SiHitCollectionm_HitColl
GeoModelIO::ReadGeoModel * m_sqlreader

Detailed Description

Definition at line 33 of file HGTDSensorGmxSD.h.

Constructor & Destructor Documentation

◆ HGTDSensorGmxSD()

HGTDSensorGmxSD::HGTDSensorGmxSD ( const std::string & name,
const std::string & hitCollectionName,
GeoModelIO::ReadGeoModel * sqlreader = nullptr )

Definition at line 35 of file HGTDSensorGmxSD.cxx.

36 : G4VSensitiveDetector( name ),
37 m_HitColl( hitCollectionName ),
38 m_sqlreader( sqlreader )
39{
40
41}
GeoModelIO::ReadGeoModel * m_sqlreader
SG::WriteHandle< SiHitCollection > m_HitColl

◆ ~HGTDSensorGmxSD()

virtual HGTDSensorGmxSD::~HGTDSensorGmxSD ( )
inlinevirtual

Definition at line 42 of file HGTDSensorGmxSD.h.

42{}

Member Function Documentation

◆ Initialize()

void HGTDSensorGmxSD::Initialize ( G4HCofThisEvent * )
finaloverride

Definition at line 44 of file HGTDSensorGmxSD.cxx.

45{
46 if (!m_HitColl.isValid()) m_HitColl = std::make_unique<SiHitCollection>();
47}

◆ ProcessHits()

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

Definition at line 49 of file HGTDSensorGmxSD.cxx.

50{
51 if (verboseLevel>5) G4cout << "Process Hit" << G4endl;
52
53 G4double edep = aStep->GetTotalEnergyDeposit();
54 edep *= CLHEP::MeV;
55
56 if (edep==0.) {
57 if (aStep->GetTrack()->GetDefinition() != G4Geantino::GeantinoDefinition() &&
58 aStep->GetTrack()->GetDefinition() != G4ChargedGeantino::ChargedGeantinoDefinition())
59 return false;
60 }
61
62 //
63 // Get the Touchable History:
64 //
65 const G4TouchableHistory* myTouch = dynamic_cast<const G4TouchableHistory*>(aStep->GetPreStepPoint()->GetTouchable());
66 if (not myTouch){
67 G4cout<<"HGTDSensorGmxSD::ProcessHits: dynamic cast failed"<<G4endl;
68 return false;
69 }
70 if(verboseLevel>5){
71 for (int i=0;i<myTouch->GetHistoryDepth();i++){
72 std::string detname = myTouch->GetVolume(i)->GetLogicalVolume()->GetName();
73 int copyno = myTouch->GetVolume(i)->GetCopyNo();
74 G4cout << "Volume " << detname << " Copy Nr. " << copyno << G4endl;
75 }
76 }
77
78 //
79 // Get the hit coordinates. Start and End Point
80 //
81 G4ThreeVector startCoord = aStep->GetPreStepPoint()->GetPosition();
82 G4ThreeVector endCoord = aStep->GetPostStepPoint()->GetPosition();
83
84 // Create the SiHits
85
86 const G4AffineTransform transformation = myTouch->GetHistory()->GetTopTransform();
87
88 G4ThreeVector localPosition1 = transformation.TransformPoint(startCoord);
89 G4ThreeVector localPosition2 = transformation.TransformPoint(endCoord);
90
91 HepGeom::Point3D<double> lP1,lP2;
92 //TODO need to check
93 lP1[SiHit::xEta] = localPosition1[1]*CLHEP::mm; //long edge of the module
94 lP1[SiHit::xPhi] = localPosition1[0]*CLHEP::mm; //short edge of the module
95 lP1[SiHit::xDep] = localPosition1[2]*CLHEP::mm; //depth (z)
96
97 lP2[SiHit::xEta] = localPosition2[1]*CLHEP::mm;
98 lP2[SiHit::xPhi] = localPosition2[0]*CLHEP::mm;
99 lP2[SiHit::xDep] = localPosition2[2]*CLHEP::mm;
100
101 // get the HepMcParticleLink from the TrackHelper
102 TrackHelper trHelp(aStep->GetTrack());
103
104 if(m_sqlreader){
105 // if sqlite inputs, Identifier indices come from PhysVol Name
106 std::string physVolName = myTouch->GetVolume()->GetName();
107
108 int hitIdOfWafer = SiHitIdHelper::GetHelper()->buildHitIdFromStringHGTD(2,physVolName);
109
110 m_HitColl->Emplace(lP1,
111 lP2,
112 edep,
113 aStep->GetPreStepPoint()->GetGlobalTime(),
114 trHelp.GenerateParticleLink(),
115 hitIdOfWafer);
116
117 return true;
118 }
119
120 // if not from SQLite, we assume that the Identifier has already been written in as the copy number
121 // (it should hsave done if GeoModel building ran within Athena)
122 //
123 // Get the indexes of which detector the hit is in
124 //
125 const int id = myTouch->GetVolume()->GetCopyNo();
126
127 m_HitColl->Emplace(lP1,
128 lP2,
129 edep,
130 aStep->GetPreStepPoint()->GetGlobalTime(),
131 trHelp.GenerateParticleLink(),
132 id);
133
134 return true;
135}
int buildHitIdFromStringHGTD(int part, const std::string &) const
static const SiHitIdHelper * GetHelper()
@ xPhi
Definition SiHit.h:162
@ xEta
Definition SiHit.h:162
@ xDep
Definition SiHit.h:162

Member Data Documentation

◆ m_HitColl

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

Definition at line 52 of file HGTDSensorGmxSD.h.

◆ m_sqlreader

GeoModelIO::ReadGeoModel* HGTDSensorGmxSD::m_sqlreader
private

Definition at line 53 of file HGTDSensorGmxSD.h.


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