Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:56

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 //  mod.:        P.Kostka LHeD (asymmetrical detector placement in z)
0017 //                             ( circ-ellipt. in x,y)
0018 //==========================================================================
0019 #include "DD4hep/DetFactoryHelper.h"
0020 #include "DD4hep/Printout.h"
0021 #include "XML/Layering.h"
0022 
0023 using namespace std;
0024 using namespace dd4hep;
0025 using namespace dd4hep::detail;
0026 
0027 static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector sens)  {
0028   xml_det_t  x_det     = e;
0029   string     det_name  = x_det.nameStr();
0030   string     det_type  = x_det.typeStr();
0031   Material   air       = description.air();
0032   DetElement sdet        (det_name,x_det.id());
0033   Assembly   assembly    (det_name+"_assembly");
0034   PlacedVolume pv;
0035   int n = 0;
0036 
0037   for(xml_coll_t i(x_det,_U(layer)); i; ++i, ++n)  {
0038     xml_comp_t x_layer = i;
0039     string  l_name = det_name+_toString(n,"_layer%d");
0040     double  z    = x_layer.outer_z();
0041     double  rmin = x_layer.inner_r();
0042     double  rmax = x_layer.outer_r();
0043     double  r    = rmin;
0044     double  rmax_ell  = x_layer.rmax();
0045 
0046     double ra    = 1.;             // ellipse long radius init
0047            ra    = rmax_ell;       // ellipse long radius
0048     double rb    = 1.;             // ellipse short radius init
0049            rb    = rmin;           // ellipse short radius
0050     double thick = rmax - rmin;    // layer thickness
0051     
0052     EllipticalTube bpElTubeOut(ra+thick, rb+thick, z);
0053     EllipticalTube bpElTubeInn(ra, rb, z+0.1);
0054     SubtractionSolid bpElTube(bpElTubeOut,bpElTubeInn);
0055 
0056     Tube bpTube1(rb, rb+thick, z+0.1, 3*M_PI/2, M_PI/2);
0057     UnionSolid beamTube1(bpElTube,bpTube1);
0058 
0059     Tube bpTube2(rb+thick, ra+thick, z+0.1, 3*M_PI/2, M_PI/2);
0060     SubtractionSolid l_tub(beamTube1,bpTube2);
0061 
0062     DetElement layer(sdet,_toString(n,"layer%d"),x_layer.id());  
0063     Volume   l_vol(l_name, l_tub, air);
0064     
0065     cout << l_name << " " << rmin << " " << r << " " << z << endl;
0066     l_vol.setVisAttributes(description,x_layer.visStr());
0067     
0068     double z_offset = x_layer.hasAttr(_U(z_offset)) ? x_layer.z_offset() : 0.0;
0069     pv = assembly.placeVolume(l_vol,Position(0,0,z_offset));
0070     pv.addPhysVolID("layer",n);
0071     layer.setPlacement(pv);
0072   }
0073   if ( x_det.hasAttr(_U(combineHits)) ) {
0074     sdet.setCombineHits(x_det.combineHits(),sens);
0075   }
0076 
0077   pv = description.pickMotherVolume(sdet).placeVolume(assembly);
0078   pv.addPhysVolID("system",sdet.id()).addPhysVolID("barrel",0);
0079   sdet.setPlacement(pv);
0080   return sdet;
0081 }
0082 
0083 DECLARE_DETELEMENT(Lhe_BP_MultiLayerTracker,create_detector)