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

#include <MuonWallSD.h>

Inheritance diagram for MuonWallSD:
Collaboration diagram for MuonWallSD:

Public Member Functions

 MuonWallSD (const std::string &name, const std::string &hitCollectionName, int verbose)
 ~MuonWallSD ()=default
void StartOfAthenaEvent ()
void Initialize (G4HCofThisEvent *) override final
G4bool ProcessHits (G4Step *, G4TouchableHistory *) override final
void EndOfAthenaEvent ()

Private Attributes

const TileTBIDm_tileTBID {}
int m_nhits [s_nCell]
TileSimHitm_hit [s_nCell]
Identifier m_id [s_nCell]
SG::WriteHandle< TileHitVectorm_HitColl

Static Private Attributes

static const int s_nCellMu = 14
static const int s_nCellS = 4
static const int s_nCell = s_nCellMu+s_nCellS

Detailed Description

Definition at line 32 of file MuonWallSD.h.

Constructor & Destructor Documentation

◆ MuonWallSD()

MuonWallSD::MuonWallSD ( const std::string & name,
const std::string & hitCollectionName,
int verbose )

Definition at line 27 of file MuonWallSD.cxx.

28 : G4VSensitiveDetector(name),
29 m_nhits(),
30 m_hit(),
31 m_HitColl(hitCollectionName)
32{
33 verboseLevel = std::max(verboseLevel, verbose);
34
35 SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service("DetectorStore")};
36 if ( !detStore ) {
37 G4ExceptionDescription description;
38 description << "Constructor: DetectorStoreSvc not found!";
39 G4Exception("MuonWallSD", "NoDetStore", FatalException, description);
40 abort();
41 } else if (verboseLevel >= 5) {
42 G4cout << "DetectorStoreSvc initialized" << G4endl;
43 }
44
45 if (detStore->retrieve(m_tileTBID).isFailure()) {
46 G4ExceptionDescription description;
47 description << "Constructor: No TileTBID helper!";
48 G4Exception("MuonWallSD", "NoTileTBIDHelper", FatalException, description);
49 abort();
50 } else if (verboseLevel >= 5) {
51 G4cout << "TileTBID helper retrieved" << G4endl;
52 }
53
55 for (int channel=0; channel<s_nCellMu; ++channel) {
56 m_id[channel] = m_tileTBID->channel_id(type,module,channel);
57 }
58
59 module=TileTBID::CRACK_WALL;
60 for (int channel=0; channel<s_nCellS; ++channel) {
61 m_id[channel+s_nCellMu] = m_tileTBID->channel_id(type,module,channel);
62 }
63}
static const int s_nCellMu
Definition MuonWallSD.h:47
const TileTBID * m_tileTBID
Definition MuonWallSD.h:45
TileSimHit * m_hit[s_nCell]
Definition MuonWallSD.h:52
Identifier m_id[s_nCell]
Definition MuonWallSD.h:53
int m_nhits[s_nCell]
Definition MuonWallSD.h:51
SG::WriteHandle< TileHitVector > m_HitColl
Definition MuonWallSD.h:55
static const int s_nCellS
Definition MuonWallSD.h:48
std::string description
glabal timer - how long have I taken so far?
Definition hcg.cxx:91
bool verbose
Definition hcg.cxx:73

◆ ~MuonWallSD()

MuonWallSD::~MuonWallSD ( )
default

Member Function Documentation

◆ EndOfAthenaEvent()

void MuonWallSD::EndOfAthenaEvent ( )

Definition at line 142 of file MuonWallSD.cxx.

142 {
143 for (int ind = 0; ind < s_nCell; ++ind) {
144 int nhit = m_nhits[ind];
145 if (nhit > 0) {
146 if (verboseLevel >= 5) {
147 G4cout << "Cell id=" << m_tileTBID->to_string(m_id[ind])
148 << " nhit=" << nhit
149 << " ene=" << m_hit[ind]->energy() << G4endl;
150 }
151 m_HitColl->Insert(TileHit(m_hit[ind]));
152 delete m_hit[ind];
153 } else if (verboseLevel >= 10) {
154 G4cout << "Cell id=" << m_tileTBID->to_string(m_id[ind])
155 << " nhit=0" << G4endl;
156 }
157 }
158
159 if (verboseLevel >= 5) {
160 G4cout << "Total number of hits is " << m_HitColl->size() << G4endl;
161 }
162 return ;
163}
static const int s_nCell
Definition MuonWallSD.h:49

◆ Initialize()

void MuonWallSD::Initialize ( G4HCofThisEvent * )
finaloverride

