CMS 3D CMS Logo

DDPixFwdDiskAlgo.cc
Go to the documentation of this file.
1 // File: DDPixFwdDiskAlgo.cc
3 // Description: Position n copies at given z-values
5 
12 #include "CLHEP/Units/PhysicalConstants.h"
13 #include "CLHEP/Units/SystemOfUnits.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 DDPixFwdDiskAlgo : public DDAlgorithm {
24 public:
25  //Constructor and Destructor
27  ~DDPixFwdDiskAlgo() 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  string idNameSpace; //Namespace of this and ALL sub-parts
39  string childName; //Child name
40  string rotName; //Name of the base rotation matrix
41  string flagString; //Flag if a blade is present
42  int nBlades; //Number of blades
43  int startCopyNo; //Start Copy number
44  double bladeAngle; //Angle of blade rotation aroung y-axis
45  double zPlane; //Common shift in z for all blades
46  vector<double> bladeZShift; //Shift in Z of individual blades
47  double anchorR; //Distance of beam line to anchor point
48  double bladeTilt; //Tilt of the blade around x-axis
49 };
50 
51 DDPixFwdDiskAlgo::DDPixFwdDiskAlgo() { LogDebug("TrackerGeom") << "DDPixFwdDiskAlgo info: Creating an instance"; }
52 
54 
56  const DDVectorArguments& vArgs,
57  const DDMapArguments&,
58  const DDStringArguments& sArgs,
59  const DDStringVectorArguments& vsArgs) {
60  startCopyNo = int(nArgs["StartCopyNo"]);
61  nBlades = int(nArgs["NumberOfBlades"]);
62  bladeAngle = nArgs["BladeAngle"];
63  bladeTilt = nArgs["BladeTilt"];
64  zPlane = nArgs["BladeCommonZ"];
65  bladeZShift = vArgs["BladeZShift"];
66  anchorR = nArgs["AnchorRadius"];
67 
68  idNameSpace = DDCurrentNamespace::ns();
69  childName = sArgs["ChildName"];
70  rotName = sArgs["RotationName"];
71  flagString = sArgs["FlagString"];
72  DDName parentName = parent().name();
73  LogDebug("TrackerGeom") << "DDPixFwdDiskAlgo debug: Parent " << parentName << "\tChild " << childName << " NameSpace "
74  << idNameSpace << "\tRot Name " << rotName << "\tCopyNo (Start/Total) " << startCopyNo << ", "
75  << nBlades << "\tAngles " << bladeAngle / CLHEP::deg << ", " << bladeTilt / CLHEP::deg
76  << "\tZshifts " << zPlane << "\tAmnchor Radius " << anchorR;
77 
78  for (int iBlade = 0; iBlade < nBlades; ++iBlade) {
79  LogDebug("TrackerGeom") << "DDPixFwdDiskAlgo: Blade " << iBlade << " flag " << flagString[iBlade] << " zshift "
80  << bladeZShift[iBlade];
81  }
82 }
83 
85  int copy = startCopyNo;
86  DDName mother = parent().name();
87  DDName child(DDSplit(childName).first, DDSplit(childName).second);
88  string flagSelector = "Y";
89 
90  double deltaPhi = (360. / nBlades) * CLHEP::deg;
91  string rotns = DDSplit(rotName).second;
92  for (int iBlade = 0; iBlade < nBlades; ++iBlade) {
93  if (flagString[iBlade] == flagSelector[0]) {
94  string rotstr = DDSplit(rotName).first + to_string(double(copy));
95 
96  double phi = (iBlade + 0.5) * deltaPhi;
97  // double phi = (iBlade+0.5)*deltaPhi - 90.*CLHEP::deg;
98  double phix = atan2(sin(phi) * cos(bladeAngle), cos(phi) * cos(bladeAngle));
99  double thetx = acos(-sin(bladeAngle));
100  double phiy = atan2((cos(phi) * cos(bladeTilt) + sin(phi) * sin(bladeAngle) * sin(bladeTilt)),
101  (-sin(phi) * cos(bladeTilt) + cos(phi) * sin(bladeAngle) * sin(bladeTilt)));
102  double thety = acos(cos(bladeAngle) * sin(bladeTilt));
103  double phiz = atan2((-cos(phi) * sin(bladeTilt) + sin(phi) * sin(bladeAngle) * cos(bladeTilt)),
104  (sin(phi) * sin(bladeTilt) + cos(phi) * sin(bladeAngle) * cos(bladeTilt)));
105  double thetz = acos(cos(bladeAngle) * cos(bladeTilt));
106  DDRotation rot = DDRotation(DDName(rotstr, rotns));
107  if (!rot) {
108  LogDebug("TrackerGeom") << "DDPixFwdDiskAlgo test: Creating a new "
109  << "rotation: " << rotstr << "\t" << thetx / CLHEP::deg << ", " << phix / CLHEP::deg
110  << ", " << thety / CLHEP::deg << ", " << phiy / CLHEP::deg << ", " << thetz / CLHEP::deg
111  << ", " << phiz / CLHEP::deg;
112  LogDebug("TrackerGeom") << "Rotation Matrix (" << phi / CLHEP::deg << ", " << bladeAngle / CLHEP::deg << ", "
113  << bladeTilt / CLHEP::deg << ") " << cos(phi) * cos(bladeAngle) << ", "
114  << (-sin(phi) * cos(bladeTilt) + cos(phi) * sin(bladeAngle) * sin(bladeTilt)) << ", "
115  << (sin(phi) * sin(bladeTilt) + cos(phi) * sin(bladeAngle) * cos(bladeTilt)) << ", "
116  << sin(phi) * cos(bladeAngle) << ", "
117  << (cos(phi) * cos(bladeTilt) + sin(phi) * sin(bladeAngle) * sin(bladeTilt)) << ", "
118  << (-cos(phi) * sin(bladeTilt) + sin(phi) * sin(bladeAngle) * cos(bladeTilt)) << ", "
119  << -sin(bladeAngle) << ", " << cos(bladeAngle) * sin(bladeTilt) << ", "
120  << cos(bladeAngle) * cos(bladeTilt);
121  rot = DDrot(DDName(rotstr, rotns), thetx, phix, thety, phiy, thetz, phiz);
122  }
123  double xpos = anchorR * (-sin(phi) * cos(bladeTilt) + cos(phi) * sin(bladeAngle) * sin(bladeTilt));
124  double ypos = anchorR * (cos(phi) * cos(bladeTilt) + sin(phi) * sin(bladeAngle) * sin(bladeTilt));
125  double zpos = anchorR * (cos(bladeAngle) * sin(bladeTilt)) + zPlane + bladeZShift[iBlade];
126  DDTranslation tran(xpos, ypos, zpos);
127  cpv.position(child, mother, copy, tran, rot);
128  LogDebug("TrackerGeom") << "DDPixFwdDiskAlgo test: " << child << " number " << copy << " positioned in " << mother
129  << " at " << tran << " with " << rot;
130  }
131  copy++;
132  }
133 }
134 
135 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDPixFwdDiskAlgo, "track:DDPixFwdDiskAlgo");
DDPixFwdDiskAlgo::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDPixFwdDiskAlgo.cc:55
DDCurrentNamespace.h
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
DDPixFwdDiskAlgo::anchorR
double anchorR
Definition: DDPixFwdDiskAlgo.cc:47
DDSplit.h
DDPixFwdDiskAlgo::bladeTilt
double bladeTilt
Definition: DDPixFwdDiskAlgo.cc:48
DDPixFwdDiskAlgo::bladeZShift
vector< double > bladeZShift
Definition: DDPixFwdDiskAlgo.cc:46
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
DDPixFwdDiskAlgo::DDPixFwdDiskAlgo
DDPixFwdDiskAlgo()
Definition: DDPixFwdDiskAlgo.cc:51
dqmdumpme.first
first
Definition: dqmdumpme.py:55
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
DDPixFwdDiskAlgo::idNameSpace
string idNameSpace
Definition: DDPixFwdDiskAlgo.cc:38
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
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
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
DDPixFwdDiskAlgo::childName
string childName
Definition: DDPixFwdDiskAlgo.cc:39
DDPixFwdDiskAlgo::rotName
string rotName
Definition: DDPixFwdDiskAlgo.cc:40
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
DDPixFwdDiskAlgo::nBlades
int nBlades
Definition: DDPixFwdDiskAlgo.cc:42
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDPixFwdDiskAlgo::execute
void execute(DDCompactView &cpv) override
Definition: DDPixFwdDiskAlgo.cc:84
DDTypes.h
createfilelist.int
int
Definition: createfilelist.py:10
DDPixFwdDiskAlgo
Definition: DDPixFwdDiskAlgo.cc:23
DDPixFwdDiskAlgo::bladeAngle
double bladeAngle
Definition: DDPixFwdDiskAlgo.cc:44
DDPixFwdDiskAlgo::zPlane
double zPlane
Definition: DDPixFwdDiskAlgo.cc:45
ReadMapType< double >
DDAlgorithm.h
std
Definition: JetResolutionObject.h:76
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDPixFwdDiskAlgo::startCopyNo
int startCopyNo
Definition: DDPixFwdDiskAlgo.cc:43
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
DDPixFwdDiskAlgo::~DDPixFwdDiskAlgo
~DDPixFwdDiskAlgo() override
Definition: DDPixFwdDiskAlgo.cc:53
class-composition.child
child
Definition: class-composition.py:91
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
DDPixFwdDiskAlgo::flagString
string flagString
Definition: DDPixFwdDiskAlgo.cc:41
child
Definition: simpleInheritance.h:11
DDAlgorithmFactory.h
class-composition.parent
parent
Definition: class-composition.py:88
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