Public Member Functions | Private Member Functions | Private Attributes | List of all members
gar::geo::AuxDetGeo Class Reference

#include <AuxDetGeo.h>

Public Member Functions

 AuxDetGeo (std::vector< const TGeoNode * > &path, int depth)
 
 ~AuxDetGeo ()
 
void GetCenter (double *xyz, double localz=0.0) const
 
void GetNormalVector (double *xyzDir) const
 
double Length () const
 
double HalfWidth1 () const
 
double HalfWidth2 () const
 
double HalfHeight () const
 
const TGeoVolume * TotalVolume () const
 
double DistanceToPoint (double *xyz) const
 
void LocalToWorld (const double *local, double *world) const
 
void LocalToWorldVect (const double *local, double *world) const
 
void WorldToLocal (const double *world, double *local) const
 
void WorldToLocalVect (const double *world, double *local) const
 
std::string Name () const
 
size_t FindSensitiveVolume (double const worldLoc[3]) const
 
AuxDetSensitiveGeo const & PositionToSensitiveVolume (double const worldLoc[3], size_t &sv) const
 
AuxDetSensitiveGeo const & SensitiveVolume (size_t sv) const
 
size_t NSensitiveVolume () const
 
void SortSubVolumes (geo::AuxDetGeoObjectSorter const &sorter)
 

Private Member Functions

void FindAuxDetSensitive (std::vector< const TGeoNode * > &path, unsigned int depth)
 
void MakeAuxDetSensitive (std::vector< const TGeoNode * > &path, int depth)
 

Private Attributes

const TGeoVolume * fTotalVolume
 Total volume of AuxDet, called vol*. More...
 
TGeoHMatrix * fGeoMatrix
 Transformation matrix to world frame. More...
 
double fLength
 length of volume, along z direction in local More...
 
double fHalfWidth1
 1st half width of volume, at -z/2 in local coordinates More...
 
double fHalfWidth2
 2nd half width (width1==width2 for boxes), at +z/2 More...
 
double fHalfHeight
 half height of volume More...
 
std::vector< AuxDetSensitiveGeo * > fSensitive
 sensitive volumes in the detector More...
 

Detailed Description

Definition at line 24 of file AuxDetGeo.h.

Constructor & Destructor Documentation

gar::geo::AuxDetGeo::AuxDetGeo ( std::vector< const TGeoNode * > &  path,
int  depth 
)

Definition at line 30 of file AuxDetGeo.cxx.

32  : fTotalVolume(0)
33  {
34 
35  TGeoVolume *vc = path[depth]->GetVolume();
36  if(vc){
37  fTotalVolume = vc;
38  if(!fTotalVolume)
39  throw cet::exception("AuxDetGeo") << "cannot find AuxDet volume\n";
40 
41  }// end if found volume
42 
43  MF_LOG_DEBUG("Geometry") << "detector total volume is " << fTotalVolume->GetName();
44 
45  // Build the matrix that takes us to the top world frame
46  // build a matrix to take us from the local to the world coordinates
47  // in one step
48  fGeoMatrix = new TGeoHMatrix(*path[0]->GetMatrix());
49  for(int i = 1; i <= depth; ++i){
50  fGeoMatrix->Multiply(path[i]->GetMatrix());
51  }
52 
53  // look for sensitive volumes - if there are none then this aux det
54  // could be from an older gdml file than the introduction of AuxDetSensitiveGeo
55  // in that case assume the full AuxDetGeo is sensitive and copy its information
56  // into a single AuxDetSensitive
57  this->FindAuxDetSensitive(path, depth);
58  if( fSensitive.size() < 1) fSensitive.push_back(new AuxDetSensitiveGeo(fTotalVolume, fGeoMatrix));
59 
60  // set the ends depending on whether the shape is a box or trapezoid
61  std::string volName(fTotalVolume->GetName());
62  if( volName.find("Trap") != std::string::npos ) {
63 
64  // Small Width
65  // ____ Height is the thickness
66  // / \ T of the trapezoid
67  // / \ |
68  // / \ | Length
69  // /__________\ _
70  // Width
71  fHalfHeight = ((TGeoTrd2*)fTotalVolume->GetShape())->GetDy1(); // same as Dy2()
72  fLength = 2.0*((TGeoTrd2*)fTotalVolume->GetShape())->GetDz();
73  fHalfWidth1 = ((TGeoTrd2*)fTotalVolume->GetShape())->GetDx1(); // at -Dz
74  fHalfWidth2 = ((TGeoTrd2*)fTotalVolume->GetShape())->GetDx2(); // at +Dz
75  }
76  else {
77  fHalfWidth1 = ((TGeoBBox*)fTotalVolume->GetShape())->GetDX();
78  fHalfHeight = ((TGeoBBox*)fTotalVolume->GetShape())->GetDY();
79  fLength = 2.0*((TGeoBBox*)fTotalVolume->GetShape())->GetDZ();
81  }
82 
83  }
std::string string
Definition: nybbler.cc:12
const TGeoVolume * fTotalVolume
Total volume of AuxDet, called vol*.
Definition: AuxDetGeo.h:67
double fHalfWidth1
1st half width of volume, at -z/2 in local coordinates
Definition: AuxDetGeo.h:70
std::vector< AuxDetSensitiveGeo * > fSensitive
sensitive volumes in the detector
Definition: AuxDetGeo.h:73
double fHalfHeight
half height of volume
Definition: AuxDetGeo.h:72
TGeoHMatrix * fGeoMatrix
Transformation matrix to world frame.
Definition: AuxDetGeo.h:68
void FindAuxDetSensitive(std::vector< const TGeoNode * > &path, unsigned int depth)
Definition: AuxDetGeo.cxx:93
#define MF_LOG_DEBUG(id)
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
double fLength
length of volume, along z direction in local
Definition: AuxDetGeo.h:69
double fHalfWidth2
2nd half width (width1==width2 for boxes), at +z/2
Definition: AuxDetGeo.h:71
gar::geo::AuxDetGeo::~AuxDetGeo ( )

