Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /DD4hep/examples/DDCMS/src/plugins/DDPixBarLayerAlgo.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, ParsingContext& ctxt, xml_h e, SensitiveDetector& /* sens */)  {
0027   PlacedVolume  pv;
0028   Namespace     ns(ctxt, e, true);
0029   AlgoArguments args(ctxt, e);
0030   string        parentName = args.parentName();
0031 
0032   LogDebug("PixelGeom") << "+++ Parsing arguments for Algorithm:" <<  args.name
0033                         << " rParent:" << parentName;
0034   string genMat    = args.value<string>("GeneralMaterial");
0035   int    number    = args.value<int>("Ladders");
0036   double layerDz   = args.value<double>("LayerDz");
0037   double sensorEdge= args.value<double>("SensorEdge");
0038   double coolDz    = args.value<double>("CoolDz");
0039   double coolWidth = args.value<double>("CoolWidth");
0040   double coolSide  = args.value<double>("CoolSide");
0041   double coolThick = args.value<double>("CoolThick");
0042   double coolDist  = args.value<double>("CoolDist");
0043   string coolMat   = args.value<string>("CoolMaterial");
0044   string tubeMat   = args.value<string>("CoolTubeMaterial");
0045   LogDebug("PixelGeom") << "Parent " << parentName << " NameSpace " << ns.name << "\n"
0046       << "\tLadders " << number << "\tGeneral Material " 
0047       << genMat << "\tLength " << layerDz << "\tSensorEdge "
0048       << sensorEdge << "\tSpecification of Cooling Pieces:\n"
0049       << "\tLength " << coolDz << " Width " << coolWidth 
0050       << " Side " << coolSide << " Thickness of Shell " 
0051       << coolThick << " Radial distance " << coolDist 
0052       << " Materials " << coolMat << ", " << tubeMat;
0053   vector<string> ladder      = args.value<vector<string> >("LadderName");
0054   vector<double> ladderWidth = args.value<vector<double> >("LadderWidth");
0055   vector<double> ladderThick = args.value<vector<double> >("LadderThick");
0056   LogDebug("PixelGeom") << "Full Ladder " << ladder[0] << " width/thickness " << ladderWidth[0]
0057       << ", " << ladderThick[0] << "\tHalf Ladder " 
0058       << ladder[1] << " width/thickness " << ladderWidth[1]
0059       << ", " << ladderThick[1];
0060 
0061   const std::string idName = ns.obj_name(parentName);
0062   double dphi = CLHEP::twopi/number;
0063   double d2   = 0.5*coolWidth;
0064   double d1   = d2 - coolSide*sin(0.5*dphi);
0065   double x1   = (d1+d2)/(2.*sin(0.5*dphi));
0066   double x2   = coolDist*sin(0.5*dphi);
0067   double rmin = (coolDist-0.5*(d1+d2))*cos(0.5*dphi)-0.5*ladderThick[0];
0068   double rmax = (coolDist+0.5*(d1+d2))*cos(0.5*dphi)+0.5*ladderThick[0];
0069   double rmxh = rmax - 0.5*ladderThick[0] + ladderThick[1];
0070   LogDebug("PixelGeom") << "Rmin/Rmax " << rmin 
0071       << ", " << rmax << " d1/d2 " << d1 << ", " << d2 
0072       << " x1/x2 " << x1 << ", " << x2;
0073 
0074   double rtmi = rmin + 0.5*ladderThick[0] - ladderThick[1];
0075   double rtmx = sqrt(rmxh*rmxh+ladderWidth[1]*ladderWidth[1]);
0076   Solid solid = ns.addSolid(idName,Tube(rtmi, rtmx, 0.5*layerDz, 0, CLHEP::twopi));
0077   LogDebug("PixelGeom") << "IDname "<< idName << " Tubs made of " 
0078       << genMat << " from 0 to " << CLHEP::twopi/CLHEP::deg 
0079       << " with Rin " << rtmi << " Rout " << rtmx 
0080       << " ZHalf " << 0.5*layerDz;
0081   
0082   Volume layer = ns.addVolume(Volume(idName, solid, ns.material(genMat)));
0083   double rr = 0.5*(rmax+rmin);
0084   double dr = 0.5*(rmax-rmin);
0085   double h1 = 0.5*coolSide*cos(0.5*dphi);
0086   std::string name = idName + "CoolTube";
0087   solid = ns.addSolid(name,Trap(0.5*coolDz, 0, 0, h1, d2, d1, 0, h1, d2, d1, 0));
0088   LogDebug("PixelGeom") << "Solid " << solid.name() 
0089       << " Trap made of " << tubeMat << " of dimensions " 
0090       << 0.5*coolDz << ", 0, 0, " << h1 << ", " << d2 
0091       << ", " << d1 << ", 0, " << h1 << ", " << d2 << ", " 
0092       << d1 << ", 0";
0093 
0094   Volume coolTube = ns.addVolume(Volume(name, solid, description.material(tubeMat)));
0095   h1  -= coolThick;
0096   d1  -= coolThick;
0097   d2  -= coolThick;
0098   name = idName + "Coolant";
0099   solid = ns.addSolid(name, Trap(0.5*coolDz, 0, 0, h1, d2, d1, 0, h1, d2, d1, 0));
0100   LogDebug("PixelGeom") << "Solid " << solid.name() 
0101       << " Trap made of " << coolMat << " of dimensions " 
0102       << 0.5*coolDz << ", 0, 0, " << h1 << ", " << d2
0103       << ", " << d1 << ", 0, " << h1 << ", " << d2 << ", " 
0104       << d1 << ", 0";
0105 
0106   Volume cool = ns.addVolume(Volume(name, solid, description.material(coolMat)));
0107   pv = coolTube.placeVolume(cool,1);
0108   LogDebug("PixelGeom") << "Cool " << cool.name() 
0109       << " number 1 positioned in " << coolTube.name() 
0110       << " at (0,0,0) with no rotation";
0111 
0112   string ladderFull = ladder[0];
0113   string ladderHalf = ladder[1];
0114   int nphi=number/2, copy=1, iup=-1;
0115   double phi0 = 90*CLHEP::deg;
0116   Volume ladderHalfVol = ns.volume(ladderHalf);
0117   Volume ladderFullVol = ns.volume(ladderFull);
0118 
0119   for (int i=0; i<number; i++) {
0120     double phi = phi0 + i*dphi;
0121     double phix, phiy, rrr, xx;
0122     std::string rots;
0123     Position    tran;
0124     Rotation3D rot;
0125     if (i == 0 || i == nphi) {
0126       rrr  = rr + dr + 0.5*(ladderThick[1]-ladderThick[0]);
0127       xx   = (0.5*ladderWidth[1] - sensorEdge) * sin(phi);
0128       tran = Position(xx, rrr*sin(phi), 0);
0129       rots = idName + std::to_string(copy);
0130       phix = phi-90*CLHEP::deg;
0131       phiy = 90*CLHEP::deg+phix;
0132       LogDebug("PixelGeom") << "Creating a new "
0133           << "rotation: " << rots << "\t90., " 
0134           << phix/CLHEP::deg << ", 90.," << phiy/CLHEP::deg 
0135           << ", 0, 0";
0136       rot = make_rotation3D(90*CLHEP::deg, phix, 90*CLHEP::deg, phiy, 0.,0.);
0137 
0138       //cpv.position(ladderHalf, layer, copy, tran, rot);
0139       pv = layer.placeVolume(ladderHalfVol, copy, Transform3D(rot,tran));
0140       if ( !pv.isValid() )  {  }
0141       LogDebug("PixelGeom") << "ladderHalfVol: " << ladderHalfVol.name()
0142           << " number " << copy << " positioned in " 
0143           << layer.name() << " at " << tran << " with " 
0144           << rot;
0145       copy++;
0146       iup  = -1;
0147       rrr  = rr - dr - 0.5*(ladderThick[1]-ladderThick[0]);
0148       tran = Position(-xx, rrr*sin(phi), 0);
0149       rots = idName + std::to_string(copy);
0150       phix = phi+90*CLHEP::deg;
0151       phiy = 90*CLHEP::deg+phix;
0152       LogDebug("PixelGeom") << "Creating a new rotation: " << rots << "\t90., " 
0153           << phix/CLHEP::deg << ", 90.," << phiy/CLHEP::deg 
0154           << ", 0, 0";
0155       rot = make_rotation3D(90*CLHEP::deg, phix, 90*CLHEP::deg, phiy, 0.,0.);
0156       //cpv.position(ladderHalf, layer, copy, tran, rot);
0157       pv = layer.placeVolume(ladderHalfVol, copy, Transform3D(rot,tran));
0158       if ( !pv.isValid() )  {  }
0159       LogDebug("PixelGeom") << "ladderHalfVol: " << ladderHalfVol.name()
0160           << " number " << copy << " positioned in " 
0161           << layer.name() << " at " << tran << " with " 
0162           << rot;
0163       copy++;
0164     } else {
0165       iup  =-iup;
0166       rrr  = rr + iup*dr;
0167       tran = Position(rrr*cos(phi), rrr*sin(phi), 0);
0168       rots = idName + std::to_string(copy);
0169       if (iup > 0) phix = phi-90*CLHEP::deg;
0170       else         phix = phi+90*CLHEP::deg;
0171       phiy = phix+90.*CLHEP::deg;
0172       LogDebug("PixelGeom") << "DDPixBarLayerAlgo test: Creating a new "
0173           << "rotation: " << rots << "\t90., " 
0174           << phix/CLHEP::deg << ", 90.," << phiy/CLHEP::deg 
0175           << ", 0, 0";
0176       rot = make_rotation3D(90*CLHEP::deg, phix, 90*CLHEP::deg, phiy, 0.,0.);
0177 
0178       //cpv.position(ladderFull, layer, copy, tran, rot);
0179       pv = layer.placeVolume(ladderFullVol, copy, Transform3D(rot,tran));
0180       if ( !pv.isValid() )  {  }
0181       LogDebug("PixelGeom") << "test: " << ladderFullVol.name()
0182           << " number " << copy << " positioned in " 
0183           << layer.name() << " at " << tran << " with " 
0184           << rot;
0185       copy++;
0186     }
0187     rrr  = coolDist*cos(0.5*dphi);
0188     tran = Position(rrr*cos(phi)-x2*sin(phi), rrr*sin(phi)+x2*cos(phi), 0);
0189     rots = idName + std::to_string(i+100);
0190     phix = phi+0.5*dphi;
0191     if (iup > 0) phix += 180*CLHEP::deg;
0192     phiy = phix+90.*CLHEP::deg;
0193     LogDebug("PixelGeom") << "Creating a new rotation: " << rots << "\t90., " 
0194         << phix/CLHEP::deg << ", 90.," << phiy/CLHEP::deg 
0195         << ", 0, 0";
0196     
0197     rot = make_rotation3D(90*CLHEP::deg, phix, 90*CLHEP::deg, phiy, 0.,0.);
0198     pv  = layer.placeVolume(coolTube, i+1, Transform3D(rot,tran));
0199     if ( !pv.isValid() )  {  }
0200     LogDebug("PixelGeom") << "coolTube: " << coolTube.name() 
0201         << " number " << i+1 << " positioned in " 
0202         << layer.name() << " at " << tran << " with "<< rot;
0203   }
0204   LogDebug("PixelGeom") << "Layer: " << layer.name();
0205   return 1;
0206 }
0207 
0208 // first argument is the type from the xml file
0209 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDPixBarLayerAlgo,algorithm)
0210