ATLAS Offline Software
Loading...
Searching...
No Matches
VoxelDensityTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Primary include
6#include "VoxelDensityTool.h"
7
8// Geant4 includes
9#include "G4Version.hh"
10#include "G4LogicalVolumeStore.hh"
11
12//=============================================================================
13// Standard constructor, initializes variables
14//=============================================================================
16 const std::string& name,
17 const IInterface* parent)
18 : GeometryConfigurationToolBase(type, name, parent)
19{
20}
21
23{
24 ATH_MSG_DEBUG("VoxelDensityTool::preGeometryConfigure()");
25
26 return StatusCode::SUCCESS;
27}
28
30{
31 ATH_MSG_INFO("VoxelDensityTool::postGeometryConfigure()");
32 // Set VoxelDensity
33 G4LogicalVolumeStore *logicalVolumeStore = G4LogicalVolumeStore::GetInstance();
34 if (logicalVolumeStore->size() == 0) {
35 ATH_MSG_ERROR( "G4 logical volume store is empty." );
36 }
37 const G4String muonSys("Muon::MuonSys");
38 const G4String embSTAC("LArMgr::LAr::EMB::STAC");
39 bool ilvMuonSys = false, ilvEmbSTAC = false;
40 for (auto* ilv : *logicalVolumeStore ) {
41 if ( ilv->GetName() == muonSys ) {
42 ilv->SetSmartless( 0.1 );
43 ATH_MSG_INFO( "Set VoxelDensity for Muon::MuonSys to 0.1" );
44 ilvMuonSys = true;
45 }
46 else if ( ilv->GetName() == embSTAC ) {
47 ilv->SetSmartless( 0.5 );
48 ATH_MSG_INFO( "Set VoxelDensity for LArMgr::LAr::EMB::STAC to 0.5" );
49 ilvEmbSTAC = true;
50 }
51
52 //Now for any volumes set via job property std::pair<volume name, value>...
53 for (auto& volToSet:m_volumeVoxelDensityLevel) {
54#if G4VERSION_NUMBER < 1100
55 if (ilv->GetName().contains(volToSet.first)) {
56#else
57 if (G4StrUtil::contains(ilv->GetName(), std::string_view(volToSet.first))) {
58#endif
59 ilv->SetSmartless(volToSet.second);
60 ATH_MSG_INFO("Set VoxelDensity for "<<ilv->GetName()<<" to "<<volToSet.second);
61 }
62 }
63
64 }
65 if (ilvMuonSys == false) {
66 ATH_MSG_INFO( "Muon::MuonSys not in G4 logical volume store. VoxelDensity not set." );
67 }
68 if (ilvEmbSTAC == false) {
69 ATH_MSG_INFO( "LArMgr::LAr::EMB::STAC not in G4 logical volume store. VoxelDensity not set." );
70 }
71
72 return StatusCode::SUCCESS;
73}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
GeometryConfigurationToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
virtual StatusCode postGeometryConfigure() const override final
Gaudi::Property< std::map< std::string, double > > m_volumeVoxelDensityLevel
VoxelDensityTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
virtual StatusCode preGeometryConfigure() const override final
Configure method.