Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running code-format for reconstruction #27074

Merged
merged 2 commits into from Jun 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
302 changes: 152 additions & 150 deletions DataFormats/ProtonReco/interface/ForwardProton.h
Expand Up @@ -15,156 +15,158 @@

#include "DataFormats/CTPPSReco/interface/CTPPSLocalTrackLiteFwd.h"

namespace reco
{
class ForwardProton
{
public:
/// parameter dimension
enum { dimension = 5 };
/// indices to the covariance matrix
enum struct Index { xi, th_x, vtx_x, th_y, vtx_y, num_indices = dimension };
/// dimension-parameter covariance matrix
typedef math::ErrorF<dimension>::type CovarianceMatrix;
/// spatial vector
typedef math::XYZVectorF Vector;
/// point in the space
typedef math::XYZPointF Point;
/// type of reconstruction applied for this track
enum class ReconstructionMethod { invalid = -1, singleRP, multiRP };

public:
/// default constructor
ForwardProton();
/// constructor from refit parameters, fitted vertex and momentum, and longitudinal fractional momentum loss
ForwardProton( double chi2, double ndof, const Point& vtx, const Vector& momentum, float xi,
const CovarianceMatrix& cov, ReconstructionMethod method,
const CTPPSLocalTrackLiteRefVector& local_tracks, bool valid,
const float time=0., const float time_err=0. );

/// fitted vertex position
const Point& vertex() const { return vertex_; }
/// fitted vertex horizontal position
float vx() const { return vertex_.x(); }
/// fitted vertex vertical position
float vy() const { return vertex_.y(); }
/// vertex longitudinal position (conventionally set to 0)
float vz() const { return vertex_.z(); }
/// fitted track direction
const Vector& momentum() const { return momentum_; }
/// scalar norm of fitted track momentum
float p() const { return momentum_.r(); }
/// scalar fitted track transverse momentum
float pt() const { return momentum_.rho(); }
/// fitted track momentum horizontal component
float px() const { return momentum_.x(); }
/// fitted track momentum vertical component
float py() const { return momentum_.y(); }
/// fitted track momentum longitudinal component
float pz() const { return momentum_.z(); }

/// chi-squared of the fit
float chi2() const { return chi2_; }
/// number of degrees of freedom for the track fit
unsigned int ndof() const { return ndof_; }
/// chi-squared divided by ndof (or chi-squared * 1e6 if ndof is zero)
float normalizedChi2() const {
return ( ndof_ != 0 ) ? chi2_ / ndof_ : chi2_ * 1.e6;
}

/// longitudinal fractional momentum loss
float xi() const { return xi_; }
/// vertical scattering angle, in rad
float thetaX() const { return px() / p(); }
/// horizontal scattering angle, in rad
float thetaY() const { return py() / p(); }

// vertex position can be obtained via TrackBase::vx() and vy() functions

/// return the uncertainty on a given component
double error( Index i ) const {
return sqrt( covariance_( (unsigned int)i, (unsigned int)i ) );
}

/// uncertainty on longitudinal fractional momentum loss
float xiError() const { return error( Index::xi ); }
/// uncertainty on fitted momentum horizontal angle opening
float thetaXError() const { return error( Index::th_x ); }
/// uncertainty on fitted momentum vertical angle opening
float thetaYError() const { return error( Index::th_y ); }
/// uncertainty on fitted vertex horizontal position
float vxError() const { return error( Index::vtx_x ); }
/// uncertainty on fitted vertex vertical position
float vyError() const { return error( Index::vtx_y ); }

/// proton mass in GeV
static float mass() { return mass_; }

/// compute the squared four-momentum transfer from incident and scattered momenta, and angular information
static float calculateT( double beam_mom, double proton_mom, double theta );

/// four-momentum transfer squared, in GeV^2
float t() const;

/// time of proton arrival at forward stations
float time() const { return time_; }
void setTime(float time) { time_ = time; }

/// uncertainty on time of proton arrival at forward stations
float timeError() const { return time_err_; }
void setTimeError(float time_err) { time_err_ = time_err; }

/// set the flag for the fit validity
void setValidFit( bool valid = true ) { valid_fit_ = valid; }
/// flag for the fit validity
bool validFit() const { return valid_fit_; }

/// set the reconstruction method for this track
void setMethod( const ReconstructionMethod& method ) { method_ = method; }
/// reconstruction method for this track
ReconstructionMethod method() const { return method_; }

/// store the list of RP tracks that contributed to this global track
void setContributingLocalTracks( const CTPPSLocalTrackLiteRefVector &v ) { contributing_local_tracks_ = v; }
/// list of RP tracks that contributed to this global track
const CTPPSLocalTrackLiteRefVector& contributingLocalTracks() const { return contributing_local_tracks_; }

/// LHC sector
enum class LHCSector { invalid = -1, sector45, sector56 };
LHCSector lhcSector() const
{
if ( pz() < 0. ) return LHCSector::sector56;
if ( pz() > 0. ) return LHCSector::sector45;
return LHCSector::invalid;
}

private:
static constexpr float mass_ = 0.938272046; ///< proton mass, GeV
static constexpr float massSquared_ = 0.88035443; ///< proton mass squared, GeV^2

/// reconstructed vertex position at z/s = 0
Point vertex_;
/// reconstructed momentum vector
Vector momentum_;
/// reconstructed time at forward detectors
float time_;
/// uncertainty on reconstructed time at forward detectors
float time_err_;
/// fractional momentum loss (positive for diffractive protons)
float xi_;
/// 5x5 covariance matrix
CovarianceMatrix covariance_;
/// chi-squared
float chi2_;
/// number of degrees of freedom
unsigned int ndof_;
/// fit validity flag
bool valid_fit_;
/// type of reconstruction applied
ReconstructionMethod method_;
/// collection of references to tracks contributing to this object definition
CTPPSLocalTrackLiteRefVector contributing_local_tracks_;
namespace reco {
class ForwardProton {
public:
/// parameter dimension
enum { dimension = 5 };
/// indices to the covariance matrix
enum struct Index { xi, th_x, vtx_x, th_y, vtx_y, num_indices = dimension };
/// dimension-parameter covariance matrix
typedef math::ErrorF<dimension>::type CovarianceMatrix;
/// spatial vector
typedef math::XYZVectorF Vector;
/// point in the space
typedef math::XYZPointF Point;
/// type of reconstruction applied for this track
enum class ReconstructionMethod { invalid = -1, singleRP, multiRP };

public:
/// default constructor
ForwardProton();
/// constructor from refit parameters, fitted vertex and momentum, and longitudinal fractional momentum loss
ForwardProton(double chi2,
double ndof,
const Point& vtx,
const Vector& momentum,
float xi,
const CovarianceMatrix& cov,
ReconstructionMethod method,
const CTPPSLocalTrackLiteRefVector& local_tracks,
bool valid,
const float time = 0.,
const float time_err = 0.);

/// fitted vertex position
const Point& vertex() const { return vertex_; }
/// fitted vertex horizontal position
float vx() const { return vertex_.x(); }
/// fitted vertex vertical position
float vy() const { return vertex_.y(); }
/// vertex longitudinal position (conventionally set to 0)
float vz() const { return vertex_.z(); }
/// fitted track direction
const Vector& momentum() const { return momentum_; }
/// scalar norm of fitted track momentum
float p() const { return momentum_.r(); }
/// scalar fitted track transverse momentum
float pt() const { return momentum_.rho(); }
/// fitted track momentum horizontal component
float px() const { return momentum_.x(); }
/// fitted track momentum vertical component
float py() const { return momentum_.y(); }
/// fitted track momentum longitudinal component
float pz() const { return momentum_.z(); }

/// chi-squared of the fit
float chi2() const { return chi2_; }
/// number of degrees of freedom for the track fit
unsigned int ndof() const { return ndof_; }
/// chi-squared divided by ndof (or chi-squared * 1e6 if ndof is zero)
float normalizedChi2() const { return (ndof_ != 0) ? chi2_ / ndof_ : chi2_ * 1.e6; }

/// longitudinal fractional momentum loss
float xi() const { return xi_; }
/// vertical scattering angle, in rad
float thetaX() const { return px() / p(); }
/// horizontal scattering angle, in rad
float thetaY() const { return py() / p(); }

// vertex position can be obtained via TrackBase::vx() and vy() functions

/// return the uncertainty on a given component
double error(Index i) const { return sqrt(covariance_((unsigned int)i, (unsigned int)i)); }

/// uncertainty on longitudinal fractional momentum loss
float xiError() const { return error(Index::xi); }
/// uncertainty on fitted momentum horizontal angle opening
float thetaXError() const { return error(Index::th_x); }
/// uncertainty on fitted momentum vertical angle opening
float thetaYError() const { return error(Index::th_y); }
/// uncertainty on fitted vertex horizontal position
float vxError() const { return error(Index::vtx_x); }
/// uncertainty on fitted vertex vertical position
float vyError() const { return error(Index::vtx_y); }

/// proton mass in GeV
static float mass() { return mass_; }

/// compute the squared four-momentum transfer from incident and scattered momenta, and angular information
static float calculateT(double beam_mom, double proton_mom, double theta);

/// four-momentum transfer squared, in GeV^2
float t() const;

/// time of proton arrival at forward stations
float time() const { return time_; }
void setTime(float time) { time_ = time; }

/// uncertainty on time of proton arrival at forward stations
float timeError() const { return time_err_; }
void setTimeError(float time_err) { time_err_ = time_err; }

/// set the flag for the fit validity
void setValidFit(bool valid = true) { valid_fit_ = valid; }
/// flag for the fit validity
bool validFit() const { return valid_fit_; }

/// set the reconstruction method for this track
void setMethod(const ReconstructionMethod& method) { method_ = method; }
/// reconstruction method for this track
ReconstructionMethod method() const { return method_; }

/// store the list of RP tracks that contributed to this global track
void setContributingLocalTracks(const CTPPSLocalTrackLiteRefVector& v) { contributing_local_tracks_ = v; }
/// list of RP tracks that contributed to this global track
const CTPPSLocalTrackLiteRefVector& contributingLocalTracks() const { return contributing_local_tracks_; }

/// LHC sector
enum class LHCSector { invalid = -1, sector45, sector56 };
LHCSector lhcSector() const {
if (pz() < 0.)
return LHCSector::sector56;
if (pz() > 0.)
return LHCSector::sector45;
return LHCSector::invalid;
}

private:
static constexpr float mass_ = 0.938272046; ///< proton mass, GeV
static constexpr float massSquared_ = 0.88035443; ///< proton mass squared, GeV^2

/// reconstructed vertex position at z/s = 0
Point vertex_;
/// reconstructed momentum vector
Vector momentum_;
/// reconstructed time at forward detectors
float time_;
/// uncertainty on reconstructed time at forward detectors
float time_err_;
/// fractional momentum loss (positive for diffractive protons)
float xi_;
/// 5x5 covariance matrix
CovarianceMatrix covariance_;
/// chi-squared
float chi2_;
/// number of degrees of freedom
unsigned int ndof_;
/// fit validity flag
bool valid_fit_;
/// type of reconstruction applied
ReconstructionMethod method_;
/// collection of references to tracks contributing to this object definition
CTPPSLocalTrackLiteRefVector contributing_local_tracks_;
};
}
} // namespace reco

#endif
6 changes: 2 additions & 4 deletions DataFormats/ProtonReco/interface/ForwardProtonFwd.h
Expand Up @@ -16,8 +16,7 @@

#include <vector>

namespace reco
{
namespace reco {
class ForwardProton;
/// Collection of ForwardProton objects
typedef std::vector<ForwardProton> ForwardProtonCollection;
Expand All @@ -27,7 +26,6 @@ namespace reco
typedef edm::RefProd<ForwardProtonCollection> ForwardProtonRefProd;
/// Vector of references to ForwardProton in the same collection
typedef edm::RefVector<ForwardProtonCollection> ForwardProtonRefVector;
}
} // namespace reco

#endif