Belle II Software development
CDCSVGPlotter Class Reference

Helper class to generated the svg image from the various tracking objects. More...

#include <CDCSVGPlotter.h>

Public Member Functions

 CDCSVGPlotter (bool animate=false, bool forwardFade=false)
 Constructor.
 
CDCSVGPlotterclone ()
 Make a copy of the current status of the plotter.
 
void drawWires (const CDCWireTopology &cdcWireTopology)
 Draws the wires.
 
void drawInteractionPoint ()
 Draws the interaction point.
 
void drawSuperLayerBoundaries (const std::string &stroke)
 Draws the individual super layer boundaries.
 
void drawOuterCDCWall (const std::string &stroke)
 Draws the outer CDCWall.
 
void drawInnerCDCWall (const std::string &stroke)
 Draws the inner CDCWall.
 
void drawHits (const std::string &storeArrayName, const std::string &stroke, const std::string &strokeWidth)
 Draws CDCHits.
 
void drawSimHits (const std::string &storeArrayName, const std::string &stroke, const std::string &strokeWidth)
 Draws CDCSimHits.
 
void drawClusters (const std::string &storeObjName, const std::string &stroke, const std::string &strokeWidth)
 Draws CDCWireHitClusters.
 
void drawSegments (const std::string &storeObjName, const std::string &stroke, const std::string &strokeWidth)
 Draws CDCSegments.
 
void drawSegmentTrajectories (const std::string &storeObjName, const std::string &stroke, const std::string &strokeWidth)
 Draws SegmentTrajectories.
 
void drawSegmentPairs (const std::string &storeObjName, const std::string &stroke, const std::string &strokeWidth)
 Draw the axial to stereo segment pairs.
 
void drawAxialSegmentPairs (const std::string &storeObjName, const std::string &stroke, const std::string &strokeWidth)
 Draw the axial to axial segment pairs.
 
void drawSegmentTriples (const std::string &storeObjName, const std::string &stroke, const std::string &strokeWidth)
 Draw the axial, stereo, axial segment triples.
 
void drawSegmentTripleTrajectories (const std::string &storeObjName, const std::string &stroke, const std::string &strokeWidth)
 Draw the trajectories of the axial, stereo, axial segment triples.
 
void drawTracks (const std::string &storeObjName, const std::string &stroke, const std::string &strokeWidth)
 Draws CDCTracks.
 
void drawTrackTrajectories (const std::string &storeObjName, const std::string &stroke, const std::string &strokeWidth)
 Draws trajectories of the tracks.
 
void drawRecoTracks (const std::string &storeArrayName, const std::string &stroke, const std::string &strokeWidth)
 Draw RecoTracks.
 
void drawRecoTrackTrajectories (const std::string &storeArrayName, const std::string &stroke, const std::string &strokeWidth)
 Draw RecoTracks trajectories.
 
void drawMCParticleTrajectories (const std::string &storeArrayName, const std::string &stroke, const std::string &strokeWidth)
 Draw MCParticles.
 
void drawWrongRLHitsInSegments (const std::string &segmentsStoreObjName)
 Draw the CDCRLWireHits in the CDCSegments colored by the match of the right left passage information.
 
void drawWrongRLHitsInTracks (const std::string &tracksStoreObjName)
 Draw the CDCRLWireHits in the CDCTracks colored by the match of the right left passage information.
 
void drawSimHitsConnectByToF (const std::string &simHitStoreArrayName, const std::string &stroke, const std::string &strokeWidth)
 Draw the CDCSimHits connected in the order of their getFlightTime for each Monte Carlo particle.
 
void drawMCSegmentPairs (const std::string &segmentsStoreObjName, const std::string &stroke, const std::string &strokeWidth)
 Draws the Monte Carlo true CDCSegmentPairs.
 
void drawMCAxialSegmentPairs (const std::string &segmentsStoreObjName, const std::string &stroke, const std::string &strokeWidth)
 Draws the Monte Carlo true CDCAxialSegmentPairs.
 
void drawMCSegmentTriples (const std::string &segmentsStoreObjName, const std::string &stroke, const std::string &strokeWidth)
 Draws the Monte Carlo true CDCSegmentTriples.
 
std::string saveFile (const std::string &fileName="display.svg")
 Save the current dom object representation to disk.
 

Private Member Functions

template<class ACDCHitCollection >
void drawWrongRLHits (const std::string &storeObjName)
 Draw the CDCRLWireHits in the ACDCHitCollection colored by the match of the right left passage information.
 
template<class AItem , bool a_drawTrajectories = false>
void drawStoreArray (const std::string &storeArrayName, Styling< AItem > &styling)
 Function Template for drawing the elements of a given StoreArray.
 
template<class AItem , bool a_drawTrajectories = false>
void drawStoreVector (const std::string &storeObjName, Styling< AItem > &styling)
 Function Template for drawing the elements of a given StoreVector.
 
template<bool a_drawTrajectory = false, class AIterable , class AStyling >
void drawIterable (const AIterable &items, AStyling &styling)
 Draw every element of an iterable object.
 
template<bool a_drawTrajectory = false, class AObject >
void draw (const AObject &object, const AttributeMap &attributeMap)
 Draws the object or its trajectory with the given attributes.
 

Private Attributes

EventDataPlotter m_eventdataPlotter
 The plotter instance to translate event data objects to svg expressions.
 

Detailed Description

Helper class to generated the svg image from the various tracking objects.

Definition at line 23 of file CDCSVGPlotter.h.

Constructor & Destructor Documentation

◆ CDCSVGPlotter()

CDCSVGPlotter ( bool  animate = false,
bool  forwardFade = false 
)

Constructor.

Definition at line 105 of file CDCSVGPlotter.cc.

105 :
106 m_eventdataPlotter(std::make_unique<SVGPrimitivePlotter>(c_defaultSVGAttributes), animate, forwardFade)
107{
108 int top = -112;
109 int left = -112;
110 int right = 112;
111 int bottom = 112;
112
113 TrackFindingCDC::BoundingBox default_bound(left, bottom, right, top);
114 int default_width = 1120;
115 int default_height = 1120;
116
117 m_eventdataPlotter.setBoundingBox(default_bound);
118 m_eventdataPlotter.setCanvasHeight(default_height);
119 m_eventdataPlotter.setCanvasWidth(default_width);
120}
A two dimensional rectangle that keeps track of the extend of a drawing.
Definition: BoundingBox.h:21
EventDataPlotter m_eventdataPlotter
The plotter instance to translate event data objects to svg expressions.
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.
void setCanvasWidth(float width)
Setter for the canvas width in pixels.

Member Function Documentation

◆ clone()

CDCSVGPlotter * clone ( )

Make a copy of the current status of the plotter.

Definition at line 122 of file CDCSVGPlotter.cc.

123{
124 return (new CDCSVGPlotter(*this));
125}
Helper class to generated the svg image from the various tracking objects.
Definition: CDCSVGPlotter.h:23

◆ drawAxialSegmentPairs()

void drawAxialSegmentPairs ( const std::string &  storeObjName,
const std::string &  stroke,
const std::string &  strokeWidth 
)

Draw the axial to axial segment pairs.

Parameters
storeObjNameThe name of the StoreVector containing the CDCAxialSegmentPairs.
strokeEither the color to be used for drawing or the name of the method, which maps the CDCAxialSegmentPair and its id to a color.
strokeWidthEither the stroke-width to be used for drawing or the name of the method, which maps the CDCAxialSegmentPair and its id to a stroke-width.

Definition at line 225 of file CDCSVGPlotter.cc.

228{
230 if (stroke != "") styling.setStroke(stroke);
231 if (strokeWidth != "") styling.setStrokeWidth(strokeWidth);
232 drawStoreVector<const CDCAxialSegmentPair>(storeObjName, styling);
233}
void setStrokeWidth(const std::string &mappingName)
Legacy method to set the mapping on how to match a object to the stroke width.
Definition: Styling.h:173
void setStroke(const std::string &mappingName)
Legacy method to set the mapping on how to match a object to the stroke color.
Definition: Styling.h:163
Class template for coloring objects with stroke colors prepared to be the default color cycle.
Definition: Styling.h:185

◆ drawClusters()

void drawClusters ( const std::string &  storeObjName,
const std::string &  stroke,
const std::string &  strokeWidth 
)

Draws CDCWireHitClusters.

Parameters
storeObjNameThe name of the StoreVector containing the CDCWireHitClusters.
strokeEither the color to be used for drawing or the name of the method, which maps the CDCHit and its id to a color.
strokeWidthEither the stroke-width to be used for drawing or the name of the method, which maps the CDCHit and its id to a stroke-width.

Definition at line 194 of file CDCSVGPlotter.cc.

197{
199 if (stroke != "") styling.setStroke(stroke);
200 if (strokeWidth != "") styling.setStrokeWidth(strokeWidth);
201 drawStoreVector<const CDCWireHitCluster>(storeObjName, styling);
202}

◆ drawHits()

void drawHits ( const std::string &  storeArrayName,
const std::string &  stroke,
const std::string &  strokeWidth 
)

Draws CDCHits.

Parameters
storeArrayNameThe name of the StoreArray containing the CDCHits.
strokeEither the color to be used for drawing or the name of the method, which maps the CDCHit and its id to a color.
strokeWidthEither the stroke-width to be used for drawing or the name of the method, which maps the CDCHit and its id to a stroke-width.

Definition at line 158 of file CDCSVGPlotter.cc.

161{
162 ChooseableHitStyling styling;
163 if (stroke != "") styling.setStroke(stroke);
164 if (strokeWidth != "") styling.setStrokeWidth(strokeWidth);
165 drawStoreArray<const CDCHit>(storeArrayName, styling);
166}
This Class handles the mapping from the colormapping-method name given as a string to the actual colo...
Definition: Styling.h:234

