Core function: given a set of CPANs, return a float which indicates the compatibility the cluster combination.
50 if ( clusters.size() == 1 )
53 if (
_verbose) { std::cout <<
"Number of clusters taken into account: " << clusters.size() <<
std::endl; }
59 std::vector<std::vector<util::PxHit> >
Hits(3, std::vector<util::PxHit>());
61 for (
size_t c=0;
c < clusters.size();
c++)
62 Hits.
at( clusters.at(
c)->Plane() ) = clusters.at(
c)->GetHitVector();
69 std::vector<int> StartWires;
70 std::vector<int> EndWires;
71 std::vector<float> StartTimes;
72 std::vector<float> EndTimes;
74 for (
int pl=0; pl < 3; pl++){
75 StartWires.push_back(9999);
76 EndWires.push_back(0);
77 StartTimes.push_back(9999);
78 EndTimes.push_back(0);
84 std::cout <<
"Need to insert fake hit ranges...";
89 if (
hit.t < StartTimes.at(
h) ) { StartTimes.at(
h) =
hit.t; }
90 if (
hit.t > EndTimes.at(
h) ) { EndTimes.at(
h) =
hit.t; }
102 if ( StartWires.at(
h) == 9999 ) { StartWires.at(
h) = 1; }
103 if ( EndWires.at(
h) == 0 ) { EndWires.at(
h) = geo->
Nwires(
h)-1; }
104 if ( StartTimes.at(
h) == 9999 ) { StartTimes.at(
h) = 0; }
105 if ( EndTimes.at(
h) == 0 ) { EndTimes.at(
h) = 9999; }
110 if ( (StartTimes.at(1) > EndTimes.at(0)) or (StartTimes.at(1) > EndTimes.at(2)) or
111 (StartTimes.at(2) > EndTimes.at(0)) or (StartTimes.at(2) > EndTimes.at(1)) or
112 (StartTimes.at(0) > EndTimes.at(1)) or (StartTimes.at(0) > EndTimes.at(2)) ){
117 float Tmin=9999, Tmax=0;
118 ( StartTimes.at(1) > StartTimes.at(0) ) ? (Tmin = StartTimes.at(1)) : (Tmin = StartTimes.at(0));
119 if (StartTimes.at(2) > Tmin) { Tmin = StartTimes.at(2); }
120 ( EndTimes.at(1) < EndTimes.at(0) ) ? (Tmax = EndTimes.at(1)) : (Tmax = EndTimes.at(0));
121 if (EndTimes.at(2) < Tmax) { Tmax = EndTimes.at(2); }
122 float Trange = Tmax-Tmin;
125 Double_t xyzStart0WireStart[3] = {0., 0., 0.};
126 Double_t xyzStart0WireEnd[3] = {0., 0., 0.};
127 Double_t xyzEnd0WireStart[3] = {0., 0., 0.};
128 Double_t xyzEnd0WireEnd[3] = {0., 0., 0.};
129 Double_t xyzStart1WireStart[3] = {0., 0., 0.};
130 Double_t xyzStart1WireEnd[3] = {0., 0., 0.};
131 Double_t xyzEnd1WireStart[3] = {0., 0., 0.};
132 Double_t xyzEnd1WireEnd[3] = {0., 0., 0.};
133 Double_t xyzStart2WireStart[3] = {0., 0., 0.};
134 Double_t xyzStart2WireEnd[3] = {0., 0., 0.};
135 Double_t xyzEnd2WireStart[3] = {0., 0., 0.};
136 Double_t xyzEnd2WireEnd[3] = {0., 0., 0.};
139 std::cout <<
"Wire Ranges:" <<
std::endl;
140 std::cout <<
"U-Plane: [ " << StartWires.at(0) <<
", " << EndWires.at(0) <<
"]" <<
std::endl;
141 std::cout <<
"V-Plane: [ " << StartWires.at(1) <<
", " << EndWires.at(1) <<
"]" <<
std::endl;
142 std::cout <<
"Y-Plane: [ " << StartWires.at(2) <<
", " << EndWires.at(2) <<
"]" <<
std::endl;
154 geo->
WireEndPoints(0, 0, 0, StartWires.at(0), xyzStart0WireStart, xyzStart0WireEnd);
155 geo->
WireEndPoints(0, 0, 0, EndWires.at(0), xyzEnd0WireStart, xyzEnd0WireEnd);
156 geo->
WireEndPoints(0, 0, 1, StartWires.at(1), xyzStart1WireStart, xyzStart1WireEnd);
157 geo->
WireEndPoints(0, 0, 1, EndWires.at(1), xyzEnd1WireStart, xyzEnd1WireEnd);
158 geo->
WireEndPoints(0, 0, 2, StartWires.at(2), xyzStart2WireStart, xyzStart2WireEnd);
159 geo->
WireEndPoints(0, 0, 2, EndWires.at(2), xyzEnd2WireStart, xyzEnd2WireEnd);
163 double zMin = xyzStart2WireStart[2];
165 double zMax = xyzEnd2WireStart[2];
173 double slopeU = tan(30*3.14/180.);
174 double slopeV = tan(-30*3.14/180.);
177 double bUup = xyzStart0WireStart[1] - xyzStart0WireStart[2] * slopeU;
178 double bUdn = xyzEnd0WireStart[1] - xyzEnd0WireStart[2] * slopeU;
179 double bVdn = xyzStart1WireStart[1] - xyzStart1WireStart[2] * slopeV;
180 double bVup = xyzEnd1WireStart[1] - xyzEnd1WireStart[2] * slopeV;
182 if ( bUup < bUdn ) { std::cout <<
"Uup and Udn are mixed up!" <<
std::endl; }
183 if ( bVdn > bVup ) { std::cout <<
"Vup and Vdn are mixed up!" <<
std::endl; }
190 double VdnZmin = slopeV * zMin + bVdn;
191 double VdnZmax = slopeV * zMax + bVdn;
192 double VupZmin = slopeV * zMin + bVup;
193 double VupZmax = slopeV * zMax + bVup;
194 double UdnZmin = slopeU * zMin + bUdn;
195 double UdnZmax = slopeU * zMax + bUdn;
196 double UupZmin = slopeU * zMin + bUup;
197 double UupZmax = slopeU * zMax + bUup;
200 std::cout <<
"Y-Plane and U-Plane points [Z,Y]:" <<
std::endl;
201 std::cout <<
"\t\t[ " << zMin <<
", " << UdnZmin <<
"]" <<
std::endl;
202 std::cout <<
"\t\t[ " << zMin <<
", " << UupZmin <<
"]" <<
std::endl;
203 std::cout <<
"\t\t[ " << zMax <<
", " << UupZmax <<
"]" <<
std::endl;
204 std::cout <<
"\t\t[ " << zMax <<
", " << UdnZmax <<
"]" <<
std::endl;
205 std::cout <<
"Y-Plane and V-Plane points [Z,Y]:" <<
std::endl;
206 std::cout <<
"\t\t[ " << zMin <<
", " << VdnZmin <<
"]" <<
std::endl;
207 std::cout <<
"\t\t[ " << zMin <<
", " << VupZmin <<
"]" <<
std::endl;
208 std::cout <<
"\t\t[ " << zMax <<
", " << VupZmax <<
"]" <<
std::endl;
209 std::cout <<
"\t\t[ " << zMax <<
", " << VdnZmax <<
"]" <<
std::endl;
220 std::vector< std::pair<float,float> > WireIntersection;
224 zInt = (bUup-bVup)/(slopeV-slopeU);
225 if ( (zInt > zMin) and (zInt < zMax) )
226 WireIntersection.push_back( std::make_pair( zInt, slopeV*zInt+bVup ) );
228 if ( (VupZmax < UupZmax) and (VupZmax > UdnZmax) )
229 WireIntersection.push_back( std::make_pair( zMax, VupZmax ) );
231 if ( (VupZmin < UupZmin) and ( VupZmin > UdnZmin) )
232 WireIntersection.push_back( std::make_pair( zMin, VupZmin ) );
234 zInt = (bUdn-bVup)/(slopeV-slopeU);
235 if ( (zInt > zMin) and (zInt < zMax) )
236 WireIntersection.push_back( std::make_pair( zInt, slopeV*zInt+bVup ) );
240 zInt = (bUup-bVdn)/(slopeV-slopeU);
241 if ( (zInt > zMin) and (zInt < zMax) )
242 WireIntersection.push_back( std::make_pair( zInt, slopeV*zInt+bVdn ) );
244 if ( (VdnZmax < UupZmax) and (VdnZmax > UdnZmax) )
245 WireIntersection.push_back( std::make_pair( zMax, VdnZmax ) );
247 if ( (VdnZmin < UupZmin) and ( VdnZmin > UdnZmin) )
248 WireIntersection.push_back( std::make_pair( zMin, VdnZmin ) );
250 zInt = (bUdn-bVdn)/(slopeV-slopeU);
251 if ( (zInt > zMin) and (zInt < zMax) )
252 WireIntersection.push_back( std::make_pair( zInt, slopeV*zInt+bVdn ) );
256 if ( (UupZmax < VupZmax) and ( UupZmax > VdnZmax) )
257 WireIntersection.push_back( std::make_pair( zMax, UupZmax ) );
259 if ( (UdnZmax < VupZmax) and ( UdnZmax > VdnZmax) )
260 WireIntersection.push_back( std::make_pair( zMax, UdnZmax ) );
264 if ( (UupZmin < VupZmin) and ( UupZmin > VdnZmin) )
265 WireIntersection.push_back( std::make_pair( zMin, UupZmin ) );
267 if ( (UdnZmin < VupZmin) and ( UdnZmin > VdnZmin) )
268 WireIntersection.push_back( std::make_pair( zMin, UdnZmin ) );
271 if ( WireIntersection.size() == 0 ){
281 double PolyArea = -1;
283 WirePolygon.UntanglePolygon();
286 std::vector< std::pair<float,float> > TPCCorners;
287 TPCCorners.push_back( std::make_pair(0., -geo->
DetHalfHeight()) );
290 TPCCorners.push_back( std::make_pair(0., geo->
DetHalfHeight()) );
292 if (TPCPolygon.Contained(WirePolygon) ){
294 std::cout <<
"Wire Overlap contained in TPC" <<
std::endl;
295 std::cout <<
"Intersection Polygon Coordinates [Z,Y]: " <<
std::endl;
296 for (
unsigned int s=0;
s < WirePolygon.Size();
s++)
297 std::cout <<
"\t\t[ " << WirePolygon.Point(
s).first <<
", " << WirePolygon.Point(
s).second <<
"]" <<
std::endl;
300 PolyArea = WirePolygon.Area();
304 std::cout <<
"Wire overlap not fully contained in TPC" <<
std::endl;
305 std::cout <<
"Intersection Polygon Coordinates [Z,Y]: " <<
std::endl;
306 for (
unsigned int s=0;
s < WirePolygon.Size();
s++)
307 std::cout <<
"\t\t[ " << WirePolygon.Point(
s).first <<
", " << WirePolygon.Point(
s).second <<
"]" <<
std::endl;
311 Polygon2D IntersectionPolygon(TPCPolygon, WirePolygon);
312 PolyArea = IntersectionPolygon.Area();
316 if (
_verbose) { std::cout <<
"Intersection area: " << PolyArea << std::endl <<
std::endl; }
317 return Trange*PolyArea;
unsigned int Nwires(unsigned int p, unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wires in the specified plane.
geo::Length_t DetHalfHeight(geo::TPCID const &tpcid) const
Returns the half height of the active volume of the specified TPC.
geo::Length_t DetLength(geo::TPCID const &tpcid) const
Returns the length of the active volume of the specified TPC.
reference at(size_type n)
Detector simulation of raw signals on wires.
art::PtrVector< recob::Hit > Hits
void WireEndPoints(geo::WireID const &wireid, double *xyzStart, double *xyzEnd) const
Fills two arrays with the coordinates of the wire end points.
Namespace collecting geometry-related classes utilities.
QTextStream & endl(QTextStream &s)
h
training ###############################