Back to home page

EIC code displayed by LXR

 
 

    


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

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     : F.Gaede
0011 //
0012 //==========================================================================
0013 #include "DD4hep/Detector.h"
0014 #include "DD4hep/Factories.h"
0015 #include "DD4hep/DD4hepUnits.h" 
0016 
0017 #include "DDRec/DetectorData.h"
0018 #include "DDRec/DDGear.h"
0019 #include "DDRec/MaterialManager.h"
0020 
0021 #include "DDRec/Vector3D.h"
0022 
0023 #include "gearimpl/TPCParametersImpl.h"
0024 #include "gearimpl/FixedPadSizeDiskLayout.h"
0025 #include "gearimpl/ZPlanarParametersImpl.h"
0026 #include "gearimpl/FTDParametersImpl.h"
0027 #include "gearimpl/CalorimeterParametersImpl.h"
0028 
0029 #include <iostream>
0030 
0031 namespace dd4hep{
0032   namespace rec{
0033     
0034     using namespace detail ;
0035 
0036     /** Plugin that creates Gear objects for DetElements and attaches them 
0037      *  as extensions. Called from DDGear::createGearMgr().
0038      *  NB: this code is for backward compatibility to run 
0039      *  the old reconstruction that expects Gear information
0040      *  and should eventually be phased out.
0041      * 
0042      *  @author F.Gaede, CERN/DESY
0043      *  @date Oct 2014
0044      *  @version $Id$
0045      *
0046      *  Minimal plugin for SiD solely to be used with LCCalibration
0047      *  adapted from the ILD and CLIC plugins
0048      *  @author D.Protopopescu, Glasgow
0049      *  @date Nov 2017
0050      *
0051      */
0052     
0053     static long createGearForSiD(Detector& description, int /*argc*/, char** /*argv*/) {
0054       
0055       std::cout << " **** running plugin createGearForSiD ! " <<  std::endl ;
0056       
0057       try {
0058     
0059     DetElement coilDE = description.detector("Solenoid") ;
0060     
0061     gear::GearParametersImpl* gearCOIL = new gear::GearParametersImpl();
0062     
0063     Tube coilTube = Tube( coilDE.volume().solid() )  ;
0064     
0065     gearCOIL->setDoubleVal("Coil_cryostat_inner_radius" , coilTube->GetRmin()/ dd4hep::mm ) ;
0066     gearCOIL->setDoubleVal("Coil_cryostat_outer_radius" , coilTube->GetRmax()/ dd4hep::mm ) ;
0067     gearCOIL->setDoubleVal("Coil_cryostat_half_z"       , coilTube->GetDZ()/ dd4hep::mm ) ;
0068     
0069     coilDE.addExtension< GearHandle >( new GearHandle( gearCOIL, "CoilParameters" ) ) ;
0070     
0071       } catch( std::runtime_error& e ){  
0072     std::cerr << " >>>> " << e.what() << std::endl ;
0073       } 
0074         
0075       //========= CALO ONLY ==============================================================
0076 
0077       //**********************************************************
0078       //*  gear interface w/ LayeredCalorimeterData extension
0079       //**********************************************************
0080 
0081       std::map< std::string, std::string > caloMap ;
0082       caloMap["HCalBarrel"] = "HcalBarrelParameters" ; 
0083       caloMap["HCalEndcap"] = "HcalEndcapParameters" ;
0084       caloMap["ECalBarrel"] = "EcalBarrelParameters" ;
0085       caloMap["ECalEndcap"] = "EcalEndcapParameters" ;
0086       caloMap["MuonBarrel"] = "YokeBarrelParameters" ;
0087       caloMap["MuonEndcap"] = "YokeEndcapParameters" ;
0088       caloMap["LumiCal"]    = "LcalParameters" ;
0089       caloMap["BeamCal"]    = "BeamCalParameters" ;
0090       
0091       for( std::map< std::string, std::string >::const_iterator it = caloMap.begin() ; it != caloMap.end() ; ++it ){
0092 
0093     try {
0094 
0095       DetElement caloDE = description.detector( it->first ) ;
0096     
0097       LayeredCalorimeterData* calo = caloDE.extension<LayeredCalorimeterData>() ;
0098       
0099       gear::CalorimeterParametersImpl* gearCalo = 
0100         ( calo->layoutType == LayeredCalorimeterData::BarrelLayout  ?
0101           new gear::CalorimeterParametersImpl(  calo->extent[0]/dd4hep::mm, calo->extent[3]/dd4hep::mm, calo->inner_symmetry, calo->inner_phi0 )  :
0102           //CalorimeterParametersImpl (double rMin, double zMax, int symOrder=8, double phi0=0.0) - C'tor for a cylindrical (octagonal) BARREL calorimeter.
0103           new gear::CalorimeterParametersImpl(  calo->extent[0]/dd4hep::mm,  calo->extent[1]/dd4hep::mm,  calo->extent[2]/dd4hep::mm, calo->outer_symmetry, calo->outer_phi0 )   ) ;
0104       //CalorimeterParametersImpl (double rMin, double rMax, double zMin, int symOrder=2, double phi0=0.0) - C'tor for a cylindrical (octagonal) ENDCAP calorimeter. 
0105       
0106       for( unsigned i=0, nL = calo->layers.size() ; i <nL ; ++i ){
0107         
0108         LayeredCalorimeterData::Layer& l = calo->layers[i] ;
0109                     
0110             //Do some arithmetic to get thicknesses and (approximate) absorber thickneses from "new" rec structures
0111             //The positioning should come out right, but the absorber thickness should be overestimated due to the presence of 
0112             //other less dense material
0113         if( i == 0 ) {
0114             //First layer is positioned with only its inner thickness taken into account
0115           gearCalo->layerLayout().positionLayer( l.distance/dd4hep::mm, (l.inner_thickness+l.sensitive_thickness/2.)/dd4hep::mm , 
0116                              l.cellSize0/dd4hep::mm, l.cellSize1/dd4hep::mm, (l.inner_thickness-l.sensitive_thickness/2.)/dd4hep::mm ) ;
0117         } else if ( i == nL -1 ) {
0118           //Need to handle outermost layer differently; add its outer thickness
0119           //This gives the right extent, but the "wrong" distance for the last layer
0120           gearCalo->layerLayout().addLayer((l.inner_thickness+l.outer_thickness+calo->layers[i-1].outer_thickness-calo->layers[i-1].sensitive_thickness/2.)/dd4hep::mm , 
0121                            l.cellSize0/dd4hep::mm, l.cellSize1/dd4hep::mm, (l.inner_thickness+l.outer_thickness-l.sensitive_thickness+calo->layers[i-1].outer_thickness-calo->layers[i-1].sensitive_thickness/2.)/dd4hep::mm) ;
0122         } else {
0123           //All other layers need to be added taking into account the previous layer outer thicknesses
0124           gearCalo->layerLayout().addLayer((l.inner_thickness+l.sensitive_thickness/2.+calo->layers[i-1].outer_thickness-calo->layers[i-1].sensitive_thickness/2.)/dd4hep::mm , 
0125                            l.cellSize0/dd4hep::mm, l.cellSize1/dd4hep::mm, (l.inner_thickness-l.sensitive_thickness/2.+calo->layers[i-1].outer_thickness-calo->layers[i-1].sensitive_thickness/2.)/dd4hep::mm) ;
0126         }   
0127       }
0128     
0129       if( it->first == "HCalBarrel" ){
0130         // additional parameters needed by MarlinPandora
0131         gearCalo->setIntVal("Hcal_outer_polygon_order"   , calo->outer_symmetry  ) ;
0132         gearCalo->setDoubleVal("Hcal_outer_polygon_phi0" ,  calo->outer_phi0 ) ;
0133       }
0134           
0135       caloDE.addExtension< GearHandle >( new GearHandle( gearCalo, it->second ) ) ;
0136 
0137     } catch( std::runtime_error& e ){  
0138       std::cerr << " >>>> " << e.what() << std::endl ;
0139     } 
0140 
0141       } // calo loop 
0142 
0143       // --- Detector::apply() expects return code 1 if all went well ! ----
0144       return 1;
0145     }
0146   }
0147 }
0148 DECLARE_APPLY( GearForSiD, dd4hep::rec::createGearForSiD )
0149 
0150