Classes | Public Types | Public Member Functions | Private Attributes | List of all members
WireSelector Class Reference

#include <WireSelector.h>

Classes

struct  WireInfo
 
class  WireSummary
 

Public Types

using Index = unsigned int
 
using IndexVector = std::vector< Index >
 
using GeometryCore = geo::GeometryCore
 
using View = geo::View_t
 
using PlaneID = geo::PlaneID
 
using PlaneIDVector = std::vector< PlaneID >
 
using WireInfoVector = std::vector< WireInfo >
 
using WireInfoMap = std::multimap< Index, const WireInfo * >
 

Public Member Functions

 WireSelector (Index icry=0)
 
const GeometryCoregeometry () const
 
const IndexVectorcryostats () const
 
View view () const
 
double wireAngle () const
 
double wireAngleTolerance () const
 
double driftMin () const
 
double driftMax () const
 
const PlaneIDVectorplaneIDs () const
 
bool haveData () const
 
const WireInfoVectordata () const
 
const WireInfoMapdataMap () const
 
const WireSummarywireSummary () const
 
const GeometryCoregeometry ()
 
void selectCryostats (const IndexVector &a_icrys)
 
void selectView (View view)
 
void selectWireAngle (double wireAngle, double tol=0.001)
 
void selectDrift (double dmin, double dmax=1.e20)
 
void selectTpcSet (Index itps)
 
void selectTpcSets (const IndexVector &itpss)
 
void selectPlanes ()
 
const WireInfoVectorfillData ()
 
const WireInfoMapfillDataMap ()
 
const WireSummaryfillWireSummary ()
 
void clearData ()
 

Private Attributes

const GeometryCorem_pgeo =nullptr
 
IndexVector m_icrys
 
View m_view =geo::kUnknown
 
double m_wireAngle =999.
 
double m_wireAngleTolerance =999.
 
double m_driftMin = 0.0
 
double m_driftMax = 1.e20
 
PlaneIDVector m_pids
 
IndexVector m_tpcSets
 
bool m_haveData =false
 
WireInfoVector m_data
 
WireInfoMap m_datamap
 
WireSummary m_wireSummary
 

Detailed Description

Definition at line 29 of file WireSelector.h.

Member Typedef Documentation

Definition at line 35 of file WireSelector.h.

using WireSelector::Index = unsigned int

Definition at line 33 of file WireSelector.h.

Definition at line 34 of file WireSelector.h.

Definition at line 37 of file WireSelector.h.

Definition at line 38 of file WireSelector.h.

Definition at line 36 of file WireSelector.h.

using WireSelector::WireInfoMap = std::multimap<Index, const WireInfo*>

Definition at line 98 of file WireSelector.h.

Definition at line 97 of file WireSelector.h.

Constructor & Destructor Documentation

WireSelector::WireSelector ( Index  icry = 0)
explicit

Definition at line 15 of file WireSelector.cxx.

15  {
16  selectCryostats({icry});
17 }
void selectCryostats(const IndexVector &a_icrys)

Member Function Documentation

void WireSelector::clearData ( )

Definition at line 193 of file WireSelector.cxx.

193  {
194  m_data.clear();
195  m_datamap.clear();
197  m_haveData = false;
198 }
WireInfoMap m_datamap
Definition: WireSelector.h:187
WireInfoVector m_data
Definition: WireSelector.h:186
WireSummary m_wireSummary
Definition: WireSelector.h:188
const IndexVector& WireSelector::cryostats ( ) const
inline

Definition at line 109 of file WireSelector.h.

109 { return m_icrys; }
IndexVector m_icrys
Definition: WireSelector.h:177
const WireInfoVector& WireSelector::data ( ) const
inline

Definition at line 127 of file WireSelector.h.

127 { return m_data; }
WireInfoVector m_data
Definition: WireSelector.h:186
const WireInfoMap& WireSelector::dataMap ( ) const
inline

Definition at line 128 of file WireSelector.h.

128 { return m_datamap; }
WireInfoMap m_datamap
Definition: WireSelector.h:187
double WireSelector::driftMax ( ) const
inline

Definition at line 120 of file WireSelector.h.

120 { return m_driftMax; }
double m_driftMax
Definition: WireSelector.h:182
double WireSelector::driftMin ( ) const
inline

Definition at line 119 of file WireSelector.h.

119 { return m_driftMin; }
double m_driftMin
Definition: WireSelector.h:181
const WireSelector::WireInfoVector & WireSelector::fillData ( )

Definition at line 117 of file WireSelector.cxx.

117  {
118  const string myname = "WireSelector::fillData: ";
119  const double piOver2 = 0.5*acos(-1.0);
120  if ( haveData() ) return m_data;
121  for ( geo::PlaneID pid : planeIDs() ) {
122  const geo::PlaneGeo& gpla = geometry()->Plane(pid);
123  const geo::TPCGeo& gtpc = geometry()->TPC(pid);
124  const geo::PlaneGeo& gplaLast = gtpc.LastPlane(); // Plane furthest from TPC center.
125  double xLastPlane = gplaLast.MiddleWire().GetCenter<TVector3>().x();
126  double xThisPlane = gpla.MiddleWire().GetCenter<TVector3>().x();
127  double driftOffset = fabs(xThisPlane - xLastPlane);
128  for ( Index iwir=0; iwir<gpla.Nwires(); ++iwir ) {
129  geo::WireID wid(pid, iwir);
130  const geo::WireGeo* pgwir = gpla.WirePtr(wid);
131  double wireAngle = gpla.ThetaZ() - piOver2;
132  TVector3 xyzWire = pgwir->GetCenter<TVector3>();
133  xyzWire.RotateX(wireAngle);
134  double driftSign = gpla.GetNormalDirection().x();
135  if ( fabs(fabs(driftSign) - 1.0) > 0.001 ) {
136  cout << myname << "ERROR: Plane normal is not along x." << endl;
137  continue;
138  }
139  double driftDist = gtpc.DriftDistance() - driftOffset;
140  m_data.emplace_back(xyzWire.x(), xyzWire.y(), xyzWire.z(),
141  driftSign*driftDist,
142  pgwir->Length(),
143  gpla.WirePitch(),
144  geometry()->PlaneWireToChannel(wid));
145  }
146  }
147  m_haveData = true;
148  return m_data;
149 }
geo::WirePtr WirePtr(unsigned int iwire) const
Returns the wire number iwire from this plane.
Definition: PlaneGeo.h:324
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Definition: WireGeo.h:65
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
double wireAngle() const
Definition: WireSelector.h:115
double Length() const
Returns the wire length in centimeters.
Definition: WireGeo.h:236
const PlaneIDVector & planeIDs() const
Definition: WireSelector.h:123
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
Geometry information for a single TPC.
Definition: TPCGeo.h:38
unsigned int Index
Vector GetNormalDirection() const
Returns the direction normal to the plane.
Definition: PlaneGeo.h:442
const GeometryCore * geometry() const
Definition: WireSelector.h:106
double ThetaZ() const
Angle of the wires from positive z axis; .
Definition: PlaneGeo.cxx:726
const WireGeo & MiddleWire() const
Return the middle wire in the plane.
Definition: PlaneGeo.h:347
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
double DriftDistance() const
Definition: TPCGeo.h:155
geo::PlaneGeo const & LastPlane() const
Returns the last wire plane (the farther from TPC center).
Definition: TPCGeo.h:248
unsigned int Nwires() const
Number of wires in this plane.
Definition: PlaneGeo.h:269
list x
Definition: train.py:276
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
Definition: WireGeo.cxx:73
bool haveData() const
Definition: WireSelector.h:126
double WirePitch() const
Return the wire pitch (in centimeters). It is assumed constant.
Definition: PlaneGeo.h:411
QTextStream & endl(QTextStream &s)
WireInfoVector m_data
Definition: WireSelector.h:186
const WireSelector::WireInfoMap & WireSelector::fillDataMap ( )

Definition at line 153 of file WireSelector.cxx.

153  {
154  if ( haveData() && m_datamap.size() == m_data.size() ) return m_datamap;
155  for ( const WireInfo& dat : fillData() ) {
156  m_datamap.emplace(dat.channel, &dat);
157  }
158  return m_datamap;
159 }
WireInfoMap m_datamap
Definition: WireSelector.h:187
const WireInfoVector & fillData()
bool haveData() const
Definition: WireSelector.h:126
WireInfoVector m_data
Definition: WireSelector.h:186
const WireSelector::WireSummary & WireSelector::fillWireSummary ( )

Definition at line 163 of file WireSelector.cxx.

163  {
164  if ( haveData() && m_wireSummary.size() == m_data.size() ) return m_wireSummary;
165  WireSummary& ws = m_wireSummary;
166  Index nwir = data().size();
167  ws.xmin = 1000.0;
168  ws.ymin = 1000.0;
169  ws.zmin = 1000.0;
170  ws.xmax = -1000.0;
171  ws.ymax = -1000.0;
172  ws.zmax = -1000.0;
173  ws.xWire.resize(nwir);
174  ws.xCathode.resize(nwir);
175  ws.zWire.resize(nwir);
176  for ( Index iwir=0; iwir<nwir; ++iwir ) {
177  const WireInfo& dat = data()[iwir];
178  if ( dat.x1() < ws.xmin ) ws.xmin = dat.x1();
179  if ( dat.y1() < ws.ymin ) ws.ymin = dat.y1();
180  if ( dat.z1() < ws.zmin ) ws.zmin = dat.z1();
181  if ( dat.x2() > ws.xmax ) ws.xmax = dat.x2();
182  if ( dat.y2() > ws.ymax ) ws.ymax = dat.y2();
183  if ( dat.z2() > ws.zmax ) ws.zmax = dat.z2();
184  ws.xWire[iwir] = dat.x;
185  ws.xCathode[iwir] = dat.x + dat.driftMax;
186  ws.zWire[iwir] = dat.z;
187  }
188  return ws;
189 }
const WireInfoVector & data() const
Definition: WireSelector.h:127
unsigned int Index
bool haveData() const
Definition: WireSelector.h:126
WireInfoVector m_data
Definition: WireSelector.h:186
WireSummary m_wireSummary
Definition: WireSelector.h:188
const GeometryCore* WireSelector::geometry ( ) const
inline

Definition at line 106 of file WireSelector.h.

106 { return m_pgeo; }
const GeometryCore * m_pgeo
Definition: WireSelector.h:176
const WireSelector::GeometryCore * WireSelector::geometry ( )

Definition at line 21 of file WireSelector.cxx.

21  {
22  if ( m_pgeo == nullptr ) {
24  m_pgeo = hgeo.get();
25  }
26  return m_pgeo;
27 }
T * get() const
Definition: ServiceHandle.h:63
const GeometryCore * m_pgeo
Definition: WireSelector.h:176
bool WireSelector::haveData ( ) const
inline

Definition at line 126 of file WireSelector.h.

126 { return m_haveData; };
const PlaneIDVector& WireSelector::planeIDs ( ) const
inline

Definition at line 123 of file WireSelector.h.

123 { return m_pids; }
PlaneIDVector m_pids
Definition: WireSelector.h:183
void WireSelector::selectCryostats ( const IndexVector a_icrys)

Definition at line 31 of file WireSelector.cxx.

31  {
32  m_icrys = a_icrys;
33  selectPlanes();
34 }
IndexVector m_icrys
Definition: WireSelector.h:177
void selectPlanes()
void WireSelector::selectDrift ( double  dmin,
double  dmax = 1.e20 
)

Definition at line 53 of file WireSelector.cxx.

53  {
54  m_driftMin = dmin;
55  m_driftMax = dmax;
56  selectPlanes();
57 }
void selectPlanes()
double m_driftMin
Definition: WireSelector.h:181
double m_driftMax
Definition: WireSelector.h:182
void WireSelector::selectPlanes ( )

Definition at line 75 of file WireSelector.cxx.

