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