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 #include <map>
9 #include <string>
10 #include <vector>
11 
22 
23 //#define EDM_ML_DEBUG
24 using namespace geant_units::operators;
25 
26 class DDHGCalWaferAlgo : public DDAlgorithm {
27 public:
28  // Constructor and Destructor
30 
31  void initialize(const DDNumericArguments& nArgs,
32  const DDVectorArguments& vArgs,
33  const DDMapArguments& mArgs,
34  const DDStringArguments& sArgs,
35  const DDStringVectorArguments& vsArgs) override;
36  void execute(DDCompactView& cpv) override;
37 
38 private:
39  double cellSize_; // Cell Size
40  int cellType_; // Type (1 fine; 2 coarse)
41  std::vector<std::string> childNames_; // Names of children
42  std::vector<int> positionX_; // Position in X
43  std::vector<int> positionY_; // Position in Y
44  std::vector<double> angles_; // Rotation angle
45  std::vector<int> detectorType_; // Detector type
46  std::string rotns_; // Namespace for rotation matrix
47  std::string idNameSpace_; // Namespace of this and ALL sub-parts
48  DDName parentName_; // Parent name
49 };
50 
52 #ifdef EDM_ML_DEBUG
53  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferAlgo: Creating an instance";
54 #endif
55 }
56 
58  const DDVectorArguments& vArgs,
59  const DDMapArguments&,
60  const DDStringArguments& sArgs,
61  const DDStringVectorArguments& vsArgs) {
62  cellSize_ = nArgs["CellSize"];
63  cellType_ = (int)(nArgs["CellType"]);
64  childNames_ = vsArgs["ChildNames"];
65  positionX_ = dbl_to_int(vArgs["PositionX"]);
66  positionY_ = dbl_to_int(vArgs["PositionY"]);
67  angles_ = vArgs["Angles"];
68  detectorType_ = dbl_to_int(vArgs["DetectorType"]);
69 #ifdef EDM_ML_DEBUG
70  edm::LogVerbatim("HGCalGeom") << childNames_.size() << " children: " << childNames_[0] << "; " << childNames_[1]
71  << " positioned " << positionX_.size() << " times with cell size " << cellSize_;
72  for (unsigned int k = 0; k < positionX_.size(); ++k)
73  edm::LogVerbatim("HGCalGeom") << "[" << k << "] x " << positionX_[k] << " y " << positionY_[k] << " angle "
74  << angles_[k] << " detector " << detectorType_[k];
75 #endif
76  rotns_ = sArgs["RotNameSpace"];
77  idNameSpace_ = DDCurrentNamespace::ns();
78  parentName_ = parent().name();
79 #ifdef EDM_ML_DEBUG
80  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferAlgo debug: Parent " << parentName_ << " NameSpace " << idNameSpace_
81  << " for Rotation " << rotns_;
82 #endif
83 }
84 
86 #ifdef EDM_ML_DEBUG
87  edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalWaferAlgo...";
88 #endif
89  double dx = 0.5 * cellSize_;
90  double dy = 0.5 * dx * tan(30._deg);
91 
92  for (unsigned int k = 0; k < positionX_.size(); ++k) {
93  std::string name(childNames_[detectorType_[k]]);
95  std::string rotstr("NULL");
96  if (angles_[k] != 0) {
97  double phi = convertDegToRad(angles_[k]);
98  rotstr = "R" + formatAsDegrees(phi);
99  rotation = DDRotation(DDName(rotstr, rotns_));
100  if (!rotation) {
101 #ifdef EDM_ML_DEBUG
102  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferAlgo: Creating new rotation " << DDName(rotstr, rotns_)
103  << "\t90, " << angles_[k] << ", 90, " << (angles_[k] + 90) << ", 0, 0";
104 #endif
105  rotation = DDrot(DDName(rotstr, rotns_), 90._deg, phi, 90._deg, (90._deg + phi), 0, 0);
106  }
107  }
108  double xpos = dx * positionX_[k];
109  double ypos = dy * positionY_[k];
110  DDTranslation tran(xpos, ypos, 0);
111  int copy = HGCalTypes::packCellType6(cellType_, k);
112  cpv.position(DDName(name, idNameSpace_), parentName_, copy, tran, rotation);
113 #ifdef EDM_ML_DEBUG
114  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferAlgo: " << DDName(name, idNameSpace_) << " number " << copy
115  << " positioned in " << parentName_ << " at " << tran << " with " << rotation;
116 #endif
117  }
118 }
119 
120 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalWaferAlgo, "hgcal:DDHGCalWaferAlgo");
PluginFactory.h
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
DDHGCalWaferAlgo::positionX_
std::vector< int > positionX_
Definition: DDHGCalWaferAlgo.cc:42
angle_units::operators::convertDegToRad
constexpr long double convertDegToRad(NumType degrees)
Definition: angle_units.h:27
HGCalTypes::packCellType6
static int32_t packCellType6(int type, int cell)
Definition: HGCalTypes.cc:36
geant_units::operators
Definition: GeantUnits.h:18
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
DDHGCalWaferAlgo::execute
void execute(DDCompactView &cpv) override
Definition: DDHGCalWaferAlgo.cc:85
DDHGCalWaferAlgo::DDHGCalWaferAlgo
DDHGCalWaferAlgo()
Definition: DDHGCalWaferAlgo.cc:51
DDHGCalWaferAlgo::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDHGCalWaferAlgo.cc:57
DDHGCalWaferAlgo::parentName_
DDName parentName_
Definition: DDHGCalWaferAlgo.cc:48
DDHGCalWaferAlgo::positionY_
std::vector< int > positionY_
Definition: DDHGCalWaferAlgo.cc:43
DDHGCalWaferAlgo::rotns_
std::string rotns_
Definition: DDHGCalWaferAlgo.cc:46
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDHGCalWaferAlgo
Definition: DDHGCalWaferAlgo.cc:26
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
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
GeantUnits.h
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDHGCalWaferAlgo::childNames_
std::vector< std::string > childNames_
Definition: DDHGCalWaferAlgo.cc:41
DDTypes.h
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
createfilelist.int
int
Definition: createfilelist.py:10
DDutils.h
DDHGCalWaferAlgo::detectorType_
std::vector< int > detectorType_
Definition: DDHGCalWaferAlgo.cc:45
DDHGCalWaferAlgo::cellSize_
double cellSize_
Definition: DDHGCalWaferAlgo.cc:39
PVValHelper::dy
Definition: PVValidationHelpers.h:49
DDHGCalWaferAlgo::angles_
std::vector< double > angles_
Definition: DDHGCalWaferAlgo.cc:44
DDLogicalPart.h
ReadMapType< double >
DDHGCalWaferAlgo::cellType_
int cellType_
Definition: DDHGCalWaferAlgo.cc:40
DDAlgorithm.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDHGCalWaferAlgo::idNameSpace_
std::string idNameSpace_
Definition: DDHGCalWaferAlgo.cc:47
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
HGCalTypes.h
DDAlgorithmFactory.h
edm::Log
Definition: MessageLogger.h:70
class-composition.parent
parent
Definition: class-composition.py:88
PVValHelper::dx
Definition: PVValidationHelpers.h: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:18