Skip to content
Snippets Groups Projects
Commit 82b7af54 authored by FU Chengdong's avatar FU Chengdong
Browse files

change control from macro to parameter

parent af9bbbe4
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include <array> #include <array>
namespace CEPC{ 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 GetResolutionRPhi(edm4hep::TrackerHit& hit);
float GetResolutionZ(edm4hep::TrackerHit& hit); float GetResolutionZ(edm4hep::TrackerHit& hit);
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "CLHEP/Vector/Rotation.h" #include "CLHEP/Vector/Rotation.h"
#include <bitset> #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()){ if(hit.isAvailable()){
int type = hit.getType(); int type = hit.getType();
if(std::bitset<32>(type)[CEPCConf::TrkHitTypeBit::COMPOSITE_SPACEPOINT]){ if(std::bitset<32>(type)[CEPCConf::TrkHitTypeBit::COMPOSITE_SPACEPOINT]){
...@@ -23,51 +23,52 @@ std::array<float,6> CEPC::GetCovMatrix(edm4hep::TrackerHit& hit){ ...@@ -23,51 +23,52 @@ std::array<float,6> CEPC::GetCovMatrix(edm4hep::TrackerHit& hit){
float thetaV = hit.getCovMatrix(3); float thetaV = hit.getCovMatrix(3);
float phiV = hit.getCovMatrix(4); float phiV = hit.getCovMatrix(4);
float dV = hit.getCovMatrix(5); 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); if(!useSpacePointBuilderMethod){
TMatrixF diffs(2,3);
TMatrixF covMatrixUV(2,2); TMatrixF diffsT(3,2);
covMatrixUV(0,0) = dU*dU; diffs(0,0) = sin(thetaU)*cos(phiU);
covMatrixUV(0,1) = 0; diffs(0,1) = sin(thetaU)*sin(phiU);
covMatrixUV(1,0) = 0; diffs(0,2) = cos(thetaU);
covMatrixUV(1,1) = dV*dV; diffs(1,0) = sin(thetaV)*cos(phiV);
diffs(1,1) = sin(thetaV)*sin(phiV);
TMatrixF covMatrixXYZ(3,3); diffs(1,2) = cos(thetaV);
covMatrixXYZ = diffsT*covMatrixUV*diffs;
cov[0] = covMatrixXYZ(0,0); diffsT.Transpose(diffs);
cov[1] = covMatrixXYZ(1,0);
cov[2] = covMatrixXYZ(1,1); TMatrixF covMatrixUV(2,2);
cov[3] = covMatrixXYZ(2,0); covMatrixUV(0,0) = dU*dU;
cov[4] = covMatrixXYZ(2,1); covMatrixUV(0,1) = 0;
cov[5] = covMatrixXYZ(2,2); covMatrixUV(1,0) = 0;
#else // Method used in SpacePointBuilder, results are almost same with above covMatrixUV(1,1) = dV*dV;
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)); TMatrixF covMatrixXYZ(3,3);
CLHEP::Hep3Vector w_sensor = u_sensor.cross(v_sensor); covMatrixXYZ = diffsT*covMatrixUV*diffs;
CLHEP::HepRotation rot_sensor(u_sensor, v_sensor, w_sensor); cov[0] = covMatrixXYZ(0,0);
CLHEP::HepMatrix rot_sensor_matrix; cov[1] = covMatrixXYZ(1,0);
rot_sensor_matrix = rot_sensor; cov[2] = covMatrixXYZ(1,1);
CLHEP::HepSymMatrix cov_plane(3,0); cov[3] = covMatrixXYZ(2,0);
cov_plane(1,1) = dU*dU; cov[4] = covMatrixXYZ(2,1);
cov_plane(2,2) = dV*dV; cov[5] = covMatrixXYZ(2,2);
CLHEP::HepSymMatrix cov_xyz= cov_plane.similarity(rot_sensor_matrix); }
cov[0] = cov_xyz[0][0]; else{ // Method used in SpacePointBuilder, results are almost same with above
cov[1] = cov_xyz[1][0]; CLHEP::Hep3Vector u_sensor(sin(thetaU)*cos(phiU), sin(thetaU)*sin(phiU), cos(thetaU));
cov[2] = cov_xyz[1][1]; CLHEP::Hep3Vector v_sensor(sin(thetaV)*cos(phiV), sin(thetaV)*sin(phiV), cos(thetaV));
cov[3] = cov_xyz[2][0]; CLHEP::Hep3Vector w_sensor = u_sensor.cross(v_sensor);
cov[4] = cov_xyz[2][1]; CLHEP::HepRotation rot_sensor(u_sensor, v_sensor, w_sensor);
cov[5] = cov_xyz[2][2]; CLHEP::HepMatrix rot_sensor_matrix;
#endif 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; return cov;
} }
else{ else{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment