Back to home page

EIC code displayed by LXR

 
 

    


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

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_element(Detector& description, xml_h e, SensitiveDetector sens)  {
0024   xml_det_t   x_det = e;
0025   string      name  = x_det.nameStr();
0026   Volume      vol   = Assembly(name+"_envelope");
0027   DetElement  det (name,x_det.id());
0028 
0029   xml_det_t    x_station = x_det.child(_U(station));
0030   xml_comp_t   x_station_box (x_station.child(_U(box)));
0031   xml_dim_t    x_station_pos (x_station.child(_U(position)));
0032   Box          dbox  (x_station_box.x(), x_station_box.y(), x_station_box.z());
0033   Volume       dvol  (name+"_vol_1", dbox, description.air());
0034   DetElement   det1 = DetElement(det, name+"_1", x_station.id());
0035   DetElement   det2 = DetElement(det, name+"_2", x_station.id());
0036   Position     dpos1 (x_station_pos.x(), x_station_pos.y(), x_station_pos.z());
0037   PlacedVolume phv  = vol.placeVolume(dvol, dpos1);
0038 
0039   Position     dpos2 (-x_station_pos.x(), -x_station_pos.y(), -x_station_pos.z());
0040   phv  = vol.placeVolume(dvol, dpos2);
0041   phv.addPhysVolID("station", 1);
0042 
0043   dvol.setAttributes(description, x_station.regionStr(), x_station.limitsStr(), x_station.visStr());
0044   det1.setPlacement(phv);
0045   det2.setPlacement(phv);
0046 
0047   int lnum = 0;
0048   Material si = description.material("Silicon");
0049   for(xml_coll_t i(x_station,_U(module)); i; ++i, ++lnum)  {
0050     xml_comp_t   x_module = i;
0051     xml_dim_t    x_module_pos(x_module.child(_U(position)));
0052     string       lnam = _toString(lnum,"layer%d");
0053     Position     lpos(x_module_pos.x(), x_module_pos.y(), x_module_pos.z());
0054     Volume       lvol(lnam, Box(x_module.x(), x_module.y(), x_module.z()), si);
0055     PlacedVolume lpl = dvol.placeVolume(lvol, lpos);
0056     DetElement   lde(lnam, lnum);
0057 
0058     lvol.setSensitiveDetector(sens);
0059     lvol.setAttributes(description, x_module.regionStr(), x_module.limitsStr(), x_module.visStr());
0060 
0061     lde.setPlacement(lpl);
0062     det1.add(lde);
0063     det2.add(lde);
0064     lpl.addPhysVolID("module", lnum);
0065   }
0066 
0067   vol.setAttributes(description, x_det.regionStr(), x_det.limitsStr(), x_det.visStr());
0068   phv = description.pickMotherVolume(det).placeVolume(vol);
0069   phv.addPhysVolID("system",x_det.id());
0070   det.setPlacement(phv);
0071   
0072   if ( x_det.isSensitive() )   {
0073     sens.setType("tracker");
0074   }
0075   return det;
0076 }
0077 
0078 DECLARE_DETELEMENT(DD4hep_IllDetector,create_element)
0079