ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileG4
TileAncillary
MuonWall
src
MuonWallSD.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
//************************************************************
6
//
7
// Class MuonWallSD.
8
// Sensitive detector for the muon wall
9
//
10
//************************************************************
11
12
#include "
MuonWallSD.h
"
13
14
#include "
CaloIdentifier/TileTBID.h
"
15
#include "
HitManagement/HitCollectionMap.h
"
16
#include "
MCTruth/AtlasG4EventUserInfo.h
"
17
#include "
StoreGate/StoreGateSvc.h
"
18
19
#include "GaudiKernel/ISvcLocator.h"
20
#include "GaudiKernel/Bootstrap.h"
21
22
#include "G4EventManager.hh"
23
#include "G4HCofThisEvent.hh"
24
#include "G4VPhysicalVolume.hh"
25
#include "G4Step.hh"
26
#include "G4VTouchable.hh"
27
#include "G4TouchableHistory.hh"
28
29
MuonWallSD::MuonWallSD
(
const
std::string& name,
const
std::string& hitCollectionName,
int
verbose
)
30
: G4VSensitiveDetector(name),
31
m_hitCollectionName
(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
54
int
type
=
TileTBID::ADC_TYPE
, module=
TileTBID::BACK_WALL
;
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
}
64
65
MuonWallSD::HitVectorBuilder
*
MuonWallSD::GetHitCollection
()
66
{
67
auto
* eventManager = G4EventManager::GetEventManager();
68
if
(!eventManager) {
69
return
nullptr
;
70
}
71
72
auto
* eventInfo =
dynamic_cast<
AtlasG4EventUserInfo
*
>
(eventManager->GetUserInformation());
73
if
(!eventInfo) {
74
return
nullptr
;
75
}
76
77
auto
hitCollections = eventInfo->
GetHitCollectionMap
();
78
return
hitCollections ? hitCollections->
Find
<
HitVectorBuilder
>(
m_hitCollectionName
) :
nullptr
;
79
}
80
81
void
MuonWallSD::Initialize
(G4HCofThisEvent*
/* HCE */
) {
82
if
(verboseLevel >= 5) {
83
G4cout <<
"MuonWallSD::Initialize()"
<< G4endl;
84
}
85
86
m_hitCollection
=
GetHitCollection
();
87
}
88
89
G4bool
MuonWallSD::ProcessHits
(G4Step* aStep, G4TouchableHistory*
/* ROhist */
) {
90
if
(verboseLevel >= 10) {
91
G4cout <<
"MuonWallSD::ProcessHits"
<< G4endl;
92
}
93
94
const
G4TouchableHistory* theTouchable =
static_cast<
const
G4TouchableHistory*
>
(aStep->GetPreStepPoint()->GetTouchable());
95
const
G4VPhysicalVolume* physVol = theTouchable->GetVolume();
96
const
G4LogicalVolume* logiVol = physVol->GetLogicalVolume();
97
const
G4String nameLogiVol = logiVol->GetName();
98
const
G4int nScinti = physVol->GetCopyNo();
99
100
const
G4double edep = aStep->GetTotalEnergyDeposit() * aStep->GetTrack()->GetWeight();
101
G4double stepl = 0.;
102
103
if
(aStep->GetTrack()->GetDefinition()->GetPDGCharge() != 0.){
// FIXME not-equal check on double
104
105
stepl = aStep->GetStepLength();
106
}
107
108
if
((edep == 0.) && (stepl == 0.)) {
//FIXME equality check on double
109
110
return
false
;
111
}
112
113
int
ind;
114
115
if
(nameLogiVol.find(
"MuScintillatorLayer"
) !=G4String::npos) {
116
// for muon wall, nScinti-1 is the correct indice.
117
ind = nScinti-1;
118
}
else
if
(nameLogiVol.find(
"S1"
) !=G4String::npos) {
119
ind =
s_nCellMu
+ 0;
120
}
else
if
(nameLogiVol.find(
"S2"
) !=G4String::npos) {
121
ind =
s_nCellMu
+ 1;
122
}
else
if
(nameLogiVol.find(
"S3"
) !=G4String::npos) {
123
ind =
s_nCellMu
+ 2;
124
}
else
{
125
ind =
s_nCellMu
+ 3;
126
}
127
128
if
(verboseLevel >= 10) {
129
HitVectorBuilder
* hitCollection =
m_hitCollection
?
m_hitCollection
:
GetHitCollection
();
130
G4cout << ((hitCollection && hitCollection->
HasHit
(ind))?
"Additional hit in "
:
"First hit in "
)
131
<< ((ind<
s_nCellMu
)?
"MuonWall "
:
"beam counter S"
)
132
<< ((ind<
s_nCellMu
)?nScinti:(ind-
s_nCellMu
+1))
133
<<
" time="
<< aStep->GetPostStepPoint()->GetGlobalTime()
134
<<
" ene="
<< edep << G4endl;
135
}
136
137
HitVectorBuilder
* hitCollection =
m_hitCollection
?
m_hitCollection
:
GetHitCollection
();
138
if
(!hitCollection) {
139
if
(verboseLevel >= 5) {
140
G4cout <<
"MuonWallSD::ProcessHits WARNING hit collection is not available"
<< G4endl;
141
}
142
return
false
;
143
}
144
m_hitCollection
= hitCollection;
145
hitCollection->
AddHit
(ind,
m_id
[ind], edep);
146
147
return
true
;
148
}
AtlasG4EventUserInfo.h
TileTBID.h
HitCollectionMap.h
MuonWallSD.h
StoreGateSvc.h
AtlasG4EventUserInfo
This class is attached to G4Event objects as UserInformation.
Definition
AtlasG4EventUserInfo.h:26
AtlasG4EventUserInfo::GetHitCollectionMap
std::shared_ptr< HitCollectionMap > GetHitCollectionMap() const
Get the HitCollectionMap object with shared ownership.
Definition
AtlasG4EventUserInfo.h:82
HitCollectionMap::Find
T * Find(std::string const &hitCollectionName)
Get the hit collection for a given SDs.
Definition
HitCollectionMap.h:49
MuonWallSD::GetHitCollection
HitVectorBuilder * GetHitCollection()
Definition
MuonWallSD.cxx:65
MuonWallSD::s_nCellMu
static const int s_nCellMu
Definition
MuonWallSD.h:46
MuonWallSD::Initialize
void Initialize(G4HCofThisEvent *) override final
Definition
MuonWallSD.cxx:81
MuonWallSD::m_id
Identifier m_id[NCells]
Definition
MuonWallSD.h:51
MuonWallSD::m_tileTBID
const TileTBID * m_tileTBID
Definition
MuonWallSD.h:44
MuonWallSD::ProcessHits
G4bool ProcessHits(G4Step *, G4TouchableHistory *) override final
Definition
MuonWallSD.cxx:89
MuonWallSD::m_hitCollection
HitVectorBuilder * m_hitCollection
Definition
MuonWallSD.h:53
MuonWallSD::m_hitCollectionName
const std::string m_hitCollectionName
Definition
MuonWallSD.h:52
MuonWallSD::s_nCellS
static const int s_nCellS
Definition
MuonWallSD.h:47
MuonWallSD::HitVectorBuilder
TileHitVectorCellBuilder< NCells > HitVectorBuilder
Definition
MuonWallSD.h:38
MuonWallSD::MuonWallSD
MuonWallSD(const std::string &name, const std::string &hitCollectionName, int verbose)
Definition
MuonWallSD.cxx:29
TileHitVectorCellBuilder::HasHit
bool HasHit(std::size_t index) const
Definition
TileHitVectorCellBuilder.h:32
TileHitVectorCellBuilder::AddHit
void AddHit(std::size_t index, Identifier id, double energy, double time=0.0, double deltaT=0.0)
Definition
TileHitVectorCellBuilder.h:34
TileTBID::BACK_WALL
@ BACK_WALL
Definition
Calorimeter/CaloIdentifier/CaloIdentifier/TileTBID.h:91
TileTBID::ADC_TYPE
@ ADC_TYPE
Definition
Calorimeter/CaloIdentifier/CaloIdentifier/TileTBID.h:84
description
std::string description
glabal timer - how long have I taken so far?
Definition
hcg.cxx:93
verbose
bool verbose
Definition
hcg.cxx:75
type
Generated on
for ATLAS Offline Software by
1.17.0