modified: .vscode/settings.json
modified: Armory/ClassPW.h
This commit is contained in:
parent
d8b11bdcf3
commit
9bf83f8028
15
.vscode/settings.json
vendored
15
.vscode/settings.json
vendored
|
@ -90,6 +90,17 @@
|
|||
"processRun.C": "cpp",
|
||||
"TrackRecon.C": "cpp",
|
||||
"processRuns.C": "cpp",
|
||||
"Analysis.C": "cpp"
|
||||
}
|
||||
"Analysis.C": "cpp",
|
||||
"datastructs.h": "c",
|
||||
"ANASENPlotEdit.C": "cpp",
|
||||
"GetMean_Q3_new.C": "cpp",
|
||||
"AlphaCal_new.C": "cpp",
|
||||
"f1.C": "cpp",
|
||||
"GeoCal_Maria_new.C": "cpp",
|
||||
"PCPulser_All_new.C": "cpp",
|
||||
"PosCal_2.C": "cpp",
|
||||
"AutoFit.C": "cpp",
|
||||
"Fitting.C": "cpp"
|
||||
},
|
||||
"github-enterprise.uri": "https://fsunuc.physics.fsu.edu"
|
||||
}
|
113
Armory/ClassPW.h
113
Armory/ClassPW.h
|
@ -6,14 +6,16 @@
|
|||
#include <TVector3.h>
|
||||
#include <TRandom.h>
|
||||
|
||||
struct PWHitInfo{
|
||||
struct PWHitInfo
|
||||
{
|
||||
std::pair<short, short> nearestWire; // anode, cathode
|
||||
std::pair<double, double> nearestDist; // anode, cathode
|
||||
|
||||
std::pair<short, short> nextNearestWire; // anode, cathode
|
||||
std::pair<double, double> nextNearestDist; // anode, cathode
|
||||
|
||||
void Clear(){
|
||||
void Clear()
|
||||
{
|
||||
nearestWire.first = -1;
|
||||
nearestWire.second = -1;
|
||||
nearestDist.first = 999999999;
|
||||
|
@ -25,8 +27,20 @@ struct PWHitInfo{
|
|||
}
|
||||
};
|
||||
|
||||
struct Coord
|
||||
{
|
||||
float x, y, z;
|
||||
Coord(const TVector3 &vec)
|
||||
{
|
||||
x = vec.X(); // TVector3's X() returns the x-coordinate
|
||||
y = vec.Y(); // TVector3's Y() returns the y-coordinate
|
||||
z = vec.Z(); // TVector3's Z() returns the z-coordinate
|
||||
}
|
||||
};
|
||||
|
||||
//! ########################################################
|
||||
class PW{ // proportional wire
|
||||
class PW
|
||||
{ // proportional wire
|
||||
public:
|
||||
PW() { ClearHitInfo(); };
|
||||
~PW() {};
|
||||
|
@ -66,7 +80,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);
|
||||
|
||||
void Print(){
|
||||
void Print()
|
||||
{
|
||||
printf(" The nearest | Anode: %2d(%5.2f) Cathode: %2d(%5.2f)\n", hitInfo.nearestWire.first,
|
||||
hitInfo.nearestDist.first,
|
||||
hitInfo.nearestWire.second,
|
||||
|
@ -79,7 +94,6 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
|
||||
PWHitInfo hitInfo;
|
||||
|
||||
TVector3 trackPos;
|
||||
|
@ -98,20 +112,22 @@ private:
|
|||
std::vector<std::pair<TVector3, TVector3>> An; // the anode wire position vector in space
|
||||
std::vector<std::pair<TVector3, TVector3>> Ca; // the cathode wire position vector in space
|
||||
|
||||
double Distance(TVector3 a1, TVector3 a2, TVector3 b1, TVector3 b2){
|
||||
double Distance(TVector3 a1, TVector3 a2, TVector3 b1, TVector3 b2)
|
||||
{
|
||||
TVector3 na = a1 - a2;
|
||||
TVector3 nb = b1 - b2;
|
||||
TVector3 nd = (na.Cross(nb)).Unit();
|
||||
return TMath::Abs(nd.Dot(a1 - b2));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
inline void PW::ClearHitInfo(){
|
||||
inline void PW::ClearHitInfo()
|
||||
{
|
||||
hitInfo.Clear();
|
||||
}
|
||||
|
||||
inline void PW::ConstructGeo(){
|
||||
inline void PW::ConstructGeo()
|
||||
{
|
||||
|
||||
An.clear();
|
||||
Ca.clear();
|
||||
|
@ -123,7 +139,8 @@ inline void PW::ConstructGeo(){
|
|||
// anode wire shift is right-hand.
|
||||
// cathode wire shift is left-hand.
|
||||
|
||||
for(int i = 0; i < nWire; i++ ){
|
||||
for (int i = 0; i < nWire; i++)
|
||||
{
|
||||
// Anode rotate right-hand
|
||||
p1.first.SetXYZ(radiusA * TMath::Cos(TMath::TwoPi() / nWire * (i) + TMath::PiOver2()),
|
||||
radiusA * TMath::Sin(TMath::TwoPi() / nWire * (i) + TMath::PiOver2()),
|
||||
|
@ -148,23 +165,29 @@ inline void PW::ConstructGeo(){
|
|||
cathodeLength = TMath::Sqrt(zLen * zLen + TMath::Power(2 * radiusC * TMath::Sin(dAngle / 2), 2));
|
||||
}
|
||||
|
||||
inline void PW::FindWireID(TVector3 pos, TVector3 direction, bool verbose ){
|
||||
inline void PW::FindWireID(TVector3 pos, TVector3 direction, bool verbose)
|
||||
{
|
||||
|
||||
hitInfo.Clear();
|
||||
double phi = direction.Phi();
|
||||
|
||||
for( int i = 0; i < nWire; i++){
|
||||
for (int i = 0; i < nWire; i++)
|
||||
{
|
||||
|
||||
double disA = 99999999;
|
||||
double phiS = An[i].first.Phi() - TMath::PiOver4();
|
||||
double phiL = An[i].second.Phi() + TMath::PiOver4();
|
||||
// printf("A%2d: %f %f | %f\n", i, phiS * TMath::RadToDeg(), phiL * TMath::RadToDeg(), phi * TMath::RadToDeg());
|
||||
if( phi > 0 && phiS > phiL ) phiL = phiL + TMath::TwoPi();
|
||||
if( phi < 0 && phiS > phiL ) phiS = phiS - TMath::TwoPi();
|
||||
if (phi > 0 && phiS > phiL)
|
||||
phiL = phiL + TMath::TwoPi();
|
||||
if (phi < 0 && phiS > phiL)
|
||||
phiS = phiS - TMath::TwoPi();
|
||||
|
||||
if( phiS < phi && phi < phiL) {
|
||||
if (phiS < phi && phi < phiL)
|
||||
{
|
||||
disA = Distance(pos, pos + direction, An[i].first, An[i].second);
|
||||
if( disA < hitInfo.nearestDist.first ){
|
||||
if (disA < hitInfo.nearestDist.first)
|
||||
{
|
||||
hitInfo.nearestDist.first = disA;
|
||||
hitInfo.nearestWire.first = i;
|
||||
}
|
||||
|
@ -174,53 +197,70 @@ inline void PW::FindWireID(TVector3 pos, TVector3 direction, bool verbose ){
|
|||
phiS = Ca[i].second.Phi() - TMath::PiOver4();
|
||||
phiL = Ca[i].first.Phi() + TMath::PiOver4();
|
||||
// printf("C%2d: %f %f\n", i, phiS * TMath::RadToDeg(), phiL * TMath::RadToDeg());
|
||||
if( phi > 0 && phiS > phiL ) phiL = phiL + TMath::TwoPi();
|
||||
if( phi < 0 && phiS > phiL ) phiS = phiS - TMath::TwoPi();
|
||||
if (phi > 0 && phiS > phiL)
|
||||
phiL = phiL + TMath::TwoPi();
|
||||
if (phi < 0 && phiS > phiL)
|
||||
phiS = phiS - TMath::TwoPi();
|
||||
|
||||
if(phiS < phi && phi < phiL) {
|
||||
if (phiS < phi && phi < phiL)
|
||||
{
|
||||
disC = Distance(pos, pos + direction, Ca[i].first, Ca[i].second);
|
||||
if( disC < hitInfo.nearestDist.second ){
|
||||
if (disC < hitInfo.nearestDist.second)
|
||||
{
|
||||
hitInfo.nearestDist.second = disC;
|
||||
hitInfo.nearestWire.second = i;
|
||||
}
|
||||
}
|
||||
|
||||
if(verbose) printf(" %2d | %8.2f, %8.2f\n", i, disA, disC);
|
||||
if (verbose)
|
||||
printf(" %2d | %8.2f, %8.2f\n", i, disA, disC);
|
||||
}
|
||||
|
||||
//==== find the 2nd nearest wire
|
||||
short anode1 = hitInfo.nearestWire.first;
|
||||
short aaa1 = anode1 - 1; if( aaa1 < 0 ) aaa1 += nWire;
|
||||
short aaa1 = anode1 - 1;
|
||||
if (aaa1 < 0)
|
||||
aaa1 += nWire;
|
||||
short aaa2 = (anode1 + 1) % nWire;
|
||||
|
||||
double haha1 = Distance(pos, pos + direction, An[aaa1].first, An[aaa1].second);
|
||||
double haha2 = Distance(pos, pos + direction, An[aaa2].first, An[aaa2].second);
|
||||
if( haha1 < haha2){
|
||||
if (haha1 < haha2)
|
||||
{
|
||||
hitInfo.nextNearestWire.first = aaa1;
|
||||
hitInfo.nextNearestDist.first = haha1;
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
hitInfo.nextNearestWire.first = aaa2;
|
||||
hitInfo.nextNearestDist.first = haha2;
|
||||
}
|
||||
|
||||
short cathode1 = hitInfo.nearestWire.second;
|
||||
short ccc1 = cathode1 - 1; if( ccc1 < 0 ) ccc1 += nWire;
|
||||
short ccc1 = cathode1 - 1;
|
||||
if (ccc1 < 0)
|
||||
ccc1 += nWire;
|
||||
short ccc2 = (cathode1 + 1) % nWire;
|
||||
|
||||
haha1 = Distance(pos, pos + direction, Ca[ccc1].first, Ca[ccc1].second);
|
||||
haha2 = Distance(pos, pos + direction, Ca[ccc2].first, Ca[ccc2].second);
|
||||
if( haha1 < haha2){
|
||||
if (haha1 < haha2)
|
||||
{
|
||||
hitInfo.nextNearestWire.second = ccc1;
|
||||
hitInfo.nextNearestDist.second = haha1;
|
||||
}else{
|
||||
}
|
||||
else
|
||||
{
|
||||
hitInfo.nextNearestWire.second = ccc2;
|
||||
hitInfo.nextNearestDist.second = haha2;
|
||||
}
|
||||
|
||||
if( verbose ) Print();
|
||||
if (verbose)
|
||||
Print();
|
||||
}
|
||||
|
||||
inline void PW::CalTrack(TVector3 sx3Pos, int anodeID, int cathodeID, bool verbose){
|
||||
inline void PW::CalTrack(TVector3 sx3Pos, int anodeID, int cathodeID, bool verbose)
|
||||
{
|
||||
|
||||
trackPos = sx3Pos;
|
||||
|
||||
|
@ -230,11 +270,12 @@ inline void PW::CalTrack(TVector3 sx3Pos, int anodeID, int cathodeID, bool verbo
|
|||
// if the handiness of anode and cathode revered, it should be n2 cross n1
|
||||
trackVec = (n2.Cross(n1)).Unit();
|
||||
|
||||
if( verbose ) printf("Theta, Phi = %f, %f \n", trackVec.Theta() *TMath::RadToDeg(), trackVec.Phi()*TMath::RadToDeg());
|
||||
|
||||
if (verbose)
|
||||
printf("Theta, Phi = %f, %f \n", trackVec.Theta() * TMath::RadToDeg(), trackVec.Phi() * TMath::RadToDeg());
|
||||
}
|
||||
|
||||
inline void PW::CalTrack2(TVector3 sx3Pos, PWHitInfo hitInfo, double sigmaA, double sigmaC, bool verbose){
|
||||
inline void PW::CalTrack2(TVector3 sx3Pos, PWHitInfo hitInfo, double sigmaA, double sigmaC, bool verbose)
|
||||
{
|
||||
|
||||
trackPos = sx3Pos;
|
||||
|
||||
|
@ -266,11 +307,12 @@ inline void PW::CalTrack2(TVector3 sx3Pos, PWHitInfo hitInfo, double sigmaA, dou
|
|||
// if the handiness of anode and cathode revered, it should be n2 cross n1
|
||||
trackVec = (n2.Cross(n1)).Unit();
|
||||
|
||||
if( verbose ) printf("Theta, Phi = %f, %f \n", trackVec.Theta() *TMath::RadToDeg(), trackVec.Phi()*TMath::RadToDeg());
|
||||
|
||||
if (verbose)
|
||||
printf("Theta, Phi = %f, %f \n", trackVec.Theta() * TMath::RadToDeg(), trackVec.Phi() * TMath::RadToDeg());
|
||||
}
|
||||
|
||||
inline double PW::GetZ0(){
|
||||
inline double PW::GetZ0()
|
||||
{
|
||||
|
||||
double x = trackPos.X();
|
||||
double y = trackPos.Y();
|
||||
|
@ -278,7 +320,6 @@ inline double PW::GetZ0(){
|
|||
double theta = trackVec.Theta();
|
||||
|
||||
return trackPos.Z() - rho / TMath::Tan(theta);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user