diff --git a/Utilities/DataHelper/include/DataHelper/TrackerHitHelper.h b/Utilities/DataHelper/include/DataHelper/TrackerHitHelper.h index c83fb7a46da4ad2e487bfbdded6d525c06f8cb55..60057adaf9afac84541b4a770bfa8a879658617a 100644 --- a/Utilities/DataHelper/include/DataHelper/TrackerHitHelper.h +++ b/Utilities/DataHelper/include/DataHelper/TrackerHitHelper.h @@ -5,7 +5,7 @@ #include <array> namespace CEPC{ - std::array<float, 6> GetCovMatrix(edm4hep::TrackerHit& hit); + std::array<float, 6> GetCovMatrix(edm4hep::TrackerHit& hit, bool useSpacePointerBuilderMethod = false); float GetResolutionRPhi(edm4hep::TrackerHit& hit); float GetResolutionZ(edm4hep::TrackerHit& hit); } diff --git a/Utilities/DataHelper/src/TrackerHitHelper.cpp b/Utilities/DataHelper/src/TrackerHitHelper.cpp index 1edfb733b1a01d44e0138ecff856d882db4499b1..58f5278d6e3beefcf7b2986e0a25c59713bb259e 100644 --- a/Utilities/DataHelper/src/TrackerHitHelper.cpp +++ b/Utilities/DataHelper/src/TrackerHitHelper.cpp @@ -9,7 +9,7 @@ #include "CLHEP/Vector/Rotation.h" #include <bitset> -std::array<float,6> CEPC::GetCovMatrix(edm4hep::TrackerHit& hit){ +std::array<float,6> CEPC::GetCovMatrix(edm4hep::TrackerHit& hit, bool useSpacePointBuilderMethod){ if(hit.isAvailable()){ int type = hit.getType(); if(std::bitset<32>(type)[CEPCConf::TrkHitTypeBit::COMPOSITE_SPACEPOINT]){ @@ -23,51 +23,52 @@ std::array<float,6> CEPC::GetCovMatrix(edm4hep::TrackerHit& hit){ float thetaV = hit.getCovMatrix(3); float phiV = hit.getCovMatrix(4); float dV = hit.getCovMatrix(5); - -#ifndef MethodUsedInSpacePointBuilder - TMatrixF diffs(2,3); - TMatrixF diffsT(3,2); - diffs(0,0) = sin(thetaU)*cos(phiU); - diffs(0,1) = sin(thetaU)*sin(phiU); - diffs(0,2) = cos(thetaU); - diffs(1,0) = sin(thetaV)*cos(phiV); - diffs(1,1) = sin(thetaV)*sin(phiV); - diffs(1,2) = cos(thetaV); - diffsT.Transpose(diffs); - - TMatrixF covMatrixUV(2,2); - covMatrixUV(0,0) = dU*dU; - covMatrixUV(0,1) = 0; - covMatrixUV(1,0) = 0; - covMatrixUV(1,1) = dV*dV; - - TMatrixF covMatrixXYZ(3,3); - covMatrixXYZ = diffsT*covMatrixUV*diffs; - cov[0] = covMatrixXYZ(0,0); - cov[1] = covMatrixXYZ(1,0); - cov[2] = covMatrixXYZ(1,1); - cov[3] = covMatrixXYZ(2,0); - cov[4] = covMatrixXYZ(2,1); - cov[5] = covMatrixXYZ(2,2); -#else // Method used in SpacePointBuilder, results are almost same with above - CLHEP::Hep3Vector u_sensor(sin(thetaU)*cos(phiU), sin(thetaU)*sin(phiU), cos(thetaU)); - CLHEP::Hep3Vector v_sensor(sin(thetaV)*cos(phiV), sin(thetaV)*sin(phiV), cos(thetaV)); - CLHEP::Hep3Vector w_sensor = u_sensor.cross(v_sensor); - CLHEP::HepRotation rot_sensor(u_sensor, v_sensor, w_sensor); - CLHEP::HepMatrix rot_sensor_matrix; - rot_sensor_matrix = rot_sensor; - CLHEP::HepSymMatrix cov_plane(3,0); - cov_plane(1,1) = dU*dU; - cov_plane(2,2) = dV*dV; - CLHEP::HepSymMatrix cov_xyz= cov_plane.similarity(rot_sensor_matrix); - cov[0] = cov_xyz[0][0]; - cov[1] = cov_xyz[1][0]; - cov[2] = cov_xyz[1][1]; - cov[3] = cov_xyz[2][0]; - cov[4] = cov_xyz[2][1]; - cov[5] = cov_xyz[2][2]; -#endif + if(!useSpacePointBuilderMethod){ + TMatrixF diffs(2,3); + TMatrixF diffsT(3,2); + diffs(0,0) = sin(thetaU)*cos(phiU); + diffs(0,1) = sin(thetaU)*sin(phiU); + diffs(0,2) = cos(thetaU); + diffs(1,0) = sin(thetaV)*cos(phiV); + diffs(1,1) = sin(thetaV)*sin(phiV); + diffs(1,2) = cos(thetaV); + + diffsT.Transpose(diffs); + + TMatrixF covMatrixUV(2,2); + covMatrixUV(0,0) = dU*dU; + covMatrixUV(0,1) = 0; + covMatrixUV(1,0) = 0; + covMatrixUV(1,1) = dV*dV; + + TMatrixF covMatrixXYZ(3,3); + covMatrixXYZ = diffsT*covMatrixUV*diffs; + cov[0] = covMatrixXYZ(0,0); + cov[1] = covMatrixXYZ(1,0); + cov[2] = covMatrixXYZ(1,1); + cov[3] = covMatrixXYZ(2,0); + cov[4] = covMatrixXYZ(2,1); + cov[5] = covMatrixXYZ(2,2); + } + else{ // Method used in SpacePointBuilder, results are almost same with above + CLHEP::Hep3Vector u_sensor(sin(thetaU)*cos(phiU), sin(thetaU)*sin(phiU), cos(thetaU)); + CLHEP::Hep3Vector v_sensor(sin(thetaV)*cos(phiV), sin(thetaV)*sin(phiV), cos(thetaV)); + CLHEP::Hep3Vector w_sensor = u_sensor.cross(v_sensor); + CLHEP::HepRotation rot_sensor(u_sensor, v_sensor, w_sensor); + CLHEP::HepMatrix rot_sensor_matrix; + rot_sensor_matrix = rot_sensor; + CLHEP::HepSymMatrix cov_plane(3,0); + cov_plane(1,1) = dU*dU; + cov_plane(2,2) = dV*dV; + CLHEP::HepSymMatrix cov_xyz= cov_plane.similarity(rot_sensor_matrix); + cov[0] = cov_xyz[0][0]; + cov[1] = cov_xyz[1][0]; + cov[2] = cov_xyz[1][1]; + cov[3] = cov_xyz[2][0]; + cov[4] = cov_xyz[2][1]; + cov[5] = cov_xyz[2][2]; + } return cov; } else{