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