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) 2023 Anna B. Kowalewska
0003 
0004 #include "DD4hep/DetFactoryHelper.h"
0005 #include "DD4hep/Printout.h"
0006 #include "DD4hep/Shapes.h"
0007 #include "DDRec/DetectorData.h"
0008 #include "DDRec/Surface.h"
0009 #include "XML/Layering.h"
0010 #include <XML/Helper.h>
0011 
0012 using namespace std;
0013 using namespace dd4hep;
0014 
0015 static Ref_t create_detector(Detector& desc, xml_h e, SensitiveDetector sens) {
0016   sens.setType("calorimeter");
0017 
0018   xml_det_t x_det  = e;
0019   xml_comp_t x_dim = x_det.dimensions();
0020   xml_comp_t x_pos = x_det.position();
0021   xml_comp_t x_rot = x_det.rotation();
0022   //
0023   string det_name = x_det.nameStr();
0024   string mat_name = dd4hep::getAttrOrDefault<string>(x_det, _U(material), "PbWO4");
0025   int det_ID      = x_det.id();
0026   DetElement det(det_name, det_ID);
0027   //
0028   double sizeX = x_dim.x();
0029   double sizeY = x_dim.y();
0030   double sizeZ = x_dim.z();
0031   double posX  = x_pos.x();
0032   double posY  = x_pos.y();
0033   double posZ  = x_pos.z();
0034   double rotX  = x_rot.x();
0035   double rotY  = x_rot.y();
0036   double rotZ  = x_rot.z();
0037 
0038   Box box(sizeX, sizeY, sizeZ);
0039   Volume vol(det_name + "_vol", box, desc.material(mat_name));
0040   vol.setVisAttributes(desc.visAttributes(x_det.visStr()));
0041   vol.setSensitiveDetector(sens);
0042 
0043   Transform3D pos(RotationZYX(rotX, rotY, rotZ), Position(posX, posY, posZ));
0044 
0045   Volume motherVol = desc.pickMotherVolume(det);
0046   PlacedVolume phv = motherVol.placeVolume(vol, pos);
0047   phv.addPhysVolID("system", det_ID);
0048   det.setPlacement(phv);
0049   return det;
0050 }
0051 
0052 DECLARE_DETELEMENT(LumiDirectPCAL, create_detector)