Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:56

0001 #ifndef BEAMSPOTOBJECTS_H
0002 #define BEAMSPOTOBJECTS_H
0003 /** \class BeamSpotObjects
0004  *
0005  * Reconstructed beam spot object. It provides position, error, and
0006  * width of the beam position.
0007  *
0008  * \author Francisco Yumiceva, Fermilab (yumiceva@fnal.gov)
0009  *
0010  * \version $Id: BeamSpotObjects.h,v 1.9 2009/03/26 18:39:42 yumiceva Exp $
0011  *
0012  */
0013 
0014 #include "CondFormats/Serialization/interface/Serializable.h"
0015 
0016 #include <cmath>
0017 #include <sstream>
0018 #include <cstring>
0019 
0020 class BeamSpotObjects {
0021 public:
0022   /// default constructor
0023   BeamSpotObjects() : sigmaZ_(0), beamwidthX_(0), beamwidthY_(0), dxdz_(0), dydz_(0), type_(-1) {
0024     beamwidthXError_ = 0;
0025     beamwidthYError_ = 0;
0026     emittanceX_ = 0;
0027     emittanceY_ = 0;
0028     betaStar_ = 0;
0029     std::memset(position_, 0, sizeof position_);
0030     std::memset(covariance_, 0, sizeof covariance_);
0031   }
0032 
0033   virtual ~BeamSpotObjects() {}
0034 
0035   /// set XYZ position
0036   void setPosition(double x, double y, double z) {
0037     position_[0] = x;
0038     position_[1] = y;
0039     position_[2] = z;
0040   };
0041   /// set sigma Z, RMS bunch length
0042   void setSigmaZ(double val) { sigmaZ_ = val; }
0043   /// set dxdz slope, crossing angle
0044   void setdxdz(double val) { dxdz_ = val; }
0045   /// set dydz slope, crossing angle in XZ
0046   void setdydz(double val) { dydz_ = val; }
0047   /// set average transverse beam width X
0048   void setBeamWidthX(double val) { beamwidthX_ = val; }
0049   /// set average transverse beam width Y
0050   void setBeamWidthY(double val) { beamwidthY_ = val; }
0051   /// set beam width X error
0052   void setBeamWidthXError(double val) { beamwidthXError_ = val; }
0053   /// set beam width Y error
0054   void setBeamWidthYError(double val) { beamwidthYError_ = val; }
0055   /// set i,j element of the full covariance matrix 7x7
0056   void setCovariance(int i, int j, double val) { covariance_[i][j] = val; }
0057   /// set beam type
0058   void setType(int type) { type_ = type; }
0059   /// set emittance
0060   void setEmittanceX(double val) { emittanceX_ = val; }
0061   /// set emittance
0062   void setEmittanceY(double val) { emittanceY_ = val; }
0063   /// set beta star
0064   void setBetaStar(double val) { betaStar_ = val; }
0065 
0066   /// get X beam position
0067   double x() const { return position_[0]; }
0068   /// get Y beam position
0069   double y() const { return position_[1]; }
0070   /// get Z beam position
0071   double z() const { return position_[2]; }
0072   /// get sigma Z, RMS bunch length
0073   double sigmaZ() const { return sigmaZ_; }
0074   /// get average transverse beam width
0075   double beamWidthX() const { return beamwidthX_; }
0076   /// get average transverse beam width
0077   double beamWidthY() const { return beamwidthY_; }
0078   /// get dxdz slope, crossing angle in XZ
0079   double dxdz() const { return dxdz_; }
0080   /// get dydz slope, crossing angle in YZ
0081   double dydz() const { return dydz_; }
0082   /// get i,j element of the full covariance matrix 7x7
0083   double covariance(int i, int j) const { return covariance_[i][j]; }
0084   /// get X beam position Error
0085   double xError() const { return sqrt(covariance_[0][0]); }
0086   /// get Y beam position Error
0087   double yError() const { return sqrt(covariance_[1][1]); }
0088   /// get Z beam position Error
0089   double zError() const { return sqrt(covariance_[2][2]); }
0090   /// get sigma Z, RMS bunch length Error
0091   double sigmaZError() const { return sqrt(covariance_[3][3]); }
0092   /// get average transverse beam width error ASSUME the same for X and Y
0093   double beamWidthXError() const { return sqrt(covariance_[6][6]); }
0094   /// get average transverse beam width error X = Y
0095   double beamWidthYError() const { return sqrt(covariance_[6][6]); }
0096   /// get dxdz slope, crossing angle in XZ Error
0097   double dxdzError() const { return sqrt(covariance_[4][4]); }
0098   /// get dydz slope, crossing angle in YZ Error
0099   double dydzError() const { return sqrt(covariance_[5][5]); }
0100   /// get beam type
0101   int beamType() const { return type_; }
0102   /// get emittance
0103   double emittanceX() const { return emittanceX_; }
0104   /// get emittance
0105   double emittanceY() const { return emittanceY_; }
0106   /// get beta star
0107   double betaStar() const { return betaStar_; }
0108 
0109   /// print beam spot parameters
0110   void print(std::stringstream& ss) const;
0111 
0112 protected:
0113   double position_[3];
0114   double sigmaZ_;
0115   double beamwidthX_;
0116   double beamwidthY_;
0117   double beamwidthXError_;
0118   double beamwidthYError_;
0119   double dxdz_;
0120   double dydz_;
0121   double covariance_[7][7];
0122   int type_;
0123   double emittanceX_;
0124   double emittanceY_;
0125   double betaStar_;
0126 
0127   COND_SERIALIZABLE;
0128 };
0129 
0130 std::ostream& operator<<(std::ostream&, BeamSpotObjects beam);
0131 
0132 #endif