added CircularMean to PW class
This commit is contained in:
parent
ccab43f18c
commit
b0093563d5
12
.vscode/c_cpp_properties.json
vendored
12
.vscode/c_cpp_properties.json
vendored
|
@ -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": [
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue
Block a user