File indexing completed on 2024-04-06 12:03:46
0001 #ifndef BeamSpot_BeamSpot_h
0002 #define BeamSpot_BeamSpot_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include <Rtypes.h>
0014 #include "DataFormats/Math/interface/Error.h"
0015 #include "DataFormats/Math/interface/Point3D.h"
0016 #include <string>
0017 #include <sstream>
0018
0019 namespace reco {
0020
0021 class BeamSpot {
0022 public:
0023
0024 enum BeamType { Unknown = -1, Fake = 0, LHC = 1, Tracker = 2 };
0025
0026
0027 typedef math::XYZPoint Point;
0028 enum { dimension = 7 };
0029 typedef math::Error<dimension>::type CovarianceMatrix;
0030 enum { dim3 = 3 };
0031 typedef math::Error<dim3>::type Covariance3DMatrix;
0032 enum { resdim = 2 };
0033 typedef math::Error<resdim>::type ResCovMatrix;
0034
0035
0036 BeamSpot();
0037
0038
0039 BeamSpot(const Point& point,
0040 double sigmaZ,
0041 double dxdz,
0042 double dydz,
0043 double BeamWidthX,
0044 const CovarianceMatrix& error,
0045 BeamType type = Unknown) {
0046 position_ = point;
0047 sigmaZ_ = sigmaZ;
0048 dxdz_ = dxdz;
0049 dydz_ = dydz;
0050 BeamWidthX_ = BeamWidthX;
0051 BeamWidthY_ = BeamWidthX;
0052 error_ = error;
0053 type_ = type;
0054 emittanceX_ = emittanceY_ = 0;
0055 betaStar_ = 0;
0056 };
0057
0058
0059 const Point& position() const { return position_; }
0060
0061 double x0() const { return position_.X(); }
0062
0063 double y0() const { return position_.Y(); }
0064
0065 double z0() const { return position_.Z(); }
0066
0067
0068 double x(const double z) const { return x0() + dxdz() * (z - z0()); }
0069
0070 double y(const double z) const { return y0() + dydz() * (z - z0()); }
0071
0072 const Point position(const double z) const;
0073
0074
0075
0076 double sigmaZ() const { return sigmaZ_; }
0077
0078 double dxdz() const { return dxdz_; }
0079
0080 double dydz() const { return dydz_; }
0081
0082 double BeamWidthX() const { return BeamWidthX_; }
0083
0084 double BeamWidthY() const { return BeamWidthY_; }
0085
0086 double x0Error() const { return sqrt(error_(0, 0)); }
0087
0088 double y0Error() const { return sqrt(error_(1, 1)); }
0089
0090 double z0Error() const { return sqrt(error_(2, 2)); }
0091
0092 double sigmaZ0Error() const { return sqrt(error_(3, 3)); }
0093
0094 double dxdzError() const { return sqrt(error_(4, 4)); }
0095
0096 double dydzError() const { return sqrt(error_(5, 5)); }
0097
0098
0099 double BeamWidthXError() const { return sqrt(error_(6, 6)); }
0100
0101 double BeamWidthYError() const { return sqrt(error_(6, 6)); }
0102
0103
0104 void setBeamWidthX(double v) { BeamWidthX_ = v; }
0105 void setBeamWidthY(double v) { BeamWidthY_ = v; }
0106
0107
0108 double covariance(int i, int j) const { return error_(i, j); }
0109
0110 CovarianceMatrix covariance() const { return error_; }
0111
0112 Covariance3DMatrix covariance3D() const {
0113 Covariance3DMatrix matrix;
0114 for (int j = 0; j < 3; j++) {
0115 for (int k = j; k < 3; k++) {
0116 matrix(j, k) = error_(j, k);
0117 }
0118 }
0119 return matrix;
0120 };
0121
0122 BeamType type() const { return type_; }
0123
0124 void setType(BeamType type) { type_ = type; }
0125
0126 Covariance3DMatrix rotatedCovariance3D() const;
0127
0128
0129 double emittanceX() const { return emittanceX_; }
0130 double emittanceY() const { return emittanceY_; }
0131 double betaStar() const { return betaStar_; }
0132 double beamWidthFromBeta(double z, double e) const {
0133 return sqrt(e * betaStar_ * (1 + pow((z - position_.Z()) / betaStar_, 2)));
0134 }
0135
0136 void setEmittanceX(double v) { emittanceX_ = v; }
0137 void setEmittanceY(double v) { emittanceY_ = v; }
0138 void setbetaStar(double v) { betaStar_ = v; }
0139
0140
0141 void print(std::stringstream& ss) const;
0142
0143 private:
0144
0145 Point position_;
0146
0147 CovarianceMatrix error_;
0148
0149 Double32_t sigmaZ_;
0150 Double32_t BeamWidthX_;
0151 Double32_t BeamWidthY_;
0152 Double32_t dxdz_;
0153 Double32_t dydz_;
0154 Double32_t emittanceX_;
0155 Double32_t emittanceY_;
0156 Double32_t betaStar_;
0157
0158 BeamType type_;
0159 };
0160
0161 std::ostream& operator<<(std::ostream&, BeamSpot beam);
0162
0163 }
0164
0165 #endif