// $Id$ // // File: DGeometry.cc // Created: Thu Apr 3 08:43:06 EDT 2008 // Creator: davidl (on Darwin swire-d95.jlab.org 8.11.1 i386) // #include "DGeometry.h" #include "DMaterialStepper.h" #include #include "FDC/DFDCWire.h" #include "FDC/DFDCGeometry.h" using namespace std; //--------------------------------- // DGeometry (Constructor) //--------------------------------- DGeometry::DGeometry(JGeometry *jgeom, DApplication *dapp) { this->jgeom = jgeom; this->dapp = dapp; } //--------------------------------- // ~DGeometry (Destructor) //--------------------------------- DGeometry::~DGeometry() { for(unsigned int i=0; iGetBfield(); } //--------------------------------- // GetLorentzDeflections //--------------------------------- DLorentzDeflections* DGeometry::GetLorentzDeflections(void) { return dapp->GetLorentzDeflections(); } //--------------------------------- // FindNodes //--------------------------------- void DGeometry::FindNodes(string xpath, vector &matched_xpaths) const { /// Find all nodes that match the specified xpath and return them as /// fully parsed lists of the nodes and attributes. /// /// The matched_xpaths variable has 4 levels of STL containers nested /// together! The node_t data type contains 2 of them and represents /// a single tag with the "first" member being the tag name /// and the "second" member being a map of all of the attributes /// of that tag along with their values. /// /// The xpathparsed_t data type is a STL vector of node_t objects /// that comprises a complete xpath. The data type of matched_xpaths /// is a STL vector if xpathparsed_t objects and so comprises a /// list of complete xpaths. /// We do this by calling the GetXPaths() method of JGeometry to get /// a list of all xpaths. Then we pass all of those in to /// JGeometryXML::ParseXPath() to get a parsed list for each. This /// is compared to the parsed values of the xpath passed to us /// (also parsed by JGeometryXML::ParseXPath()) to find matches. // Make sure matched_xpaths is empty matched_xpaths.clear(); // Cast JGeometry into a JGeometryXML JGeometryXML *jgeomxml = dynamic_cast(jgeom); // Parse our target xpath xpathparsed_t target; string unused_string; unsigned int unused_int; jgeomxml->ParseXPath(xpath, target, unused_string, unused_int); // Get all xpaths for current geometry source vector allxpaths; jgeom->GetXPaths(allxpaths, JGeometry::attr_level_all); // Loop over xpaths for(unsigned int i=0; iGetName() == name)return materials[i]; } //_DBG_<<"No material \""< xpaths; jgeom->GetXPaths(xpaths, JGeometry::attr_level_all, filter); // Look for xpaths that have "/materials[" in them for(unsigned int i=0; itoString(); } //=========== composites =========== filter = "//materials/composite[@name]"; // Get list of all xpaths jgeom->GetXPaths(xpaths, JGeometry::attr_level_all, filter); // Look for xpaths that have "/materials[" in them for(unsigned int i=0; itoString(); } } //--------------------------------- // GetCompositeMaterial //--------------------------------- bool DGeometry::GetCompositeMaterial(const string &name, double &density, double &radlen) { // Get list of all xpaths with "addmaterial" and "fractionmass" char filter[512]; sprintf(filter,"//materials/composite[@name='%s']/addmaterial/fractionmass[@fraction]", name.c_str()); vector xpaths; jgeom->GetXPaths(xpaths, JGeometry::attr_level_all, filter); // Loop over components of this composite _DBG_<<"Components for compsite "<origin.SetXYZ(x,y,z_wires[layer-1]); // Length of wire is set by active radius w->L = 2.0*sqrt(pow(FDC_ACTIVE_RADIUS,2.0) - u*u); // Set directions of wire's coordinate system with "udir" // along wire. w->udir.SetXYZ(sin(angle),cos(angle),0.0); // "s" points in direction from beamline to midpoint of // wire. This happens to be the same direction as "origin" w->sdir = w->origin; w->sdir.SetMag(1.0); w->tdir = w->udir.Cross(w->sdir); w->tdir.SetMag(1.0); // This isn't really needed temp.push_back(w); } fdcwires.push_back(temp); } return good; } //--------------------------------- // GetFDCZ //--------------------------------- bool DGeometry::GetFDCZ(vector &z_wires) const { // The FDC geometry is defined as 4 packages, each containing 2 // "module"s and each of those containing 3 "chambers". The modules // are placed as multiple copies in Z using mposZ, but none of the // others are (???). // // This method is currently hardwired to assume 4 packages and // 3 chambers. (The number of modules is discovered via the // "ncopy" attribute of mposZ.) vector ForwardDC; vector forwardDC; vector forwardDC_package[4]; map forwardDC_module[4]; vector forwardDC_chamber[4][3]; bool good = true; good |= Get("//section/composition/posXYZ[@volume='ForwardDC']/@X_Y_Z", ForwardDC); good |= Get("//composition[@name='ForwardDC']/posXYZ[@volume='forwardDC']/@X_Y_Z", forwardDC); good |= Get("//posXYZ[@volume='forwardDC_package_1']/@X_Y_Z", forwardDC_package[0]); good |= Get("//posXYZ[@volume='forwardDC_package_2']/@X_Y_Z", forwardDC_package[1]); good |= Get("//posXYZ[@volume='forwardDC_package_3']/@X_Y_Z", forwardDC_package[2]); good |= Get("//posXYZ[@volume='forwardDC_package_4']/@X_Y_Z", forwardDC_package[3]); good |= Get("//mposZ[@volume='forwardDC_module_1']", forwardDC_module[0]); good |= Get("//mposZ[@volume='forwardDC_module_2']", forwardDC_module[1]); good |= Get("//mposZ[@volume='forwardDC_module_3']", forwardDC_module[2]); good |= Get("//mposZ[@volume='forwardDC_module_4']", forwardDC_module[3]); good |= Get("//posXYZ[@volume='forwardDC_chamber_1']/@X_Y_Z/layer[@value='1']", forwardDC_chamber[0][0]); good |= Get("//posXYZ[@volume='forwardDC_chamber_1']/@X_Y_Z/layer[@value='2']", forwardDC_chamber[0][1]); good |= Get("//posXYZ[@volume='forwardDC_chamber_1']/@X_Y_Z/layer[@value='3']", forwardDC_chamber[0][2]); good |= Get("//posXYZ[@volume='forwardDC_chamber_2']/@X_Y_Z/layer[@value='1']", forwardDC_chamber[1][0]); good |= Get("//posXYZ[@volume='forwardDC_chamber_2']/@X_Y_Z/layer[@value='2']", forwardDC_chamber[1][1]); good |= Get("//posXYZ[@volume='forwardDC_chamber_2']/@X_Y_Z/layer[@value='3']", forwardDC_chamber[1][2]); good |= Get("//posXYZ[@volume='forwardDC_chamber_3']/@X_Y_Z/layer[@value='1']", forwardDC_chamber[2][0]); good |= Get("//posXYZ[@volume='forwardDC_chamber_3']/@X_Y_Z/layer[@value='2']", forwardDC_chamber[2][1]); good |= Get("//posXYZ[@volume='forwardDC_chamber_3']/@X_Y_Z/layer[@value='3']", forwardDC_chamber[2][2]); good |= Get("//posXYZ[@volume='forwardDC_chamber_4']/@X_Y_Z/layer[@value='1']", forwardDC_chamber[3][0]); good |= Get("//posXYZ[@volume='forwardDC_chamber_4']/@X_Y_Z/layer[@value='2']", forwardDC_chamber[3][1]); good |= Get("//posXYZ[@volume='forwardDC_chamber_4']/@X_Y_Z/layer[@value='3']", forwardDC_chamber[3][2]); if(!good){ _DBG_<<"Unable to retrieve ForwardDC positions."< &stereo_angles) const { // The FDC geometry is defined as 4 packages, each containing 2 // "module"s and each of those containing 3 "chambers". The modules // are placed as multiple copies in Z using mposZ, but none of the // others are (???). // // This method is currently hardwired to assume 4 packages and // 3 chambers. (The number of modules is discovered via the // "ncopy" attribute of mposZ.) // // Stereo angles are assumed to be rotated purely about the z-axis // and the units are not specified, but the XML currently uses degrees. map forwardDC_module[4]; vector forwardDC_chamber[4][3]; bool good = true; good |= Get("//mposZ[@volume='forwardDC_module_1']", forwardDC_module[0]); good |= Get("//mposZ[@volume='forwardDC_module_2']", forwardDC_module[1]); good |= Get("//mposZ[@volume='forwardDC_module_3']", forwardDC_module[2]); good |= Get("//mposZ[@volume='forwardDC_module_4']", forwardDC_module[3]); good |= Get("//posXYZ[@volume='forwardDC_chamber_1']/@rot/layer[@value='1']", forwardDC_chamber[0][0]); good |= Get("//posXYZ[@volume='forwardDC_chamber_1']/@rot/layer[@value='2']", forwardDC_chamber[0][1]); good |= Get("//posXYZ[@volume='forwardDC_chamber_1']/@rot/layer[@value='3']", forwardDC_chamber[0][2]); good |= Get("//posXYZ[@volume='forwardDC_chamber_2']/@rot/layer[@value='1']", forwardDC_chamber[1][0]); good |= Get("//posXYZ[@volume='forwardDC_chamber_2']/@rot/layer[@value='2']", forwardDC_chamber[1][1]); good |= Get("//posXYZ[@volume='forwardDC_chamber_2']/@rot/layer[@value='3']", forwardDC_chamber[1][2]); good |= Get("//posXYZ[@volume='forwardDC_chamber_3']/@rot/layer[@value='1']", forwardDC_chamber[2][0]); good |= Get("//posXYZ[@volume='forwardDC_chamber_3']/@rot/layer[@value='2']", forwardDC_chamber[2][1]); good |= Get("//posXYZ[@volume='forwardDC_chamber_3']/@rot/layer[@value='3']", forwardDC_chamber[2][2]); good |= Get("//posXYZ[@volume='forwardDC_chamber_4']/@rot/layer[@value='1']", forwardDC_chamber[3][0]); good |= Get("//posXYZ[@volume='forwardDC_chamber_4']/@rot/layer[@value='2']", forwardDC_chamber[3][1]); good |= Get("//posXYZ[@volume='forwardDC_chamber_4']/@rot/layer[@value='3']", forwardDC_chamber[3][2]); if(!good){ _DBG_<<"Unable to retrieve ForwardDC positions."< &rmin_packages) const { vector FDA[4]; bool good = true; good |= Get("//section[@name='ForwardDC']/tubs[@name='FDA1']/@Rio_Z", FDA[0]); good |= Get("//section[@name='ForwardDC']/tubs[@name='FDA2']/@Rio_Z", FDA[1]); good |= Get("//section[@name='ForwardDC']/tubs[@name='FDA3']/@Rio_Z", FDA[2]); good |= Get("//section[@name='ForwardDC']/tubs[@name='FDA4']/@Rio_Z", FDA[3]); if(!good){ _DBG_<<"Unable to retrieve FDC Rmin values."< FDA1; bool good = true; good |= Get("//section[@name='ForwardDC']/tubs[@name='FDA1']/@Rio_Z", FDA1); if(!good){ _DBG_<<"Unable to retrieve FDC Rmax values."< Rio_Z; bool good = Get("//section[@name='CentralDC']/tubs[@name='STRW']/@Rio_Z", Rio_Z); cdc_axial_length = Rio_Z[2]; if(!good){ _DBG_<<"Unable to retrieve CDC axial wire length"< &cdc_stereo) const { return false; } //--------------------------------- // GetCDCRmid //--------------------------------- bool DGeometry::GetCDCRmid(vector &cdc_rmid) const { return false; } //--------------------------------- // GetCDCNwires //--------------------------------- bool DGeometry::GetCDCNwires(vector &cdc_nwires) const { return false; } //--------------------------------- // GetCDCEndplate //--------------------------------- bool DGeometry::GetCDCEndplate(double &z,double &dz,double &rmin,double &rmax) const{ bool good = true; vectorcdc_origin; vectorcdc_center; vectorcdc_endplate_pos; vectorcdc_endplate_dim; good |= Get("//posXYZ[@volume='CentralDC'/@X_Y_Z",cdc_origin); good |= Get("//posXYZ[@volume='centralDC_option-1']/@X_Y_Z",cdc_center); good |= Get("//posXYZ[@volume='CDPD']/@X_Y_Z",cdc_endplate_pos); good |= Get("//tubs[@name='CDPD']/@Rio_Z",cdc_endplate_dim); if(!good){ _DBG_<<"Unable to retrieve CDC Endplate data."< ForwardEMcalpos; bool good = Get("//section/composition/posXYZ[@volume='ForwardEMcal']/@X_Y_Z", ForwardEMcalpos); if(!good){ _DBG_<<"Unable to retrieve ForwardEMcal position."< &z_tof) const { vector ForwardTOF; vector forwardTOF[2]; vector FTOC; bool good = true; good |= Get("//section/composition/posXYZ[@volume='ForwardTOF']/@X_Y_Z", ForwardTOF); good |= Get("//composition[@name='ForwardTOF']/posXYZ[@volume='forwardTOF']/@X_Y_Z/plane[@value='0']", forwardTOF[0]); good |= Get("//composition[@name='ForwardTOF']/posXYZ[@volume='forwardTOF']/@X_Y_Z/plane[@value='1']", forwardTOF[1]); good |= Get("//box[@name='FTOC' and sensitive='true']/@X_Y_Z", FTOC); z_tof.push_back(ForwardTOF[2] + forwardTOF[0][2] - FTOC[2]/2.0); z_tof.push_back(ForwardTOF[2] + forwardTOF[1][2] - FTOC[2]/2.0); return good; } //--------------------------------- // GetTargetZ //--------------------------------- bool DGeometry::GetTargetZ(double &z_target) const { return false; } //--------------------------------- // GetTargetLength //--------------------------------- bool DGeometry::GetTargetLength(double &target_length) const { return false; }