Find the center of the 3 intersections, choose best if multiple.
364 std::vector< geo::WireIDIntersection > UVIntersects;
366 std::vector< double > UVzToZ(UVIntersects.size());
368 unsigned int cryo = Zwid.Cryostat;
369 unsigned int tpc = Zwid.TPC;
370 std::vector<geo::WireID> Uwids =
fGeom->ChannelToWire(u);
371 std::vector<geo::WireID> Vwids =
fGeom->ChannelToWire(v);
372 std::vector<geo::WireID> UwidsInTPC, VwidsInTPC;
373 for(
size_t i=0; i<Uwids.size(); i++)
if( Uwids[i].
TPC==tpc ) UwidsInTPC.push_back(Uwids[i]);
374 for(
size_t i=0; i<Vwids.size(); i++)
if( Vwids[i].
TPC==tpc ) VwidsInTPC.push_back(Vwids[i]);
375 double Zcent[3] = {0.};
376 fGeom->WireIDToWireGeo( Zwid ).GetCenter(Zcent);
378 std::cout <<
"Zcent = " << Zcent[2] <<
", UVintersects zpos = ";
379 for(
size_t uv=0; uv<UVIntersects.size(); uv++){
389 if( UVIntersects.size() == 0 ){
390 if( UwidsInTPC.size() > 1 || VwidsInTPC.size() > 1 )
391 throw cet::exception(
"ThreeChanPos") <<
"U/V channels don't intersect, bad return.\n";
394 mf::LogWarning(
"ThreeChanPos") <<
"No U/V intersect, exceptional channels. See if U or V intersects Z\n";
395 std::vector<double> yzCenter(2,0.);
399 bool checkUZ =
fGeom->WireIDsIntersect( Uwid, Zwid, UZInt );
400 bool checkVZ =
fGeom->WireIDsIntersect( Vwid, Zwid, VZInt );
401 if( !checkUZ && !checkVZ )
402 throw cet::exception(
"NoChanIntersect") <<
"No channels intersect, bad return.\n";
403 if( checkUZ && !checkVZ ){ yzCenter[0] = UZInt.
y; yzCenter[1] = UZInt.
z; }
404 if( checkVZ && !checkUZ ){ yzCenter[0] = VZInt.
y; yzCenter[1] = VZInt.
z; }
405 if( checkUZ && checkVZ ){ yzCenter[0] = (VZInt.
y+UZInt.
y)/2; yzCenter[1] = (VZInt.
z+UZInt.
z)/2; }
416 for(
size_t widI = 0; widI < UVIntersects.size(); widI++ ){
417 UVzToZ[widI] =
std::abs( UVIntersects[widI].
z - Zcent[2] );
422 unsigned int bestWidI = 0;
423 double minZdiff =
fGeom->Cryostat(cryo).TPC(tpc).Length();
424 for(
unsigned int widI = 0; widI < UVIntersects.size(); widI++ ){
428 if( UVIntersects[widI].
TPC == tpc && UVzToZ[widI] < minZdiff ){
429 minZdiff = UVzToZ[widI];
437 double UVInt[3] = {0.};
438 UVInt[1] = ChosenUVInt.
y; UVInt[2] = ChosenUVInt.
z;
442 bool checkUZ =
fGeom->WireIDsIntersect( Uwid, Zwid, UZInt );
443 bool checkVZ =
fGeom->WireIDsIntersect( Vwid, Zwid, VZInt );
445 std::cout <<
"UZint.z = " << UZInt.
z <<
" (" << checkUZ <<
"), VZint.z = " << VZInt.
z <<
" (" << checkVZ <<
")\n";
448 std::vector<double> yzCenter(2,0.);
451 if( !checkUZ || !checkVZ ){
454 std::cout <<
"ChosenUVint.y = " << ChosenUVInt.
y <<
"ChosenUVint.z = " << ChosenUVInt.
z << std::endl;
457 yzCenter[0] = ChosenUVInt.
y;
458 yzCenter[1] = ChosenUVInt.
z;
463 yzCenter[0] = (ChosenUVInt.
y + UZInt.
y + VZInt.
y)/3;
464 yzCenter[1] = (ChosenUVInt.
z + UZInt.
z + VZInt.
z)/3;
process_name opflash particleana ie ie ie z
double z
z position of intersection
bool APAChannelsIntersect(uint32_t chan1, uint32_t chan2, std::vector< geo::WireIDIntersection > &IntersectVector) const
If the channels intersect, get all intersections.
art::ServiceHandle< geo::Geometry const > fGeom
geo::WireID NearestWireIDOnChan(const double WorldLoc[3], uint32_t chan, unsigned int const plane, unsigned int const tpc=0, unsigned int const cstat=0) const
double y
y position of intersection
BEGIN_PROLOG could also be cout