diff --git a/Detector/DetInterface/include/DetInterface/IGeomSvc.h b/Detector/DetInterface/include/DetInterface/IGeomSvc.h index d4f508b99779f44e6b30811f4296ac722d8cf9c8..51c26406a307d3e66724d207a730bbeca823c216 100644 --- a/Detector/DetInterface/include/DetInterface/IGeomSvc.h +++ b/Detector/DetInterface/include/DetInterface/IGeomSvc.h @@ -27,11 +27,6 @@ namespace dd4hep { class StructExtension; -namespace gear{ - class ZPlanarParametersImpl; - class GearParametersImpl; -} -class TMaterial; // class G4VUserDetectorConstruction; class GAUDI_API IGeomSvc : virtual public IService { @@ -49,16 +44,6 @@ public: // short cut to retrieve the Decoder according to the Readout name virtual Decoder* getDecoder(const std::string& readout_name) = 0; - // obsolete parameter format, will remove once StructExtension<> validated - virtual const gear::ZPlanarParametersImpl* getVXDParameters() = 0; - - virtual const dd4hep::rec::ZPlanarData* getVXDData() = 0; - virtual const dd4hep::rec::ConicalSupportData* getBeamPipeData() =0; - - virtual const std::map<std::string,double>& getDetParameters(std::string s) = 0; - virtual double getDetParameter(std::string set_name, std::string par_name) = 0; - virtual TMaterial* getMaterial(std::string s) = 0; - virtual ~IGeomSvc() {} }; diff --git a/Detector/GeomSvc/src/GeomSvc.cpp b/Detector/GeomSvc/src/GeomSvc.cpp index 54736e6c617c0e4c2591fd14817641751fe67f1e..f7ae4a2bd6c04f6f728e51a8c251e1cd9a31575e 100644 --- a/Detector/GeomSvc/src/GeomSvc.cpp +++ b/Detector/GeomSvc/src/GeomSvc.cpp @@ -22,7 +22,7 @@ DECLARE_COMPONENT(GeomSvc) GeomSvc::GeomSvc(const std::string& name, ISvcLocator* svc) -: base_class(name, svc), m_dd4hep_geo(nullptr), m_vxdData(nullptr), m_beamPipeData(nullptr){ +: base_class(name, svc), m_dd4hep_geo(nullptr){ } @@ -38,39 +38,12 @@ GeomSvc::initialize() { // if failed to load the compact, a runtime error will be thrown. m_dd4hep_geo->fromCompact(m_dd4hep_xmls.value()); - dd4hep::DetElement world = m_dd4hep_geo->world(); - //info() << world.type() << " " << world.path() << " " << world.placementPath() << endmsg; - const std::map<std::string, dd4hep::DetElement>& subs = world.children(); - for(std::map<std::string, dd4hep::DetElement>::const_iterator it=subs.begin();it!=subs.end();it++){ - dd4hep::DetElement sub = it->second; - info() << it->first << " " << sub.path() << " " << sub.placementPath() << endmsg; - if(it->first=="Tube"){ - dd4hep::Volume vol = sub.volume(); - dd4hep::Solid solid = vol.solid(); - //info() << " " << solid.type() << " " << solid.name() << endmsg; - const std::map<std::string, dd4hep::DetElement>& pipes = sub.children(); - for(std::map<std::string, dd4hep::DetElement>::const_iterator it=pipes.begin();it!=pipes.end();it++){ - dd4hep::DetElement pipe = it->second; - //info() << " " << it->first << " " << pipe.id() << " " << pipe.path() << " " << pipe.placementPath() << endmsg; - } - try{ - m_beamPipeData = sub.extension<dd4hep::rec::ConicalSupportData>(); - } - catch(std::runtime_error& e){ - info() << e.what() << " " << m_beamPipeData << endmsg; - } - } - if(it->first=="VXD"){ - sc = convertVXD(sub); - } - } return sc; } StatusCode GeomSvc::finalize() { StatusCode sc; - if(m_vxdParameters) delete m_vxdParameters; return sc; } @@ -119,484 +92,3 @@ GeomSvc::getDecoder(const std::string& readout_name) { return decoder; } - - -const std::map<std::string,double>& GeomSvc::getDetParameters(std::string name){ - if(m_detParameters.find(name)!=m_detParameters.end()) return m_detParameters[name]; - else{ - char message[200]; - sprintf(message,"GeomSvc has not the parameter set named %s", name.c_str()); - throw std::runtime_error(message); - } -} - -double GeomSvc::getDetParameter(std::string set_name, std::string par_name){ - std::map<std::string, std::map<std::string,double> >::iterator it=m_detParameters.find(set_name); - if(it!=m_detParameters.end()){ - if(it->second.find(par_name)!=it->second.end()) return it->second[par_name]; - } - char message[200]; - sprintf(message,"GeomSvc has not the parameter named %s in set %s", par_name.c_str(), set_name.c_str()); - throw std::runtime_error(message); -} - -StatusCode GeomSvc::convertVXD(dd4hep::DetElement& vxd){ - StatusCode sc; - //fucd: another method to obtain parameters, but not fully for KalDet - bool extensionDataValid = true; - try{ - m_vxdData = vxd.extension<dd4hep::rec::ZPlanarData>(); - } - catch(std::runtime_error& e){ - extensionDataValid = false; - info() << e.what() << " " << m_vxdData << endmsg; - } - - std::vector<helpLayer> helpSensitives; - std::vector<helpLayer> helpLadders; - std::vector<int> helpNumberLadders; - std::vector<double> helpPhi0; - int helpCount=0; - int type=0; - double shellInnerRadius, shellOuterRadius, shellHalfLength, gap, shellRadLength; - int nLadders=0; - double phi0=0; - helpLayer thisLadder; - double beryllium_ladder_block_length=0,end_electronics_half_z=0,side_band_electronics_width=0; - double rAlu, drAlu, rSty, drSty, dzSty, rInner, aluEndcapZ, aluHalfZ, alu_RadLen, Cryostat_dEdx; - double VXDSupportDensity, VXDSupportZeff, VXDSupportAeff, VXDSupportRadLen; - dd4hep::Volume vxd_vol = vxd.volume(); - for(int i=0;i<vxd_vol->GetNdaughters();i++){ - TGeoNode* daughter = vxd_vol->GetNode(i); - std::string nodeName = daughter->GetName(); - //info() << daughter->GetName() << endmsg; - if(nodeName=="VXD_support_assembly_0"){ - TGeoNode* shell = FindNode(daughter, "SupportShell"); - if(shell){ - const TGeoShape* shape_shell = shell->GetVolume()->GetShape(); - //fucd: IsA() method does not always work for TGeoTube, sometimes, strange? - //if(shape_shell->IsA()==TGeoTube::Class()){ - if(shape_shell->TestShapeBit(TGeoTube::kGeoTube)){ - const TGeoTube* tube = (const TGeoTube*) shape_shell; - shellInnerRadius = tube->GetRmin()*CLHEP::cm; - shellOuterRadius = tube->GetRmax()*CLHEP::cm; - shellHalfLength = tube->GetDz()*CLHEP::cm; - } - else{ - error() << shell->GetName() << " is not a TGeoTube! Shape bits = " << shape_shell->TestShapeBits(0xFFFFFFFF) << endmsg; - } - TGeoMaterial* mat = shell->GetMedium()->GetMaterial(); - shellRadLength = mat->GetRadLen()*CLHEP::cm; - } - TGeoNode* block = FindNode(daughter, "BerylliumAnnulusBlock"); - if(block){ - const TGeoShape* shape_block = block->GetVolume()->GetShape(); - if(shape_block->IsA()==TGeoBBox::Class()){ - const TGeoBBox* box = (const TGeoBBox*) shape_block; - beryllium_ladder_block_length = box->GetDY()*CLHEP::cm; - } - else{ - error() << block->GetName() << " is not a TGeoTube! Shape bits = " << shape_block->TestShapeBits(0xFFFFFFFF) << endmsg; - } - } - TGeoNode* skin = FindNode(daughter, "CryostatAluSkinBarrel"); - if(skin){ - const TGeoShape* shape_skin = skin->GetVolume()->GetShape(); - if(shape_skin->TestShapeBit(TGeoTube::kGeoTube)){ - const TGeoTube* tube = (const TGeoTube*) shape_skin; - rAlu = tube->GetRmin()*CLHEP::cm; - drAlu = tube->GetRmax()*CLHEP::cm - rAlu; - aluHalfZ = tube->GetDz()*CLHEP::cm; - //info() << rmin << "," << rmax << "," << zhalf << endmsg; - } - else{ - error() << skin->GetName() << " is not a TGeoTube! Shape bits = " << shape_skin->TestShapeBits(0xFFFFFFFF) << endmsg; - } - } - TGeoNode* foam = FindNode(daughter, "CryostatFoamBarrel"); - if(foam){ - const TGeoShape* shape_foam = foam->GetVolume()->GetShape(); - if(shape_foam->TestShapeBit(TGeoTube::kGeoTube)){ - const TGeoTube* tube = (const TGeoTube*) shape_foam; - rSty = tube->GetRmin()*CLHEP::cm; - drSty = tube->GetRmax()*CLHEP::cm - rSty; - dzSty = tube->GetDz()*CLHEP::cm; - //info() << rmin << "," << rmax << "," << zhalf << endmsg; - } - else{ - error() << foam->GetName() << " is not a TGeoTube! Shape bits = " << shape_foam->TestShapeBits(0xFFFFFFFF) << endmsg; - } - } - TGeoNode* skinEnd = FindNode(daughter, "CryostatAluSkinEndPlateInner"); - if(skinEnd){ - const TGeoShape* shape_skinEnd = skinEnd->GetVolume()->GetShape(); - if(shape_skinEnd->TestShapeBit(TGeoTube::kGeoTube)){ - const TGeoTube* tube = (const TGeoTube*) shape_skinEnd; - rInner = tube->GetRmin()*CLHEP::cm; - double rmax = tube->GetRmax()*CLHEP::cm; - drAlu = tube->GetDz()*CLHEP::cm*2; - //info() << rmin << "," << rmax << "," << zhalf << endmsg; - } - else{ - error() << skinEnd->GetName() << " is not a TGeoTube! Shape bits = " << shape_skinEnd->TestShapeBits(0xFFFFFFFF) << endmsg; - } - } - TGeoNode* shellEnd = FindNode(daughter, "EndPlateShell_outer"); - if(shellEnd){ - const TGeoShape* shape_shellEnd = shellEnd->GetVolume()->GetShape(); - if(shape_shellEnd->TestShapeBit(TGeoTube::kGeoTube)){ - const TGeoTube* tube = (const TGeoTube*) shape_shellEnd; - double rmin = tube->GetRmin()*CLHEP::cm; - double rmax = tube->GetRmax()*CLHEP::cm; - double zhalf = tube->GetDz()*CLHEP::cm; - //info() << rmin << "," << rmax << "," << zhalf << endmsg; - } - else{ - error() << shellEnd->GetName() << " is not a TGeoTube! Shape bits = " << shape_shellEnd->TestShapeBits(0xFFFFFFFF) << endmsg; - } - } - - } - else if(nodeName=="layer_assembly_0_1"){ - if(TGeoNode* side_band = FindNode(daughter, "ElectronicsBand")){ - const TGeoShape* shape_band = side_band->GetVolume()->GetShape(); - if(shape_band->IsA()==TGeoBBox::Class()){ - const TGeoBBox* box = (const TGeoBBox*) shape_band; - side_band_electronics_width = box->GetDX()*CLHEP::cm*2; - //info() << "fucd: "<< box->GetDX() << " " << box->GetDY() << " " << box->GetDZ() <<endmsg; - } - else{ - error() << "ElectronicsBand is not a TGeoBBox!!!"<< endmsg; - } - } - if(TGeoNode* end = FindNode(daughter, "ElectronicsEnd")){ - const TGeoShape* shape_end = end->GetVolume()->GetShape(); - if(shape_end->IsA()==TGeoBBox::Class()){ - const TGeoBBox* box = (const TGeoBBox*) shape_end; - end_electronics_half_z = box->GetDY()*CLHEP::cm; - //info() << "fucd: " << box->GetDX() << " " << box->GetDY() << " " << box->GetDZ() << endmsg; - } - else{ - error() << "ElectronicsEnd is not a TGeoBBox!!!"<< endmsg; - } - } - } - - /* - for(int j=0;j<daughter->GetNdaughters();j++){ - TGeoNode* next = daughter->GetDaughter(j); - info() << "fucd: " << next->GetName() << endmsg; - } - */ - } - - const std::map<std::string, dd4hep::DetElement>& components = vxd.children(); - for(std::map<std::string, dd4hep::DetElement>::const_iterator it=components.begin();it!=components.end();it++){ - dd4hep::DetElement component = it->second; - dd4hep::Volume vol = component.volume(); - dd4hep::PlacedVolume phys = component.placement(); - TGeoMaterial* mat = vol->GetMaterial(); - const TGeoShape* shape = vol->GetShape(); - const dd4hep::PlacedVolumeExtension::VolIDs& ids = phys.volIDs(); - //info() << " " << it->first << " " << vol->GetName() << " " << component.id() << " " << component.path() << " " << component.placementPath() << endmsg; - //info() << " " << shape->GetName() << " " << vol.solid().name() << endmsg; - //info() << " " << mat->GetName() << " " << mat->GetRadLen() << endmsg; - //info() << " " << ids.str() << endmsg; - //info() << " " << vol->GetNdaughters() << endmsg; - //double radL = mat->GetRadLen(); - //dd4hep::Solid solid = vol.solid(); - //info() << " " << sh->TestShapeBit(TGeoShape::kGeoBox) << " " << sh->GetName() << " " << phys.material().radLength() << endmsg; - if(vol.isSensitive()&&shape->IsA()==TGeoBBox::Class()){ - int iLayer = ids.find("layer")->second; - int iModule = ids.find("module")->second; - int iSide = ids.find("side")->second; - //info() << " layer=" << iLayer << " module=" << iModule << mat->GetName() << endmsg; - if(iModule==0&&iLayer==helpCount+1){ - helpCount++; - helpSensitives.push_back(thisLadder); - helpLadders.push_back(thisLadder); - helpNumberLadders.push_back(nLadders); - helpPhi0.push_back(phi0); - nLadders = 0; - thisLadder.length = 0; - } - if(iLayer == helpCount){ - if(iModule == 0){ - const TGeoBBox* box = (const TGeoBBox*) shape; - double width = box->GetDX()*CLHEP::cm; - double length = box->GetDY()*CLHEP::cm; - double thickness = box->GetDZ()*CLHEP::cm; - TGeoMatrix* matrix = phys->GetMatrix(); - const double* pos = matrix->GetTranslation(); - const double* rot_data = matrix->GetRotationMatrix(); - TGeoRotation rot; - rot.SetMatrix(rot_data); - double theta,phi,psi; - rot.GetAngles(phi,theta,psi); - phi *= TMath::DegToRad(); - theta *= TMath::DegToRad(); - psi *= TMath::DegToRad(); - phi0 = -TMath::PiOver2()+phi; - double distance = fabs(cos(phi0)*sin(theta)*pos[0]+sin(phi0)*sin(theta)*pos[1]+cos(theta)*pos[2]); - double offset = sqrt(pos[0]*pos[0]+pos[1]*pos[1]-distance*distance)*pos[0]/fabs(pos[0])*CLHEP::cm; - distance *= CLHEP::cm; - distance -= thickness; - double radL = mat->GetRadLen()*CLHEP::cm; - //info() << " -> " << helpCount << ": " << distance << " " << cos(atan2(pos[1],pos[0])-phi)*sqrt(pos[0]*pos[0]+pos[1]*pos[1]) << endmsg; - thisLadder.distance = distance; - thisLadder.offset = offset; - thisLadder.thickness = thickness; - thisLadder.length += length; - thisLadder.width = width; - thisLadder.radLength = radL; - thisLadder.z = pos[2]*CLHEP::cm; - } - if(iModule==nLadders) nLadders++; - } - } - //info() << " " << vol.solid().type() << " " << vol.solid().name() << " " << vol->GetNdaughters() << endmsg; - else if(it->first=="VXD_support"){ - helpCount++; - helpSensitives.push_back(thisLadder); - helpLadders.push_back(thisLadder); - helpNumberLadders.push_back(nLadders); - helpPhi0.push_back(phi0); - nLadders = 0; - if(vol->GetNdaughters()==0) error() << "!!!!!!!!!" << endmsg; - - int nFlexCable = 0, nFoamSpacer=0, nMetalTraces=0; - int currentLayer = -1; - double tFlexCable, tFoamSpacer, tMetalTraces; - double radLFlexCable, radLFoamSpacer, radLMetalTraces; - double intLFlexCable, intLFoamSpacer, intLMetalTraces; - double dFlexCable, dFoamSpacer, dMetalTraces; - double metalZeff, metalZAeff, foamZeff, foamZAeff, flexZeff, flexZAeff; - for(int i=0;i<vol->GetNdaughters();i++){ - TGeoNode* daughter = vol->GetNode(i); - TGeoMaterial* matDaughter = daughter->GetMedium()->GetMaterial(); - const TGeoShape* shape_sup = daughter->GetVolume()->GetShape(); - TGeoMatrix* matrix = daughter->GetMatrix(); - const double* pos = matrix->GetTranslation(); - const double* rot_data = matrix->GetRotationMatrix(); - TGeoRotation rot; - rot.SetMatrix(rot_data); - double theta,phi,psi; - rot.GetAngles(phi,theta,psi); - phi *= TMath::DegToRad(); - theta *= TMath::DegToRad(); - psi *= TMath::DegToRad(); - phi0 = -TMath::PiOver2()+phi; - std::string phy_name = daughter->GetName(); - if(phy_name.find("FoamSpacer")==-1&&phy_name.find("FlexCable")==-1&&phy_name.find("MetalTraces")==-1){ - //info() << phy_name <<endmsg; - continue; - } - int iLayer = atoi(phy_name.substr(phy_name.find("_")+1,2).c_str()); - if(iLayer!=currentLayer){ - //info() << tFoamSpacer << "," << tFlexCable << "," << tMetalTraces << endmsg; - helpLadders[currentLayer].thickness = tFoamSpacer+tFlexCable+tMetalTraces; - helpLadders[currentLayer].radLength = helpLadders[currentLayer].thickness / (tFoamSpacer/radLFoamSpacer+tFlexCable/radLFlexCable+tMetalTraces/radLMetalTraces); - nFlexCable = 0; - nFoamSpacer=0; - nMetalTraces=0; - currentLayer=iLayer; - } - //info() << "ss pos=" << pos[0] << "," << pos[1] << "," << pos[2] << " distance=" << sqrt(pos[0]*pos[0]+pos[1]*pos[1]) << endmsg; - //info() << "ss rot=" << phi << "," << theta << "," << psi << endmsg; - //info() << "ss " << daughter->GetName() << " " << daughter->GetVolume()->GetName() << " " << endmsg; - if(shape_sup->IsA()==TGeoBBox::Class()&&(nFoamSpacer==0||nFlexCable==0||nMetalTraces==0)){ - const TGeoBBox* box = (const TGeoBBox*) shape_sup; - //info() << phy_name.substr(phy_name.find("_")+1,2) << " " << iLayer << " " << box->GetDX() << "," << box->GetDY() << "," << box->GetDZ() << endmsg; - //info() << "fucd: pos " << pos[0] << " " << pos[1] << " " << pos[2] << endmsg; - double distance = fabs(cos(phi0)*sin(theta)*pos[0]+sin(phi0)*sin(theta)*pos[1]+cos(theta)*pos[2]); - double offset = sqrt(pos[0]*pos[0]+pos[1]*pos[1]-distance*distance)*pos[0]/fabs(pos[0])*CLHEP::cm; - distance -= box->GetDZ(); - distance *= CLHEP::cm; - if(helpLadders[iLayer].distance == helpSensitives[iLayer].distance) helpLadders[iLayer].distance = distance; - else helpLadders[iLayer].distance = TMath::Min(helpLadders[iLayer].distance, distance); - //info() << phy_name << " " << distance << " " << offset << endmsg; - if(phy_name.find("FoamSpacer")!=-1&&nFoamSpacer==0){ - helpLadders[iLayer].offset = offset; - tFoamSpacer = box->GetDZ()*CLHEP::cm; - radLFoamSpacer = matDaughter->GetRadLen()*CLHEP::cm; - intLFoamSpacer = matDaughter->GetIntLen()*CLHEP::cm; - dFoamSpacer = matDaughter->GetDensity()*CLHEP::g/CLHEP::cm3; - //fucd: A calculated by TGeoMaterial class is not equal to Zeff/ZAeff, Zeff = sum(Zi*Ai/sumA), ZAeff = sum(Zi/Ai*A/totalA) - // use Zeff and ZAeff to keep same with Mokka case - //foamZ = matDaughter->GetZ(); - //foamA = matDaughter->GetA(); - double totalA = 0, Zeff = 0, ZAeff = 0; - for(int iEle = 0; iEle<matDaughter->GetNelements(); iEle++){ - totalA += matDaughter->GetElement(iEle)->A(); - } - for(int iEle = 0; iEle<matDaughter->GetNelements(); iEle++){ - double A, Z, w; - // by fucd: w!=A/totalA, strange! to fix - matDaughter->GetElementProp(A,Z,w,iEle); - Zeff += Z*w; - ZAeff += Z/A*w; - //info() << std::setprecision(16) << Z << " " << A << " " << A/totalA << " " << w << endmsg; - } - foamZeff = Zeff; - foamZAeff = ZAeff; - nFoamSpacer++; - } - if(phy_name.find("FlexCable")!=-1&&nFlexCable==0){ - helpLadders[iLayer].width = box->GetDX()*CLHEP::cm; - helpLadders[iLayer].length = box->GetDY()*CLHEP::cm-beryllium_ladder_block_length*2-end_electronics_half_z*2; - tFlexCable = box->GetDZ()*CLHEP::cm; - radLFlexCable = matDaughter->GetRadLen()*CLHEP::cm; - intLFlexCable = matDaughter->GetIntLen()*CLHEP::cm; - dFlexCable = matDaughter->GetDensity()*CLHEP::g/CLHEP::cm3; - double Zeff = 0, ZAeff = 0; - for(int iEle = 0; iEle<matDaughter->GetNelements(); iEle++){ - double A, Z, w; - matDaughter->GetElementProp(A,Z,w,iEle); - Zeff += Z*w; - ZAeff += Z/A*w; - //std::cout << std::setprecision(16) << Z << " " << A << " " << w << std::endl; - } - flexZeff = Zeff; - flexZAeff = ZAeff; - nFlexCable++; - } - if(phy_name.find("MetalTraces")!=-1&&nMetalTraces==0){ - tMetalTraces = box->GetDZ()*CLHEP::cm; - radLMetalTraces = matDaughter->GetRadLen()*CLHEP::cm; - intLMetalTraces = matDaughter->GetIntLen()*CLHEP::cm; - dMetalTraces = matDaughter->GetDensity()*CLHEP::g/CLHEP::cm3; - double totalA = 0, Zeff = 0, ZAeff = 0; - for(int iEle = 0; iEle<matDaughter->GetNelements(); iEle++){ - totalA += matDaughter->GetElement(iEle)->A(); - } - for(int iEle = 0; iEle<matDaughter->GetNelements(); iEle++){ - double A, Z, w; - matDaughter->GetElementProp(A,Z,w,iEle); - Zeff += Z*w; - ZAeff += Z/A*w; - //info() << Z << " " << A << " " << w << endmsg; - } - metalZeff = Zeff; - metalZAeff = ZAeff; - nMetalTraces++; - } - } - } - { - //info() << tFoamSpacer << "," << tFlexCable << "," << tMetalTraces << endmsg; - double tSupport = tMetalTraces + tFoamSpacer + tFlexCable; - helpLadders[currentLayer].thickness = tSupport; - helpLadders[currentLayer].radLength = helpLadders[currentLayer].thickness / (tFoamSpacer/radLFoamSpacer+tFlexCable/radLFlexCable+tMetalTraces/radLMetalTraces); - nFlexCable = 0; - nFoamSpacer=0; - nMetalTraces=0; - - //calculations of thickness fractions of each layer of the support - double metalTF = tMetalTraces / tSupport; - double foamTF = tFoamSpacer / tSupport; - double flexTF = tFlexCable / tSupport; - //info() << foamTF << "," << flexTF << "," << metalTF << endmsg; - //info() << dFoamSpacer/(CLHEP::kg/CLHEP::cm3) << "," << dFlexCable/(CLHEP::kg/CLHEP::cm3) << "," << dMetalTraces/(CLHEP::kg/CLHEP::cm3) << endmsg; - //info() << foamZeff << " " << flexZeff << " " << metalZeff << endmsg; - //info() << foamZAeff << " " << flexZAeff << " " << metalZAeff << endmsg; - G4double elemVol = 1*CLHEP::cm3; - G4double VXDSupportMass = (foamTF*dFoamSpacer + flexTF*dFlexCable + metalTF*dMetalTraces)*elemVol; - VXDSupportDensity = VXDSupportMass/elemVol; - - G4double foamFM = 100. * ((foamTF*(elemVol)*dFoamSpacer) / VXDSupportMass) ; - G4double kaptonFM = 100. * ((flexTF*(elemVol)*dFlexCable) / VXDSupportMass) ; - G4double metalFM = 100. * ((metalTF*(elemVol)*dMetalTraces) / VXDSupportMass) ; - - VXDSupportRadLen = helpLadders[currentLayer].radLength; - - VXDSupportZeff = (metalFM/100.)*metalZeff + (kaptonFM/100.)*flexZeff + (foamFM/100.)*foamZeff; - G4double VXDSupportZAeff = (metalFM/100.)*metalZAeff + (kaptonFM/100.)*flexZAeff + (foamFM/100.)*foamZAeff; - VXDSupportAeff = VXDSupportZeff / VXDSupportZAeff; - G4double VXDSupportIntLength = 1. / ((metalTF/intLMetalTraces) + (flexTF/intLFlexCable) + (foamTF/intLFoamSpacer)); - VXDSupportDensity = 1000*VXDSupportDensity/(CLHEP::g/CLHEP::cm3); - //info() << "fucd: " << VXDSupportZeff << " " << VXDSupportAeff << " " << VXDSupportRadLen << " " << VXDSupportIntLength << " " << VXDSupportDensity << endmsg; - //info() << intLMetalTraces << " " << intLFlexCable << " " << intLFoamSpacer <<endmsg; - } - } - //info() << it->first << endmsg; - } - if(end_electronics_half_z>0 && side_band_electronics_width==0) type = gear::ZPlanarParametersImpl::CCD ; - if(side_band_electronics_width>0 && end_electronics_half_z==0 ) type = gear::ZPlanarParametersImpl::CMOS ; - if(side_band_electronics_width>0 && end_electronics_half_z>0) type = gear::ZPlanarParametersImpl::HYBRID ; - - m_vxdParameters = new gear::ZPlanarParametersImpl(type, shellInnerRadius, shellOuterRadius, shellHalfLength, gap, shellRadLength ); - // by fucd: debug info, if validated enough, merge them in future - info() << "=====================from convertor==============================" << endmsg; - info() << type << " " << shellInnerRadius << " " << shellOuterRadius << " " << shellHalfLength << " " << gap << " " << shellRadLength << endmsg; - for(int i=0;i<helpCount;i++){ - m_vxdParameters->addLayer(helpNumberLadders[i] , helpPhi0[i] , - helpLadders[i].distance , helpLadders[i].offset, helpLadders[i].thickness*2 , - helpLadders[i].length , helpLadders[i].width*2 , helpLadders[i].radLength , - helpSensitives[i].distance, helpSensitives[i].offset , helpSensitives[i].thickness*2 , - helpSensitives[i].length , helpSensitives[i].width*2 , helpSensitives[i].radLength ) ; - info() << "fucd " << i << ": " << helpNumberLadders[i] << ", " << helpPhi0[i] << ", " - << helpLadders[i].distance << ", " << helpLadders[i].offset << ", " << helpLadders[i].thickness*2 << ", " << helpLadders[i].length << ", " - << helpLadders[i].width*2 << ", " << helpLadders[i].radLength << ", " << helpSensitives[i].distance << ", " << helpSensitives[i].offset << ", " - << helpSensitives[i].thickness*2 << ", " << helpSensitives[i].length << ", " << helpSensitives[i].width*2 << ", " << helpSensitives[i].radLength << endmsg; - } - //m_vxdInfra = new gear::GearParametersImpl; - //CryostatAlRadius, CryostatAlThickness, CryostatAlInnerR, CryostatAlZEndCap, CryostatAlHalfZ - //m_vxdInfra->setDoubleVal("CryostatAlRadius",rAlu); - //m_vxdInfra->setDoubleVal("CryostatAlThickness",drAlu); - //m_vxdInfra->setDoubleVal("CryostatAlInnerR",rInner); - //m_vxdInfra->setDoubleVal("CryostatAlZEndCap",aluEndcapZ=dzSty + drSty + drAlu / 2); - //m_vxdInfra->setDoubleVal("CryostatAlHalfZ",aluHalfZ= dzSty + drSty); - // change GearParametersImpl to map - std::map<std::string,double> vxdInfra; - vxdInfra["CryostatAlRadius"] = rAlu; - vxdInfra["CryostatAlThickness"] = drAlu; - vxdInfra["CryostatAlInnerR"] = rInner; - vxdInfra["CryostatAlZEndCap"] = dzSty+drSty+drAlu/2; - vxdInfra["CryostatAlHalfZ"] = dzSty+drSty; - m_detParameters["VXDInfra"] = vxdInfra; - //effective A different with what in Mokka, fix them as Mokka's - //m_materials["VXDSupportMaterial"] = new TMaterial("VXDSupportMaterial", "", VXDSupportAeff, VXDSupportZeff, VXDSupportDensity, VXDSupportRadLen, 0.); - m_materials["VXDSupportMaterial"] = new TMaterial("VXDSupportMaterial", "", 2.075865162e+01, 1.039383117e+01, 2.765900000e+02/1000, 1.014262421e+02, 0.); - - info() << "=====================from ZPlanarData==============================" << endmsg; - if(m_vxdData){ - info() << m_vxdData->rInnerShell << " " << m_vxdData->rOuterShell << " " << m_vxdData->zHalfShell << " " << m_vxdData->gapShell << endmsg; - const std::vector<dd4hep::rec::ZPlanarData::LayerLayout>& layers = m_vxdData->layers; - for(int i=0;i<layers.size();i++){ - const dd4hep::rec::ZPlanarData::LayerLayout& thisLayer = layers[i]; - info() << i << ": " << thisLayer.ladderNumber << "," << thisLayer.phi0 << "," << thisLayer.distanceSupport << "," << thisLayer.offsetSupport << "," - << thisLayer.thicknessSupport << "," << thisLayer.zHalfSupport << "," << thisLayer.widthSupport << "," << "NULL," - << thisLayer.distanceSensitive << "," << thisLayer.offsetSensitive << "," << thisLayer.thicknessSensitive << "," << thisLayer.zHalfSensitive << "," - << thisLayer.widthSensitive << ",NULL" << endmsg; - } - } - info() << rAlu << " " << drAlu << " " << rInner << " " << aluEndcapZ << " " << aluHalfZ << endmsg; - //info() << m_materials["VXDSupportMaterial"] << endmsg; - return sc; -} - -TGeoNode* GeomSvc::FindNode(TGeoNode* mother, char* name){ - TGeoNode* next = 0; - if(mother->GetNdaughters()!=0){ - for(int i=0;i<mother->GetNdaughters();i++){ - TGeoNode* daughter = mother->GetDaughter(i); - std::string s = daughter->GetName(); - //info() << "current: " << s << " search for" << name << endmsg; - if(s.find(name)!=-1){ - next = daughter; - break; - } - else{ - next = FindNode(daughter, name); - } - } - } - return next; -} - -TMaterial* GeomSvc::getMaterial(std::string name){ - std::map<std::string, TMaterial*>::const_iterator it = m_materials.find(name); - if(it!=m_materials.end()) return it->second; - else return 0; - -} diff --git a/Detector/GeomSvc/src/GeomSvc.h b/Detector/GeomSvc/src/GeomSvc.h index 4ef39d2f0644c25b666145d4ee4a5caffd8420e1..119e2ea5870db041ad48bf4bf0175af290af51cd 100644 --- a/Detector/GeomSvc/src/GeomSvc.h +++ b/Detector/GeomSvc/src/GeomSvc.h @@ -34,45 +34,15 @@ class GeomSvc: public extends<Service, IGeomSvc> { dd4hep::DetElement getDD4HepGeo() override; dd4hep::Detector* lcdd() override; - const gear::ZPlanarParametersImpl* getVXDParameters() override {return m_vxdParameters;}; - const dd4hep::rec::ZPlanarData* getVXDData() override {return m_vxdData;}; - const dd4hep::rec::ConicalSupportData* getBeamPipeData() override {return m_beamPipeData;}; - - const std::map<std::string,double>& getDetParameters(std::string name) override; - double getDetParameter(std::string set_name, std::string par_name) override; - TMaterial* getMaterial(std::string name); - private: - StatusCode convertVXD(dd4hep::DetElement& sub); - - Decoder* getDecoder(const std::string& readout_name) override; - + Decoder* getDecoder(const std::string& readout_name) override; + private: - TGeoNode* FindNode(TGeoNode* mother, char* name); // DD4hep XML compact file path Gaudi::Property<std::string> m_dd4hep_xmls{this, "compact"}; // dd4hep::Detector* m_dd4hep_geo; - - - gear::ZPlanarParametersImpl* m_vxdParameters{nullptr}; - dd4hep::rec::ZPlanarData* m_vxdData{nullptr}; - dd4hep::rec::ConicalSupportData* m_beamPipeData{nullptr}; - - //gear::GearParametersImpl* m_vxdInfra; - std::map<std::string, std::map<std::string,double> > m_detParameters; - std::map<std::string, TMaterial*> m_materials; - struct helpLayer { - double distance =0; - double offset =0; - double thickness =0; - double length =0; - double width =0; - double radLength =0; - double z =0; - double foam_spacer_radLength =0; - }; }; #endif // GeomSvc_h diff --git a/Utilities/KalDet/src/ild/common/MaterialDataBase.cc b/Utilities/KalDet/src/ild/common/MaterialDataBase.cc index a6b8f6e63488dd7026ad2a2f958ecf8292374966..f181b8b53de84a990f3b4351d455241e0a344bf8 100644 --- a/Utilities/KalDet/src/ild/common/MaterialDataBase.cc +++ b/Utilities/KalDet/src/ild/common/MaterialDataBase.cc @@ -205,9 +205,12 @@ void MaterialDataBase::createMaterials(const gear::GearMgr& gearMgr, IGeomSvc* g // VXD Support Material if(geoSvc){ - TMaterial* vxdsupport = geoSvc->getMaterial("VXDSupportMaterial"); - if(vxdsupport) this->addMaterial(vxdsupport, "VXDSupportMaterial"); - else std::cout << "Material VXDSupportMaterial not found" << std::endl; + //obselete + //TMaterial* vxdsupport = geoSvc->getMaterial("VXDSupportMaterial"); + //if(vxdsupport) this->addMaterial(vxdsupport, "VXDSupportMaterial"); + //else std::cout << "Material VXDSupportMaterial not found" << std::endl; + std::cout << "geoSvc should be set as NULL before new GeomSvc interface ready!" << std::endl; + exit(1); } else{ try{ diff --git a/Utilities/KalDet/src/ild/support/ILDSupportKalDetector.cc b/Utilities/KalDet/src/ild/support/ILDSupportKalDetector.cc index fe92415eb745cdfcbf883be2fd2c9ac3dc878bdb..64dd65463d1cf178c0c85e7d87bd079390591e21 100644 --- a/Utilities/KalDet/src/ild/support/ILDSupportKalDetector.cc +++ b/Utilities/KalDet/src/ild/support/ILDSupportKalDetector.cc @@ -35,7 +35,22 @@ TVKalDetector(10) std::vector<double> z, rInner, rOuter; // streamlog_out(DEBUG1) << "ILDSupportKalDetector building beampipe using GEAR " << std::endl ; if(geoSvc){ - const dd4hep::rec::ConicalSupportData* pBeamPipeData = geoSvc->getBeamPipeData(); + dd4hep::DetElement world = geoSvc->getDD4HepGeo(); + dd4hep::DetElement pipe; + const std::map<std::string, dd4hep::DetElement>& subs = world.children(); + for(std::map<std::string, dd4hep::DetElement>::const_iterator it=subs.begin();it!=subs.end();it++){ + if(it->first!="Tube") continue; + pipe = it->second; + } + dd4hep::rec::ConicalSupportData* pBeamPipeData = nullptr; + try{ + pBeamPipeData = pipe.extension<dd4hep::rec::ConicalSupportData>(); + } + catch(std::runtime_error& e){ + std::cout << e.what() << " " << pBeamPipeData << std::endl; + std::cerr << "Cannot find extension data in Beampipe!" << std::endl; + } + const std::vector<dd4hep::rec::ConicalSupportData::Section>& sections = pBeamPipeData->sections; const dd4hep::Direction& field = geoSvc->lcdd()->field().magneticField(dd4hep::Position(0,0,0)); bz = field.z()/dd4hep::tesla; diff --git a/Utilities/KalDet/src/ild/vxd/ILDVXDKalDetector.cc b/Utilities/KalDet/src/ild/vxd/ILDVXDKalDetector.cc index 5cacd3d76205a515295102ec6c6f865bd24776a4..3043a7f392acd79700a441c826b3cbd3f5f32522 100644 --- a/Utilities/KalDet/src/ild/vxd/ILDVXDKalDetector.cc +++ b/Utilities/KalDet/src/ild/vxd/ILDVXDKalDetector.cc @@ -382,7 +382,6 @@ void ILDVXDKalDetector::setupGearGeom( const gear::GearMgr& gearMgr ){ void ILDVXDKalDetector::setupGearGeom( IGeomSvc* geoSvc){ - /* dd4hep::DetElement world = geoSvc->getDD4HepGeo(); dd4hep::DetElement vxd; const std::map<std::string, dd4hep::DetElement>& subs = world.children(); @@ -398,14 +397,13 @@ void ILDVXDKalDetector::setupGearGeom( IGeomSvc* geoSvc){ std::cout << e.what() << " " << vxdData << std::endl; throw GaudiException(e.what(), "FATAL", StatusCode::FAILURE); } - */ + const dd4hep::Direction& field = geoSvc->lcdd()->field().magneticField(dd4hep::Position(0,0,0)); _bZ = field.z()/dd4hep::tesla; + + const std::vector<dd4hep::rec::ZPlanarData::LayerLayout>& layers = vxdData->layers; - const gear::ZPlanarParametersImpl* pVXDDetMain = geoSvc->getVXDParameters(); - const gear::VXDLayerLayout& pVXDLayerLayout = pVXDDetMain->getVXDLayerLayout(); - - _nLayers = pVXDLayerLayout.getNLayers(); + _nLayers = layers.size(); _VXDgeo.resize(_nLayers); //SJA:FIXME: for now the support is taken as the same size the sensitive @@ -414,16 +412,17 @@ void ILDVXDKalDetector::setupGearGeom( IGeomSvc* geoSvc){ // for a significant distance for( int layer=0; layer < _nLayers; ++layer){ - _VXDgeo[layer].nLadders = pVXDLayerLayout.getNLadders(layer); - _VXDgeo[layer].phi0 = pVXDLayerLayout.getPhi0(layer); + const dd4hep::rec::ZPlanarData::LayerLayout& thisLayer = layers[layer]; + _VXDgeo[layer].nLadders = thisLayer.ladderNumber; + _VXDgeo[layer].phi0 = thisLayer.phi0; _VXDgeo[layer].dphi = 2*M_PI / _VXDgeo[layer].nLadders; - _VXDgeo[layer].senRMin = pVXDLayerLayout.getSensitiveDistance(layer); - _VXDgeo[layer].supRMin = pVXDLayerLayout.getLadderDistance(layer); - _VXDgeo[layer].length = pVXDLayerLayout.getSensitiveLength(layer) * 2.0 ; // note: gear for historical reasons uses the halflength - _VXDgeo[layer].width = pVXDLayerLayout.getSensitiveWidth(layer); - _VXDgeo[layer].offset = pVXDLayerLayout.getSensitiveOffset(layer); - _VXDgeo[layer].senThickness = pVXDLayerLayout.getSensitiveThickness(layer); - _VXDgeo[layer].supThickness = pVXDLayerLayout.getLadderThickness(layer); + _VXDgeo[layer].senRMin = thisLayer.distanceSensitive; + _VXDgeo[layer].supRMin = thisLayer.distanceSupport; + _VXDgeo[layer].length = thisLayer.zHalfSensitive * 2.0 ; // note: gear for historical reasons uses the halflength + _VXDgeo[layer].width = thisLayer.widthSensitive; + _VXDgeo[layer].offset = thisLayer.offsetSensitive; + _VXDgeo[layer].senThickness = thisLayer.thicknessSensitive; + _VXDgeo[layer].supThickness = thisLayer.thicknessSupport; //std::cout << layer << ": " << _VXDgeo[layer].nLadders << " " << _VXDgeo[layer].phi0 << " " << _VXDgeo[layer].dphi << " " << _VXDgeo[layer].senRMin // << " " << _VXDgeo[layer].supRMin << " " << _VXDgeo[layer].length << " " << _VXDgeo[layer].width << " " << _VXDgeo[layer].offset // << " " << _VXDgeo[layer].senThickness << " " << _VXDgeo[layer].supThickness << std::endl; @@ -432,26 +431,20 @@ void ILDVXDKalDetector::setupGearGeom( IGeomSvc* geoSvc){ // layer, this can optionally be changed, e.g. in the case of the FPCCD where the // epitaxial layer is 15 mu thick (in a 50 mu wafer) _relative_position_of_measurement_surface = 0.5 ; + // Cryostat - try { - _vxd_Cryostat.alRadius = geoSvc->getDetParameter("VXDInfra","CryostatAlRadius"); - _vxd_Cryostat.alThickness = geoSvc->getDetParameter("VXDInfra","CryostatAlThickness"); - _vxd_Cryostat.alInnerR = geoSvc->getDetParameter("VXDInfra","CryostatAlInnerR"); - _vxd_Cryostat.alZEndCap = geoSvc->getDetParameter("VXDInfra","CryostatAlZEndCap"); - _vxd_Cryostat.alHalfZ = geoSvc->getDetParameter("VXDInfra","CryostatAlHalfZ"); + // FIXME not support by ZPlanarData, not install in current CEPC + //_vxd_Cryostat.shellInnerR = vxdData->rInnerShell; + //_vxd_Cryostat.shellThickness = vxdData->rOuterShell; + //_vxd_Cryostat.shelllHalfZ = vxdData->zHalfShell; + //_vxd_Cryostat.alRadius = geoSvc->getDetParameter("VXDInfra","CryostatAlRadius"); + //_vxd_Cryostat.alThickness = geoSvc->getDetParameter("VXDInfra","CryostatAlThickness"); + //_vxd_Cryostat.alInnerR = geoSvc->getDetParameter("VXDInfra","CryostatAlInnerR"); + //_vxd_Cryostat.alZEndCap = geoSvc->getDetParameter("VXDInfra","CryostatAlZEndCap"); + //_vxd_Cryostat.alHalfZ = geoSvc->getDetParameter("VXDInfra","CryostatAlHalfZ"); + _vxd_Cryostat.exists = false; - _vxd_Cryostat.shellInnerR = pVXDDetMain->getShellInnerRadius(); - _vxd_Cryostat.shellThickness = pVXDDetMain->getShellOuterRadius() - _vxd_Cryostat.shellInnerR; - _vxd_Cryostat.shelllHalfZ = pVXDDetMain->getShellHalfLength(); - - _vxd_Cryostat.exists = true; - //std::cout << "VXDInfra: " << _vxd_Cryostat.alRadius << " " << _vxd_Cryostat.alThickness << " " << _vxd_Cryostat.alInnerR << " " << _vxd_Cryostat.alZEndCap << " " - // << _vxd_Cryostat.alHalfZ << " " << _vxd_Cryostat.shellInnerR << " " << _vxd_Cryostat.shellThickness << " " << _vxd_Cryostat.shelllHalfZ << std::endl; - } - catch (std::runtime_error& e) { - std::cout << e.what() << std::endl ; - _vxd_Cryostat.exists = false; - - } + //std::cout << "VXDInfra: " << _vxd_Cryostat.alRadius << " " << _vxd_Cryostat.alThickness << " " << _vxd_Cryostat.alInnerR << " " << _vxd_Cryostat.alZEndCap << " " + // << _vxd_Cryostat.alHalfZ << " " << _vxd_Cryostat.shellInnerR << " " << _vxd_Cryostat.shellThickness << " " << _vxd_Cryostat.shelllHalfZ << std::endl; }