Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:08:00

0001 #include <cmath>
0002 #include <algorithm>
0003 
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0006 #include "DetectorDescription/Core/interface/DDSolid.h"
0007 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
0008 #include "DetectorDescription/Core/interface/DDTranslation.h"
0009 #include <string>
0010 #include <vector>
0011 
0012 #include "DetectorDescription/Core/interface/DDTypes.h"
0013 #include "DetectorDescription/Core/interface/DDName.h"
0014 #include "DetectorDescription/Core/interface/DDAlgorithm.h"
0015 #include "DetectorDescription/Core/interface/DDMaterial.h"
0016 #include "DetectorDescription/Core/interface/DDSplit.h"
0017 #include "DetectorDescription/Core/interface/DDTransform.h"
0018 
0019 class DDEcalAPDAlgo : public DDAlgorithm {
0020 public:
0021   //Constructor and Destructor
0022   DDEcalAPDAlgo();
0023   ~DDEcalAPDAlgo() override;
0024 
0025   void initialize(const DDNumericArguments& nArgs,
0026                   const DDVectorArguments& vArgs,
0027                   const DDMapArguments& mArgs,
0028                   const DDStringArguments& sArgs,
0029                   const DDStringVectorArguments& vsArgs) override;
0030   void execute(DDCompactView& cpv) override;
0031 
0032 protected:
0033 private:
0034   DDName ddname(const std::string& s) const;
0035 
0036   const std::vector<double>& vecCerPos() const { return m_vecCerPos; }
0037   int apdHere() const { return m_APDHere; }
0038 
0039   DDName capName() const { return ddname(m_capName); }
0040   DDMaterial capMat() const { return DDMaterial(ddname(m_capMat)); }
0041   double capXSize() const { return m_capXSize; }
0042   double capYSize() const { return m_capYSize; }
0043   double capThick() const { return m_capThick; }
0044 
0045   DDName cerName() const { return ddname(m_CERName); }
0046   DDMaterial cerMat() const { return DDMaterial(ddname(m_CERMat)); }
0047   double cerXSize() const { return m_CERXSize; }
0048   double cerYSize() const { return m_CERYSize; }
0049   double cerThick() const { return m_CERThick; }
0050 
0051   DDName bsiName() const { return ddname(m_BSiName); }
0052   DDMaterial bsiMat() const { return DDMaterial(ddname(m_BSiMat)); }
0053   double bsiXSize() const { return m_BSiXSize; }
0054   double bsiYSize() const { return m_BSiYSize; }
0055   double bsiThick() const { return m_BSiThick; }
0056 
0057   DDName sglName() const { return ddname(m_SGLName); }
0058   DDMaterial sglMat() const { return DDMaterial(ddname(m_SGLMat)); }
0059   double sglThick() const { return m_SGLThick; }
0060 
0061   DDName atjName() const { return ddname(m_ATJName); }
0062   DDMaterial atjMat() const { return DDMaterial(ddname(m_ATJMat)); }
0063   double atjThick() const { return m_ATJThick; }
0064 
0065   DDName aglName() const { return ddname(m_AGLName); }
0066   DDMaterial aglMat() const { return DDMaterial(ddname(m_AGLMat)); }
0067   double aglThick() const { return m_AGLThick; }
0068 
0069   DDName andName() const { return ddname(m_ANDName); }
0070   DDMaterial andMat() const { return DDMaterial(ddname(m_ANDMat)); }
0071   double andThick() const { return m_ANDThick; }
0072 
0073   DDName apdName() const { return ddname(m_APDName); }
0074   DDMaterial apdMat() const { return DDMaterial(ddname(m_APDMat)); }
0075   double apdSide() const { return m_APDSide; }
0076   double apdThick() const { return m_APDThick; }
0077   double apdZ() const { return m_APDZ; }
0078   double apdX1() const { return m_APDX1; }
0079   double apdX2() const { return m_APDX2; }
0080 
0081 private:
0082   std::string m_idNameSpace;  //Namespace of this and ALL sub-parts
0083 
0084   std::vector<double> m_vecCerPos;  // Translation
0085   int m_APDHere;
0086 
0087   std::string m_capName;  // Capsule
0088   std::string m_capMat;   //
0089   double m_capXSize;      //
0090   double m_capYSize;      //
0091   double m_capThick;      //
0092 
0093   std::string m_CERName;  // Ceramic
0094   std::string m_CERMat;   //
0095   double m_CERXSize;      //
0096   double m_CERYSize;      //
0097   double m_CERThick;      //
0098 
0099   std::string m_BSiName;  // Bulk Silicon
0100   std::string m_BSiMat;   //
0101   double m_BSiXSize;      //
0102   double m_BSiYSize;      //
0103   double m_BSiThick;      //
0104 
0105   std::string m_APDName;  // APD
0106   std::string m_APDMat;   //
0107   double m_APDSide;       //
0108   double m_APDThick;      //
0109   double m_APDZ;          //
0110   double m_APDX1;         //
0111   double m_APDX2;         //
0112 
0113   std::string m_ATJName;  // After-The-Junction
0114   std::string m_ATJMat;   //
0115   double m_ATJThick;      //
0116 
0117   std::string m_SGLName;  // APD-Silicone glue
0118   std::string m_SGLMat;   //
0119   double m_SGLThick;      //
0120 
0121   std::string m_AGLName;  // APD-Glue
0122   std::string m_AGLMat;   //
0123   double m_AGLThick;      //
0124 
0125   std::string m_ANDName;  // APD-Non-Depleted
0126   std::string m_ANDMat;   //
0127   double m_ANDThick;      //
0128 };
0129 
0130 DDEcalAPDAlgo::DDEcalAPDAlgo()
0131     : m_vecCerPos(),
0132       m_APDHere(0),
0133 
0134       m_capName(""),
0135       m_capMat(""),
0136       m_capXSize(0),
0137       m_capYSize(0),
0138       m_capThick(0),
0139 
0140       m_CERName(""),
0141       m_CERMat(""),
0142       m_CERXSize(0),
0143       m_CERYSize(0),
0144       m_CERThick(0),
0145 
0146       m_BSiName(""),
0147       m_BSiMat(""),
0148       m_BSiXSize(0),
0149       m_BSiYSize(0),
0150       m_BSiThick(0),
0151 
0152       m_APDName(""),
0153       m_APDMat(""),
0154       m_APDSide(0),
0155       m_APDThick(0),
0156       m_APDZ(0),
0157       m_APDX1(0),
0158       m_APDX2(0),
0159 
0160       m_ATJName(""),
0161       m_ATJMat(""),
0162       m_ATJThick(0),
0163 
0164       m_SGLName(""),
0165       m_SGLMat(""),
0166       m_SGLThick(0),
0167 
0168       m_AGLName(""),
0169       m_AGLMat(""),
0170       m_AGLThick(0),
0171 
0172       m_ANDName(""),
0173       m_ANDMat(""),
0174       m_ANDThick(0) {
0175   LogDebug("EcalGeom") << "DDEcalAPDAlgo info: Creating an instance";
0176 }
0177 
0178 DDEcalAPDAlgo::~DDEcalAPDAlgo() {}
0179 
0180 void DDEcalAPDAlgo::initialize(const DDNumericArguments& nArgs,
0181                                const DDVectorArguments& vArgs,
0182                                const DDMapArguments& mArgs,
0183                                const DDStringArguments& sArgs,
0184                                const DDStringVectorArguments& vsArgs) {
0185   LogDebug("EcalGeom") << "DDEcalAPDAlgo info: Initialize";
0186 
0187   m_idNameSpace = parent().name().ns();
0188 
0189   m_vecCerPos = vArgs["CerPos"];
0190   m_APDHere = (int)(nArgs["APDHere"]);
0191 
0192   m_capName = sArgs["CapName"];
0193   m_capMat = sArgs["CapMat"];
0194   m_capXSize = nArgs["CapXSize"];
0195   m_capYSize = nArgs["CapYSize"];
0196   m_capThick = nArgs["CapThick"];
0197 
0198   m_CERName = sArgs["CerName"];
0199   m_CERMat = sArgs["CerMat"];
0200   m_CERXSize = nArgs["CerXSize"];
0201   m_CERYSize = nArgs["CerYSize"];
0202   m_CERThick = nArgs["CerThick"];
0203 
0204   m_BSiName = sArgs["BSiName"];
0205   m_BSiMat = sArgs["BSiMat"];
0206   m_BSiXSize = nArgs["BSiXSize"];
0207   m_BSiYSize = nArgs["BSiYSize"];
0208   m_BSiThick = nArgs["BSiThick"];
0209 
0210   m_APDName = sArgs["APDName"];
0211   m_APDMat = sArgs["APDMat"];
0212   m_APDSide = nArgs["APDSide"];
0213   m_APDThick = nArgs["APDThick"];
0214   m_APDZ = nArgs["APDZ"];
0215   m_APDX1 = nArgs["APDX1"];
0216   m_APDX2 = nArgs["APDX2"];
0217 
0218   m_ATJName = sArgs["ATJName"];
0219   m_ATJMat = sArgs["ATJMat"];
0220   m_ATJThick = nArgs["ATJThick"];
0221 
0222   m_SGLName = sArgs["SGLName"];
0223   m_SGLMat = sArgs["SGLMat"];
0224   m_SGLThick = nArgs["SGLThick"];
0225 
0226   m_AGLName = sArgs["AGLName"];
0227   m_AGLMat = sArgs["AGLMat"];
0228   m_AGLThick = nArgs["AGLThick"];
0229 
0230   m_ANDName = sArgs["ANDName"];
0231   m_ANDMat = sArgs["ANDMat"];
0232   m_ANDThick = nArgs["ANDThick"];
0233 
0234   LogDebug("EcalGeom") << "DDEcalAPDAlgo info: end initialize";
0235 }
0236 
0237 ////////////////////////////////////////////////////////////////////
0238 // DDEcalBarrelAlgo methods...
0239 ////////////////////////////////////////////////////////////////////
0240 
0241 void DDEcalAPDAlgo::execute(DDCompactView& cpv) {
0242   LogDebug("EcalGeom") << "******** DDEcalAPDAlgo execute!" << std::endl;
0243 
0244   //++++++++++++++++++++++++++++++++++  APD ++++++++++++++++++++++++++++++++++
0245   const DDName capDDName(capName().name());
0246 
0247   DDSolid capSolid(DDSolidFactory::box(capDDName, capXSize() / 2., capYSize() / 2., capThick() / 2.));
0248 
0249   const unsigned int copyCAP(1);
0250 
0251   const DDLogicalPart capLog(capDDName, capMat(), capSolid);
0252 
0253   const DDName sglDDName(sglName().name());
0254 
0255   DDSolid sglSolid(DDSolidFactory::box(sglDDName, capXSize() / 2., capYSize() / 2., sglThick() / 2.));
0256 
0257   const DDLogicalPart sglLog(sglDDName, sglMat(), sglSolid);
0258 
0259   const unsigned int copySGL(1);
0260 
0261   const DDName cerDDName(cerName().name());
0262 
0263   DDSolid cerSolid(DDSolidFactory::box(cerDDName, cerXSize() / 2., cerYSize() / 2., cerThick() / 2.));
0264 
0265   const DDLogicalPart cerLog(cerDDName, cerMat(), cerSolid);
0266 
0267   const unsigned int copyCER(1);
0268 
0269   const DDName bsiDDName(bsiName().name());
0270 
0271   DDSolid bsiSolid(DDSolidFactory::box(bsiDDName, bsiXSize() / 2., bsiYSize() / 2., bsiThick() / 2.));
0272 
0273   const DDLogicalPart bsiLog(bsiDDName, bsiMat(), bsiSolid);
0274 
0275   const unsigned int copyBSi(1);
0276 
0277   const DDName atjDDName(atjName().name());
0278 
0279   DDSolid atjSolid(DDSolidFactory::box(atjDDName, apdSide() / 2., apdSide() / 2., atjThick() / 2.));
0280 
0281   const DDLogicalPart atjLog(atjDDName, atjMat(), atjSolid);
0282 
0283   const unsigned int copyATJ(1);
0284 
0285   const DDName aglDDName(aglName().name());
0286 
0287   DDSolid aglSolid(DDSolidFactory::box(aglDDName, bsiXSize() / 2., bsiYSize() / 2., aglThick() / 2.));
0288 
0289   const DDLogicalPart aglLog(aglDDName, aglMat(), aglSolid);
0290 
0291   const unsigned int copyAGL(1);
0292 
0293   const DDName andDDName(andName().name());
0294 
0295   DDSolid andSolid(DDSolidFactory::box(andDDName, apdSide() / 2., apdSide() / 2., andThick() / 2.));
0296 
0297   const DDLogicalPart andLog(andDDName, andMat(), andSolid);
0298 
0299   const unsigned int copyAND(1);
0300 
0301   const DDName apdDDName(apdName().name());
0302 
0303   DDSolid apdSolid(DDSolidFactory::box(apdDDName, apdSide() / 2., apdSide() / 2., apdThick() / 2.));
0304 
0305   const DDLogicalPart apdLog(apdDDName, apdMat(), apdSolid);
0306 
0307   const unsigned int copyAPD(1);
0308 
0309   if (0 != apdHere()) {
0310     cpv.position(aglLog, bsiLog, copyAGL, DDTranslation(0, 0, -aglThick() / 2. + bsiThick() / 2.), DDRotation());
0311 
0312     cpv.position(
0313         andLog, bsiLog, copyAND, DDTranslation(0, 0, -andThick() / 2. - aglThick() + bsiThick() / 2.), DDRotation());
0314 
0315     cpv.position(apdLog,
0316                  bsiLog,
0317                  copyAPD,
0318                  DDTranslation(0, 0, -apdThick() / 2. - andThick() - aglThick() + bsiThick() / 2.),
0319                  DDRotation());
0320 
0321     cpv.position(atjLog,
0322                  bsiLog,
0323                  copyATJ,
0324                  DDTranslation(0, 0, -atjThick() / 2. - apdThick() - andThick() - aglThick() + bsiThick() / 2.),
0325                  DDRotation());
0326 
0327     cpv.position(bsiLog, cerLog, copyBSi, DDTranslation(0, 0, -bsiThick() / 2. + cerThick() / 2.), DDRotation());
0328 
0329     cpv.position(sglLog, capLog, copySGL, DDTranslation(0, 0, -sglThick() / 2. + capThick() / 2.), DDRotation());
0330 
0331     cpv.position(
0332         cerLog, capLog, copyCER, DDTranslation(0, 0, -sglThick() - cerThick() / 2. + capThick() / 2.), DDRotation());
0333 
0334     cpv.position(
0335         capLog, parent().name(), copyCAP, DDTranslation(vecCerPos()[0], vecCerPos()[1], vecCerPos()[2]), DDRotation());
0336   }
0337 
0338   LogDebug("EcalGeom") << "******** DDEcalAPDAlgo test: end it...";
0339 }
0340 
0341 DDName DDEcalAPDAlgo::ddname(const std::string& s) const {
0342   const std::pair<std::string, std::string> temp(DDSplit(s));
0343   if (temp.second.empty()) {
0344     return DDName(temp.first, m_idNameSpace);
0345   } else {
0346     return DDName(temp.first, temp.second);
0347   }
0348 }
0349 
0350 #include "DetectorDescription/Core/interface/DDAlgorithmFactory.h"
0351 
0352 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDEcalAPDAlgo, "ecal:DDEcalAPDAlgo");