ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ISF::G4PolyconeGeoIDSvc Class Reference

#include <G4PolyconeGeoIDSvc.h>

Inheritance diagram for ISF::G4PolyconeGeoIDSvc:
Collaboration diagram for ISF::G4PolyconeGeoIDSvc:

Public Member Functions

 G4PolyconeGeoIDSvc (const std::string &name, ISvcLocator *svc)
 Constructor with parameters. More...
 
 ~G4PolyconeGeoIDSvc ()
 Destructor. More...
 
StatusCode initialize ()
 
AtlasDetDescr::AtlasRegion identifyGeoID (const Amg::Vector3D &pos) const
 A static filter that returns the AtlasRegion of the given position. More...
 
ISF::InsideType inside (const Amg::Vector3D &pos, AtlasDetDescr::AtlasRegion geoID) const
 Checks if the given position (ISFParticle) is inside a given AtlasRegion. More...
 
AtlasDetDescr::AtlasRegion identifyNextGeoID (const Amg::Vector3D &pos, const Amg::Vector3D &dir) const
 Find the AtlasRegion that the particle will enter with its next infinitesimal step along the given direction. More...
 

Private Member Functions

StatusCode fillDimensions ()
 Retrieve and fill in the dimensions for the different AtlasRegion. More...
 
void pushDimension (AtlasDetDescr::AtlasRegion geoID, double rin, double rou, double z)
 
void pushDimension (AtlasDetDescr::AtlasRegion geoID, double r, double z)
 
StatusCode createVolume (AtlasDetDescr::AtlasRegion geoID)
 Retrieve and fill in the dimensions for the different AtlasRegion. More...
 

Private Attributes

ServiceHandle< IEnvelopeDefSvcm_envDefSvc {this, "EnvelopeDefSvc", "AtlasGeometry_EnvelopeDefSvc"}
 service providing the envelope dimensions for the different sub-detectors More...
 
G4VSolid * m_volume [AtlasDetDescr::fNumAtlasRegions]
 
ISF::InsideType m_typeConverter [ISF::fNumInsideTypes]
 a quick way to convert G4 enum EInside to ISF::InsideType More...
 

Detailed Description

Todo:
Author
Elmar.Ritsch -at- cern.ch

Definition at line 39 of file G4PolyconeGeoIDSvc.h.

Constructor & Destructor Documentation

◆ G4PolyconeGeoIDSvc()

ISF::G4PolyconeGeoIDSvc::G4PolyconeGeoIDSvc ( const std::string &  name,
ISvcLocator *  svc 
)

Constructor with parameters.

Constructor.

Definition at line 33 of file G4PolyconeGeoIDSvc.cxx.

33  :
34  base_class(name,svc),
35  m_volume(),
37 {
38 }

◆ ~G4PolyconeGeoIDSvc()

ISF::G4PolyconeGeoIDSvc::~G4PolyconeGeoIDSvc ( )

Destructor.

Definition at line 42 of file G4PolyconeGeoIDSvc.cxx.

43 {
44 }

Member Function Documentation

◆ createVolume()

StatusCode ISF::G4PolyconeGeoIDSvc::createVolume ( AtlasDetDescr::AtlasRegion  geoID)
private

Retrieve and fill in the dimensions for the different AtlasRegion.

Definition at line 132 of file G4PolyconeGeoIDSvc.cxx.

133 {
134 
135  // ensure a proper numeric value for geoID
136  assertAtlasRegion( geoID);
137 
138  ATH_MSG_INFO( "Building envelope volume for '" << AtlasDetDescr::AtlasRegionHelper::getName(geoID)
139  << "' (GeoID="<< geoID << ").");
140 
141  // resetting volume for current geoID
142  m_volume[geoID] = 0;
143 
144  // volume definitions
145  const double phimin = 0.;
146  const double deltaphi = 360.*CLHEP::deg;
147  const std::string volumeName( AtlasDetDescr::AtlasRegionHelper::getName(geoID));
148 
149  {
150  // retrieve the vector of (r,z) values from the EnvelopeDefSvc
151  const RZPairVector &rz = m_envDefSvc->getRZBoundary( geoID );
152 
153  // entries in the database table
154  size_t curVolNumPoints = rz.size();
155  if ( !curVolNumPoints)
156  {
157  ATH_MSG_ERROR("No entries for " << AtlasDetDescr::AtlasRegionHelper::getName(geoID) << " envelope in envelope definition service. Unable to build envelope.");
158  // resources cleanup
159  return StatusCode::FAILURE;
160  }
161 
162  // arrays of (r,z) coordinates of the current envelope volume
163  double *z = new double[curVolNumPoints];
164  double *r = new double[curVolNumPoints];
165 
166  // convert vector of pairs into two arrays
167  RZPairVector::const_iterator rzIt = rz.begin();
168  for ( size_t i=0; i<curVolNumPoints; ++i)
169  {
170  r[i] = rzIt->first;
171  z[i] = rzIt->second;
172 
173  ++rzIt;
174  }
175 
176  // create a G4Polycone volume with the given dimensions
177  std::stringstream curName;
178  curName << volumeName;
179  // store it in the m_volume array
180  m_volume[geoID] = new G4Polycone( curName.str(), phimin, deltaphi, curVolNumPoints, r, z);
181  // set the volume name
182  m_volume[geoID]->SetName( volumeName);
183 
184  // cleanup
185  delete[] r;
186  delete[] z;
187  }
188 
189  return StatusCode::SUCCESS;
190 }

◆ fillDimensions()

StatusCode ISF::G4PolyconeGeoIDSvc::fillDimensions ( )
private

Retrieve and fill in the dimensions for the different AtlasRegion.

◆ identifyGeoID()

AtlasDetDescr::AtlasRegion ISF::G4PolyconeGeoIDSvc::identifyGeoID ( const Amg::Vector3D pos) const

A static filter that returns the AtlasRegion of the given position.

Definition at line 94 of file G4PolyconeGeoIDSvc.cxx.

95 {
96  // loop over geoIDs
97  for (unsigned short geoID=AtlasDetDescr::fFirstAtlasRegion; geoID<AtlasDetDescr::fNumAtlasRegions; ++geoID)
98  {
99  // point inside given geoID -> return geoID
101  {
102  return AtlasDetDescr::AtlasRegion(geoID);
103  }
104  }
105  // point is not inside any of the registered geoIDs
107 }

◆ identifyNextGeoID()

AtlasDetDescr::AtlasRegion ISF::G4PolyconeGeoIDSvc::identifyNextGeoID ( const Amg::Vector3D pos,
const Amg::Vector3D dir 
) const

Find the AtlasRegion that the particle will enter with its next infinitesimal step along the given direction.

Definition at line 110 of file G4PolyconeGeoIDSvc.cxx.

112 {
113 
114  // if position inside a volume -> return that volume as the next geoID
116  if validAtlasRegion(geoID)
117  {
118  return geoID;
119  }
120  //not inside - make a step towards the p direction and check if inside again
121  const Amg::Vector3D &dirUnit = dir.unit();
122  const Amg::Vector3D &posStep = pos+dirUnit;
123  AtlasDetDescr::AtlasRegion closestGeoID = identifyGeoID(posStep);
124  if validAtlasRegion(closestGeoID)
125  {
126  return closestGeoID;
127  }
129 }

◆ initialize()

StatusCode ISF::G4PolyconeGeoIDSvc::initialize ( )

Definition at line 48 of file G4PolyconeGeoIDSvc.cxx.

49 {
50  ATH_MSG_VERBOSE("initialize()");
51 
52  // retrieve envelope definition service
53  ATH_CHECK( m_envDefSvc.retrieve() );
54 
55  // create internal volume representations for the given dimensions
57  {
58  if ( createVolume( AtlasDetDescr::AtlasRegion(geoID)).isFailure())
59  {
60  ATH_MSG_ERROR("Unable to create volume representation for geoID="<<geoID);
61  }
62  }
63 
64  // setup the converter for: G4 enum to ISF::InsideType
65  m_typeConverter[kOutside] = ISF::fOutside;
66  m_typeConverter[kSurface] = ISF::fSurface;
67  m_typeConverter[kInside] = ISF::fInside;
68 
69  return StatusCode::SUCCESS;
70 }

◆ inside()

ISF::InsideType ISF::G4PolyconeGeoIDSvc::inside ( const Amg::Vector3D pos,
AtlasDetDescr::AtlasRegion  geoID 
) const

Checks if the given position (ISFParticle) is inside a given AtlasRegion.

Definition at line 73 of file G4PolyconeGeoIDSvc.cxx.

74 {
75  // initialized with default return value
77 
78  // check for volume to be present
79  G4VSolid *curVol = m_volume[geoID];
80  if (curVol)
81  {
82  G4ThreeVector posG4( pos.x(), pos.y(), pos.z() );
83  EInside g4Where = curVol->Inside( posG4 );
84 
85  // use this trick to quickly convert G4 type to ISF::InsideType
86  where = m_typeConverter[g4Where];
87  }
88 
89  // hand back the position information
90  return where;
91 }

◆ pushDimension() [1/2]

void ISF::G4PolyconeGeoIDSvc::pushDimension ( AtlasDetDescr::AtlasRegion  geoID,
double  r,
double  z 
)
private

◆ pushDimension() [2/2]

void ISF::G4PolyconeGeoIDSvc::pushDimension ( AtlasDetDescr::AtlasRegion  geoID,
double  rin,
double  rou,
double  z 
)
private

Member Data Documentation

◆ m_envDefSvc

ServiceHandle<IEnvelopeDefSvc> ISF::G4PolyconeGeoIDSvc::m_envDefSvc {this, "EnvelopeDefSvc", "AtlasGeometry_EnvelopeDefSvc"}
private

service providing the envelope dimensions for the different sub-detectors

Definition at line 74 of file G4PolyconeGeoIDSvc.h.

◆ m_typeConverter

ISF::InsideType ISF::G4PolyconeGeoIDSvc::m_typeConverter[ISF::fNumInsideTypes]
private

a quick way to convert G4 enum EInside to ISF::InsideType

Definition at line 80 of file G4PolyconeGeoIDSvc.h.

◆ m_volume

G4VSolid* ISF::G4PolyconeGeoIDSvc::m_volume[AtlasDetDescr::fNumAtlasRegions]
private
Todo:
:

Definition at line 77 of file G4PolyconeGeoIDSvc.h.


The documentation for this class was generated from the following files:
AtlasDetDescr::fNumAtlasRegions
@ fNumAtlasRegions
Definition: AtlasRegion.h:39
beamspotman.r
def r
Definition: beamspotman.py:676
ISF::G4PolyconeGeoIDSvc::createVolume
StatusCode createVolume(AtlasDetDescr::AtlasRegion geoID)
Retrieve and fill in the dimensions for the different AtlasRegion.
Definition: G4PolyconeGeoIDSvc.cxx:132
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ISF::G4PolyconeGeoIDSvc::identifyGeoID
AtlasDetDescr::AtlasRegion identifyGeoID(const Amg::Vector3D &pos) const
A static filter that returns the AtlasRegion of the given position.
Definition: G4PolyconeGeoIDSvc.cxx:94
RZPairVector
std::vector< RZPair > RZPairVector
Definition: RZPair.h:18
AtlasDetDescr::AtlasRegion
AtlasRegion
Definition: AtlasRegion.h:27
ISF::InsideType
InsideType
Definition: IGeoIDSvc.h:22
ISF::G4PolyconeGeoIDSvc::m_typeConverter
ISF::InsideType m_typeConverter[ISF::fNumInsideTypes]
a quick way to convert G4 enum EInside to ISF::InsideType
Definition: G4PolyconeGeoIDSvc.h:80
ISF::G4PolyconeGeoIDSvc::m_envDefSvc
ServiceHandle< IEnvelopeDefSvc > m_envDefSvc
service providing the envelope dimensions for the different sub-detectors
Definition: G4PolyconeGeoIDSvc.h:74
deg
#define deg
Definition: SbPolyhedron.cxx:17
AtlasDetDescr::fUndefinedAtlasRegion
@ fUndefinedAtlasRegion
Definition: AtlasRegion.h:29
ISF::fOutside
@ fOutside
Definition: IGeoIDSvc.h:23
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
AtlasDetDescr::AtlasRegionHelper::getName
static const char * getName(int region)
Definition: AtlasRegionHelper.cxx:13
ISF::fSurface
@ fSurface
Definition: IGeoIDSvc.h:24
ISF::fInside
@ fInside
Definition: IGeoIDSvc.h:25
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
python.Utils.unixtools.where
def where(filename, prepath=[])
"which" for python files -------------------------------------------------—
Definition: unixtools.py:53
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
beamspotman.dir
string dir
Definition: beamspotman.py:623
ISF::G4PolyconeGeoIDSvc::inside
ISF::InsideType inside(const Amg::Vector3D &pos, AtlasDetDescr::AtlasRegion geoID) const
Checks if the given position (ISFParticle) is inside a given AtlasRegion.
Definition: G4PolyconeGeoIDSvc.cxx:73
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
ISF::G4PolyconeGeoIDSvc::m_volume
G4VSolid * m_volume[AtlasDetDescr::fNumAtlasRegions]
Definition: G4PolyconeGeoIDSvc.h:77
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
assertAtlasRegion
#define assertAtlasRegion(region)
Definition: AtlasRegion.h:16
validAtlasRegion
#define validAtlasRegion(region)
Definition: AtlasRegion.h:15
AtlasDetDescr::fFirstAtlasRegion
@ fFirstAtlasRegion
Definition: AtlasRegion.h:31