// $Id$ // // File: DGeometry.h // Created: Thu Apr 3 08:43:06 EDT 2008 // Creator: davidl (on Darwin swire-d95.jlab.org 8.11.1 i386) // #ifndef _DGeometry_ #define _DGeometry_ #include #include #include #include using namespace jana; #include #include "FDC/DFDCGeometry.h" #include "FDC/DFDCWire.h" #include "FDC/DFDCCathode.h" #include "CDC/DCDCWire.h" #include #include #include "DMaterial.h" #include "DMaterialMap.h" using namespace jana; class DApplication; class DMagneticFieldMap; class DLorentzDeflections; class DGeometry{ public: DGeometry(JGeometry *jgeom, DApplication *dapp, unsigned int runnumber); virtual ~DGeometry(); virtual const char* className(void){return static_className();} static const char* static_className(void){return "DGeometry";} JGeometry* GetJGeometry(void) {return jgeom;} DMagneticFieldMap* GetBfield(void) const; DLorentzDeflections *GetLorentzDeflections(void); // These methods just map to the same methods in JGeometry. Ideally, we'd // base DGeometry on JGeometry and so we'd get these automatically. // However, that would require a more complicated generator mechanism // where the geometry objects are made outside of JANA. bool Get(string xpath, string &sval) const {return jgeom->Get(xpath, sval);} bool Get(string xpath, map &svals) const {return jgeom->Get(xpath, svals);} template bool Get(string xpath, T &val) const {return jgeom->Get(xpath, val);} template bool Get(string xpath, vector &vals, string delimiter=" ") const {return jgeom->Get(xpath, vals, delimiter);} template bool Get(string xpath, map &vals) const {return jgeom->Get(xpath, vals);} // The GNU 3.2.3 compiler has a problem resolving the ambiguity between // Get(string, T&val) and Get(string, vector &vals, string) above. // This does not seem to be a problem with the 4.0 compiler. To get // around this, some non-templated versions are provided (eeech!). bool Get(string xpath, vector &vals, string delimiter=" ") const {return jgeom->Get(xpath, vals, delimiter);} bool Get(string xpath, vector &vals, string delimiter=" ") const {return jgeom->Get(xpath, vals, delimiter);} bool Get(string xpath, vector &vals, string delimiter=" ") const {return jgeom->Get(xpath, vals, delimiter);} bool GetMultiple(string xpath,vector >&vals, string delimiter=" ") const {return jgeom->GetMultiple(xpath,vals,delimiter);} typedef struct{ double du,dphi,dz; }fdc_wire_offset_t; typedef struct{ double du,dphi; }fdc_cathode_offset_t; typedef struct{ double dx_u,dy_u,dx_d,dy_d; }cdc_offset_t; typedef pair > node_t; typedef vector xpathparsed_t; void FindNodes(string xpath, vector &matched_xpaths) const; // Methods for accessing material map tables obtained from calibDB jerror_t FindMat(DVector3 &pos, double &rhoZ_overA, double &rhoZ_overA_logI, double &RadLen) const; jerror_t FindMat(DVector3 &pos, double &density, double &A, double &Z, double &RadLen) const; jerror_t FindMatALT1(DVector3 &pos, DVector3 &mom, double &KrhoZ_overA, double &rhoZ_overA,double &LnI, double &X0, double *s_to_boundary=NULL) const; jerror_t FindMatKalman(const DVector3 &pos,const DVector3 &mom, double &KrhoZ_overA, double &rhoZ_overA,double &LnI, double &chi2c_factor, double &chi2a_factor, double &chi2a_factor2, unsigned int &last_index, double *s_to_boundary=NULL) const; jerror_t FindMatKalman(const DVector3 &pos, double &KrhoZ_overA, double &rhoZ_overA,double &LnI, double &chi2c_factor, double &chi2a_factor, double &chi2a_factor2, unsigned int &last_index) const; const DMaterialMap::MaterialNode* FindMatNode(DVector3 &pos) const; const DMaterialMap* FindDMaterialMap(DVector3 &pos) const; // Convenience methods const DMaterial* GetDMaterial(string name) const; bool GetFDCWires(vector >&fdcwires) const; bool GetFDCCathodes(vector >&fdccathodes) const; bool GetFDCZ(vector &z_wires) const; ///< z-locations for each of the FDC wire planes in cm bool GetFDCStereo(vector &stereo_angles) const; ///< stereo angles of each of the FDC wire layers bool GetFDCRmin(vector &rmin_packages) const; ///< beam hole size for each FDC package in cm bool GetFDCRmax(double &rmax_active_fdc) const; ///< outer radius of FDC active area in cm bool GetCDCWires(vector >&cdcwires) const; bool GetCDCOption(string &cdc_option) const; ///< get the centralDC_option-X string bool GetCDCCenterZ(double &cdc_center_z) const; ///< z-location of center of CDC wires in cm bool GetCDCAxialLength(double &cdc_axial_length) const; ///< length of CDC axial wires in cm bool GetCDCStereo(vector &cdc_stereo) const; ///< stereo angle for each CDC layer in degrees bool GetCDCRmid(vector &cdc_rmid) const; ///< Distance of the center of CDC wire from beamline for each layer in cm bool GetCDCNwires(vector &cdc_nwires) const; ///< Number of wires for each CDC layer bool GetCDCEndplate(double &z,double &dz,double &rmin,double &rmax) const; bool GetCDCAxialWires(unsigned int ring,unsigned int ncopy, double zcenter,double dz, vector >&cdc_offsets, vector &axialwires) const; bool GetCDCStereoWires(unsigned int ring,unsigned int ncopy, double zcenter, double dz, vector >&cdc_offsets, vector &stereowires) const; bool GetBCALRmin(double &bcal_rmin) const; ///< minimum distance of BCAL module from beam line bool GetBCALNmodules(unsigned int &bcal_nmodules) const; ///< Number of BCAL modules bool GetBCALCenterZ(double &bcal_center_z) const; ///< z-location of center of BCAL module in cm bool GetBCALLength(double &bcal_length) const; ///< length of BCAL module in cm bool GetBCALDepth(double &bcal_depth) const; ///< depth (or height) of BCAL module in cm bool GetBCALPhiShift(double &bcal_phi_shift) const; ///< phi angle in degrees that first BCAL module is shifted from being centered at ph=0.0 bool GetFCALZ(double &z_fcal) const; ///< z-location of front face of FCAL in cm bool GetTOFZ(vector &z_tof) const; ///< z-location of front face of each of TOF in cm bool GetTargetZ(double &z_target) const; ///< z-location og center of target bool GetTargetLength(double &target_length) const; ///< z-location of center of target bool GetStartCounterGeom(vector >&pos, vector >&norm) const; // < vectors containing positions and norm 3-vectors for start counter // There are 30 sets of positions (pos) of points along the // start counter, one set for each paddle, and a corresponding // set of norms at various points along the start counter. // For example, to access the most upstream point of paddle 1 // use pos[0][0]. The end of the barrel section before the // nose region is at pos[0][1]. The tip of the nose region // for this paddle is at pos[0][pos[0].size()-1]. The bend // region is modeled by many closely-spaced points starting // after pos[0][1]. vector GetMaterialMapVector(void) const; protected: DGeometry(){} void ReadMaterialMaps(void) const; void GetMaterials(void) const; bool GetCompositeMaterial(const string &name, double &density, double &radlen) const; private: JGeometry *jgeom; DApplication *dapp; mutable DMagneticFieldMap *bfield; unsigned int runnumber; mutable vector materials; /// Older implementation to keep track of material specs without ranges mutable vector materialmaps; /// Material maps generated automatically(indirectly) from XML with ranges and specs mutable bool materialmaps_read; mutable bool materials_read; mutable pthread_mutex_t bfield_mutex; mutable pthread_mutex_t materialmap_mutex; mutable pthread_mutex_t materials_mutex; }; #endif // _DGeometry_