CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BeamSpot.cc
Go to the documentation of this file.
1 
17 
18 #include <iostream>
19 
20 
21 namespace reco {
22 
23  using namespace math;
24 
26  // initialize
27  position_ = Point(0.,0.,0.);
28  sigmaZ_ = 0.;
29  dxdz_ = 0.;
30  dydz_ = 0.;
31  BeamWidthX_ = 0.; BeamWidthY_ = 0;
32  for (int j=0; j<7; j++) {
33  for (int k=j; k<7; k++) {
34  error_(j,k) = 0.;
35  }
36  }
37  type_ = Unknown;
38  emittanceX_ = 0;
39  emittanceY_ = 0;
40  betaStar_ = 0;
41  }
42 
43  const BeamSpot::Point BeamSpot::position(const double z) const {
44 
45  Point pos(x(z),y(z),z);
46  return pos;
47 
48  }
49 
50 
51  void BeamSpot::print(std::stringstream& ss) const {
52 
53  ss << "-----------------------------------------------------\n"
54  << " Beam Spot Data\n\n"
55  << " Beam type = " << type() << "\n"
56  << " X0 = " << x0() << " +/- " << x0Error() << " [cm]\n"
57  << " Y0 = " << y0() << " +/- " << y0Error() << " [cm]\n"
58  << " Z0 = " << z0() << " +/- " << z0Error() << " [cm]\n"
59  << " Sigma Z0 = " << sigmaZ() << " +/- " << sigmaZ0Error() << " [cm]\n"
60  << " dxdz = " << dxdz() << " +/- " << dxdzError() << " [radians]\n"
61  << " dydz = " << dydz() << " +/- " << dydzError() << " [radians]\n"
62  << " Beam width X = " << BeamWidthX() << " +/- " << BeamWidthXError() << " [cm]\n"
63  << " Beam width Y = " << BeamWidthY() << " +/- " << BeamWidthYError() << " [cm]\n"
64  << " EmittanceX = " << emittanceX() << " [cm]\n"
65  << " EmittanceY = " << emittanceY() << " [cm]\n"
66  << " beta-star = " << betaStar() << " [cm]\n"
67  << "-----------------------------------------------------\n\n";
68 
69  }
70 
71  //
72  std::ostream& operator<< ( std::ostream& os, BeamSpot beam ) {
73  std::stringstream ss;
74  beam.print(ss);
75  os << ss.str();
76  return os;
77  }
78 
80  {
81  AlgebraicVector3 newZ(dxdz(), dydz(), 1.);
82  AlgebraicVector3 globalZ(0.,0.,1.);
83  AlgebraicVector3 rotationAxis = ROOT::Math::Cross(globalZ.Unit(), newZ.Unit());
84  float rotationAngle = -acos( ROOT::Math::Dot(globalZ.Unit(),newZ.Unit()));
85  AlgebraicVector a = asHepVector(rotationAxis);
86  Basic3DVector<float> aa(a[0], a[1], a[2]);
87  TkRotation<float> rotation(aa ,rotationAngle);
88  AlgebraicMatrix33 rotationMatrix;
89  rotationMatrix(0,0) = rotation.xx();
90  rotationMatrix(0,1) = rotation.xy();
91  rotationMatrix(0,2) = rotation.xz();
92  rotationMatrix(1,0) = rotation.yx();
93  rotationMatrix(1,1) = rotation.yy();
94  rotationMatrix(1,2) = rotation.yz();
95  rotationMatrix(2,0) = rotation.zx();
96  rotationMatrix(2,1) = rotation.zy();
97  rotationMatrix(2,2) = rotation.zz();
98 
99  AlgebraicSymMatrix33 diagError ;
100  diagError(0,0) = pow(BeamWidthX(),2);
101  diagError(1,1) = pow(BeamWidthY(),2);
102  diagError(2,2) = pow(sigmaZ(),2);
103 
104  Covariance3DMatrix matrix;
105  matrix = ROOT::Math::Similarity(rotationMatrix, diagError) + covariance3D();
106  return matrix;
107  }
108 
109 }
T xx() const
type
Definition: HCALResponse.h:22
math::Error< dim3 >::type Covariance3DMatrix
Definition: BeamSpot.h:34
BeamSpot()
default constructor
Definition: BeamSpot.cc:25
T yx() const
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:30
std::pair< double, double > Point
Definition: CaloEllipse.h:18
double double double z
T zx() const
T xy() const
T zz() const
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:72
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
ROOT::Math::SVector< double, 3 > AlgebraicVector3
T zy() const
int j
Definition: DBlmapReader.cc:9
T yy() const
int k[5][pyjets_maxn]
void print(std::stringstream &ss) const
print information
Definition: BeamSpot.cc:51
CLHEP::HepVector AlgebraicVector
double a
Definition: hdecay.h:121
T xz() const
const Point & position() const
position
Definition: BeamSpot.h:63
Definition: DDAxes.h:10
Covariance3DMatrix rotatedCovariance3D() const
Definition: BeamSpot.cc:79
CLHEP::HepVector asHepVector(const ROOT::Math::SVector< double, N > &v)
Definition: Migration.h:43
T yz() const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepStd< double, 3, 3 > > AlgebraicMatrix33