19#include "GaudiKernel/ISvcLocator.h"
20#include "GaudiKernel/Bootstrap.h"
22#include "G4EventManager.hh"
23#include "G4HCofThisEvent.hh"
24#include "G4VPhysicalVolume.hh"
26#include "G4VTouchable.hh"
27#include "G4TouchableHistory.hh"
30 : G4VSensitiveDetector(name),
33 verboseLevel = std::max(verboseLevel,
verbose);
35 SmartIF<StoreGateSvc> detStore{Gaudi::svcLocator()->service(
"DetectorStore")};
38 description <<
"Constructor: DetectorStoreSvc not found!";
39 G4Exception(
"MuonWallSD",
"NoDetStore", FatalException,
description);
41 }
else if (verboseLevel >= 5) {
42 G4cout <<
"DetectorStoreSvc initialized" << G4endl;
45 if (detStore->retrieve(
m_tileTBID).isFailure()) {
48 G4Exception(
"MuonWallSD",
"NoTileTBIDHelper", FatalException,
description);
50 }
else if (verboseLevel >= 5) {
51 G4cout <<
"TileTBID helper retrieved" << G4endl;
55 for (
int channel=0; channel<
s_nCellMu; ++channel) {
59 module=TileTBID::CRACK_WALL;
60 for (
int channel=0; channel<
s_nCellS; ++channel) {
67 auto* eventManager = G4EventManager::GetEventManager();
82 if (verboseLevel >= 5) {
83 G4cout <<
"MuonWallSD::Initialize()" << G4endl;
90 if (verboseLevel >= 10) {
91 G4cout <<
"MuonWallSD::ProcessHits" << G4endl;
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();
100 const G4double edep = aStep->GetTotalEnergyDeposit() * aStep->GetTrack()->GetWeight();
103 if (aStep->GetTrack()->GetDefinition()->GetPDGCharge() != 0.){
105 stepl = aStep->GetStepLength();
108 if ((edep == 0.) && (stepl == 0.)) {
115 if(nameLogiVol.find(
"MuScintillatorLayer") !=G4String::npos) {
118 }
else if(nameLogiVol.find(
"S1") !=G4String::npos) {
120 }
else if(nameLogiVol.find(
"S2") !=G4String::npos) {
122 }
else if(nameLogiVol.find(
"S3") !=G4String::npos) {
128 if (verboseLevel >= 10) {
130 G4cout << ((hitCollection && hitCollection->
HasHit(ind))?
"Additional hit in ":
"First hit in ")
131 << ((ind<
s_nCellMu)?
"MuonWall ":
"beam counter S")
133 <<
" time=" << aStep->GetPostStepPoint()->GetGlobalTime()
134 <<
" ene=" << edep << G4endl;
138 if (!hitCollection) {
139 if (verboseLevel >= 5) {
140 G4cout <<
"MuonWallSD::ProcessHits WARNING hit collection is not available" << G4endl;
This class is attached to G4Event objects as UserInformation.
std::shared_ptr< HitCollectionMap > GetHitCollectionMap() const
Get the HitCollectionMap object with shared ownership.
T * Find(std::string const &hitCollectionName)
Get the hit collection for a given SDs.
HitVectorBuilder * GetHitCollection()
static const int s_nCellMu
void Initialize(G4HCofThisEvent *) override final
const TileTBID * m_tileTBID
G4bool ProcessHits(G4Step *, G4TouchableHistory *) override final
HitVectorBuilder * m_hitCollection
const std::string m_hitCollectionName
static const int s_nCellS
TileHitVectorCellBuilder< NCells > HitVectorBuilder
MuonWallSD(const std::string &name, const std::string &hitCollectionName, int verbose)
bool HasHit(std::size_t index) const
void AddHit(std::size_t index, Identifier id, double energy, double time=0.0, double deltaT=0.0)
std::string description
glabal timer - how long have I taken so far?