13from ROOT
import gSystem
16from ROOT
import Belle2
18gSystem.Load(
'libtracking_trackFindingCDC')
24 Helper class to generated the svg image from the various
tracking objects.
25 This
is a tiny wrapper around the TrackFindingCDC.EventDataPlotter.
31 @param animate switch indicating
if an animated SVG should be generated
53 Make a copy of the current status of the plotter.
61 Transfer the styling information to the attribute map
65 for key, value
in list(styling.items()):
66 attribute_map[str(key)] = str(value)
72 Draw the CDC superlayer boundaries
79 Draw the interaction point
85 Draw the CDC outer wall
92 Draw the CDC inner wall
99 """Mapping function to unpack the attributes from the attribute maps. Mechanism and interface inspired by d3.js"""
101 for (key, value)
in list(styling.items()):
102 if isinstance(value, collections.abc.Callable):
103 result[key] = value(i_obj, obj)
104 elif isinstance(value, str):
106 elif hasattr(value,
'__getitem__'):
107 result[key] = value[i_obj % len(value)]
114 Draw one or more items
with the specified styling
118 for (i_obj, obj)
in enumerate(iterable):
120 draw(obj, **obj_styling)
124 Draw information in a vector
from the DataStore
with the specified styling
126 print('Drawing vector from DataStore:', storeobj_name, end=
' ')
132 wrapped_vector = pystoreobj.obj()
133 vector = wrapped_vector.get()
135 print(
'with', vector.size(),
'entries')
136 print(
'Attributes are')
137 for (key, value)
in list(styling.items()):
138 print(str(key),
':', str(value))
143 print(
"### not present in the DataStore")
144 print(
"Current content of the DataStore")
145 print(
"StoreArrays:")
147 print(
"StoreObjPtr:")
152 Draw information from a StoreArray
with the specified styling
154 print('Drawing StoreArray:', storearray_name, end=
' ')
158 print(
'with', storearray.getEntries(),
'entries')
159 print(
'Attributes are')
160 for (key, value)
in list(styling.items()):
161 print(str(key),
':', str(value))
166 print(
"### not present in the DataStore")
167 print(
"Current content of the DataStore")
168 print(
"StoreArrays:")
170 print(
"StoreObjPtr:")
173 def draw(self, obj, **styling):
175 Draw an object with the specified styling
182 Save the current dom object representation to disk.
187 boundingBox = eventdata_plotter.getBoundingBox()
189 height = boundingBox.getHeight()
190 width = boundingBox.getWidth()
192 totalPoints = 1120 * 1120
193 svgHeight = round(math.sqrt(totalPoints * float(height) / width))
194 svgWidth = round(math.sqrt(totalPoints * float(width) / height))
196 eventdata_plotter.setCanvasHeight(svgHeight)
197 eventdata_plotter.setCanvasWidth(svgWidth)
199 return eventdata_plotter.save(svgFileName)
203 Save the current dom object representation to disk as a png.
209 temp_file_name =
"tmp.svg"
212 boundingBox = eventdata_plotter.getBoundingBox()
214 height = boundingBox.getHeight()
215 width = boundingBox.getWidth()
217 totalPoints = 1120 * 1120
218 svgHeight = round(math.sqrt(totalPoints * float(height) / width))
219 svgWidth = round(math.sqrt(totalPoints * float(width) / height))
221 eventdata_plotter.setCanvasHeight(svgHeight)
222 eventdata_plotter.setCanvasWidth(svgWidth)
224 eventdata_plotter.save(temp_file_name)
226 with open(temp_file_name)
as temp_file:
227 with open(pngFileName,
"w")
as output_file:
228 svg_code = temp_file.read()
229 cairosvg.svg2png(bytestring=svg_code, write_to=output_file)
231 os.remove(temp_file_name)
A (simplified) python wrapper for StoreArray.
static void printList(DataStore::EDurability durability=DataStore::EDurability::c_Event)
Print list of available arrays for given durability.
a (simplified) python wrapper for StoreObjPtr.
static void printList(DataStore::EDurability durability=DataStore::EDurability::c_Event)
Print list of available objects for given durability.
A two dimensional rectangle that keeps track of the extend of a drawing.
A class that can plot event related data types.
Belle2::TrackFindingCDC::AttributeMap AttributeMap
A map type for attributes names to values for additional drawing information.
def draw_storevector(self, storeobj_name, **styling)
def saveSVGFile(self, svgFileName='display.svg')
def draw_storearray(self, storearray_name, **styling)
def draw_superlayer_boundaries(self, **styling)
eventdata_plotter
Display the image using the event-data plotter.
def draw_inner_cdc_wall(self, **styling)
def savePNGFile(self, pngFileName='display.png')
def draw_interaction_point(self)
def draw(self, obj, **styling)
animate
Switch to indicating if an animated SVG should be generated.
def draw_iterable(self, iterable, **styling)
def draw_outer_cdc_wall(self, **styling)
def styling_to_attribute_map(self, **styling)
def __init__(self, animate=False)
def unpack_attributes(styling, i_obj=0, obj=None)