Back to home page

EIC code displayed by LXR

 
 

    


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

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 // Include files
0015 #include "JSON/Helper.h"
0016 #include "DD4hep/Printout.h"
0017 #include "DD4hep/Detector.h"
0018 
0019 #include <iostream>
0020 #include <map>
0021 
0022 using namespace std;
0023 using namespace dd4hep;
0024 using namespace dd4hep::detail;
0025 
0026 namespace  {
0027 
0028   struct MyDetExtension  {
0029     int idD, Ni, Nj;
0030     double posDX, posDY, posDZ;
0031     double dimDX, dimDY, dimDZ;
0032     double pixelX, pixelY, pixelZ;
0033     DetElement detector;
0034 
0035     MyDetExtension(DetElement e) : idD(0), Ni(0), Nj(0),
0036         posDX(0.0), posDY(0.0), posDZ(0.0),
0037         dimDX(0.0), dimDY(0.0), dimDZ(0.0),
0038         pixelX(0.0), pixelY(0.0), pixelZ(0.0), detector(e) {}
0039     MyDetExtension(const MyDetExtension& e, DetElement d) 
0040       : idD(e.idD), Ni(e.Ni), Nj(e.Nj),
0041         posDX(e.posDX), posDY(e.posDY), posDZ(e.posDZ),
0042         dimDX(e.dimDX), dimDY(e.dimDY), dimDZ(e.dimDZ),
0043         pixelX(e.pixelX), pixelY(e.pixelY), pixelZ(e.pixelZ),
0044         detector(d)                            
0045     {
0046     }
0047   };
0048 }
0049 typedef MyDetExtension DetectorExtension;
0050 
0051 static Ref_t create_detector(Detector &description, json_h e, SensitiveDetector sens)  {
0052   json_det_t x_det = e;                 //json-detelemnt of the detector taken as an argument
0053   string det_name = x_det.nameStr();    //det_name is the name of the json-detelement
0054   Assembly assembly (det_name);
0055   int detectors_id = x_det.id();
0056 
0057   DetElement sdet(det_name,x_det.id());        //sdet is the detelement of the detector!!(actually is a Handle,already a pointer to m_element)
0058   DetectorExtension* ext = new MyDetExtension(sdet);
0059   sdet.addExtension<MyDetExtension>(ext);
0060   ext->idD= detectors_id;
0061 
0062   json_comp_t det_po = x_det.child(_U(position));
0063 
0064   double det_y = det_po.y();     // det_y is the y dimension of the json-detelement
0065   double det_x = det_po.x();     // det_x is the x dimension of  the json-detelement
0066   double det_z = det_po.z();     // det_z is the z dimension of the json-detelement
0067   ext->posDY = det_y;
0068   ext->posDX = det_x;
0069   ext->posDZ = det_z;
0070 
0071   json_comp_t det_dim = x_det.child(_U(dimensions));
0072   double dim_x = det_dim.x();    // det_x is the x dimension of  the json-detelement
0073   double dim_y = det_dim.y();    // det_y is the y dimension of the json-detelement
0074   double dim_z = det_dim.z();    // det_z is the z dimension of the json-detelement
0075 
0076   Material mat = description.material("Silicon");
0077 
0078   Volume motherVol = description.pickMotherVolume(sdet); //the mothers volume of our detector
0079 
0080   PlacedVolume pv;  //struct of Handle giving the volume id(ayto pou 8a kanw volume kai 8a to steilw me setplacement),dld o detector mou
0081   json_comp_t dtc_mod = x_det.child(_U(module));        // considering the module-pixel of the detector
0082   double pixelX = dtc_mod.x();  // The x dimension of the module
0083   double pixelY = dtc_mod.y();  // The y dimension of the module
0084   double pixelZ = dtc_mod.z();  // The z dimension of the module
0085 
0086   int Ni = dim_x/pixelX;         // how many pixels in the x dimension
0087   int Nj = dim_y/pixelY;
0088 
0089   ext->dimDX = dim_x;
0090   ext->dimDY = dim_y;
0091   ext->dimDZ = dim_z;
0092   ext->pixelX = pixelX;
0093   ext->pixelY = pixelY;
0094   ext->pixelZ = pixelZ;
0095   ext->Ni= Ni;
0096   ext->Nj= Nj;
0097 
0098 
0099   Volume m_volume(det_name, Box(dim_x, dim_y, dim_z), mat); //as parameters it needs name,solid,material
0100   m_volume.setVisAttributes(description.visAttributes(x_det.visStr())); //I DONT MIND ABOUT THIS!
0101   pv = motherVol.placeVolume(m_volume,Transform3D(Position(det_x,det_y,det_z)));  //det_x,det_y,det_z are the dimensions of the detector in space
0102 
0103   json_comp_t dtctr = x_det;
0104   if ( dtctr.isSensitive() ) {
0105     sens.setType("tracker");
0106     pv.addPhysVolID("system",detectors_id);
0107     m_volume.setSensitiveDetector(sens);
0108   }
0109   sdet.setPlacement(pv);
0110   // Support additional test if Detector_InhibitConstants is set to TRUE
0111   description.constant<double>("world_side");
0112   return sdet;
0113 }
0114 
0115 DECLARE_JSON_DETELEMENT(MiniTelPixel_json,create_detector)