LArSoft  v07_13_02
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 131 of file AuxDetReadoutGeometry.cxx.

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

Referenced by Construct().

134  {
135 
136  G4LogicalVolume* LogicalVolumeAtDepth = path[depth]->GetLogicalVolume();
137 
138  std::string volName(path[depth]->GetName());
139  if( volName.find("volAuxDet") != std::string::npos ){
140 
141  // find world coordinate of the AuxDet origin in cm
142  G4Point3D local(0., 0., 0.);
143  G4Point3D world = DepthToWorld * local; // G4 works in mm
144  double worldPos[3] = { world.x() / CLHEP::cm, world.y() / CLHEP::cm, world.z() / CLHEP::cm };
145 
146  unsigned int adNum;
147  fGeo->PositionToAuxDet(worldPos, adNum);
148  // N.B. This name is expected by code in LArG4:
149  std::string SDName = "AuxDetSD_AuxDet" + std::to_string(adNum) + "_0";
150  AuxDetReadout* adReadout = new larg4::AuxDetReadout(SDName, adNum, 0);
151 
152  LOG_DEBUG("AuxDetReadoutGeometry") << "found" << path[depth]->GetName()
153  << ", number " << adNum << ":0";
154 
155  // Tell Geant4's sensitive-detector manager about the AuxDetReadout class
156  (G4SDManager::GetSDMpointer())->AddNewDetector(adReadout);
157  LogicalVolumeAtDepth->SetSensitiveDetector(adReadout);
159  return;
160  }
161 
162  // Explore the next layer down -- unless it is a very deep geometry,
163  // recursion should end before exception is thrown.
164  unsigned int deeper = depth+1;
165  if(deeper >= path.size()){
166  throw cet::exception("AuxDetReadoutGeometry") << "exceeded maximum TGeoNode depth\n";
167  }
168 
169  // Note that there will be nd different branches off of path[depth]
170  G4int nd = LogicalVolumeAtDepth->GetNoDaughters();
171  for(int d = 0; d < nd; ++d){
172 
173  // get the physvol daughter in the logicalvol
174  path[deeper] = LogicalVolumeAtDepth->GetDaughter(d);
175 
176  // keep track of the transform to world coordinates for PositionToAuxDet
177  G4Transform3D DeeperToMother( path[deeper]->GetObjectRotationValue(),
178  path[deeper]->GetObjectTranslation() );
179  G4Transform3D DeeperToWorld = DepthToWorld * DeeperToMother;
180  this->FindAndMakeAuxDet(path, deeper, DeeperToWorld);
181  }
182 
183  }
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)
uint32_t fNumSensitiveVol
number of sensitive volumes
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(), fNumSensitiveVol, 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);
104  return;
105  }
106 
107  // Explore the next layer down -- unless it is a very deep geometry,
108  // recursion should end before exception is thrown.
109  unsigned int deeper = depth+1;
110  if(deeper >= path.size()){
111  throw cet::exception("AuxDetReadoutGeometry") << "exceeded maximum TGeoNode depth\n";
112  }
113 
114  // Note that there will be nd different branches off of path[depth]
115  G4int nd = LogicalVolumeAtDepth->GetNoDaughters();
116  for(int d = 0; d < nd; ++d){
117 
118  // get the physvol daughter in the logicalvol
119  path[deeper] = LogicalVolumeAtDepth->GetDaughter(d);
120 
121  // keep track of the transform to world coordinates for PositionToAuxDet
122  G4Transform3D DeeperToMother( path[deeper]->GetObjectRotationValue(),
123  path[deeper]->GetObjectTranslation() );
124  G4Transform3D DeeperToWorld = DepthToWorld * DeeperToMother;
125  this->FindAndMakeAuxDetSensitive(path, deeper, DeeperToWorld);
126  }
127 
128  }
uint32_t fNumSensitiveVol
number of sensitive volumes
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(), FindAndMakeAuxDet(), and FindAndMakeAuxDetSensitive().


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