◆ drawInnerCDCWall()

void drawInnerCDCWall ( const std::string &  stroke)

Draws the inner CDCWall.

Parameters
strokeThe color to be used for drawing.

Definition at line 146 of file CDCSVGPlotter.cc.

147{
148 AttributeMap attributeMap;
149 attributeMap.emplace("stroke", stroke);
151}
void drawInnerCDCWall(const AttributeMap &attributeMap=AttributeMap())
Draw the inner wall of the CDC.

◆ drawInteractionPoint()

void drawInteractionPoint ( )

Draws the interaction point.

Definition at line 127 of file CDCSVGPlotter.cc.

128{
130}
void drawInteractionPoint()
Marks the position of the interaction point with a filled circle.

◆ drawIterable()

void drawIterable ( const AIterable &  items,
AStyling &  styling 
)
private

Draw every element of an iterable object.

Template Parameters
a_drawTrajectorySwitch to draw the fitted trajectory from the object instead.
Parameters
itemsAn iterable object (StoreArray, std::vector...).
stylingStyling object from which drawing attributes are constructed

◆ drawMCAxialSegmentPairs()

void drawMCAxialSegmentPairs ( const std::string &  segmentsStoreObjName,
const std::string &  stroke,
const std::string &  strokeWidth 
)

Draws the Monte Carlo true CDCAxialSegmentPairs.

This routine creates the true axial segment pairs from the stored segments to get an overview which cases the segment triple reconstruction should cover.

Parameters
segmentsStoreObjNameThe name of the StoreVector containing the CDCSegment2Ds, from which the pair should be constructed.
strokeColor of the lines to be drawn.
strokeWidthWidth of the lines to be drawn.

Definition at line 473 of file CDCSVGPlotter.cc.

476{
477 B2INFO("Draw axial to axial segment pairs");
478 StoreWrappedObjPtr<std::vector<CDCSegment2D>> storedSegments(segmentsStoreObjName);
479 if (not storedSegments) {
480 B2WARNING(segmentsStoreObjName << "does not exist in current DataStore");
481 printDataStoreContent();
482 return;
483 }
484
485 std::vector<CDCSegment2D>& segments = *storedSegments;
486 B2INFO("#Segments: " << segments.size());
487
488 std::vector<const CDCAxialSegment2D*> axialSegments;
489 for (const CDCAxialSegment2D& segment : segments) {
490 if (segment.isAxial()) axialSegments.push_back(&segment);
491 }
492
493 MCAxialSegmentPairFilter mcAxialSegmentPairFilter;
494 std::vector<CDCAxialSegmentPair> mcAxialSegmentPairs;
495 for (const CDCAxialSegment2D* fromSegment : axialSegments) {
496 for (const CDCAxialSegment2D* toSegment : axialSegments) {
497 if (fromSegment == toSegment) continue;
498 mcAxialSegmentPairs.emplace_back(fromSegment, toSegment);
499 Weight mcWeight = mcAxialSegmentPairFilter(mcAxialSegmentPairs.back());
500 // Remove segment pairs that are not true
501 if (std::isnan(mcWeight)) {
502 mcAxialSegmentPairs.pop_back();
503 }
504 }
505 }
506 B2INFO("# Axial segment pairs: " << mcAxialSegmentPairs.size());
508 if (stroke != "") styling.setStroke(stroke);
509 if (strokeWidth != "") styling.setStroke(strokeWidth);
510 drawIterable(mcAxialSegmentPairs, styling);
511}
void drawIterable(const AIterable &items, AStyling &styling)
Draw every element of an iterable object.
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
Implementation of a styling from fixed attribute map.
Definition: Styling.h:54
void setStroke(const std::string &value)
Legacy - Sets the stroke color to the fixed value.
Definition: Styling.h:81
Filter for the construction of axial to axial segment pairs based on simple criteria.
This class is for convenience access and registration of objects, that are stored inside the StoreWra...

◆ drawMCParticleTrajectories()

void drawMCParticleTrajectories ( const std::string &  storeArrayName,
const std::string &  stroke,
const std::string &  strokeWidth 
)

Draw MCParticles.

Parameters
storeArrayNameThe name of the StoreArray containing the RecoTracks.
strokeEither the color to be used for drawing or the name of the method, which maps the CDCHit and its id to a color.
strokeWidthEither the stroke-width to be used for drawing or the name of the method, which maps the CDCHit and its id to a stroke-width.

Definition at line 308 of file CDCSVGPlotter.cc.

311{
313 if (stroke != "") styling.setStroke(stroke);
314 if (strokeWidth != "") styling.setStrokeWidth(strokeWidth);
315 const bool drawTrajectories = true;
316 drawStoreArray<const MCParticle, drawTrajectories>(storeArrayName, styling);
317}

◆ drawMCSegmentPairs()

void drawMCSegmentPairs ( const std::string &  segmentsStoreObjName,
const std::string &  stroke,
const std::string &  strokeWidth 
)

Draws the Monte Carlo true CDCSegmentPairs.

This routine creates the true segment pairs from the stored segments to get an overview which cases the segment triple reconstruction should cover.

Parameters
segmentsStoreObjNameThe name of the StoreVector containing the CDCSegment2Ds, from which the pair should be constructed.
strokeColor of the lines to be drawn.
strokeWidthWidth of the lines to be drawn.

Definition at line 513 of file CDCSVGPlotter.cc.

516{
517 B2INFO("Draw axial to stero segment pairs");
518 StoreWrappedObjPtr<std::vector<CDCSegment2D>> storedSegments(segmentsStoreObjName);
519 if (not storedSegments) {
520 B2WARNING(segmentsStoreObjName << "does not exist in current DataStore");
521 printDataStoreContent();
522 return;
523 }
524
525 std::vector<CDCSegment2D>& segments = *storedSegments;
526 B2INFO("#Segments: " << segments.size());
527
528 std::vector<const CDCAxialSegment2D*> axialSegments;
529 std::vector<const CDCStereoSegment2D*> stereoSegments;
530 for (const CDCAxialSegment2D& segment : segments) {
531 if (segment.isAxial()) {
532 axialSegments.push_back(&segment);
533 } else {
534 stereoSegments.push_back(&segment);
535 }
536 }
537
538 MCSegmentPairFilter mcSegmentPairFilter;
539 std::vector<CDCSegmentPair> mcSegmentPairs;
540 for (const CDCAxialSegment2D* axialSegment : axialSegments) {
541 for (const CDCStereoSegment2D* stereoSegment : stereoSegments) {
542 // Axial first
543 {
544 mcSegmentPairs.emplace_back(axialSegment, stereoSegment);
545 Weight mcWeight = mcSegmentPairFilter(mcSegmentPairs.back());
546 // Remove segment pairs that are not true
547 if (std::isnan(mcWeight)) {
548 mcSegmentPairs.pop_back();
549 }
550 }
551 // Stereo first
552 {
553 mcSegmentPairs.emplace_back(stereoSegment, axialSegment);
554 Weight mcWeight = mcSegmentPairFilter(mcSegmentPairs.back());
555 // Remove segment pairs that are not true
556 if (std::isnan(mcWeight)) {
557 mcSegmentPairs.pop_back();
558 }
559 }
560 }
561 }
562 B2INFO("# Segment pairs: " << mcSegmentPairs.size());
564 if (stroke != "") styling.setStroke(stroke);
565 if (strokeWidth != "") styling.setStroke(strokeWidth);
566 drawIterable(mcSegmentPairs, styling);
567}
Filter for the construction of axial to stereo segment pairs based on MC information.

◆ drawMCSegmentTriples()

void drawMCSegmentTriples ( const std::string &  segmentsStoreObjName,
const std::string &  stroke,
const std::string &  strokeWidth 
)

Draws the Monte Carlo true CDCSegmentTriples.

This routine creates the true segment triples from the stored segments to get an overview which cases the segment triple reconstruction should cover.

Parameters
segmentsStoreObjNameThe name of the StoreVector containing the CDCSegment2Ds, from which the pair should be constructed.
strokeColor of the lines to be drawn.
strokeWidthWidth of the lines to be drawn.

Definition at line 569 of file CDCSVGPlotter.cc.

572{
573 B2INFO("Draw segment triples");
574 StoreWrappedObjPtr<std::vector<CDCSegment2D>> storedSegments(segmentsStoreObjName);
575 if (not storedSegments) {
576 B2WARNING(segmentsStoreObjName << "does not exist in current DataStore");
577 printDataStoreContent();
578 return;
579 }
580
581 std::vector<CDCSegment2D>& segments = *storedSegments;
582 B2INFO("#Segment " << segments.size());
583
584 std::vector<const CDCAxialSegment2D*> axialSegments;
585 std::vector<const CDCStereoSegment2D*> stereoSegments;
586 for (const CDCSegment2D& segment : segments) {
587 if (segment.isAxial()) {
588 axialSegments.push_back(&segment);
589 } else {
590 stereoSegments.push_back(&segment);
591 }
592 }
593
594 MCSegmentTripleFilter mcSegmentTripleFilter;
595 std::vector<CDCSegmentTriple> mcSegmentTriples;
596 for (const CDCAxialSegment2D* startSegment : axialSegments) {
597 for (const CDCStereoSegment2D* middleSegment : stereoSegments) {
598 for (const CDCAxialSegment2D* endSegment : axialSegments) {
599 if (startSegment == endSegment) continue;
600 mcSegmentTriples.emplace_back(startSegment, middleSegment, endSegment);
601 Weight mcWeight = mcSegmentTripleFilter(mcSegmentTriples.back());
602 // Remove segment pairs that are not true
603 if (std::isnan(mcWeight)) {
604 mcSegmentTriples.pop_back();
605 }
606 }
607 }
608 }
609 B2INFO("# Segment triples: " << mcSegmentTriples.size());
611 if (stroke != "") styling.setStroke(stroke);
612 if (strokeWidth != "") styling.setStroke(strokeWidth);
613 drawIterable(mcSegmentTriples, styling);
614}
Filter for the construction of segment triples based on Monte Carlo information.

