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 //             : P.Kostka   (LHeC more refined version circ-ell BP)
0016 // 
0017 //==========================================================================
0018 #include "DD4hep/DetFactoryHelper.h"
0019 
0020 using namespace std;
0021 using namespace dd4hep;
0022 using namespace dd4hep::detail;
0023 
0024 static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector sens)  {
0025   xml_det_t  x_det     = e;
0026   Material   air       = description.air();
0027   string     det_name  = x_det.nameStr();
0028   string     det_type  = x_det.typeStr();
0029   bool       reflect   = x_det.reflect();
0030   DetElement sdet        (det_name,x_det.id());
0031   Assembly   assembly    (det_name+"_assembly");
0032   PlacedVolume pv;
0033   int l_num = 0;
0034     
0035   for(xml_coll_t i(x_det,_U(layer)); i; ++i, ++l_num)  {
0036     xml_comp_t x_layer = i;
0037     string l_nam = det_name+_toString(l_num,"_layer%d");
0038     double  zmin = x_layer.inner_z();
0039     double  rmin = x_layer.inner_r();
0040     double  rmax = x_layer.outer_r();
0041     double  z    = zmin, layerWidth = 0.;
0042     int     s_num = 0;
0043     double  rmax_ell  = x_layer.rmax();
0044 
0045     for(xml_coll_t j(x_layer,_U(slice)); j; ++j)  {
0046       double thickness = xml_comp_t(j).thickness();
0047       layerWidth += thickness;
0048     }
0049 
0050 
0051     
0052     double ra    = 1.;             // ellipse long radius init
0053            ra    = rmax_ell;       // ellipse long radius
0054     double rb    = 1.;             // ellipse short radius init
0055            rb    = rmin;           // ellipse short radius
0056     double thickl = 0.;    // layer thickness
0057            thickl = layerWidth;    // layer thickness
0058     double rdiff = rmax - rmin;    // layer thickness
0059    
0060     EllipticalTube bpElTubeOut1(ra+rdiff, rb+rdiff, thickl);
0061     EllipticalTube bpElTubeInn1(ra, rb, thickl+0.1);
0062     SubtractionSolid bpElTube1(bpElTubeOut1,bpElTubeInn1);
0063 
0064     Tube bpTube1(rb, rb+rdiff, thickl+0.1, 3*M_PI/2, M_PI/2);
0065     UnionSolid beamTube1(bpElTube1,bpTube1);
0066 
0067     Tube bpTube2(rb+rdiff, ra+rdiff, thickl+0.1, 3*M_PI/2, M_PI/2);
0068     SubtractionSolid l_tub(beamTube1,bpTube2);
0069 
0070     Volume  l_vol(l_nam,l_tub,air);
0071     l_vol.setVisAttributes(description,x_layer.visStr());
0072     for(xml_coll_t j(x_layer,_U(slice)); j; ++j, ++s_num)  {
0073       xml_comp_t x_slice = j;
0074       double thicks = x_slice.thickness();
0075       Material mat = description.material(x_slice.materialStr());
0076       string s_nam = l_nam+_toString(s_num,"_slice%d");
0077     
0078     EllipticalTube bpElTubeOut2(ra+rdiff, rb+rdiff, thickl);
0079     EllipticalTube bpElTubeInn2(ra, rb, thickl+0.1);
0080     SubtractionSolid bpElTube2(bpElTubeOut2,bpElTubeInn2);
0081 
0082     Tube bpTube3(rb, rb+rdiff, thickl+0.1, 3*M_PI/2, M_PI/2);
0083     UnionSolid beamTube2(bpElTube2,bpTube3);
0084 
0085     Tube bpTube4(rb+rdiff, ra+rdiff, thickl+0.1, 3*M_PI/2, M_PI/2);
0086     SubtractionSolid s_tub(beamTube2,bpTube4);
0087 
0088     Volume   s_vol(s_nam, s_tub, mat);
0089     s_vol.setVisAttributes(description,x_layer.visStr());
0090         
0091       if ( x_slice.isSensitive() ) {
0092         sens.setType("tracker");
0093         s_vol.setSensitiveDetector(sens);
0094        }
0095     l_vol.setAttributes(description,x_slice.regionStr(),x_slice.limitsStr(),x_slice.visStr());
0096     pv = s_vol.placeVolume(s_vol,Position(0,0,z-zmin-layerWidth/2+thicks/2));
0097     pv.addPhysVolID("slice",s_num);
0098     }
0099 
0100     DetElement layer(sdet,l_nam+"_pos",l_num);
0101     pv = assembly.placeVolume(l_vol,Position(0,0,zmin+layerWidth/2.));
0102     pv.addPhysVolID("layer",l_num);
0103     pv.addPhysVolID("barrel",1);
0104     layer.setPlacement(pv);
0105     if ( reflect )  {
0106       pv = assembly.placeVolume(l_vol,Transform3D(RotationY(2*M_PI),Position(0,0,-zmin-layerWidth/2)));
0107       pv.addPhysVolID("layer",l_num);
0108       pv.addPhysVolID("barrel",2);
0109       DetElement layerR = layer.clone(l_nam+"_neg");
0110       sdet.add(layerR.setPlacement(pv));
0111     }
0112   }
0113   if ( x_det.hasAttr(_U(combineHits)) ) {
0114     sdet.setCombineHits(x_det.attr<bool>(_U(combineHits)),sens);
0115   }
0116   pv = description.pickMotherVolume(sdet).placeVolume(assembly);
0117   pv.addPhysVolID("system", x_det.id());      // Set the subdetector system ID.
0118   sdet.setPlacement(pv);
0119   return sdet;
0120 }
0121 
0122 DECLARE_DETELEMENT(Lhe_BP_DiskTracker,create_detector)