CMS 3D CMS Logo

DDTECPhiAltAlgo.cc
Go to the documentation of this file.
1 // File: DDTECPhiAltAlgo.cc
3 // Description: Position n copies inside and outside Z at alternate phi values
5 
12 #include "CLHEP/Units/GlobalPhysicalConstants.h"
13 #include "CLHEP/Units/GlobalSystemOfUnits.h"
14 
15 #include <cmath>
16 #include <algorithm>
17 #include <map>
18 #include <string>
19 #include <vector>
20 
21 using namespace std;
22 
23 class DDTECPhiAltAlgo : public DDAlgorithm {
24 public:
25  //Constructor and Destructor
27  ~DDTECPhiAltAlgo() override;
28 
29  void initialize(const DDNumericArguments& nArgs,
30  const DDVectorArguments& vArgs,
31  const DDMapArguments& mArgs,
32  const DDStringArguments& sArgs,
33  const DDStringVectorArguments& vsArgs) override;
34 
35  void execute(DDCompactView& cpv) override;
36 
37 private:
38  double startAngle; //Start angle
39  double incrAngle; //Increment in angle
40  double radius; //Radius
41  double zIn; //z position for the even ones
42  double zOut; //z position for the odd ones
43  int number; //Number of copies
44  int startCopyNo; //Start copy number
45  int incrCopyNo; //Increment in copy number
46 
47  string idNameSpace; //Namespace of this and ALL sub-parts
48  string childName; //Child name
49 };
50 
51 DDTECPhiAltAlgo::DDTECPhiAltAlgo() { LogDebug("TECGeom") << "DDTECPhiAltAlgo info: Creating an instance"; }
52 
54 
56  const DDVectorArguments&,
57  const DDMapArguments&,
58  const DDStringArguments& sArgs,
59  const DDStringVectorArguments&) {
60  startAngle = nArgs["StartAngle"];
61  incrAngle = nArgs["IncrAngle"];
62  radius = nArgs["Radius"];
63  zIn = nArgs["ZIn"];
64  zOut = nArgs["ZOut"];
65  number = int(nArgs["Number"]);
66  startCopyNo = int(nArgs["StartCopyNo"]);
67  incrCopyNo = int(nArgs["IncrCopyNo"]);
68 
69  LogDebug("TECGeom") << "DDTECPhiAltAlgo debug: Parameters for "
70  << "positioning--"
71  << "\tStartAngle " << startAngle / CLHEP::deg << "\tIncrAngle " << incrAngle / CLHEP::deg
72  << "\tRadius " << radius << "\tZ in/out " << zIn << ", " << zOut << "\tCopy Numbers " << number
73  << " Start/Increment " << startCopyNo << ", " << incrCopyNo;
74 
75  idNameSpace = DDCurrentNamespace::ns();
76  childName = sArgs["ChildName"];
77  DDName parentName = parent().name();
78  LogDebug("TECGeom") << "DDTECPhiAltAlgo debug: Parent " << parentName << "\tChild " << childName << " NameSpace "
79  << idNameSpace;
80 }
81 
83  if (number > 0) {
84  double theta = 90. * CLHEP::deg;
85  int copyNo = startCopyNo;
86 
87  DDName mother = parent().name();
88  DDName child(DDSplit(childName).first, DDSplit(childName).second);
89  for (int i = 0; i < number; i++) {
90  double phiz = startAngle + i * incrAngle;
91  double phix = phiz + 90. * CLHEP::deg;
92  double phideg = phiz / CLHEP::deg;
93 
95  string rotstr = DDSplit(childName).first + to_string(phideg * 10.);
96  rotation = DDRotation(DDName(rotstr, idNameSpace));
97  if (!rotation) {
98  LogDebug("TECGeom") << "DDTECPhiAltAlgo test: Creating a new "
99  << "rotation " << rotstr << "\t" << theta / CLHEP::deg << ", " << phix / CLHEP::deg
100  << ", 0, 0, " << theta / CLHEP::deg << ", " << phiz / CLHEP::deg;
101  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, 0., 0., theta, phiz);
102  }
103 
104  double xpos = radius * cos(phiz);
105  double ypos = radius * sin(phiz);
106  double zpos;
107  if (i % 2 == 0)
108  zpos = zIn;
109  else
110  zpos = zOut;
111  DDTranslation tran(xpos, ypos, zpos);
112 
113  cpv.position(child, mother, copyNo, tran, rotation);
114  LogDebug("TECGeom") << "DDTECPhiAltAlgo test: " << child << " number " << copyNo << " positioned in " << mother
115  << " at " << tran << " with " << rotation;
116  copyNo += incrCopyNo;
117  }
118  }
119 }
120 
121 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTECPhiAltAlgo, "track:DDTECPhiAltAlgo");
DDTECPhiAltAlgo
Definition: DDTECPhiAltAlgo.cc:23
DDCurrentNamespace.h
mps_fire.i
i
Definition: mps_fire.py:355
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
DDTECPhiAltAlgo::incrAngle
double incrAngle
Definition: DDTECPhiAltAlgo.cc:39
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDSplit.h
DDTECPhiAltAlgo::zOut
double zOut
Definition: DDTECPhiAltAlgo.cc:42
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
DDTECPhiAltAlgo::startCopyNo
int startCopyNo
Definition: DDTECPhiAltAlgo.cc:44
dqmdumpme.first
first
Definition: dqmdumpme.py:55
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDTECPhiAltAlgo::childName
string childName
Definition: DDTECPhiAltAlgo.cc:48
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
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
DDTECPhiAltAlgo::number
int number
Definition: DDTECPhiAltAlgo.cc:43
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
DDTECPhiAltAlgo::incrCopyNo
int incrCopyNo
Definition: DDTECPhiAltAlgo.cc:45
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDTypes.h
createfilelist.int
int
Definition: createfilelist.py:10
DDTECPhiAltAlgo::execute
void execute(DDCompactView &cpv) override
Definition: DDTECPhiAltAlgo.cc:82
ReadMapType< double >
DDAlgorithm.h
std
Definition: JetResolutionObject.h:76
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDTECPhiAltAlgo::idNameSpace
string idNameSpace
Definition: DDTECPhiAltAlgo.cc:47
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
class-composition.child
child
Definition: class-composition.py:91
DDTECPhiAltAlgo::radius
double radius
Definition: DDTECPhiAltAlgo.cc:40
DDTECPhiAltAlgo::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDTECPhiAltAlgo.cc:55
DDTECPhiAltAlgo::DDTECPhiAltAlgo
DDTECPhiAltAlgo()
Definition: DDTECPhiAltAlgo.cc:51
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
DDTECPhiAltAlgo::zIn
double zIn
Definition: DDTECPhiAltAlgo.cc:41
child
Definition: simpleInheritance.h:11
DDAlgorithmFactory.h
class-composition.parent
parent
Definition: class-composition.py:88
DDTECPhiAltAlgo::startAngle
double startAngle
Definition: DDTECPhiAltAlgo.cc:38
DDTECPhiAltAlgo::~DDTECPhiAltAlgo
~DDTECPhiAltAlgo() override
Definition: DDTECPhiAltAlgo.cc:53
DDSplit
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = ':'
Definition: DDSplit.cc:3
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