File indexing completed on 2025-01-18 09:14:35
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
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
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053 static long createGearForSiD(Detector& description, int , char** ) {
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
0076
0077
0078
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
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
0105
0106 for( unsigned i=0, nL = calo->layers.size() ; i <nL ; ++i ){
0107
0108 LayeredCalorimeterData::Layer& l = calo->layers[i] ;
0109
0110
0111
0112
0113 if( i == 0 ) {
0114
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
0119
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
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
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 }
0142
0143
0144 return 1;
0145 }
0146 }
0147 }
0148 DECLARE_APPLY( GearForSiD, dd4hep::rec::createGearForSiD )
0149
0150