CMS 3D CMS Logo

DDGEMAngular.cc
Go to the documentation of this file.
1 // File: DDGEMAngular.cc
3 // Description: Position inside the mother according to (eta,phi)
5 
6 #include <cmath>
7 #include <algorithm>
8 #include <map>
9 #include <string>
10 #include <vector>
11 
20 
21 //#define EDM_ML_DEBUG
22 
23 using namespace angle_units::operators;
24 
25 class DDGEMAngular : public DDAlgorithm {
26 public:
27  //Constructor and Destructor
28  DDGEMAngular();
29  ~DDGEMAngular() 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 
37  void execute(DDCompactView& cpv) override;
38 
39 private:
40  double startAngle; //Start angle
41  double stepAngle; //Step angle
42  int invert; //inverted or forward
43  double rPos; //Radial position of center
44  double zoffset; //Offset in z
45  int n; //Mumber of copies
46  int startCopyNo; //Start copy Number
47  int incrCopyNo; //Increment copy Number
48 
49  std::string rotns; //Namespace for rotation matrix
50  std::string idNameSpace; //Namespace of this and ALL sub-parts
51  std::string childName; //Children name
52 };
53 
55 #ifdef EDM_ML_DEBUG
56  edm::LogVerbatim("MuonGeom") << "DDGEMAngular: Creating an instance";
57 #endif
58 }
59 
61 
63  const DDVectorArguments&,
64  const DDMapArguments&,
65  const DDStringArguments& sArgs,
66  const DDStringVectorArguments&) {
67  startAngle = nArgs["startAngle"];
68  stepAngle = nArgs["stepAngle"];
69  invert = int(nArgs["invert"]);
70  rPos = nArgs["rPosition"];
71  zoffset = nArgs["zoffset"];
72  n = int(nArgs["n"]);
73  startCopyNo = int(nArgs["startCopyNo"]);
74  incrCopyNo = int(nArgs["incrCopyNo"]);
75 #ifdef EDM_ML_DEBUG
76  edm::LogVerbatim("MuonGeom") << "DDGEMAngular: Parameters for positioning-- " << n << " copies in steps of "
77  << convertRadToDeg(stepAngle) << " from " << convertRadToDeg(startAngle)
78  << " (inversion flag " << invert << ") \trPos " << rPos << " Zoffest " << zoffset
79  << "\tStart and inremental "
80  << "copy nos " << startCopyNo << ", " << incrCopyNo;
81 #endif
82 
83  rotns = sArgs["RotNameSpace"];
84  idNameSpace = DDCurrentNamespace::ns();
85  childName = sArgs["ChildName"];
86 #ifdef EDM_ML_DEBUG
87  edm::LogVerbatim("MuonGeom") << "DDGEMAngular: Parent " << parent().name() << "\tChild " << childName
88  << "\tNameSpace " << idNameSpace << "\tRotation Namespace " << rotns;
89 #endif
90 }
91 
93  double phi = startAngle;
94  int copyNo = startCopyNo;
95 
96  for (int ii = 0; ii < n; ii++) {
97  double phitmp = phi;
98  if (phitmp >= 2._pi)
99  phitmp -= 2._pi;
101  std::string rotstr("RG");
102 
103  if (invert > 0)
104  rotstr += "I";
105  rotstr += formatAsDegrees(phitmp);
106  rotation = DDRotation(DDName(rotstr, rotns));
107  if (!rotation) {
108  double thetax = 90.0_deg;
109  double phix = invert == 0 ? (90.0_deg + phitmp) : (-90.0_deg + phitmp);
110  double thetay = invert == 0 ? 0.0 : 180.0_deg;
111  double phiz = phitmp;
112 #ifdef EDM_ML_DEBUG
113  edm::LogVerbatim("MuonGeom") << "DDGEMAngular: Creating a new rotation " << DDName(rotstr, idNameSpace) << "\t "
114  << convertRadToDeg(thetax) << ", " << convertRadToDeg(phix) << ", "
115  << convertRadToDeg(thetay) << ", 0, " << convertRadToDeg(thetax) << ", "
116  << convertRadToDeg(phiz);
117 #endif
118  rotation = DDrot(DDName(rotstr, rotns), thetax, phix, thetay, 0., thetax, phiz);
119  }
120 
121  DDTranslation tran(rPos * cos(phitmp), rPos * sin(phitmp), zoffset);
122 
123  DDName parentName = parent().name();
124  cpv.position(DDName(childName, idNameSpace), parentName, copyNo, tran, rotation);
125 #ifdef EDM_ML_DEBUG
126  edm::LogVerbatim("MuonGeom") << "DDGEMAngular: " << DDName(childName, idNameSpace) << " number " << copyNo
127  << " positioned in " << parentName << " at " << tran << " with " << rotstr << " "
128  << rotation;
129 #endif
130  phi += stepAngle;
131  copyNo += incrCopyNo;
132  }
133 }
134 
135 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDGEMAngular, "muon:DDGEMAngular");
PluginFactory.h
DDCurrentNamespace.h
MessageLogger.h
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
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
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
DDGEMAngular::rPos
double rPos
Definition: DDGEMAngular.cc:43
DDGEMAngular::~DDGEMAngular
~DDGEMAngular() override
Definition: DDGEMAngular.cc:60
DDGEMAngular::incrCopyNo
int incrCopyNo
Definition: DDGEMAngular.cc:47
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDGEMAngular::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDGEMAngular.cc:62
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
DDGEMAngular::startAngle
double startAngle
Definition: DDGEMAngular.cc:40
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
DDGEMAngular::idNameSpace
std::string idNameSpace
Definition: DDGEMAngular.cc:50
formatAsDegrees
std::string formatAsDegrees(double radianVal)
Definition: DDTypes.cc:68
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDGEMAngular::childName
std::string childName
Definition: DDGEMAngular.cc:51
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
DDGEMAngular::invert
int invert
Definition: DDGEMAngular.cc:42
DDGEMAngular::execute
void execute(DDCompactView &cpv) override
Definition: DDGEMAngular.cc:92
edmplugin::PluginFactory
Definition: PluginFactory.h:34
angle_units::operators
Definition: angle_units.h:11
DDTypes.h
DDGEMAngular
Definition: DDGEMAngular.cc:25
createfilelist.int
int
Definition: createfilelist.py:10
DDLogicalPart.h
DDGEMAngular::stepAngle
double stepAngle
Definition: DDGEMAngular.cc:41
ReadMapType< double >
DDGEMAngular::startCopyNo
int startCopyNo
Definition: DDGEMAngular.cc:46
DDAlgorithm.h
l1tstage2_dqm_sourceclient-live_cfg.invert
invert
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:85
DDGEMAngular::n
int n
Definition: DDGEMAngular.cc:45
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DDGEMAngular::zoffset
double zoffset
Definition: DDGEMAngular.cc:44
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
DDGEMAngular::rotns
std::string rotns
Definition: DDGEMAngular.cc:49
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
angle_units.h
DDAlgorithmFactory.h
class-composition.parent
parent
Definition: class-composition.py:88
cuy.ii
ii
Definition: cuy.py:590
DDGEMAngular::DDGEMAngular
DDGEMAngular()
Definition: DDGEMAngular.cc:54
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