Belle II Software development
EventDataPlotter.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <tracking/trackFindingCDC/display/PrimitivePlotter.h>
11
12#include <framework/datastore/StoreArray.h>
13
14#include <memory>
15
16namespace Belle2 {
21 class MCParticle;
22 class RecoTrack;
23 class CDCHit;
24 class CDCSimHit;
25
26 namespace CDC {
27 class CDCWireTopology;
29 class CDCWire;
30 }
31
32 namespace TrackingUtilities {
33 class Circle2D;
34 class CDCTrajectory2D;
35 class CDCWireHit;
36 class CDCTrack;
37 class CDCRecoHit3D;
38 class CDCRecoHit2D;
40 class CDCSegment2D;
41 class CDCSegment3D;
42 class CDCSegmentPair;
44 class CDCSegmentTriple;
45 class CDCTangent;
46 }
47
48 namespace TrackFindingCDC {
49 class BoundingBox;
50
51
54
55
56 public:
59
60 public:
62 explicit EventDataPlotter(bool animate = false, bool forwardFade = false);
63
69 explicit EventDataPlotter(std::unique_ptr<PrimitivePlotter> ptrPrimitivePlotter,
70 bool animate = false,
71 bool forwardFade = false);
72
74 EventDataPlotter(const EventDataPlotter& eventDataPlotter);
75
76 public:
87 const std::string save(const std::string& fileName);
88
90 void clear();
91
92 public:
95
97 void setBoundingBox(const BoundingBox& boundingBox);
98
100 float getCanvasWidth() const;
101
103 float getCanvasHeight() const;
104
111 void setCanvasWidth(float width);
112
119 void setCanvasHeight(float height);
120
124 void startGroup(const AttributeMap& attributeMap = AttributeMap());
125
129 void endGroup();
130
131 public:
133 std::string getAnimationTimeFromNanoSeconds(float nanoseconds)
134 {
135 return std::to_string(nanoseconds) + "s";
136 }
137
138 private:
140 void startAnimationGroup(const Belle2::CDCSimHit& simHit);
141
143 void startAnimationGroup(const Belle2::CDCHit* ptrHit);
144
145 public:
148
150 void drawInnerCDCWall(const AttributeMap& attributeMap = AttributeMap());
151
153 void drawOuterCDCWall(const AttributeMap& attributeMap = AttributeMap());
154
156 void drawSuperLayerBoundaries(const AttributeMap& attributeMap = AttributeMap());
157
159 void drawLine(float startX,
160 float startY,
161 float endX,
162 float endY,
163 const AttributeMap& attributeMap = AttributeMap());
164
165 public:
166 // Drawing methods for the various event data objects.
167
169 void draw(const TrackingUtilities::Circle2D& circle,
170 AttributeMap attributeMap = AttributeMap());
171
173 void draw(const CDC::CDCWire& wire,
174 const AttributeMap& attributeMap = AttributeMap());
175
177 void draw(const CDC::CDCWireSuperLayer& wireSuperLayer,
178 const AttributeMap& attributeMap = AttributeMap());
179
181 void draw(const CDC::CDCWireTopology& wireTopology,
182 AttributeMap attributeMap = AttributeMap());
183
185 void draw(const CDCSimHit& simHit,
186 const AttributeMap& attributeMap = AttributeMap());
187
189 void draw(const CDCHit& hit,
190 const AttributeMap& attributeMap = AttributeMap());
191
193 void draw(const TrackingUtilities::CDCWireHit& wireHit,
194 const AttributeMap& attributeMap = AttributeMap());
195
197 void draw(const TrackingUtilities::CDCRecoHit2D& recoHit2D,
198 const AttributeMap& attributeMap = AttributeMap());
199
201 void draw(const TrackingUtilities::CDCRecoHit3D& recoHit3D,
202 const AttributeMap& attributeMap = AttributeMap());
203
205 void draw(const TrackingUtilities::CDCTangent& tangent,
206 const AttributeMap& attributeMap = AttributeMap());
207
209 void draw(const TrackingUtilities::CDCTrajectory2D& trajectory2D, AttributeMap attributeMap = AttributeMap());
210
212 void draw(const TrackingUtilities::CDCWireHitCluster& wireHitCluster, const AttributeMap& attributeMap = AttributeMap());
213
215 void draw(const TrackingUtilities::CDCSegment2D& segment2D, const AttributeMap& attributeMap = AttributeMap());
216
218 void draw(const TrackingUtilities::CDCSegment3D& segment3D, const AttributeMap& attributeMap = AttributeMap());
219
221 void draw(const TrackingUtilities::CDCAxialSegmentPair& axialSegmentPair, const AttributeMap& attributeMap = AttributeMap());
222
224 void draw(const TrackingUtilities::CDCSegmentPair& segmentPair, const AttributeMap& attributeMap = AttributeMap());
225
227 void draw(const TrackingUtilities::CDCSegmentTriple& segmentTriple, const AttributeMap& attributeMap = AttributeMap());
228
230 void draw(const TrackingUtilities::CDCTrack& track, const AttributeMap& attributeMap = AttributeMap());
231
233 void draw(const RecoTrack& recoTrack, const AttributeMap& attributeMap = AttributeMap());
234
236 void drawTrajectory(const MCParticle& mcParticle, const AttributeMap& attributeMap = AttributeMap());
237
239 void drawTrajectory(const TrackingUtilities::CDCSegment2D& segment, const AttributeMap& attributeMap = AttributeMap());
240
242 void drawTrajectory(const TrackingUtilities::CDCSegmentTriple& segmentTriple, const AttributeMap& attributeMap = AttributeMap());
243
245 void drawTrajectory(const TrackingUtilities::CDCTrack& track, const AttributeMap& attributeMap = AttributeMap());
246
248 void drawTrajectory(const RecoTrack& recoTrack, const AttributeMap& attributeMap = AttributeMap());
249
251 template<class T>
252 void draw(const T* ptr, const AttributeMap& attributeMap = AttributeMap())
253 {
254 if (ptr) draw(*ptr, attributeMap);
255 }
256
258 template<class T>
259 void draw(const StoreArray<T>& storeArray, const AttributeMap& attributeMap = AttributeMap())
260 {
261 if (not storeArray) return;
262 drawRange(storeArray, attributeMap);
263 }
264
266 template<class ARange>
267 void drawRange(const ARange& range, const AttributeMap& attributeMap = AttributeMap())
268 {
269 if (not m_ptrPrimitivePlotter) return;
270 PrimitivePlotter& primitivePlotter = *m_ptrPrimitivePlotter;
271 primitivePlotter.startGroup(attributeMap);
272 for (const auto& element : range) {
273 draw(element);
274 }
275 primitivePlotter.endGroup();
276 }
277
279 template<class ARange>
280 void drawRangeWithFade(const ARange& range, const AttributeMap& attributeMap = AttributeMap())
281 {
282 if (not m_ptrPrimitivePlotter) return;
283 PrimitivePlotter& primitivePlotter = *m_ptrPrimitivePlotter;
284 primitivePlotter.startGroup(attributeMap);
285 float opacity = 1;
286 float endOpacity = 0.5;
287 int n = std::distance(std::begin(range), std::end(range));
288 if (n == 0) return;
289 float opacityFactor = std::pow(endOpacity / opacity, 1.0 / (n - 1));
290 for (const auto& element : range) {
291 const auto opacity_str = std::to_string(opacity);
292 AttributeMap elementAttributeMap{{"opacity", opacity_str}};
293 draw(element, elementAttributeMap);
294 opacity *= opacityFactor;
295 }
296 primitivePlotter.endGroup();
297 }
298
299 private:
301 std::unique_ptr<PrimitivePlotter> m_ptrPrimitivePlotter;
302
304 bool m_animate = false;
305
307 bool m_forwardFade = false;
308
309 };
310 }
312}
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition CDCHit.h:40
Example Detector.
Definition CDCSimHit.h:21
Class representing a sense wire superlayer in the central drift chamber.
Class representing the sense wire arrangement in the whole of the central drift chamber.
Class representing a sense wire in the central drift chamber.
Definition CDCWire.h:50
A Class to store the Monte Carlo particle information.
Definition MCParticle.h:32
This is the Reconstruction Event-Data Model Track.
Definition RecoTrack.h:79
Accessor to arrays stored in the data store.
Definition StoreArray.h:113
A two dimensional rectangle that keeps track of the extend of a drawing.
Definition BoundingBox.h:21
void drawInteractionPoint()
Marks the position of the interaction point with a filled circle.
float getCanvasHeight() const
Getter for the canvas height in pixels.
void setCanvasHeight(float height)
Setter for the canvas height in pixels The canvas height denotes the size of the image being produced...
void setBoundingBox(const BoundingBox &boundingBox)
Setter for the bounding box of all drawn objects.
bool m_forwardFade
Memory for the flag whether the orientation of tracks segments etc should be shown as dimming opacity...
void drawOuterCDCWall(const AttributeMap &attributeMap=AttributeMap())
Draw the outer wall of the CDC.
void drawTrajectory(const MCParticle &mcParticle, const AttributeMap &attributeMap=AttributeMap())
Draws the trajectory that is represented by the MC particle.
void drawInnerCDCWall(const AttributeMap &attributeMap=AttributeMap())
Draw the inner wall of the CDC.
float getCanvasWidth() const
Getter for the canvas width in pixels.
PrimitivePlotter::AttributeMap AttributeMap
Forward the Attribute map from the primitive plotter.
void drawRange(const ARange &range, const AttributeMap &attributeMap=AttributeMap())
Draws a range iterable collection of drawable elements.
void startGroup(const AttributeMap &attributeMap=AttributeMap())
Indicates the start of a group of drawn elements.
bool m_animate
Memory for the flag if the event data should be animated. If animation is supported is backend depend...
void setCanvasWidth(float width)
Setter for the canvas width in pixels.
void draw(const T *ptr, const AttributeMap &attributeMap=AttributeMap())
Allow the drawing of pointers checking if the pointer is nonzero.
const std::string save(const std::string &fileName)
Saves the current plot stead to a file.
BoundingBox getBoundingBox() const
Getter for the current bounding box.
std::unique_ptr< PrimitivePlotter > m_ptrPrimitivePlotter
Reference to the primitivePlotter instance used as backend for the draw commands.
void draw(const TrackingUtilities::Circle2D &circle, AttributeMap attributeMap=AttributeMap())
Draws a filled circle.
EventDataPlotter(bool animate=false, bool forwardFade=false)
Default constructor for ROOT compatibility. Uses an SVGPrimitivePlotter as backend.
void clear()
Clears all drawn elements from the plotter.
void drawSuperLayerBoundaries(const AttributeMap &attributeMap=AttributeMap())
Draw the super layer bounds of the CDC.
void drawRangeWithFade(const ARange &range, const AttributeMap &attributeMap=AttributeMap())
Draws a range iterable collection of drawable elements.
void draw(const StoreArray< T > &storeArray, const AttributeMap &attributeMap=AttributeMap())
Draw store array.
void drawLine(float startX, float startY, float endX, float endY, const AttributeMap &attributeMap=AttributeMap())
Draws a straight Line.
void startAnimationGroup(const Belle2::CDCSimHit &simHit)
Start a group in the underlying plotter with an animation uncovering the elements at the time of flig...
void endGroup()
Indicates the end of a group of drawn elements.
std::string getAnimationTimeFromNanoSeconds(float nanoseconds)
Converts a time given in nanoseconds to a time string of the from "%fs".
A base class for plots of primitive objects.
virtual void startGroup(const AttributeMap &attributeMap=AttributeMap())
Indicates the start of a group of drawn elements.
Belle2::TrackFindingCDC::AttributeMap AttributeMap
A map type for attributes names to values for additional drawing information.
virtual void endGroup()
Indicates the end of a group of drawn elements.
Class representing a pair of reconstructed axial segments in adjacent superlayer.
Class representing a two dimensional reconstructed hit in the central drift chamber.
Class representing a three dimensional reconstructed hit.
A reconstructed sequence of two dimensional hits in one super layer.
A segment consisting of three dimensional reconstructed hits.
Class representing a pair of one reconstructed axial segment and one stereo segment in adjacent super...
Class representing a triple of reconstructed segments in adjacent superlayer.
Class representing a linear track piece between two oriented wire hits.
Definition CDCTangent.h:40
Class representing a sequence of three dimensional reconstructed hits.
Definition CDCTrack.h:39
Particle trajectory as it is seen in xy projection represented as a circle.
Class representing a hit wire in the central drift chamber.
Definition CDCWireHit.h:58
A two dimensional circle in its natural representation using center and radius as parameters.
Definition Circle2D.h:26
Abstract base class for different kinds of events.