ChannelMapStandardAlg.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file ChannelMapStandardAlg.h
3 /// \brief Interface to algorithm class for a specific detector channel mapping
4 ///
5 /// \author brebel@fnal.gov
6 ////////////////////////////////////////////////////////////////////////
7 #ifndef LARCOREALG_GEOMETRY_CHANNELSTANDARDMAPALG_H
8 #define LARCOREALG_GEOMETRY_CHANNELSTANDARDMAPALG_H
9 
10 #include <vector>
11 #include <set>
12 
13 #include "larcoreobj/SimpleTypesAndConstants/readout_types.h" // readout::TPCsetID, ...
17 
18 namespace fhicl { class ParameterSet; }
19 
20 namespace geo{
21 
23 
24  public:
25 
27 
28  virtual void Initialize( GeometryData_t const& geodata ) override;
29  virtual void Uninitialize() override;
30  virtual std::vector<WireID> ChannelToWire(raw::ChannelID_t channel) const override;
31  virtual unsigned int Nchannels() const override;
32 
33  /// @brief Returns the number of channels in the specified ROP
34  /// @return number of channels in the specified ROP, 0 if non-existent
35  virtual unsigned int Nchannels(readout::ROPID const& ropid) const override;
36 
37  //@{
38  virtual double WireCoordinate
39  (double YPos, double ZPos, geo::PlaneID const& planeID) const override;
40  virtual double WireCoordinate(double YPos, double ZPos,
41  unsigned int PlaneNo,
42  unsigned int TPCNo,
43  unsigned int cstat) const override
44  { return WireCoordinate(YPos, ZPos, geo::PlaneID(cstat, TPCNo, PlaneNo)); }
45  //@}
46 
47  //@{
48  virtual WireID NearestWireID
49  (const TVector3& worldPos, geo::PlaneID const& planeID) const override;
50  virtual WireID NearestWireID(const TVector3& worldPos,
51  unsigned int PlaneNo,
52  unsigned int TPCNo,
53  unsigned int cstat) const override
54  { return NearestWireID(worldPos, geo::PlaneID(cstat, TPCNo, PlaneNo)); }
55  //@}
56 
57  //@{
58  virtual raw::ChannelID_t PlaneWireToChannel
59  (geo::WireID const& wireID) const override;
60  virtual raw::ChannelID_t PlaneWireToChannel(unsigned int plane,
61  unsigned int wire,
62  unsigned int tpc,
63  unsigned int cstat) const override
64  { return PlaneWireToChannel(geo::WireID(cstat, tpc, plane, wire)); }
65  //@}
66 
67  virtual std::set<PlaneID> const& PlaneIDs() const override;
68 
69 
70  //
71  // TPC set interface
72  //
73  /// @name TPC set mapping
74  /// @{
75  /**
76  * @brief Returns the total number of TPC sets in the specified cryostat
77  * @param cryoid cryostat ID
78  * @return number of TPC sets in the cryostat, or 0 if no cryostat found
79  *
80  * In this mapping, TPCs have independent readout and there is one TPC in
81  * each TPC set and one TPC set for each TPC.
82  */
83  virtual unsigned int NTPCsets
84  (readout::CryostatID const& cryoid) const override;
85 
86  /// Returns the largest number of TPC sets any cryostat in the detector has
87  virtual unsigned int MaxTPCsets() const override;
88 
89  /// Returns whether we have the specified TPC set
90  /// @return whether the TPC set is valid and exists
91  virtual bool HasTPCset(readout::TPCsetID const& tpcsetid) const override;
92 
93  /**
94  * @brief Returns the ID of the TPC set the specified TPC belongs to
95  * @param tpcid ID of the TPC
96  * @return the ID of the corresponding TPC set, or invalid ID when tpcid is
97  *
98  * In this mapping, TPC sets and TPCs are mapped one-to-one.
99  * The returned value mirrors the TPC ID in the readout space.
100  * If the TPC ID is not valid, an invalid TPC set ID is returned.
101  * Note that this check is performed on the validity of the TPC ID, that
102  * does not necessarily imply that the TPC specified by the ID actually
103  * exists.
104  */
105  virtual readout::TPCsetID TPCtoTPCset
106  (geo::TPCID const& tpcid) const override;
107 
108  /**
109  * @brief Returns a list of ID of TPCs belonging to the specified TPC set
110  * @param tpcsetid ID of the TPC set to convert into TPC IDs
111  * @return the list of TPCs, empty if TPC set is invalid
112  *
113  * In this mapping, TPC sets and TPCs are mapped one-to-one.
114  * The returned list contains always one entry, unless the specified TPC
115  * set ID is invalid, in which case the list is empty.
116  * Note that the check is performed on the validity of the TPC set ID, that
117  * does not necessarily imply that the TPC set specified by the ID actually
118  * exists. Check the existence of the TPC set first (HasTPCset()).
119  * Behaviour on valid, non-existent TPC set IDs is undefined.
120  */
121  virtual std::vector<geo::TPCID> TPCsetToTPCs
122  (readout::TPCsetID const& tpcsetid) const override;
123 
124  /// Returns the ID of the first TPC belonging to the specified TPC set
125  virtual geo::TPCID FirstTPCinTPCset
126  (readout::TPCsetID const& tpcsetid) const override;
127 
128  /// @} TPC set mapping
129 
130 
131 
132  //
133  // Readout plane interface
134  //
135  /// @name Readout plane mapping
136  /// @{
137 
138  /**
139  * @brief Returns the total number of ROPs in the specified TPC set
140  * @param tpcsetid TPC set ID
141  * @return number of readout planes in the TPC sets, or 0 if ID is invalid
142  *
143  * Note that this methods explicitly check the existence of the TPC set.
144  *
145  * In this mapping, planes have independent readout and there is one wire
146  * plane in each readout plane and one readout plane for each wire plane.
147  */
148  virtual unsigned int NROPs
149  (readout::TPCsetID const& tpcsetid) const override;
150 
151  /// Returns the largest number of ROPs a TPC set in the detector has
152  virtual unsigned int MaxROPs() const override;
153 
154  /// Returns whether we have the specified ROP
155  /// @return whether the readout plane is valid and exists
156  virtual bool HasROP(readout::ROPID const& ropid) const override;
157 
158  /**
159  * @brief Returns the ID of the ROP planeid belongs to, or invalid if none
160  * @param planeid ID of the plane
161  * @return the ID of the corresponding ROP, or invalid ID when planeid is
162  *
163  * In this mapping, readout planes and wire planes are mapped one-to-one.
164  * The returned value mirrors the plane ID in the readout space.
165  * If the plane ID is not valid, an invalid readout plane ID is returned.
166  * Note that this check is performed on the validity of the plane ID, that
167  * does not necessarily imply that the plane specified by the ID actually
168  * exists.
169  */
170  virtual readout::ROPID WirePlaneToROP
171  (geo::PlaneID const& planeid) const override;
172 
173  /**
174  * @brief Returns a list of ID of wire planes belonging to the specified ROP
175  * @param ropid ID of the readout plane to convert into wire planes
176  * @return the list of wire plane IDs, empty if readout plane ID is invalid
177  *
178  * In this mapping, readout planes and wire planes are mapped one-to-one.
179  * The returned list contains always one entry, unless the specified readout
180  * plane ID is invalid, in which case the list is empty.
181  * Note that this check is performed on the validity of the readout plane
182  * ID, that does not necessarily imply that the readout plane specified by
183  * the ID actually exists.
184  */
185  virtual std::vector<geo::PlaneID> ROPtoWirePlanes
186  (readout::ROPID const& ropid) const override;
187 
188  /**
189  * @brief Returns a list of ID of TPCs the specified ROP spans
190  * @param ropid ID of the readout plane
191  * @return the list of TPC IDs, empty if readout plane ID is invalid
192  *
193  * In this mapping, readout planes and wire planes are mapped one-to-one.
194  * The returned list contains always one entry, unless the specified readout
195  * plane ID is invalid, in which case the list is empty.
196  * Note that this check is performed on the validity of the readout plane
197  * ID, that does not necessarily imply that the readout plane specified by
198  * the ID actually exists. Check if the ROP exists with HasROP().
199  * The behaviour on non-existing readout planes is undefined.
200  */
201  virtual std::vector<geo::TPCID> ROPtoTPCs
202  (readout::ROPID const& ropid) const override;
203 
204  /// Returns the ID of the ROP the channel belongs to (invalid if none)
205  virtual readout::ROPID ChannelToROP
206  (raw::ChannelID_t channel) const override;
207 
208  /**
209  * @brief Returns the ID of the first channel in the specified readout plane
210  * @param ropid ID of the readout plane
211  * @return ID of first channel, or raw::InvalidChannelID if ID is invalid
212  *
213  * Note that this check is performed on the validity of the readout plane
214  * ID, that does not necessarily imply that the readout plane specified by
215  * the ID actually exists. Check if the ROP exists with HasROP().
216  * The behaviour for non-existing readout planes is undefined.
217  */
218  virtual raw::ChannelID_t FirstChannelInROP
219  (readout::ROPID const& ropid) const override;
220 
221  /// Returns the ID of the first plane belonging to the specified ROP
222  virtual geo::PlaneID FirstWirePlaneInROP
223  (readout::ROPID const& ropid) const override;
224 
225  /// @} readout plane mapping
226 
227  /// Return the sorter
228  virtual geo::GeoObjectSorter const& Sorter() const override
229  { return fSorter; }
230 
231  private:
232 
233  unsigned int fNcryostat; ///< number of cryostats in the detector
234  unsigned int fNchannels; ///< number of channels in the detector
235  raw::ChannelID_t fTopChannel; ///< book keeping highest channel #
236  std::vector<unsigned int> fNTPC; ///< number of TPCs in each cryostat
237  std::set<View_t> fViews; ///< vector of the views present in the detector
238  std::set<PlaneID> fPlaneIDs; ///< vector of the PlaneIDs present in the detector
239  PlaneInfoMap_t<float> fFirstWireProj; ///< Distance (0,0,0) to first wire
240  ///< along orth vector per plane per TPC
241  PlaneInfoMap_t<float> fOrthVectorsY; ///< Unit vectors orthogonal to wires in
242  PlaneInfoMap_t<float> fOrthVectorsZ; ///< each plane - stored as 2 components
243  ///< to avoid having to invoke any bulky
244  ///< TObjects / CLHEP vectors etc
245  PlaneInfoMap_t<float> fWireCounts; ///< Number of wires in each plane - for
246  ///< range checking after calculation
247  TPCInfoMap_t<unsigned int> fNPlanes; ///< Number of planes in each TPC - for
248  ///< range checking after calculation
249  PlaneInfoMap_t<unsigned int> fPlaneBaselines; ///< The number of wires in all the
250  ///< tpcs and planes up to this one
251  ///< in the heirachy
252  PlaneInfoMap_t<unsigned int> fWiresPerPlane; ///< The number of wires in this plane
253  ///< in the heirachy
254 
255  geo::GeoObjectSorterStandard fSorter; ///< class to sort geo objects
256 
257 
258  virtual SigType_t SignalTypeForChannelImpl( raw::ChannelID_t const channel ) const override;
259 
260  /// Retrieved the wire cound for the specified plane ID
261  unsigned int WireCount(geo::PlaneID const& id) const
262  { return AccessElement(fWireCounts, id); }
263 
264  /// Returns the largest number of TPCs in a single cryostat
265  unsigned int MaxTPCs() const;
266 
267  /// Converts a TPC ID into a TPC set ID using the same numerical indices
268  static readout::TPCsetID ConvertTPCtoTPCset(geo::TPCID const& tpcid);
269 
270  /// Converts a TPC set ID into a TPC ID using the same numerical indices
271  static geo::TPCID ConvertTPCsetToTPC(readout::TPCsetID const& tpcsetid);
272 
273  /// Converts a ROP ID into a wire plane ID using the same numerical indices
274  static readout::ROPID ConvertWirePlaneToROP(geo::PlaneID const& planeid);
275 
276  /// Converts a wire plane ID into a ROP ID using the same numerical indices
277  static geo::PlaneID ConvertROPtoWirePlane(readout::ROPID const& ropid);
278 
279  };
280 
281 
282 }
283 #endif // LARCOREALG_GEOMETRY_CHANNELSTANDARDMAPALG_H
Interface for a class providing readout channel mapping to geometry.
Definition: ChannelMapAlg.h:48
TPCInfoMap_t< unsigned int > fNPlanes
PlaneInfoMap_t< float > fWireCounts
Classes identifying readout-related concepts.
virtual geo::GeoObjectSorter const & Sorter() const override
Return the sorter.
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
Class identifying a set of TPC sharing readout channels.
Definition: readout_types.h:70
uint8_t channel
Definition: CRTFragment.hh:201
PlaneInfoMap_t< float > fOrthVectorsZ
std::set< View_t > fViews
vector of the views present in the detector
Interface to algorithm class for standard sorting of geo::XXXGeo objects.
std::vector< std::vector< T >> TPCInfoMap_t
Data type for per-TPC information.
TPCInfoMap_t< std::vector< T >> PlaneInfoMap_t
Data type for per-plane information.
unsigned int WireCount(geo::PlaneID const &id) const
Retrieved the wire cound for the specified plane ID.
enum geo::_plane_sigtype SigType_t
unsigned int fNcryostat
number of cryostats in the detector
PlaneInfoMap_t< unsigned int > fPlaneBaselines
p
Definition: test.py:223
void Initialize(void)
PlaneInfoMap_t< unsigned int > fWiresPerPlane
PlaneInfoMap_t< float > fFirstWireProj
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
std::set< PlaneID > fPlaneIDs
vector of the PlaneIDs present in the detector
Definition of data types for geometry description.
Class identifying a set of planes sharing readout channels.
unsigned int fNchannels
number of channels in the detector
virtual double WireCoordinate(double YPos, double ZPos, unsigned int PlaneNo, unsigned int TPCNo, unsigned int cstat) const override
Returns the index of the wire nearest to the specified position.
virtual WireID NearestWireID(const TVector3 &worldPos, unsigned int PlaneNo, unsigned int TPCNo, unsigned int cstat) const override
Returns the ID of the wire nearest to the specified position.
PlaneInfoMap_t< float > fOrthVectorsY
Unit vectors orthogonal to wires in.
geo::GeoObjectSorterStandard fSorter
class to sort geo objects
raw::ChannelID_t fTopChannel
book keeping highest channel #
virtual raw::ChannelID_t PlaneWireToChannel(unsigned int plane, unsigned int wire, unsigned int tpc, unsigned int cstat) const override
Returns the channel ID a wire is connected to.
Data in the geometry description.
Definition: GeometryData.h:31
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
Interface to algorithm class for a specific detector channel mapping.
LArSoft geometry interface.
Definition: ChannelGeo.h:16
std::vector< unsigned int > fNTPC
number of TPCs in each cryostat
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190