Back to home page

EIC code displayed by LXR

 
 

    


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

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 #include "DD4hep/DetFactoryHelper.h"
0018 
0019 using namespace std;
0020 using namespace dd4hep;
0021 using namespace dd4hep::detail;
0022 
0023 static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector sens)  {
0024   xml_det_t  x_det     = e;
0025   Material   air       = description.air();
0026   string     det_name  = x_det.nameStr();
0027   bool       reflect   = x_det.reflect();
0028   DetElement sdet(det_name,x_det.id());
0029   Assembly   assembly(det_name);
0030   PlacedVolume pv;
0031   int l_num = 0;
0032     
0033   for(xml_coll_t i(x_det,_U(layer)); i; ++i, ++l_num)  {
0034     xml_comp_t x_layer = i;
0035     string l_nam = det_name+_toString(l_num,"_layer%d");
0036     double  zmin = x_layer.inner_z();
0037     double  rmin = x_layer.inner_r();
0038     double  rmax = x_layer.outer_r();
0039     double  z    = zmin, layerWidth = 0.;
0040     int     s_num = 0;
0041       
0042     for(xml_coll_t j(x_layer,_U(slice)); j; ++j)  {
0043       double thickness = xml_comp_t(j).thickness();
0044       layerWidth += thickness;
0045     }
0046     Tube    l_tub(rmin,rmax,layerWidth,2*M_PI);
0047     Volume  l_vol(l_nam,l_tub,air);
0048     l_vol.setVisAttributes(description,x_layer.visStr());
0049     for(xml_coll_t j(x_layer,_U(slice)); j; ++j, ++s_num)  {
0050       xml_comp_t x_slice = j;
0051       double thick = x_slice.thickness();
0052       Material mat = description.material(x_slice.materialStr());
0053       string s_nam = l_nam+_toString(s_num,"_slice%d");
0054       Volume s_vol(s_nam, Tube(rmin,rmax,thick), mat);
0055         
0056       if ( x_slice.isSensitive() ) {
0057         sens.setType("tracker");
0058         s_vol.setSensitiveDetector(sens);
0059       }
0060       s_vol.setAttributes(description,x_slice.regionStr(),x_slice.limitsStr(),x_slice.visStr());
0061       pv = l_vol.placeVolume(s_vol,Position(0,0,z-zmin-layerWidth/2+thick/2));
0062       pv.addPhysVolID("slice",s_num);
0063     }
0064 
0065     DetElement layer(sdet,l_nam+"_pos",l_num);
0066     pv = assembly.placeVolume(l_vol,Position(0,0,zmin+layerWidth/2.));
0067     pv.addPhysVolID("layer",l_num);
0068     pv.addPhysVolID("barrel",1);
0069     layer.setPlacement(pv);
0070     if ( reflect )  {
0071       pv = assembly.placeVolume(l_vol,Transform3D(RotationY(M_PI),Position(0,0,-zmin-layerWidth/2)));
0072       pv.addPhysVolID("layer",l_num);
0073       pv.addPhysVolID("barrel",2);
0074       DetElement layerR = layer.clone(l_nam+"_neg");
0075       sdet.add(layerR.setPlacement(pv));
0076     }
0077   }
0078   if ( x_det.hasAttr(_U(combineHits)) ) {
0079     sdet.setCombineHits(x_det.attr<bool>(_U(combineHits)),sens);
0080   }
0081   pv = description.pickMotherVolume(sdet).placeVolume(assembly);
0082   pv.addPhysVolID("system", x_det.id());      // Set the subdetector system ID.
0083   sdet.setPlacement(pv);
0084   return sdet;
0085 }
0086 
0087 DECLARE_DETELEMENT(Lhe_DiskTracker,create_detector)