diff --git a/AnalysisDataFormats/SUSYBSMObjects/src/classes_def.xml b/AnalysisDataFormats/SUSYBSMObjects/src/classes_def.xml index 8e9297ad63519..566d074b46348 100644 --- a/AnalysisDataFormats/SUSYBSMObjects/src/classes_def.xml +++ b/AnalysisDataFormats/SUSYBSMObjects/src/classes_def.xml @@ -48,7 +48,7 @@ - + diff --git a/DataFormats/DTRecHit/interface/DTRecHit1D.h b/DataFormats/DTRecHit/interface/DTRecHit1D.h index 0e71892302791..05388699cc862 100644 --- a/DataFormats/DTRecHit/interface/DTRecHit1D.h +++ b/DataFormats/DTRecHit/interface/DTRecHit1D.h @@ -22,80 +22,83 @@ class DTLayer; class GeomDet; -class DTRecHit1D : public RecHit1D { -public: - /// Constructor from wireId and digi time only. - DTRecHit1D(const DTWireId& wireId, DTEnums::DTCellSide lr, float digiTime); +namespace io_v1 { + class DTRecHit1D : public RecHit1D { + public: + /// Constructor from wireId and digi time only. + DTRecHit1D(const DTWireId& wireId, DTEnums::DTCellSide lr, float digiTime); - /// Default constructor - DTRecHit1D(); + /// Default constructor + DTRecHit1D(); - /// Constructor from a local position, wireId and digi time. - /// The 3-dimensional local error is defined as - /// resolution (the cell resolution) for the coordinate being measured - /// and 0 for the two other coordinates - DTRecHit1D(const DTWireId& wireId, DTEnums::DTCellSide lr, float digiTime, const LocalPoint& pos); + /// Constructor from a local position, wireId and digi time. + /// The 3-dimensional local error is defined as + /// resolution (the cell resolution) for the coordinate being measured + /// and 0 for the two other coordinates + DTRecHit1D(const DTWireId& wireId, DTEnums::DTCellSide lr, float digiTime, const LocalPoint& pos); - /// Constructor from a local position and error, wireId and digi time. - DTRecHit1D( - const DTWireId& wireId, DTEnums::DTCellSide lr, float digiTime, const LocalPoint& pos, const LocalError& err); + /// Constructor from a local position and error, wireId and digi time. + DTRecHit1D( + const DTWireId& wireId, DTEnums::DTCellSide lr, float digiTime, const LocalPoint& pos, const LocalError& err); - /// Destructor - ~DTRecHit1D() override; + /// Destructor + ~DTRecHit1D() override; - /// Return the 3-dimensional local position - LocalPoint localPosition() const override { return theLocalPosition; } + /// Return the 3-dimensional local position + LocalPoint localPosition() const override { return theLocalPosition; } - /// Return the 3-dimensional error on the local position - LocalError localPositionError() const override { return theLocalError; } + /// Return the 3-dimensional error on the local position + LocalError localPositionError() const override { return theLocalError; } - DTRecHit1D* clone() const override; + DTRecHit1D* clone() const override; - /// No components rechits: it returns a null vector - std::vector recHits() const override; + /// No components rechits: it returns a null vector + std::vector recHits() const override; - /// No components rechits: it returns a null vector - std::vector recHits() override; + /// No components rechits: it returns a null vector + std::vector recHits() override; - /// The side of the cell - DTEnums::DTCellSide lrSide() const { return theLRSide; } + /// The side of the cell + DTEnums::DTCellSide lrSide() const { return theLRSide; } - /// Set local position - void setPosition(LocalPoint pos) { theLocalPosition = pos; } + /// Set local position + void setPosition(LocalPoint pos) { theLocalPosition = pos; } - /// Set local position error - void setError(LocalError err) { theLocalError = err; } + /// Set local position error + void setError(LocalError err) { theLocalError = err; } - /// Set the local position and its error - void setPositionAndError(LocalPoint pos, LocalError err) { - theLocalPosition = pos; - theLocalError = err; - } + /// Set the local position and its error + void setPositionAndError(LocalPoint pos, LocalError err) { + theLocalPosition = pos; + theLocalError = err; + } - /// Return the wireId - DTWireId wireId() const { return theWireId; } + /// Return the wireId + DTWireId wireId() const { return theWireId; } - /// Return the time (ns) of the digi used to build the rechit - float digiTime() const { return theDigiTime; } + /// Return the time (ns) of the digi used to build the rechit + float digiTime() const { return theDigiTime; } - /// Comparison operator, based on the wireId and the digi time - bool operator==(const DTRecHit1D& hit) const; + /// Comparison operator, based on the wireId and the digi time + bool operator==(const DTRecHit1D& hit) const; -private: - // The wire id - DTWireId theWireId; + private: + // The wire id + DTWireId theWireId; - // Left/Right side code - DTEnums::DTCellSide theLRSide; + // Left/Right side code + DTEnums::DTCellSide theLRSide; - // The digi time used to reconstruct the hit - float theDigiTime; + // The digi time used to reconstruct the hit + float theDigiTime; - // Position and error in the Local Ref. Frame of the DTLayer - LocalPoint theLocalPosition; - LocalError theLocalError; -}; -#endif + // Position and error in the Local Ref. Frame of the DTLayer + LocalPoint theLocalPosition; + LocalError theLocalError; + }; -/// The ostream operator -std::ostream& operator<<(std::ostream& os, const DTRecHit1D& hit); + /// The ostream operator + std::ostream& operator<<(std::ostream& os, const DTRecHit1D& hit); +} // namespace io_v1 +using DTRecHit1D = io_v1::DTRecHit1D; +#endif diff --git a/DataFormats/DTRecHit/interface/DTRecHit1DFwd.h b/DataFormats/DTRecHit/interface/DTRecHit1DFwd.h index 849c80b03f10e..80f7b4603f941 100644 --- a/DataFormats/DTRecHit/interface/DTRecHit1DFwd.h +++ b/DataFormats/DTRecHit/interface/DTRecHit1DFwd.h @@ -1,5 +1,8 @@ #ifndef DataFormats_DTRecHit_DTRecHit1D_h #define DataFormats_DTRecHit_DTRecHit1D_h -class DTRecHit1D; +namespace io_v1 { + class DTRecHit1D; +} +using DTRecHit1D = io_v1::DTRecHit1D; #endif diff --git a/DataFormats/DTRecHit/interface/DTRecHit1DPair.h b/DataFormats/DTRecHit/interface/DTRecHit1DPair.h index c9e7802e972bb..d72b4d1a1f4d7 100644 --- a/DataFormats/DTRecHit/interface/DTRecHit1DPair.h +++ b/DataFormats/DTRecHit/interface/DTRecHit1DPair.h @@ -23,87 +23,89 @@ class DTLayer; -class DTRecHit1DPair : public RecHit1D { -public: - /// Constructor without components: must use setPos and Err! - DTRecHit1DPair(const DTWireId& wireId, const DTDigi& digi); +namespace io_v1 { + class DTRecHit1DPair : public RecHit1D { + public: + /// Constructor without components: must use setPos and Err! + DTRecHit1DPair(const DTWireId& wireId, const DTDigi& digi); - /// Default constructor. Needed to write the RecHit into a STL container. - DTRecHit1DPair(); + /// Default constructor. Needed to write the RecHit into a STL container. + DTRecHit1DPair(); - /// Destructor - ~DTRecHit1DPair() override; + /// Destructor + ~DTRecHit1DPair() override; - // Operations + // Operations - DTRecHit1DPair* clone() const override; + DTRecHit1DPair* clone() const override; - /// Return the 3-dimensional local position. - /// The average theLeftHit/theRightHit hits position, namely the wire position - /// is returned. - LocalPoint localPosition() const override; + /// Return the 3-dimensional local position. + /// The average theLeftHit/theRightHit hits position, namely the wire position + /// is returned. + LocalPoint localPosition() const override; - /// Return the 3-dimensional error on the local position. - /// The error is defiened as half - /// the distance between theLeftHit and theRightHit pos - LocalError localPositionError() const override; + /// Return the 3-dimensional error on the local position. + /// The error is defiened as half + /// the distance between theLeftHit and theRightHit pos + LocalError localPositionError() const override; - /// Access to component RecHits. - /// Return the two recHits (L/R) - std::vector recHits() const override; + /// Access to component RecHits. + /// Return the two recHits (L/R) + std::vector recHits() const override; - /// Non-const access to component RecHits. - /// Return the two recHits (L/R) - std::vector recHits() override; + /// Non-const access to component RecHits. + /// Return the two recHits (L/R) + std::vector recHits() override; - /// Return the detId of the Det (a DTLayer). - virtual DetId geographicalId() const; + /// Return the detId of the Det (a DTLayer). + virtual DetId geographicalId() const; - /// Return the digi time (ns) used to build the rechits - float digiTime() const { return theLeftHit.digiTime(); } + /// Return the digi time (ns) used to build the rechits + float digiTime() const { return theLeftHit.digiTime(); } - /// Comparison operator, based on the wireId and the digi time - bool operator==(const DTRecHit1DPair& hit) const; + /// Comparison operator, based on the wireId and the digi time + bool operator==(const DTRecHit1DPair& hit) const; - /// Inequality operator, defined as the mirror image of the comparions - /// operator - bool operator!=(const DTRecHit1DPair& hit) const { return !(*this == hit); } + /// Inequality operator, defined as the mirror image of the comparions + /// operator + bool operator!=(const DTRecHit1DPair& hit) const { return !(*this == hit); } - /// Return position in the local (layer) coordinate system for a - /// certain hypothesis about the L/R cell side - LocalPoint localPosition(DTEnums::DTCellSide lrside) const; + /// Return position in the local (layer) coordinate system for a + /// certain hypothesis about the L/R cell side + LocalPoint localPosition(DTEnums::DTCellSide lrside) const; - /// Return position error in the local (layer) coordinate system for a - /// certain hypothesis about the L/R cell side - LocalError localPositionError(DTEnums::DTCellSide lrside) const; + /// Return position error in the local (layer) coordinate system for a + /// certain hypothesis about the L/R cell side + LocalError localPositionError(DTEnums::DTCellSide lrside) const; - /// Set the 3-dimensional local position for the component hit - /// corresponding to the given cell side. Default value is assumed for the error. - void setPosition(DTEnums::DTCellSide lrside, const LocalPoint& point); + /// Set the 3-dimensional local position for the component hit + /// corresponding to the given cell side. Default value is assumed for the error. + void setPosition(DTEnums::DTCellSide lrside, const LocalPoint& point); - /// Set the 3-dimensional local position and error for the component hit - /// corresponding to the given cell side. Default value is assumed for the error. - void setPositionAndError(DTEnums::DTCellSide lrside, const LocalPoint& point, const LocalError& err); + /// Set the 3-dimensional local position and error for the component hit + /// corresponding to the given cell side. Default value is assumed for the error. + void setPositionAndError(DTEnums::DTCellSide lrside, const LocalPoint& point, const LocalError& err); - // Return the wireId - DTWireId wireId() const { return theLeftHit.wireId(); } + // Return the wireId + DTWireId wireId() const { return theLeftHit.wireId(); } - /// Return the left/right DTRecHit1D - const DTRecHit1D* componentRecHit(DTEnums::DTCellSide lrSide) const; + /// Return the left/right DTRecHit1D + const DTRecHit1D* componentRecHit(DTEnums::DTCellSide lrSide) const; - /// Get the left and right 1D rechits (first and second respectively). - std::pair componentRecHits() const; + /// Get the left and right 1D rechits (first and second respectively). + std::pair componentRecHits() const; -private: - /// Non const access to left/right DTRecHit1D - DTRecHit1D* componentRecHit(DTEnums::DTCellSide lrSide); + private: + /// Non const access to left/right DTRecHit1D + DTRecHit1D* componentRecHit(DTEnums::DTCellSide lrSide); - // The two rechits - DTRecHit1D theLeftHit; - DTRecHit1D theRightHit; -}; - -/// Ostream operator -std::ostream& operator<<(std::ostream& os, const DTRecHit1DPair& hit); + // The two rechits + DTRecHit1D theLeftHit; + DTRecHit1D theRightHit; + }; + /// Ostream operator + std::ostream& operator<<(std::ostream& os, const DTRecHit1DPair& hit); +} // namespace io_v1 +using DTRecHit1DPair = io_v1::DTRecHit1DPair; #endif diff --git a/DataFormats/DTRecHit/interface/DTRecSegment4D.h b/DataFormats/DTRecHit/interface/DTRecSegment4D.h index bba508c0ec817..d5d4328313a78 100644 --- a/DataFormats/DTRecHit/interface/DTRecSegment4D.h +++ b/DataFormats/DTRecHit/interface/DTRecSegment4D.h @@ -20,127 +20,129 @@ /* C++ Headers */ #include -class DTRecSegment4D : public RecSegment { -public: - friend class DTSegmentUpdator; - /// Empty constructor - DTRecSegment4D() : theProjection(none), theDimension(0) {} +namespace io_v1 { + class DTRecSegment4D : public RecSegment { + public: + friend class ::DTSegmentUpdator; + /// Empty constructor + DTRecSegment4D() : theProjection(none), theDimension(0) {} - /// Construct from phi and Z projections - DTRecSegment4D(const DTChamberRecSegment2D& phiSeg, - const DTSLRecSegment2D& zedSeg, - const LocalPoint& posZInCh, - const LocalVector& dirZInCh); + /// Construct from phi and Z projections + DTRecSegment4D(const DTChamberRecSegment2D& phiSeg, + const DTSLRecSegment2D& zedSeg, + const LocalPoint& posZInCh, + const LocalVector& dirZInCh); - /// Construct from phi projection - DTRecSegment4D(const DTChamberRecSegment2D& phiSeg); + /// Construct from phi projection + DTRecSegment4D(const DTChamberRecSegment2D& phiSeg); - /// Construct from Z projection - DTRecSegment4D(const DTSLRecSegment2D& zedSeg, const LocalPoint& posZInCh, const LocalVector& dirZInCh); + /// Construct from Z projection + DTRecSegment4D(const DTSLRecSegment2D& zedSeg, const LocalPoint& posZInCh, const LocalVector& dirZInCh); - /// Destructor - ~DTRecSegment4D() override; + /// Destructor + ~DTRecSegment4D() override; - //--- Base class interface + //--- Base class interface - DTRecSegment4D* clone() const override { return new DTRecSegment4D(*this); } + DTRecSegment4D* clone() const override { return new DTRecSegment4D(*this); } - /// Parameters of the segment, for the track fit. - /// For a 4D segment: (dx/dy,dy/dz,x,y) - /// For a 2D, phi-only segment: (dx/dz,x) - /// For a 2D, Z-only segment: (dy/dz,y) - AlgebraicVector parameters() const override; + /// Parameters of the segment, for the track fit. + /// For a 4D segment: (dx/dy,dy/dz,x,y) + /// For a 2D, phi-only segment: (dx/dz,x) + /// For a 2D, Z-only segment: (dy/dz,y) + AlgebraicVector parameters() const override; - /// Covariance matrix fo parameters() - AlgebraicSymMatrix parametersError() const override; + /// Covariance matrix fo parameters() + AlgebraicSymMatrix parametersError() const override; - /// The projection matrix relates the trajectory state parameters to the segment parameters(). - AlgebraicMatrix projectionMatrix() const override; + /// The projection matrix relates the trajectory state parameters to the segment parameters(). + AlgebraicMatrix projectionMatrix() const override; - /// Local position in Chamber frame - LocalPoint localPosition() const override { return thePosition; } + /// Local position in Chamber frame + LocalPoint localPosition() const override { return thePosition; } - /// Local position error in Chamber frame - LocalError localPositionError() const override; + /// Local position error in Chamber frame + LocalError localPositionError() const override; - /// Local direction in Chamber frame - LocalVector localDirection() const override { return theDirection; } + /// Local direction in Chamber frame + LocalVector localDirection() const override { return theDirection; } - /// Local direction error in the Chamber frame - LocalError localDirectionError() const override; + /// Local direction error in the Chamber frame + LocalError localDirectionError() const override; - // Chi2 of the segment fit - double chi2() const override; + // Chi2 of the segment fit + double chi2() const override; - // Degrees of freedom of the segment fit - int degreesOfFreedom() const override; + // Degrees of freedom of the segment fit + int degreesOfFreedom() const override; - // Dimension (in parameter space) - int dimension() const override { return theDimension; } + // Dimension (in parameter space) + int dimension() const override { return theDimension; } - // Access to component RecHits (if any) - std::vector recHits() const override; + // Access to component RecHits (if any) + std::vector recHits() const override; - // Non-const access to component RecHits (if any) - std::vector recHits() override; + // Non-const access to component RecHits (if any) + std::vector recHits() override; - //--- Extension of the interface + //--- Extension of the interface - /// Does it have the Phi projection? - bool hasPhi() const { return (theProjection == full || theProjection == phi); } + /// Does it have the Phi projection? + bool hasPhi() const { return (theProjection == full || theProjection == phi); } - /// Does it have the Z projection? - bool hasZed() const { return (theProjection == full || theProjection == Z); } + /// Does it have the Z projection? + bool hasZed() const { return (theProjection == full || theProjection == Z); } - /// The superPhi segment: 0 if no phi projection available - const DTChamberRecSegment2D* phiSegment() const { return hasPhi() ? &thePhiSeg : nullptr; } + /// The superPhi segment: 0 if no phi projection available + const DTChamberRecSegment2D* phiSegment() const { return hasPhi() ? &thePhiSeg : nullptr; } - /// The Z segment: 0 if not zed projection available - const DTSLRecSegment2D* zSegment() const { return hasZed() ? &theZedSeg : nullptr; } + /// The Z segment: 0 if not zed projection available + const DTSLRecSegment2D* zSegment() const { return hasZed() ? &theZedSeg : nullptr; } - /// Set position - void setPosition(LocalPoint pos) { thePosition = pos; } + /// Set position + void setPosition(LocalPoint pos) { thePosition = pos; } - /// Set direction - void setDirection(LocalVector dir) { theDirection = dir; } + /// Set direction + void setDirection(LocalVector dir) { theDirection = dir; } - /// Set covariance matrix - void setCovMatrix(const AlgebraicSymMatrix& mat) { theCovMatrix = mat; } + /// Set covariance matrix + void setCovMatrix(const AlgebraicSymMatrix& mat) { theCovMatrix = mat; } - /// The (specific) DetId of the chamber on which the segment resides - virtual DTChamberId chamberId() const; + /// The (specific) DetId of the chamber on which the segment resides + virtual DTChamberId chamberId() const; -private: - /// Which projections are actually there - enum Projection { full, phi, Z, none }; - Projection theProjection; + private: + /// Which projections are actually there + enum Projection { full, phi, Z, none }; + Projection theProjection; - /// the superPhi segment - DTChamberRecSegment2D* phiSegment() { return &thePhiSeg; } + /// the superPhi segment + DTChamberRecSegment2D* phiSegment() { return &thePhiSeg; } - /// the Z segment - DTSLRecSegment2D* zSegment() { return &theZedSeg; } + /// the Z segment + DTSLRecSegment2D* zSegment() { return &theZedSeg; } - LocalPoint thePosition; // in chamber frame - LocalVector theDirection; // in chamber frame + LocalPoint thePosition; // in chamber frame + LocalVector theDirection; // in chamber frame - void setCovMatrixForZed(const LocalPoint& posZInCh); + void setCovMatrixForZed(const LocalPoint& posZInCh); - // the covariance matrix, has the following meaning - // mat[0][0]=sigma (dx/dz) - // mat[1][1]=sigma (dy/dz) - // mat[2][2]=sigma (x) - // mat[3][3]=sigma (y) - // mat[0][2]=cov(dx/dz,x) - // mat[1][3]=cov(dy/dz,y) - AlgebraicSymMatrix theCovMatrix; + // the covariance matrix, has the following meaning + // mat[0][0]=sigma (dx/dz) + // mat[1][1]=sigma (dy/dz) + // mat[2][2]=sigma (x) + // mat[3][3]=sigma (y) + // mat[0][2]=cov(dx/dz,x) + // mat[1][3]=cov(dy/dz,y) + AlgebraicSymMatrix theCovMatrix; - DTChamberRecSegment2D thePhiSeg; - DTSLRecSegment2D theZedSeg; + DTChamberRecSegment2D thePhiSeg; + DTSLRecSegment2D theZedSeg; - int theDimension; // the dimension of this rechit -}; - -std::ostream& operator<<(std::ostream& os, const DTRecSegment4D& seg); + int theDimension; // the dimension of this rechit + }; + std::ostream& operator<<(std::ostream& os, const DTRecSegment4D& seg); +} // namespace io_v1 +using DTRecSegment4D = io_v1::DTRecSegment4D; #endif // DTRecHit_DTRecSegment4D_h diff --git a/DataFormats/DTRecHit/interface/DTRecSegment4DFwd.h b/DataFormats/DTRecHit/interface/DTRecSegment4DFwd.h index 5774fdeee4aed..d306d1465f8c8 100644 --- a/DataFormats/DTRecHit/interface/DTRecSegment4DFwd.h +++ b/DataFormats/DTRecHit/interface/DTRecSegment4DFwd.h @@ -1,6 +1,9 @@ #ifndef DataFormats_DTRecHit_DTRecSegment4DFwd_h #define DataFormats_DTRecHit_DTRecSegment4DFwd_h -class DTRecSegment4D; +namespace io_v1 { + class DTRecSegment4D; +} +using DTRecSegment4D = io_v1::DTRecSegment4D; #endif diff --git a/DataFormats/DTRecHit/src/DTRecHit1D.cc b/DataFormats/DTRecHit/src/DTRecHit1D.cc index d7206150cc94c..2b328a33d60bc 100644 --- a/DataFormats/DTRecHit/src/DTRecHit1D.cc +++ b/DataFormats/DTRecHit/src/DTRecHit1D.cc @@ -8,74 +8,76 @@ using namespace std; using namespace DTEnums; -// Constructor from wireId and digi time only. -DTRecHit1D::DTRecHit1D(const DTWireId& wireId, - DTEnums::DTCellSide lr, - float digiTime) - : RecHit1D(wireId.layerId()), // the detId of the Det (a DTLayer). - theWireId(wireId), - theLRSide(lr), - theDigiTime(digiTime), - theLocalPosition(), - theLocalError() {} +namespace io_v1 { + // Constructor from wireId and digi time only. + DTRecHit1D::DTRecHit1D(const DTWireId& wireId, + DTEnums::DTCellSide lr, + float digiTime) + : RecHit1D(wireId.layerId()), // the detId of the Det (a DTLayer). + theWireId(wireId), + theLRSide(lr), + theDigiTime(digiTime), + theLocalPosition(), + theLocalError() {} -// Default constructor -DTRecHit1D::DTRecHit1D() : theWireId(), theLRSide(undefLR), theDigiTime(-1), theLocalPosition(), theLocalError() {} + // Default constructor + DTRecHit1D::DTRecHit1D() : theWireId(), theLRSide(undefLR), theDigiTime(-1), theLocalPosition(), theLocalError() {} -// Constructor from a local position, wireId and digi time. -// The 3-dimensional local error is defined as -// resolution (the cell resolution) for the coordinate being measured -// and 0 for the two other coordinates -DTRecHit1D::DTRecHit1D(const DTWireId& wireId, - DTEnums::DTCellSide lr, - float digiTime, - const LocalPoint& pos) - : RecHit1D(wireId.layerId()), // the detId of the Det (a DTLayer). - theWireId(wireId), - theLRSide(lr), - theDigiTime(digiTime), - theLocalPosition(pos) { - float cellResolution = 0.02; //cm cell resolution = 200 um = 0.02 cm - theLocalError = LocalError(cellResolution * cellResolution, 0., 0.); //FIXME: is it really needed? -} + // Constructor from a local position, wireId and digi time. + // The 3-dimensional local error is defined as + // resolution (the cell resolution) for the coordinate being measured + // and 0 for the two other coordinates + DTRecHit1D::DTRecHit1D(const DTWireId& wireId, + DTEnums::DTCellSide lr, + float digiTime, + const LocalPoint& pos) + : RecHit1D(wireId.layerId()), // the detId of the Det (a DTLayer). + theWireId(wireId), + theLRSide(lr), + theDigiTime(digiTime), + theLocalPosition(pos) { + float cellResolution = 0.02; //cm cell resolution = 200 um = 0.02 cm + theLocalError = LocalError(cellResolution * cellResolution, 0., 0.); //FIXME: is it really needed? + } -// Constructor from a local position and error, wireId and digi time. -DTRecHit1D::DTRecHit1D( - const DTWireId& wireId, DTEnums::DTCellSide lr, float digiTime, const LocalPoint& pos, const LocalError& err) - : RecHit1D(wireId.layerId()), - theWireId(wireId), - theLRSide(lr), - theDigiTime(digiTime), - theLocalPosition(pos), - theLocalError(err) {} + // Constructor from a local position and error, wireId and digi time. + DTRecHit1D::DTRecHit1D( + const DTWireId& wireId, DTEnums::DTCellSide lr, float digiTime, const LocalPoint& pos, const LocalError& err) + : RecHit1D(wireId.layerId()), + theWireId(wireId), + theLRSide(lr), + theDigiTime(digiTime), + theLocalPosition(pos), + theLocalError(err) {} -// Destructor -DTRecHit1D::~DTRecHit1D() {} + // Destructor + DTRecHit1D::~DTRecHit1D() {} -DTRecHit1D* DTRecHit1D::clone() const { return new DTRecHit1D(*this); } + DTRecHit1D* DTRecHit1D::clone() const { return new DTRecHit1D(*this); } -// Access to component RecHits. -// No components rechits: it returns a null vector -vector DTRecHit1D::recHits() const { - vector nullvector; - return nullvector; -} + // Access to component RecHits. + // No components rechits: it returns a null vector + vector DTRecHit1D::recHits() const { + vector nullvector; + return nullvector; + } -// Non-const access to component RecHits. -// No components rechits: it returns a null vector -vector DTRecHit1D::recHits() { - vector nullvector; - return nullvector; -} + // Non-const access to component RecHits. + // No components rechits: it returns a null vector + vector DTRecHit1D::recHits() { + vector nullvector; + return nullvector; + } -// Comparison operator, based on the wireId and the digi time -bool DTRecHit1D::operator==(const DTRecHit1D& hit) const { - return wireId() == hit.wireId() && fabs(digiTime() - hit.digiTime()) < 0.1; -} + // Comparison operator, based on the wireId and the digi time + bool DTRecHit1D::operator==(const DTRecHit1D& hit) const { + return wireId() == hit.wireId() && fabs(digiTime() - hit.digiTime()) < 0.1; + } -// The ostream operator -ostream& operator<<(ostream& os, const DTRecHit1D& hit) { - os << "pos: " << hit.localPosition().x(); - os << " +/- " << sqrt(hit.localPositionError().xx()); - return os; -} + // The ostream operator + ostream& operator<<(ostream& os, const DTRecHit1D& hit) { + os << "pos: " << hit.localPosition().x(); + os << " +/- " << sqrt(hit.localPositionError().xx()); + return os; + } +} // namespace io_v1 diff --git a/DataFormats/DTRecHit/src/DTRecHit1DPair.cc b/DataFormats/DTRecHit/src/DTRecHit1DPair.cc index 0f24e0ae73a3b..fd4bcb01cdd4c 100644 --- a/DataFormats/DTRecHit/src/DTRecHit1DPair.cc +++ b/DataFormats/DTRecHit/src/DTRecHit1DPair.cc @@ -11,114 +11,116 @@ using namespace DTEnums; using namespace std; -// Constructor without components: must use setPos and Err! -DTRecHit1DPair::DTRecHit1DPair(const DTWireId& wireId, const DTDigi& digi) - : theLeftHit(wireId, Left, digi.time()), theRightHit(wireId, Right, digi.time()) {} - -// Default constructor -DTRecHit1DPair::DTRecHit1DPair() : theLeftHit(), theRightHit() {} - -// Destructor -DTRecHit1DPair::~DTRecHit1DPair() {} - -DTRecHit1DPair* DTRecHit1DPair::clone() const { return new DTRecHit1DPair(*this); } - -// Return the 3-dimensional local position. -// The average theLeftHit/theRightHit hits position, namely the wire position -// is returned. -LocalPoint DTRecHit1DPair::localPosition() const { - return theLeftHit.localPosition() + (theRightHit.localPosition() - theLeftHit.localPosition()) / 2.; -} - -// Return the 3-dimensional error on the local position. -// The error is defiened as half -// the distance between theLeftHit and theRightHit pos -LocalError DTRecHit1DPair::localPositionError() const { - return LocalError((theRightHit.localPosition().x() - theLeftHit.localPosition().x()) / 2., 0., 0.); -} - -// Access to component RecHits. -vector DTRecHit1DPair::recHits() const { - vector result; - result.push_back(componentRecHit(Left)); - result.push_back(componentRecHit(Right)); - return result; -} - -// Non-const access to component RecHits. -vector DTRecHit1DPair::recHits() { - vector result; - result.push_back(componentRecHit(Left)); - result.push_back(componentRecHit(Right)); - return result; -} - -// Return the detId of the Det (a DTLayer). -DetId DTRecHit1DPair::geographicalId() const { return wireId().layerId(); } - -// Comparison operator, based on the wireId and the digi time -bool DTRecHit1DPair::operator==(const DTRecHit1DPair& hit) const { - return wireId() == hit.wireId() && fabs(digiTime() - hit.digiTime()) < 0.1; -} - -// Return position in the local (layer) coordinate system for a -// certain hypothesis about the L/R cell side -LocalPoint DTRecHit1DPair::localPosition(DTCellSide lrside) const { return componentRecHit(lrside)->localPosition(); } - -// Return position error in the local (layer) coordinate system for a -// certain hypothesis about the L/R cell side -LocalError DTRecHit1DPair::localPositionError(DTCellSide lrside) const { - return componentRecHit(lrside)->localPositionError(); -} - -// Set the 3-dimensional local position for the component hit -// corresponding to the given cell side. Default value is assumed for the error. -void DTRecHit1DPair::setPosition(DTCellSide lrside, const LocalPoint& point) { - if (lrside != undefLR) - componentRecHit(lrside)->setPosition(point); - else - throw cms::Exception("DTRecHit1DPair::setPosition with undefined LR"); -} - -// Set the 3-dimensional local position and error for the component hit -// corresponding to the given cell side. Default value is assumed for the error. -void DTRecHit1DPair::setPositionAndError(DTCellSide lrside, const LocalPoint& point, const LocalError& err) { - if (lrside != undefLR) { - componentRecHit(lrside)->setPosition(point); - componentRecHit(lrside)->setError(err); - } else - throw cms::Exception("DTRecHit1DPair::setPosition with undefined LR"); -} - -// Return the left/right DTRecHit1D -const DTRecHit1D* DTRecHit1DPair::componentRecHit(DTCellSide lrSide) const { - if (lrSide == Left) { - return &theLeftHit; - } else if (lrSide == Right) { - return &theRightHit; - } else { - throw cms::Exception("DTRecHit1DPair::recHit with undefined LR"); +namespace io_v1 { + // Constructor without components: must use setPos and Err! + DTRecHit1DPair::DTRecHit1DPair(const DTWireId& wireId, const DTDigi& digi) + : theLeftHit(wireId, Left, digi.time()), theRightHit(wireId, Right, digi.time()) {} + + // Default constructor + DTRecHit1DPair::DTRecHit1DPair() : theLeftHit(), theRightHit() {} + + // Destructor + DTRecHit1DPair::~DTRecHit1DPair() {} + + DTRecHit1DPair* DTRecHit1DPair::clone() const { return new DTRecHit1DPair(*this); } + + // Return the 3-dimensional local position. + // The average theLeftHit/theRightHit hits position, namely the wire position + // is returned. + LocalPoint DTRecHit1DPair::localPosition() const { + return theLeftHit.localPosition() + (theRightHit.localPosition() - theLeftHit.localPosition()) / 2.; + } + + // Return the 3-dimensional error on the local position. + // The error is defiened as half + // the distance between theLeftHit and theRightHit pos + LocalError DTRecHit1DPair::localPositionError() const { + return LocalError((theRightHit.localPosition().x() - theLeftHit.localPosition().x()) / 2., 0., 0.); + } + + // Access to component RecHits. + vector DTRecHit1DPair::recHits() const { + vector result; + result.push_back(componentRecHit(Left)); + result.push_back(componentRecHit(Right)); + return result; + } + + // Non-const access to component RecHits. + vector DTRecHit1DPair::recHits() { + vector result; + result.push_back(componentRecHit(Left)); + result.push_back(componentRecHit(Right)); + return result; } -} - -// Non const access to left/right DTRecHit1D -DTRecHit1D* DTRecHit1DPair::componentRecHit(DTCellSide lrSide) { - if (lrSide == Left) { - return &theLeftHit; - } else if (lrSide == Right) { - return &theRightHit; - } else { - throw cms::Exception("DTRecHit1DPair::recHit with undefined LR"); + + // Return the detId of the Det (a DTLayer). + DetId DTRecHit1DPair::geographicalId() const { return wireId().layerId(); } + + // Comparison operator, based on the wireId and the digi time + bool DTRecHit1DPair::operator==(const DTRecHit1DPair& hit) const { + return wireId() == hit.wireId() && fabs(digiTime() - hit.digiTime()) < 0.1; + } + + // Return position in the local (layer) coordinate system for a + // certain hypothesis about the L/R cell side + LocalPoint DTRecHit1DPair::localPosition(DTCellSide lrside) const { return componentRecHit(lrside)->localPosition(); } + + // Return position error in the local (layer) coordinate system for a + // certain hypothesis about the L/R cell side + LocalError DTRecHit1DPair::localPositionError(DTCellSide lrside) const { + return componentRecHit(lrside)->localPositionError(); + } + + // Set the 3-dimensional local position for the component hit + // corresponding to the given cell side. Default value is assumed for the error. + void DTRecHit1DPair::setPosition(DTCellSide lrside, const LocalPoint& point) { + if (lrside != undefLR) + componentRecHit(lrside)->setPosition(point); + else + throw cms::Exception("DTRecHit1DPair::setPosition with undefined LR"); + } + + // Set the 3-dimensional local position and error for the component hit + // corresponding to the given cell side. Default value is assumed for the error. + void DTRecHit1DPair::setPositionAndError(DTCellSide lrside, const LocalPoint& point, const LocalError& err) { + if (lrside != undefLR) { + componentRecHit(lrside)->setPosition(point); + componentRecHit(lrside)->setError(err); + } else + throw cms::Exception("DTRecHit1DPair::setPosition with undefined LR"); + } + + // Return the left/right DTRecHit1D + const DTRecHit1D* DTRecHit1DPair::componentRecHit(DTCellSide lrSide) const { + if (lrSide == Left) { + return &theLeftHit; + } else if (lrSide == Right) { + return &theRightHit; + } else { + throw cms::Exception("DTRecHit1DPair::recHit with undefined LR"); + } + } + + // Non const access to left/right DTRecHit1D + DTRecHit1D* DTRecHit1DPair::componentRecHit(DTCellSide lrSide) { + if (lrSide == Left) { + return &theLeftHit; + } else if (lrSide == Right) { + return &theRightHit; + } else { + throw cms::Exception("DTRecHit1DPair::recHit with undefined LR"); + } + } + + /// Get the left and right 1D rechits (first and second respectively). + pair DTRecHit1DPair::componentRecHits() const { + return make_pair(componentRecHit(Left), componentRecHit(Right)); + } + + // Ostream operator + ostream& operator<<(ostream& os, const DTRecHit1DPair& hit) { + os << "Pos: " << hit.localPosition(); + return os; } -} - -/// Get the left and right 1D rechits (first and second respectively). -pair DTRecHit1DPair::componentRecHits() const { - return make_pair(componentRecHit(Left), componentRecHit(Right)); -} - -// Ostream operator -ostream& operator<<(ostream& os, const DTRecHit1DPair& hit) { - os << "Pos: " << hit.localPosition(); - return os; -} +} // namespace io_v1 diff --git a/DataFormats/DTRecHit/src/DTRecSegment4D.cc b/DataFormats/DTRecHit/src/DTRecSegment4D.cc index 9ef6e8676d5a8..bb204681a8356 100644 --- a/DataFormats/DTRecHit/src/DTRecSegment4D.cc +++ b/DataFormats/DTRecHit/src/DTRecSegment4D.cc @@ -12,245 +12,249 @@ #include "FWCore/Utilities/interface/Exception.h" /* C++ Headers */ -DTRecSegment4D::DTRecSegment4D(const DTChamberRecSegment2D& phiSeg, - const DTSLRecSegment2D& zedSeg, - const LocalPoint& posZInCh, - const LocalVector& dirZInCh) - : RecSegment(phiSeg.chamberId()), theProjection(full), thePhiSeg(phiSeg), theZedSeg(zedSeg), theDimension(4) { - // Check consistency of 2 sub-segments - if (DTChamberId(phiSeg.geographicalId().rawId()) != DTChamberId(zedSeg.geographicalId().rawId())) - throw cms::Exception("DTRecSegment4D") - << "the z Segment and the phi segment have different chamber id" << std::endl; - - // The position of 2D segments are defined in the SL frame: I must first - // extrapolate that position at the Chamber reference plane - LocalPoint posZAt0 = posZInCh + dirZInCh * (-posZInCh.z()) / cos(dirZInCh.theta()); - - thePosition = LocalPoint(phiSeg.localPosition().x(), posZAt0.y(), 0.); - LocalVector dirPhiInCh = phiSeg.localDirection(); - - // given the actual definition of chamber refFrame, (with z poiniting to IP), - // the zed component of direction is negative. - theDirection = LocalVector(dirPhiInCh.x() / fabs(dirPhiInCh.z()), dirZInCh.y() / fabs(dirZInCh.z()), -1.); - theDirection = theDirection.unit(); - - // set cov matrix - theCovMatrix = AlgebraicSymMatrix(4); - theCovMatrix[0][0] = phiSeg.covMatrix()[0][0]; //sigma (dx/dz) - theCovMatrix[0][2] = phiSeg.covMatrix()[0][1]; //cov(dx/dz,x) - theCovMatrix[2][2] = phiSeg.covMatrix()[1][1]; //sigma (x) - setCovMatrixForZed(posZInCh); -} - -DTRecSegment4D::DTRecSegment4D(const DTChamberRecSegment2D& phiSeg) - : RecSegment(phiSeg.chamberId()), - theProjection(phi), - thePhiSeg(phiSeg), - theZedSeg(DTSLRecSegment2D()), - theDimension(2) { - thePosition = thePhiSeg.localPosition(); - - theDirection = thePhiSeg.localDirection(); - - // set cov matrix - theCovMatrix = AlgebraicSymMatrix(4); - theCovMatrix[0][0] = phiSeg.covMatrix()[0][0]; //sigma (dx/dz) - theCovMatrix[0][2] = phiSeg.covMatrix()[0][1]; //cov(dx/dz,x) - theCovMatrix[2][2] = phiSeg.covMatrix()[1][1]; //sigma (x) -} - -DTRecSegment4D::DTRecSegment4D(const DTSLRecSegment2D& zedSeg, const LocalPoint& posZInCh, const LocalVector& dirZInCh) - : RecSegment(zedSeg.superLayerId().chamberId()), - theProjection(Z), - thePhiSeg(DTChamberRecSegment2D()), - theZedSeg(zedSeg), - theDimension(2) { - LocalPoint posZAt0 = posZInCh + dirZInCh * (-posZInCh.z() / cos(dirZInCh.theta())); - - thePosition = posZAt0; - theDirection = dirZInCh; - - // set cov matrix - theCovMatrix = AlgebraicSymMatrix(4); - setCovMatrixForZed(posZInCh); -} - -DTRecSegment4D::~DTRecSegment4D() {} - -AlgebraicVector DTRecSegment4D::parameters() const { - if (dimension() == 4) { - // (dx/dz,dy/dz,x,y) - AlgebraicVector result(4); - result[2] = thePosition.x(); - result[3] = thePosition.y(); - result[0] = theDirection.x() / theDirection.z(); - result[1] = theDirection.y() / theDirection.z(); - return result; +namespace io_v1 { + DTRecSegment4D::DTRecSegment4D(const DTChamberRecSegment2D& phiSeg, + const DTSLRecSegment2D& zedSeg, + const LocalPoint& posZInCh, + const LocalVector& dirZInCh) + : RecSegment(phiSeg.chamberId()), theProjection(full), thePhiSeg(phiSeg), theZedSeg(zedSeg), theDimension(4) { + // Check consistency of 2 sub-segments + if (DTChamberId(phiSeg.geographicalId().rawId()) != DTChamberId(zedSeg.geographicalId().rawId())) + throw cms::Exception("DTRecSegment4D") + << "the z Segment and the phi segment have different chamber id" << std::endl; + + // The position of 2D segments are defined in the SL frame: I must first + // extrapolate that position at the Chamber reference plane + LocalPoint posZAt0 = posZInCh + dirZInCh * (-posZInCh.z()) / cos(dirZInCh.theta()); + + thePosition = LocalPoint(phiSeg.localPosition().x(), posZAt0.y(), 0.); + LocalVector dirPhiInCh = phiSeg.localDirection(); + + // given the actual definition of chamber refFrame, (with z poiniting to IP), + // the zed component of direction is negative. + theDirection = LocalVector(dirPhiInCh.x() / fabs(dirPhiInCh.z()), dirZInCh.y() / fabs(dirZInCh.z()), -1.); + theDirection = theDirection.unit(); + + // set cov matrix + theCovMatrix = AlgebraicSymMatrix(4); + theCovMatrix[0][0] = phiSeg.covMatrix()[0][0]; //sigma (dx/dz) + theCovMatrix[0][2] = phiSeg.covMatrix()[0][1]; //cov(dx/dz,x) + theCovMatrix[2][2] = phiSeg.covMatrix()[1][1]; //sigma (x) + setCovMatrixForZed(posZInCh); } - AlgebraicVector result(2); - if (theProjection == phi) { - // (dx/dz,x) - result[1] = thePosition.x(); - result[0] = theDirection.x() / theDirection.z(); - } else if (theProjection == Z) { - // (dy/dz,y) (note we are in the chamber r.f.) - result[1] = thePosition.y(); - result[0] = theDirection.y() / theDirection.z(); + DTRecSegment4D::DTRecSegment4D(const DTChamberRecSegment2D& phiSeg) + : RecSegment(phiSeg.chamberId()), + theProjection(phi), + thePhiSeg(phiSeg), + theZedSeg(DTSLRecSegment2D()), + theDimension(2) { + thePosition = thePhiSeg.localPosition(); + + theDirection = thePhiSeg.localDirection(); + + // set cov matrix + theCovMatrix = AlgebraicSymMatrix(4); + theCovMatrix[0][0] = phiSeg.covMatrix()[0][0]; //sigma (dx/dz) + theCovMatrix[0][2] = phiSeg.covMatrix()[0][1]; //cov(dx/dz,x) + theCovMatrix[2][2] = phiSeg.covMatrix()[1][1]; //sigma (x) } - return result; -} -AlgebraicSymMatrix DTRecSegment4D::parametersError() const { - if (dimension() == 4) { - return theCovMatrix; + DTRecSegment4D::DTRecSegment4D(const DTSLRecSegment2D& zedSeg, + const LocalPoint& posZInCh, + const LocalVector& dirZInCh) + : RecSegment(zedSeg.superLayerId().chamberId()), + theProjection(Z), + thePhiSeg(DTChamberRecSegment2D()), + theZedSeg(zedSeg), + theDimension(2) { + LocalPoint posZAt0 = posZInCh + dirZInCh * (-posZInCh.z() / cos(dirZInCh.theta())); + + thePosition = posZAt0; + theDirection = dirZInCh; + + // set cov matrix + theCovMatrix = AlgebraicSymMatrix(4); + setCovMatrixForZed(posZInCh); } - AlgebraicSymMatrix result(2); - if (theProjection == phi) { - result[0][0] = theCovMatrix[0][0]; //S(dx/dz) - result[0][1] = theCovMatrix[0][2]; //Cov(dx/dz,x) - result[1][1] = theCovMatrix[2][2]; //S(x) - } else if (theProjection == Z) { - result[0][0] = theCovMatrix[1][1]; //S(dy/dz) - result[0][1] = theCovMatrix[1][3]; //Cov(dy/dz,y) - result[1][1] = theCovMatrix[3][3]; //S(y) + DTRecSegment4D::~DTRecSegment4D() {} + + AlgebraicVector DTRecSegment4D::parameters() const { + if (dimension() == 4) { + // (dx/dz,dy/dz,x,y) + AlgebraicVector result(4); + result[2] = thePosition.x(); + result[3] = thePosition.y(); + result[0] = theDirection.x() / theDirection.z(); + result[1] = theDirection.y() / theDirection.z(); + return result; + } + + AlgebraicVector result(2); + if (theProjection == phi) { + // (dx/dz,x) + result[1] = thePosition.x(); + result[0] = theDirection.x() / theDirection.z(); + } else if (theProjection == Z) { + // (dy/dz,y) (note we are in the chamber r.f.) + result[1] = thePosition.y(); + result[0] = theDirection.y() / theDirection.z(); + } + return result; + } + + AlgebraicSymMatrix DTRecSegment4D::parametersError() const { + if (dimension() == 4) { + return theCovMatrix; + } + + AlgebraicSymMatrix result(2); + if (theProjection == phi) { + result[0][0] = theCovMatrix[0][0]; //S(dx/dz) + result[0][1] = theCovMatrix[0][2]; //Cov(dx/dz,x) + result[1][1] = theCovMatrix[2][2]; //S(x) + } else if (theProjection == Z) { + result[0][0] = theCovMatrix[1][1]; //S(dy/dz) + result[0][1] = theCovMatrix[1][3]; //Cov(dy/dz,y) + result[1][1] = theCovMatrix[3][3]; //S(y) + } + return result; } - return result; -} - -//These methods are only used to initialize the const static values -// used by projectionMatrix(). -static AlgebraicMatrix initThe4DProjectionMatrix() { - AlgebraicMatrix the4DProjectionMatrix(4, 5, 0); - the4DProjectionMatrix[0][1] = 1; - the4DProjectionMatrix[1][2] = 1; - the4DProjectionMatrix[2][3] = 1; - the4DProjectionMatrix[3][4] = 1; - return the4DProjectionMatrix; -} -static const AlgebraicMatrix the4DProjectionMatrix{initThe4DProjectionMatrix()}; - -static AlgebraicMatrix initThe2DPhiProjMatrix() { - AlgebraicMatrix the2DPhiProjMatrix(2, 5, 0); - the2DPhiProjMatrix[0][1] = 1; - the2DPhiProjMatrix[1][3] = 1; - return the2DPhiProjMatrix; -} -static const AlgebraicMatrix the2DPhiProjMatrix{initThe2DPhiProjMatrix()}; - -static AlgebraicMatrix initThe2DZProjMatrix() { - AlgebraicMatrix the2DZProjMatrix(2, 5, 0); - the2DZProjMatrix[0][2] = 1; - the2DZProjMatrix[1][4] = 1; - return the2DZProjMatrix; -} -static const AlgebraicMatrix the2DZProjMatrix{initThe2DZProjMatrix()}; - -AlgebraicMatrix DTRecSegment4D::projectionMatrix() const { - if (dimension() == 4) { + + //These methods are only used to initialize the const static values + // used by projectionMatrix(). + static AlgebraicMatrix initThe4DProjectionMatrix() { + AlgebraicMatrix the4DProjectionMatrix(4, 5, 0); + the4DProjectionMatrix[0][1] = 1; + the4DProjectionMatrix[1][2] = 1; + the4DProjectionMatrix[2][3] = 1; + the4DProjectionMatrix[3][4] = 1; return the4DProjectionMatrix; - } else if (theProjection == phi) { + } + static const AlgebraicMatrix the4DProjectionMatrix{initThe4DProjectionMatrix()}; + + static AlgebraicMatrix initThe2DPhiProjMatrix() { + AlgebraicMatrix the2DPhiProjMatrix(2, 5, 0); + the2DPhiProjMatrix[0][1] = 1; + the2DPhiProjMatrix[1][3] = 1; return the2DPhiProjMatrix; - } else if (theProjection == Z) { + } + static const AlgebraicMatrix the2DPhiProjMatrix{initThe2DPhiProjMatrix()}; + + static AlgebraicMatrix initThe2DZProjMatrix() { + AlgebraicMatrix the2DZProjMatrix(2, 5, 0); + the2DZProjMatrix[0][2] = 1; + the2DZProjMatrix[1][4] = 1; return the2DZProjMatrix; - } else { - return AlgebraicMatrix(); } -} - -LocalError DTRecSegment4D::localPositionError() const { - return LocalError(theCovMatrix[2][2], theCovMatrix[2][3], theCovMatrix[3][3]); -} - -LocalError DTRecSegment4D::localDirectionError() const { - return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]); -} - -double DTRecSegment4D::chi2() const { - double result = 0; - if (hasPhi()) - result += thePhiSeg.chi2(); - if (hasZed()) - result += theZedSeg.chi2(); - return result; -} - -int DTRecSegment4D::degreesOfFreedom() const { - int result = 0; - if (hasPhi()) - result += thePhiSeg.degreesOfFreedom(); - if (hasZed()) - result += theZedSeg.degreesOfFreedom(); - return result; -} - -void DTRecSegment4D::setCovMatrixForZed(const LocalPoint& posZInCh) { - // Warning!!! the covariance matrix for Theta SL segment is defined in the SL - // reference frame, here that in the Chamber ref frame must be used. - // For direction, no problem, but the position is extrapolated, so we must - // propagate the error properly. - - // many thanks to Paolo Ronchese for the help in deriving the formulas! - - // y=m*z+q in SL frame - // y=m'*z+q' in CH frame - - // var(m') = var(m) - theCovMatrix[1][1] = theZedSeg.parametersError()[0][0]; //sigma (dy/dz) - - // cov(m',q') = DeltaZ*Var(m) + Cov(m,q) - theCovMatrix[1][3] = - posZInCh.z() * theZedSeg.parametersError()[0][0] + theZedSeg.parametersError()[0][1]; //cov(dy/dz,y) - - // Var(q') = DeltaZ^2*Var(m) + Var(q) + 2*DeltaZ*Cov(m,q) - // cout << "Var(q') = DeltaZ^2*Var(m) + Var(q) + 2*DeltaZ*Cov(m,q)" << endl; - // cout << "Var(q')= " << posZInCh.z()*posZInCh.z() << "*" << - // theZedSeg.parametersError()[0][0] << " + " << - // theZedSeg.parametersError()[1][1] << " + " << - // 2*posZInCh.z() << "*" << theZedSeg.parametersError()[0][1] ; - theCovMatrix[3][3] = 2. * (posZInCh.z() * posZInCh.z()) * theZedSeg.parametersError()[0][0] + - theZedSeg.parametersError()[1][1] + 2. * posZInCh.z() * theZedSeg.parametersError()[0][1]; - // cout << " = " << theCovMatrix[3][3] << endl; -} - -std::ostream& operator<<(std::ostream& os, const DTRecSegment4D& seg) { - os << "Pos " << seg.localPosition() << " Dir: " << seg.localDirection() << " dim: " << seg.dimension() - << " chi2/ndof: " << seg.chi2() << "/" << seg.degreesOfFreedom() << " :"; - if (seg.hasPhi()) - os << seg.phiSegment()->recHits().size(); - else - os << 0; - os << ":"; - if (seg.hasZed()) - os << seg.zSegment()->recHits().size(); - else - os << 0; - return os; -} - -/// Access to component RecHits (if any) -std::vector DTRecSegment4D::recHits() const { - std::vector pointersOfRecHits; - - if (hasPhi()) - pointersOfRecHits.push_back(phiSegment()); - if (hasZed()) - pointersOfRecHits.push_back(zSegment()); - - return pointersOfRecHits; -} - -/// Non-const access to component RecHits (if any) -std::vector DTRecSegment4D::recHits() { - std::vector pointersOfRecHits; - - if (hasPhi()) - pointersOfRecHits.push_back(phiSegment()); - if (hasZed()) - pointersOfRecHits.push_back(zSegment()); - - return pointersOfRecHits; -} - -DTChamberId DTRecSegment4D::chamberId() const { return DTChamberId(geographicalId()); } + static const AlgebraicMatrix the2DZProjMatrix{initThe2DZProjMatrix()}; + + AlgebraicMatrix DTRecSegment4D::projectionMatrix() const { + if (dimension() == 4) { + return the4DProjectionMatrix; + } else if (theProjection == phi) { + return the2DPhiProjMatrix; + } else if (theProjection == Z) { + return the2DZProjMatrix; + } else { + return AlgebraicMatrix(); + } + } + + LocalError DTRecSegment4D::localPositionError() const { + return LocalError(theCovMatrix[2][2], theCovMatrix[2][3], theCovMatrix[3][3]); + } + + LocalError DTRecSegment4D::localDirectionError() const { + return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]); + } + + double DTRecSegment4D::chi2() const { + double result = 0; + if (hasPhi()) + result += thePhiSeg.chi2(); + if (hasZed()) + result += theZedSeg.chi2(); + return result; + } + + int DTRecSegment4D::degreesOfFreedom() const { + int result = 0; + if (hasPhi()) + result += thePhiSeg.degreesOfFreedom(); + if (hasZed()) + result += theZedSeg.degreesOfFreedom(); + return result; + } + + void DTRecSegment4D::setCovMatrixForZed(const LocalPoint& posZInCh) { + // Warning!!! the covariance matrix for Theta SL segment is defined in the SL + // reference frame, here that in the Chamber ref frame must be used. + // For direction, no problem, but the position is extrapolated, so we must + // propagate the error properly. + + // many thanks to Paolo Ronchese for the help in deriving the formulas! + + // y=m*z+q in SL frame + // y=m'*z+q' in CH frame + + // var(m') = var(m) + theCovMatrix[1][1] = theZedSeg.parametersError()[0][0]; //sigma (dy/dz) + + // cov(m',q') = DeltaZ*Var(m) + Cov(m,q) + theCovMatrix[1][3] = + posZInCh.z() * theZedSeg.parametersError()[0][0] + theZedSeg.parametersError()[0][1]; //cov(dy/dz,y) + + // Var(q') = DeltaZ^2*Var(m) + Var(q) + 2*DeltaZ*Cov(m,q) + // cout << "Var(q') = DeltaZ^2*Var(m) + Var(q) + 2*DeltaZ*Cov(m,q)" << endl; + // cout << "Var(q')= " << posZInCh.z()*posZInCh.z() << "*" << + // theZedSeg.parametersError()[0][0] << " + " << + // theZedSeg.parametersError()[1][1] << " + " << + // 2*posZInCh.z() << "*" << theZedSeg.parametersError()[0][1] ; + theCovMatrix[3][3] = 2. * (posZInCh.z() * posZInCh.z()) * theZedSeg.parametersError()[0][0] + + theZedSeg.parametersError()[1][1] + 2. * posZInCh.z() * theZedSeg.parametersError()[0][1]; + // cout << " = " << theCovMatrix[3][3] << endl; + } + + std::ostream& operator<<(std::ostream& os, const DTRecSegment4D& seg) { + os << "Pos " << seg.localPosition() << " Dir: " << seg.localDirection() << " dim: " << seg.dimension() + << " chi2/ndof: " << seg.chi2() << "/" << seg.degreesOfFreedom() << " :"; + if (seg.hasPhi()) + os << seg.phiSegment()->recHits().size(); + else + os << 0; + os << ":"; + if (seg.hasZed()) + os << seg.zSegment()->recHits().size(); + else + os << 0; + return os; + } + + /// Access to component RecHits (if any) + std::vector DTRecSegment4D::recHits() const { + std::vector pointersOfRecHits; + + if (hasPhi()) + pointersOfRecHits.push_back(phiSegment()); + if (hasZed()) + pointersOfRecHits.push_back(zSegment()); + + return pointersOfRecHits; + } + + /// Non-const access to component RecHits (if any) + std::vector DTRecSegment4D::recHits() { + std::vector pointersOfRecHits; + + if (hasPhi()) + pointersOfRecHits.push_back(phiSegment()); + if (hasZed()) + pointersOfRecHits.push_back(zSegment()); + + return pointersOfRecHits; + } + + DTChamberId DTRecSegment4D::chamberId() const { return DTChamberId(geographicalId()); } +} // namespace io_v1 diff --git a/DataFormats/DTRecHit/src/classes_def.xml b/DataFormats/DTRecHit/src/classes_def.xml index 1e097572324d5..7548bf330328d 100644 --- a/DataFormats/DTRecHit/src/classes_def.xml +++ b/DataFormats/DTRecHit/src/classes_def.xml @@ -1,40 +1,34 @@ - - - - + + - - - + + - + - - - - - - - - - + + + + + + + + - - - + + - - - + + @@ -42,28 +36,25 @@ - - - + + - - - - + + - + - - - - + + + + - + @@ -72,7 +63,7 @@ - + diff --git a/DataFormats/MuonReco/src/classes_def.xml b/DataFormats/MuonReco/src/classes_def.xml index b3776ade1221c..125783e28a0fa 100644 --- a/DataFormats/MuonReco/src/classes_def.xml +++ b/DataFormats/MuonReco/src/classes_def.xml @@ -57,7 +57,7 @@ initial version number of a class which has never been stored before. - +