◆ drawOuterCDCWall()

void drawOuterCDCWall ( const std::string &  stroke)

Draws the outer CDCWall.

Parameters
strokeThe color to be used for drawing.

Definition at line 139 of file CDCSVGPlotter.cc.

140{
141 AttributeMap attributeMap;
142 attributeMap.emplace("stroke", stroke);
144}
void drawOuterCDCWall(const AttributeMap &attributeMap=AttributeMap())
Draw the outer wall of the CDC.

◆ drawRecoTracks()

void drawRecoTracks ( const std::string &  storeArrayName,
const std::string &  stroke,
const std::string &  strokeWidth 
)

Draw RecoTracks.

Parameters
storeArrayNameThe name of the StoreArray containing the RecoTracks.
strokeEither the color to be used for drawing or the name of the method, which maps the CDCHit and its id to a color.
strokeWidthEither the stroke-width to be used for drawing or the name of the method, which maps the CDCHit and its id to a stroke-width.

Definition at line 287 of file CDCSVGPlotter.cc.

290{
292 if (stroke != "") styling.setStroke(stroke);
293 if (strokeWidth != "") styling.setStrokeWidth(strokeWidth);
294 drawStoreArray<const RecoTrack>(storeArrayName, styling);
295}
This Class handles the mapping from the colormapping-method name given as a string to the actual colo...
Definition: Styling.h:198

◆ drawRecoTrackTrajectories()

void drawRecoTrackTrajectories ( const std::string &  storeArrayName,
const std::string &  stroke,
const std::string &  strokeWidth 
)

Draw RecoTracks trajectories.

Parameters
storeArrayNameThe name of the StoreArray containing the RecoTracks.
strokeEither the color to be used for drawing or the name of the method, which maps the CDCHit and its id to a color.
strokeWidthEither the stroke-width to be used for drawing or the name of the method, which maps the CDCHit and its id to a stroke-width.

Definition at line 297 of file CDCSVGPlotter.cc.

300{
302 if (stroke != "") styling.setStroke(stroke);
303 if (strokeWidth != "") styling.setStrokeWidth(strokeWidth);
304 const bool drawTrajectories = true;
305 drawStoreArray<const RecoTrack, drawTrajectories>(storeArrayName, styling);
306}

◆ drawSegmentPairs()

void drawSegmentPairs ( const std::string &  storeObjName,
const std::string &  stroke,
const std::string &  strokeWidth 
)

Draw the axial to stereo segment pairs.

Parameters
storeObjNameThe name of the StoreVector containing the CDCSegmentPairs.
strokeEither the color to be used for drawing or the name of the method, which maps the CDCSegmentPair and its id to a color.
strokeWidthEither the stroke-width to be used for drawing or the name of the method, which maps the CDCSegmentPair and its id to a stroke-width.

Definition at line 235 of file CDCSVGPlotter.cc.

238{
240 if (stroke != "") styling.setStroke(stroke);
241 if (strokeWidth != "") styling.setStrokeWidth(strokeWidth);
242 drawStoreVector<const CDCSegmentPair>(storeObjName, styling);
243}

◆ drawSegments()

void drawSegments ( const std::string &  storeObjName,
const std::string &  stroke,
const std::string &  strokeWidth 
)

Draws CDCSegments.

Parameters
storeObjNameThe name of the StoreVector containing the CDCSegments.
strokeEither the color to be used for drawing or the name of the method, which maps the CDCHit and its id to a color.
strokeWidthEither the stroke-width to be used for drawing or the name of the method, which maps the CDCHit and its id to a stroke-width.

Definition at line 204 of file CDCSVGPlotter.cc.

207{
209 if (stroke != "") styling.setStroke(stroke);
210 if (strokeWidth != "") styling.setStrokeWidth(strokeWidth);
211 drawStoreVector<const CDCSegment2D>(storeObjName, styling);
212}
This Class handles the mapping from the colormapping-method name given as a string to the actual ACol...
Definition: Styling.h:216

◆ drawSegmentTrajectories()

void drawSegmentTrajectories ( const std::string &  storeObjName,
const std::string &  stroke,
const std::string &  strokeWidth 
)

Draws SegmentTrajectories.

Parameters
storeObjNameThe name of the StoreVector containing the CDCSegments.
strokeEither the color to be used for drawing or the name of the method, which maps the CDCHit and its id to a color.
strokeWidthEither the stroke-width to be used for drawing or the name of the method, which maps the CDCHit and its id to a stroke-width.

Definition at line 214 of file CDCSVGPlotter.cc.