Definition at line 73 of file MuonWallSD.cxx.

73 {
74 if (verboseLevel >= 5) {
75 G4cout << "MuonWallSD::Initialize()" << G4endl;
76 }
77
78 if (!m_HitColl.isValid()) {
79 m_HitColl = std::make_unique<TileHitVector>(m_HitColl.name());
80 }
81}

◆ ProcessHits()

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

Definition at line 83 of file MuonWallSD.cxx.

83 {
84 if (verboseLevel >= 10) {
85 G4cout << "MuonWallSD::ProcessHits" << G4endl;
86 }
87
88 const G4TouchableHistory* theTouchable = static_cast<const G4TouchableHistory*>(aStep->GetPreStepPoint()->GetTouchable());
89 const G4VPhysicalVolume* physVol = theTouchable->GetVolume();
90 const G4LogicalVolume* logiVol = physVol->GetLogicalVolume();
91 const G4String nameLogiVol = logiVol->GetName();
92 const G4int nScinti = physVol->GetCopyNo();
93
94 const G4double edep = aStep->GetTotalEnergyDeposit() * aStep->GetTrack()->GetWeight();
95 G4double stepl = 0.;
96
97 if (aStep->GetTrack()->GetDefinition()->GetPDGCharge() != 0.){ // FIXME not-equal check on double
98
99 stepl = aStep->GetStepLength();
100 }
101
102 if ((edep == 0.) && (stepl == 0.)) { //FIXME equality check on double
103
104 return false;
105 }
106
107 int ind;
108
109 if(nameLogiVol.find("MuScintillatorLayer") !=G4String::npos) {
110 // for muon wall, nScinti-1 is the correct indice.
111 ind = nScinti-1;
112 } else if(nameLogiVol.find("S1") !=G4String::npos) {
113 ind = s_nCellMu + 0;
114 } else if(nameLogiVol.find("S2") !=G4String::npos) {
115 ind = s_nCellMu + 1;
116 } else if(nameLogiVol.find("S3") !=G4String::npos) {
117 ind = s_nCellMu + 2;
118 } else {
119 ind = s_nCellMu + 3;
120 }
121
122 if (verboseLevel >= 10) {
123 G4cout << ((m_nhits[ind] > 0)?"Additional hit in ":"First hit in ")
124 << ((ind<s_nCellMu)?"MuonWall ":"beam counter S")
125 << ((ind<s_nCellMu)?nScinti:(ind-s_nCellMu+1))
126 << " time=" << aStep->GetPostStepPoint()->GetGlobalTime()
127 << " ene=" << edep << G4endl;
128 }
129
130 if ( m_nhits[ind] > 0 ) {
131 m_hit[ind]->add(edep,0.0,0.0);
132 } else {
133 // First hit in a cell
134 m_hit[ind] = new TileSimHit(m_id[ind],edep,0.0,0.0);
135 }
136
137 ++m_nhits[ind];
138
139 return true;
140}

◆ StartOfAthenaEvent()

void MuonWallSD::StartOfAthenaEvent ( )

Definition at line 65 of file MuonWallSD.cxx.

65 {
66 if (verboseLevel >= 5) {
67 G4cout << "Initializing SD" << G4endl;
68 }
69
70 memset(m_nhits, 0, sizeof(m_nhits));
71}

Member Data Documentation

◆ m_hit

TileSimHit* MuonWallSD::m_hit[s_nCell]
private

Definition at line 52 of file MuonWallSD.h.

◆ m_HitColl

SG::WriteHandle<TileHitVector> MuonWallSD::m_HitColl
private

Definition at line 55 of file MuonWallSD.h.

◆ m_id

Identifier MuonWallSD::m_id[s_nCell]
private

Definition at line 53 of file MuonWallSD.h.

◆ m_nhits

int MuonWallSD::m_nhits[s_nCell]
private

Definition at line 51 of file MuonWallSD.h.

◆ m_tileTBID

const TileTBID* MuonWallSD::m_tileTBID {}
private

Definition at line 45 of file MuonWallSD.h.

45{};

◆ s_nCell

const int MuonWallSD::s_nCell = s_nCellMu+s_nCellS
staticprivate

Definition at line 49 of file MuonWallSD.h.

◆ s_nCellMu

const int MuonWallSD::s_nCellMu = 14
staticprivate

Definition at line 47 of file MuonWallSD.h.

◆ s_nCellS

const int MuonWallSD::s_nCellS = 4
staticprivate

Definition at line 48 of file MuonWallSD.h.


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