CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/Geometry/EcalCommonData/src/DDEcalAPDAlgo.cc

Go to the documentation of this file.
00001 #include <cmath>
00002 #include <algorithm>
00003 
00004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00005 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
00006 #include "DetectorDescription/Core/interface/DDSolid.h"
00007 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
00008 #include "DetectorDescription/Base/interface/DDTranslation.h"
00009 #include "Geometry/EcalCommonData/interface/DDEcalAPDAlgo.h"
00010 
00011 DDEcalAPDAlgo::DDEcalAPDAlgo() :
00012   m_vecCerPos    ( ),
00013   m_APDHere      (0),
00014 
00015   m_capName      (""),
00016   m_capMat       (""),
00017   m_capXSize     (0),
00018   m_capYSize     (0),
00019   m_capThick     (0),
00020 
00021   m_CERName      (""),
00022   m_CERMat       (""),
00023   m_CERXSize     (0),
00024   m_CERYSize     (0),
00025   m_CERThick     (0),
00026 
00027   m_BSiName      (""),
00028   m_BSiMat       (""),
00029   m_BSiXSize     (0),
00030   m_BSiYSize     (0),
00031   m_BSiThick     (0),
00032 
00033   m_APDName      (""),
00034   m_APDMat       (""),
00035   m_APDSide      (0),
00036   m_APDThick     (0),
00037   m_APDZ         (0),
00038   m_APDX1        (0),
00039   m_APDX2        (0),
00040 
00041   m_ATJName      (""),
00042   m_ATJMat       (""),
00043   m_ATJThick     (0),
00044 
00045   m_SGLName      (""),
00046   m_SGLMat       (""),
00047   m_SGLThick     (0),
00048 
00049   m_AGLName      (""),
00050   m_AGLMat       (""),
00051   m_AGLThick     (0),
00052 
00053   m_ANDName      (""),
00054   m_ANDMat       (""),
00055   m_ANDThick     (0) {
00056 
00057   LogDebug("EcalGeom") << "DDEcalAPDAlgo info: Creating an instance" ;
00058 }
00059 
00060 DDEcalAPDAlgo::~DDEcalAPDAlgo() {}
00061 
00062 void DDEcalAPDAlgo::initialize(const DDNumericArguments      & nArgs,
00063                                const DDVectorArguments       & vArgs,
00064                                const DDMapArguments          & mArgs,
00065                                const DDStringArguments       & sArgs,
00066                                const DDStringVectorArguments & vsArgs) {
00067 
00068   LogDebug("EcalGeom") << "DDEcalAPDAlgo info: Initialize" ;
00069 
00070   m_idNameSpace = parent().name().ns();
00071 
00072   m_vecCerPos= vArgs["CerPos" ] ;
00073   m_APDHere  = (int)(nArgs["APDHere"]) ;
00074 
00075   m_capName  = sArgs["CapName"] ;
00076   m_capMat   = sArgs["CapMat"] ;
00077   m_capXSize = nArgs["CapXSize"] ;
00078   m_capYSize = nArgs["CapYSize"] ;
00079   m_capThick = nArgs["CapThick"] ;
00080 
00081   m_CERName  = sArgs["CerName"] ;
00082   m_CERMat   = sArgs["CerMat"] ;
00083   m_CERXSize = nArgs["CerXSize"] ;
00084   m_CERYSize = nArgs["CerYSize"] ;
00085   m_CERThick = nArgs["CerThick"] ;
00086 
00087   m_BSiName  = sArgs["BSiName"] ;
00088   m_BSiMat   = sArgs["BSiMat"] ;
00089   m_BSiXSize = nArgs["BSiXSize"] ;
00090   m_BSiYSize = nArgs["BSiYSize"] ;
00091   m_BSiThick = nArgs["BSiThick"] ;
00092 
00093   m_APDName  = sArgs["APDName"] ;
00094   m_APDMat   = sArgs["APDMat"] ;
00095   m_APDSide  = nArgs["APDSide"] ;
00096   m_APDThick = nArgs["APDThick"] ;
00097   m_APDZ     = nArgs["APDZ"] ;
00098   m_APDX1    = nArgs["APDX1"] ;
00099   m_APDX2    = nArgs["APDX2"] ;
00100 
00101   m_ATJName  = sArgs["ATJName"] ;
00102   m_ATJMat   = sArgs["ATJMat"] ;
00103   m_ATJThick = nArgs["ATJThick"] ;
00104 
00105   m_SGLName  = sArgs["SGLName"] ;
00106   m_SGLMat   = sArgs["SGLMat"] ;
00107   m_SGLThick = nArgs["SGLThick"] ;
00108 
00109   m_AGLName  = sArgs["AGLName"] ;
00110   m_AGLMat   = sArgs["AGLMat"] ;
00111   m_AGLThick = nArgs["AGLThick"] ;
00112 
00113   m_ANDName  = sArgs["ANDName"] ;
00114   m_ANDMat   = sArgs["ANDMat"] ;
00115   m_ANDThick = nArgs["ANDThick"] ;
00116    
00117   LogDebug("EcalGeom") << "DDEcalAPDAlgo info: end initialize" ;
00118 }
00119 
00121 // DDEcalBarrelAlgo methods...
00123 
00124 void DDEcalAPDAlgo::execute(DDCompactView& cpv) {
00125 
00126   LogDebug("EcalGeom") << "******** DDEcalAPDAlgo execute!" << std::endl ;
00127 
00128 //++++++++++++++++++++++++++++++++++  APD ++++++++++++++++++++++++++++++++++
00129   const DDName        capDDName (capName().name()) ;
00130 
00131   DDSolid capSolid ( DDSolidFactory::box( capDDName, capXSize()/2.,
00132                                           capYSize()/2., capThick()/2. ) ) ;
00133          
00134   const unsigned int copyCAP ( 1 ) ;
00135          
00136   const DDLogicalPart capLog ( capDDName, capMat(), capSolid ) ;
00137 
00138   const DDName        sglDDName ( sglName().name()) ;
00139 
00140   DDSolid sglSolid ( DDSolidFactory::box( sglDDName, capXSize()/2.,
00141                                           capYSize()/2., sglThick()/2. ) ) ;
00142 
00143   const DDLogicalPart sglLog ( sglDDName, sglMat(), sglSolid ) ;
00144          
00145   const unsigned int copySGL ( 1 ) ;
00146 
00147   const DDName        cerDDName ( cerName().name() ) ;
00148 
00149   DDSolid cerSolid ( DDSolidFactory::box( cerDDName, cerXSize()/2.,
00150                                           cerYSize()/2., cerThick()/2. ) ) ;
00151 
00152   const DDLogicalPart cerLog ( cerDDName, cerMat(), cerSolid ) ;
00153          
00154   const unsigned int copyCER ( 1 ) ;
00155 
00156   const DDName        bsiDDName ( bsiName().name() ) ;
00157 
00158   DDSolid bsiSolid ( DDSolidFactory::box( bsiDDName, bsiXSize()/2.,
00159                                           bsiYSize()/2., bsiThick()/2. ) ) ;
00160 
00161   const DDLogicalPart bsiLog ( bsiDDName, bsiMat(), bsiSolid ) ;
00162          
00163   const unsigned int copyBSi ( 1 ) ;
00164 
00165   const DDName        atjDDName ( atjName().name() ) ;
00166 
00167   DDSolid atjSolid ( DDSolidFactory::box( atjDDName, apdSide()/2.,
00168                                           apdSide()/2., atjThick()/2. ) ) ;
00169 
00170   const DDLogicalPart atjLog ( atjDDName, atjMat(), atjSolid ) ;
00171          
00172   const unsigned int copyATJ ( 1 ) ;
00173 
00174   const DDName        aglDDName ( aglName().name() ) ;
00175 
00176   DDSolid aglSolid ( DDSolidFactory::box( aglDDName, bsiXSize()/2.,
00177                                           bsiYSize()/2., aglThick()/2. ) ) ;
00178 
00179   const DDLogicalPart aglLog ( aglDDName, aglMat(), aglSolid ) ;
00180          
00181   const unsigned int copyAGL ( 1 ) ;
00182 
00183   const DDName        andDDName ( andName().name() ) ;
00184 
00185   DDSolid andSolid ( DDSolidFactory::box( andDDName, apdSide()/2.,
00186                                           apdSide()/2., andThick()/2. ) ) ;
00187 
00188   const DDLogicalPart andLog ( andDDName, andMat(), andSolid ) ;
00189   
00190   const unsigned int copyAND ( 1 ) ;
00191   
00192   const DDName        apdDDName ( apdName().name() ) ;
00193 
00194   DDSolid apdSolid ( DDSolidFactory::box( apdDDName, apdSide()/2.,
00195                                          apdSide()/2., apdThick()/2. ) ) ;
00196 
00197   const DDLogicalPart apdLog ( apdDDName, apdMat(), apdSolid ) ;
00198          
00199   const unsigned int copyAPD ( 1 ) ;
00200  
00201   if ( 0 != apdHere() ) { 
00202     cpv.position(aglLog, bsiLog, copyAGL, 
00203                  DDTranslation(0,0,-aglThick()/2.+bsiThick()/2.),DDRotation());
00204 
00205     cpv.position(andLog, bsiLog, copyAND, 
00206                  DDTranslation(0, 0, -andThick()/2.-aglThick()+bsiThick()/2.),
00207                  DDRotation() ) ;
00208 
00209     cpv.position(apdLog, bsiLog, copyAPD, 
00210                  DDTranslation(0,0,-apdThick()/2.-andThick()-aglThick()+bsiThick()/2.),
00211                  DDRotation() ) ;
00212 
00213     cpv.position(atjLog, bsiLog, copyATJ, 
00214                  DDTranslation(0,0,-atjThick()/2.-apdThick()-andThick()-aglThick()+bsiThick()/2. ),
00215                  DDRotation() ) ;
00216 
00217     cpv.position(bsiLog, cerLog, copyBSi, 
00218                  DDTranslation(0,0,-bsiThick()/2.+cerThick()/2.),DDRotation());
00219 
00220     cpv.position(sglLog, capLog, copySGL, 
00221                  DDTranslation(0,0,-sglThick()/2.+capThick()/2.),DDRotation());
00222 
00223     cpv.position(cerLog, capLog, copyCER, 
00224                  DDTranslation(0,0,-sglThick()-cerThick()/2.+capThick()/2.),
00225                  DDRotation() ) ;
00226 
00227     cpv.position(capLog, parent().name(), copyCAP, 
00228                  DDTranslation(vecCerPos()[0],vecCerPos()[1],vecCerPos()[2]),
00229                  DDRotation() ) ;
00230   }
00231 
00232   LogDebug("EcalGeom") << "******** DDEcalAPDAlgo test: end it..." ;
00233 }
00234 
00235 DDName DDEcalAPDAlgo::ddname( const std::string& s ) const { 
00236 
00237   const std::pair<std::string,std::string> temp ( DDSplit(s) ) ;
00238   if ( temp.second == "" ) {
00239     return DDName( temp.first, m_idNameSpace ) ;
00240   } else {
00241     return DDName( temp.first, temp.second );
00242   } 
00243 }