CMS 3D CMS Logo

DDHGCalWaferAlgo.cc
Go to the documentation of this file.
1 // File: DDHGCalWaferAlgo.cc
3 // Description: Position inside the mother according to (eta,phi)
5 
6 #include <cmath>
7 #include <algorithm>
8 
14 #include "CLHEP/Units/GlobalSystemOfUnits.h"
15 
16 //#define EDM_ML_DEBUG
17 
19 #ifdef EDM_ML_DEBUG
20  edm::LogInfo("HGCalGeom") << "DDHGCalWaferAlgo test: Creating an instance";
21 #endif
22 }
23 
25 
27  const DDVectorArguments & vArgs,
28  const DDMapArguments & ,
29  const DDStringArguments & sArgs,
30  const DDStringVectorArguments & vsArgs) {
31 
32  cellSize = nArgs["CellSize"];
33  cellType = (int)(nArgs["CellType"]);
34  childNames = vsArgs["ChildNames"];
35  positionX = dbl_to_int(vArgs["PositionX"]);
36  positionY = dbl_to_int(vArgs["PositionY"]);
37  angles = vArgs["Angles"];
38  detectorType= dbl_to_int(vArgs["DetectorType"]);
39 #ifdef EDM_ML_DEBUG
40  std::cout << childNames.size() << " children: " << childNames[0] << "; "
41  << childNames[1] << " positioned " << positionX.size()
42  << " times with cell size " << cellSize << std::endl;
43  for (unsigned int k=0; k<positionX.size(); ++k)
44  std::cout << "[" << k << "] x " << positionX[k] << " y " << positionY[k]
45  << " angle " << angles[k] << " detector " << detectorType[k]
46  << std::endl;
47 #endif
48  rotns = sArgs["RotNameSpace"];
50  parentName = parent().name();
51 #ifdef EDM_ML_DEBUG
52  std::cout << "DDHGCalWaferAlgo debug: Parent " << parentName << " NameSpace "
53  << idNameSpace << " for Rotation " << rotns << std::endl;
54 #endif
55 }
56 
58 
59 #ifdef EDM_ML_DEBUG
60  edm::LogInfo("HGCalGeom") << "==>> Constructing DDHGCalWaferAlgo...";
61 #endif
62  double dx = 0.5*cellSize;
63  double dy = 0.5*dx*tan(30.0*CLHEP::deg);
64 
65  for (unsigned int k=0; k<positionX.size(); ++k) {
68  std::string rotstr("NULL");
69  if (angles[k] != 0) {
70  if (angles[k] >=0 && angles[k] < 100) rotstr = "R0";
71  else rotstr = "R";
72  rotstr = rotstr + std::to_string(angles[k]);
73  rotation = DDRotation(DDName(rotstr, rotns));
74  if (!rotation) {
75 #ifdef EDM_ML_DEBUG
76  std::cout << "DDHGCalWaferAlgo: Creating new rotation "
77  << DDName(rotstr, rotns) << "\t90, " << angles[k] << ", 90, "
78  << (angles[k]+90) << ", 0, 0" << std::endl;
79 #endif
80  rotation = DDrot(DDName(rotstr, rotns), 90*CLHEP::deg,
81  angles[k]*CLHEP::deg, 90*CLHEP::deg,
82  (90+angles[k])*CLHEP::deg, 0*CLHEP::deg,0*CLHEP::deg);
83  }
84  }
85  double xpos = dx*positionX[k];
86  double ypos = dy*positionY[k];
87  DDTranslation tran(xpos, ypos, 0);
88  int copy = cellType*1000+k;
89  cpv.position(DDName(name,idNameSpace), parentName, copy, tran, rotation);
90 #ifdef EDM_ML_DEBUG
91  std::cout << "DDHGCalWaferAlgo: " << DDName(name,idNameSpace) << " number "
92  << copy << " positioned in " << parentName << " at " << tran
93  << " with " << rotation << std::endl;
94 #endif
95  }
96 }
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
static std::string & ns()
type of data representation of DDCompactView
Definition: DDCompactView.h:90
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:67
std::vector< int > dbl_to_int(const std::vector< double > &vecdbl)
Converts a std::vector of doubles to a std::vector of int.
Definition: DDutils.h:7
std::string idNameSpace
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
std::vector< int > positionX
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
std::vector< int > detectorType
int k[5][pyjets_maxn]
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
std::vector< std::string > childNames
std::vector< int > positionY
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
~DDHGCalWaferAlgo() override
std::vector< double > angles
void execute(DDCompactView &cpv) override