Definition at line 86 of file AuxDetGeo.cxx.

87  {
88  if(fGeoMatrix) delete fGeoMatrix;
89  return;
90  }
TGeoHMatrix * fGeoMatrix
Transformation matrix to world frame.
Definition: AuxDetGeo.h:68

Member Function Documentation

double gar::geo::AuxDetGeo::DistanceToPoint ( double *  xyz) const

Definition at line 181 of file AuxDetGeo.cxx.

182  {
183  double Center[3];
184  GetCenter(Center);
185  return std::sqrt((Center[0]-xyz[0])*(Center[0]-xyz[0]) +
186  (Center[1]-xyz[1])*(Center[1]-xyz[1]) +
187  (Center[2]-xyz[2])*(Center[2]-xyz[2]));
188  }
void GetCenter(double *xyz, double localz=0.0) const
Definition: AuxDetGeo.cxx:164
void gar::geo::AuxDetGeo::FindAuxDetSensitive ( std::vector< const TGeoNode * > &  path,
unsigned int  depth 
)
private

Definition at line 93 of file AuxDetGeo.cxx.

95  {
96  // Check if the current node is a senstive volume - we already know
97  // we are in an Auxiliary detector
98  std::string pathName(path[depth]->GetName());
99  if( pathName.find("Sensitive") != std::string::npos){
100  this->MakeAuxDetSensitive(path, depth);
101  return;
102  }
103 
104  // Explore the next layer down
105  unsigned int deeper = depth+1;
106  if (deeper>=path.size()) {
107  throw cet::exception("ExceededMaxDepth") << "Exceeded maximum depth\n";
108  }
109  const TGeoVolume* v = path[depth]->GetVolume();
110  int nd = v->GetNdaughters();
111  for (int i=0; i<nd; ++i) {
112  path[deeper] = v->GetNode(i);
113  this->FindAuxDetSensitive(path, deeper);
114  }
115  }
std::string string
Definition: nybbler.cc:12
void FindAuxDetSensitive(std::vector< const TGeoNode * > &path, unsigned int depth)
Definition: AuxDetGeo.cxx:93
void MakeAuxDetSensitive(std::vector< const TGeoNode * > &path, int depth)
Definition: AuxDetGeo.cxx:118
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
size_t gar::geo::AuxDetGeo::FindSensitiveVolume ( double const  worldLoc[3]) const

Definition at line 191 of file AuxDetGeo.cxx.

