All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WireCreator.h
Go to the documentation of this file.
1 /** ****************************************************************************
2  * @file WireCreator.h
3  * @brief Helper functions to create a wire
4  * @date December 11, 2014
5  * @author petrillo@fnal.gov
6  * @see Wire.h WireCreator.cxx
7  *
8  * ****************************************************************************/
9 
10 #ifndef WIRECREATOR_H
11 #define WIRECREATOR_H
12 
13 // C/C++ standard library
14 #include <utility> // std::move()
15 
16 // LArSoft libraries
17 #include "larcoreobj/SimpleTypesAndConstants/RawTypes.h" // raw::ChannelID_t
18 #include "larcoreobj/SimpleTypesAndConstants/geo_types.h" // geo::View_t
20 
21 namespace raw { class RawDigit; }
22 
23 /// Reconstruction base classes
24 namespace recob {
25 
26  /**
27  * @brief Class managing the creation of a new recob::Wire object
28  *
29  * In order to be as simple as possible (Plain Old Data), data products like
30  * recob::Wire need to be stripped of most of their functions, including the
31  * ability to communicate whether a value we try to store is invalid
32  * (that would require a art::Exception -- art -- or at least a message on the
33  * screen -- MessageFacility) and the ability to read things from event,
34  * services (e.g. geometry) etc.
35  *
36  * A Creator is a class that creates a temporary data product, and at the
37  * end it yields it to the caller for storage.
38  * This last step should be by move construction, although a copy method is
39  * also provided.
40  *
41  * An example of creating a Wire object:
42  *
43  * // let RoIsignal be a recob::Wire::RegionsOfInterest_t already filled
44  * // with the signal regions, and rawdigit the raw::RawDigit of the
45  * // channel; RoIsignal will become empty
46  * recob::WireCreator wire(std::move(RoIsignal), rawdigit);
47  * wires.push_back(wire.move()); // wire content is not valid any more
48  *
49  * This is a one-step creation object: the wire is constructed at the same
50  * time the WireCreator is, and no facility is offered to modify the
51  * constructed wire, or to create another one.
52  */
53  class WireCreator {
54  public:
55  /// Alias for the type of regions of interest
57 
58  // destructor, copy and move constructor and assignment as default
59 
60  /**
61  * @brief Constructor: uses specified signal in regions of interest
62  * @param sigROIlist signal organized in regions of interest
63  * @param rawdigit the raw digit this channel is associated to
64  *
65  * The information used from the raw digit are the channel ID and the
66  * length in samples (TDC ticks) of the original readout window.
67  */
69  (const RegionsOfInterest_t& sigROIlist, const raw::RawDigit& rawdigit);
70 
71 
72  /**
73  * @brief Constructor: uses specified signal in regions of interest
74  * @param sigROIlist signal organized in regions of interest
75  * @param rawdigit the raw digit this channel is associated to
76  *
77  * The information used from the raw digit are the channel ID and the
78  * length in samples (TDC ticks) of the original readout window.
79  *
80  * Signal information is moved from sigROIlist, that becomes empty.
81  */
83  (RegionsOfInterest_t&& sigROIlist, const raw::RawDigit& rawdigit);
84 
85 
86  /**
87  * @brief Constructor: uses specified signal in regions of interest
88  * @param sigROIlist signal organized in regions of interest
89  * @param channel the ID of the channel
90  * @param view the view the channel belongs to
91  *
92  * The information used from the raw digit are the channel ID and the
93  * length in samples (TDC ticks) of the original readout window.
94  */
96  RegionsOfInterest_t const& sigROIlist,
97  raw::ChannelID_t channel,
98  geo::View_t view
99  );
100 
101 
102  /**
103  * @brief Constructor: uses specified signal in regions of interest
104  * @param sigROIlist signal organized in regions of interest
105  * @param channel the ID of the channel
106  * @param view the view the channel belongs to
107  *
108  * The information used from the raw digit are the channel ID and the
109  * length in samples (TDC ticks) of the original readout window.
110  *
111  * Signal information is moved from sigROIlist, that becomes empty.
112  */
113  WireCreator(
114  RegionsOfInterest_t&& sigROIlist,
115  raw::ChannelID_t channel,
116  geo::View_t view
117  );
118 
119  /**
120  * @brief Prepares the constructed wire to be moved away
121  * @return a right-value reference to the constructed wire
122  *
123  * Despite the name, no move happens in this function.
124  * Move takes place in the caller code as proper; for example:
125  *
126  * // be wire a WireCreator instance:
127  * std::vector<recob::Wire> Wires;
128  * wire.move(); // nothing happens
129  * Wires.push_back(wire.move()); // here the copy happens
130  * recob::Wire single_wire(wire.move()); // wrong! wire is empty now
131  *
132  */
133  Wire&& move() { return std::move(wire); }
134 
135 
136  /**
137  * @brief Returns the constructed wire
138  * @return a constant reference to the constructed wire
139  *
140  * Despite the name, no copy happens in this function.
141  * Copy takes place in the caller code as proper; for example:
142  *
143  * // be wire a WireCreator instance:
144  * std::vector<recob::Wire> Wires;
145  * wire.copy(); // nothing happens
146  * Wires.push_back(wire.copy()); // here a copy happens
147  * recob::Wire single_wire(wire.copy()); // wire is copied again
148  *
149  */
150  const Wire& copy() const { return wire; }
151 
152  protected:
153 
154  Wire wire; ///< local instance of the wire being constructed
155 
156  }; // class WireCreator
157 
158 } // namespace recob
159 
160 #endif // WIRECREATOR_H
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Wire wire
local instance of the wire being constructed
Definition: WireCreator.h:154
lar::sparse_vector< float > RegionsOfInterest_t
a region of interest is a pair (TDC offset, readings)
Definition: Wire.h:121
Wire && move()
Prepares the constructed wire to be moved away.
Definition: WireCreator.h:133
Class managing the creation of a new recob::Wire object.
Definition: WireCreator.h:53
WireCreator(const RegionsOfInterest_t &sigROIlist, const raw::RawDigit &rawdigit)
Constructor: uses specified signal in regions of interest.
Definition: WireCreator.cxx:30
const Wire & copy() const
Returns the constructed wire.
Definition: WireCreator.h:150
Definition of data types for geometry description.
Class holding the regions of interest of signal from a channel.
Definition: Wire.h:118
Declaration of basic channel signal object.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28