Back to home page

EIC code displayed by LXR

 
 

    


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

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 (to be done: asym.detector placement in z)
0017 // 
0018 //==========================================================================
0019 #include "DD4hep/DetFactoryHelper.h"
0020 #include "DD4hep/Printout.h"
0021 #include "XML/Utilities.h"
0022 
0023 using namespace std;
0024 using namespace dd4hep;
0025 using namespace dd4hep::detail;
0026 
0027 static Ref_t create_element(Detector& description, xml_h e, Ref_t)  {
0028   xml_det_t  x_det  (e);
0029   string     det_name = x_det.nameStr();
0030   DetElement sdet(det_name, x_det.id());
0031   Volume     vol;
0032 
0033   bool useRot = x_det.hasChild(_U(rotation));
0034   bool usePos = x_det.hasChild(_U(position));
0035   Position    pos;
0036   RotationZYX rot;
0037 
0038   sdet.setType("compound");
0039   xml::setDetectorTypeFlag( e, sdet ) ;
0040 
0041   if( usePos ) {
0042     pos = Position(x_det.position().x(), x_det.position().y(), x_det.position().z());
0043   }
0044   if( useRot ) {
0045     rot = RotationZYX(x_det.rotation().x(), x_det.rotation().y(), x_det.rotation().z());
0046   }
0047 
0048   if ( x_det.hasChild(_U(shape)) )  {
0049     xml_comp_t x_shape = x_det.child(_U(shape));
0050     string     type  = x_shape.typeStr();
0051     Solid      solid = xml::createShape(description, type, x_shape);
0052     Material   mat   = description.material(x_shape.materialStr());
0053     printout(DEBUG,det_name,"+++ Creating detector assembly with shape of type:%s",type.c_str());
0054     vol = Volume(det_name,solid,mat);
0055   }
0056   else  {
0057     printout(DEBUG,det_name,"+++ Creating detector assembly without shape");
0058     vol = Assembly(det_name);
0059   }
0060 
0061   vol.setAttributes(description,x_det.regionStr(),x_det.limitsStr(),x_det.visStr());
0062 
0063   Volume mother = description.pickMotherVolume(sdet);
0064   PlacedVolume pv;
0065   if( useRot && usePos ){
0066     pv =  mother.placeVolume(vol, Transform3D(rot, pos));
0067   } else if( useRot ){
0068     pv =  mother.placeVolume(vol, rot);
0069   } else if( usePos ){
0070     pv =  mother.placeVolume(vol, pos);
0071   } else {
0072     pv = mother.placeVolume(vol);
0073   }
0074 
0075   sdet.setPlacement(pv);
0076   
0077   for(xml_coll_t c(x_det,_U(composite)); c; ++c)  {
0078     xml_dim_t component = c;
0079     string nam = component.nameStr();
0080     description.declareParent(nam, sdet);
0081   }
0082   return sdet;
0083 }
0084 
0085 DECLARE_DETELEMENT(Lhe_SubdetectorAssembly,create_element)