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 <algorithm>
7 #include <cmath>
8 
15 
16 //#define EDM_ML_DEBUG
17 using namespace geant_units::operators;
18 
20 #ifdef EDM_ML_DEBUG
21  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferAlgo: Creating an instance";
22 #endif
23 }
24 
26 
28  const DDVectorArguments& vArgs,
29  const DDMapArguments&,
30  const DDStringArguments& sArgs,
31  const DDStringVectorArguments& vsArgs) {
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::LogVerbatim("HGCalGeom")
41  << childNames.size() << " children: " << childNames[0] << "; "
42  << childNames[1] << " positioned " << positionX.size()
43  << " times with cell size " << cellSize;
44  for (unsigned int k = 0; k < positionX.size(); ++k)
45  edm::LogVerbatim("HGCalGeom")
46  << "[" << k << "] x " << positionX[k] << " y " << positionY[k]
47  << " angle " << angles[k] << " detector " << detectorType[k];
48 #endif
49  rotns = sArgs["RotNameSpace"];
50  idNameSpace = DDCurrentNamespace::ns();
51  parentName = parent().name();
52 #ifdef EDM_ML_DEBUG
53  edm::LogVerbatim("HGCalGeom")
54  << "DDHGCalWaferAlgo debug: Parent " << parentName << " NameSpace "
55  << idNameSpace << " for Rotation " << rotns;
56 #endif
57 }
58 
60 #ifdef EDM_ML_DEBUG
61  edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalWaferAlgo...";
62 #endif
63  double dx = 0.5 * cellSize;
64  double dy = 0.5 * dx * tan(30._deg);
65 
66  for (unsigned int k = 0; k < positionX.size(); ++k) {
67  std::string name(childNames[detectorType[k]]);
69  std::string rotstr("NULL");
70  if (angles[k] != 0) {
71  double phi = convertDegToRad(angles[k]);
72  rotstr = "R" + formatAsDegrees(phi);
73  rotation = DDRotation(DDName(rotstr, rotns));
74  if (!rotation) {
75 #ifdef EDM_ML_DEBUG
76  edm::LogVerbatim("HGCalGeom")
77  << "DDHGCalWaferAlgo: Creating new rotation "
78  << DDName(rotstr, rotns) << "\t90, " << angles[k] << ", 90, "
79  << (angles[k] + 90) << ", 0, 0";
80 #endif
81  rotation = DDrot(DDName(rotstr, rotns), 90._deg, phi,
82  90._deg, (90._deg + phi), 0, 0);
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  edm::LogVerbatim("HGCalGeom")
92  << "DDHGCalWaferAlgo: " << DDName(name, idNameSpace) << " number "
93  << copy << " positioned in " << parentName << " at " << tran
94  << " with " << rotation;
95 #endif
96  }
97 }
def copy(args, dbName)
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
static std::string & ns()
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:68
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
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
DDRotation DDrot(const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:80
constexpr long double convertDegToRad(NumType degrees)
Definition: GeantUnits.h:104
std::string formatAsDegrees(double radianVal)
Definition: DDTypes.cc:75
int k[5][pyjets_maxn]
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
~DDHGCalWaferAlgo() override
void execute(DDCompactView &cpv) override