Skip to content

Commit b582805

Browse files
committed
Add a function to calculate the intersection point of two wires.
1 parent d8574a4 commit b582805

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

sbndcode/Utilities/SBNDGeoHelper_module.cc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ util::SBNDGeoHelper::SBNDGeoHelper(fhicl::ParameterSet const& p)
6363
while (input!=0){
6464
cout<<"0: quit"<<endl;
6565
cout<<"1: convert tpc/plane/wire to offline channel number"<<endl;
66+
cout<<"2: find intersection of two wires"<<endl;
6667
cout<<"Type a number: ";
6768
cin >> input;
6869
if (input == 1){
@@ -90,6 +91,35 @@ util::SBNDGeoHelper::SBNDGeoHelper(fhicl::ParameterSet const& p)
9091
cout<<"FEM (1-16) = "<<chaninfo.FEM<<endl;
9192
cout<<"FEMCh (0-63) = "<<chaninfo.FEMCh<<endl;
9293
}
94+
else if (input == 2){
95+
cout<<"Find wire intersection of two wires"<<endl;
96+
int tpc1, plane1, wire1, tpc2, plane2, wire2;
97+
cout<<"TPC1 number: ";
98+
cin>>tpc1;
99+
cout<<"Plane1 number: ";
100+
cin>>plane1;
101+
cout<<"Wire1 number: ";
102+
cin>>wire1;
103+
cout<<"TPC2 number: ";
104+
cin>>tpc2;
105+
cout<<"Plane2 number: ";
106+
cin>>plane2;
107+
cout<<"Wire2 number: ";
108+
cin>>wire2;
109+
geo::WireID wid1(0,tpc1,plane1,wire1);
110+
geo::WireID wid2(0,tpc2,plane2,wire2);
111+
double y,z;
112+
bool intersect = geo->IntersectionPoint(wid1,wid2,y,z);
113+
cout<<"WireID 1:"<<wid1.toString()<<endl;
114+
cout<<"WireID 2:"<<wid2.toString()<<endl;
115+
cout<<"The intersection point is ("<<y<<","<<z<<")."<<endl;
116+
if (intersect){
117+
cout<<"It is inside the detector."<<endl;
118+
}
119+
else{
120+
cout<<"It is outside the detector."<<endl;
121+
}
122+
}
93123
}
94124

95125
}

0 commit comments

Comments
 (0)