374 def __call__(self, root_file):
375 hist = find_histo(root_file, self.input_hist)
376 if not hist:
377 if crash_on_error:
378 raise RuntimeError(f"Histogram '{self.input_hist}' not found.")
379 else:
380 logging.error(f"Histogram '{self.input_hist}' not found.")
381 return
382
383 b1, b2 = hist.GetYaxis().FindBin(self.bins_x[0]), hist.GetYaxis().FindBin(self.bins_x[1])
384 b3, b4 = hist.GetXaxis().FindBin(self.bins_y[0]), hist.GetXaxis().FindBin(self.bins_y[1])
385
386 path_parts = self.output.
strip(
"/").
split(
"/")
387 *dir_path, output_name = path_parts
388 directory_path = "/".join(dir_path)
389 ensure_directory_exists(root_file, directory_path)
390 root_file.cd(directory_path)
391
392 if self.x_proj:
393 proj_x = hist.ProjectionX(output_name, b1, b2).Clone(output_name)
394 self.project(proj_x, hist.GetXaxis().GetTitle(), "X")
395 if self.y_proj:
396 proj_y = hist.ProjectionY(output_name, b3, b4).Clone(output_name)
397 self.project(proj_y, hist.GetYaxis().GetTitle(), "Y")
398
std::vector< std::string > split(const std::string &s, const std::string &t=":")