Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DGeometry.h
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: DGeometry.h
4 // Created: Thu Apr 3 08:43:06 EDT 2008
5 // Creator: davidl (on Darwin swire-d95.jlab.org 8.11.1 i386)
6 //
7 
8 #ifndef _DGeometry_
9 #define _DGeometry_
10 
11 #include <pthread.h>
12 #include <map>
13 
14 #include <JANA/jerror.h>
15 #include <JANA/JGeometry.h>
16 using namespace jana;
17 
18 #include <DANA/DApplication.h>
19 #include "FDC/DFDCGeometry.h"
20 #include "FDC/DFDCWire.h"
21 #include "FDC/DFDCCathode.h"
22 #include "CDC/DCDCWire.h"
23 
24 #include <particleType.h>
25 #include <DVector3.h>
26 #include "DMaterial.h"
27 #include "DMaterialMap.h"
28 using namespace jana;
29 
30 class DApplication;
31 class DMagneticFieldMap;
33 
34 
35 class DGeometry{
36  public:
37  DGeometry(JGeometry *jgeom, DApplication *dapp, int32_t runnumber);
38  virtual ~DGeometry();
39  virtual const char* className(void){return static_className();}
40  static const char* static_className(void){return "DGeometry";}
41 
42  JGeometry* GetJGeometry(void) {return jgeom;}
43  DMagneticFieldMap* GetBfield(void) const;
44  DLorentzDeflections *GetLorentzDeflections(void);
45 
46  // These methods just map to the same methods in JGeometry. Ideally, we'd
47  // base DGeometry on JGeometry and so we'd get these automatically.
48  // However, that would require a more complicated generator mechanism
49  // where the geometry objects are made outside of JANA.
50  bool Get(string xpath, string &sval) const {return jgeom->Get(xpath, sval);}
51  bool Get(string xpath, map<string, string> &svals) const {return jgeom->Get(xpath, svals);}
52  template<class T> bool Get(string xpath, T &val) const {return jgeom->Get(xpath, val);}
53  template<class T> bool Get(string xpath, vector<T> &vals, string delimiter=" ") const {return jgeom->Get(xpath, vals, delimiter);}
54  template<class T> bool Get(string xpath, map<string,T> &vals) const {return jgeom->Get(xpath, vals);}
55 
56  // The GNU 3.2.3 compiler has a problem resolving the ambiguity between
57  // Get(string, T&val) and Get(string, vector<T> &vals, string) above.
58  // This does not seem to be a problem with the 4.0 compiler. To get
59  // around this, some non-templated versions are provided (eeech!).
60  bool Get(string xpath, vector<double> &vals, string delimiter=" ") const {return jgeom->Get(xpath, vals, delimiter);}
61  bool Get(string xpath, vector<int> &vals, string delimiter=" ") const {return jgeom->Get(xpath, vals, delimiter);}
62  bool Get(string xpath, vector<float> &vals, string delimiter=" ") const {return jgeom->Get(xpath, vals, delimiter);}
63 
64  bool GetMultiple(string xpath,vector<vector<double> >&vals,
65  string delimiter=" ") const
66  {return jgeom->GetMultiple(xpath,vals,delimiter);}
67 
68  typedef struct{
69  double du,dphi,dz;
71  typedef struct{
72  double dPhiX,dPhiY,dPhiZ;
74  typedef struct{
75  double du,dphi;
77  typedef struct{
78  double dx_u,dy_u,dx_d,dy_d;
79  }cdc_offset_t;
80 
81  typedef pair<string, map<string,string> > node_t;
82  typedef vector<node_t> xpathparsed_t;
83 
84  void FindNodes(string xpath, vector<xpathparsed_t> &matched_xpaths) const;
85 
86  // Methods for accessing material map tables obtained from calibDB
87  jerror_t FindMat(DVector3 &pos, double &rhoZ_overA, double &rhoZ_overA_logI, double &RadLen) const;
88  jerror_t FindMat(DVector3 &pos, double &density, double &A, double &Z, double &RadLen) const;
89  jerror_t FindMatALT1(DVector3 &pos, DVector3 &mom, double &KrhoZ_overA,
90  double &rhoZ_overA,double &LnI,
91  double &X0, double *s_to_boundary=NULL) const;
92  jerror_t FindMatKalman(const DVector3 &pos,const DVector3 &mom,
93  double &KrhoZ_overA,
94  double &rhoZ_overA,double &LnI,double &Z,
95  double &chi2c_factor,
96  double &chi2a_factor,
97  double &chi2a_factor2,
98  unsigned int &last_index,
99  double *s_to_boundary=NULL) const;
100  jerror_t FindMatKalman(const DVector3 &pos,
101  double &KrhoZ_overA,
102  double &rhoZ_overA,double &LnI,
103  double &Z,
104  double &chi2c_factor,
105  double &chi2a_factor,
106  double &chi2a_factor2,
107  unsigned int &last_index) const;
108 
109  const DMaterialMap::MaterialNode* FindMatNode(DVector3 &pos) const;
110  const DMaterialMap* FindDMaterialMap(DVector3 &pos) const;
111 
112  // Convenience methods
113  const DMaterial* GetDMaterial(string name) const;
114 
115  bool GetFDCWires(vector<vector<DFDCWire *> >&fdcwires) const;
116  bool GetFDCCathodes(vector<vector<DFDCCathode *> >&fdccathodes) const;
117  bool GetFDCZ(vector<double> &z_wires) const; ///< z-locations for each of the FDC wire planes in cm
118  bool GetFDCStereo(vector<double> &stereo_angles) const; ///< stereo angles of each of the FDC wire layers
119  bool GetFDCRmin(vector<double> &rmin_packages) const; ///< beam hole size for each FDC package in cm
120  bool GetFDCRmax(double &rmax_active_fdc) const; ///< outer radius of FDC active area in cm
121 
122  bool GetCDCWires(vector<vector<DCDCWire *> >&cdcwires) const;
123  bool GetCDCOption(string &cdc_option) const; ///< get the centralDC_option-X string
124  bool GetCDCCenterZ(double &cdc_center_z) const; ///< z-location of center of CDC wires in cm
125  bool GetCDCAxialLength(double &cdc_axial_length) const; ///< length of CDC axial wires in cm
126  bool GetCDCStereo(vector<double> &cdc_stereo) const; ///< stereo angle for each CDC layer in degrees
127  bool GetCDCRmid(vector<double> &cdc_rmid) const; ///< Distance of the center of CDC wire from beamline for each layer in cm
128  bool GetCDCNwires(vector<int> &cdc_nwires) const; ///< Number of wires for each CDC layer
129  bool GetCDCEndplate(double &z,double &dz,double &rmin,double &rmax) const;
130  bool GetCDCAxialWires(unsigned int ring,unsigned int ncopy,
131  double zcenter,double dz,
132  vector<vector<cdc_offset_t> >&cdc_offsets,
133  vector<DCDCWire*> &axialwires,
134  vector<double>&rot_angles,double dx,
135  double dy) const;
136  bool GetCDCStereoWires(unsigned int ring,unsigned int ncopy,
137  double zcenter,
138  double dz,
139  vector<vector<cdc_offset_t> >&cdc_offsets,
140  vector<DCDCWire*> &stereowires,
141  vector<double>&rot_angles,
142  double dx,double dy) const;
143 
144  bool GetBCALRmin(float &bcal_rmin) const; ///< minimum distance of BCAL module from beam line
145  bool GetBCALfADCRadii(vector<float> &fADC_radii) const; ///< fADC radii including the outer radius of the last layer
146  bool GetBCALNmodules(unsigned int &bcal_nmodules) const; ///< Number of BCAL modules
147  bool GetBCALCenterZ(float &bcal_center_z) const; ///< z-location of center of BCAL module in cm
148  bool GetBCALLength(float &bcal_length) const; ///< length of BCAL module in cm
149  bool GetBCALDepth(float &bcal_depth) const; ///< depth (or height) of BCAL module in cm
150  bool GetBCALPhiShift(float &bcal_phi_shift) const; ///< phi angle in degrees that first BCAL module is shifted from being centered at ph=0.0
151 
152  bool GetCCALZ(double &z_ccal) const; /// z-location of front face of CCAL in cm
153 
154  bool GetFCALZ(double &z_fcal) const; ///< z-location of front face of FCAL in cm
155  bool GetDIRCZ(double &z_dirc) const; ///< z-location of DIRC in cm
156  bool GetTOFZ(vector<double> &z_tof) const; ///< z-location of front face of each of TOF in cm
157  bool GetTOFPaddlePerpPositions(vector<double> &y_tof) const;
158  bool GetTOFPaddleParameters(map<string,double> &paddle_params) const;
159  bool GetTargetZ(double &z_target) const; ///< z-location of center of target
160  bool GetTargetLength(double &target_length) const; ///< z-location of center of target
161 
162  bool GetStartCounterGeom(vector<vector<DVector3> >&pos,
163  vector<vector<DVector3> >&norm) const; // < vectors containing positions and norm 3-vectors for start counter
164  // There are 30 sets of positions (pos) of points along the
165  // start counter, one set for each paddle, and a corresponding
166  // set of norms at various points along the start counter.
167  // For example, to access the most upstream point of paddle 1
168  // use pos[0][0]. The end of the barrel section before the
169  // nose region is at pos[0][1]. The tip of the nose region
170  // for this paddle is at pos[0][pos[0].size()-1]. The bend
171  // region is modeled by many closely-spaced points starting
172  // after pos[0][1].
173 
174 
175  vector<DMaterialMap*> GetMaterialMapVector(void) const;
176 
177  protected:
179  void ReadMaterialMaps(void) const;
180  void GetMaterials(void) const;
181  bool GetCompositeMaterial(const string &name, double &density, double &radlen) const;
182 
183  private:
184  JGeometry *jgeom;
187  int32_t runnumber;
188  mutable vector<DMaterial*> materials; /// Older implementation to keep track of material specs without ranges
189  mutable vector<DMaterialMap*> materialmaps; /// Material maps generated automatically(indirectly) from XML with ranges and specs
190  mutable bool materialmaps_read;
191  mutable bool materials_read;
192 
193  mutable pthread_mutex_t bfield_mutex;
194  mutable pthread_mutex_t materialmap_mutex;
195  mutable pthread_mutex_t materials_mutex;
196 
197 
198 };
199 
200 #endif // _DGeometry_
201 
JGeometry * GetJGeometry(void)
Definition: DGeometry.h:42
bool Get(string xpath, vector< T > &vals, string delimiter=" ") const
Definition: DGeometry.h:53
DApplication * dapp
bool Get(string xpath, vector< int > &vals, string delimiter=" ") const
Definition: DGeometry.h:61
bool Get(string xpath, T &val) const
Definition: DGeometry.h:52
double rmax
pthread_mutex_t materialmap_mutex
Definition: DGeometry.h:194
#define X0
JGeometry * jgeom
Definition: DGeometry.h:184
TVector3 DVector3
Definition: DVector3.h:14
bool materials_read
Definition: DGeometry.h:191
DApplication * dapp
Definition: DGeometry.h:185
pthread_mutex_t materials_mutex
Definition: DGeometry.h:195
static vector< vector< DFDCWire * > > fdcwires
bool Get(string xpath, string &sval) const
Definition: DGeometry.h:50
bool materialmaps_read
Material maps generated automatically(indirectly) from XML with ranges and specs. ...
Definition: DGeometry.h:190
double rmin
vector< DMaterialMap * > materialmaps
Older implementation to keep track of material specs without ranges.
Definition: DGeometry.h:189
bool Get(string xpath, vector< float > &vals, string delimiter=" ") const
Definition: DGeometry.h:62
pair< string, map< string, string > > node_t
Definition: DGeometry.h:81
int32_t runnumber
Definition: DGeometry.h:187
bool Get(string xpath, map< string, string > &svals) const
Definition: DGeometry.h:51
DMagneticFieldMap * bfield
Definition: DGeometry.h:186
bool Get(string xpath, map< string, T > &vals) const
Definition: DGeometry.h:54
vector< DMaterial * > materials
Definition: DGeometry.h:188
vector< node_t > xpathparsed_t
Definition: DGeometry.h:82
The DMaterial class holds information on a single material type. The main purpose is to hold informat...
Definition: DMaterial.h:25
virtual const char * className(void)
Definition: DGeometry.h:39
bool Get(string xpath, vector< double > &vals, string delimiter=" ") const
Definition: DGeometry.h:60
bool GetMultiple(string xpath, vector< vector< double > > &vals, string delimiter=" ") const
Definition: DGeometry.h:64
static const char * static_className(void)
Definition: DGeometry.h:40
pthread_mutex_t bfield_mutex
Definition: DGeometry.h:193