CMS 3D CMS Logo

DDHGCalWafer.cc
Go to the documentation of this file.
1 #include <algorithm>
2 #include <cmath>
3 
11 
12 //#define EDM_ML_DEBUG
13 using namespace geant_units::operators;
14 
16 #ifdef EDM_ML_DEBUG
17  edm::LogVerbatim("HGCalGeom") << "DDHGCalWafer: Creating an instance";
18 #endif
19 }
20 
22 
24  const DDVectorArguments& vArgs,
25  const DDMapArguments&,
26  const DDStringArguments& sArgs,
27  const DDStringVectorArguments& vsArgs) {
28  waferSize_ = nArgs["WaferSize"];
29  cellType_ = (int)(nArgs["CellType"]);
30  nColumns_ = (int)(nArgs["NColumns"]);
31  nBottomY_ = (int)(nArgs["NBottomY"]);
32  childNames_ = vsArgs["ChildNames"];
33  nCellsRow_ = dbl_to_int(vArgs["NCellsRow"]);
34  angleEdges_ = dbl_to_int(vArgs["AngleEdges"]);
35  detectorType_ = dbl_to_int(vArgs["DetectorType"]);
36  idNameSpace_ = DDCurrentNamespace::ns();
37  parentName_ = parent().name();
38 #ifdef EDM_ML_DEBUG
39  edm::LogVerbatim("HGCalGeom")
40  << childNames_.size() << " children: " << childNames_[0] << "; "
41  << childNames_[1] << " in namespace " << idNameSpace_
42  << " positioned in " << nCellsRow_.size() << " rows and "
43  << nColumns_ << " columns with lowest column at " << nBottomY_
44  << " in mother " << parentName_ << " of size " << waferSize_;
45  for (unsigned int k = 0; k < nCellsRow_.size(); ++k)
46  edm::LogVerbatim("HGCalGeom")
47  << "[" << k << "] Ncells " << nCellsRow_[k] << " Edge rotations "
48  << angleEdges_[2 * k] << ":" << angleEdges_[2 * k + 1]
49  << " Type of edge cells " << detectorType_[2 * k] << ":"
50  << detectorType_[2 * k + 1];
51 #endif
52 }
53 
55 #ifdef EDM_ML_DEBUG
56  edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalWafer...";
57 #endif
58  double dx = 0.5 * waferSize_ / nColumns_;
59  double dy = 0.5 * dx * tan(30._deg);
60  int ny = nBottomY_;
61  int kount(0);
62 
63  for (unsigned int ir = 0; ir < nCellsRow_.size(); ++ir) {
64  int nx = 1 - nCellsRow_[ir];
65  double ypos = dy * ny;
66  for (int ic = 0; ic < nCellsRow_[ir]; ++ic) {
67  std::string name(childNames_[0]), rotstr("NULL");
68  int irot(0);
69  if (ic == 0) {
70  name = childNames_[detectorType_[2 * ir]];
71  irot = angleEdges_[2 * ir];
72  } else if (ic + 1 == nCellsRow_[ir]) {
73  name = childNames_[detectorType_[2 * ir + 1]];
74  irot = angleEdges_[2 * ir + 1];
75  }
77  if (irot != 0) {
78  double phi = convertDegToRad(irot);
79  rotstr = "R" + formatAsDegrees(phi);
80  rot = DDRotation(DDName(rotstr, idNameSpace_));
81  if (!rot) {
82 #ifdef EDM_ML_DEBUG
83  edm::LogVerbatim("HGCalGeom")
84  << "DDHGCalWaferAlgo: Creating new rotation "
85  << DDName(rotstr, idNameSpace_) << "\t90, " << irot
86  << ", 90, " << (irot + 90) << ", 0, 0";
87 #endif
88  rot = DDrot(DDName(rotstr, idNameSpace_), 90._deg, phi, 90._deg,
89  (90._deg+phi), 0, 0);
90  }
91  }
92  double xpos = dx * nx;
93  nx += 2;
94  DDTranslation tran(xpos, ypos, 0);
95  int copy = cellType_ * 1000 + kount;
96  cpv.position(DDName(name, idNameSpace_), parentName_, copy, tran, rot);
97  ++kount;
98 #ifdef EDM_ML_DEBUG
99  edm::LogVerbatim("HGCalGeom")
100  << "DDHGCalWafer: " << DDName(name, idNameSpace_) << " number "
101  << copy << " positioned in " << parentName_ << " at " << tran
102  << " with " << rot;
103 #endif
104  }
105  ny += 6;
106  }
107 }
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDHGCalWafer.cc:23
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]
~DDHGCalWafer() override
Definition: DDHGCalWafer.cc:21
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
void execute(DDCompactView &cpv) override
Definition: DDHGCalWafer.cc:54