Commit ba522b90 authored by Sabine Elles's avatar Sabine Elles Committed by Graeme Stewart
Browse files

Add PIXB4 alignment channel (PixelGeoModel-00-09-42)

	* Fix missing alignment channel
	* Tag as PixelGeoModel-00-09-42

2014-11-19 Sabine Elles <elles@lapp.in2p3.fr>
	* Fix coverity warning
	* Tag as PixelGeoModel-00-09-41

2014-11-05 Sabine Elles <elles@lapp.in2p3.fr>
	* Fix phi angle of stave 0 value
	* Tas as PixelGeoModel-00-09-40

2014-09-19 Matthew Klein <matthew.henry.klein@cern.ch>
	* No longer disables alignable by default
	* Tag as PixelGeoModel-00-09-39
parent 95ebdab3
......@@ -32,10 +32,6 @@ class DBM_Det : public GeoVPixelFactory {
/** member variables for algorithm properties: */
// int/double/bool m_propertyName;
std::vector<double> m_module[4];
unsigned int m_moduleon;
bool m_dbmon;
bool m_BDparameters;
};
#endif
......@@ -26,7 +26,7 @@ class GeoPixelLadder : public GeoVPixelFactory {
double calcThickness();
double calcWidth();
const GeoLogVol* theLadder;
const GeoLogVol* m_theLadder;
GeoPixelSiCrystal& m_theSensor;
GeoPixelStaveSupport * m_staveSupport;
double m_thickness;
......
......@@ -86,6 +86,7 @@ class GeoPixelBarrel : public GeoVPixelFactory {
class GeoPixelCable : public GeoVPixelFactory {
public:
GeoPixelCable():m_moduleNumber(0){}
virtual GeoVPhysVol* Build();
double Thickness();
double Length();
......@@ -98,8 +99,6 @@ class GeoPixelCable : public GeoVPixelFactory {
int m_moduleNumber;
};
#endif
#ifndef GEOPIXELCHIP_H
#define GEOPIXELCHIP_H
......
......@@ -11,7 +11,7 @@
#include <sstream>
GeoPixelCable::GeoPixelCable()
: m_currentElement(-1)
: m_currentElement(-1)
{
fillElements(gmt_mgr->GetLD(), gmt_mgr->Phi());
if (m_elements.empty()) { // If no information for layer use layer 0 numbers.
......
......@@ -168,9 +168,9 @@ GeoVPhysVol* GeoPixelDetailedStaveSupport::Build() {
double WingWidth = gmt_mgr->IBLStaveFlexWingWidth();
double WingThick = gmt_mgr->IBLStaveFlexWingThick();
bool bFlexAndWing = gmt_mgr->IBLFlexAndWingDefined();
// bFlexAndWing=false;
bool bFlexConstantThickness = bFlexAndWing;
bool bFlexConstantThickness = true;
if(!bFlexAndWing) bFlexConstantThickness = false;
double layerRadius = gmt_mgr->PixelLayerRadius();
......
......@@ -117,12 +117,16 @@ GeoVPhysVol* GeoPixelDisk::Build( ) {
// Even modules (front of disk, delta z < 0)
// and Odd modules (back of disk, delta z > 0)
for (int ii = 0; ii < gmt_mgr->PixelECNSectors1()*2; ii++) {
int pixelECNSectors1 = gmt_mgr->PixelECNSectors1();
for (int ii = 0; ii < pixelECNSectors1*2; ii++) {
// Build both endcaps the same but re-number phiId in endcap C to get correct offline numbering.
// Endcap C is obtained by rotating endcap A by 180 around y axis. Numbering goes in opposite direction
// with module 0 becoming module 23. Mapping is 0<->23, 24<->47.
int phiId = (gmt_mgr->GetSide()>0) ? ii : (3*gmt_mgr->PixelECNSectors1()-ii-1)%(gmt_mgr->PixelECNSectors1()*2);
// Add a test to get rid off division by zero coverity error
int phiId = 0;
if(pixelECNSectors1>0) phiId = (gmt_mgr->GetSide()>0) ? ii : (3*pixelECNSectors1-ii-1)%(pixelECNSectors1*2);
gmt_mgr->SetPhi(phiId);
......
......@@ -30,6 +30,7 @@ GeoPixelDiskSupports::GeoPixelDiskSupports() {
_halflength.push_back(halflength);
_typeNum.push_back(matTypeNum);
}
_nframe = 0;
}
......
......@@ -262,7 +262,7 @@ GeoVPhysVol* GeoPixelEnvelope::Build( ) {
}
}
delete pixServices;
if(pixServices) delete pixServices;
return envelopePhys;
......
......@@ -33,6 +33,9 @@ void GeoPixelFrame::BuildAndPlace(GeoFullPhysVol * parent, int section)
int numSides = gmt_mgr->PixelFrameNumSides(section);
bool mirrorSides = gmt_mgr->PixelFrameMirrorSides(section);
// No frame defined in the DB table
if(numSides==0)return;
double midRadius = 0.5*(rminSide+rmaxSide);
double zCenter = 0.5*(zmin+zmax);
......
......@@ -21,7 +21,12 @@
#include <algorithm>
using std::max;
GeoPixelIFlexServices::GeoPixelIFlexServices(int iSection): m_section(iSection)
GeoPixelIFlexServices::GeoPixelIFlexServices(int iSection):
m_section(iSection),
m_supportPhysA(0),
m_supportPhysC(0),
m_xformSupportA(0),
m_xformSupportC(0)
{
}
......@@ -35,7 +40,9 @@ GeoVPhysVol* GeoPixelIFlexServices::Build()
double barrelZmax = gmt_mgr->PixelBarrelHalfLength();
int nSectors = gmt_mgr->NPixelSectors();
double angle=360./nSectors*CLHEP::deg;
// check if sectors are properly defined
if(nSectors==0) return 0;
double angle=360./(double)nSectors*CLHEP::deg;
double zmin=0., zmax=0.;
if(m_section==0) {
......@@ -58,6 +65,7 @@ GeoVPhysVol* GeoPixelIFlexServices::Build()
double innerRadius = gmt_mgr->IBLServiceGetMaxRadialPosition("IPT","simple",zmin,zmax)+safety;
double outerRadius = gmt_mgr->IBLServiceGetMinRadialPosition("IST","simple",zmin,zmax)-safety;
double phiOfModuleZero = gmt_mgr->PhiOfModuleZero();
// Define IFlex section for side A
......@@ -165,7 +173,7 @@ GeoVPhysVol* GeoPixelIFlexServices::Build()
gmt_mgr->SetPhi(ii);
// cooling transform
double phiOfCooling = cooling_angle + ii*angle;
double phiOfCooling = phiOfModuleZero+ cooling_angle + ii*angle;
std::ostringstream tmp1;
tmp1 << "fl" << ii;
GeoNameTag * tag1 = new GeoNameTag(tmp1.str());
......@@ -180,7 +188,7 @@ GeoVPhysVol* GeoPixelIFlexServices::Build()
// flex transform
double phiOfFlex = flex_angle + ii*angle;
double phiOfFlex = phiOfModuleZero+ flex_angle + ii*angle;
std::ostringstream tmp2;
tmp2 << "fl" << ii;
GeoNameTag * tag2 = new GeoNameTag(tmp2.str());
......@@ -224,8 +232,6 @@ GeoVPhysVol* GeoPixelIFlexServices::Build()
HepGeom::Transform3D supportTrfC = HepGeom::TranslateZ3D(-(zmin+zmax)*0.5);
m_xformSupportC = new GeoTransform(supportTrfC);
return 0;
}
......@@ -25,6 +25,7 @@ using std::max;
GeoPixelLadder::GeoPixelLadder(GeoPixelSiCrystal& theSensor,
GeoPixelStaveSupport* staveSupport) :
m_theLadder(0),
m_theSensor(theSensor),
m_staveSupport(staveSupport)
{
......@@ -70,15 +71,19 @@ GeoPixelLadder::GeoPixelLadder(GeoPixelSiCrystal& theSensor,
const GeoShape & shiftedBox = (*box) << HepGeom::TranslateX3D(shift);
ladderShape = &shiftedBox;
}
else
else if(m_staveSupport)
{
GeoSimplePolygonBrep* staveSupportShape=m_staveSupport->computeStaveEnvelopShape(safety);
const GeoShape & staveShape = (*staveSupportShape);
ladderShape = &staveShape;
}
else
{
gmt_mgr->msg(MSG::ERROR)<<"No ladder shape could be defined "<<endreq;
}
const GeoMaterial* air = mat_mgr->getMaterial("std::Air");
theLadder = new GeoLogVol("Ladder",ladderShape,air);
m_theLadder = new GeoLogVol("Ladder",ladderShape,air);
m_thickness = 2*std::max(m_thicknessN,m_thicknessP);
}
......@@ -113,7 +118,11 @@ GeoPixelLadder::GeoPixelLadder(GeoPixelSiCrystal& theSensor,
GeoVPhysVol* GeoPixelLadder::Build( ) {
GeoPhysVol* ladderPhys = new GeoPhysVol(theLadder);
// Something went wrong while building the ladder logical volume
if(!m_theLadder) return 0;
// Create the ladder physVolume
GeoPhysVol* ladderPhys = new GeoPhysVol(m_theLadder);
//
// Place the Modules
//
......
......@@ -36,6 +36,9 @@ GeoPixelLayer::GeoPixelLayer(){
m_supportPhysA=0;
m_supportPhysC=0;
m_supportMidRing=0;
m_xformSupportA=0;
m_xformSupportC=0;
m_xformSupportMidRing=0;
}
GeoVPhysVol* GeoPixelLayer::Build() {
......@@ -82,6 +85,12 @@ GeoVPhysVol* GeoPixelLayer::Build() {
}
if(!staveSupport)
{
gmt_mgr->msg(MSG::ERROR)<<"No stave support corresponding to the staveLayout "<<staveLayout<<" could be defined "<<endreq;
return 0;
}
gmt_mgr->msg(MSG::INFO)<<"*** LAYER "<<gmt_mgr->GetLD()<<" planar/3D modules : "<< staveSupport->PixelNPlanarModule()<<" "<<staveSupport->PixelN3DModule()<<endreq;
......@@ -227,42 +236,49 @@ GeoVPhysVol* GeoPixelLayer::Build() {
//
// Calculate layerThicknessP: Thickness from layer radius to max radius of envelope
//
// We need the dimensions of the GeoPixelLadderServices. They are all the same in this regards
// so any of them will do - use the first one.
HepGeom::Point3D<double> corner1 = firstLadderServices->envelopeCornerC1();
HepGeom::Point3D<double> corner2 = firstLadderServices->envelopeCornerC2();
HepGeom::Point3D<double> corner3 = firstLadderServices->envelopeCornerA1();
HepGeom::Point3D<double> corner4 = firstLadderServices->envelopeCornerA2();
// translate relative to sensor center (center of tilt rotation),
// then tilt then translate by radius of layer, then calculate r.
double xLadderServicesOffset = gmt_mgr->PixelLadderServicesX();
double yLadderServicesOffset = gmt_mgr->PixelLadderServicesY();
// xCenter, yCenter or coordinates of ladder services relative to active layer center (center of tilt rotation)
double xCenter = (firstLadderServices->referenceX() + xLadderServicesOffset);
double yCenter = (firstLadderServices->referenceY() + yLadderServicesOffset);
HepGeom::Transform3D ladderSvcToglobal = HepGeom::TranslateX3D(layerRadius)
* HepGeom::RotateZ3D(ladderTilt)
* HepGeom::Translate3D(xCenter, yCenter, 0);
HepGeom::Point3D<double> corner1global = ladderSvcToglobal * corner1;
HepGeom::Point3D<double> corner2global = ladderSvcToglobal * corner2;
HepGeom::Point3D<double> corner3global = ladderSvcToglobal * corner3;
HepGeom::Point3D<double> corner4global = ladderSvcToglobal * corner4;
double rMaxTmp = std::max(corner1global.perp(),
std::max(corner2global.perp(),
std::max(corner3global.perp(), corner4global.perp())));
// Thickness from layer radius to max radius of envelope
layerThicknessP = std::max(layerThicknessP, rMaxTmp - gmt_mgr->PixelLayerRadius());
//std::cout << rMaxTmp << std::endl;
//std::cout << layerThicknessP<< " "<<layerThicknessN <<std::endl;
// No longer needed
delete firstLadderServices;
double xCenter = 0.;
double yCenter = 0.;
if(firstLadderServices){
// We need the dimensions of the GeoPixelLadderServices. They are all the same in this regards
// so any of them will do - use the first one.
HepGeom::Point3D<double> corner1 = firstLadderServices->envelopeCornerC1();
HepGeom::Point3D<double> corner2 = firstLadderServices->envelopeCornerC2();
HepGeom::Point3D<double> corner3 = firstLadderServices->envelopeCornerA1();
HepGeom::Point3D<double> corner4 = firstLadderServices->envelopeCornerA2();
// translate relative to sensor center (center of tilt rotation),
// then tilt then translate by radius of layer, then calculate r.
double xLadderServicesOffset = gmt_mgr->PixelLadderServicesX();
double yLadderServicesOffset = gmt_mgr->PixelLadderServicesY();
// xCenter, yCenter or coordinates of ladder services relative to active layer center (center of tilt rotation)
xCenter = (firstLadderServices->referenceX() + xLadderServicesOffset);
yCenter = (firstLadderServices->referenceY() + yLadderServicesOffset);
HepGeom::Transform3D ladderSvcToglobal = HepGeom::TranslateX3D(layerRadius)
* HepGeom::RotateZ3D(ladderTilt)
* HepGeom::Translate3D(xCenter, yCenter, 0);
HepGeom::Point3D<double> corner1global = ladderSvcToglobal * corner1;
HepGeom::Point3D<double> corner2global = ladderSvcToglobal * corner2;
HepGeom::Point3D<double> corner3global = ladderSvcToglobal * corner3;
HepGeom::Point3D<double> corner4global = ladderSvcToglobal * corner4;
double rMaxTmp = std::max(corner1global.perp(),
std::max(corner2global.perp(),
std::max(corner3global.perp(), corner4global.perp())));
// Thickness from layer radius to max radius of envelope
layerThicknessP = std::max(layerThicknessP, rMaxTmp - gmt_mgr->PixelLayerRadius());
//std::cout << rMaxTmp << std::endl;
//std::cout << layerThicknessP<< " "<<layerThicknessN <<std::endl;
// No longer needed
delete firstLadderServices;
}
//
// Determine the position of the ladders and service volume.
//
......@@ -324,7 +340,7 @@ GeoVPhysVol* GeoPixelLayer::Build() {
//
// A few variables needed below
//
double angle=360./nSectors*CLHEP::deg;
double angle=(nSectors>0)?(360./(double)nSectors*CLHEP::deg):(360.*CLHEP::deg);
HepGeom::Transform3D transRadiusAndTilt = HepGeom::TranslateX3D(layerRadius)*HepGeom::RotateZ3D(ladderTilt);
double phiOfModuleZero = gmt_mgr->PhiOfModuleZero();
......
......@@ -60,8 +60,11 @@ GeoVPhysVol* GeoPixelRingSLHC::Build() {
int iring = gmt_mgr->Eta();
int nmodules = gmt_mgr->PixelDiskRingNModules();
// in case no modules are defined for the ring
if(nmodules==0) return ringPhys;
// deltaPhi is angle between two adjacent modules regardless of side of the disk
double deltaPhi = 360.*CLHEP::deg / nmodules;
double deltaPhi = 360.*CLHEP::deg / (double)nmodules;
// This is the start angle of the even modules
// Start angle could eventually come from the database...
......
......@@ -27,7 +27,12 @@ GeoPixelStaveRing::GeoPixelStaveRing()
{
m_ringName="staveRing";
m_ringPosition="AC";
// m_physVol = Build();
m_zPosition =0;
m_innerRadius = 0.;
m_outerRadius = 0.;
m_physVol = 0;
}
GeoVPhysVol* GeoPixelStaveRing::SetParametersAndBuild(std::string ringName, std::string ringPos)
......
......@@ -24,7 +24,9 @@
using std::max;
GeoPixelStaveRingServices::GeoPixelStaveRingServices(GeoPixelLadder& ladder, GeoPixelStaveSupport& staveSupport):
m_ladder(ladder),m_staveSupport(staveSupport), m_xformSupportA(0), m_xformSupportC(0), m_xformSupportMidRing(0)
m_ladder(ladder),m_staveSupport(staveSupport),
m_supportPhysA(0),m_supportPhysC(0),m_supportMidRing(0),
m_xformSupportA(0), m_xformSupportC(0), m_xformSupportMidRing(0)
{
}
......@@ -98,164 +100,170 @@ GeoVPhysVol* GeoPixelStaveRingServices::Build()
m_supportPhysA = new GeoPhysVol(supportLogVol_A);
m_supportPhysC = new GeoPhysVol(supportLogVol_C);
double angle=360./nSectors*CLHEP::deg;
// HepGeom::Transform3D transRadiusAndTilt = HepGeom::TranslateX3D(layerRadius)*HepGeom::TranslateZ3D(endblockZpos)*HepGeom::RotateZ3D(ladderTilt);
HepGeom::Transform3D transRadiusAndTilt = HepGeom::TranslateX3D(layerRadius)*HepGeom::RotateZ3D(ladderTilt);
double phiOfModuleZero = gmt_mgr->PhiOfModuleZero();
for(int ii = 0; ii < nSectors; ii++) {
gmt_mgr->SetPhi(ii);
double phiOfSector = phiOfModuleZero + ii*angle;
// transform equiv RotZ(phiOfSector)*TransZ(layerRadius)*RotZ(tilt)
HepGeom::Transform3D ladderTransform = HepGeom::RotateZ3D(phiOfSector) * transRadiusAndTilt ;
//
// Place endblock and endblock flex
//
std::ostringstream nameTag;
nameTag << "Endblock" << ii;
GeoNameTag * tag = new GeoNameTag(nameTag.str());
GeoTransform* xformA = new GeoTransform(ladderTransform*ladderLocalTrf*HepGeom::TranslateZ3D(endblockZpos-serviceZpos-dogLegStaveLength*0.5));
m_supportPhysA->add(tag);
m_supportPhysA->add(xformA);
m_supportPhysA->add(endblockA);
GeoTransform* xformC = new GeoTransform(ladderTransform*ladderLocalTrf*HepGeom::TranslateZ3D(-endblockZpos+serviceZpos+dogLegStaveLength*0.5));
m_supportPhysC->add(tag);
m_supportPhysC->add(xformC);
m_supportPhysC->add(endblockC);
//
// Add endblock flex section
//
std::ostringstream nameTagFlex;
nameTagFlex << "EndblockFlex" << ii;
GeoNameTag * tagFlex = new GeoNameTag(nameTagFlex.str());
GeoTransform* xformFlexA = new GeoTransform(ladderTransform*ladderLocalTrf*(endblockFlexTrf->getTransform())*HepGeom::TranslateZ3D(-dogLegStaveLength*0.5));
GeoTransform* xformFlexB = new GeoTransform(ladderTransform*ladderLocalTrf*(endblockFlexTrf->getTransform())*HepGeom::TranslateZ3D(dogLegStaveLength*0.5));
m_supportPhysA->add(tagFlex);
m_supportPhysA->add(xformFlexA);
m_supportPhysA->add(endblockFlex);
m_supportPhysC->add(tagFlex);
m_supportPhysC->add(xformFlexB);
m_supportPhysC->add(endblockFlex);
if(nSectors==0){
gmt_mgr->msg(MSG::ERROR)<<"No phi sectors defined"<<std::endl;
}
else {
double angle=360./nSectors*CLHEP::deg;
// HepGeom::Transform3D transRadiusAndTilt = HepGeom::TranslateX3D(layerRadius)*HepGeom::TranslateZ3D(endblockZpos)*HepGeom::RotateZ3D(ladderTilt);
HepGeom::Transform3D transRadiusAndTilt = HepGeom::TranslateX3D(layerRadius)*HepGeom::RotateZ3D(ladderTilt);
double phiOfModuleZero = gmt_mgr->PhiOfModuleZero();
//
// Add cooling pipe service
//
if(serviceCoolPipe){
std::ostringstream nameTagPipe;
nameTagPipe << "ServicePipe" << ii;
GeoNameTag * tagPipe = new GeoNameTag(nameTagPipe.str());
GeoTransform* xformPipeA = new GeoTransform(ladderTransform*ladderLocalTrf*(serviceCoolPipeTrfA->getTransform())) ;
m_supportPhysA->add(tagPipe);
m_supportPhysA->add(xformPipeA);
m_supportPhysA->add(serviceCoolPipe);
for(int ii = 0; ii < nSectors; ii++) {
gmt_mgr->SetPhi(ii);
GeoTransform* xformPipeC = new GeoTransform(ladderTransform*ladderLocalTrf*(serviceCoolPipeTrfC->getTransform()));
m_supportPhysC->add(tagPipe);
m_supportPhysC->add(xformPipeC);
m_supportPhysC->add(serviceCoolPipe);
double phiOfSector = phiOfModuleZero + ii*angle;
HepGeom::Point3D<double> p=ladderTransform*ladderLocalTrf*(serviceCoolPipeTrfA->getTransform())*HepGeom::Point3D<double>(0.,0.,0.);
// std::cout<<"Cooling pipe srv : "<<p.x()<<" "<<p.y()<<" "<<p.z();
// std::cout<<" r : "<<sqrt(p.x()*p.x()+p.y()*p.y())<<" ";
// std::cout<<" ang : "<<acos(p.x()/sqrt(p.x()*p.x()+p.y()*p.y()))*180./3.1415<<" ";
// std::cout<<std::endl;
// transform equiv RotZ(phiOfSector)*TransZ(layerRadius)*RotZ(tilt)
HepGeom::Transform3D ladderTransform = HepGeom::RotateZ3D(phiOfSector) * transRadiusAndTilt ;
//
// flex dogleg
// Place endblock and endblock flex
//
std::ostringstream nameTag;
nameTag << "Endblock" << ii;
GeoNameTag * tag = new GeoNameTag(nameTag.str());
GeoTransform* xformA = new GeoTransform(ladderTransform*ladderLocalTrf*HepGeom::TranslateZ3D(endblockZpos-serviceZpos-dogLegStaveLength*0.5));
m_supportPhysA->add(tag);
m_supportPhysA->add(xformA);
m_supportPhysA->add(endblockA);
double length=gmt_mgr->IBLFlexDoglegLength();
double eoStave=halfSupportLength-dogLegStaveLength;
double height1=gmt_mgr->IBLFlexDoglegHeight(1);
double height2=gmt_mgr->IBLFlexDoglegHeight(2);
double part1=gmt_mgr->IBLFlexDoglegRatio();
double alpha1=atan(height1/(length*part1));
double alpha2=atan(height2/(length*(1.-part1)));
double dimX_lin=length*part1;
double dimX=dimX_lin/cos(alpha1)-.15;
double dimY=gmt_mgr->IBLStaveFlexWidth();
double dimZ=gmt_mgr->IBLStaveFlexBaseThickness();
double angle=90.*CLHEP::deg-alpha1; //90.-27.99;
double delta=gmt_mgr->IBLFlexDoglegDY();
double trX=-dimX_lin*tan(alpha1)*0.5; //-3.28;
double trZ=eoStave+dimX_lin*0.5;
std::vector<double> xShape, yShape;
xShape.push_back(dimX*0.5); yShape.push_back(dimY*0.5);
xShape.push_back(-dimX*0.5); yShape.push_back(dimY*0.5+delta);
xShape.push_back(-dimX*0.5); yShape.push_back(-dimY*0.5+delta);
xShape.push_back(dimX*0.5); yShape.push_back(-dimY*0.5);
GeoSimplePolygonBrep* tmp_shape = new GeoSimplePolygonBrep(dimZ*0.5);
for(unsigned int iPt=0; iPt<xShape.size(); iPt++) tmp_shape->addVertex(xShape[iPt],yShape[iPt]);
GeoTransform* xformC = new GeoTransform(ladderTransform*ladderLocalTrf*HepGeom::TranslateZ3D(-endblockZpos+serviceZpos+dogLegStaveLength*0.5));
m_supportPhysC->add(tag);
m_supportPhysC->add(xformC);
m_supportPhysC->add(endblockC);
// GeoPara * tmp_shape = new GeoPara(0.47,5.5,9.,0.*CLHEP::deg,55.*CLHEP::deg,0.);
std::string flexMatName = gmt_mgr->IBLFlexMaterial(1,"doglegA");
const GeoMaterial* tmp_material = mat_mgr->getMaterial(flexMatName);
GeoLogVol* tmp_logVol = new GeoLogVol("FlexDogLeg1",tmp_shape,tmp_material);
GeoPhysVol * tmp_logVolPV = new GeoPhysVol(tmp_logVol);
GeoNameTag* tmp_tag = new GeoNameTag("FlexDogLeg1");
HepGeom::Transform3D trfGblA=ladderTransform*ladderLocalTrf*HepGeom::TranslateX3D(trX)*HepGeom::TranslateZ3D(trZ)*(endblockFlexTrf->getTransform())*HepGeom::RotateY3D(angle);
GeoTransform* tmp_xformA = new GeoTransform(trfGblA);
//
// Add endblock flex section
//
std::ostringstream nameTagFlex;
nameTagFlex << "EndblockFlex" << ii;
GeoNameTag * tagFlex = new GeoNameTag(nameTagFlex.str());
GeoTransform* xformFlexA = new GeoTransform(ladderTransform*ladderLocalTrf*(endblockFlexTrf->getTransform())*HepGeom::TranslateZ3D(-dogLegStaveLength*0.5));
GeoTransform* xformFlexB = new GeoTransform(ladderTransform*ladderLocalTrf*(endblockFlexTrf->getTransform())*HepGeom::TranslateZ3D(dogLegStaveLength*0.5));
m_supportPhysA->add(tmp_tag);
m_supportPhysA->add(tmp_xformA);
m_supportPhysA->add(tmp_logVolPV);
m_supportPhysA->add(tagFlex);
m_supportPhysA->add(xformFlexA);
m_supportPhysA->add(endblockFlex);
trX=-dimX_lin*tan(alpha1)*0.5; //-3.28;
trZ=-(eoStave+dimX_lin*0.5);
HepGeom::Transform3D trfGblC=ladderTransform*ladderLocalTrf*HepGeom::TranslateX3D(trX)*HepGeom::TranslateZ3D(trZ)*(endblockFlexTrf->getTransform())*HepGeom::RotateY3D(-angle);
GeoTransform* tmp_xformC = new GeoTransform(trfGblC);
m_supportPhysC->add(tagFlex);
m_supportPhysC->add(xformFlexB);
m_supportPhysC->add(endblockFlex);
m_supportPhysC->add(tmp_tag);
m_supportPhysC->add(tmp_xformC);
m_supportPhysC->add(tmp_logVolPV);
//
// flex : from dogleg to longitudinal
// Add cooling pipe service
//
double dimX2_lin=length*(1.-part1);
double dimX2=dimX2_lin/cos(alpha2)-.15;
double dimY2=gmt_mgr->IBLStaveFlexWidth();
double trX2=trX*2.-dimX2_lin*tan(alpha2)*0.5; //-3.28;
double trZ2=eoStave+dimX_lin+dimX2_lin*0.5;
xShape.clear(); yShape.clear();
angle=90.*CLHEP::deg-alpha2;
xShape.push_back(dimX2*0.5); yShape.push_back(dimY2*0.5);
xShape.push_back(-dimX2*0.5); yShape.push_back(dimY2*0.5);
xShape.push_back(-dimX2*0.5); yShape.push_back(-dimY2*0.5);
xShape.push_back(dimX2*0.5); yShape.push_back(-dimY2*0.5);
GeoSimplePolygonBrep* tmp2_shape = new GeoSimplePolygonBrep(dimZ*0.5);
for(unsigned int iPt=0; iPt<xShape.size(); iPt++) tmp2_shape->addVertex(xShape[iPt],yShape[iPt]);
const GeoMaterial* tmp2_material = mat_mgr->getMaterial(flexMatName);
GeoLogVol* tmp2_logVol = new GeoLogVol("FlexDogLeg2",tmp2_shape,tmp2_material);
GeoPhysVol * tmp2_logVolPV = new GeoPhysVol(tmp2_logVol);
GeoNameTag* tmp2_tag = new GeoNameTag("FlexDogLeg2");
GeoTransform* tmp2_xformA = new GeoTransform(ladderTransform*ladderLocalTrf*HepGeom::TranslateX3D(trX2)*HepGeom::TranslateZ3D(trZ2)*(endblockFlexTrf->getTransform())*HepGeom::RotateY3D(angle)*HepGeom::TranslateY3D(delta*.75));