GeometryTest35_module.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // $Id: GeometryTest35_module.cc,v 1.1 2011/02/17 01:45:48 brebel Exp $
3 //
4 //
5 // geometry unit tests
6 //
7 // tylerdalion@gmail.com
8 //
9 ////////////////////////////////////////////////////////////////////////
10 
11 #ifndef GEO_GEOMETRYTEST35_H
12 #define GEO_GEOMETRYTEST35_H
13 #include <cmath>
14 #include <vector>
15 #include <string>
16 #include <iostream>
17 
18 // ROOT includes
19 #include "TH1D.h"
20 #include "TH2D.h"
21 #include "TVector3.h"
22 #include "TNtuple.h"
23 #include "TGeoManager.h"
24 #include "TStopwatch.h"
25 #include "TMath.h"
26 
27 // LArSoft includes
37 
38 // Framework includes
41 #include "fhiclcpp/ParameterSet.h"
44 #include "art_root_io/TFileService.h"
45 #include "art_root_io/TFileDirectory.h"
47 
49 
50 namespace geo { class Geometry; }
51 
52 namespace geo {
54  public:
55  explicit GeometryTest35(fhicl::ParameterSet const& pset);
56  virtual ~GeometryTest35();
57 
58  virtual void analyze(art::Event const&) {}
59  virtual void beginJob();
60 
61  private:
62 
63  void testAuxDet();
64 
65  };
66 }
67 
68 namespace geo{
69 
70  //......................................................................
72  : EDAnalyzer(pset)
73  {
74  }
75 
76  //......................................................................
78  {
79  }
80 
81  //......................................................................
83  {
84 
85  mf::LogVerbatim("GeometryTest35") << "\n35t specific testing...\n";
86 
87  try{
88 
89  MF_LOG_DEBUG("GeometryTest35") << "test AuxDets...";
90  this->testAuxDet();
91  MF_LOG_DEBUG("GeometryTest35") << "complete.";
92 
93  }
94  catch (cet::exception &e) {
95  mf::LogWarning("GeometryTest35") << "exception caught: \n" << e;
96  }
97 
98  return;
99  }
100 
101 
102 
103  //......................................................................
105  {
107 
108  double origin[3] = {0.};
109  double AuxDetWorld[3] = {0.};
110  mf::LogVerbatim("35tAuxDetTest") << "Number of Aux Dets: " << geom->NAuxDets();
111  for(unsigned int a = 0; a < geom->NAuxDets(); ++a) {
112  geom->AuxDet(a).LocalToWorld(origin, AuxDetWorld);
113 
114  double testPos1[3] = {AuxDetWorld[0], AuxDetWorld[1], AuxDetWorld[2]};
115  double testPos2a[3] = {AuxDetWorld[0], AuxDetWorld[1], AuxDetWorld[2]};
116  double testPos2b[3] = {AuxDetWorld[0], AuxDetWorld[1], AuxDetWorld[2]};
117  std::string CounterType = "";
118 
119  if( strncmp( geom->AuxDet(a).TotalVolume()->GetName(), "volAuxDetTrap", 13 ) == 0 ){
120 
121  // in 35t gdml, width 2 is the smaller width at +z/2 in local coordinates
122  //
123  // Width 2
124  // ____ Height is the thickness
125  // / \ T of the trapezoid
126  // / \ |
127  // / \ | Length
128  // /__________\ _
129  // Width 1
130 
131  CounterType = "trapezoid";
132  testPos1[1] += geom->AuxDet(a).Length()/2 - 0.1;
133  testPos2a[2] += geom->AuxDet(a).HalfWidth2();
134  testPos2b[0] += geom->AuxDet(a).HalfWidth2();
135 
136  double TrapCheckPtA[3] = { AuxDetWorld[0]+geom->AuxDet(a).HalfWidth1(),
137  AuxDetWorld[1]+geom->AuxDet(a).Length()/2-0.1,
138  AuxDetWorld[2]};
139  double TrapCheckPtB[3] = { AuxDetWorld[0],
140  AuxDetWorld[1]+geom->AuxDet(a).Length()/2-0.1,
141  AuxDetWorld[2]+geom->AuxDet(a).HalfWidth1()};
142 
143 
144  // these points are close to the small end and should not be found
145 
146  bool trpCheckpta(true), trpCheckptb(true);
147  try{ trpCheckpta = (geom->FindAuxDetAtPosition(TrapCheckPtA) == a); }
148  catch(cet::exception &e){ trpCheckpta = false; }
149  try{ trpCheckptb = (geom->FindAuxDetAtPosition(TrapCheckPtB) == a); }
150  catch(cet::exception &e){ trpCheckptb = false; }
151 
152  if( trpCheckpta || trpCheckptb )
153  throw cet::exception("GeometryTest35_AuxDet")
154  << "\t ...Found unexpected test point outside of trapezoidal AuxDet "
155  << a << "\n";
156 
157 
158  } else {
159  CounterType = "box";
160  testPos2a[2] += geom->AuxDet(a).HalfWidth2();
161  testPos2b[0] += geom->AuxDet(a).HalfWidth2();
162  }
163 
164  mf::LogVerbatim("GeometryTest35_AuxDet") << "AuxDet " << a << ": " << CounterType
165  << ", Center: (" << AuxDetWorld[0] << ", "
166  << AuxDetWorld[1] << ", " << AuxDetWorld[2] << ")" << std::endl;
167 
168 
169  // if either test point 1 or test point 2 aren't found, something is wrong
170  // one of 2a or 2b should work
171 
172  bool tp1(false), tp2a(false), tp2b(false);
173  try{ tp1 = (geom->FindAuxDetAtPosition(testPos1) == a); }
174  catch(cet::exception &e){ }
175  try{ tp2a = (geom->FindAuxDetAtPosition(testPos2a) == a); }
176  catch(cet::exception &e){ }
177  try{ tp2b = (geom->FindAuxDetAtPosition(testPos2b) == a); }
178  catch(cet::exception &e){ }
179 
180 
181  if( !tp1 || !( tp2a || tp2b ) )
182  throw cet::exception("GeometryTest35_AuxDet")
183  << "\t ...Did not find expected test points around AuxDet "
184  << a << "\n";
185 
186  }// AuxDet loop
187 
188  }
189 
190 
191 
192 
193 }//end namespace
194 
195 
196 namespace geo{
197 
199 
200 }
201 
202 #endif
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
void LocalToWorld(const double *auxdet, double *world) const
Transform point from local auxiliary detector frame to world frame.
Definition: AuxDetGeo.h:120
Encapsulate the construction of a single cyostat.
Collect all the geometry header files together.
virtual void analyze(art::Event const &)
GeometryTest35(fhicl::ParameterSet const &pset)
std::string string
Definition: nybbler.cc:12
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:27
double HalfWidth2() const
Definition: AuxDetGeo.h:104
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:69
Definition of data types for geometry description.
AuxDetGeo const & AuxDet(unsigned int const ad=0) const
Returns the specified auxiliary detector.
Encapsulate the geometry of an auxiliary detector.
Encapsulate the geometry of a wire.
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
Encapsulate the geometry of an optical detector.
Encapsulate the construction of a single detector plane.
double Length() const
Definition: AuxDetGeo.h:102
const TGeoVolume * TotalVolume() const
Definition: AuxDetGeo.h:106
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
#define MF_LOG_DEBUG(id)
unsigned int FindAuxDetAtPosition(double const worldLoc[3]) const
Returns the index of the auxiliary detector at specified location.
double HalfWidth1() const
Definition: AuxDetGeo.h:103
Namespace collecting geometry-related classes utilities.
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:227
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
unsigned int NAuxDets() const
Returns the number of auxiliary detectors.
Encapsulate the construction of a single detector plane.