CMS 3D CMS Logo

DDHGCalWafer.cc
Go to the documentation of this file.
1 #include <algorithm>
2 #include <cmath>
3 #include <map>
4 #include <string>
5 #include <vector>
6 
17 
18 //#define EDM_ML_DEBUG
19 using namespace geant_units::operators;
20 
21 class DDHGCalWafer : public DDAlgorithm {
22 public:
23  // Constructor and Destructor
24  DDHGCalWafer();
25  ~DDHGCalWafer() override;
26 
27  void initialize(const DDNumericArguments& nArgs,
28  const DDVectorArguments& vArgs,
29  const DDMapArguments& mArgs,
30  const DDStringArguments& sArgs,
31  const DDStringVectorArguments& vsArgs) override;
32  void execute(DDCompactView& cpv) override;
33 
34 private:
35  double waferSize_; // Wafer Size
36  int cellType_; // Type (1 fine; 2 coarse)
37  int nColumns_; // Maximum number of columns
38  int nBottomY_; // Index of cell position of bottom row
39  std::vector<std::string> childNames_; // Names of children
40  std::vector<int> nCellsRow_; // Number of cells in a row
41  std::vector<int> angleEdges_; // Rotation angles to be used for edges
42  std::vector<int> detectorType_; // Detector type of edge cells
43  std::string idNameSpace_; // Namespace of this and ALL sub-parts
44  DDName parentName_; // Parent name
45 };
46 
48 #ifdef EDM_ML_DEBUG
49  edm::LogVerbatim("HGCalGeom") << "DDHGCalWafer: Creating an instance";
50 #endif
51 }
52 
54 
56  const DDVectorArguments& vArgs,
57  const DDMapArguments&,
58  const DDStringArguments& sArgs,
59  const DDStringVectorArguments& vsArgs) {
60  waferSize_ = nArgs["WaferSize"];
61  cellType_ = (int)(nArgs["CellType"]);
62  nColumns_ = (int)(nArgs["NColumns"]);
63  nBottomY_ = (int)(nArgs["NBottomY"]);
64  childNames_ = vsArgs["ChildNames"];
65  nCellsRow_ = dbl_to_int(vArgs["NCellsRow"]);
66  angleEdges_ = dbl_to_int(vArgs["AngleEdges"]);
67  detectorType_ = dbl_to_int(vArgs["DetectorType"]);
68  idNameSpace_ = DDCurrentNamespace::ns();
69  parentName_ = parent().name();
70 #ifdef EDM_ML_DEBUG
71  edm::LogVerbatim("HGCalGeom") << childNames_.size() << " children: " << childNames_[0] << "; " << childNames_[1]
72  << " in namespace " << idNameSpace_ << " positioned in " << nCellsRow_.size()
73  << " rows and " << nColumns_ << " columns with lowest column at " << nBottomY_
74  << " in mother " << parentName_ << " of size " << waferSize_;
75  for (unsigned int k = 0; k < nCellsRow_.size(); ++k)
76  edm::LogVerbatim("HGCalGeom") << "[" << k << "] Ncells " << nCellsRow_[k] << " Edge rotations "
77  << angleEdges_[2 * k] << ":" << angleEdges_[2 * k + 1] << " Type of edge cells "
78  << detectorType_[2 * k] << ":" << detectorType_[2 * k + 1];
79 #endif
80 }
81 
83 #ifdef EDM_ML_DEBUG
84  edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalWafer...";
85 #endif
86  double dx = 0.5 * waferSize_ / nColumns_;
87  double dy = 0.5 * dx * tan(30._deg);
88  int ny = nBottomY_;
89  int kount(0);
90 
91  for (unsigned int ir = 0; ir < nCellsRow_.size(); ++ir) {
92  int nx = 1 - nCellsRow_[ir];
93  double ypos = dy * ny;
94  for (int ic = 0; ic < nCellsRow_[ir]; ++ic) {
95  std::string name(childNames_[0]), rotstr("NULL");
96  int irot(0);
97  if (ic == 0) {
98  name = childNames_[detectorType_[2 * ir]];
99  irot = angleEdges_[2 * ir];
100  } else if (ic + 1 == nCellsRow_[ir]) {
101  name = childNames_[detectorType_[2 * ir + 1]];
102  irot = angleEdges_[2 * ir + 1];
103  }
104  DDRotation rot;
105  if (irot != 0) {
106  double phi = convertDegToRad(irot);
107  rotstr = "R" + formatAsDegrees(phi);
108  rot = DDRotation(DDName(rotstr, idNameSpace_));
109  if (!rot) {
110 #ifdef EDM_ML_DEBUG
111  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferAlgo: Creating new rotation " << DDName(rotstr, idNameSpace_)
112  << "\t90, " << irot << ", 90, " << (irot + 90) << ", 0, 0";
113 #endif
114  rot = DDrot(DDName(rotstr, idNameSpace_), 90._deg, phi, 90._deg, (90._deg + phi), 0, 0);
115  }
116  }
117  double xpos = dx * nx;
118  nx += 2;
119  DDTranslation tran(xpos, ypos, 0);
120  int copy = cellType_ * 1000 + kount;
121  cpv.position(DDName(name, idNameSpace_), parentName_, copy, tran, rot);
122  ++kount;
123 #ifdef EDM_ML_DEBUG
124  edm::LogVerbatim("HGCalGeom") << "DDHGCalWafer: " << DDName(name, idNameSpace_) << " number " << copy
125  << " positioned in " << parentName_ << " at " << tran << " with " << rot;
126 #endif
127  }
128  ny += 6;
129  }
130 }
131 
132 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalWafer, "hgcal:DDHGCalWafer");
PluginFactory.h
DDHGCalWafer::nCellsRow_
std::vector< int > nCellsRow_
Definition: DDHGCalWafer.cc:40
DDCurrentNamespace.h
MessageLogger.h
DDrot
DDRotation DDrot(const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:67
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDHGCalWafer::waferSize_
double waferSize_
Definition: DDHGCalWafer.cc:35
DDSplit.h
DDHGCalWafer
Definition: DDHGCalWafer.cc:21
angle_units::operators::convertDegToRad
constexpr long double convertDegToRad(NumType degrees)
Definition: angle_units.h:27
DDHGCalWafer::nBottomY_
int nBottomY_
Definition: DDHGCalWafer.cc:38
DDHGCalWafer::~DDHGCalWafer
~DDHGCalWafer() override
Definition: DDHGCalWafer.cc:53
geant_units::operators
Definition: GeantUnits.h:18
DDHGCalWafer::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDHGCalWafer.cc:55
dbl_to_int
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
DDHGCalWafer::childNames_
std::vector< std::string > childNames_
Definition: DDHGCalWafer.cc:39
DDHGCalWafer::execute
void execute(DDCompactView &cpv) override
Definition: DDHGCalWafer.cc:82
DDHGCalWafer::parentName_
DDName parentName_
Definition: DDHGCalWafer.cc:44
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDHGCalWafer::cellType_
int cellType_
Definition: DDHGCalWafer.cc:36
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
formatAsDegrees
std::string formatAsDegrees(double radianVal)
Definition: DDTypes.cc:68
dqmdumpme.k
k
Definition: dqmdumpme.py:60
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
DDHGCalWafer::nColumns_
int nColumns_
Definition: DDHGCalWafer.cc:37
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDHGCalWafer::angleEdges_
std::vector< int > angleEdges_
Definition: DDHGCalWafer.cc:41
GeantUnits.h
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDTypes.h
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
createfilelist.int
int
Definition: createfilelist.py:10
DDutils.h
edm::LogVerbatim
Definition: MessageLogger.h:297
PVValHelper::dy
Definition: PVValidationHelpers.h:49
DDHGCalWafer::idNameSpace_
std::string idNameSpace_
Definition: DDHGCalWafer.cc:43
DDLogicalPart.h
ReadMapType< double >
DDAlgorithm.h
DDHGCalWafer::detectorType_
std::vector< int > detectorType_
Definition: DDHGCalWafer.cc:42
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
DDAlgorithmFactory.h
class-composition.parent
parent
Definition: class-composition.py:88
PVValHelper::dx
Definition: PVValidationHelpers.h:48
DDHGCalWafer::DDHGCalWafer
DDHGCalWafer()
Definition: DDHGCalWafer.cc:47
DDCompactView::position
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
Definition: DDCompactView.cc:66
DDRotation
ROOT::Math::Rotation3D DDRotation
Definition: DDEcalEndcapAlgo.cc:18