Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-18 07:52:12

0001 // SPDX-License-Identifier: LGPL-3.0-or-later
0002 // Copyright (C) 2022 Wouter Deconinck, Whitney Armstrong
0003 
0004 #include "DD4hep/DetFactoryHelper.h"
0005 #include "DD4hep/OpticalSurfaces.h"
0006 #include "DD4hep/Printout.h"
0007 #include "DDRec/DetectorData.h"
0008 #include "DDRec/Surface.h"
0009 #include <XML/Helper.h>
0010 #include <XML/Utilities.h>
0011 
0012 //////////////////////////////////////////////////
0013 // Low Q2 Tagger
0014 //////////////////////////////////////////////////
0015 
0016 using namespace std;
0017 using namespace dd4hep;
0018 
0019 static Ref_t createDetector(Detector& desc, xml_h e, SensitiveDetector sens) {
0020   xml_det_t x_det = e;
0021   string detName  = x_det.nameStr();
0022   int detID       = x_det.id();
0023 
0024   xml_dim_t dim    = x_det.dimensions();
0025   double Width     = dim.x();
0026   double Height    = dim.y();
0027   double Thickness = dim.z() / 2;
0028 
0029   xml_dim_t pos = x_det.position();
0030   // xml_dim_t  rot        = x_det.rotation();
0031 
0032   Material Vacuum   = desc.material("Vacuum");
0033   Material Silicon  = desc.material("Silicon");
0034   Material Absorber = desc.material("TungstenDens24");
0035 
0036   sens.setType("calorimeter");
0037 
0038   // Create Global Volume
0039   Box Tagger_Box(Width, Height, Thickness);
0040   Volume detVol("Tagger_Box", Tagger_Box, Vacuum);
0041   detVol.setVisAttributes(desc.visAttributes(x_det.visStr()));
0042 
0043   // Calorimeter
0044   double abso_z = 8.5 * mm; // for 20 layers
0045   double sens_z = 0.3 * mm;
0046   // double calo_start = 30*mm;
0047 
0048   for (int i = 0; i < 20; i++) {
0049 
0050     // absorber
0051     Box Abso_Box(Width, Height, abso_z / 2);
0052     Volume absoVol("AbsorberVolume", Abso_Box, Absorber);
0053     absoVol.setVisAttributes(desc.visAttributes("BlueVis"));
0054 
0055     detVol.placeVolume(absoVol, Position(0, 0, Thickness - (i) * (abso_z + sens_z) - abso_z / 2));
0056 
0057     // sensitive layer
0058     Box Cal_Box(Width, Height, sens_z / 2);
0059     Volume calVol("SensVolume", Cal_Box, Silicon);
0060     calVol.setSensitiveDetector(sens);
0061     calVol.setVisAttributes(desc.visAttributes("RedVis"));
0062 
0063     PlacedVolume pv_mod = detVol.placeVolume(
0064         calVol, Position(0, 0, Thickness - (i) * (abso_z + sens_z) - abso_z - sens_z / 2));
0065     pv_mod.addPhysVolID("layer", i + 3); // leave room for tracking IDs
0066   }
0067 
0068   // mother volume for calorimeter
0069   std::string mother_nam = dd4hep::getAttrOrDefault<std::string>(x_det, _Unicode(place_into), "");
0070   VolumeManager man      = VolumeManager::getVolumeManager(desc);
0071   DetElement mdet        = man.detector().child(mother_nam);
0072 
0073   // placement in envelope
0074   Transform3D tr(RotationZYX(0, 0, 0), Position(pos.x(), pos.y(), pos.z()));
0075   PlacedVolume detPV = mdet.volume().placeVolume(detVol, tr);
0076   detPV.addPhysVolID("system", detID);
0077   DetElement det(detName, detID);
0078   det.setPlacement(detPV);
0079 
0080   // apply any detector type flags set in XML
0081   dd4hep::xml::setDetectorTypeFlag(x_det, det);
0082 
0083   return det;
0084 }
0085 
0086 DECLARE_DETELEMENT(TaggerCalWSi, createDetector)