Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //====================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------
0004 //
0005 //  Generic cylindric shell detector to be used to measure 
0006 //  e.g. escape energy from calorimeters.
0007 //
0008 //  Author     : M.Frank
0009 //
0010 //====================================================================
0011 
0012 /*
0013   Example XML:
0014 
0015   <detector id="2" name="ContainmentShell" type="ZylinderShell" vis="VisibleRed" readout="ContainmentHits" >
0016       <comment>Containment shell to measure calorimeter escapes</comment>
0017       <material name="Air"/>
0018       <module name="Barrel" id="0" vis="VisibleRed">
0019         <zplane rmin="HcalBarrel_rmax+20*cm" rmax="HcalBarrel_rmax+22*cm" z="-2*HcalBarrel_zmax"/>
0020         <zplane rmin="HcalBarrel_rmax+20*cm" rmax="HcalBarrel_rmax+22*cm" z="2*HcalBarrel_zmax"/>
0021       </module>
0022       <module name="SideA" id="1" vis="VisibleRed">
0023         <zplane rmin="0" rmax="HcalBarrel_rmax+22*cm" z="2*HcalBarrel_zmax+10*cm"/>
0024         <zplane rmin="0" rmax="HcalBarrel_rmax+22*cm" z="2*HcalBarrel_zmax+20*cm"/>
0025       </module>
0026       <module name="SideB" id="2" vis="VisibleRed">
0027         <zplane rmin="0" rmax="HcalBarrel_rmax+22*cm" z="-(2*HcalBarrel_zmax+10*cm)"/>
0028         <zplane rmin="0" rmax="HcalBarrel_rmax+22*cm" z="-(2*HcalBarrel_zmax+20*cm)"/>
0029       </module>
0030     </detector>
0031   </detectors>
0032 
0033 to be joined by a sensitive detector:
0034   <readouts>
0035     <readout name="ContainmentHits">
0036       <id>system:8,barrel:3</id>
0037     </readout>
0038   </readouts>
0039 
0040 
0041 */
0042 #include "DD4hep/DetFactoryHelper.h"
0043 
0044 using namespace std;
0045 using namespace dd4hep;
0046 using namespace dd4hep::detail;
0047 
0048 static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector sensitive)  {
0049   xml_det_t  x_det   = e;
0050   string     name    = x_det.nameStr();
0051   DetElement sdet   (name,x_det.id());
0052   Assembly   assembly(name+"_assembly");
0053   Material   mat    (description.material(x_det.materialStr()));
0054   PlacedVolume pv;
0055 
0056   sensitive.setType("escape_counter");
0057   for(xml_coll_t xm(e,_U(module)); xm; ++xm)  {
0058     xml_comp_t mod = xm;
0059     vector<double> rmin,rmax,z;
0060     string vis = mod.visStr().empty() ? x_det.visStr() : mod.visStr();
0061     int num = 0;
0062     for(xml_coll_t c(mod,_U(zplane)); c; ++c, ++num)  {
0063       xml_comp_t dim(c);
0064       rmin.push_back(dim.rmin());
0065       rmax.push_back(dim.rmax());
0066       z.push_back(dim.z()/2);
0067     }
0068     if ( num < 2 )  {
0069       throw runtime_error("ZylinderShell["+name+"]> Not enough Z planes. minimum is 2!");
0070     }
0071     Polycone   cone  (0.,2*M_PI,rmin,rmax,z);
0072     Volume     volume(name, cone, mat);
0073     volume.setVisAttributes(description, vis);
0074     volume.setSensitiveDetector(sensitive);
0075     pv = assembly.placeVolume(volume);
0076     pv.addPhysVolID("barrel",mod.id());
0077   }
0078 
0079   pv = description.pickMotherVolume(sdet).placeVolume(assembly);
0080   pv.addPhysVolID("system",x_det.id());
0081   sdet.setPlacement(pv);
0082   return sdet;
0083 }
0084 
0085 DECLARE_DETELEMENT(Lhe_CylinderShell,create_detector)