192  {
193  double local[3] = {0.};
194  for(unsigned int a = 0; a < fSensitive.size(); ++a) {
195 
196  this->SensitiveVolume(a).WorldToLocal(worldPos, local);
197  double HalfCenterWidth = (this->SensitiveVolume(a).HalfWidth1() + this->SensitiveVolume(a).HalfWidth2()) / 2;
198 
199  if( local[2] >= - this->SensitiveVolume(a).Length()/2 &&
200  local[2] <= this->SensitiveVolume(a).Length()/2 &&
201  local[1] >= - this->SensitiveVolume(a).HalfHeight() &&
202  local[1] <= this->SensitiveVolume(a).HalfHeight() &&
203  // if SensitiveVolume a is a box, then HalfSmallWidth = HalfWidth
204  local[0] >= - HalfCenterWidth + local[2]*(HalfCenterWidth-this->SensitiveVolume(a).HalfWidth2())/(this->SensitiveVolume(a).Length()/2) &&
205  local[0] <= HalfCenterWidth - local[2]*(HalfCenterWidth-this->SensitiveVolume(a).HalfWidth2())/(this->SensitiveVolume(a).Length()/2)
206  ) return a;
207 
208  }// for loop over AuxDetSensitive a
209 
210  throw cet::exception("Geometry") << "Can't find AuxDetSensitive for position ("
211  << worldPos[0] << ","
212  << worldPos[1] << ","
213  << worldPos[2] << ")\n";
214 
215  return UINT_MAX;
216  }
std::vector< AuxDetSensitiveGeo * > fSensitive
sensitive volumes in the detector
Definition: AuxDetGeo.h:73
AuxDetSensitiveGeo const & SensitiveVolume(size_t sv) const
Definition: AuxDetGeo.h:55
void WorldToLocal(const double *world, double *local) const
const double a
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void gar::geo::AuxDetGeo::GetCenter ( double *  xyz,
double  localz = 0.0 
) const

Return the center position of an AuxDet

Parameters
xyz: 3-D array. The returned location.
localz: Distance along the length of the volume (z) (cm). Default is 0.

Definition at line 164 of file AuxDetGeo.cxx.

165  {
166  double xyzLocal[3] = {0.,0.,localz};
167  this->LocalToWorld(xyzLocal, xyz);
168  }
void LocalToWorld(const double *local, double *world) const
Definition: AuxDetGeo.cxx:127
void gar::geo::AuxDetGeo::GetNormalVector ( double *  xyzDir) const

Definition at line 172 of file AuxDetGeo.cxx.

173  {
174  double normal[3]={0.,0.,1.};
175  this->LocalToWorldVect(normal,xyzDir);
176  }
void LocalToWorldVect(const double *local, double *world) const
Definition: AuxDetGeo.cxx:136
double gar::geo::AuxDetGeo::HalfHeight ( ) const
inline

Definition at line 38 of file AuxDetGeo.h.

38 { return fHalfHeight; }
double fHalfHeight
half height of volume
Definition: AuxDetGeo.h:72
double gar::geo::AuxDetGeo::HalfWidth1 ( ) const
inline

Definition at line 36 of file AuxDetGeo.h.

36 { return fHalfWidth1; }
double fHalfWidth1
1st half width of volume, at -z/2 in local coordinates
Definition: AuxDetGeo.h:70
double gar::geo::AuxDetGeo::HalfWidth2 ( ) const
inline

Definition at line 37 of file AuxDetGeo.h.

37 { return fHalfWidth2; }
double fHalfWidth2
2nd half width (width1==width2 for boxes), at +z/2
Definition: AuxDetGeo.h:71
double gar::geo::AuxDetGeo::Length ( ) const
inline

Definition at line 35 of file AuxDetGeo.h.

35 { return fLength; }
double fLength
length of volume, along z direction in local
Definition: AuxDetGeo.h:69
void gar::geo::AuxDetGeo::LocalToWorld ( const double *  local,
double *  world 
) const

Transform a position from local frame to world frame

Parameters
local: 3D array. Position in the local frame Input.
world: 3D array. Position in the world frame. Returned.

Definition at line 127 of file AuxDetGeo.cxx.

128  {
129  fGeoMatrix->LocalToMaster(local,world);
130  }
TGeoHMatrix * fGeoMatrix
Transformation matrix to world frame.
Definition: AuxDetGeo.h:68
void gar::geo::AuxDetGeo::LocalToWorldVect ( const double *  local,
double *  world 
) const

Transform a 3-vector from local frame to world frame

Parameters
local: 3D array. Position in the local frame Input.
world: 3D array. Position in the world frame. Returned.

Definition at line 136 of file AuxDetGeo.cxx.

137  {
138  fGeoMatrix->LocalToMasterVect(local,world);
139  }
TGeoHMatrix * fGeoMatrix
Transformation matrix to world frame.
Definition: AuxDetGeo.h:68
void gar::geo::AuxDetGeo::MakeAuxDetSensitive ( std::vector< const TGeoNode * > &  path,
int  depth 
)
private

Definition at line 118 of file AuxDetGeo.cxx.

119  {
120  fSensitive.push_back(new AuxDetSensitiveGeo(path, depth));
121  }
std::vector< AuxDetSensitiveGeo * > fSensitive
sensitive volumes in the detector
Definition: AuxDetGeo.h:73
std::string gar::geo::AuxDetGeo::Name ( ) const
inline

