Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022 Dhevan Gangadharan
0003 
0004 #include "DD4hep/DetFactoryHelper.h"
0005 #include "DD4hep/Printout.h"
0006 #include <XML/Helper.h>
0007 
0008 using namespace std;
0009 using namespace dd4hep;
0010 
0011 static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector sens) {
0012   sens.setType("tracker");
0013 
0014   xml_det_t x_det = e;
0015   string det_name = x_det.nameStr();
0016   int det_ID      = x_det.id();
0017   string vis_Si   = getAttrOrDefault<string>(x_det, _Unicode(vis), "TrackerVis");
0018   string vis_Cu   = getAttrOrDefault<string>(x_det, _Unicode(visCu), "TrackerServiceVis");
0019   string Si_name  = getAttrOrDefault<string>(x_det, _Unicode(materialSi), "SiliconOxide");
0020   string Cu_name  = getAttrOrDefault<string>(x_det, _Unicode(materialCu), "Copper");
0021   double Si_DZ    = getAttrOrDefault<double>(x_det, _Unicode(thicknessSi), 0.03 / 2.0);
0022   double Cu_DZ    = getAttrOrDefault<double>(x_det, _Unicode(thicknessCu), 0.014 / 2.0);
0023 
0024   Material m_Si = description.material(Si_name);
0025   Material m_Cu = description.material(Cu_name);
0026 
0027   // Create main detector element to be returned at the end
0028   DetElement det(det_name, det_ID);
0029 
0030   // Mother volume
0031   Volume motherVol = description.pickMotherVolume(det);
0032 
0033   // Detector assembly
0034   Assembly assembly(det_name);
0035   assembly.setVisAttributes(description.invisible());
0036 
0037   // Build detector components
0038   // loop over modules
0039   for (xml_coll_t mi(x_det, _Unicode(module)); mi; mi++) { // modules
0040 
0041     xml_comp_t x_mod(mi);
0042     int module_id = x_mod.id();
0043 
0044     // loop over sectors within each module
0045     for (xml_coll_t si(mi, _Unicode(sector)); si; si++) { // sectors
0046 
0047       xml_comp_t x_sector(si);
0048       int sector_id = x_sector.id();
0049       string name   = getAttrOrDefault<string>(x_sector, _Unicode(name), "");
0050 
0051       double posX  = x_sector.position().x();
0052       double posY  = x_sector.position().y();
0053       double posZ  = x_sector.position().z();
0054       double sizeX = x_sector.dimensions().x();
0055       double sizeY = x_sector.dimensions().y();
0056 
0057       // Silicon sensor
0058       Box box_Si(sizeX, sizeY, Si_DZ);
0059       Volume vol_Si(det_name + "_" + name, box_Si, m_Si);
0060       vol_Si.setVisAttributes(description.visAttributes(vis_Si));
0061       vol_Si.setSensitiveDetector(sens);
0062 
0063       // Cu layer to approximate ASICs/cooling
0064       Box box_Cu(sizeX, sizeY, Cu_DZ);
0065       Volume vol_Cu(det_name + "_" + name + "_Cu", box_Cu, m_Cu);
0066       vol_Cu.setVisAttributes(description.visAttributes(vis_Cu));
0067 
0068       // place into assembly
0069       PlacedVolume pv = assembly.placeVolume(
0070           vol_Si, Transform3D(RotationZYX(0.0, 0.0, 0.0), Position(posX, posY, posZ)));
0071       assembly.placeVolume(vol_Cu, Transform3D(RotationZYX(0.0, 0.0, 0.0),
0072                                                Position(posX, posY, posZ - (Si_DZ + Cu_DZ))));
0073 
0074       // Connect sector and module IDs
0075       pv.addPhysVolID("sector", sector_id).addPhysVolID("module", module_id);
0076 
0077     } // sectors
0078   } // modules
0079 
0080   // Place assembly into mother volume.  Assembly is centered at origin
0081   PlacedVolume detPV = motherVol.placeVolume(assembly, Position(0.0, 0.0, 0.0));
0082 
0083   // Connect system ID
0084   detPV.addPhysVolID("system", det_ID);
0085 
0086   det.setPlacement(detPV);
0087 
0088   return det;
0089 }
0090 
0091 DECLARE_DETELEMENT(LumiSpecTracker, create_detector)