217{
219 if (stroke != "") styling.setStroke(stroke);
220 if (strokeWidth != "") styling.setStrokeWidth(strokeWidth);
221 const bool drawTrajectories = true;
222 drawStoreVector<const CDCSegment2D, drawTrajectories>(storeObjName, styling);
223}
void setStrokeWidth(const std::string &value)
Legacy - Sets the stroke width to the fixed value.
Definition: Styling.h:87

◆ drawSegmentTriples()

void drawSegmentTriples ( const std::string &  storeObjName,
const std::string &  stroke,
const std::string &  strokeWidth 
)

Draw the axial, stereo, axial segment triples.

Parameters
storeObjNameThe name of the StoreVector containing the CDCSegmentTriples.
strokeEither the color to be used for drawing or the name of the method, which maps the CDCSegmentTriple and its id to a color.
strokeWidthEither the stroke-width to be used for drawing or the name of the method, which maps the CDCSegmentTriple and its id to a stroke-width.

Definition at line 245 of file CDCSVGPlotter.cc.

248{
250 if (stroke != "") styling.setStroke(stroke);
251 if (strokeWidth != "") styling.setStrokeWidth(strokeWidth);
252 drawStoreVector<const CDCSegmentTriple>(storeObjName, styling);
253}

◆ drawSegmentTripleTrajectories()

void drawSegmentTripleTrajectories ( const std::string &  storeObjName,
const std::string &  stroke,
const std::string &  strokeWidth 
)

Draw the trajectories of the axial, stereo, axial segment triples.

Parameters
storeObjNameThe name of the StoreVector containing the CDCSegmentTriples.
strokeEither the color to be used for drawing or the name of the method, which maps the CDCSegmentTriple and its id to a color.
strokeWidthEither the stroke-width to be used for drawing or the name of the method, which maps the CDCSegmentTriple and its id to a stroke-width.

Definition at line 255 of file CDCSVGPlotter.cc.

258{
260 if (stroke != "") styling.setStroke(stroke);
261 if (strokeWidth != "") styling.setStrokeWidth(strokeWidth);
262 const bool drawTrajectories = true;
263 drawStoreVector<const CDCSegmentTriple, drawTrajectories>(storeObjName, styling);
264}

◆ drawSimHits()

void drawSimHits ( const std::string &  storeArrayName,
const std::string &  stroke,
const std::string &  strokeWidth 
)

Draws CDCSimHits.

Parameters
storeArrayNameThe name of the StoreArray containing the CDCSimHits.
strokeEither the color to be used for drawing or the name of the method, which maps the CDCSimHit and its id to a color.
strokeWidthEither the stroke-width to be used for drawing or the name of the method, which maps the CDCSimHit and its id to a stroke-width.

Definition at line 168 of file CDCSVGPlotter.cc.

171{
172 B2INFO("Drawing simulated hits");
173 StoreArray<CDCHit> storeArray(storeArrayName);
174 if (not storeArray) {
175 B2WARNING("StoreArray " << storeArrayName << " not present");
176 printDataStoreContent();
177 return;
178 }
179 std::vector<CDCSimHit> simHitsRelatedToHits;
180 for (const CDCHit& hit : storeArray) {
181 simHitsRelatedToHits.push_back(*hit.getRelated<CDCSimHit>("CDCSimHits"));
182 }
183 B2INFO("#CDCSimHits: " << storeArray.getEntries());
185 if (stroke != "") {
186 styling.setStroke("orange");
187 } else {
188 styling.setStroke(stroke);
189 }
190 styling.setStrokeWidth(strokeWidth);
191 drawIterable(simHitsRelatedToHits, styling);
192}
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
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113

◆ drawSimHitsConnectByToF()

void drawSimHitsConnectByToF ( const std::string &  simHitStoreArrayName,
const std::string &  stroke,
const std::string &  strokeWidth 
)

Draw the CDCSimHits connected in the order of their getFlightTime for each Monte Carlo particle.

Parameters
simHitStoreArrayNameThe name of the StoreArray containing the CDCSimHits.
strokeColor of the lines to be drawn.
strokeWidthWidth of the lines to be drawn.

Definition at line 319 of file CDCSVGPlotter.cc.

322{
323 B2INFO("Drawing simulated hits connected by tof");
324 StoreArray<CDCHit> hitStoreArray(hitStoreArrayName);
325 if (not hitStoreArray) {
326 B2WARNING("StoreArray " << hitStoreArrayName << " not present");
327 printDataStoreContent();
328 return;
329 }
330 std::vector<CDCSimHit*> simHits;
331 for (const CDCHit& hit : hitStoreArray) {
332 simHits.push_back(hit.getRelated<CDCSimHit>());
333 }
334
335 // group them by their mcparticle id
336 std::map<int, std::set<CDCSimHit*, FlightTimeOrder>> simHitsByMcParticleId;
337 for (CDCSimHit* simHit : simHits) {
338 MCParticle* mcParticle = simHit->getRelated<MCParticle>();
339 if (mcParticle != nullptr) {
340 int mcTrackId = mcParticle->getArrayIndex();
341 simHitsByMcParticleId[mcTrackId].insert(simHit);
342 }
343 }
344
345 AttributeMap defaultAttributeMap = {{"stroke", stroke}, {"stroke-width", strokeWidth}};
346
347 for (const auto& mcParticleIdAndSimHits : simHitsByMcParticleId) {
348 const std::set<CDCSimHit*, FlightTimeOrder>& simHitsForMcParticle =
349 mcParticleIdAndSimHits.second;
350
351 auto drawConnectSimHits = [this, &defaultAttributeMap](CDCSimHit * fromSimHit, CDCSimHit * toSimHit) {
352
353 CDCHit* fromHit = fromSimHit->getRelated<CDCHit>();
354 CDCHit* toHit = toSimHit->getRelated<CDCHit>();
355 if (fromHit == nullptr) return false;
356 if (toHit == nullptr) return false;
357
358 CDCWireHit fromWireHit(fromHit);
359 CDCWireHit toWireHit(toHit);
360
361 CDCRLWireHit fromRLWireHit(&fromWireHit);
362 CDCRLWireHit toRLWireHit(&toWireHit);
363
364 Vector3D fromDisplacement(fromSimHit->getPosTrack() - fromSimHit->getPosWire());
365 Vector3D toDisplacement(toSimHit->getPosTrack() - toSimHit->getPosWire());
366
367 CDCRecoHit2D fromRecoHit2D(fromRLWireHit, fromDisplacement.xy());
368 CDCRecoHit2D toRecoHit2D(toRLWireHit, toDisplacement.xy());
369
370 bool falseOrder = false;
371 if (fromSimHit->getArrayIndex() > toSimHit->getArrayIndex()) {
372 bool fromReassigned = fromHit->getRelatedWithWeight<MCParticle>().second < 0;
373 bool toReassigned = toHit->getRelatedWithWeight<MCParticle>().second < 0;
374 if (not fromReassigned and not toReassigned) {
375 falseOrder = true;
376 }
377 }
378
379 AttributeMap attributeMap = defaultAttributeMap;
380 if (falseOrder) {
381 attributeMap["stroke"] = "red";
382 attributeMap["stroke-width"] = "1.0";
383 }
384 draw(fromRecoHit2D, attributeMap);
385 draw(toRecoHit2D, attributeMap);
386
387 const Vector2D fromPos = fromRecoHit2D.getRecoPos2D();
388 const float fromX = fromPos.x();
389 const float fromY = fromPos.y();
390
391 const Vector2D toPos = toRecoHit2D.getRecoPos2D();
392 const float toX = toPos.x();
393 const float toY = toPos.y();
394
395 m_eventdataPlotter.drawLine(fromX, fromY, toX, toY, attributeMap);
396 return false;
397 };
398
399 std::ignore = std::adjacent_find(simHitsForMcParticle.begin(),
400 simHitsForMcParticle.end(),
401 drawConnectSimHits);
402 }
403}
B2Vector3D getPosWire() const
The method to get position on wire.
Definition: CDCSimHit.h:199
B2Vector3D getPosTrack() const
The method to get position on the track.
Definition: CDCSimHit.h:217
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
int getArrayIndex() const
Get 0-based index of the particle in the corresponding MCParticle list.
Definition: MCParticle.h:244
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
std::pair< T *, float > getRelatedWithWeight(const std::string &name="", const std::string &namedRelation="") const
Get first related object & weight of relation pointing from/to an array.
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
Definition: CDCRLWireHit.h:41
Class representing a two dimensional reconstructed hit in the central drift chamber.
Definition: CDCRecoHit2D.h:47
void draw(const AObject &object, const AttributeMap &attributeMap)
Draws the object or its trajectory with the given attributes.
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:55
void drawLine(float startX, float startY, float endX, float endY, const AttributeMap &attributeMap=AttributeMap())
Draws a straight Line.
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
Definition: Vector2D.h:32
double x() const
Getter for the x coordinate.
Definition: Vector2D.h:595
double y() const
Getter for the y coordinate.
Definition: Vector2D.h:605
A three dimensional vector.
Definition: Vector3D.h:33

◆ drawStoreArray()

void drawStoreArray ( const std::string &  storeArrayName,
Styling< AItem > &  styling 
)
private

Function Template for drawing the elements of a given StoreArray.

Needs to know the type of the objects in the StoreArray and the right styling for these objects.

Template Parameters
a_drawTrajectoriesSwitch to draw the fitted trajectory from the object instead.
Parameters
storeArrayNameThe name of the StoreArray containing the objects.
stylingFunctional object to construct attributes for each object to be drawn

◆ drawStoreVector()

void drawStoreVector ( const std::string &  storeObjName,
Styling< AItem > &  styling 
)
private

Function Template for drawing the elements of a given StoreVector.

Needs to know the type of the objects in the store objects and the right styling for these objects.

