CMS 3D CMS Logo

DDHCalTBZposAlgo.cc
Go to the documentation of this file.
1 // File: DDHCalTBZposAlgo.cc
3 // Description: Position inside the mother by shifting along Z given by eta
5 
6 #include <cmath>
7 #include <algorithm>
8 #include <map>
9 #include <string>
10 #include <vector>
11 
21 
22 //#define EDM_ML_DEBUG
23 using namespace geant_units::operators;
24 
25 class DDHCalTBZposAlgo : public DDAlgorithm {
26 public:
27  //Constructor and Destructor
29  ~DDHCalTBZposAlgo() 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 eta; //Eta at which beam is focussed
41  double theta; //Corresponding theta value
42  double shiftY; //Shift along Y
43  double shiftX; //Shift along X
44  double zoffset; //Offset in z
45  double dist; //Radial distance
46  double tilt; //Tilt with respect to y-axis
47  int copyNumber; //Copy Number
48 
49  std::string idNameSpace; //Namespace of this and ALL sub-parts
50  std::string childName; //Children name
51 };
52 
54 #ifdef EDM_ML_DEBUG
55  edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: Creating an instance";
56 #endif
57 }
58 
60 
62  const DDVectorArguments&,
63  const DDMapArguments&,
64  const DDStringArguments& sArgs,
65  const DDStringVectorArguments&) {
66  eta = nArgs["Eta"];
67  theta = 2.0 * atan(exp(-eta));
68  shiftX = nArgs["ShiftX"];
69  shiftY = nArgs["ShiftY"];
70  zoffset = nArgs["Zoffset"];
71  dist = nArgs["Distance"];
72  tilt = nArgs["TiltAngle"];
73  copyNumber = int(nArgs["Number"]);
74  edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: Parameters for position"
75  << "ing--"
76  << " Eta " << eta << "\tTheta " << convertRadToDeg(theta) << "\tShifts " << shiftX
77  << ", " << shiftY << " along x, y "
78  << "axes; \tZoffest " << zoffset << "\tRadial Distance " << dist << "\tTilt angle "
79  << convertRadToDeg(tilt) << "\tcopyNumber " << copyNumber;
80 
81  idNameSpace = DDCurrentNamespace::ns();
82  childName = sArgs["ChildName"];
83 #ifdef EDM_ML_DEBUG
84  edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: Parent " << parent().name() << "\tChild " << childName
85  << " NameSpace " << idNameSpace;
86 #endif
87 }
88 
90  DDName mother = parent().name();
91  DDName child(DDSplit(childName).first, DDSplit(childName).second);
92 
93  double thetax = 90._deg - theta;
94  double z = zoffset + dist * tan(thetax);
95  double x = shiftX - shiftY * sin(tilt);
96  double y = shiftY * cos(tilt);
97  DDTranslation tran(x, y, z);
99  if (tilt != 0) {
100  std::string rotstr = "R" + formatAsDegrees(tilt);
101  rot = DDRotation(DDName(rotstr, idNameSpace));
102  if (!rot) {
103 #ifdef EDM_ML_DEBUG
104  edm::LogVerbatim("HCalGeom") << "DDHCalZposAlgo: Creating a rotation " << DDName(rotstr, idNameSpace) << "\t90, "
105  << convertRadToDeg(tilt) << ",90," << (90 + convertRadToDeg(tilt)) << ", 0, 0";
106 #endif
107  rot = DDrot(DDName(rotstr, idNameSpace), 90._deg, tilt, 90._deg, (90._deg + tilt), 0.0, 0.0);
108  }
109  }
110  cpv.position(child, mother, copyNumber, tran, rot);
111 #ifdef EDM_ML_DEBUG
112  edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: " << child << " number " << copyNumber << " positioned in "
113  << mother << " at " << tran << " with " << rot;
114 #endif
115 }
116 
117 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHCalTBZposAlgo, "hcal:DDHCalTBZposAlgo");
PluginFactory.h
DDCurrentNamespace.h
DDHCalTBZposAlgo::execute
void execute(DDCompactView &cpv) override
Definition: DDHCalTBZposAlgo.cc:89
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
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDHCalTBZposAlgo::~DDHCalTBZposAlgo
~DDHCalTBZposAlgo() override
Definition: DDHCalTBZposAlgo.cc:59
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
DDSplit.h
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
geant_units::operators
Definition: GeantUnits.h:18
DDHCalTBZposAlgo::DDHCalTBZposAlgo
DDHCalTBZposAlgo()
Definition: DDHCalTBZposAlgo.cc:53
dqmdumpme.first
first
Definition: dqmdumpme.py:55
DDHCalTBZposAlgo::shiftX
double shiftX
Definition: DDHCalTBZposAlgo.cc:43
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDHCalTBZposAlgo::idNameSpace
std::string idNameSpace
Definition: DDHCalTBZposAlgo.cc:49
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
DDHCalTBZposAlgo::dist
double dist
Definition: DDHCalTBZposAlgo.cc:45
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
PVValHelper::eta
Definition: PVValidationHelpers.h:69
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDHCalTBZposAlgo::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDHCalTBZposAlgo.cc:61
DDHCalTBZposAlgo::copyNumber
int copyNumber
Definition: DDHCalTBZposAlgo.cc:47
formatAsDegrees
std::string formatAsDegrees(double radianVal)
Definition: DDTypes.cc:68
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDHCalTBZposAlgo::tilt
double tilt
Definition: DDHCalTBZposAlgo.cc:46
DDHCalTBZposAlgo::zoffset
double zoffset
Definition: DDHCalTBZposAlgo.cc:44
DDHCalTBZposAlgo
Definition: DDHCalTBZposAlgo.cc:25
GeantUnits.h
edmplugin::PluginFactory
Definition: PluginFactory.h:34
DDTypes.h
DDHCalTBZposAlgo::theta
double theta
Definition: DDHCalTBZposAlgo.cc:41
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
createfilelist.int
int
Definition: createfilelist.py:10
DDLogicalPart.h
ReadMapType< double >
DDHCalTBZposAlgo::eta
double eta
Definition: DDHCalTBZposAlgo.cc:40
DDAlgorithm.h
submitPVValidationJobs.child
child
Definition: submitPVValidationJobs.py:119
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
DDHCalTBZposAlgo::childName
std::string childName
Definition: DDHCalTBZposAlgo.cc:50
child
Definition: simpleInheritance.h:11
DDAlgorithmFactory.h
class-composition.parent
parent
Definition: class-composition.py:88
DDHCalTBZposAlgo::shiftY
double shiftY
Definition: DDHCalTBZposAlgo.cc:42
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:18