added CircularMean to PW class

This commit is contained in:
Ryan@Home 2024-04-29 15:24:16 -04:00
parent ccab43f18c
commit b0093563d5
2 changed files with 31 additions and 0 deletions

View File

@ -37,6 +37,18 @@
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64"
},
{
"name": "RyanHome",
"includePath": [
"${workspaceFolder}/**",
"/home/ryan/root_v6.30.06/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64"
},
{
"name": "Dirac",
"includePath": [

View File

@ -65,6 +65,8 @@ public:
void CalTrack(TVector3 sx3Pos, int anodeID, int cathodeID, bool verbose = false);
void CalTrack2(TVector3 sx3Pos, PWHitInfo hitInfo, double sigmaA = 0, double sigmaC = 0, bool verbose = false);
double CircularMean(std::vector<std::pair<int, double>> wireList);
void Print(){
printf(" The nearest | Anode: %2d(%5.2f) Cathode: %2d(%5.2f)\n", hitInfo.nearestWire.first,
hitInfo.nearestDist.first,
@ -280,4 +282,21 @@ inline double PW::GetZ0(){
}
inline double PW::CircularMean(std::vector<std::pair<int, double>> wireList){
//use unit vector, wireID start from Zero
double xCom = 0, yCom = 0;
for( size_t i = 0; i < wireList.size() ; i++){
xCom += TMath::Cos(TMath::TwoPi() * wireList[i].first / nWire) * wireList[i].second;
yCom += TMath::Sin(TMath::TwoPi() * wireList[i].first / nWire) * wireList[i].second;
}
//calculate the angle of the summed unit vectors
double angle = TMath::ATan2(yCom, xCom);
if( angle < 0 ) angle += TMath::TwoPi(); // convert the angle from 0 to 2 pi
return angle/ TMath::TwoPi() * nWire;
}
#endif