Template Parameters
a_drawTrajectoriesSwitch to draw the fitted trajectory from the object instead.
Parameters
storeObjNamename of the StoreObject containing the objects.
stylingFunctional object to construct attributes for each object to be drawn

◆ drawSuperLayerBoundaries()

void drawSuperLayerBoundaries ( const std::string &  stroke)

Draws the individual super layer boundaries.

Parameters
strokeThe color to be used for drawing.

Definition at line 132 of file CDCSVGPlotter.cc.

133{
134 AttributeMap attributeMap;
135 attributeMap.emplace("stroke", stroke);
137}
void drawSuperLayerBoundaries(const AttributeMap &attributeMap=AttributeMap())
Draw the super layer bounds of the CDC.

◆ drawTracks()

void drawTracks ( const std::string &  storeObjName,
const std::string &  stroke,
const std::string &  strokeWidth 
)

Draws CDCTracks.

Parameters
storeObjNameThe name of the StoreVector containing the CDCTracks.
strokeEither the color to be used for drawing or the name of the method, which maps the CDCSegmentTriple and its id to a color.
strokeWidthEither the stroke-width to be used for drawing or the name of the method, which maps the CDCSegmentTriple and its id to a stroke-width.

Definition at line 266 of file CDCSVGPlotter.cc.

269{
271 if (stroke != "") styling.setStroke(stroke);
272 if (strokeWidth != "") styling.setStrokeWidth(strokeWidth);
273 drawStoreVector<const CDCTrack>(storeObjName, styling);
274}

◆ drawTrackTrajectories()

void drawTrackTrajectories ( const std::string &  storeObjName,
const std::string &  stroke,
const std::string &  strokeWidth 
)

Draws trajectories of the tracks.

Parameters
storeObjNameThe name of the StoreVector containing the CDCTracks.
strokeEither the color to be used for drawing or the name of the method, which maps the CDCHit and its id to a color.
strokeWidthEither the stroke-width to be used for drawing or the name of the method, which maps the CDCHit and its id to a stroke-width.

Definition at line 276 of file CDCSVGPlotter.cc.

279{
281 if (stroke != "") styling.setStroke(stroke);
282 if (strokeWidth != "") styling.setStrokeWidth(strokeWidth);
283 const bool drawTrajectories = true;
284 drawStoreVector<const CDCTrack, drawTrajectories>(storeObjName, styling);
285}

◆ drawWires()

void drawWires ( const CDCWireTopology cdcWireTopology)

Draws the wires.

Definition at line 153 of file CDCSVGPlotter.cc.

154{
155 m_eventdataPlotter.draw(cdcWireTopology);
156}
void draw(const Belle2::TrackFindingCDC::Circle2D &circle, AttributeMap attributeMap=AttributeMap())
Draws a filled circle.

◆ drawWrongRLHits()

void drawWrongRLHits ( const std::string &  storeObjName)
private

Draw the CDCRLWireHits in the ACDCHitCollection colored by the match of the right left passage information.

It respects hit collections reconstructed backwards to have the opposite rl information.

◆ drawWrongRLHitsInSegments()

void drawWrongRLHitsInSegments ( const std::string &  segmentsStoreObjName)

Draw the CDCRLWireHits in the CDCSegments colored by the match of the right left passage information.

It respects segments reconstructed backwards to have the opposite rl information

Definition at line 405 of file CDCSVGPlotter.cc.

406{
407 this->drawWrongRLHits<CDCSegment2D>(segmentsStoreObjName);
408}

◆ drawWrongRLHitsInTracks()

void drawWrongRLHitsInTracks ( const std::string &  tracksStoreObjName)

Draw the CDCRLWireHits in the CDCTracks colored by the match of the right left passage information.

It respects tracks reconstructed backwards to have the opposite rl information

Definition at line 410 of file CDCSVGPlotter.cc.

411{
412 this->drawWrongRLHits<CDCTrack>(tracksStoreObjName);
413}

◆ saveFile()

std::string saveFile ( const std::string &  fileName = "display.svg")

Save the current dom object representation to disk.

Parameters
fileNameThe Name of the saved file. Defaults to "display.svg".

Definition at line 616 of file CDCSVGPlotter.cc.

617{
619
620 float height = boundingBox.getHeight();
621 float width = boundingBox.getWidth();
622
623 int totalPoints = 1120 * 1120;
624 float svgHeight = roundf(sqrt(totalPoints * height / width));
625 float svgWidth = roundf(sqrt(totalPoints * width / height));
626
629
630 return (m_eventdataPlotter.save(fileName));
631}
float getWidth() const
Getter for the width of the bounding box rectangle.
Definition: BoundingBox.h:63
float getHeight() const
Getter for the height of the bounding box rectangle.
Definition: BoundingBox.h:67
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.
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28

Member Data Documentation

◆ m_eventdataPlotter

EventDataPlotter m_eventdataPlotter
private

The plotter instance to translate event data objects to svg expressions.

Definition at line 330 of file CDCSVGPlotter.h.


The documentation for this class was generated from the following files: