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