ChannelMapAPAAlg.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file ChannelMapAPAAlg.h
3 /// \brief Interface to algorithm class for a specific detector channel mapping
4 ///
5 /// \version $Id: $
6 /// \author tylerdalion@gmail.com
7 ////////////////////////////////////////////////////////////////////////
8 #ifndef GEO_CHANNELAPAMAPALG_H
9 #define GEO_CHANNELAPAMAPALG_H
10 
11 
12 #include <vector>
13 #include <set>
14 
15 #include "cetlib_except/exception.h"
16 #include "larcoreobj/SimpleTypesAndConstants/readout_types.h" // readout::ROPID, ...
17 #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t
20 
21 #include "fhiclcpp/ParameterSet.h"
22 
23 namespace geo{
24 
26 
27  public:
28 
30 
31  void Initialize( GeometryData_t const& geodata ) override;
32  void Uninitialize() override;
33 
34  /// Returns a list of TPC wires connected to the specified readout channel ID
35  /// @throws cet::exception (category: "Geometry") if non-existent channel
36  std::vector<WireID> ChannelToWire(raw::ChannelID_t channel) const override;
37 
38  unsigned int Nchannels() const override;
39 
40  /// @brief Returns the number of channels in the specified ROP
41  /// @return number of channels in the specified ROP, 0 if non-existent
42  /// @todo to be completed
43  virtual unsigned int Nchannels(readout::ROPID const& ropid) const override;
44 
45  //@{
46  virtual double WireCoordinate(double YPos,
47  double ZPos,
48  unsigned int PlaneNo,
49  unsigned int TPCNo,
50  unsigned int cstat) const override
51  { return WireCoordinate(YPos, ZPos, geo::PlaneID(cstat, TPCNo, PlaneNo)); }
52  virtual double WireCoordinate(double YPos,
53  double ZPos,
54  geo::PlaneID const& planeID) const override;
55  //@}
56 
57  //@{
58  virtual WireID NearestWireID(const TVector3& worldPos,
59  unsigned int PlaneNo,
60  unsigned int TPCNo,
61  unsigned int cstat) const override
62  { return NearestWireID(worldPos, geo::PlaneID(cstat, TPCNo, PlaneNo)); }
63  virtual WireID NearestWireID
64  (const TVector3& worldPos, geo::PlaneID const& planeID) const override;
65  //@}
66  //@{
67  virtual raw::ChannelID_t PlaneWireToChannel(unsigned int plane,
68  unsigned int wire,
69  unsigned int tpc,
70  unsigned int cstat) const override
71  { return PlaneWireToChannel(geo::WireID(cstat, tpc, plane, wire)); }
72  virtual raw::ChannelID_t PlaneWireToChannel(geo::WireID const& wireID) const override;
73  //@}
74  View_t View( raw::ChannelID_t const channel ) const;
75  SigType_t SignalTypeForChannelImpl( raw::ChannelID_t const channel) const override;
76  std::set<View_t> const& Views() const;
77  std::set<PlaneID> const& PlaneIDs() const override;
78 
79  //
80  // TPC set interface
81  //
82  /// @name TPC set mapping
83  /// @{
84  /**
85  * @brief Returns the total number of TPC sets in the specified cryostat
86  * @param cryoid cryostat ID
87  * @return number of TPC sets in the cryostat, or 0 if no cryostat found
88  *
89  * @todo to be completed
90  */
91  virtual unsigned int NTPCsets
92  (readout::CryostatID const& cryoid) const override;
93 
94  /// Returns the largest number of TPC sets any cryostat in the detector has
95  /// @todo to be completed
96  virtual unsigned int MaxTPCsets() const override;
97 
98  /// Returns whether we have the specified TPC set
99  /// @return whether the TPC set is valid and exists
100  /// @todo to be completed
101  virtual bool HasTPCset(readout::TPCsetID const& tpcsetid) const override;
102 
103  /**
104  * @brief Returns the ID of the TPC set the specified TPC belongs to
105  * @param tpcid ID of the TPC
106  * @return the ID of the corresponding TPC set
107  *
108  * Note that the check is performed on the validity of the TPC set ID, that
109  * does not necessarily imply that the TPC set specified by the ID actually
110  * exists. Check the existence of the TPC set first (HasTPCset()).
111  * Behaviour on valid, non-existent TPC set IDs is undefined.
112  *
113  * @todo to be completed
114  */
116  (geo::TPCID const& tpcid) const override;
117 
118  /**
119  * @brief Returns a list of ID of TPCs belonging to the specified TPC set
120  * @param tpcsetid ID of the TPC set to convert into TPC IDs
121  * @return the list of TPCs, empty if TPC set is invalid
122  *
123  * Note that the check is performed on the validity of the TPC set ID, that
124  * does not necessarily imply that the TPC set specified by the ID actually
125  * exists. Check the existence of the TPC set first (HasTPCset()).
126  * Behaviour on valid, non-existent TPC set IDs is undefined.
127  *
128  * @todo to be completed
129  */
130  virtual std::vector<geo::TPCID> TPCsetToTPCs
131  (readout::TPCsetID const& tpcsetid) const override;
132 
133  /// Returns the ID of the first TPC belonging to the specified TPC set
134  /// @todo to be completed
136  (readout::TPCsetID const& tpcsetid) const override;
137 
138  /// @} TPC set mapping
139 
140 
141 
142  //
143  // Readout plane interface
144  //
145  /// @name Readout plane mapping
146  /// @{
147 
148  /**
149  * @brief Returns the total number of ROP in the specified TPC set
150  * @param tpcsetid TPC set ID
151  * @return number of readout planes in the TPC set, or 0 if no TPC set found
152  *
153  * Note that this methods explicitly check the existence of the TPC set.
154  *
155  * @todo to be completed
156  */
157  virtual unsigned int NROPs
158  (readout::TPCsetID const& tpcsetid) const override;
159 
160  /// Returns the largest number of ROPs a TPC set in the detector has
161  /// @todo to be completed
162  virtual unsigned int MaxROPs() const override;
163 
164  /// Returns whether we have the specified ROP
165  /// @return whether the readout plane is valid and exists
166  virtual bool HasROP(readout::ROPID const& ropid) const override;
167 
168  /**
169  * @brief Returns the ID of the ROP planeid belongs to, or invalid if none
170  * @param planeid ID of the wire plane
171  * @return the ID of the corresponding ROP, or invalid ID when planeid is
172  *
173  * Note that this check is performed on the validity of the wire plane
174  * ID, that does not necessarily imply that the wire plane specified by
175  * the ID actually exists. Check if the wire plane exists with HasPlane().
176  * The behaviour on non-existing wire planes is undefined.
177  *
178  * @todo to be completed
179  */
181  (geo::PlaneID const& planeid) const override;
182 
183  /**
184  * @brief Returns a list of ID of wire planes belonging to the specified ROP
185  * @param ropid ID of the readout plane to convert into wire planes
186  * @return the list of wire plane IDs, empty if readout plane ID is invalid
187  *
188  * Note that this check is performed on the validity of the readout plane
189  * ID, that does not necessarily imply that the readout plane specified by
190  * the ID actually exists. Check if the ROP exists with HasROP().
191  * The behaviour on non-existing readout planes is undefined.
192  *
193  * @todo to be completed
194  */
195  virtual std::vector<geo::PlaneID> ROPtoWirePlanes
196  (readout::ROPID const& ropid) const override;
197 
198  /**
199  * @brief Returns a list of ID of TPCs the specified ROP spans
200  * @param ropid ID of the readout plane
201  * @return the list of TPC IDs, empty if readout plane ID is invalid
202  *
203  * Note that this check is performed on the validity of the readout plane
204  * ID, that does not necessarily imply that the readout plane specified by
205  * the ID actually exists. Check if the ROP exists with HasROP().
206  * The behaviour on non-existing readout planes is undefined.
207  *
208  * @todo to be completed
209  */
210  virtual std::vector<geo::TPCID> ROPtoTPCs
211  (readout::ROPID const& ropid) const override;
212 
213  /// Returns the ID of the ROP the channel belongs to (invalid if none)
214  /// @throws cet::exception (category: "Geometry") if non-existent channel
216  (raw::ChannelID_t channel) const override;
217 
218  /**
219  * @brief Returns the ID of the first channel in the specified readout plane
220  * @param ropid ID of the readout plane
221  * @return ID of first channel, or raw::InvalidChannelID if ID is invalid
222  *
223  * Note that this check is performed on the validity of the readout plane
224  * ID, that does not necessarily imply that the readout plane specified by
225  * the ID actually exists. Check if the ROP exists with HasROP().
226  * The behaviour for non-existing readout planes is undefined.
227  *
228  * @todo to be completed
229  */
231  (readout::ROPID const& ropid) const override;
232 
233  /**
234  * @brief Returns the ID of the first plane belonging to the specified ROP
235  * @param ropid ID of the readout plane
236  * @return ID of first channel, or raw::InvalidChannelID if ID is invalid
237  *
238  * Note that this check is performed on the validity of the readout plane
239  * ID, that does not necessarily imply that the readout plane specified by
240  * the ID actually exists. Check if the ROP exists with HasROP().
241  * The behaviour for non-existing readout planes is undefined.
242  *
243  * @todo to be completed
244  */
246  (readout::ROPID const& ropid) const override;
247 
248  /// @} readout plane mapping
249 
250  /// Returns the object to sort geometry with
251  virtual geo::GeoObjectSorter const& Sorter() const override
252  { return fSorter; }
253 
254 
255 
256  unsigned int NOpChannels(unsigned int NOpDets) const override;
257  unsigned int NOpHardwareChannels(unsigned int opDet) const override;
258  unsigned int OpChannel(unsigned int detNum, unsigned int channel = 0) const override;
259  unsigned int OpDetFromOpChannel(unsigned int opChannel) const override;
260  unsigned int HardwareChannelFromOpChannel(unsigned int opChannel) const override;
261 
262  private:
263 
264  unsigned int fChannelsPerOpDet;
265  unsigned int fNcryostat; ///< number of cryostats in the detector
266  unsigned int fNchannels; ///< number of channels in the detector
267  raw::ChannelID_t fTopChannel; ///< book keeping highest channel #
268  std::vector<unsigned int> fNTPC; ///< number of TPCs in each cryostat
269  std::set<View_t> fViews; ///< vector of the views present in the detector
270  std::set<PlaneID> fPlaneIDs; ///< vector of the PlaneIDs present in the detector
271  // Assuming all APA's are identical
272  std::vector< unsigned int > fWiresInPlane;
273  unsigned int fPlanesPerAPA;
274  unsigned int fChannelsPerAPA;
275  std::vector< unsigned int > nAnchoredWires;
276 
277  PlaneInfoMap_t<unsigned int> fWiresPerPlane; ///< The number of wires in this plane
278  ///< in the heirachy
279 
280  geo::GeoObjectSorterAPA fSorter; ///< sorts geo::XXXGeo objects
281 
282  /// all data we need for each APA
283  typedef struct {
286  /// +1 if the wire ID order follow z (larger z, or smaller intercept => larger wire ID); -1 otherwise
288  double fYmax;
289  double fYmin;
290  double fZmax;
291  double fZmin;
292  } PlaneData_t;
293 
294  ///< collects all data we need for each plane (indices: c t p)
296 
297  std::vector< double > fWirePitch;
298  std::vector< double > fOrientation;
299  std::vector< double > fSinOrientation; // to explore improving speed
300  std::vector< double > fCosOrientation; // to explore improving speed
301 
302  };
303 
304 }
305 #endif // GEO_CHANNELMAPAPAALG_H
306 
unsigned int fNchannels
number of channels in the detector
float fWireSortingInZ
+1 if the wire ID order follow z (larger z, or smaller intercept => larger wire ID); -1 otherwise ...
std::set< View_t > fViews
vector of the views present in the detector
Interface for a class providing readout channel mapping to geometry.
Definition: ChannelMapAlg.h:48
std::vector< unsigned int > fWiresInPlane
std::vector< unsigned int > nAnchoredWires
virtual bool HasROP(readout::ROPID const &ropid) const override
Classes identifying readout-related concepts.
SigType_t SignalTypeForChannelImpl(raw::ChannelID_t const channel) const override
Return the signal type of the specified channel.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
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.
std::vector< double > fSinOrientation
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.
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
std::set< PlaneID > fPlaneIDs
vector of the PlaneIDs present in the detector
Interface to algorithm class for standard sorting of geo::XXXGeo objects.
Class identifying a set of TPC sharing readout channels.
Definition: readout_types.h:70
virtual geo::GeoObjectSorter const & Sorter() const override
Returns the object to sort geometry with.
uint8_t channel
Definition: CRTFragment.hh:201
geo::GeoObjectSorterAPA fSorter
sorts geo::XXXGeo objects
virtual std::vector< geo::TPCID > TPCsetToTPCs(readout::TPCsetID const &tpcsetid) const override
Returns a list of ID of TPCs belonging to the specified TPC set.
std::set< View_t > const & Views() const
virtual unsigned int NTPCsets(readout::CryostatID const &cryoid) const override
Returns the total number of TPC sets in the specified cryostat.
raw::ChannelID_t fTopChannel
book keeping highest channel #
unsigned int fChannelsPerAPA
PlaneInfoMap_t< PlaneData_t > fPlaneData
std::vector< WireID > ChannelToWire(raw::ChannelID_t channel) const override
virtual raw::ChannelID_t FirstChannelInROP(readout::ROPID const &ropid) const override
Returns the ID of the first channel in the specified readout plane.
PlaneInfoMap_t< unsigned int > fWiresPerPlane
TPCInfoMap_t< std::vector< T >> PlaneInfoMap_t
Data type for per-plane information.
std::vector< unsigned int > fNTPC
number of TPCs in each cryostat
unsigned int OpChannel(unsigned int detNum, unsigned int channel=0) const override
Returns the channel ID of the specified hardware channel.
virtual unsigned int NROPs(readout::TPCsetID const &tpcsetid) const override
Returns the total number of ROP in the specified TPC set.
std::vector< double > fOrientation
virtual bool HasTPCset(readout::TPCsetID const &tpcsetid) const override
virtual unsigned int MaxROPs() const override
enum geo::_plane_sigtype SigType_t
virtual std::vector< geo::TPCID > ROPtoTPCs(readout::ROPID const &ropid) const override
Returns a list of ID of TPCs the specified ROP spans.
unsigned int NOpHardwareChannels(unsigned int opDet) const override
Returns the number of channels in the specified optical detectors.
p
Definition: test.py:223
virtual readout::ROPID ChannelToROP(raw::ChannelID_t channel) const override
std::vector< double > fWirePitch
The data type to uniquely identify a TPC.
Definition: geo_types.h:386
void Uninitialize() override
Deconfiguration: prepare for a following call of Initialize()
virtual geo::PlaneID FirstWirePlaneInROP(readout::ROPID const &ropid) const override
Returns the ID of the first plane belonging to the specified ROP.
void Initialize(GeometryData_t const &geodata) override
Geometry initialisation.
Class identifying a set of planes sharing readout channels.
std::set< PlaneID > const & PlaneIDs() const override
Returns a list of the plane IDs in the whole detector.
virtual readout::TPCsetID TPCtoTPCset(geo::TPCID const &tpcid) const override
Returns the ID of the TPC set the specified TPC belongs to.
virtual readout::ROPID WirePlaneToROP(geo::PlaneID const &planeid) const override
Returns the ID of the ROP planeid belongs to, or invalid if none.
virtual unsigned int MaxTPCsets() const override
unsigned int OpDetFromOpChannel(unsigned int opChannel) const override
Returns the optical detector the specified optical channel belongs.
unsigned int fNcryostat
number of cryostats in the detector
virtual std::vector< geo::PlaneID > ROPtoWirePlanes(readout::ROPID const &ropid) const override
Returns a list of ID of wire planes belonging to the specified ROP.
unsigned int HardwareChannelFromOpChannel(unsigned int opChannel) const override
Returns the hardware channel number of specified optical channel.
unsigned int NOpChannels(unsigned int NOpDets) const override
Returns the number of optical channels contained in some detectors.
unsigned int Nchannels() const override
Returns the total number of channels present (not necessarily contiguous)
all data we need for each APA
ChannelMapAPAAlg(fhicl::ParameterSet const &p)
unsigned int fChannelsPerOpDet
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
virtual geo::TPCID FirstTPCinTPCset(readout::TPCsetID const &tpcsetid) const override
View_t View(raw::ChannelID_t const channel) const
The data type to uniquely identify a cryostat.
Definition: geo_types.h:190
std::vector< double > fCosOrientation