ATLAS Offline Software
RegionCreator.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Base class
7 
8 // Geant4 includes used in functions
9 
10 #include "G4LogicalVolume.hh"
11 #include "G4LogicalVolumeStore.hh"
12 #include "G4Region.hh"
13 #include "G4ProductionCuts.hh"
14 
15 RegionCreator::RegionCreator(const std::string& type, const std::string& name, const IInterface* parent)
16  : base_class(type,name,parent)
17 {
18 }
19 
20 // Athena method, called at initialization time
22 {
23  ATH_MSG_INFO(" initializing RegionCreator "<<name() );
24  if (m_regionName.empty()) {
25  m_regionName = this->name();
26  // re-initialize m_regionName in order to take the real tool name rather than the path to it
27  size_t ipos=m_regionName.value().find_last_of('.');
28  size_t length=m_regionName.value().size();
29  if (ipos<length) {
30  ATH_MSG_VERBOSE( "m_regionName: " << m_regionName.value() << " needs to be reset.");
31  m_regionName=m_regionName.value().substr(ipos+1,length-ipos-1);
32  }
33  ATH_MSG_INFO( "m_regionName default value reset to "<<m_regionName.value());
34  }
35  return StatusCode::SUCCESS;
36 }
37 
39 {
40  //create a new G4Region
41  G4Region* theRegion=new G4Region(m_regionName.value());
42 
43  // loop over volumes and fish for those in the list
44  size_t nVolumes{0};
45  G4LogicalVolumeStore* logStore=G4LogicalVolumeStore::GetInstance();
46  for (const auto& vol: m_logicalVolumes) {
47  size_t nVolumesCurrent{0};
48  for (auto* it: *logStore)
49  {
50 
51  if (vol == static_cast<const std::string&>(it->GetName()))
52  {
53  nVolumesCurrent++;
54  it->SetRegion(theRegion);
55  theRegion->AddRootLogicalVolume(it);
56  }
57  }
58  if (nVolumesCurrent==0) {
59  ATH_MSG_WARNING("No volumes matching \"" << vol << "\" found in G4 LogicalVolumeStore. " << m_regionName.value() << " G4PhysicsRegion may not behave as intended.");
60  }
61  nVolumes += nVolumesCurrent;
62  }
63 
64  ATH_MSG_INFO("A total of "<<nVolumes<<" volumes was assigned to region "<<m_regionName.value() );
65 
66  // create a G4ProductionCuts object and set appropriate values
67  G4ProductionCuts* cuts=new G4ProductionCuts();
68  cuts->SetProductionCut(m_gammaCut,"gamma");
69  cuts->SetProductionCut(m_electronCut,"e-");
70  cuts->SetProductionCut(m_positronCut,"e+");
71  cuts->SetProductionCut(m_protonCut,"proton");
72 
73  // assign cuts to the region and return succesfully
74  theRegion->SetProductionCuts(cuts);
75 
76  Dump();
77 }
78 
80 {
81  ATH_MSG_INFO("+----------------------------------------------------+");
82  ATH_MSG_INFO(" ");
83  ATH_MSG_INFO(" Dump of region "<<m_regionName.value());
84  ATH_MSG_INFO(" Volumes being assigned to this region:");
85  for (const auto& vol: m_logicalVolumes)
86  {
87  ATH_MSG_INFO(" "<<vol);
88  }
89  ATH_MSG_INFO(" ");
90  ATH_MSG_INFO(" Cuts selected for this region:");
91  ATH_MSG_INFO(" Gamma ="<<m_gammaCut);
92  ATH_MSG_INFO(" Electron ="<<m_electronCut);
93  ATH_MSG_INFO(" Positron ="<<m_positronCut);
94  ATH_MSG_INFO(" Proton ="<<m_protonCut);
95  ATH_MSG_INFO(" ");
96  ATH_MSG_INFO("+----------------------------------------------------+");
97 }
RegionCreator::initialize
virtual StatusCode initialize() override
Definition: RegionCreator.cxx:21
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
skel.it
it
Definition: skel.GENtoEVGEN.py:423
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
RegionCreator::m_positronCut
Gaudi::Property< double > m_positronCut
Definition: RegionCreator.h:41
RegionCreator::m_electronCut
Gaudi::Property< double > m_electronCut
Definition: RegionCreator.h:40
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
RegionCreator::Construct
void Construct() override
Definition: RegionCreator.cxx:38
plotBeamSpotVert.cuts
string cuts
Definition: plotBeamSpotVert.py:93
test_pyathena.parent
parent
Definition: test_pyathena.py:15
RegionCreator::m_gammaCut
Gaudi::Property< double > m_gammaCut
Definition: RegionCreator.h:39
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
RegionCreator::m_logicalVolumes
Gaudi::Property< std::vector< std::string > > m_logicalVolumes
Definition: RegionCreator.h:43
RegionCreator::m_regionName
Gaudi::Property< std::string > m_regionName
Definition: RegionCreator.h:38
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
RegionCreator::m_protonCut
Gaudi::Property< double > m_protonCut
Definition: RegionCreator.h:42
RegionCreator::RegionCreator
RegionCreator(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RegionCreator.cxx:15
RegionCreator::Dump
void Dump() override
Definition: RegionCreator.cxx:79
RegionCreator.h
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26