Back to home page

EIC code displayed by LXR

 
 

    


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

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   xml_dim_t  dim       = x_det.dimensions();
0026   Material   air       = description.air();
0027   string     det_name  = x_det.nameStr();
0028   DetElement sdet       (det_name,x_det.id());
0029   double     z         = dim.outer_z();
0030   double     rmin      = dim.inner_r();
0031   double     r         = rmin;
0032   int        n         = 0;
0033   Tube       envelope(rmin,2*rmin,2*z);
0034   Volume     envelopeVol(det_name+"_envelope",envelope,air);
0035     
0036   for(xml_coll_t c(x_det,_U(layer)); c; ++c)  {
0037     xml_comp_t x_layer = c;
0038     for(int i=0, im=0, repeat=x_layer.repeat(); i<repeat; ++i, im=0)  {
0039       string layer_name = det_name + _toString(n,"_layer%d");
0040       double rlayer = r;
0041       Tube   layer_tub(rmin,rlayer,2*z);
0042       Volume layer_vol(layer_name,layer_tub,air);
0043         
0044       for(xml_coll_t l(x_layer,_U(slice)); l; ++l, ++im)  {
0045         xml_comp_t x_slice = l;
0046         double     router = r + x_slice.thickness();
0047         Material   slice_mat  = description.material(x_slice.materialStr());
0048         string     slice_name = layer_name + _toString(im,"slice%d");
0049         Tube       slice_tube(r,router,z*2);
0050         Volume     slice_vol (slice_name,slice_tube,slice_mat);
0051           
0052         if ( x_slice.isSensitive() ) {
0053           sens.setType("calorimeter");
0054           slice_vol.setSensitiveDetector(sens);
0055         }
0056         r = router;
0057         slice_vol.setAttributes(description,x_slice.regionStr(),x_slice.limitsStr(),x_slice.visStr());
0058         // Instantiate physical volume
0059         layer_vol.placeVolume(slice_vol);
0060       }
0061       layer_vol.setVisAttributes(description,x_layer.visStr());
0062       layer_tub.setDimensions(rlayer,r,z*2,0,2*M_PI);
0063         
0064       PlacedVolume layer_physvol = envelopeVol.placeVolume(layer_vol);
0065       layer_physvol.addPhysVolID("layer",n);
0066       ++n;
0067     }
0068   }
0069   envelope.setDimensions(rmin,r,2*z);
0070   // Set region of slice
0071   envelopeVol.setAttributes(description,x_det.regionStr(),x_det.limitsStr(),x_det.visStr());
0072     
0073   PlacedVolume physvol = description.pickMotherVolume(sdet).placeVolume(envelopeVol);
0074   physvol.addPhysVolID("system",sdet.id()).addPhysVolID(_U(barrel),0);
0075   sdet.setPlacement(physvol);
0076   return sdet;
0077 }
0078 
0079 DECLARE_DETELEMENT(DD4hep_CylindricalBarrelCalorimeter,create_detector)
0080