Definition at line 48 of file AuxDetGeo.h.

48 { return fTotalVolume->GetName(); }
const TGeoVolume * fTotalVolume
Total volume of AuxDet, called vol*.
Definition: AuxDetGeo.h:67
size_t gar::geo::AuxDetGeo::NSensitiveVolume ( ) const
inline

Definition at line 56 of file AuxDetGeo.h.

56 { return fSensitive.size(); }
std::vector< AuxDetSensitiveGeo * > fSensitive
sensitive volumes in the detector
Definition: AuxDetGeo.h:73
AuxDetSensitiveGeo const & gar::geo::AuxDetGeo::PositionToSensitiveVolume ( double const  worldLoc[3],
size_t &  sv 
) const

Definition at line 219 of file AuxDetGeo.cxx.

221  {
222  sv = this->FindSensitiveVolume(worldLoc);
223  return this->SensitiveVolume(sv);
224  }
AuxDetSensitiveGeo const & SensitiveVolume(size_t sv) const
Definition: AuxDetGeo.h:55
size_t FindSensitiveVolume(double const worldLoc[3]) const
Definition: AuxDetGeo.cxx:191
AuxDetSensitiveGeo const& gar::geo::AuxDetGeo::SensitiveVolume ( size_t  sv) const
inline

Definition at line 55 of file AuxDetGeo.h.

55 { return *fSensitive[sv]; }
std::vector< AuxDetSensitiveGeo * > fSensitive
sensitive volumes in the detector
Definition: AuxDetGeo.h:73
void gar::geo::AuxDetGeo::SortSubVolumes ( geo::AuxDetGeoObjectSorter const &  sorter)

Definition at line 227 of file AuxDetGeo.cxx.

228  {
229  sorter.SortAuxDetSensitive(fSensitive);
230 
231  return;
232  }
std::vector< AuxDetSensitiveGeo * > fSensitive
sensitive volumes in the detector
Definition: AuxDetGeo.h:73
const TGeoVolume* gar::geo::AuxDetGeo::TotalVolume ( ) const
inline

Definition at line 39 of file AuxDetGeo.h.

39 { return fTotalVolume; }
const TGeoVolume * fTotalVolume
Total volume of AuxDet, called vol*.
Definition: AuxDetGeo.h:67
void gar::geo::AuxDetGeo::WorldToLocal ( const double *  world,
double *  local 
) const

Transform a position from world frame to local frame

Parameters
world: 3D array. Position in the world frame. Input.
local: 3D array. Position in the local frame Returned.

Definition at line 145 of file AuxDetGeo.cxx.

146  {
147  fGeoMatrix->MasterToLocal(world,local);
148  }
TGeoHMatrix * fGeoMatrix
Transformation matrix to world frame.
Definition: AuxDetGeo.h:68
void gar::geo::AuxDetGeo::WorldToLocalVect ( const double *  world,
double *  local 
) const

Transform a 3-vector from world frame to local frame

Parameters
world: 3D array. Position in the world frame. Input.
local: 3D array. Position in the local frame Returned.

Definition at line 154 of file AuxDetGeo.cxx.

155  {
156  fGeoMatrix->MasterToLocalVect(world,local);
157  }
TGeoHMatrix * fGeoMatrix
Transformation matrix to world frame.
Definition: AuxDetGeo.h:68

Member Data Documentation

TGeoHMatrix* gar::geo::AuxDetGeo::fGeoMatrix
private

Transformation matrix to world frame.

Definition at line 68 of file AuxDetGeo.h.

double gar::geo::AuxDetGeo::fHalfHeight
private

half height of volume

Definition at line 72 of file AuxDetGeo.h.

double gar::geo::AuxDetGeo::fHalfWidth1
private

1st half width of volume, at -z/2 in local coordinates

Definition at line 70 of file AuxDetGeo.h.

double gar::geo::AuxDetGeo::fHalfWidth2
private

2nd half width (width1==width2 for boxes), at +z/2

Definition at line 71 of file AuxDetGeo.h.

double gar::geo::AuxDetGeo::fLength
private

length of volume, along z direction in local

Definition at line 69 of file AuxDetGeo.h.

std::vector<AuxDetSensitiveGeo*> gar::geo::AuxDetGeo::fSensitive
private

sensitive volumes in the detector

Definition at line 73 of file AuxDetGeo.h.

const TGeoVolume* gar::geo::AuxDetGeo::fTotalVolume
private

Total volume of AuxDet, called vol*.

Definition at line 67 of file AuxDetGeo.h.


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