Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:16:00

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 
0011 //////////////////////////////////////////////////
0012 // Low Q2 Tagger
0013 //////////////////////////////////////////////////
0014 
0015 using namespace std;
0016 using namespace dd4hep;
0017 
0018 static Ref_t createDetector(Detector& desc, xml_h e, SensitiveDetector sens) {
0019   xml_det_t x_det = e;
0020   string detName  = x_det.nameStr();
0021   int detID       = x_det.id();
0022 
0023   xml_dim_t dim    = x_det.dimensions();
0024   double Width     = dim.x();
0025   double Height    = dim.y();
0026   double Thickness = dim.z() / 2;
0027 
0028   xml_dim_t pos = x_det.position();
0029   // xml_dim_t  rot        = x_det.rotation();
0030 
0031   Material Vacuum   = desc.material("Vacuum");
0032   Material Silicon  = desc.material("Silicon");
0033   Material Absorber = desc.material("TungstenDens24");
0034 
0035   sens.setType("calorimeter");
0036 
0037   // Create Global Volume
0038   Box Tagger_Box(Width, Height, Thickness);
0039   Volume detVol("Tagger_Box", Tagger_Box, Vacuum);
0040   detVol.setVisAttributes(desc.visAttributes(x_det.visStr()));
0041 
0042   // Calorimeter
0043   double abso_z = 8.5 * mm; // for 20 layers
0044   double sens_z = 0.3 * mm;
0045   // double calo_start = 30*mm;
0046 
0047   for (int i = 0; i < 20; i++) {
0048 
0049     // absorber
0050     Box Abso_Box(Width, Height, abso_z / 2);
0051     Volume absoVol("AbsorberVolume", Abso_Box, Absorber);
0052     absoVol.setVisAttributes(desc.visAttributes("BlueVis"));
0053 
0054     detVol.placeVolume(absoVol, Position(0, 0, Thickness - (i) * (abso_z + sens_z) - abso_z / 2));
0055 
0056     // sensitive layer
0057     Box Cal_Box(Width, Height, sens_z / 2);
0058     Volume calVol("SensVolume", Cal_Box, Silicon);
0059     calVol.setSensitiveDetector(sens);
0060     calVol.setVisAttributes(desc.visAttributes("RedVis"));
0061 
0062     PlacedVolume pv_mod = detVol.placeVolume(
0063         calVol, Position(0, 0, Thickness - (i) * (abso_z + sens_z) - abso_z - sens_z / 2));
0064     pv_mod.addPhysVolID("layer", i + 3); // leave room for tracking IDs
0065   }
0066 
0067   // mother volume for calorimeter
0068   std::string mother_nam = dd4hep::getAttrOrDefault<std::string>(x_det, _Unicode(place_into), "");
0069   VolumeManager man      = VolumeManager::getVolumeManager(desc);
0070   DetElement mdet        = man.detector().child(mother_nam);
0071 
0072   // placement in envelope
0073   Transform3D tr(RotationZYX(0, 0, 0), Position(pos.x(), pos.y(), pos.z()));
0074   PlacedVolume detPV = mdet.volume().placeVolume(detVol, tr);
0075   detPV.addPhysVolID("system", detID);
0076   DetElement det(detName, detID);
0077   det.setPlacement(detPV);
0078 
0079   return det;
0080 }
0081 
0082 DECLARE_DETELEMENT(TaggerCalWSi, createDetector)