14 #include "messagefacility/MessageLogger/MessageLogger.h" 
   59     for (channel=0; channel < 
fGeom->Nchannels(); ++channel)
 
   61         if ( 
fGeom->ChannelToWire(channel)[0].TPC > 1 )
 
   86       if( wid.
TPC == lastwid.
TPC + 1  ){
 
   92       if (c >=  
fGeom->Nchannels()) 
break;
 
   93       wid = (
fGeom->ChannelToWire(c))[0]; 
 
  101                                            << 
"Channel boundaries are inconsistent.\n";
 
  114                                      unsigned int & cryo)
 const {
 
  147       else throw cet::exception(
"ChannelsInView")
 
  148              << 
"Both Z sides should have the same amount of channels\n";
 
  176                                                unsigned int cryo )
 const {
 
  197     unsigned int apa, cryo;
 
  205                                                uint32_t chan )
 const {
 
  207     unsigned int apa, cryo;
 
  244     std::vector<geo::WireID> wids = 
fGeom->ChannelToWire(chan);
 
  257     std::vector<geo::WireID> thisSide;
 
  259     for(
size_t i = 0; i < wids.size(); i++)
 
  260       if( wids[i].
TPC % 2 == side ) thisSide.push_back(wids[i]);
 
  271                                                     unsigned int const plane,
 
  272                                                     unsigned int const tpc,
 
  273                                                     unsigned int const cstat   )
 const 
  276     std::vector<geo::WireID> cWids = 
fGeom->ChannelToWire( chan );
 
  278     if( cWids[0].Cryostat != cstat )
 
  279       throw cet::exception(
"APAGeometryAlg") << 
"Channel " << chan
 
  280                                              << 
"not in cryostat " << cstat << 
"\n";
 
  281     if( std::floor( cWids[0].
TPC / 2 ) != std::floor( tpc / 2 ) )
 
  282       throw cet::exception(
"APAGeometryAlg") << 
"Channel " << chan
 
  283                                              << 
"not in APA " << std::floor(tpc/2) << 
"\n";
 
  288     unsigned int xyzWire = 
fGeom->NearestWireID( WorldLoc, plane, tpc, cstat ).Wire;
 
  293     for(
size_t i=0; i<cWids.size(); i++){
 
  294       if( cWids[i].
TPC != tpc ) 
continue;
 
  305                                              std::vector<geo::WireID> & widsCrossed,
 
  306                                              bool ExtendLine = 
true )
 const 
  314     unsigned int tpc, cryo;
 
  316     xyzMid[0] = (xyzStart[0]+xyzEnd[0])/2;
 
  317     xyzMid[1] = (xyzStart[1]+xyzEnd[1])/2;
 
  318     xyzMid[2] = (xyzStart[2]+xyzEnd[2])/2;
 
  319     fGeom->PositionToTPC(xyzMid, tpc, cryo);
 
  322     std::vector<geo::WireID> wids = 
fGeom->ChannelToWire(chan);
 
  323     unsigned int startW = 
fGeom->NearestWire( xyzStart, wids[0].
Plane, tpc, cryo );
 
  324     unsigned int endW   = 
fGeom->NearestWire( xyzEnd,   wids[0].Plane, tpc, cryo );
 
  326     if( startW > endW ) std::swap(startW, endW);
 
  330     for( 
size_t w = 0; 
w < wids.size(); 
w++ ){
 
  331       if( wids[
w].
TPC != tpc ) 
continue;
 
  332       if( wids[
w].Cryostat != cryo ) 
throw cet::exception(
"LineSegChanIntersect")
 
  333                                        << 
"Channel and line not in the same crostat.\n";
 
  341       unsigned int ext = 0;
 
  342       if ( ExtendLine) ext = 10;
 
  344       if( 
fGeom->ValueInRange( wids[
w].Wire*1., (startW-ext)*1., (endW+ext)*1. ) ) widsCrossed.push_back(wids[
w]);
 
  348     if( widsCrossed.size() > 0 ) 
return true;
 
  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;
 
  478                                              std::vector< geo::WireIDIntersection >& IntersectVector )
 const 
  484     std::vector< geo::WireID > wids1 = 
