All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RawDataDrawer.h
Go to the documentation of this file.
1 /// \file RawDataDrawer.h
2 /// \brief Class to aid in the rendering of RawData objects
3 /// \author messier@indiana.edu
4 #ifndef EVD_RAWDATADRAWER_H
5 #define EVD_RAWDATADRAWER_H
6 
7 namespace fhicl { class ParameterSet; }
8 
9 #include "larcoreobj/SimpleTypesAndConstants/geo_types.h" // geo::PlaneID
10 
11 #include <vector>
12 
13 #ifndef __CINT__
14 #include "larevt/CalibrationDBI/Interface/ChannelStatusProvider.h" // lariov::ChannelStatusProvider::Status_t
15 #endif
16 
17 namespace art { class Event; }
18 
19 class TH1F;
20 class TVirtualPad;
21 namespace detinfo {
22  class DetectorPropertiesData;
23 }
24 namespace evdb {
25  class View2D;
26 }
27 namespace raw {
28  class RawDigit;
29 }
30 namespace util {
31  class PlaneDataChangeTracker_t;
32 } // namespace util
33 
34 namespace evd {
35 
36  namespace details {
37  class RawDigitCacheDataClass;
39  typedef ::util::PlaneDataChangeTracker_t CacheID_t;
40  } // namespace details
41 
42  /// Aid in the rendering of RawData objects
43  class RawDataDrawer {
44  public:
45  RawDataDrawer();
47 
48  /**
49  * @brief Draws raw digit content in 2D wire plane representation
50  * @param evt source for raw digits
51  * @param view target rendered object
52  * @param plane number of the plane to be drawn
53  * @param bZoomToRoI whether to render only te region of interest
54  *
55  * This function performs pre-rendering of the raw digit content into a
56  * 2D view of the wire plane as TDC vs. wire number.
57  * The material for rendering is created and sent to view object for actual
58  * rendering.
59  * The pre-rendering result currently depends on information from the
60  * current rendering canvas, and in particular on its viewport in the
61  * (wire, TDC) space.
62  *
63  * If no zoom to the region of interest is required, the region itself is
64  * computed (only if not known yet) while the rendering is performed.
65  * If the zoom is required instead, rendering is performed in two steps;
66  * in the first, run only of no region of interest is known yet, the region
67  * is extracted. In the second, that information is used for rendering.
68  */
69  void RawDigit2D(art::Event const& evt,
71  evdb::View2D* view,
72  unsigned int plane,
73  bool bZoomToRoI = false);
74 
75  void FillQHisto(const art::Event& evt, unsigned int plane, TH1F* histo);
76 
77  void FillTQHisto(const art::Event& evt, unsigned int plane, unsigned int wire, TH1F* histo);
78 
79  double
80  StartTick() const
81  {
82  return fStartTick;
83  }
84  double
86  {
87  return fTicks;
88  }
89 
90  /// Fills the viewport information from the specified pad
91  void ExtractRange(TVirtualPad* pPad, std::vector<double> const* zoom = nullptr);
92 
93  /// Fills the viewport borders from the specified extremes
94  void SetDrawingLimits(float low_wire, float high_wire, float low_tdc, float high_tdc);
95 
96  int GetRegionOfInterest(int plane, int& minw, int& maxw, int& mint, int& maxt);
97 
98  /// Forgets about the current region of interest
99  void ResetRegionOfInterest();
100 
101  /// Returns whether there is currently a valid region of interest
102  /// for the specified plane
104 
105  void GetChargeSum(int plane, double& charge, double& convcharge);
106 
107  private:
108  typedef struct {
109  int adc = 0; ///< total ADC count in this box
110  bool good = false; ///< whether the channel is not bad
111  } BoxInfo_t;
112 
113  typedef struct {
114  unsigned int width = 0; // width of pad in pixels
115  unsigned int height = 0; // heigt of pad in pixels
116 
117  /// Returns whether the stored value is valid
118  bool
119  isFilled() const
120  {
121  return (width != 0) && (height != 0);
122  }
123 
124  /// Returns whether the stored value is valid
125  operator bool() const { return isFilled(); }
126 
127  } PadResolution_t; ///< Stores the information about the drawing area
128 
129  /// Helper class to be used with ChannelLooper()
130  class OperationBaseClass;
131  class ManyOperations;
132  class BoxDrawer;
134 
135  // Since this is a private facility, we indulge in non-recommended practises
136  // like friendship; these classes have the ability to write their findings
137  // directly into RawDataDrawer; the alternative would be to have an
138  // interface writing that information exposed to the public, that has the
139  // draw back that we completely lose control on who can use it.
140  // Other solutions might be also possible...
141  // but this is already more complicated than needed.
142  friend class BoxDrawer;
143  friend class RoIextractorClass;
144 
145  /// Cache of raw digits
146  // Never use raw pointers. Unless you are dealing with CINT, that is.
148 
149 #ifndef __CINT__
150  /// Prepares for a new event (if somebody tells it to)
151  void Reset(art::Event const& event);
152 
153  /// Reads raw::RawDigits; also triggers Reset()
154  void GetRawDigits(art::Event const& evt);
155 
156  /// Returns whether a channel with the specified status should be processed
158 #endif // __CINT__
159 
160  double fStartTick; ///< low tick
161  double fTicks; ///< number of ticks of the clock
162 
163  std::vector<int> fWireMin; ///< lowest wire in interesting region for each plane
164  std::vector<int> fWireMax; ///< highest wire in interesting region for each plane
165  std::vector<int> fTimeMin; ///< lowest time in interesting region for each plane
166  std::vector<int> fTimeMax; ///< highest time in interesting region for each plane
167 
168  std::vector<double> fRawCharge; ///< Sum of Raw Charge
169  std::vector<double> fConvertedCharge; ///< Sum of Charge Converted using Birks' formula
170 
171  PadResolution_t PadResolution; ///< stored pad resolution
172 
173  details::CacheID_t* fCacheID; ///< information about the last processed plane
174 
175  // TODO with ROOT 6, turn this into a std::unique_ptr()
176  details::CellGridClass* fDrawingRange; ///< information about the viewport
177 
178  /// Performs the 2D wire plane drawing
179  void DrawRawDigit2D(art::Event const& evt, evdb::View2D* view, unsigned int plane);
180 
181  /**
182  * @brief Makes sure raw::RawDigit's are available for the current settings
183  * @param evt event to read the digits from
184  * @param ts a cache ID assessing the new state the cache should move to
185  *
186  * The function will ask the data cache for an update
187  * (RawDigitCacheDataClass::Update()).
188  * The cache will evaluate whether it is already in a state compatible with
189  * ts or if cache needs to be invalidated, in which case it will fill with
190  * new data.
191  * This method also triggers a Reset() if the target state differs from the
192  * old one.
193  */
194  void GetRawDigits(art::Event const& evt, details::CacheID_t const& new_timestamp);
195 
196  // Helper functions for drawing
197  bool RunOperation(art::Event const& evt, OperationBaseClass* operation);
198  void QueueDrawingBoxes(evdb::View2D* view,
199  geo::PlaneID const& pid,
200  std::vector<BoxInfo_t> const& BoxInfo);
201  void RunDrawOperation(art::Event const& evt,
202  detinfo::DetectorPropertiesData const& detProp,
203  evdb::View2D* view,
204  unsigned int plane);
205  void RunRoIextractor(art::Event const& evt, unsigned int plane);
207  void
209  {
211  }
212 
213  /// Empty collection, used in return value of invalid digits
214  static std::vector<raw::RawDigit> const EmptyRawDigits;
215 
216  }; // class RawDataDrawer
217 
218 }
219 
220 #endif
221 ////////////////////////////////////////////////////////////////////////
int GetRegionOfInterest(int plane, int &minw, int &maxw, int &mint, int &maxt)
void FillTQHisto(const art::Event &evt, unsigned int plane, unsigned int wire, TH1F *histo)
void RunDrawOperation(art::Event const &evt, detinfo::DetectorPropertiesData const &detProp, evdb::View2D *view, unsigned int plane)
void DrawRawDigit2D(art::Event const &evt, evdb::View2D *view, unsigned int plane)
Performs the 2D wire plane drawing.
void SetDrawingLimitsFromRoI(geo::PlaneID::PlaneID_t plane)
double fStartTick
low tick
unsigned int PlaneID_t
Type for the ID number.
Definition: geo_types.h:473
The data type to uniquely identify a Plane.
Definition: geo_types.h:472
details::CacheID_t * fCacheID
information about the last processed plane
bool isFilled() const
Returns whether the stored value is valid.
static constexpr bool
void RawDigit2D(art::Event const &evt, detinfo::DetectorPropertiesData const &detProp, evdb::View2D *view, unsigned int plane, bool bZoomToRoI=false)
Draws raw digit content in 2D wire plane representation.
bool ProcessChannelWithStatus(lariov::ChannelStatusProvider::Status_t channel_status) const
Returns whether a channel with the specified status should be processed.
std::vector< double > fRawCharge
Sum of Raw Charge.
BEGIN_PROLOG channel_status
std::vector< int > fWireMin
lowest wire in interesting region for each plane
void SetDrawingLimits(float low_wire, float high_wire, float low_tdc, float high_tdc)
Fills the viewport borders from the specified extremes.
std::vector< int > fTimeMax
highest time in interesting region for each plane
unsigned short Status_t
type representing channel status
double fTicks
number of ticks of the clock
PadResolution_t PadResolution
stored pad resolution
Cached set of RawDigitInfo_t.
void FillQHisto(const art::Event &evt, unsigned int plane, TH1F *histo)
void GetChargeSum(int plane, double &charge, double &convcharge)
void RunRoIextractor(art::Event const &evt, unsigned int plane)
std::vector< int > fWireMax
highest wire in interesting region for each plane
void SetDrawingLimitsFromRoI(geo::PlaneID const pid)
void GetRawDigits(art::Event const &evt)
Reads raw::RawDigits; also triggers Reset()
double TotalClockTicks() const
Definition: RawDataDrawer.h:85
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
Definition of data types for geometry description.
Detects the presence of a new event, data product or wire plane.
double StartTick() const
Definition: RawDataDrawer.h:80
void Reset(art::Event const &event)
Prepares for a new event (if somebody tells it to)
bool hasRegionOfInterest(geo::PlaneID::PlaneID_t plane) const
friend class BoxDrawer
void QueueDrawingBoxes(evdb::View2D *view, geo::PlaneID const &pid, std::vector< BoxInfo_t > const &BoxInfo)
Aid in the rendering of RawData objects.
Definition: RawDataDrawer.h:43
Interface for experiment-specific channel quality info provider.
static std::vector< raw::RawDigit > const EmptyRawDigits
Empty collection, used in return value of invalid digits.
void ResetRegionOfInterest()
Forgets about the current region of interest.
details::CellGridClass * fDrawingRange
information about the viewport
std::vector< int > fTimeMin
lowest time in interesting region for each plane
::util::PlaneDataChangeTracker_t CacheID_t
Definition: RawDataDrawer.h:38
Manages a grid-like division of 2D space.
TCEvent evt
Definition: DataStructs.cxx:8
evd::details::RawDigitCacheDataClass * digit_cache
Cache of raw digits.
bool RunOperation(art::Event const &evt, OperationBaseClass *operation)
auto const detProp
std::vector< double > fConvertedCharge
Sum of Charge Converted using Birks&#39; formula.
void ExtractRange(TVirtualPad *pPad, std::vector< double > const *zoom=nullptr)
Fills the viewport information from the specified pad.