Back to home page

EIC code displayed by LXR

 
 

    


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

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 // Specialized generic detector constructor
0015 // 
0016 //==========================================================================
0017 #include "DD4hep/DetFactoryHelper.h"
0018 #include "DD4hep/Printout.h"
0019 
0020 using namespace std;
0021 using namespace dd4hep;
0022 using namespace dd4hep::detail;
0023 
0024 
0025 static Ref_t create_element(Detector& description, xml_h e, Ref_t sens)  {
0026   xml_det_t  x_det  (e);
0027   xml_comp_t x_envelope = x_det.envelope();
0028   xml_dim_t  pos        = x_det.position();
0029   xml_dim_t  rot        = x_det.rotation();
0030   string     det_name   = x_det.nameStr();
0031   DetElement sdet(det_name,x_det.id());
0032   double     env_angle  = x_envelope.angle();
0033   double     env_dz     = x_envelope.dz()/2.0;
0034   double     sin_cone   = std::sin(std::atan(x_envelope.rmax()/env_dz/2.0));
0035   //Cone       env_cone(env_dz,0,0.0001,x_envelope.rmax(),x_envelope.rmax()+0.0001);
0036   //Volume     env_vol (det_name,env_cone,description.air());
0037   // If the cone should be removed and replaced by an assembly,
0038   // comment the upper to and enable the lower line
0039   Assembly   env_vol(det_name);
0040   PlacedVolume pv;
0041   SensitiveDetector sd = sens;
0042 
0043   sd.setType("tracker");
0044   // Set visualization, limits and region (if present)
0045   env_vol.setRegion(description, x_det.regionStr());
0046   env_vol.setLimitSet(description, x_det.limitsStr());
0047   env_vol.setVisAttributes(description, x_det.visStr());
0048   printout(INFO,"CODEX-b","%s beam-angle=%g atan(cone)=%g",
0049            det_name.c_str(), env_angle, std::atan(x_envelope.rmax()/env_dz/2.0));
0050 
0051   Tube tub(0, 3, x_envelope.dz()+500);
0052   Volume tub_vol(det_name+"_Tube", tub, description.air());
0053   tub_vol.setVisAttributes(description, "BlackVis");
0054   pv = env_vol.placeVolume(tub_vol, Position(0,0,0));
0055 
0056   int num_sensitive = 1;
0057   for(xml_coll_t i(x_det,_U(shield)); i; ++i)  {
0058     xml_comp_t shield = i;
0059     double     z  = shield.z(), dz = shield.dz();
0060     double     r1 = sin_cone*z, r2 = sin_cone*(z+dz);
0061     string     nam = det_name+"_"+shield.nameStr();
0062     Cone       con(dz/2., 0., r1, 0., r2);
0063     Material   mat(description.material(shield.attr<string>(_U(material))));
0064     Volume     vol(nam,con,mat);
0065 
0066     printout(INFO,"CODEX-b","%s Shield: %-12s %-12s z=%7g dz=%7g r1=%7g r2=%7g",
0067              det_name.c_str(), vol.name(), ('['+string(mat.name())+']').c_str(), z, dz, r1, r2);
0068     vol.setVisAttributes(description, shield.visStr());
0069     pv = env_vol.placeVolume(vol, Position(0,0,-env_dz+z+dz/2.0));
0070     if ( shield.isSensitive() )   {
0071       DetElement det(sdet, "shield_"+nam, x_det.id());
0072       vol.setSensitiveDetector(sd);
0073 //      pv.addPhysVolID("type", 0);
0074       pv.addPhysVolID("station", num_sensitive);
0075       det.setPlacement(pv);
0076       ++num_sensitive;
0077     }
0078   }
0079 
0080   Volume mother = description.pickMotherVolume(sdet);
0081   Transform3D trafo(RotationZYX(rot.z(),rot.y(),rot.x()),Position(-pos.x(),-pos.y(),pos.z()));
0082   Direction dir = trafo*Direction(0,0,1.);
0083   pv = mother.placeVolume(env_vol,trafo);
0084   if ( x_det.hasAttr(_U(id)) )  {
0085     pv.addPhysVolID("system",x_det.id());
0086   }
0087   printout(INFO,det_name,"+++ Need to shot in direction: (x,y,z) = (%g,%g,%g)",dir.X(),dir.Y(),dir.Z());
0088   sdet.setPlacement(pv);
0089   return sdet;
0090 }
0091 
0092 DECLARE_DETELEMENT(DD4hep_CODEXb_shield,create_element)
0093