fGeom->ChannelToWire( chan1 );
 
  485     std::vector< geo::WireID > wids2 = 
fGeom->ChannelToWire( chan2 );
 
  488     if( view1 == view2 ){
 
  489       mf::LogWarning(
"APAChannelsIntersect") << 
"Comparing two channels in the same view, return false";
 
  491     if( wids1[0].Cryostat         != wids2[0].Cryostat         ||
 
  493       throw cet::exception(
"APAChannelsIntersect") << 
"Comparing two channels in in different APAs: " 
  494                                                    << 
"channel " << chan1 << 
" in Cryo " 
  495                                                    << wids1[0].Cryostat << 
", APA " << this->
ChannelToAPA(chan1)
 
  496                                                    << 
", and channel " << chan2 << 
" in Cryo " 
  497                                                    << wids2[0].Cryostat << 
", APA " << this->
ChannelToAPA(chan2)
 
  504     for( 
unsigned int i1 = 0; i1 < wids1.size() ; i1++){
 
  505       for( 
unsigned int i2 = 0; i2 < wids2.size() ; i2++){
 
  509             wids1[i1].
TPC      != wids2[i2].
TPC   ||      
 
  510             wids1[i1].Cryostat != wids2[i2].Cryostat ) 
continue;
 
  520         if( 
fGeom->WireIDsIntersect( wids1[i1], wids2[i2], widIntersect ) ){
 
  524           IntersectVector.push_back( widIntersect );
 
  531     if( IntersectVector.size() > 4 ){
 
  532       mf::LogWarning(
"APAChannelsIntersect") << 
"Got " << IntersectVector.size()
 
  533                                              << 
" intersections for channels " 
  534                                              << chan1 << 
" and " << chan2
 
  535                                              << 
" - never expect more than 4, so far";  }
 
  542     std::sort( IntersectVector.begin(), IntersectVector.end() );
 
  545     if( IntersectVector.size() == 0 ) 
return false;
 
process_name opflash particleana ie ie ie z
double z
z position of intersection 
BEGIN_PROLOG true icarus_rawdigitfilter FilterTools FilterPlane1 Plane
Encapsulate the construction of a single cyostat. 
enum geo::_plane_proj View_t
Enumerate the possible plane projections. 
bool LineSegChanIntersect(TVector3 xyzStart, TVector3 xyzEnd, uint32_t chan, std::vector< geo::WireID > &widsCrossed, bool ExtendLine) const 
If a line given by start/end points intersects a channel. 
void Init()
Initialize some chanel numbers to speed up other methods. 
unsigned int ChannelsInAPAView(APAView_t apaview) const 
uint32_t FirstChannelInView(geo::View_t geoview, unsigned int apa, unsigned int cryo) const 
Planes which measure Z direction. 
U view on both sides of the APA. 
unsigned int fAPAsPerCryo
V view on both sides of the APA. 
bool APAChannelsIntersect(uint32_t chan1, uint32_t chan2, std::vector< geo::WireIDIntersection > &IntersectVector) const 
If the channels intersect, get all intersections. 
Z view on the larger-x side of the APA. 
enum apa::_apa_plane_proj APAView_t
APAView_t APAView(uint32_t chan) const 
Get which of the 4 APA views the channel is in. 
unsigned int ChannelToAPA(uint32_t chan) const 
Get number of the APA containing the given channel. 
unsigned int ChannelsInView(geo::View_t geoview) const 
unsigned int fChannelsPerAPA
All APAs have this same number of channels. 
Definition of data types for geometry description. 
Z view on the smaller-x side of the APA. 
Encapsulate the geometry of a wire. 
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 
std::vector< geo::WireID > ChanSegsPerSide(uint32_t chan, unsigned int side) const 
void reconfigure(fhicl::ParameterSet const &p)
TPCID_t TPC
Index of the TPC within its cryostat. 
std::vector< double > ThreeChanPos(uint32_t u, uint32_t v, uint32_t z) const 
Find the center of the 3 intersections, choose best if multiple. 
BEGIN_PROLOG could also be cout
Encapsulate the construction of a single detector plane.