LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
larg4::AuxDetReadoutGeometry Class Reference

#include "AuxDetReadoutGeometry.h"

Inheritance diagram for larg4::AuxDetReadoutGeometry:

Public Member Functions

 AuxDetReadoutGeometry (const G4String name="AuxDetReadoutGeometry")
 Constructor and destructor. More...
 
virtual ~AuxDetReadoutGeometry ()
 
virtual void Construct ()
 

Private Member Functions

void FindAndMakeAuxDet (std::vector< const G4VPhysicalVolume * > &path, unsigned int depth, G4Transform3D DepthToWorld)
 
void FindAndMakeAuxDetSensitive (std::vector< const G4VPhysicalVolume * > &path, unsigned int depth, G4Transform3D DepthToWorld)
 

Private Attributes

art::ServiceHandle< geo::GeometryfGeo
 Handle to the geometry. More...
 
uint32_t fNumSensitiveVol
 number of sensitive volumes More...
 

Detailed Description

Definition at line 36 of file AuxDetReadoutGeometry.h.

Constructor & Destructor Documentation

larg4::AuxDetReadoutGeometry::AuxDetReadoutGeometry ( const G4String  name = "AuxDetReadoutGeometry")

Constructor and destructor.

Definition at line 39 of file AuxDetReadoutGeometry.cxx.

40  : G4VUserParallelWorld(name)
41  , fNumSensitiveVol(0)
42  {}
uint32_t fNumSensitiveVol
number of sensitive volumes
larg4::AuxDetReadoutGeometry::~AuxDetReadoutGeometry ( )
virtual

Definition at line 43 of file AuxDetReadoutGeometry.cxx.

44  {}

Member Function Documentation

void larg4::AuxDetReadoutGeometry::Construct ( )
virtual

The key method in this class; creates a parallel world view of those volumes relevant to the auxiliary detector readout. Required of any class that inherits from G4VUserParallelWorld

Definition at line 47 of file AuxDetReadoutGeometry.cxx.

References FindAndMakeAuxDet(), FindAndMakeAuxDetSensitive(), fNumSensitiveVol, and g4b::DetectorConstruction::GetWorld().

48  {
49 
50  // We want to find all of the AuxDets that the Geometry service would
51  // find and make each one a G4 sensitive detector.
52 
53  // Call initial case of a function that will rucursively run through
54  // the volume tree down to max depth. Start at 0 depth with World,
55  // where the initial translation and rotation should be 0 as well
56  unsigned int MaxDepth = 8; // should be plenty
57  std::vector<const G4VPhysicalVolume*> path(MaxDepth);
59  G4Transform3D InitTransform( path[0]->GetObjectRotationValue(),
60  path[0]->GetObjectTranslation() );
61 
62  // first try to make sensitive volumes, if those are not in
63  // the gdml file (ie file was made before the introduction of
64  // sensitive volumes) fall back to looking for the aux dets
65  this->FindAndMakeAuxDetSensitive(path, 0, InitTransform);
66  if(fNumSensitiveVol < 1)
67  this->FindAndMakeAuxDet(path, 0, InitTransform);
68 
69 
70  return;
71  }// end Construct
static G4VPhysicalVolume * GetWorld()
void FindAndMakeAuxDet(std::vector< const G4VPhysicalVolume * > &path, unsigned int depth, G4Transform3D DepthToWorld)
uint32_t fNumSensitiveVol
number of sensitive volumes
void FindAndMakeAuxDetSensitive(std::vector< const G4VPhysicalVolume * > &path, unsigned int depth, G4Transform3D DepthToWorld)
void larg4::AuxDetReadoutGeometry::FindAndMakeAuxDet ( std::vector< const G4VPhysicalVolume * > &  path,
unsigned int  depth,
G4Transform3D  DepthToWorld 
)
private

Definition at line 130 of file AuxDetReadoutGeometry.cxx.

References d, fGeo, LOG_DEBUG, geo::GeometryCore::PositionToAuxDet(), and util::flags::to_string().

Referenced by Construct().

133  {
134 
135  G4LogicalVolume* LogicalVolumeAtDepth = path[depth]->GetLogicalVolume();
136 
137  std::string volName(path[depth]->GetName());
138  if( volName.find("volAuxDet") != std::string::npos ){
139 
140  // find world coordinate of the AuxDet origin in cm
141  G4Point3D local(0., 0., 0.);
142  G4Point3D world = DepthToWorld * local; // G4 works in mm
143  double worldPos[3] = { world.x() / CLHEP::cm, world.y() / CLHEP::cm, world.z() / CLHEP::cm };
144 
145  unsigned int adNum;
146  fGeo->PositionToAuxDet(worldPos, adNum);
147  // N.B. This name is expected by code in LArG4:
148  std::string SDName = "AuxDetSD_AuxDet" + std::to_string(adNum) + "_0";
149  AuxDetReadout* adReadout = new larg4::AuxDetReadout(SDName, adNum, 0);
150 
151  LOG_DEBUG("AuxDetReadoutGeometry") << "found" << path[depth]->GetName()
152  << ", number " << adNum << ":0";
153 
154  // Tell Geant4's sensitive-detector manager about the AuxDetReadout class
155  (G4SDManager::GetSDMpointer())->AddNewDetector(adReadout);
156  LogicalVolumeAtDepth->SetSensitiveDetector(adReadout);
157  return;
158  }
159 
160  // Explore the next layer down -- unless it is a very deep geometry,
161  // recursion should end before exception is thrown.
162  unsigned int deeper = depth+1;
163  if(deeper >= path.size()){
164  throw cet::exception("AuxDetReadoutGeometry") << "exceeded maximum TGeoNode depth\n";
165  }
166 
167  // Note that there will be nd different branches off of path[depth]
168  G4int nd = LogicalVolumeAtDepth->GetNoDaughters();
169  for(int d = 0; d < nd; ++d){
170 
171  // get the physvol daughter in the logicalvol
172  path[deeper] = LogicalVolumeAtDepth->GetDaughter(d);
173 
174  // keep track of the transform to world coordinates for PositionToAuxDet
175  G4Transform3D DeeperToMother( path[deeper]->GetObjectRotationValue(),
176  path[deeper]->GetObjectTranslation() );
177  G4Transform3D DeeperToWorld = DepthToWorld * DeeperToMother;
178  this->FindAndMakeAuxDet(path, deeper, DeeperToWorld);
179  }
180 
181  }
AuxDetGeo const & PositionToAuxDet(geo::Point_t const &point, unsigned int &ad) const
Returns the auxiliary detector at specified location.
void FindAndMakeAuxDet(std::vector< const G4VPhysicalVolume * > &path, unsigned int depth, G4Transform3D DepthToWorld)
Float_t d
Definition: plot.C:237
std::string to_string(Flag_t< Storage > const flag)
Convert a flag into a stream (shows its index).
Definition: BitMask.h:187
#define LOG_DEBUG(id)
art::ServiceHandle< geo::Geometry > fGeo
Handle to the geometry.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void larg4::AuxDetReadoutGeometry::FindAndMakeAuxDetSensitive ( std::vector< const G4VPhysicalVolume * > &  path,
unsigned int  depth,
G4Transform3D  DepthToWorld 
)
private

