From 38a753acabf6c1adca04de86268c1698bc921008 Mon Sep 17 00:00:00 2001 From: Maurik Holtrop Date: Sun, 21 Jul 2019 16:06:04 -0400 Subject: [PATCH 1/3] Modify SvtTrack for 14 silicon layers, change data type to of isolation to vector, and covmatrix to vector --- CMakeLists.txt | 2 +- include/hps_event/HpsEvent.h | 1 + include/hps_event/SvtTrack.h | 710 +++++++++++++++++------------------ src/dst/SvtDataWriter.cxx | 2 +- src/hps_event/SvtTrack.cxx | 16 +- 5 files changed, 368 insertions(+), 363 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b3646c7..e6ffa4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -181,7 +181,7 @@ else() endif(DOXYGEN_FOUND) message("-----------------------------------------------") -message("* Configuration Summary: ") +message("* Configuration Summary for hps-dst: ") message("*") message("* ROOT version: ${ROOT_VERSION} ") message("* ROOT location: $ENV{ROOTSYS} ") diff --git a/include/hps_event/HpsEvent.h b/include/hps_event/HpsEvent.h index d667fdd..884bb19 100644 --- a/include/hps_event/HpsEvent.h +++ b/include/hps_event/HpsEvent.h @@ -6,6 +6,7 @@ * @author Omar Moreno * Santa Cruz Institute for Particle Physics * University of California, Santa Cruz + * @author Maurik Holtrop * @date February 19, 2013 * */ diff --git a/include/hps_event/SvtTrack.h b/include/hps_event/SvtTrack.h index 43b4618..319723b 100644 --- a/include/hps_event/SvtTrack.h +++ b/include/hps_event/SvtTrack.h @@ -37,364 +37,364 @@ class SvtHit; class GblTrack; class SvtTrack : public TObject { - - // TODO: Add more documentation - + + // TODO: Add more documentation + public: - - /** Constructor */ - SvtTrack(); - - /** - * Copy constructor - * - * @param svtTrackObj An SvtTrack object - */ - SvtTrack(const SvtTrack &svtTrackObj); - - /** Destructor */ - ~SvtTrack(); - - /** - * Copy assignment operator - * - * @param svtTrackObj An SvtTrack object - */ - SvtTrack &operator=(const SvtTrack &svtTrackObj); - - /** Reset the SvtTrack object */ - void Clear(Option_t *option=""); - - /** - * Add a reference to an SvtHit. - * - * @param hit : An SvtHit - */ - void addHit(SvtHit* hit); - - /** - * Set the track parameters. - * - * @param d0 Distance of closest approach to the reference point. - * @param phi0 The azimuthal angle of the momentum at the distance of - * closest approach. - * @param omega The curvature of the track. - * @param tan_lambda The slope of the track in the SY plane. - * @param z0 The y position of the track at the distance of closest - * approach. - */ - void setTrackParameters(const double d0, - const double phi0, - const double omega, - const double tan_lambda, - const double z0); - - /** - * Set the chi^2 of the fit to the track. - * - * @param Chi_squared The chi^2 of the fit to the track. - */ - void setChi2(const double Chi_squared) { chi_squared = Chi_squared; }; - - /** - * Set the track time. - * - * @param Track_time The track time. - */ - void setTrackTime(const double Track_time) { track_time = Track_time; }; - - /** - * Set the isolation variable of the given layer. - * - * @param Layer Layer number associated with the given isolation value. - * @param Isolation The isolation variable. - */ - void setIsolation(const int Layer, const double Isolation) { isolation[Layer] = Isolation; }; - - /** - * The the volume (Top/Bottom) that the track is located in. - * - * @param Track_volume The track volume. - */ - void setTrackVolume(const int Track_volume) { track_volume = Track_volume; }; - - /** - * Set the HpsParticle associated with this track. This can be used to - * retrieve additional track properties such as the momentum and charge. - * - * @param Fs_particle : Final state HpsParticle associated with this track - */ - void setParticle(HpsParticle* Fs_particle) { fs_particle = (TObject*) Fs_particle; }; - - /** - * Set the extrapolated track position at the Ecal face. The - * extrapolation is assumed to use the full 3D field map. - * - * @parm position The extrapolated track position at the Ecal - */ - void setPositionAtEcal(const double* position); - - /** - * Set the 1/2 covariant matrix for the track - * - * @parm An array of 15 doubles, which is the 1/2 covariant matrix. - */ - void setCovMatrix(const float *covariant_matrix){ - memcpy(&covmatrix,covariant_matrix,sizeof(covmatrix)); - } - - /** - * Set the track type. For more details, see {@link StrategyType} and - * {@link TrackType}. - * - * @param Type The track type. - */ - void setType(const int Type) { type = Type; }; - - /** - * Set a reference to the GblTrack associated with this seed track. - * - * @param Gbl_track The GBL track associated with this seed track. - */ - void setGblTrack(GblTrack* Gbl_track) { gbl_track = (TObject*) Gbl_track; }; - - /** - * Get the distance of closest approach to the reference point. - * - * @return The distance of closest approach to the reference point. - */ - double getD0() const { return d0; }; - - /** - * Get the azimuthal angle of the momentum at the distance of closest - * approach. - * - * @return The azimuthal angle of the momentum at the distance of - * closest approach. - */ - double getPhi0() const { return phi0; }; - - /** - * Get the curvature of the track. - * - * @return The curvature of the track. - */ - double getOmega() const { return omega; }; - - /** - * Get the slope of the track in the SY plane. - * - * @return The curvature of the track in the SY plane. - */ - double getTanLambda() const { return tan_lambda; }; - - /** - * Get the y position of the track at the distance of closest approach. - * - * @return The y position of the track at the distance of closest - * approach. - */ - double getZ0() const { return z0; }; - - /** - * Get the chi^2 of the fit to the track. - * - * @return the chi^2 of the fit to the track. - */ - double getChi2() const { return chi_squared; }; - - /** - * Get the time of the track. - * - * @return The track time. - */ - double getTrackTime() const { return track_time; }; - - /** - * Get the isolation value of the given layer. - * - * @param layer The SVT layer of interest. - * @return The isolation value of the given layer. - */ - double getIsolation(const int layer) const { return isolation[layer]; }; - - /** - * Get the charge of a the track by computation. - * - * @return The charge associated of the track. - */ - int getCharge() const; - - /** - * Get the track type. - * - * @return The track type. - */ - int getType() const { return type; }; - - /** - * Get the track momentum. - * - * @return The track momentum. - */ - std::vector getMomentum(double bfield=0) const; - - /** - * Get the extrapolated track position at the Ecal face. - * - * @return Extrapolated track position at Ecal face. - */ - std::vector getPositionAtEcal() const; - - /** - * Get the 1/2 covariant matrix as vector - * - * @return 1/2 covariant matrix in a vector of 15 entries. - */ - std::vector getCovariantMatrix() const{ - std::vector retvec(sizeof(covmatrix)); - retvec.assign(covmatrix,covmatrix+sizeof(covmatrix)); // Copy data into vector. - return(retvec); // C++11 returns matrix by move. - }; - - /** - * Get the [rown,coln] element of the covariant matrix. - * - * @return covariant matrix [row,col] value (float) - */ - float getCovariantMatrix(int i,int j) const{ - if(i<0 || j<0 || i>4 || j>4) return(0); - // int k=0; for(int q=0;q<=j;++q) k+=q; - if(j1)+(j-2)*(j>2)+(j-3)*(j>3); - return(covmatrix[k]); - }; - - - /** - * Get the 1/2 covariant matrix as TMatrixD - * Note that this is MUCH less efficient than getCovariantMatrix or getCovariantMatrix(i,j) - * - * @return 1/2 covariant matrix in a 5x5 TMatrix. - */ - TMatrixD getCovariantTMatrix() const{ - double data[25]; - int k=0; - for(int i=0;i<5;i++) - for(int j=0;j getMomentum(double bfield=0) const; + + /** + * Get the extrapolated track position at the Ecal face. + * + * @return Extrapolated track position at Ecal face. + */ + std::vector getPositionAtEcal() const; + + /** + * Get the 1/2 covariant matrix as vector + * + * @return 1/2 covariant matrix in a vector of 15 entries. + */ + std::vector getCovariantMatrix() const{ +// std::vector retvec(sizeof(covmatrix)); +// retvec.assign(covmatrix,covmatrix+sizeof(covmatrix)); // Copy data into vector. + return(covmatrix); // C++11 returns matrix by move. + }; + + /** + * Get the [rown,coln] element of the covariant matrix. + * + * @return covariant matrix [row,col] value (float) + */ + float getCovariantMatrix(int i,int j) const{ + if(i<0 || j<0 || i>4 || j>4) return(0); + // int k=0; for(int q=0;q<=j;++q) k+=q; + if(j1)+(j-2)*(j>2)+(j-3)*(j>3); + return(covmatrix[k]); + }; + + + /** + * Get the 1/2 covariant matrix as TMatrixD + * Note that this is MUCH less efficient than getCovariantMatrix or getCovariantMatrix(i,j) + * + * @return 1/2 covariant matrix in a 5x5 TMatrix. + */ + TMatrixD getCovariantTMatrix() const{ + double data[25]; + int k=0; + for(int i=0;i<5;i++) + for(int j=0;j isolation={0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + + /** The number of 3D hits associated with this track. */ + int n_hits=0; + + /** The volume to which this track belongs to. */ + int track_volume=-1; + + /** The track type. */ + int type=0; + + /** The distance of closest approach to the reference point. */ + double d0=0; + + /** + * The azimuthal angle of the momentum at the position of closest + * approach to the reference point. + */ + double phi0=0; + + /** + * The track curvature. The curvature is positive (negative) if the particle has a + * positive (negative) charge. + */ + double omega=0; + + /** + * The slope of the track in the SY plane where S is the arc length of + * the helix in the xz plane. + */ + double tan_lambda=0; + + /** + * The y position of the track at the distance of closest approach + * in the xz plane. + */ + double z0=0; + + /** The chi^2 of the track fit. */ + double chi_squared=0; + + /** The 1/2 Covariant Matrix. This is the lower 1/2. **/ + std::vector covmatrix={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + + /** + * The time of the track. This is currently the average time of all + * hits composing the track. + */ + double track_time=0; + + /** The x position of the extrapolated track at the Ecal face. */ + double x_at_ecal=0; + + /** The y position of the extrapolated track at the Ecal face. */ + double y_at_ecal=0; + + /** The z position of the extrapolated track at the Ecal face. */ + double z_at_ecal=0; + }; // SvtTrack #endif // __SVT_TRACK_H__ diff --git a/src/dst/SvtDataWriter.cxx b/src/dst/SvtDataWriter.cxx index 2fe31d5..59d4a5a 100644 --- a/src/dst/SvtDataWriter.cxx +++ b/src/dst/SvtDataWriter.cxx @@ -186,7 +186,7 @@ void SvtDataWriter::writeData(EVENT::LCEvent* event, HpsEvent* hps_event) { // Check that the TrackData data structure is correct. If it's // not, throw a runtime exception. - if (track_datum->getNDouble() != 12 || track_datum->getNFloat() != 1 + if ((track_datum->getNDouble() != 12 && track_datum->getNDouble() != 14) || track_datum->getNFloat() != 1 || track_datum->getNInt() != 1) { throw std::runtime_error("[ SvtDataWriter ]: The collection " + TRACK_DATA_COL_NAME + " has the wrong structure."); diff --git a/src/hps_event/SvtTrack.cxx b/src/hps_event/SvtTrack.cxx index 7a2e34a..8b39b6e 100644 --- a/src/hps_event/SvtTrack.cxx +++ b/src/hps_event/SvtTrack.cxx @@ -34,8 +34,10 @@ z_at_ecal(svtTrackObj.x_at_ecal) { *svt_hits = *svtTrackObj.svt_hits; fs_particle = svtTrackObj.fs_particle; gbl_track = svtTrackObj.gbl_track; - memcpy(&isolation, svtTrackObj.isolation, sizeof(isolation)); - memcpy(&covmatrix, svtTrackObj.covmatrix, sizeof(covmatrix)); + isolation = svtTrackObj.isolation; + // std::copy(svtTrackObj.isolation.begin(), svtTrackObj.isolation.end(), + // std::back_inserter(isolation)); + covmatrix =svtTrackObj.covmatrix; } @@ -64,8 +66,10 @@ SvtTrack &SvtTrack::operator=(const SvtTrack &svtTrackObj) { *svt_hits = *svtTrackObj.svt_hits; fs_particle = svtTrackObj.fs_particle; gbl_track = svtTrackObj.gbl_track; - memcpy(&isolation, svtTrackObj.isolation, sizeof(isolation)); - memcpy(&covmatrix, svtTrackObj.covmatrix, sizeof(covmatrix)); + isolation = svtTrackObj.isolation; + // std::copy(svtTrackObj.isolation.begin(), svtTrackObj.isolation.end(), + // std::back_inserter(isolation)); + covmatrix=svtTrackObj.covmatrix; return *this; } @@ -77,8 +81,8 @@ SvtTrack::~SvtTrack() { void SvtTrack::Clear(Option_t* /* option */) { TObject::Clear(); svt_hits->Delete(); - memset(isolation, 0, sizeof(isolation)); - memset(covmatrix, 0, sizeof(covmatrix)); + std::fill(isolation.begin(),isolation.end(), 0); + std::fill(covmatrix.begin(),covmatrix.end(), 0); n_hits = 0; } From 6fcb02447e5c648d08dde28e3f948a7adb26cb0f Mon Sep 17 00:00:00 2001 From: Maurik Holtrop Date: Mon, 22 Jul 2019 12:11:22 -0400 Subject: [PATCH 2/3] Fixup on GBLTrack as well. --- include/hps_event/GblTrack.h | 132 ++++++++++++++++---------------- include/hps_event/HpsParticle.h | 17 ++-- src/hps_event/GblTrack.cxx | 9 --- src/hps_event/HpsParticle.cxx | 13 ---- 4 files changed, 76 insertions(+), 95 deletions(-) diff --git a/include/hps_event/GblTrack.h b/include/hps_event/GblTrack.h index b5c8b8a..b45fe45 100644 --- a/include/hps_event/GblTrack.h +++ b/include/hps_event/GblTrack.h @@ -1,12 +1,12 @@ /** - * + * * @file GblTrack.h * @brief Class used to describe an HPS SVT GBL track. * @author Omar Moreno * Santa Cruz Institute for Particle Physics * University of California, Santa Cruz * @date December 11, 2015 - * + * */ #ifndef __GBL_TRACK_H__ @@ -18,70 +18,70 @@ #include "SvtTrack.h" class GblTrack : public SvtTrack { - - public: - - /** Constructor */ - GblTrack(); - - /** - * Set the lambda kink of the given layer. - * - * @param layer Layer number associated with the given lambda kink. - * @param lambda_kink The lambda kink value. - */ - void setLambdaKink(const int layer, const double lambda_kink) { lambda_kinks[layer] = lambda_kink; } - - /** - * Set the phi kink of the given layer. - * - * @param layer Layer number associated with the given phi kink. - * @param phi_kink The phi kink value. - */ - void setPhiKink(const int layer, const double phi_kink) { phi_kinks[layer] = phi_kink; } - - /** - * Set the seed track that was refit to create this GBL track. - * - * @param Seed_track The seed track (SvtTrack object) - */ - void setSeedTrack(SvtTrack* Seed_track) { seed_track = static_cast(Seed_track); } - - /** - * Get the lambda kink value of the given layer. - * - * @param layer The SVT layer of interest. - * @return The lambda kink value of the given layer. - */ - double getLambdaKink(const int layer) const { return lambda_kinks[layer]; } - - /** - * Get the phi kink value of the given layer. - * - * @param layer The SVT layer of interest. - * @return The phi kink value of the given layer. - */ - double getPhiKink(const int layer) const { return phi_kinks[layer]; } - - /** - * Get the seed track that was refit to create this GBL track. - * - * @return The seed track. - */ - SvtTrack* getSeedTrack() const { return static_cast(seed_track.GetObject()); } - - ClassDef(GblTrack, 1) - - private: - - /** Reference to corresponding seed track */ - TRef seed_track; - - /** Array used to store the lambda kinks for each of the sensor layers. */ - double lambda_kinks[12]; - - /** Array used to store the phi kinks for each of the sensor layers. */ - double phi_kinks[12]; + +public: + + /** Constructor */ + GblTrack(){}; + + /** + * Set the lambda kink of the given layer. + * + * @param layer Layer number associated with the given lambda kink. + * @param lambda_kink The lambda kink value. + */ + void setLambdaKink(const int layer, const double lambda_kink) { lambda_kinks[layer] = lambda_kink; } + + /** + * Set the phi kink of the given layer. + * + * @param layer Layer number associated with the given phi kink. + * @param phi_kink The phi kink value. + */ + void setPhiKink(const int layer, const double phi_kink) { phi_kinks[layer] = phi_kink; } + + /** + * Set the seed track that was refit to create this GBL track. + * + * @param Seed_track The seed track (SvtTrack object) + */ + void setSeedTrack(SvtTrack* Seed_track) { seed_track = static_cast(Seed_track); } + + /** + * Get the lambda kink value of the given layer. + * + * @param layer The SVT layer of interest. + * @return The lambda kink value of the given layer. + */ + double getLambdaKink(const int layer) const { return lambda_kinks[layer]; } + + /** + * Get the phi kink value of the given layer. + * + * @param layer The SVT layer of interest. + * @return The phi kink value of the given layer. + */ + double getPhiKink(const int layer) const { return phi_kinks[layer]; } + + /** + * Get the seed track that was refit to create this GBL track. + * + * @return The seed track. + */ + SvtTrack* getSeedTrack() const { return static_cast(seed_track.GetObject()); } + + ClassDef(GblTrack, 2) + +private: + + /** Reference to corresponding seed track */ + TRef seed_track; + + /** Array used to store the lambda kinks for each of the sensor layers. */ + std::vector lambda_kinks = std::vector(14,-9999); + + /** Array used to store the phi kinks for each of the sensor layers. */ + std::vector phi_kinks = std::vector(14,-9999); }; #endif // __GBL_TRACK_H__ diff --git a/include/hps_event/HpsParticle.h b/include/hps_event/HpsParticle.h index 7506fd3..1259480 100644 --- a/include/hps_event/HpsParticle.h +++ b/include/hps_event/HpsParticle.h @@ -209,9 +209,7 @@ class HpsParticle : public TObject { * @return 1/2 covariant matrix in a vector of 15 entries. */ std::vector getCovariantMatrix() const{ - std::vector retvec(sizeof(covmatrix)); - retvec.assign(covmatrix,covmatrix+sizeof(covmatrix)); // Copy data into vector. - return(retvec); // C++11 returns matrix by move. + return(covmatrix); // C++11 returns matrix by move. }; /** @@ -236,6 +234,7 @@ class HpsParticle : public TObject { * Note that this is MUCH less efficient than getCovariantMatrix or getCovariantMatrix(i,j) * * @return 1/2 covariant matrix in a 5x5 TMatrix. + * This copies the matrix twice! (ouch) */ TMatrixD getCovariantTMatrix() const{ double data[16]; @@ -247,7 +246,7 @@ class HpsParticle : public TObject { k++; } TMatrixD retmat(4,4,data); - return(retmat); // This copies the matrix twice! (ouch) + return(retmat); }; /** @@ -297,14 +296,18 @@ class HpsParticle : public TObject { * * @return The corrected momentum of the particle. */ - std::vector getCorrMomentum() const; + std::vector getCorrMomentum() const { + return {px, py, pz}; + }; /** * Get the vertex position of the particle. * * @return The vertex position of the particle */ - std::vector getVertexPosition() const; + std::vector getVertexPosition() const{ + return {vtx_x,vtx_y,vtx_z}; + }; /** * Get the chi^2 of the vertex fit. @@ -378,7 +381,7 @@ class HpsParticle : public TObject { double vtx_fit_chi2; /** The 1/2 Covariant Matrix. This is the lower 1/2. **/ - float covmatrix[10]; + std::vector covmatrix = std::vector(10,0); /** The energy of the particle in GeV */ double energy; diff --git a/src/hps_event/GblTrack.cxx b/src/hps_event/GblTrack.cxx index 23e4120..835e135 100644 --- a/src/hps_event/GblTrack.cxx +++ b/src/hps_event/GblTrack.cxx @@ -12,13 +12,4 @@ #include "GblTrack.h" ClassImp(GblTrack) - -GblTrack::GblTrack() - : SvtTrack() { - - // Initialize the lambda and phi kinks to a non-zero value - std::fill_n(lambda_kinks, 12, -9999); - std::fill_n(phi_kinks, 12, -9999); -} - diff --git a/src/hps_event/HpsParticle.cxx b/src/hps_event/HpsParticle.cxx index 886afce..69f41f0 100644 --- a/src/hps_event/HpsParticle.cxx +++ b/src/hps_event/HpsParticle.cxx @@ -169,16 +169,3 @@ std::vector HpsParticle::getMomentum() const { return momentum; } -std::vector HpsParticle::getCorrMomentum() const { - std::vector momentum {px, py, pz}; - return momentum; -} - -std::vector HpsParticle::getVertexPosition() const { - std::vector vertex(3,0); - vertex[0] = vtx_x; - vertex[1] = vtx_y; - vertex[2] = vtx_z; - return vertex; -} - From 57500a8d1f601c18b17aa15d87f61346e7f98b2d Mon Sep 17 00:00:00 2001 From: Maurik Holtrop Date: Sat, 3 Aug 2019 14:47:35 -0400 Subject: [PATCH 3/3] Back to master and start over. --- CMakeLists.txt | 2 +- include/hps_event/GblTrack.h | 132 +++--- include/hps_event/HpsEvent.h | 1 - include/hps_event/HpsParticle.h | 17 +- include/hps_event/SvtTrack.h | 710 ++++++++++++++++---------------- src/dst/SvtDataWriter.cxx | 2 +- src/hps_event/GblTrack.cxx | 9 + src/hps_event/HpsParticle.cxx | 13 + src/hps_event/SvtTrack.cxx | 16 +- 9 files changed, 458 insertions(+), 444 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e6ffa4b..b3646c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -181,7 +181,7 @@ else() endif(DOXYGEN_FOUND) message("-----------------------------------------------") -message("* Configuration Summary for hps-dst: ") +message("* Configuration Summary: ") message("*") message("* ROOT version: ${ROOT_VERSION} ") message("* ROOT location: $ENV{ROOTSYS} ") diff --git a/include/hps_event/GblTrack.h b/include/hps_event/GblTrack.h index b45fe45..b5c8b8a 100644 --- a/include/hps_event/GblTrack.h +++ b/include/hps_event/GblTrack.h @@ -1,12 +1,12 @@ /** - * + * * @file GblTrack.h * @brief Class used to describe an HPS SVT GBL track. * @author Omar Moreno * Santa Cruz Institute for Particle Physics * University of California, Santa Cruz * @date December 11, 2015 - * + * */ #ifndef __GBL_TRACK_H__ @@ -18,70 +18,70 @@ #include "SvtTrack.h" class GblTrack : public SvtTrack { - -public: - - /** Constructor */ - GblTrack(){}; - - /** - * Set the lambda kink of the given layer. - * - * @param layer Layer number associated with the given lambda kink. - * @param lambda_kink The lambda kink value. - */ - void setLambdaKink(const int layer, const double lambda_kink) { lambda_kinks[layer] = lambda_kink; } - - /** - * Set the phi kink of the given layer. - * - * @param layer Layer number associated with the given phi kink. - * @param phi_kink The phi kink value. - */ - void setPhiKink(const int layer, const double phi_kink) { phi_kinks[layer] = phi_kink; } - - /** - * Set the seed track that was refit to create this GBL track. - * - * @param Seed_track The seed track (SvtTrack object) - */ - void setSeedTrack(SvtTrack* Seed_track) { seed_track = static_cast(Seed_track); } - - /** - * Get the lambda kink value of the given layer. - * - * @param layer The SVT layer of interest. - * @return The lambda kink value of the given layer. - */ - double getLambdaKink(const int layer) const { return lambda_kinks[layer]; } - - /** - * Get the phi kink value of the given layer. - * - * @param layer The SVT layer of interest. - * @return The phi kink value of the given layer. - */ - double getPhiKink(const int layer) const { return phi_kinks[layer]; } - - /** - * Get the seed track that was refit to create this GBL track. - * - * @return The seed track. - */ - SvtTrack* getSeedTrack() const { return static_cast(seed_track.GetObject()); } - - ClassDef(GblTrack, 2) - -private: - - /** Reference to corresponding seed track */ - TRef seed_track; - - /** Array used to store the lambda kinks for each of the sensor layers. */ - std::vector lambda_kinks = std::vector(14,-9999); - - /** Array used to store the phi kinks for each of the sensor layers. */ - std::vector phi_kinks = std::vector(14,-9999); + + public: + + /** Constructor */ + GblTrack(); + + /** + * Set the lambda kink of the given layer. + * + * @param layer Layer number associated with the given lambda kink. + * @param lambda_kink The lambda kink value. + */ + void setLambdaKink(const int layer, const double lambda_kink) { lambda_kinks[layer] = lambda_kink; } + + /** + * Set the phi kink of the given layer. + * + * @param layer Layer number associated with the given phi kink. + * @param phi_kink The phi kink value. + */ + void setPhiKink(const int layer, const double phi_kink) { phi_kinks[layer] = phi_kink; } + + /** + * Set the seed track that was refit to create this GBL track. + * + * @param Seed_track The seed track (SvtTrack object) + */ + void setSeedTrack(SvtTrack* Seed_track) { seed_track = static_cast(Seed_track); } + + /** + * Get the lambda kink value of the given layer. + * + * @param layer The SVT layer of interest. + * @return The lambda kink value of the given layer. + */ + double getLambdaKink(const int layer) const { return lambda_kinks[layer]; } + + /** + * Get the phi kink value of the given layer. + * + * @param layer The SVT layer of interest. + * @return The phi kink value of the given layer. + */ + double getPhiKink(const int layer) const { return phi_kinks[layer]; } + + /** + * Get the seed track that was refit to create this GBL track. + * + * @return The seed track. + */ + SvtTrack* getSeedTrack() const { return static_cast(seed_track.GetObject()); } + + ClassDef(GblTrack, 1) + + private: + + /** Reference to corresponding seed track */ + TRef seed_track; + + /** Array used to store the lambda kinks for each of the sensor layers. */ + double lambda_kinks[12]; + + /** Array used to store the phi kinks for each of the sensor layers. */ + double phi_kinks[12]; }; #endif // __GBL_TRACK_H__ diff --git a/include/hps_event/HpsEvent.h b/include/hps_event/HpsEvent.h index 884bb19..d667fdd 100644 --- a/include/hps_event/HpsEvent.h +++ b/include/hps_event/HpsEvent.h @@ -6,7 +6,6 @@ * @author Omar Moreno * Santa Cruz Institute for Particle Physics * University of California, Santa Cruz - * @author Maurik Holtrop * @date February 19, 2013 * */ diff --git a/include/hps_event/HpsParticle.h b/include/hps_event/HpsParticle.h index 1259480..7506fd3 100644 --- a/include/hps_event/HpsParticle.h +++ b/include/hps_event/HpsParticle.h @@ -209,7 +209,9 @@ class HpsParticle : public TObject { * @return 1/2 covariant matrix in a vector of 15 entries. */ std::vector getCovariantMatrix() const{ - return(covmatrix); // C++11 returns matrix by move. + std::vector retvec(sizeof(covmatrix)); + retvec.assign(covmatrix,covmatrix+sizeof(covmatrix)); // Copy data into vector. + return(retvec); // C++11 returns matrix by move. }; /** @@ -234,7 +236,6 @@ class HpsParticle : public TObject { * Note that this is MUCH less efficient than getCovariantMatrix or getCovariantMatrix(i,j) * * @return 1/2 covariant matrix in a 5x5 TMatrix. - * This copies the matrix twice! (ouch) */ TMatrixD getCovariantTMatrix() const{ double data[16]; @@ -246,7 +247,7 @@ class HpsParticle : public TObject { k++; } TMatrixD retmat(4,4,data); - return(retmat); + return(retmat); // This copies the matrix twice! (ouch) }; /** @@ -296,18 +297,14 @@ class HpsParticle : public TObject { * * @return The corrected momentum of the particle. */ - std::vector getCorrMomentum() const { - return {px, py, pz}; - }; + std::vector getCorrMomentum() const; /** * Get the vertex position of the particle. * * @return The vertex position of the particle */ - std::vector getVertexPosition() const{ - return {vtx_x,vtx_y,vtx_z}; - }; + std::vector getVertexPosition() const; /** * Get the chi^2 of the vertex fit. @@ -381,7 +378,7 @@ class HpsParticle : public TObject { double vtx_fit_chi2; /** The 1/2 Covariant Matrix. This is the lower 1/2. **/ - std::vector covmatrix = std::vector(10,0); + float covmatrix[10]; /** The energy of the particle in GeV */ double energy; diff --git a/include/hps_event/SvtTrack.h b/include/hps_event/SvtTrack.h index 319723b..43b4618 100644 --- a/include/hps_event/SvtTrack.h +++ b/include/hps_event/SvtTrack.h @@ -37,364 +37,364 @@ class SvtHit; class GblTrack; class SvtTrack : public TObject { - - // TODO: Add more documentation - + + // TODO: Add more documentation + public: - - /** Constructor */ - SvtTrack(); - - /** - * Copy constructor - * - * @param svtTrackObj An SvtTrack object - */ - SvtTrack(const SvtTrack &svtTrackObj); - - /** Destructor */ - ~SvtTrack(); - - /** - * Copy assignment operator - * - * @param svtTrackObj An SvtTrack object - */ - SvtTrack &operator=(const SvtTrack &svtTrackObj); - - /** Reset the SvtTrack object */ - void Clear(Option_t *option=""); - - /** - * Add a reference to an SvtHit. - * - * @param hit : An SvtHit - */ - void addHit(SvtHit* hit); - - /** - * Set the track parameters. - * - * @param d0 Distance of closest approach to the reference point. - * @param phi0 The azimuthal angle of the momentum at the distance of - * closest approach. - * @param omega The curvature of the track. - * @param tan_lambda The slope of the track in the SY plane. - * @param z0 The y position of the track at the distance of closest - * approach. - */ - void setTrackParameters(const double d0, - const double phi0, - const double omega, - const double tan_lambda, - const double z0); - - /** - * Set the chi^2 of the fit to the track. - * - * @param Chi_squared The chi^2 of the fit to the track. - */ - void setChi2(const double Chi_squared) { chi_squared = Chi_squared; }; - - /** - * Set the track time. - * - * @param Track_time The track time. - */ - void setTrackTime(const double Track_time) { track_time = Track_time; }; - - /** - * Set the isolation variable of the given layer. - * - * @param Layer Layer number associated with the given isolation value. - * @param Isolation The isolation variable. - */ - void setIsolation(const int Layer, const double Isolation) { isolation[Layer] = Isolation; }; - - /** - * The the volume (Top/Bottom) that the track is located in. - * - * @param Track_volume The track volume. - */ - void setTrackVolume(const int Track_volume) { track_volume = Track_volume; }; - - /** - * Set the HpsParticle associated with this track. This can be used to - * retrieve additional track properties such as the momentum and charge. - * - * @param Fs_particle : Final state HpsParticle associated with this track - */ - void setParticle(HpsParticle* Fs_particle) { fs_particle = (TObject*) Fs_particle; }; - - /** - * Set the extrapolated track position at the Ecal face. The - * extrapolation is assumed to use the full 3D field map. - * - * @parm position The extrapolated track position at the Ecal - */ - void setPositionAtEcal(const double* position); - - /** - * Set the 1/2 covariant matrix for the track - * - * @parm An array of 15 doubles, which is the 1/2 covariant matrix. - */ - void setCovMatrix(const float *covariant_matrix){ - std::copy(&covariant_matrix[0],&covariant_matrix[14],std::back_inserter(covmatrix)); + + /** Constructor */ + SvtTrack(); + + /** + * Copy constructor + * + * @param svtTrackObj An SvtTrack object + */ + SvtTrack(const SvtTrack &svtTrackObj); + + /** Destructor */ + ~SvtTrack(); + + /** + * Copy assignment operator + * + * @param svtTrackObj An SvtTrack object + */ + SvtTrack &operator=(const SvtTrack &svtTrackObj); + + /** Reset the SvtTrack object */ + void Clear(Option_t *option=""); + + /** + * Add a reference to an SvtHit. + * + * @param hit : An SvtHit + */ + void addHit(SvtHit* hit); + + /** + * Set the track parameters. + * + * @param d0 Distance of closest approach to the reference point. + * @param phi0 The azimuthal angle of the momentum at the distance of + * closest approach. + * @param omega The curvature of the track. + * @param tan_lambda The slope of the track in the SY plane. + * @param z0 The y position of the track at the distance of closest + * approach. + */ + void setTrackParameters(const double d0, + const double phi0, + const double omega, + const double tan_lambda, + const double z0); + + /** + * Set the chi^2 of the fit to the track. + * + * @param Chi_squared The chi^2 of the fit to the track. + */ + void setChi2(const double Chi_squared) { chi_squared = Chi_squared; }; + + /** + * Set the track time. + * + * @param Track_time The track time. + */ + void setTrackTime(const double Track_time) { track_time = Track_time; }; + + /** + * Set the isolation variable of the given layer. + * + * @param Layer Layer number associated with the given isolation value. + * @param Isolation The isolation variable. + */ + void setIsolation(const int Layer, const double Isolation) { isolation[Layer] = Isolation; }; + + /** + * The the volume (Top/Bottom) that the track is located in. + * + * @param Track_volume The track volume. + */ + void setTrackVolume(const int Track_volume) { track_volume = Track_volume; }; + + /** + * Set the HpsParticle associated with this track. This can be used to + * retrieve additional track properties such as the momentum and charge. + * + * @param Fs_particle : Final state HpsParticle associated with this track + */ + void setParticle(HpsParticle* Fs_particle) { fs_particle = (TObject*) Fs_particle; }; + + /** + * Set the extrapolated track position at the Ecal face. The + * extrapolation is assumed to use the full 3D field map. + * + * @parm position The extrapolated track position at the Ecal + */ + void setPositionAtEcal(const double* position); + + /** + * Set the 1/2 covariant matrix for the track + * + * @parm An array of 15 doubles, which is the 1/2 covariant matrix. + */ + void setCovMatrix(const float *covariant_matrix){ + memcpy(&covmatrix,covariant_matrix,sizeof(covmatrix)); + } + + /** + * Set the track type. For more details, see {@link StrategyType} and + * {@link TrackType}. + * + * @param Type The track type. + */ + void setType(const int Type) { type = Type; }; + + /** + * Set a reference to the GblTrack associated with this seed track. + * + * @param Gbl_track The GBL track associated with this seed track. + */ + void setGblTrack(GblTrack* Gbl_track) { gbl_track = (TObject*) Gbl_track; }; + + /** + * Get the distance of closest approach to the reference point. + * + * @return The distance of closest approach to the reference point. + */ + double getD0() const { return d0; }; + + /** + * Get the azimuthal angle of the momentum at the distance of closest + * approach. + * + * @return The azimuthal angle of the momentum at the distance of + * closest approach. + */ + double getPhi0() const { return phi0; }; + + /** + * Get the curvature of the track. + * + * @return The curvature of the track. + */ + double getOmega() const { return omega; }; + + /** + * Get the slope of the track in the SY plane. + * + * @return The curvature of the track in the SY plane. + */ + double getTanLambda() const { return tan_lambda; }; + + /** + * Get the y position of the track at the distance of closest approach. + * + * @return The y position of the track at the distance of closest + * approach. + */ + double getZ0() const { return z0; }; + + /** + * Get the chi^2 of the fit to the track. + * + * @return the chi^2 of the fit to the track. + */ + double getChi2() const { return chi_squared; }; + + /** + * Get the time of the track. + * + * @return The track time. + */ + double getTrackTime() const { return track_time; }; + + /** + * Get the isolation value of the given layer. + * + * @param layer The SVT layer of interest. + * @return The isolation value of the given layer. + */ + double getIsolation(const int layer) const { return isolation[layer]; }; + + /** + * Get the charge of a the track by computation. + * + * @return The charge associated of the track. + */ + int getCharge() const; + + /** + * Get the track type. + * + * @return The track type. + */ + int getType() const { return type; }; + + /** + * Get the track momentum. + * + * @return The track momentum. + */ + std::vector getMomentum(double bfield=0) const; + + /** + * Get the extrapolated track position at the Ecal face. + * + * @return Extrapolated track position at Ecal face. + */ + std::vector getPositionAtEcal() const; + + /** + * Get the 1/2 covariant matrix as vector + * + * @return 1/2 covariant matrix in a vector of 15 entries. + */ + std::vector getCovariantMatrix() const{ + std::vector retvec(sizeof(covmatrix)); + retvec.assign(covmatrix,covmatrix+sizeof(covmatrix)); // Copy data into vector. + return(retvec); // C++11 returns matrix by move. + }; + + /** + * Get the [rown,coln] element of the covariant matrix. + * + * @return covariant matrix [row,col] value (float) + */ + float getCovariantMatrix(int i,int j) const{ + if(i<0 || j<0 || i>4 || j>4) return(0); + // int k=0; for(int q=0;q<=j;++q) k+=q; + if(j getMomentum(double bfield=0) const; - - /** - * Get the extrapolated track position at the Ecal face. - * - * @return Extrapolated track position at Ecal face. - */ - std::vector getPositionAtEcal() const; - - /** - * Get the 1/2 covariant matrix as vector - * - * @return 1/2 covariant matrix in a vector of 15 entries. - */ - std::vector getCovariantMatrix() const{ -// std::vector retvec(sizeof(covmatrix)); -// retvec.assign(covmatrix,covmatrix+sizeof(covmatrix)); // Copy data into vector. - return(covmatrix); // C++11 returns matrix by move. - }; - - /** - * Get the [rown,coln] element of the covariant matrix. - * - * @return covariant matrix [row,col] value (float) - */ - float getCovariantMatrix(int i,int j) const{ - if(i<0 || j<0 || i>4 || j>4) return(0); - // int k=0; for(int q=0;q<=j;++q) k+=q; - if(j1)+(j-2)*(j>2)+(j-3)*(j>3); - return(covmatrix[k]); - }; - - - /** - * Get the 1/2 covariant matrix as TMatrixD - * Note that this is MUCH less efficient than getCovariantMatrix or getCovariantMatrix(i,j) - * - * @return 1/2 covariant matrix in a 5x5 TMatrix. - */ - TMatrixD getCovariantTMatrix() const{ - double data[25]; - int k=0; - for(int i=0;i<5;i++) - for(int j=0;j1)+(j-2)*(j>2)+(j-3)*(j>3); + return(covmatrix[k]); + }; + + + /** + * Get the 1/2 covariant matrix as TMatrixD + * Note that this is MUCH less efficient than getCovariantMatrix or getCovariantMatrix(i,j) + * + * @return 1/2 covariant matrix in a 5x5 TMatrix. + */ + TMatrixD getCovariantTMatrix() const{ + double data[25]; + int k=0; + for(int i=0;i<5;i++) + for(int j=0;j isolation={0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - - /** The number of 3D hits associated with this track. */ - int n_hits=0; - - /** The volume to which this track belongs to. */ - int track_volume=-1; - - /** The track type. */ - int type=0; - - /** The distance of closest approach to the reference point. */ - double d0=0; - - /** - * The azimuthal angle of the momentum at the position of closest - * approach to the reference point. - */ - double phi0=0; - - /** - * The track curvature. The curvature is positive (negative) if the particle has a - * positive (negative) charge. - */ - double omega=0; - - /** - * The slope of the track in the SY plane where S is the arc length of - * the helix in the xz plane. - */ - double tan_lambda=0; - - /** - * The y position of the track at the distance of closest approach - * in the xz plane. - */ - double z0=0; - - /** The chi^2 of the track fit. */ - double chi_squared=0; - - /** The 1/2 Covariant Matrix. This is the lower 1/2. **/ - std::vector covmatrix={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - - /** - * The time of the track. This is currently the average time of all - * hits composing the track. - */ - double track_time=0; - - /** The x position of the extrapolated track at the Ecal face. */ - double x_at_ecal=0; - - /** The y position of the extrapolated track at the Ecal face. */ - double y_at_ecal=0; - - /** The z position of the extrapolated track at the Ecal face. */ - double z_at_ecal=0; - + + /** Reference to the 3D hits associated with this track. */ + TRefArray* svt_hits = new TRefArray(); + + /** Reference to the reconstructed particle associated with this track. */ + TRef fs_particle=0; + + /** Reference to the GBL track associated with this seed track. */ + TRef gbl_track=0; + + /** Array used to store the isolation variables for each of the sensor layers. */ + double isolation[12]={0,0,0,0,0,0,0,0,0,0,0,0}; + + /** The number of 3D hits associated with this track. */ + int n_hits=0; + + /** The volume to which this track belongs to. */ + int track_volume=-1; + + /** The track type. */ + int type=0; + + /** The distance of closest approach to the reference point. */ + double d0=0; + + /** + * The azimuthal angle of the momentum at the position of closest + * approach to the reference point. + */ + double phi0=0; + + /** + * The track curvature. The curvature is positive (negative) if the particle has a + * positive (negative) charge. + */ + double omega=0; + + /** + * The slope of the track in the SY plane where S is the arc length of + * the helix in the xz plane. + */ + double tan_lambda=0; + + /** + * The y position of the track at the distance of closest approach + * in the xz plane. + */ + double z0=0; + + /** The chi^2 of the track fit. */ + double chi_squared=0; + + /** The 1/2 Covariant Matrix. This is the lower 1/2. **/ + float covmatrix[15]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + + /** + * The time of the track. This is currently the average time of all + * hits composing the track. + */ + double track_time=0; + + /** The x position of the extrapolated track at the Ecal face. */ + double x_at_ecal=0; + + /** The y position of the extrapolated track at the Ecal face. */ + double y_at_ecal=0; + + /** The z position of the extrapolated track at the Ecal face. */ + double z_at_ecal=0; + }; // SvtTrack #endif // __SVT_TRACK_H__ diff --git a/src/dst/SvtDataWriter.cxx b/src/dst/SvtDataWriter.cxx index 59d4a5a..2fe31d5 100644 --- a/src/dst/SvtDataWriter.cxx +++ b/src/dst/SvtDataWriter.cxx @@ -186,7 +186,7 @@ void SvtDataWriter::writeData(EVENT::LCEvent* event, HpsEvent* hps_event) { // Check that the TrackData data structure is correct. If it's // not, throw a runtime exception. - if ((track_datum->getNDouble() != 12 && track_datum->getNDouble() != 14) || track_datum->getNFloat() != 1 + if (track_datum->getNDouble() != 12 || track_datum->getNFloat() != 1 || track_datum->getNInt() != 1) { throw std::runtime_error("[ SvtDataWriter ]: The collection " + TRACK_DATA_COL_NAME + " has the wrong structure."); diff --git a/src/hps_event/GblTrack.cxx b/src/hps_event/GblTrack.cxx index 835e135..23e4120 100644 --- a/src/hps_event/GblTrack.cxx +++ b/src/hps_event/GblTrack.cxx @@ -12,4 +12,13 @@ #include "GblTrack.h" ClassImp(GblTrack) + +GblTrack::GblTrack() + : SvtTrack() { + + // Initialize the lambda and phi kinks to a non-zero value + std::fill_n(lambda_kinks, 12, -9999); + std::fill_n(phi_kinks, 12, -9999); +} + diff --git a/src/hps_event/HpsParticle.cxx b/src/hps_event/HpsParticle.cxx index 69f41f0..886afce 100644 --- a/src/hps_event/HpsParticle.cxx +++ b/src/hps_event/HpsParticle.cxx @@ -169,3 +169,16 @@ std::vector HpsParticle::getMomentum() const { return momentum; } +std::vector HpsParticle::getCorrMomentum() const { + std::vector momentum {px, py, pz}; + return momentum; +} + +std::vector HpsParticle::getVertexPosition() const { + std::vector vertex(3,0); + vertex[0] = vtx_x; + vertex[1] = vtx_y; + vertex[2] = vtx_z; + return vertex; +} + diff --git a/src/hps_event/SvtTrack.cxx b/src/hps_event/SvtTrack.cxx index 8b39b6e..7a2e34a 100644 --- a/src/hps_event/SvtTrack.cxx +++ b/src/hps_event/SvtTrack.cxx @@ -34,10 +34,8 @@ z_at_ecal(svtTrackObj.x_at_ecal) { *svt_hits = *svtTrackObj.svt_hits; fs_particle = svtTrackObj.fs_particle; gbl_track = svtTrackObj.gbl_track; - isolation = svtTrackObj.isolation; - // std::copy(svtTrackObj.isolation.begin(), svtTrackObj.isolation.end(), - // std::back_inserter(isolation)); - covmatrix =svtTrackObj.covmatrix; + memcpy(&isolation, svtTrackObj.isolation, sizeof(isolation)); + memcpy(&covmatrix, svtTrackObj.covmatrix, sizeof(covmatrix)); } @@ -66,10 +64,8 @@ SvtTrack &SvtTrack::operator=(const SvtTrack &svtTrackObj) { *svt_hits = *svtTrackObj.svt_hits; fs_particle = svtTrackObj.fs_particle; gbl_track = svtTrackObj.gbl_track; - isolation = svtTrackObj.isolation; - // std::copy(svtTrackObj.isolation.begin(), svtTrackObj.isolation.end(), - // std::back_inserter(isolation)); - covmatrix=svtTrackObj.covmatrix; + memcpy(&isolation, svtTrackObj.isolation, sizeof(isolation)); + memcpy(&covmatrix, svtTrackObj.covmatrix, sizeof(covmatrix)); return *this; } @@ -81,8 +77,8 @@ SvtTrack::~SvtTrack() { void SvtTrack::Clear(Option_t* /* option */) { TObject::Clear(); svt_hits->Delete(); - std::fill(isolation.begin(),isolation.end(), 0); - std::fill(covmatrix.begin(),covmatrix.end(), 0); + memset(isolation, 0, sizeof(isolation)); + memset(covmatrix, 0, sizeof(covmatrix)); n_hits = 0; }