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 
21 
22 //#define EDM_ML_DEBUG
23 using namespace geant_units::operators;
24 
25 class DDHGCalWaferAlgo : public DDAlgorithm {
26 public:
27  // Constructor and Destructor
29  ~DDHGCalWaferAlgo() override;
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 idName; // Name of the "parent" volume.
47  std::string rotns; // Namespace for rotation matrix
48  std::string idNameSpace; // Namespace of this and ALL sub-parts
49  DDName parentName; // Parent name
50 };
51 
53 #ifdef EDM_ML_DEBUG
54  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferAlgo: Creating an instance";
55 #endif
56 }
57 
59 
61  const DDVectorArguments& vArgs,
62  const DDMapArguments&,
63  const DDStringArguments& sArgs,
64  const DDStringVectorArguments& vsArgs) {
65  cellSize = nArgs["CellSize"];
66  cellType = (int)(nArgs["CellType"]);
67  childNames = vsArgs["ChildNames"];
68  positionX = dbl_to_int(vArgs["PositionX"]);
69  positionY = dbl_to_int(vArgs["PositionY"]);
70  angles = vArgs["Angles"];
71  detectorType = dbl_to_int(vArgs["DetectorType"]);
72 #ifdef EDM_ML_DEBUG
73  edm::LogVerbatim("HGCalGeom") << childNames.size() << " children: " << childNames[0] << "; " << childNames[1]
74  << " positioned " << positionX.size() << " times with cell size " << cellSize;
75  for (unsigned int k = 0; k < positionX.size(); ++k)
76  edm::LogVerbatim("HGCalGeom") << "[" << k << "] x " << positionX[k] << " y " << positionY[k] << " angle "
77  << angles[k] << " detector " << detectorType[k];
78 #endif
79  rotns = sArgs["RotNameSpace"];
80  idNameSpace = DDCurrentNamespace::ns();
81  parentName = parent().name();
82 #ifdef EDM_ML_DEBUG
83  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferAlgo debug: Parent " << parentName << " NameSpace " << idNameSpace
84  << " for Rotation " << rotns;
85 #endif
86 }
87 
89 #ifdef EDM_ML_DEBUG
90  edm::LogVerbatim("HGCalGeom") << "==>> Constructing DDHGCalWaferAlgo...";
91 #endif
92  double dx = 0.5 * cellSize;
93  double dy = 0.5 * dx * tan(30._deg);
94 
95  for (unsigned int k = 0; k < positionX.size(); ++k) {
96  std::string name(childNames[detectorType[k]]);
98  std::string rotstr("NULL");
99  if (angles[k] != 0) {
100  double phi = convertDegToRad(angles[k]);
101  rotstr = "R" + formatAsDegrees(phi);
102  rotation = DDRotation(DDName(rotstr, rotns));
103  if (!rotation) {
104 #ifdef EDM_ML_DEBUG
105  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferAlgo: Creating new rotation " << DDName(rotstr, rotns) << "\t90, "
106  << angles[k] << ", 90, " << (angles[k] + 90) << ", 0, 0";
107 #endif
108  rotation = DDrot(DDName(rotstr, rotns), 90._deg, phi, 90._deg, (90._deg + phi), 0, 0);
109  }
110  }
111  double xpos = dx * positionX[k];
112  double ypos = dy * positionY[k];
113  DDTranslation tran(xpos, ypos, 0);
114  int copy = cellType * 1000 + k;
115  cpv.position(DDName(name, idNameSpace), parentName, copy, tran, rotation);
116 #ifdef EDM_ML_DEBUG
117  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferAlgo: " << DDName(name, idNameSpace) << " number " << copy
118  << " positioned in " << parentName << " at " << tran << " with " << rotation;
119 #endif
120  }
121 }
122 
123 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHGCalWaferAlgo, "hgcal:DDHGCalWaferAlgo");
PluginFactory.h
DDHGCalWaferAlgo::cellType
int cellType
Definition: DDHGCalWaferAlgo.cc:40
DDCurrentNamespace.h
DDHGCalWaferAlgo::rotns
std::string rotns
Definition: DDHGCalWaferAlgo.cc:47
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
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::childNames
std::vector< std::string > childNames
Definition: DDHGCalWaferAlgo.cc:41
DDHGCalWaferAlgo::execute
void execute(DDCompactView &cpv) override
Definition: DDHGCalWaferAlgo.cc:88
DDHGCalWaferAlgo::DDHGCalWaferAlgo
DDHGCalWaferAlgo()
Definition: DDHGCalWaferAlgo.cc:52
DDHGCalWaferAlgo::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDHGCalWaferAlgo.cc:60
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
DDHGCalWaferAlgo
Definition: DDHGCalWaferAlgo.cc:25
formatAsDegrees
std::string formatAsDegrees(double radianVal)
Definition: DDTypes.cc:68
DDHGCalWaferAlgo::~DDHGCalWaferAlgo
~DDHGCalWaferAlgo() override
Definition: DDHGCalWaferAlgo.cc:58
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
DDHGCalWaferAlgo::idName
std::string idName
Definition: DDHGCalWaferAlgo.cc:46
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
GeantUnits.h
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDHGCalWaferAlgo::angles
std::vector< double > angles
Definition: DDHGCalWaferAlgo.cc:44
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
DDLogicalPart.h
DDHGCalWaferAlgo::parentName
DDName parentName
Definition: DDHGCalWaferAlgo.cc:49
ReadMapType< double >
DDAlgorithm.h
particleFlowDisplacedVertex_cfi.angles
angles
Definition: particleFlowDisplacedVertex_cfi.py:84
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDHGCalWaferAlgo::idNameSpace
std::string idNameSpace
Definition: DDHGCalWaferAlgo.cc:48
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
DDHGCalWaferAlgo::detectorType
std::vector< int > detectorType
Definition: DDHGCalWaferAlgo.cc:45
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
DDHGCalWaferAlgo::cellSize
double cellSize
Definition: DDHGCalWaferAlgo.cc:39
DDHGCalWaferAlgo::positionY
std::vector< int > positionY
Definition: DDHGCalWaferAlgo.cc:43
DDAlgorithmFactory.h
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:66
DDRotation
ROOT::Math::Rotation3D DDRotation
Definition: DDEcalEndcapAlgo.cc:18