CMS 3D CMS Logo

DDHCalTestBeamAlgo.cc
Go to the documentation of this file.
1 // File: DDHCalTestBeamAlgo.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 using namespace angle_units::operators;
22 
23 class DDHCalTestBeamAlgo : public DDAlgorithm {
24 public:
25  //Constructor and Destructor
27  ~DDHCalTestBeamAlgo() 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 eta; //Eta at which beam is focussed
39  double phi; //Phi ................
40  double theta; //Corresponding theta value
41  double distance; //Distance of the centre of rotation
42  double distanceZ; //Distance along x-axis of the centre of rotation
43  double dist; //Overall distance
44  double dz; //Half length along z of the volume to be placed
45  int copyNumber; //Copy Number
46 
47  std::string idNameSpace; //Namespace of this and ALL sub-parts
48  std::string childName; //Children name
49 };
50 
52 #ifdef EDM_ML_DEBUG
53  edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo: Creating an instance";
54 #endif
55 }
56 
58 
60  const DDVectorArguments&,
61  const DDMapArguments&,
62  const DDStringArguments& sArgs,
63  const DDStringVectorArguments&) {
64  eta = nArgs["Eta"];
65  theta = 2.0 * atan(exp(-eta));
66  phi = nArgs["Phi"];
67  distance = nArgs["Dist"];
68  distanceZ = nArgs["DistZ"];
69  dz = nArgs["Dz"];
70  copyNumber = int(nArgs["Number"]);
71  dist = (distance + distanceZ / sin(theta));
72 #ifdef EDM_ML_DEBUG
73  edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo: Parameters for position"
74  << "ing--"
75  << " Eta " << eta << "\tPhi " << convertRadToDeg(phi) << "\tTheta "
76  << convertRadToDeg(theta) << "\tDistance " << distance << "/" << distanceZ << "/" << dist
77  << "\tDz " << dz << "\tcopyNumber " << copyNumber;
78 #endif
79  idNameSpace = DDCurrentNamespace::ns();
80  childName = sArgs["ChildName"];
81 #ifdef EDM_ML_DEBUG
82  edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo:Parent " << parent().name() << "\tChild " << childName
83  << " NameSpace " << idNameSpace;
84 #endif
85 }
86 
88  double thetax = 90._deg + theta;
89  double sthx = sin(thetax);
90  if (std::abs(sthx) > 1.e-12)
91  sthx = 1. / sthx;
92  else
93  sthx = 1.;
94  double phix = atan2(sthx * cos(theta) * sin(phi), sthx * cos(theta) * cos(phi));
95  double thetay = 90._deg;
96  double phiy = 90._deg + phi;
97  double thetaz = theta;
98  double phiz = phi;
99 
101  std::string rotstr = childName;
102 #ifdef EDM_ML_DEBUG
103  edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo: Creating a rotation " << rotstr << "\t"
104  << convertRadToDeg(thetax) << "," << convertRadToDeg(phix) << ","
105  << convertRadToDeg(thetay) << "," << convertRadToDeg(phiy) << ","
106  << convertRadToDeg(thetaz) << "," << convertRadToDeg(phiz);
107 #endif
108  rotation = DDrot(DDName(rotstr, idNameSpace), thetax, phix, thetay, phiy, thetaz, phiz);
109 
110  double r = dist * sin(theta);
111  double xpos = r * cos(phi);
112  double ypos = r * sin(phi);
113  double zpos = dist * cos(theta);
114  DDTranslation tran(xpos, ypos, zpos);
115 
116  DDName parentName = parent().name();
117  cpv.position(DDName(childName, idNameSpace), parentName, copyNumber, tran, rotation);
118 #ifdef EDM_ML_DEBUG
119  edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo: " << DDName(childName, idNameSpace) << " number " << copyNumber
120  << " positioned in " << parentName << " at " << tran << " with " << rotation;
121 
122  xpos = (dist - dz) * sin(theta) * cos(phi);
123  ypos = (dist - dz) * sin(theta) * sin(phi);
124  zpos = (dist - dz) * cos(theta);
125 
126  edm::LogInfo("HCalGeom") << "DDHCalTestBeamAlgo: Suggested Beam position "
127  << "(" << xpos << ", " << ypos << ", " << zpos << ") and (dist, eta, phi) = (" << (dist - dz)
128  << ", " << eta << ", " << phi << ")";
129 #endif
130 }
131 
132 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDHCalTestBeamAlgo, "hcal:DDHCalTestBeamAlgo");
DDHCalTestBeamAlgo::~DDHCalTestBeamAlgo
~DDHCalTestBeamAlgo() override
Definition: DDHCalTestBeamAlgo.cc:57
PluginFactory.h
DDCurrentNamespace.h
DDHCalTestBeamAlgo::childName
std::string childName
Definition: DDHCalTestBeamAlgo.cc:48
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
DDHCalTestBeamAlgo::dz
double dz
Definition: DDHCalTestBeamAlgo.cc:44
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
DDHCalTestBeamAlgo::dist
double dist
Definition: DDHCalTestBeamAlgo.cc:43
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
DDHCalTestBeamAlgo::distanceZ
double distanceZ
Definition: DDHCalTestBeamAlgo.cc:42
DDHCalTestBeamAlgo::copyNumber
int copyNumber
Definition: DDHCalTestBeamAlgo.cc:45
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
DDTranslation
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
PVValHelper::eta
Definition: PVValidationHelpers.h:70
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
DDHCalTestBeamAlgo::execute
void execute(DDCompactView &cpv) override
Definition: DDHCalTestBeamAlgo.cc:87
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
DDHCalTestBeamAlgo::distance
double distance
Definition: DDHCalTestBeamAlgo.cc:41
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
edmplugin::PluginFactory
Definition: PluginFactory.h:34
angle_units::operators
Definition: angle_units.h:11
DDTypes.h
createfilelist.int
int
Definition: createfilelist.py:10
DDHCalTestBeamAlgo::phi
double phi
Definition: DDHCalTestBeamAlgo.cc:39
DDLogicalPart.h
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
alignCSCRings.r
r
Definition: alignCSCRings.py:93
ReadMapType< double >
DDAlgorithm.h
PVValHelper::dz
Definition: PVValidationHelpers.h:51
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DDCurrentNamespace::ns
static std::string & ns()
Definition: DDCurrentNamespace.cc:3
DDHCalTestBeamAlgo
Definition: DDHCalTestBeamAlgo.cc:23
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
DDHCalTestBeamAlgo::DDHCalTestBeamAlgo
DDHCalTestBeamAlgo()
Definition: DDHCalTestBeamAlgo.cc:51
DDHCalTestBeamAlgo::theta
double theta
Definition: DDHCalTestBeamAlgo.cc:40
initialize
static AlgebraicMatrix initialize()
Definition: BeamSpotTransientTrackingRecHit.cc:24
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
DDHCalTestBeamAlgo::initialize
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Definition: DDHCalTestBeamAlgo.cc:59
angle_units.h
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7746
DDAlgorithmFactory.h
class-composition.parent
parent
Definition: class-composition.py:98
DDHCalTestBeamAlgo::eta
double eta
Definition: DDHCalTestBeamAlgo.cc:38
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
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
DDHCalTestBeamAlgo::idNameSpace
std::string idNameSpace
Definition: DDHCalTestBeamAlgo.cc:47