CMS 3D CMS Logo

DDTrackerPhiAltAlgo.cc
Go to the documentation of this file.
1 // File: DDTrackerPhiAltAlgo.cc
3 // Description: Position n copies inside and outside at alternate phi values
5 
12 #include "CLHEP/Units/GlobalPhysicalConstants.h"
13 #include "CLHEP/Units/GlobalSystemOfUnits.h"
14 
15 #include <string>
16 #include <vector>
17 
18 using namespace std;
19 
20 class DDTrackerPhiAltAlgo : public DDAlgorithm {
21 public:
22  //Constructor and Destructor
24  ~DDTrackerPhiAltAlgo() override;
25 
26  void initialize(const DDNumericArguments& nArgs,
27  const DDVectorArguments& vArgs,
28  const DDMapArguments& mArgs,
29  const DDStringArguments& sArgs,
30  const DDStringVectorArguments& vsArgs) override;
31 
32  void execute(DDCompactView& cpv) override;
33 
34 private:
35  double tilt; //Tilt of the module
36  double startAngle; //offset in phi
37  double rangeAngle; //Maximum range in phi
38  double radiusIn; //Inner radius
39  double radiusOut; //Outer radius
40  double zpos; //z position
41  int number; //Number of copies
42  int startCopyNo; //Start copy number
43  int incrCopyNo; //Increment in copy number
44 
45  string idNameSpace; //Namespace of this and ALL sub-parts
46  string childName; //Child name
47 };
48 
50  LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo info: Creating an instance";
51 }
52 
54 
56  const DDVectorArguments&,
57  const DDMapArguments&,
58  const DDStringArguments& sArgs,
59  const DDStringVectorArguments&) {
60  tilt = nArgs["Tilt"];
61  startAngle = nArgs["StartAngle"];
62  rangeAngle = nArgs["RangeAngle"];
63  radiusIn = nArgs["RadiusIn"];
64  radiusOut = nArgs["RadiusOut"];
65  zpos = nArgs["ZPosition"];
66  number = int(nArgs["Number"]);
67  startCopyNo = int(nArgs["StartCopyNo"]);
68  incrCopyNo = int(nArgs["IncrCopyNo"]);
69 
70  LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo debug: Parameters for "
71  << "positioning--"
72  << " Tilt " << tilt << "\tStartAngle " << startAngle / CLHEP::deg << "\tRangeAngle "
73  << rangeAngle / CLHEP::deg << "\tRin " << radiusIn << "\tRout " << radiusOut << "\t ZPos "
74  << zpos << "\tCopy Numbers " << number << " Start/Increment " << startCopyNo << ", "
75  << incrCopyNo;
76 
77  idNameSpace = DDCurrentNamespace::ns();
78  childName = sArgs["ChildName"];
79  DDName parentName = parent().name();
80  LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo debug: Parent " << parentName << "\tChild " << childName
81  << " NameSpace " << idNameSpace;
82 }
83 
85  if (number > 0) {
86  double theta = 90. * CLHEP::deg;
87  double dphi;
88  if (number == 1 || fabs(rangeAngle - 360.0 * CLHEP::deg) < 0.001 * CLHEP::deg)
89  dphi = rangeAngle / number;
90  else
91  dphi = rangeAngle / (number - 1);
92  int copyNo = startCopyNo;
93 
94  DDName mother = parent().name();
95  DDName child(DDSplit(childName).first, DDSplit(childName).second);
96  for (int i = 0; i < number; i++) {
97  double phi = startAngle + i * dphi;
98  double phix = phi - tilt + 90. * CLHEP::deg;
99  double phiy = phix + 90. * CLHEP::deg;
100  double phideg = phix / CLHEP::deg;
101 
103  if (phideg != 0) {
104  string rotstr = DDSplit(childName).first + to_string(phideg * 10.);
105  rotation = DDRotation(DDName(rotstr, idNameSpace));
106  if (!rotation) {
107  LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo test: Creating a new"
108  << " rotation " << rotstr << "\t"
109  << "90., " << phix / CLHEP::deg << ", 90.," << phiy / CLHEP::deg << ", 0, 0";
110  rotation = DDrot(DDName(rotstr, idNameSpace), theta, phix, theta, phiy, 0., 0.);
111  }
112  }
113 
114  double xpos, ypos;
115  if (i % 2 == 0) {
116  xpos = radiusIn * cos(phi);
117  ypos = radiusIn * sin(phi);
118  } else {
119  xpos = radiusOut * cos(phi);
120  ypos = radiusOut * sin(phi);
121  }
122  DDTranslation tran(xpos, ypos, zpos);
123 
124  cpv.position(child, mother, copyNo, tran, rotation);
125  LogDebug("TrackerGeom") << "DDTrackerPhiAltAlgo test: " << child << " number " << copyNo << " positioned in "
126  << mother << " at " << tran << " with " << rotation;
127  copyNo += incrCopyNo;
128  }
129  }
130 }
131 
132 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTrackerPhiAltAlgo, "track:DDTrackerPhiAltAlgo");
DDTrackerPhiAltAlgo::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDTrackerPhiAltAlgo.cc:55
DDCurrentNamespace.h
DDTrackerPhiAltAlgo::rangeAngle
double rangeAngle
Definition: DDTrackerPhiAltAlgo.cc:37
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
DDTrackerPhiAltAlgo::incrCopyNo
int incrCopyNo
Definition: DDTrackerPhiAltAlgo.cc:43
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
DDTrackerPhiAltAlgo::zpos
double zpos
Definition: DDTrackerPhiAltAlgo.cc:40
DDTrackerPhiAltAlgo::number
int number
Definition: DDTrackerPhiAltAlgo.cc:41
DDTrackerPhiAltAlgo
Definition: DDTrackerPhiAltAlgo.cc:20
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDSplit.h
DDTrackerPhiAltAlgo::DDTrackerPhiAltAlgo
DDTrackerPhiAltAlgo()
Definition: DDTrackerPhiAltAlgo.cc:49
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
DDTrackerPhiAltAlgo::radiusIn
double radiusIn
Definition: DDTrackerPhiAltAlgo.cc:38
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:81
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
DDTrackerPhiAltAlgo::childName
string childName
Definition: DDTrackerPhiAltAlgo.cc:46
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDTypes.h
createfilelist.int
int
Definition: createfilelist.py:10
DDTrackerPhiAltAlgo::startAngle
double startAngle
Definition: DDTrackerPhiAltAlgo.cc:36
DDTrackerPhiAltAlgo::tilt
double tilt
Definition: DDTrackerPhiAltAlgo.cc:35
DDTrackerPhiAltAlgo::startCopyNo
int startCopyNo
Definition: DDTrackerPhiAltAlgo.cc:42
DDTrackerPhiAltAlgo::~DDTrackerPhiAltAlgo
~DDTrackerPhiAltAlgo() override
Definition: DDTrackerPhiAltAlgo.cc:53
ReadMapType< double >
DDAlgorithm.h
std
Definition: JetResolutionObject.h:76
submitPVValidationJobs.child
child
Definition: submitPVValidationJobs.py:119
DDTrackerPhiAltAlgo::execute
void execute(DDCompactView &cpv) override
Definition: DDTrackerPhiAltAlgo.cc:84
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDTrackerPhiAltAlgo::idNameSpace
string idNameSpace
Definition: DDTrackerPhiAltAlgo.cc:45
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
child
Definition: simpleInheritance.h:11
DDAlgorithmFactory.h
class-composition.parent
parent
Definition: class-composition.py:88
DDTrackerPhiAltAlgo::radiusOut
double radiusOut
Definition: DDTrackerPhiAltAlgo.cc:39
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:76
DDRotation
ROOT::Math::Rotation3D DDRotation
Definition: DDEcalEndcapAlgo.cc:16