CMS 3D CMS Logo

DDTECCoolAlgo.cc
Go to the documentation of this file.
1 // File: DDTECCoolAlgo.cc
3 // Description: Placing cooling pieces in the petal material of a TEC petal
4 // * in each call all objects are placed at the same radial position.
5 // * Inserts are placed into the parent object
6 // * for all i: CoolInsert[i] goes to PhiPosition[i]
8 
16 #include "CLHEP/Units/GlobalPhysicalConstants.h"
17 #include "CLHEP/Units/GlobalSystemOfUnits.h"
18 
19 #include <cmath>
20 #include <algorithm>
21 #include <map>
22 #include <string>
23 #include <vector>
24 
25 using namespace std;
26 
27 class DDTECCoolAlgo : public DDAlgorithm {
28 public:
29  //Constructor and Destructor
30  DDTECCoolAlgo();
31  ~DDTECCoolAlgo() override;
32 
33  void initialize(const DDNumericArguments& nArgs,
34  const DDVectorArguments& vArgs,
35  const DDMapArguments& mArgs,
36  const DDStringArguments& sArgs,
37  const DDStringVectorArguments& vsArgs) override;
38 
39  void execute(DDCompactView& cpv) override;
40 
41 private:
42  string idNameSpace; //Namespace of this and ALL parts
43  int startCopyNo; //Start copy number
44  double rPosition; // Position of the Inserts in R
45  vector<double> phiPosition; // Position of the Inserts in Phi
46  vector<string> coolInsert; //Name of cooling pieces
47 };
48 
49 DDTECCoolAlgo::DDTECCoolAlgo() : phiPosition(0), coolInsert(0) {
50  LogDebug("TECGeom") << "DDTECCoolAlgo info: Creating an instance";
51 }
52 
54 
56  const DDVectorArguments& vArgs,
57  const DDMapArguments&,
58  const DDStringArguments& sArgs,
59  const DDStringVectorArguments& vsArgs) {
61  startCopyNo = int(nArgs["StartCopyNo"]);
62 
63  DDName parentName = parent().name();
64  rPosition = nArgs["RPosition"];
65  LogDebug("TECGeom") << "DDTECCoolAlgo debug: Parent " << parentName << " NameSpace " << idNameSpace
66  << " at radial Position " << rPosition;
67  phiPosition = vArgs["PhiPosition"];
68  coolInsert = vsArgs["CoolInsert"];
69  if (phiPosition.size() == coolInsert.size()) {
70  for (int i = 0; i < (int)(phiPosition.size()); i++)
71  LogDebug("TECGeom") << "DDTECCoolAlgo debug: Insert[" << i << "]: " << coolInsert.at(i) << " at Phi "
72  << phiPosition.at(i) / CLHEP::deg;
73  } else {
74  LogDebug("TECGeom") << "ERROR: Number of inserts does not match the numer of PhiPositions!";
75  }
76  LogDebug("TECGeom") << " Done creating instance of DDTECCoolAlgo ";
77 }
78 
80  LogDebug("TECGeom") << "==>> Constructing DDTECCoolAlgo...";
81  int copyNo = startCopyNo;
82  // loop over the inserts to be placed
83  for (int i = 0; i < (int)(coolInsert.size()); i++) {
84  // get objects
86  DDName mother = parent().name();
87  // get positions
88  double xpos = rPosition * cos(phiPosition.at(i));
89  double ypos = -rPosition * sin(phiPosition.at(i));
90  // place inserts
91  DDTranslation tran(xpos, ypos, 0.0);
93  cpv.position(child, mother, copyNo, tran, rotation);
94  LogDebug("TECGeom") << "DDTECCoolAlgo test " << child << "[" << copyNo << "] positioned in " << mother << " at "
95  << tran << " with " << rotation << " phi " << phiPosition.at(i) / CLHEP::deg << " r "
96  << rPosition;
97  copyNo++;
98  }
99  LogDebug("TECGeom") << "<<== End of DDTECCoolAlgo construction ...";
100 }
101 
102 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTECCoolAlgo, "track:DDTECCoolAlgo");
static AlgebraicMatrix initialize()
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
static std::string & ns()
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
U second(std::pair< T, U > const &p)
vector< string > coolInsert
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
void execute(DDCompactView &cpv) override
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
~DDTECCoolAlgo() override
vector< double > phiPosition
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
string idNameSpace
#define LogDebug(id)