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