test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  edm::LogInfo("HGCalGeom") << childNames.size() << " children: "
41  << childNames[0] << "; " << childNames[1]
42  << " positioned " << positionX.size()
43  << " times with cell size " << cellSize;
44  for (unsigned int k=0; k<positionX.size(); ++k)
45  edm::LogInfo("HGCalGeom") << "[" << k << "] x " << positionX[k] << " y "
46  << positionY[k] << " angle " << angles[k]
47  << " detector " << detectorType[k];
48 #endif
49  rotns = sArgs["RotNameSpace"];
51  parentName = parent().name();
52 #ifdef EDM_ML_DEBUG
53  edm::LogInfo("HGCalGeom") << "DDHGCalWaferAlgo debug: Parent "
54  << parentName << " NameSpace " << idNameSpace
55  << " for Rotation " << rotns;
56 #endif
57 }
58 
60 
61 #ifdef EDM_ML_DEBUG
62  edm::LogInfo("HGCalGeom") << "==>> Constructing DDHGCalWaferAlgo...";
63 #endif
64  double dx = 0.5*cellSize;
65  double dy = 0.5*dx*tan(30.0*CLHEP::deg);
66 
67  for (unsigned int k=0; k<positionX.size(); ++k) {
70  std::string rotstr("NULL");
71  if (angles[k] != 0) {
72  if (angles[k] >=0 && angles[k] < 100) rotstr = "R0";
73  else rotstr = "R";
74  rotstr = rotstr + std::to_string(angles[k]);
75  rotation = DDRotation(DDName(rotstr, rotns));
76  if (!rotation) {
77 #ifdef EDM_ML_DEBUG
78  edm::LogInfo("HGCalGeom") << "DDHGCalWaferAlgo: Creating new rotation "
79  << DDName(rotstr, rotns) << "\t90, "
80  << angles[k] << ", 90, " << (angles[k]+90)
81  << ", 0, 0";
82 #endif
83  rotation = DDrot(DDName(rotstr, rotns), 90*CLHEP::deg,
84  angles[k]*CLHEP::deg, 90*CLHEP::deg,
85  (90+angles[k])*CLHEP::deg, 0*CLHEP::deg, 0*CLHEP::deg);
86  }
87  }
88  double xpos = dx*positionX[k];
89  double ypos = dy*positionY[k];
90  DDTranslation tran(xpos, ypos, 0);
91  int copy = cellType*1000+k;
92  cpv.position(DDName(name,idNameSpace), parentName, copy, tran, rotation);
93 #ifdef EDM_ML_DEBUG
94  edm::LogInfo("HGCalGeom") << "DDHGCalWaferAlgo: "
95  << DDName(name,idNameSpace) << " number " << copy
96  << " positioned in " << parentName << " at "
97  << tran << " with " << rotation;
98 #endif
99  }
100 }
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
void position(const DDLogicalPart &self, const DDLogicalPart &parent, std::string copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=NULL)
void execute(DDCompactView &cpv)
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:16
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:66
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
std::vector< std::string > childNames
std::vector< int > positionY
virtual ~DDHGCalWaferAlgo()
std::vector< double > angles