14 from ROOT
import gSystem
17 from ROOT
import Belle2
19 gSystem.Load(
'libtracking_trackFindingCDC')
25 Helper class to generated the svg image from the various tracking objects.
26 This is a tiny wrapper around the TrackFindingCDC.EventDataPlotter.
32 @param animate switch indicating if an animated SVG should be generated
54 Make a copy of the current status of the plotter.
62 Transfer the styling information to the attribute map
66 for key, value
in list(styling.items()):
67 attribute_map[str(key)] = str(value)
73 Draw the CDC superlayer boundaries
80 Draw the interaction point
86 Draw the CDC outer wall
93 Draw the CDC inner wall
100 """Mapping function to unpack the attributes from the attribute maps. Mechanism and interface inspired by d3.js"""
102 for (key, value)
in list(styling.items()):
103 if isinstance(value, collections.Callable):
104 result[key] = value(i_obj, obj)
105 elif isinstance(value, str):
107 elif hasattr(value,
'__getitem__'):
108 result[key] = value[i_obj % len(value)]
115 Draw one or more items with the specified styling
119 for (i_obj, obj)
in enumerate(iterable):
121 draw(obj, **obj_styling)
125 Draw information in a vector from the DataStore with the specified styling
127 print(
'Drawing vector from DataStore:', storeobj_name, end=
' ')
133 wrapped_vector = pystoreobj.obj()
134 vector = wrapped_vector.get()
136 print(
'with', vector.size(),
'entries')
137 print(
'Attributes are')
138 for (key, value)
in list(styling.items()):
139 print(str(key),
':', str(value))
144 print(
"### not present in the DataStore")
145 print(
"Current content of the DataStore")
146 print(
"StoreArrays:")
148 print(
"StoreObjPtr:")
153 Draw information from a StoreArray with the specified styling
155 print(
'Drawing StoreArray:', storearray_name, end=
' ')
159 print(
'with', storearray.getEntries(),
'entries')
160 print(
'Attributes are')
161 for (key, value)
in list(styling.items()):
162 print(str(key),
':', str(value))
167 print(
"### not present in the DataStore")
168 print(
"Current content of the DataStore")
169 print(
"StoreArrays:")
171 print(
"StoreObjPtr:")
174 def draw(self, obj, **styling):
176 Draw an object with the specified styling
183 Save the current dom object representation to disk.
188 boundingBox = eventdata_plotter.getBoundingBox()
190 height = boundingBox.getHeight()
191 width = boundingBox.getWidth()
193 totalPoints = 1120 * 1120
194 svgHeight = round(math.sqrt(totalPoints * float(height) / width))
195 svgWidth = round(math.sqrt(totalPoints * float(width) / height))
197 eventdata_plotter.setCanvasHeight(svgHeight)
198 eventdata_plotter.setCanvasWidth(svgWidth)
200 return eventdata_plotter.save(svgFileName)
204 Save the current dom object representation to disk as a png.
210 temp_file_name =
"tmp.svg"
213 boundingBox = eventdata_plotter.getBoundingBox()
215 height = boundingBox.getHeight()
216 width = boundingBox.getWidth()
218 totalPoints = 1120 * 1120
219 svgHeight = round(math.sqrt(totalPoints * float(height) / width))
220 svgWidth = round(math.sqrt(totalPoints * float(width) / height))
222 eventdata_plotter.setCanvasHeight(svgHeight)
223 eventdata_plotter.setCanvasWidth(svgWidth)
225 eventdata_plotter.save(temp_file_name)
227 with open(temp_file_name,
"r")
as temp_file:
228 with open(pngFileName,
"w")
as output_file:
229 svg_code = temp_file.read()
230 cairosvg.svg2png(bytestring=svg_code, write_to=output_file)
232 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)