Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-10 02:20:53

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // File: DDTECCoolAlgo.cc
0003 // Description: Placing cooling pieces in the petal material of a TEC petal
0004 // * in each call all objects are placed at the same radial position.
0005 // * Inserts are placed into the parent object
0006 // * for all i: CoolInsert[i] goes to PhiPosition[i]
0007 ///////////////////////////////////////////////////////////////////////////////
0008 
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 #include "DetectorDescription/Core/interface/DDutils.h"
0011 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
0012 #include "DetectorDescription/Core/interface/DDSplit.h"
0013 #include "DetectorDescription/Core/interface/DDTypes.h"
0014 #include "DetectorDescription/Core/interface/DDAlgorithm.h"
0015 #include "DetectorDescription/Core/interface/DDAlgorithmFactory.h"
0016 #include <CLHEP/Units/GlobalPhysicalConstants.h>
0017 #include <CLHEP/Units/SystemOfUnits.h>
0018 
0019 #include <cmath>
0020 #include <algorithm>
0021 #include <map>
0022 #include <string>
0023 #include <vector>
0024 
0025 using namespace std;
0026 
0027 class DDTECCoolAlgo : public DDAlgorithm {
0028 public:
0029   //Constructor and Destructor
0030   DDTECCoolAlgo();
0031   ~DDTECCoolAlgo() override;
0032 
0033   void initialize(const DDNumericArguments& nArgs,
0034                   const DDVectorArguments& vArgs,
0035                   const DDMapArguments& mArgs,
0036                   const DDStringArguments& sArgs,
0037                   const DDStringVectorArguments& vsArgs) override;
0038 
0039   void execute(DDCompactView& cpv) override;
0040 
0041 private:
0042   string idNameSpace;          //Namespace of this and ALL parts
0043   int startCopyNo;             //Start copy number
0044   double rPosition;            // Position of the Inserts in R
0045   vector<double> phiPosition;  // Position of the Inserts in Phi
0046   vector<string> coolInsert;   //Name of cooling pieces
0047 };
0048 
0049 DDTECCoolAlgo::DDTECCoolAlgo() : phiPosition(0), coolInsert(0) {
0050   LogDebug("TECGeom") << "DDTECCoolAlgo info: Creating an instance";
0051 }
0052 
0053 DDTECCoolAlgo::~DDTECCoolAlgo() {}
0054 
0055 void DDTECCoolAlgo::initialize(const DDNumericArguments& nArgs,
0056                                const DDVectorArguments& vArgs,
0057                                const DDMapArguments&,
0058                                const DDStringArguments& sArgs,
0059                                const DDStringVectorArguments& vsArgs) {
0060   idNameSpace = DDCurrentNamespace::ns();
0061   startCopyNo = int(nArgs["StartCopyNo"]);
0062 
0063   DDName parentName = parent().name();
0064   rPosition = nArgs["RPosition"];
0065   LogDebug("TECGeom") << "DDTECCoolAlgo debug: Parent " << parentName << " NameSpace " << idNameSpace
0066                       << " at radial Position " << rPosition;
0067   phiPosition = vArgs["PhiPosition"];
0068   coolInsert = vsArgs["CoolInsert"];
0069   if (phiPosition.size() == coolInsert.size()) {
0070     for (int i = 0; i < (int)(phiPosition.size()); i++)
0071       LogDebug("TECGeom") << "DDTECCoolAlgo debug: Insert[" << i << "]: " << coolInsert.at(i) << " at Phi "
0072                           << phiPosition.at(i) / CLHEP::deg;
0073   } else {
0074     LogDebug("TECGeom") << "ERROR: Number of inserts does not match the numer of PhiPositions!";
0075   }
0076   LogDebug("TECGeom") << " Done creating instance of DDTECCoolAlgo ";
0077 }
0078 
0079 void DDTECCoolAlgo::execute(DDCompactView& cpv) {
0080   LogDebug("TECGeom") << "==>> Constructing DDTECCoolAlgo...";
0081   int copyNo = startCopyNo;
0082   // loop over the inserts to be placed
0083   for (int i = 0; i < (int)(coolInsert.size()); i++) {
0084     // get objects
0085     DDName child = DDName(DDSplit(coolInsert.at(i)).first, DDSplit(coolInsert.at(i)).second);
0086     DDName mother = parent().name();
0087     // get positions
0088     double xpos = rPosition * cos(phiPosition.at(i));
0089     double ypos = -rPosition * sin(phiPosition.at(i));
0090     // place inserts
0091     DDTranslation tran(xpos, ypos, 0.0);
0092     DDRotation rotation;
0093     cpv.position(child, mother, copyNo, tran, rotation);
0094     LogDebug("TECGeom") << "DDTECCoolAlgo test " << child << "[" << copyNo << "] positioned in " << mother << " at "
0095                         << tran << " with " << rotation << " phi " << phiPosition.at(i) / CLHEP::deg << " r "
0096                         << rPosition;
0097     copyNo++;
0098   }
0099   LogDebug("TECGeom") << "<<== End of DDTECCoolAlgo construction ...";
0100 }
0101 
0102 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTECCoolAlgo, "track:DDTECCoolAlgo");