75  {
76  const double pi = acos(-1.0);
77  const double piOver2 = 0.5*pi;
78  m_pids.clear();
79  clearData();
80  for ( Index icry : cryostats() ) {
81  geo::CryostatID cid(icry);
82  for ( geo::TPCID tid : geometry()->IterateTPCIDs(cid) ) {
83  // Check TPC set.
84  if ( m_tpcSets.size() ) {
85  Index itps = geometry()->TPCtoTPCset(tid).TPCset;
86  if ( find(m_tpcSets.begin(), m_tpcSets.end(), itps) == m_tpcSets.end() ) continue;
87  }
88  // Check drift.
89  if ( driftMin() > 0.0 || driftMax() < 1.e20 ) {
90  const geo::TPCGeo& gtpc = geometry()->TPC(tid);
91  //double driftSize = gtpc.ActiveWidth();
92  double driftSize = gtpc.DriftDistance(); // good for the last anode plane
93  if ( driftSize < driftMin() ) continue;
94  if ( driftSize >= driftMax() ) continue;
95  }
96  for ( geo::PlaneID pid : geometry()->IteratePlaneIDs(tid) ) {
97  const geo::PlaneGeo& gpla = geometry()->Plane(pid);
98  // Check view.
99  if ( view() != geo::kUnknown && gpla.View() != view() ) continue;
100  // Check wire angle.
101  if ( wireAngleTolerance() < pi ) {
102  double planeWireAngle = gpla.ThetaZ() - piOver2;
103  double dang = planeWireAngle - wireAngle();
104  while ( dang < -piOver2 ) dang += pi;
105  while ( dang > piOver2 ) dang -= pi;
106  if ( fabs(dang) >= wireAngleTolerance() ) continue;
107  }
108  // Keep this plane.
109  m_pids.push_back(pid);
110  }
111  }
112  }
113 }
double wireAngleTolerance() const
Definition: WireSelector.h:116
double driftMax() const
Definition: WireSelector.h:120
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
double wireAngle() const
Definition: WireSelector.h:115
Unknown view.
Definition: geo_types.h:136
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
Geometry information for a single TPC.
Definition: TPCGeo.h:38
IndexVector m_tpcSets
Definition: WireSelector.h:184
unsigned int Index
const GeometryCore * geometry() const
Definition: WireSelector.h:106
readout::TPCsetID TPCtoTPCset(geo::TPCID const &tpcid) const
Returns the ID of the TPC set tpcid belongs to.
double ThetaZ() const
Angle of the wires from positive z axis; .
Definition: PlaneGeo.cxx:726
PlaneIDVector m_pids
Definition: WireSelector.h:183
View_t View() const
Which coordinate does this plane measure.
Definition: PlaneGeo.h:184
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
Definition: PlaneGeo.h:82
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
double driftMin() const
Definition: WireSelector.h:119
TPCsetID_t TPCset
Index of the TPC set within its cryostat.
Definition: readout_types.h:90
double DriftDistance() const
Definition: TPCGeo.h:155
View view() const
Definition: WireSelector.h:112
TPCGeo const & TPC(unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified TPC.
float pi
Definition: units.py:11
const IndexVector & cryostats() const
Definition: WireSelector.h:109
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190
void WireSelector::selectTpcSet ( Index  itps)

Definition at line 61 of file WireSelector.cxx.

61  {
62  m_tpcSets.clear();
63  m_tpcSets.push_back(itps);
64  selectPlanes();
65 }
IndexVector m_tpcSets
Definition: WireSelector.h:184
void selectPlanes()
void WireSelector::selectTpcSets ( const IndexVector itpss)

Definition at line 68 of file WireSelector.cxx.

68  {
69  m_tpcSets = itpss;
70  selectPlanes();
71 }
IndexVector m_tpcSets
Definition: WireSelector.h:184
void selectPlanes()
void WireSelector::selectView ( View  view)

Definition at line 38 of file WireSelector.cxx.

38  {
39  m_view = a_view;
40  selectPlanes();
41 }
void selectPlanes()
void WireSelector::selectWireAngle ( double  wireAngle,
double  tol = 0.001 
)

Definition at line 45 of file WireSelector.cxx.

45  {
46  m_wireAngle = angle;
48  selectPlanes();
49 }
auto const tol
Definition: SurfXYZTest.cc:16
void selectPlanes()
double m_wireAngleTolerance
Definition: WireSelector.h:180
double m_wireAngle
Definition: WireSelector.h:179
View WireSelector::view ( ) const
inline

Definition at line 112 of file WireSelector.h.

112 { return m_view; }
double WireSelector::wireAngle ( ) const
inline

Definition at line 115 of file WireSelector.h.

115 { return m_wireAngle; }
double m_wireAngle
Definition: WireSelector.h:179
double WireSelector::wireAngleTolerance ( ) const
inline

Definition at line 116 of file WireSelector.h.

116 { return m_wireAngleTolerance; }
double m_wireAngleTolerance
Definition: WireSelector.h:180
const WireSummary& WireSelector::wireSummary ( ) const
inline

Definition at line 129 of file WireSelector.h.

129 { return m_wireSummary; }
WireSummary m_wireSummary
Definition: WireSelector.h:188

Member Data Documentation

WireInfoVector WireSelector::m_data
private

Definition at line 186 of file WireSelector.h.

WireInfoMap WireSelector::m_datamap
private

Definition at line 187 of file WireSelector.h.

double WireSelector::m_driftMax = 1.e20
private

Definition at line 182 of file WireSelector.h.

double WireSelector::m_driftMin = 0.0
private

Definition at line 181 of file WireSelector.h.

bool WireSelector::m_haveData =false
private

Definition at line 185 of file WireSelector.h.

IndexVector WireSelector::m_icrys
private

Definition at line 177 of file WireSelector.h.

const GeometryCore* WireSelector::m_pgeo =nullptr
private

Definition at line 176 of file WireSelector.h.

PlaneIDVector WireSelector::m_pids
private

Definition at line 183 of file WireSelector.h.

IndexVector WireSelector::m_tpcSets
private

Definition at line 184 of file WireSelector.h.

View WireSelector::m_view =geo::kUnknown
private

Definition at line 178 of file WireSelector.h.

double WireSelector::m_wireAngle =999.
private

Definition at line 179 of file WireSelector.h.

double WireSelector::m_wireAngleTolerance =999.
private

Definition at line 180 of file WireSelector.h.

WireSummary WireSelector::m_wireSummary
private

Definition at line 188 of file WireSelector.h.


The documentation for this class was generated from the following files: