CMS 3D CMS Logo

DDBHMAngular.cc
Go to the documentation of this file.
1 // File: DDBHMAngular.cc
3 // Description: Position inside the mother according to phi
5 
6 #include <algorithm>
7 #include <cmath>
8 #include <map>
9 #include <string>
10 #include <vector>
11 
22 
23 using namespace geant_units::operators;
24 
25 //#define EDM_ML_DEBUG
26 
27 class DDBHMAngular : public DDAlgorithm {
28 public:
29  //Constructor and Destructor
30  DDBHMAngular();
31 
32  void initialize(const DDNumericArguments& nArgs,
33  const DDVectorArguments& vArgs,
34  const DDMapArguments& mArgs,
35  const DDStringArguments& sArgs,
36  const DDStringVectorArguments& vsArgs) override;
37 
38  void execute(DDCompactView& cpv) override;
39 
40 private:
41  int units; //Number of copies
42  double rr; //Radial position of the detectors
43  double dphi; //the distance in phi between the detectors
44 
45  std::string rotMat; //Name of the rotation matrix
46  std::string childName; //Children name
47 };
48 
49 DDBHMAngular::DDBHMAngular() { edm::LogVerbatim("ForwardGeom") << "DDBHMAngular test: Creating an instance"; }
50 
52  const DDVectorArguments&,
53  const DDMapArguments&,
54  const DDStringArguments& sArgs,
55  const DDStringVectorArguments&) {
56  units = int(nArgs["number"]);
57  rr = nArgs["radius"];
58  dphi = nArgs["deltaPhi"];
59 #ifdef EDM_ML_DEBUG
60  edm::LogVerbatim("ForwardGeom") << "DDBHMAngular debug: Parameters for positioning-- " << units
61  << " copies at radius " << convertMmToCm(rr) << " cm with delta(phi) "
62  << convertRadToDeg(dphi);
63 #endif
64  rotMat = sArgs["Rotation"];
65  childName = sArgs["ChildName"];
66 #ifdef EDM_ML_DEBUG
67  edm::LogVerbatim("ForwardGeom") << "DDBHMAngular debug: Parent " << parent().name() << "\tChild " << childName
68  << "\tRotation matrix " << rotMat;
69 #endif
70 }
71 
73  DDName child(DDSplit(childName).first, DDSplit(childName).second);
74  DDName parentName = parent().name();
75  std::string rotstr = DDSplit(rotMat).first;
77  if (rotstr != "NULL") {
78  std::string rotns = DDSplit(rotMat).second;
79  rot = DDRotation(DDName(rotstr, rotns));
80  }
81 
82  static const double fac1 = 0.5;
83  static const double fac2 = 1.5;
84  static const double fac3 = 14.5;
85  static const double fac4 = 15.5;
86  for (int jj = 0; jj < units; jj++) {
87  double driverX(0), driverY(0), driverZ(0);
88  if (jj < 16) {
89  driverX = rr * cos((jj + fac1) * dphi);
90  driverY = sqrt(rr * rr - driverX * driverX);
91  } else if (jj == 16) {
92  driverX = rr * cos(fac4 * dphi);
93  driverY = -sqrt(rr * rr - driverX * driverX);
94  } else if (jj == 17) {
95  driverX = rr * cos(fac3 * dphi);
96  driverY = -sqrt(rr * rr - driverX * driverX);
97  } else if (jj == 18) {
98  driverX = rr * cos(fac1 * dphi);
99  driverY = -sqrt(rr * rr - driverX * driverX);
100  } else if (jj == 19) {
101  driverX = rr * cos(fac2 * dphi);
102  driverY = -sqrt(rr * rr - driverX * driverX);
103  }
104  DDTranslation tran(driverX, driverY, driverZ);
105 
106  cpv.position(child, parentName, jj + 1, tran, rot);
107 #ifdef EDM_ML_DEBUG
108  edm::LogVerbatim("ForwardGeom") << "DDBHMAngular test: " << child << " number " << jj + 1 << " positioned in "
109  << parentName << " at " << tran << " with " << rot;
110 #endif
111  }
112 }
113 
114 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDBHMAngular, "bhmalgo:DDBHMAngular");
Log< level::Info, true > LogVerbatim
static AlgebraicMatrix initialize()
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDBHMAngular.cc:51
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
U second(std::pair< T, U > const &p)
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
constexpr NumType convertMmToCm(NumType millimeters)
Definition: angle_units.h:44
std::string rotMat
Definition: DDBHMAngular.cc:45
TString units(TString variable, Char_t axis)
void execute(DDCompactView &cpv) override
Definition: DDBHMAngular.cc:72
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
std::string childName
Definition: DDBHMAngular.cc:46