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 //  mod.:        P.Kostka LHeD (asymmetrical detector placement in z)
0017 // 
0018 //==========================================================================
0019 #include "DD4hep/DetFactoryHelper.h"
0020 #include "XML/Layering.h"
0021 
0022 using namespace std;
0023 using namespace dd4hep;
0024 using namespace dd4hep::detail;
0025 
0026 static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector sens)  {
0027   xml_det_t  x_det     = e;
0028   string     det_name  = x_det.nameStr();
0029   Material   air       = description.air();
0030   DetElement sdet        (det_name,x_det.id());
0031   Assembly   assembly    (det_name+"_assembly");
0032   PlacedVolume pv;
0033   int n = 0;
0034 
0035   for(xml_coll_t i(x_det,_U(layer)); i; ++i, ++n)  {
0036     xml_comp_t x_layer = i;
0037     string  l_name = det_name+_toString(n,"_layer%d");
0038     double  z    = x_layer.outer_z();
0039     double  rmin = x_layer.inner_r();
0040     double  r    = rmin;
0041     DetElement layer(sdet,_toString(n,"layer%d"),x_layer.id());
0042     Tube    l_tub (rmin,2*rmin,z);
0043     Volume  l_vol(l_name,l_tub,air);
0044     int im = 0;
0045 
0046     for(xml_coll_t j(x_layer,_U(slice)); j; ++j, ++im)  {
0047       xml_comp_t x_slice = j;
0048       Material mat = description.material(x_slice.materialStr());
0049       string s_name= l_name+_toString(im,"_slice%d");
0050       double thickness = x_slice.thickness();
0051       Tube   s_tub(r,r+thickness,z,2*M_PI);
0052       Volume s_vol(s_name, s_tub, mat);
0053 
0054       r += thickness;
0055       if ( x_slice.isSensitive() ) {
0056         sens.setType("tracker");
0057         s_vol.setSensitiveDetector(sens);
0058       }
0059       // Set Attributes
0060       s_vol.setAttributes(description,x_slice.regionStr(),x_slice.limitsStr(),x_slice.visStr());
0061       pv = l_vol.placeVolume(s_vol);
0062       // Slices have no extra id. Take the ID of the layer!
0063       pv.addPhysVolID("slice",im);
0064     }
0065     l_tub.setDimensions(rmin,r,z);
0066     //cout << l_name << " " << rmin << " " << r << " " << z << endl;
0067     l_vol.setVisAttributes(description,x_layer.visStr());
0068     
0069     double z_offset = x_layer.hasAttr(_U(z_offset)) ? x_layer.z_offset() : 0.0;
0070     pv = assembly.placeVolume(l_vol,Position(0,0,z_offset));
0071     pv.addPhysVolID("layer",n);
0072     layer.setPlacement(pv);
0073   }
0074   if ( x_det.hasAttr(_U(combineHits)) ) {
0075     sdet.setCombineHits(x_det.combineHits(),sens);
0076   }
0077 
0078   pv = description.pickMotherVolume(sdet).placeVolume(assembly);
0079   pv.addPhysVolID("system",sdet.id()).addPhysVolID("barrel",0);
0080   sdet.setPlacement(pv);
0081   return sdet;
0082 }
0083 
0084 DECLARE_DETELEMENT(Lhe_MultiLayerTracker,create_detector)