Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /DD4hep/examples/DDCMS/src/plugins/DDTIBLayerAlgo.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 //
0014 // Specialized generic detector constructor
0015 // 
0016 //==========================================================================
0017 
0018 // Framework include files
0019 #include "DD4hep/DetFactoryHelper.h"
0020 #include "DDCMS/DDCMSPlugins.h"
0021 
0022 using namespace std;
0023 using namespace dd4hep;
0024 using namespace dd4hep::cms;
0025 
0026 static long algorithm(Detector& /* description */,
0027                       ParsingContext& ctxt,
0028                       xml_h e,
0029                       SensitiveDetector& /* sens */)
0030 {
0031   typedef vector<double> vecdouble;
0032   Namespace      ns(ctxt, e, true);
0033   AlgoArguments  args(ctxt, e);
0034   string    mother       = args.parentName();
0035   string    genMat       = args.str("GeneralMaterial");           //General material name
0036   double    detectorTilt = args.dble("DetectorTilt");             //Detector Tilt
0037   double    layerL       = args.dble("LayerL");                   //Length of the layer
0038 
0039   double    radiusLo     = args.dble("RadiusLo");                 //Radius for detector at lower level
0040   int       stringsLo    = args.integer("StringsLo");             //Number of strings      ......
0041   string    detectorLo   = args.str("StringDetLoName");           //Detector string name   ......
0042 
0043   double    radiusUp     = args.dble("RadiusUp");                 //Radius for detector at upper level
0044   int       stringsUp    = args.integer("StringsUp");             //Number of strings      ......
0045   string    detectorUp   = args.str("StringDetUpName");           //Detector string name   ......
0046 
0047   double    cylinderT    = args.dble("CylinderThickness");        //Cylinder thickness
0048   double    cylinderInR  = args.dble("CylinderInnerRadius");      //Cylinder inner radius
0049   string    cylinderMat  = args.str("CylinderMaterial");          //Cylinder material
0050   double    MFRingInR    = args.dble("MFRingInnerRadius");        //Inner Manifold Ring Inner Radius 
0051   double    MFRingOutR   = args.dble("MFRingOuterRadius");        //Outer Manifold Ring Outer Radius 
0052   double    MFRingT      = args.dble("MFRingThickness");          //Manifold Ring Thickness
0053   double    MFRingDz     = args.dble("MFRingDeltaz");             //Manifold Ring Half Lenght
0054   string    MFIntRingMat = args.str("MFIntRingMaterial");         //Manifold Ring Material
0055   string    MFExtRingMat = args.str("MFExtRingMaterial");         //Manifold Ring Material
0056 
0057   double    supportT     = args.dble("SupportThickness");         //Cylinder barrel CF skin thickness
0058 
0059   string    centMat      = args.str("CentRingMaterial");          //Central rings  material
0060   vecdouble centRing1par = args.vecDble("CentRing1");             //Central rings parameters
0061   vecdouble centRing2par = args.vecDble("CentRing2");             //Central rings parameters
0062 
0063   string    fillerMat    = args.str("FillerMaterial");            //Filler material
0064   double    fillerDz     = args.dble("FillerDeltaz");             //Filler Half Length
0065 
0066   string    ribMat       = args.str("RibMaterial");               //Rib material
0067   vecdouble ribW         = args.vecDble("RibWidth");              //Rib width
0068   vecdouble ribPhi       = args.vecDble("RibPhi");                //Rib Phi position
0069 
0070   vecdouble dohmListFW   = args.vecDble("DOHMListFW");            //DOHM/AUX positions in #strings FW
0071   vecdouble dohmListBW   = args.vecDble("DOHMListBW");            //DOHM/AUX positions in #strings BW
0072 
0073   double    dohmtoMF            = args.dble("DOHMtoMFDist");      //DOHM Distance to MF
0074   double    dohmCarrierPhiOff   = args.dble("DOHMCarrierPhiOffset"); //DOHM Carrier Phi offset wrt horizontal
0075   string    dohmPrimName        = args.str("StringDOHMPrimName"); //DOHM Primary Logical Volume name
0076   string    dohmAuxName         = args.str("StringDOHMAuxName");  //DOHM Auxiliary Logical Volume name
0077 
0078   string    dohmCarrierMaterial = args.str("DOHMCarrierMaterial");//DOHM Carrier Material
0079   string    dohmCableMaterial   = args.str("DOHMCableMaterial");  //DOHM Cable Material
0080   double    dohmPrimL           = args.dble("DOHMPRIMLength");    //DOHM PRIMary Length
0081   string    dohmPrimMaterial    = args.str("DOHMPRIMMaterial");   //DOHM PRIMary Material
0082   double    dohmAuxL            = args.dble("DOHMAUXLength");     //DOHM AUXiliary Length
0083   string    dohmAuxMaterial     = args.str("DOHMAUXMaterial");    //DOHM AUXiliary Material
0084 
0085   string    pillarMaterial      = args.str("PillarMaterial");     //Pillar Material
0086 
0087   double    fwIntPillarDz       = args.dble("FWIntPillarDz");     //Internal pillar parameters
0088   double    fwIntPillarDPhi     = args.dble("FWIntPillarDPhi");  
0089   vecdouble fwIntPillarZ        = args.vecDble("FWIntPillarZ");  
0090   vecdouble fwIntPillarPhi      = args.vecDble("FWIntPillarPhi");  
0091   double    bwIntPillarDz       = args.dble("BWIntPillarDz");  
0092   double    bwIntPillarDPhi     = args.dble("BWIntPillarDPhi");  
0093   vecdouble bwIntPillarZ        = args.vecDble("BWIntPillarZ");  
0094   vecdouble bwIntPillarPhi      = args.vecDble("BWIntPillarPhi");  
0095 
0096   double    fwExtPillarDz       = args.dble("FWExtPillarDz");        //External pillar parameters
0097   double    fwExtPillarDPhi     = args.dble("FWExtPillarDPhi");  
0098   vecdouble fwExtPillarZ        = args.vecDble("FWExtPillarZ");    
0099   vecdouble fwExtPillarPhi      = args.vecDble("FWExtPillarPhi");  
0100   double    bwExtPillarDz       = args.dble("BWExtPillarDz");  
0101   double    bwExtPillarDPhi     = args.dble("BWExtPillarDPhi");  
0102   vecdouble bwExtPillarZ        = args.vecDble("BWExtPillarZ");    
0103   vecdouble bwExtPillarPhi      = args.vecDble("BWExtPillarPhi");  
0104   
0105   LogDebug("TIBGeom") << "Parent " << mother
0106       << " NameSpace " << ns.name
0107       << " General Material " << genMat;
0108   LogDebug("TIBGeom") << "Lower layer Radius " << radiusLo
0109       << " Number " << stringsLo << " String " << detectorLo;
0110   LogDebug("TIBGeom") << "Upper layer Radius "<< radiusUp
0111       << " Number " << stringsUp << " String " << detectorUp;
0112   LogDebug("TIBGeom") << "Cylinder Material/thickness " << cylinderMat << " " << cylinderT 
0113       << " Rib Material " << ribMat << " at " << ribW.size() << " positions with width/phi";
0114   for (unsigned int i = 0; i < ribW.size(); i++)  {
0115     LogDebug("TIBGeom") << "\tribW[" << i << "] = " <<  ribW[i] 
0116         << "\tribPhi[" << i << "] = " << ribPhi[i]/CLHEP::deg;
0117   }
0118   LogDebug("TIBGeom") << "DOHM Primary " << " Material " << dohmPrimMaterial << " Length " << dohmPrimL;
0119   LogDebug("TIBGeom") << "DOHM Aux     " << " Material " << dohmAuxMaterial << " Length " << dohmAuxL;
0120   for (double i : dohmListFW) {
0121     if (i>0.) LogDebug("TIBGeom") << "DOHM Primary at FW Position " << i;
0122     if (i<0.) LogDebug("TIBGeom") << "DOHM Aux     at FW Position " << -i;
0123   }
0124   for (double i : dohmListBW) {
0125     if (i>0.) LogDebug("TIBGeom") << "DOHM Primary at BW Position " << i;
0126     if (i<0.) LogDebug("TIBGeom") << "DOHM Aux     at BW Position " << -i;
0127   }
0128   LogDebug("TIBGeom") << "FW Internal Pillar [Dz, DPhi] " << fwIntPillarDz << ", " << fwIntPillarDPhi; 
0129   for (unsigned int i=0; i<fwIntPillarZ.size(); i++) {
0130     if( fwIntPillarPhi[i]>0. ) { 
0131       LogDebug("TIBGeom") << " at positions [z, phi] " << fwIntPillarZ[i] << " " << fwIntPillarPhi[i];
0132     }
0133   }
0134   LogDebug("TIBGeom") << "BW Internal Pillar [Dz, DPhi] " << bwIntPillarDz << ", " << bwIntPillarDPhi; 
0135   for (unsigned int i=0; i<bwIntPillarZ.size(); i++) {
0136     if( bwIntPillarPhi[i]>0. ) { 
0137       LogDebug("TIBGeom") << " at positions [z, phi] " << bwIntPillarZ[i] << " " << bwIntPillarPhi[i];
0138     }
0139   }
0140   LogDebug("TIBGeom") << "FW External Pillar [Dz, DPhi] " << fwExtPillarDz << ", " << fwExtPillarDPhi; 
0141   for (unsigned int i=0; i<fwExtPillarZ.size(); i++) {
0142     if( fwExtPillarPhi[i]>0. ) { 
0143       LogDebug("TIBGeom") << " at positions [z, phi] " << fwExtPillarZ[i] << " " << fwExtPillarPhi[i];
0144     }
0145   }
0146   LogDebug("TIBGeom") << "BW External Pillar [Dz, DPhi] " << bwExtPillarDz << ", " << bwExtPillarDPhi; 
0147   for (unsigned int i=0; i<bwExtPillarZ.size(); i++) {
0148     if( bwExtPillarPhi[i]>0. ) { 
0149       LogDebug("TIBGeom") << " at positions [z, phi] " << bwExtPillarZ[i] << " " << bwExtPillarPhi[i];
0150     }
0151   }
0152 
0153   string idName = mother;
0154   double rmin = MFRingInR;
0155   double rmax = MFRingOutR;
0156   Solid  solid = ns.addSolidNS(idName,Tube(rmin, rmax, 0.5*layerL));
0157   LogDebug("TIBGeom") << solid.name() << " Tubs made of " 
0158       << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg 
0159       << " with Rin " << rmin << " Rout " << rmax << " ZHalf " << 0.5*layerL;
0160   Volume layer = ns.addVolumeNS(Volume(idName, solid, ns.material(genMat)));
0161 
0162   //Internal layer first
0163   double rin  = rmin+MFRingT;
0164   //  double rout = 0.5*(radiusLo+radiusUp-cylinderT);
0165   double rout = cylinderInR;
0166   string name = idName + "Down";
0167   solid = ns.addSolidNS(name,Tube(rin, rout, 0.5*layerL));
0168   LogDebug("TIBGeom") << solid.name() << " Tubs made of " 
0169       << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg 
0170       << " with Rin " << rin << " Rout " << rout 
0171       << " ZHalf " << 0.5*layerL;
0172   Volume layerIn = ns.addVolumeNS(Volume(name, solid, ns.material(genMat)));
0173   layer.placeVolume(layerIn, 1); // copyNr=1 !
0174   LogDebug("TIBGeom") << layerIn.name()
0175       << " number 1 positioned in " << layer.name()
0176       << " at (0,0,0) with no rotation";
0177 
0178   double rposdet = radiusLo;
0179   double dphi    = CLHEP::twopi/stringsLo;
0180   Volume detIn   = ns.volume(detectorLo);
0181   for (int n = 0; n < stringsLo; n++) {
0182     double phi    = (n+0.5)*dphi;
0183     double phix   = phi - detectorTilt + 90*CLHEP::deg;
0184     double theta  = 90*CLHEP::deg;
0185     double phiy   = phix + 90.*CLHEP::deg;
0186     Rotation3D rotation = make_rotation3D(theta, phix, theta, phiy, 0., 0.);
0187     Position   trdet(rposdet*cos(phi), rposdet*sin(phi), 0);
0188     layerIn.placeVolume(detIn, n+1, Transform3D(rotation,trdet)); // copyNr=n+1
0189     LogDebug("TIBGeom") << detIn.name() << " number " << n+1 << " positioned in " 
0190         << layerIn.name() << " at " << trdet << " with "
0191         << rotation;
0192   }
0193   //Now the external layer
0194   rin  = cylinderInR + cylinderT;
0195   rout = rmax-MFRingT;
0196   name = idName + "Up";
0197   solid = ns.addSolidNS(name,Tube(rin, rout, 0.5*layerL));
0198   LogDebug("TIBGeom") << solid.name() << " Tubs made of " 
0199       << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg 
0200       << " with Rin " << rin << " Rout " << rout
0201       << " ZHalf " << 0.5*layerL;
0202   Volume layerOut = ns.addVolumeNS(Volume(name, solid, ns.material(genMat)));
0203   layer.placeVolume(layerOut, 1); // CopyNr 1 
0204   LogDebug("TIBGeom") << layerOut.name() 
0205       << " number 1 positioned in " << layer.name() 
0206       << " at (0,0,0) with no rotation";
0207 
0208   rposdet = radiusUp;
0209   dphi    = CLHEP::twopi/stringsUp;
0210   Volume detOut = ns.volume(detectorUp);
0211   for (int n = 0; n < stringsUp; n++) {
0212     double phi    = (n+0.5)*dphi;
0213     double phix   = phi - detectorTilt - 90*CLHEP::deg;
0214     double theta  = 90*CLHEP::deg;
0215     double phiy   = phix + 90.*CLHEP::deg;
0216     Rotation3D rotation = make_rotation3D(theta, phix, theta, phiy, 0., 0.);
0217     Position   trdet(rposdet*cos(phi), rposdet*sin(phi), 0);
0218     layerOut.placeVolume(detOut, n+1, Transform3D(rotation,trdet));
0219     LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << detectorUp
0220         << " number " << n+1 << " positioned in " 
0221         << layerOut.name() << " at " << trdet << " with "
0222         << rotation;
0223   }
0224 
0225   //
0226   // Inner cylinder, support wall and ribs
0227   //
0228   // External skins
0229   rin   = cylinderInR;
0230   rout  = cylinderInR+cylinderT;
0231   name  = idName + "Cylinder";
0232   solid = ns.addSolidNS(name, Tube(rin, rout, 0.5*layerL));
0233   LogDebug("TIBGeom") << solid.name() << " Tubs made of " 
0234       << cylinderMat << " from 0 to " 
0235       << CLHEP::twopi/CLHEP::deg << " with Rin " << rin 
0236       << " Rout " << rout << " ZHalf " << 0.5*layerL;
0237   Volume cylinder = ns.addVolumeNS(Volume(name, solid, ns.material(cylinderMat)));
0238   layer.placeVolume(cylinder, 1); // CopyNr = 1
0239   LogDebug("TIBGeom") << cylinder.name() 
0240       << " number 1 positioned in " << layer.name()
0241       << " at (0,0,0) with no rotation";
0242   //
0243   // inner part of the cylinder
0244   //
0245   rin  += supportT;
0246   rout -= supportT;
0247   name  = idName + "CylinderIn";
0248   solid = ns.addSolidNS(name, Tube(rin, rout, 0.5*layerL));
0249   LogDebug("TIBGeom") << solid.name() << " Tubs made of "
0250       << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg 
0251       << " with Rin " << rin << " Rout " << rout 
0252       << " ZHalf " << 0.5*layerL;
0253   Volume cylinderIn = ns.addVolumeNS(Volume(name, solid, ns.material(genMat)));
0254   cylinder.placeVolume(cylinderIn, 1);
0255   LogDebug("TIBGeom") << cylinderIn.name() 
0256       << " number 1 positioned in " << cylinder.name() 
0257       << " at (0,0,0) with no rotation";
0258   //
0259   // Filler Rings
0260   //
0261   name = idName + "Filler";
0262   solid = ns.addSolidNS(name,Tube(rin, rout, fillerDz));
0263   LogDebug("TIBGeom") << solid.name() << " Tubs made of " 
0264       << fillerMat << " from " << 0. << " to "
0265       << CLHEP::twopi/CLHEP::deg << " with Rin " << rin 
0266       << " Rout " << rout << " ZHalf "  << fillerDz;
0267   Volume cylinderFiller = ns.addVolumeNS(Volume(name,solid,ns.material(fillerMat)));
0268   cylinderIn.placeVolume(cylinderFiller, 1, Position(0.0, 0.0, 0.5*layerL-fillerDz)); // copyNr 1
0269   cylinderIn.placeVolume(cylinderFiller, 2, Position(0.0, 0.0,-0.5*layerL+fillerDz)); // copyNr 2
0270   LogDebug("TIBGeom") << "DDTIBLayerAlgo test " << cylinderFiller.name()
0271       << " number 1" << " positioned in " 
0272       << cylinderIn.name() << " at " << Position(0.0, 0.0, 0.5*layerL-fillerDz)
0273       << " number 2" << " positioned in " 
0274       << cylinderIn.name() << " at " << Position(0.0, 0.0,-0.5*layerL+fillerDz);
0275   //
0276   // Ribs
0277   //
0278   Material matrib = ns.material(ribMat);
0279   for (size_t i = 0; i < ribW.size(); i++) {
0280     name = idName + "Rib" + std::to_string(i);
0281     double width = 2.*ribW[i]/(rin+rout);
0282     double dz    = 0.5*layerL-2.*fillerDz;
0283     double _rmi  = std::min(rin+0.5*CLHEP::mm,rout-0.5*CLHEP::mm);
0284     double _rma  = std::max(rin+0.5*CLHEP::mm,rout-0.5*CLHEP::mm);
0285     solid = ns.addSolidNS(name,Tube(_rmi,_rma,dz,-0.5*width, width));
0286     LogDebug("TIBGeom") << solid.name() << " Tubs made of " 
0287         << ribMat << " from " << -0.5*width/CLHEP::deg <<" to "
0288         << 0.5*width/CLHEP::deg << " with Rin " 
0289         << rin+0.5*CLHEP::mm << " Rout " 
0290         << rout-0.5*CLHEP::mm << " ZHalf "  << dz;
0291     Volume cylinderRib = ns.addVolumeNS(Volume(name, solid, matrib));
0292     double phix   = ribPhi[i];
0293     double theta  = 90*CLHEP::deg;
0294     double phiy   = phix + 90.*CLHEP::deg;
0295     Rotation3D rotation = make_rotation3D(theta, phix, theta, phiy, 0., 0.);
0296     Position tran(0, 0, 0);
0297     cylinderIn.placeVolume(cylinderRib, 1, Transform3D(rotation,tran));// copyNr=1
0298     LogDebug("TIBGeom") << cylinderRib.name()
0299         << " number 1" << " positioned in " 
0300         << cylinderIn.name() << " at " << tran << " with " 
0301         << rotation;
0302   }
0303   //
0304   //Manifold rings
0305   //
0306   // Inner ones first
0307   rin   = MFRingInR;
0308   rout  = rin + MFRingT;
0309   name  = idName + "InnerMFRing";
0310   solid = ns.addSolidNS(name,Tube(rin, rout, MFRingDz));
0311   LogDebug("TIBGeom") << solid.name() << " Tubs made of " 
0312       << MFIntRingMat << " from 0 to " 
0313       << CLHEP::twopi/CLHEP::deg << " with Rin " << rin 
0314       << " Rout " << rout << " ZHalf " << MFRingDz;
0315   Volume inmfr = ns.addVolumeNS(Volume(name, solid, ns.material(MFIntRingMat)));
0316   layer.placeVolume(inmfr, 1, Position(0.0, 0.0, -0.5*layerL+MFRingDz)); // Copy Nr=1
0317   layer.placeVolume(inmfr, 2, Position(0.0, 0.0, +0.5*layerL+MFRingDz)); // Copy Nr=2
0318   LogDebug("TIBGeom") << inmfr.name() 
0319       << " number 1 and 2 positioned in " << layer.name()
0320       << " at (0,0,+-" << 0.5*layerL-MFRingDz << ") with no rotation";
0321 
0322   // Outer ones
0323   rout = MFRingOutR;
0324   rin  = rout - MFRingT;
0325   name = idName + "OuterMFRing";
0326   solid= ns.addSolidNS(name,Tube(rin, rout, MFRingDz));
0327   LogDebug("TIBGeom") << solid.name() << " Tubs made of " 
0328       << MFExtRingMat << " from 0 to " 
0329       << CLHEP::twopi/CLHEP::deg << " with Rin " << rin 
0330       << " Rout " << rout << " ZHalf " << MFRingDz;
0331 
0332   Volume outmfr = ns.addVolumeNS(Volume(name, solid, ns.material(MFExtRingMat)));
0333   layer.placeVolume(outmfr, 1, Position(0.0, 0.0, -0.5*layerL+MFRingDz)); // CopyNr=1
0334   layer.placeVolume(outmfr, 2, Position(0.0, 0.0, +0.5*layerL+MFRingDz)); // CopyNr=2
0335   LogDebug("TIBGeom") << outmfr.name() 
0336       << " number 1 and 2 positioned in " << layer.name()
0337       << " at (0,0,+-" << 0.5*layerL-MFRingDz 
0338       << ") with no rotation";
0339   //
0340   //Central Support rings
0341   //
0342   // Ring 1
0343   double centZ  = centRing1par[0];
0344   double centDz = 0.5*centRing1par[1];
0345   rin  = centRing1par[2];
0346   rout = centRing1par[3];
0347   name = idName + "CentRing1";
0348   solid = ns.addSolidNS(name,Tube(rin, rout, centDz));
0349 
0350   LogDebug("TIBGeom") << solid.name() << " Tubs made of " 
0351       << centMat << " from 0 to " << CLHEP::twopi/CLHEP::deg 
0352       << " with Rin " << rin << " Rout " << rout 
0353       << " ZHalf " << centDz;
0354 
0355   Volume cent1 = ns.addVolumeNS(Volume(name, solid, ns.material(centMat)));
0356   layer.placeVolume(cent1,1, Position(0.0, 0.0, centZ)); // Copy Nr = 1
0357   LogDebug("TIBGeom") << cent1.name() << " positioned in " << layer.name()
0358       << " at (0,0," << centZ << ") with no rotation";
0359   // Ring 2
0360   centZ  = centRing2par[0];
0361   centDz = 0.5*centRing2par[1];
0362   rin  = centRing2par[2];
0363   rout = centRing2par[3];
0364   name = idName + "CentRing2";
0365   solid = ns.addSolidNS(name, Tube(rin, rout, centDz));
0366   LogDebug("TIBGeom") << solid.name() << " Tubs made of " 
0367       << centMat << " from 0 to " << CLHEP::twopi/CLHEP::deg 
0368       << " with Rin " << rin << " Rout " << rout 
0369       << " ZHalf " << centDz;
0370 
0371   Volume cent2 = ns.addVolumeNS(Volume(name, solid, ns.material(centMat)));
0372   layer.placeVolume(cent2, 1, Position(0e0,0e0,centZ)); // copyNr=1
0373   LogDebug("TIBGeom") << cent2.name() 
0374       << " positioned in " << layer.name()
0375       << " at (0,0," << centZ << ") with no rotation";
0376   //
0377   ////// DOHM
0378   //
0379   // Preparing DOHM Carrier solid
0380   //
0381   name = idName + "DOHMCarrier";
0382   double dohmCarrierRin   = MFRingOutR - MFRingT;
0383   double dohmCarrierRout  = MFRingOutR;
0384   double dohmCarrierDz    = 0.5*(dohmPrimL+dohmtoMF);
0385   double dohmCarrierZ     = 0.5*layerL-2.*MFRingDz-dohmCarrierDz;
0386 
0387   solid = ns.addSolidNS(name,Tube(dohmCarrierRin, dohmCarrierRout, 
0388                                   dohmCarrierPhiOff, dohmCarrierDz, 
0389                                   180.*CLHEP::deg-2.*dohmCarrierPhiOff));
0390   LogDebug("TIBGeom") << solid.name() << " Tubs made of "
0391       << dohmCarrierMaterial << " from "
0392       << dohmCarrierPhiOff << " to " 
0393       << 180.*CLHEP::deg-dohmCarrierPhiOff << " with Rin "
0394       << dohmCarrierRin << " Rout " << MFRingOutR << " ZHalf " 
0395       << dohmCarrierDz;
0396   
0397   // Define FW and BW carrier logical volume and
0398   // place DOHM Primary and auxiliary modules inside it
0399   dphi = CLHEP::twopi/stringsUp;
0400 
0401   Rotation3D dohmRotation;
0402   double dohmR = 0.5*(dohmCarrierRin+dohmCarrierRout);
0403 
0404   for (int j = 0; j<4; j++) {
0405     vector<double> dohmList;
0406     Position tran;
0407     string rotstr;
0408     Rotation3D rotation;
0409     int dohmCarrierReplica=0;
0410     int placeDohm = 0;
0411 
0412     switch (j){
0413     case 0:
0414       name = idName + "DOHMCarrierFW";
0415       dohmList = dohmListFW;
0416       tran = Position(0., 0., dohmCarrierZ);
0417       rotstr = idName + "FwUp";
0418       rotation = Rotation3D();
0419       dohmCarrierReplica = 1;
0420       placeDohm=1;
0421       break;
0422     case 1:
0423       name = idName + "DOHMCarrierFW";
0424       dohmList = dohmListFW;
0425       tran = Position(0., 0., dohmCarrierZ);
0426       rotstr = idName + "FwDown";
0427       rotation = make_rotation3D(90.*CLHEP::deg, 180.*CLHEP::deg, 90.*CLHEP::deg,270.*CLHEP::deg, 0.,0.);
0428       dohmCarrierReplica = 2;
0429       placeDohm=0;
0430       break;
0431     case 2:
0432       name = idName + "DOHMCarrierBW";
0433       dohmList = dohmListBW;
0434       tran = Position(0., 0., -dohmCarrierZ);
0435       rotstr = idName + "BwUp";
0436       rotation = make_rotation3D(90.*CLHEP::deg, 180.*CLHEP::deg, 90.*CLHEP::deg, 90.*CLHEP::deg, 180.*CLHEP::deg, 0.);
0437       dohmCarrierReplica = 1;
0438       placeDohm=1;
0439       break;
0440     case 3:
0441       name = idName + "DOHMCarrierBW";
0442       dohmList = dohmListBW;
0443       tran = Position(0., 0., -dohmCarrierZ);
0444       rotstr = idName + "BwDown";
0445       rotation = make_rotation3D(90.*CLHEP::deg, 0., 90.*CLHEP::deg, 270.*CLHEP::deg, 180.*CLHEP::deg, 0.);
0446       dohmCarrierReplica = 2;
0447       placeDohm=0;
0448       break;
0449     }
0450 
0451     Volume dohmCarrier = ns.addVolumeNS(Volume(name,solid,ns.material(dohmCarrierMaterial)));
0452     int primReplica = 0;
0453     int auxReplica = 0;
0454 #if 0
0455     for ( size_t i = 0; i < placeDohm*dohmList.size(); i++ )   {
0456       double phi   = (std::abs(dohmList[i])+0.5-1.)*dphi;
0457       double phix  = phi + 90*CLHEP::deg;
0458       double theta = 90*CLHEP::deg;
0459       double phiy  = phix + 90.*CLHEP::deg;
0460       dohmRotation = make_rotation3D(theta, phix, theta, phiy, 0., 0.);
0461 
0462       int    dohmReplica = 0;
0463       double dohmZ = 0.;
0464       Volume dohm;
0465 
0466       if(dohmList[i]<0.) {
0467         // Place a Auxiliary DOHM
0468         dohm  = ns.volume(dohmAuxName);
0469         dohmZ = dohmCarrierDz - 0.5*dohmAuxL - dohmtoMF;
0470         primReplica++;
0471         dohmReplica = primReplica;
0472       } else {
0473         // Place a Primary DOHM
0474         dohm = ns.volume(dohmPrimName);
0475         dohmZ = dohmCarrierDz - 0.5*dohmPrimL - dohmtoMF;
0476         auxReplica++;
0477         dohmReplica = auxReplica;
0478       }
0479       Position dohmTrasl(dohmR*cos(phi), dohmR*sin(phi), dohmZ);
0480       dohmCarrier.placeVolume(dohm,dohmReplica,Transform3D(dohmRotation,dohmTrasl));
0481       LogDebug("TIBGeom") << dohm.name() 
0482           << " replica " << dohmReplica << " positioned in " 
0483           << dohmCarrier.name() << " at " << dohmTrasl << " with "
0484           << dohmRotation;
0485     }
0486 #else
0487     if ( placeDohm || primReplica || auxReplica || dohmR>0e0 )  {} // Avoid warnings
0488     LogWarn("TIBGeom") << "DOOHM placement sucks for Geant4. ERASED!";
0489 #endif
0490     layer.placeVolume(dohmCarrier, dohmCarrierReplica, Transform3D(rotation,tran));// copyNr = dohmCarrierReplica
0491     LogDebug("TIBGeom") << "DDTIBLayerAlgo test "
0492         << dohmCarrier.name() << " positioned in " << mother
0493         << " replica " << dohmCarrierReplica << " at "
0494         << tran << " with " << rotation;
0495   }
0496   //
0497   ////// PILLARS
0498   for (int j = 0; j<4; j++) {    
0499     vector<double> pillarZ;
0500     vector<double> pillarPhi;
0501     double pillarDz=0, pillarDPhi=0, pillarRin=0, pillarRout=0;
0502     
0503     switch (j){
0504     case 0:
0505       name = idName + "FWIntPillar";
0506       pillarZ    = fwIntPillarZ;
0507       pillarPhi  = fwIntPillarPhi;
0508       pillarRin  = MFRingInR;
0509       pillarRout = MFRingInR + MFRingT;
0510       pillarDz   = fwIntPillarDz;
0511       pillarDPhi = fwIntPillarDPhi;
0512       break;
0513     case 1:
0514       name = idName + "BWIntPillar";
0515       pillarZ    = bwIntPillarZ;
0516       pillarPhi  = bwIntPillarPhi;
0517       pillarRin  = MFRingInR;
0518       pillarRout = MFRingInR + MFRingT;
0519       pillarDz   = bwIntPillarDz;
0520       pillarDPhi = bwIntPillarDPhi;
0521       break;
0522     case 2:
0523       name = idName + "FWExtPillar";
0524       pillarZ    = fwExtPillarZ;
0525       pillarPhi  = fwExtPillarPhi;
0526       pillarRin  = MFRingOutR - MFRingT;
0527       pillarRout = MFRingOutR;
0528       pillarDz   = fwExtPillarDz;
0529       pillarDPhi = fwExtPillarDPhi;
0530       break;
0531     case 3:
0532       name = idName + "BWExtPillar";
0533       pillarZ    = bwExtPillarZ;
0534       pillarPhi  = bwExtPillarPhi;
0535       pillarRin  = MFRingOutR - MFRingT;
0536       pillarRout = MFRingOutR;
0537       pillarDz   = bwExtPillarDz;
0538       pillarDPhi = bwExtPillarDPhi;
0539       break;
0540     }
0541     
0542     solid = ns.addSolidNS(name,Tube(pillarRin, pillarRout, pillarDz, -pillarDPhi, 2.*pillarDPhi));    
0543     Volume Pillar = ns.addVolumeNS(Volume(name,solid,ns.material(pillarMaterial)));
0544     LogDebug("TIBGeom") << solid.name() << " Tubs made of " << pillarMaterial << " from "
0545         << -pillarDPhi << " to " << pillarDPhi << " with Rin "
0546         << pillarRin << " Rout " << pillarRout << " ZHalf "  
0547         << pillarDz;
0548     Position   pillarTran;
0549     Rotation3D pillarRota;
0550     int pillarReplica = 0;
0551     for (unsigned int i=0; i<pillarZ.size(); i++) {
0552       if( pillarPhi[i]>0. ) {
0553         pillarTran = Position(0., 0., pillarZ[i]);
0554         pillarRota = make_rotation3D(90.*CLHEP::deg, pillarPhi[i], 90.*CLHEP::deg, 90.*CLHEP::deg+pillarPhi[i], 0., 0.);
0555         layer.placeVolume(Pillar,i,Transform3D(pillarRota,pillarTran)); // copyNr i
0556         LogDebug("TIBGeom") << Pillar.name() << " positioned in " 
0557             << mother << " at "
0558             << pillarTran << " with " << pillarRota 
0559             << " copy number " << pillarReplica;
0560         pillarReplica++;
0561       }
0562     }
0563   }
0564   return 1;
0565 }
0566 
0567 // first argument is the type from the xml file
0568 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTIBLayerAlgo,algorithm)