Definition at line 74 of file AuxDetReadoutGeometry.cxx.

References d, fGeo, geo::GeometryCore::FindAuxDetSensitiveAtPosition(), LOG_DEBUG, and util::flags::to_string().

Referenced by Construct().

77  {
78 
79  G4LogicalVolume* LogicalVolumeAtDepth = path[depth]->GetLogicalVolume();
80 
81  std::string volName(path[depth]->GetName());
82  if( volName.find("volAuxDet") != std::string::npos &&
83  volName.find("Sensitive") != std::string::npos){
84 
85  // find world coordinate of the AuxDet origin in cm
86  G4Point3D local(0., 0., 0.);
87  G4Point3D world = DepthToWorld * local; // G4 works in mm
88  double worldPos[3] = { world.x() / CLHEP::cm, world.y() / CLHEP::cm, world.z() / CLHEP::cm };
89 
90  size_t adNum = 0;
91  size_t svNum = 0;
92  fGeo->FindAuxDetSensitiveAtPosition(worldPos, adNum, svNum);
93  // N.B. This name is expected by code in LArG4:
94  std::string SDName = "AuxDetSD_AuxDet" + std::to_string(adNum) + "_" + std::to_string(svNum);
95  AuxDetReadout* adReadout = new larg4::AuxDetReadout(SDName, adNum, svNum);
96 
97  LOG_DEBUG("AuxDetReadoutGeometry") << "found" << path[depth]->GetName()
98  << ", number " << adNum << ":" << svNum;
99 
100  // Tell Geant4's sensitive-detector manager about the AuxDetReadout class
101  (G4SDManager::GetSDMpointer())->AddNewDetector(adReadout);
102  LogicalVolumeAtDepth->SetSensitiveDetector(adReadout);
103  return;
104  }
105 
106  // Explore the next layer down -- unless it is a very deep geometry,
107  // recursion should end before exception is thrown.
108  unsigned int deeper = depth+1;
109  if(deeper >= path.size()){
110  throw cet::exception("AuxDetReadoutGeometry") << "exceeded maximum TGeoNode depth\n";
111  }
112 
113  // Note that there will be nd different branches off of path[depth]
114  G4int nd = LogicalVolumeAtDepth->GetNoDaughters();
115  for(int d = 0; d < nd; ++d){
116 
117  // get the physvol daughter in the logicalvol
118  path[deeper] = LogicalVolumeAtDepth->GetDaughter(d);
119 
120  // keep track of the transform to world coordinates for PositionToAuxDet
121  G4Transform3D DeeperToMother( path[deeper]->GetObjectRotationValue(),
122  path[deeper]->GetObjectTranslation() );
123  G4Transform3D DeeperToWorld = DepthToWorld * DeeperToMother;
124  this->FindAndMakeAuxDetSensitive(path, deeper, DeeperToWorld);
125  }
126 
127  }
void FindAuxDetSensitiveAtPosition(geo::Point_t const &point, std::size_t &adg, std::size_t &sv) const
Fills the indices of the sensitive auxiliary detector at location.
Float_t d
Definition: plot.C:237
std::string to_string(Flag_t< Storage > const flag)
Convert a flag into a stream (shows its index).
Definition: BitMask.h:187
#define LOG_DEBUG(id)
art::ServiceHandle< geo::Geometry > fGeo
Handle to the geometry.
void FindAndMakeAuxDetSensitive(std::vector< const G4VPhysicalVolume * > &path, unsigned int depth, G4Transform3D DepthToWorld)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

Member Data Documentation

art::ServiceHandle<geo::Geometry> larg4::AuxDetReadoutGeometry::fGeo
private

Handle to the geometry.

Definition at line 58 of file AuxDetReadoutGeometry.h.

Referenced by FindAndMakeAuxDet(), and FindAndMakeAuxDetSensitive().

uint32_t larg4::AuxDetReadoutGeometry::fNumSensitiveVol
private

number of sensitive volumes

Definition at line 59 of file AuxDetReadoutGeometry.h.

Referenced by Construct().


The documentation for this class was generated from the following files: