ATLAS Offline Software
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)
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 }
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
VoxelDensityTool::VoxelDensityTool
VoxelDensityTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition: VoxelDensityTool.cxx:15
VoxelDensityTool::preGeometryConfigure
virtual StatusCode preGeometryConfigure() const override final
Configure method.
Definition: VoxelDensityTool.cxx:22
VoxelDensityTool.h
VoxelDensityTool::postGeometryConfigure
virtual StatusCode postGeometryConfigure() const override final
Definition: VoxelDensityTool.cxx:29
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
contains
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition: hcg.cxx:111
test_pyathena.parent
parent
Definition: test_pyathena.py:15
VoxelDensityTool::m_volumeVoxelDensityLevel
Gaudi::Property< std::map< std::string, double > > m_volumeVoxelDensityLevel
Definition: VoxelDensityTool.h:36
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
GeometryConfigurationToolBase
Definition: GeometryConfigurationToolBase.h:26