diff --git a/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/PixelServMatFactoryDC3.cxx b/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/PixelServMatFactoryDC3.cxx index 6ffebfeac95b614e997458199ab4dcf34103bb56..8f2990e46c20c8b58476cedb5f4cf162c1e76d51 100755 --- a/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/PixelServMatFactoryDC3.cxx +++ b/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/PixelServMatFactoryDC3.cxx @@ -165,9 +165,8 @@ void PixelServMatFactoryDC3::create(GeoPhysVol *mother) o<<"_"; o << isec; std::string logNameTmp = logName+o.str(); //std::cout<<isec<<", "<<logNameTmp<<'\n'; - GeoTransform *xform1 = new GeoTransform(GeoTrf::GeoTransformRT(GeoTrf::GeoRotation(0.,0.,isec*M_PI/6.),servpos1)); - GeoTransform *xform2 = new GeoTransform(GeoTrf::GeoTransformRT(GeoTrf::GeoRotation(0.,0.,isec*M_PI/6.),servpos2)); - xform2->ref();//artificial refcount increment + GeoIntrusivePtr<GeoTransform> xform1{new GeoTransform(GeoTrf::GeoTransformRT(GeoTrf::GeoRotation(0.,0.,isec*M_PI/6.),servpos1))}; + GeoIntrusivePtr<GeoTransform> xform2{new GeoTransform(GeoTrf::GeoTransformRT(GeoTrf::GeoRotation(0.,0.,isec*M_PI/6.),servpos2))}; mother->add(new GeoNameTag(logNameTmp)); mother->add(xform1);//xform1 is always used mother->add(ServPhys); @@ -176,19 +175,16 @@ void PixelServMatFactoryDC3::create(GeoPhysVol *mother) mother->add(xform2); mother->add(ServPhys); } - xform2->unref(); //will delete it, if it was never used } }else{ - GeoTransform *xform1 = new GeoTransform(GeoTrf::GeoTransformRT(GeoTrf::GeoRotation(0,0,0),servpos1)); - GeoTransform *xform2 = new GeoTransform(GeoTrf::GeoTransformRT(GeoTrf::GeoRotation(0,0,0),servpos2)); - xform2->ref();//artificial refcount increment + GeoIntrusivePtr<GeoTransform> xform1{new GeoTransform(GeoTrf::GeoTransformRT(GeoTrf::GeoRotation(0,0,0),servpos1))}; + GeoIntrusivePtr<GeoTransform> xform2{new GeoTransform(GeoTrf::GeoTransformRT(GeoTrf::GeoRotation(0,0,0),servpos2))}; mother->add(xform1); mother->add(ServPhys); if( rmin > 0.){ mother->add(xform2); mother->add(ServPhys); } - xform2->unref(); //will delete it, if it was never used } diff --git a/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/SCT_ServMatFactory.cxx b/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/SCT_ServMatFactory.cxx index 40f4d48f47de068c9b7710ec9d954aeea2566ccb..fecbfc40004d67eea27ea1c72a4606a27b6e9ee6 100755 --- a/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/SCT_ServMatFactory.cxx +++ b/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/SCT_ServMatFactory.cxx @@ -102,16 +102,12 @@ void SCT_ServMatFactory::create(GeoPhysVol *mother) double phiTop = asin((yWidthTRSB + coordY) / (rminInt)); double phiBot = asin((yWidthTRSB/2. - coordY) / (rminInt)); - const GeoShape* railGap1=new GeoTubs( rminInt, outROfIDet+safetyGap ,endZOfIDet+safetyGap , - -phiBot, phiBot + phiTop); - const GeoShape* railGap2=new GeoTubs( rminInt, outROfIDet+safetyGap ,endZOfIDet+safetyGap , - -phiTop + M_PI, phiBot + phiTop); - const GeoShape* railGap12=new GeoTubs( rminInt, outROfIDet+safetyGap ,endZOfIDet+safetyGap , - -phiTop, phiBot + phiTop); //because of asymmetry - // In case they don't get used. - railGap1->ref(); - railGap2->ref(); - railGap12->ref(); + GeoIntrusivePtr<const GeoShape> railGap1{new GeoTubs( rminInt, outROfIDet+safetyGap ,endZOfIDet+safetyGap , + -phiBot, phiBot + phiTop)}; + GeoIntrusivePtr<const GeoShape> railGap2{new GeoTubs( rminInt, outROfIDet+safetyGap ,endZOfIDet+safetyGap , + -phiTop + M_PI, phiBot + phiTop)}; + GeoIntrusivePtr<const GeoShape> railGap12{new GeoTubs( rminInt, outROfIDet+safetyGap ,endZOfIDet+safetyGap , + -phiTop, phiBot + phiTop)}; //because of asymmetry // Build general services: // @@ -187,10 +183,6 @@ void SCT_ServMatFactory::create(GeoPhysVol *mother) tubeHelper.placeVolume(mother, servPhys); } - - railGap1->unref(); - railGap2->unref(); - railGap12->unref(); //------------------------------------------------------------------------------------------- // SCT supports (wings,mechanisms) @@ -303,14 +295,11 @@ void SCT_ServMatFactory::create(GeoPhysVol *mother) double phiWid=(70.*Gaudi::Units::mm)/outROfIDet; // std::cout << "Gap phiWid = " << phiWid << std::endl; double safetyGap=1.*Gaudi::Units::mm; - const GeoShape* railGap1=new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , - -phiWid/2.,phiWid); - const GeoShape* railGap2=new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , - -phiWid/2.+M_PI,phiWid); - // In case they don't get used. - railGap1->ref(); - railGap2->ref(); - + GeoIntrusivePtr<const GeoShape> railGap1{new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , + -phiWid/2.,phiWid)}; + GeoIntrusivePtr<const GeoShape> railGap2{new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , + -phiWid/2.+M_PI,phiWid)}; + // Build general services: // @@ -357,10 +346,6 @@ void SCT_ServMatFactory::create(GeoPhysVol *mother) tubeHelper.placeVolume(mother, servPhys); } - - railGap1->unref(); - railGap2->unref(); - //------------------------------------------------------------------------------------------- // SCT supports (wings,mechanisms) { diff --git a/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/SCT_ServMatFactoryDC3.cxx b/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/SCT_ServMatFactoryDC3.cxx index d17bed30c612b305a3a4ef17067d5dd5f6004c21..e953e2404e61127b773faca136473e49b0208a64 100755 --- a/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/SCT_ServMatFactoryDC3.cxx +++ b/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/SCT_ServMatFactoryDC3.cxx @@ -66,13 +66,10 @@ void SCT_ServMatFactoryDC3::create(GeoPhysVol *mother) double endZOfIDet = (*atls)[0]->getDouble("IDETZMX")*Gaudi::Units::cm; double minRofGap = 1050.0*Gaudi::Units::mm; double phiWid=(70.*Gaudi::Units::mm)/outROfIDet; double safetyGap=1.*Gaudi::Units::mm; - const GeoShape* railGap1=new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , - -phiWid/2.,phiWid); - const GeoShape* railGap2=new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , - -phiWid/2.+M_PI,phiWid); - // In case they don't get used. - railGap1->ref(); - railGap2->ref(); + GeoIntrusivePtr<const GeoShape> railGap1{new GeoTubs( minRofGap, outROfIDet +safetyGap ,endZOfIDet+safetyGap , + -phiWid/2.,phiWid)}; + GeoIntrusivePtr<const GeoShape> railGap2{new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , + -phiWid/2.+M_PI,phiWid)}; // Build SCT services in Endcap. // (Code taken from TRT_GeoModel) @@ -211,8 +208,6 @@ void SCT_ServMatFactoryDC3::create(GeoPhysVol *mother) mother->add(ServPhys); } - railGap1->unref(); - railGap2->unref(); } diff --git a/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/SCT_ServMatFactoryFS.cxx b/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/SCT_ServMatFactoryFS.cxx index 218e449b4401257e6284160f111666b0d580bdb6..a897a3a48c786e84dcabfc41e9f0740691ba01a2 100755 --- a/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/SCT_ServMatFactoryFS.cxx +++ b/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/SCT_ServMatFactoryFS.cxx @@ -75,13 +75,10 @@ void SCT_ServMatFactoryFS::create(GeoPhysVol *motherP,GeoPhysVol *motherM) double minRofGap = 1089.0*Gaudi::Units::mm; double phiWid=(70.*Gaudi::Units::mm)/outROfIDet; double safetyGap=1.*Gaudi::Units::mm; - const GeoShape* railGap1=new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , - -phiWid/2.,phiWid); - const GeoShape* railGap2=new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , - -phiWid/2.+M_PI,phiWid); - // In case they don't get used. - railGap1->ref(); - railGap2->ref(); + GeoIntrusivePtr<const GeoShape> railGap1{new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , + -phiWid/2.,phiWid)}; + GeoIntrusivePtr<const GeoShape> railGap2{new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , + -phiWid/2.+M_PI,phiWid)}; // Build general services: @@ -89,7 +86,7 @@ void SCT_ServMatFactoryFS::create(GeoPhysVol *motherP,GeoPhysVol *motherM) for (unsigned int ii =0; ii < sctGenServices->size(); ii++) { InDetDD::GenericTubeMaker tubeHelper((*sctGenServices)[ii]); - const GeoShape * serviceTubeTmp = tubeHelper.buildShape(); + GeoIntrusivePtr<const GeoShape> serviceTubeTmp{tubeHelper.buildShape()}; std::string logName = tubeHelper.name(); if (logName.empty()) { @@ -107,7 +104,7 @@ void SCT_ServMatFactoryFS::create(GeoPhysVol *motherP,GeoPhysVol *motherM) const GeoPcon* servicePcon = nullptr; // helper shape - const GeoShape* serviceTube = serviceTubeTmp; + GeoIntrusivePtr<const GeoShape> serviceTube{serviceTubeTmp}; if( tubeHelper.volData().maxRadius() > minRofGap && tubeHelper.volData().phiStart() < phiWid/2.) { // GeoModel doesn't calculate volume correctly so we calculate the cutout volume. @@ -145,7 +142,7 @@ void SCT_ServMatFactoryFS::create(GeoPhysVol *motherP,GeoPhysVol *motherM) } else { // Here we have SctHSP pcon // Break it into 4 individual placements: 1 tube, 1 cone and 2 tubs - servicePcon = dynamic_cast<const GeoPcon*>(serviceTube); + servicePcon = dynamic_cast<const GeoPcon*>(serviceTube.get()); if(servicePcon==nullptr || servicePcon->getNPlanes()!=3) continue; // Shape 1. Tube. Rmax = Rmin of the cutout @@ -198,7 +195,6 @@ void SCT_ServMatFactoryFS::create(GeoPhysVol *motherP,GeoPhysVol *motherM) tubeHelper.placeVolTwoSide(motherP,motherM,servPhysDown); } - serviceTube->unref(); } } diff --git a/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/TRT_ServMatFactory.cxx b/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/TRT_ServMatFactory.cxx index 71315305ff553e5b9c62c7ca57ab7287cc3e7f35..52bddec0a444122a00aea489c2a472325c1bf52a 100755 --- a/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/TRT_ServMatFactory.cxx +++ b/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/TRT_ServMatFactory.cxx @@ -101,10 +101,9 @@ void TRT_ServMatFactory::create(GeoPhysVol *mother) double phiTop = asin((yWidthTRSB + coordY) / (rminInt)); double phiBot = asin((yWidthTRSB/2. - coordY) / (rminInt)); - const GeoShape* railGap1 = new GeoTubs( rminInt, outROfIDet, endZOfIDet, -phiBot, phiBot + phiTop); - const GeoShape* railGap2 = new GeoTubs( rminInt, outROfIDet, endZOfIDet, M_PI - phiTop, phiBot + phiTop); - railGap1->ref(); - railGap2->ref(); + GeoIntrusivePtr<const GeoShape> railGap1{new GeoTubs( rminInt, outROfIDet, endZOfIDet, -phiBot, phiBot + phiTop)}; + GeoIntrusivePtr<const GeoShape> railGap2{new GeoTubs( rminInt, outROfIDet, endZOfIDet, M_PI - phiTop, phiBot + phiTop)}; + for (unsigned int ii =0; ii < trtGenServices->size(); ii++) { @@ -143,8 +142,7 @@ void TRT_ServMatFactory::create(GeoPhysVol *mother) tubeHelper.placeVolume(mother, servPhys); } } - railGap1->unref(); - railGap2->unref(); + } else { // ______________________________________________________________________________________________________________________ @@ -169,13 +167,11 @@ void TRT_ServMatFactory::create(GeoPhysVol *mother) double endZOfIDet = (*atls)[0]->getDouble("IDETZMX")*Gaudi::Units::cm; double minRofGap = 1050.0; double phiWid=70./outROfIDet; double safetyGap=1.; - const GeoShape* railGap1=new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , - -phiWid/2.,phiWid); - const GeoShape* railGap2=new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , - -phiWid/2.+M_PI,phiWid); - // In case they don't get used. - railGap1->ref(); - railGap2->ref(); + GeoIntrusivePtr<const GeoShape> railGap1{new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , + -phiWid/2.,phiWid)}; + GeoIntrusivePtr<const GeoShape> railGap2{new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , + -phiWid/2.+M_PI,phiWid)}; + //VK 26.03.2007 Construct a gap for SquirrelCage ribbon @@ -229,9 +225,6 @@ void TRT_ServMatFactory::create(GeoPhysVol *mother) tubeHelper.placeVolume(mother, servPhys); } - - railGap1->unref(); - railGap2->unref(); } } diff --git a/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/TRT_ServMatFactoryDC3.cxx b/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/TRT_ServMatFactoryDC3.cxx index b01d4e2ebb0768cd2590b1a1230236a0cebf7fc1..4333079e0444bd7fa971571845759e7c536ee7a5 100755 --- a/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/TRT_ServMatFactoryDC3.cxx +++ b/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/TRT_ServMatFactoryDC3.cxx @@ -69,12 +69,10 @@ void TRT_ServMatFactoryDC3::create(GeoPhysVol *mother) double endZOfIDet = (*atls)[0]->getDouble("IDETZMX")*Gaudi::Units::cm; double minRofGap = 1050.0; double phiWid=70./outROfIDet; double safetyGap=1.; - const GeoShape* railGap1=new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , - -phiWid/2.,phiWid); - const GeoShape* railGap2=new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , - -phiWid/2.+M_PI,phiWid); - railGap1->ref(); - railGap2->ref(); + GeoIntrusivePtr<const GeoShape> railGap1{new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , + -phiWid/2.,phiWid)}; + GeoIntrusivePtr<const GeoShape> railGap2{new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , + -phiWid/2.+M_PI,phiWid)}; // Build the patch panels: @@ -195,8 +193,6 @@ void TRT_ServMatFactoryDC3::create(GeoPhysVol *mother) mother->add(xform2); mother->add(ServPhys); } - railGap1->unref();//should delete if not used anywhere - railGap2->unref(); } diff --git a/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/TRT_ServMatFactoryFS.cxx b/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/TRT_ServMatFactoryFS.cxx index 54e3b7a726adb9a1fce7efa0a0cd11cd6e1e27fe..8abc08d71a171e933c1277275c7a800fd94efc10 100755 --- a/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/TRT_ServMatFactoryFS.cxx +++ b/InnerDetector/InDetDetDescr/InDetServMatGeoModel/src/TRT_ServMatFactoryFS.cxx @@ -77,14 +77,14 @@ void TRT_ServMatFactoryFS::create(GeoPhysVol *motherP, GeoPhysVol *motherM) double endZOfIDet = (*atls)[0]->getDouble("IDETZMX")*Gaudi::Units::cm; double minRofGap = 1050.0; double phiWid=70./outROfIDet; double safetyGap=1.; - const GeoShape* railGap1=new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , - -phiWid/2.,phiWid); - const GeoShape* railGap2=new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , - -phiWid/2.+M_PI,phiWid); + GeoIntrusivePtr<const GeoShape> railGap1{new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , + -phiWid/2.,phiWid)}; + GeoIntrusivePtr<const GeoShape> railGap2{new GeoTubs( minRofGap, outROfIDet+safetyGap ,endZOfIDet+safetyGap , + -phiWid/2.+M_PI,phiWid)}; // In case they don't get used. - railGap1->ref(); - railGap2->ref(); + if(railGap1->refCount() != railGap2->refCount()) { + } //VK 26.03.2007 Construct a gap for SquirrelCage ribbon double rminInt = (*cage)[0]->getDouble("RINGRMIN")*Gaudi::Units::mm; @@ -139,10 +139,7 @@ void TRT_ServMatFactoryFS::create(GeoPhysVol *motherP, GeoPhysVol *motherM) tubeHelper.placeVolTwoSide(motherP,motherM,servPhysUp); tubeHelper.placeVolTwoSide(motherP,motherM,servPhysDown); - serviceTube->unref(); } - railGap1->unref(); - railGap2->unref(); }