|
ATLAS Offline Software
|
Go to the documentation of this file.
7 #ifndef CALORECGPU_STANDALONEDATAIO_H
8 #define CALORECGPU_STANDALONEDATAIO_H
35 std::cerr <<
"ERROR: when " << kind <<
" from '" <<
file <<
"'." << std::endl;
51 std::ifstream in(
file.native(), std::ios_base::binary);
66 std::ifstream in(
file.native(), std::ios_base::binary);
67 noise.binary_input(in);
81 file.replace_extension(
".geometry");
82 std::ofstream
out(
file, std::ios_base::binary);
97 file.replace_extension(
".noise");
98 std::ofstream
out(
file, std::ios_base::binary);
117 const bool report =
false)
121 std::ifstream in(
file.native(), std::ios_base::binary);
123 in.read((
char *) & (
clusters->number),
sizeof(
int));
131 in.read((
char *)
clusters->clusterEnergy,
sizeof(
float) *
clusters->number);
151 const bool report =
false)
153 std::ifstream in(
file.native(), std::ios_base::binary);
154 cell_info.binary_input(in);
166 const bool report =
false)
168 std::ifstream in(
file.native(), std::ios_base::binary);
169 cell_state.binary_input(in);
181 const bool report =
false)
183 file.replace_extension(
".clusterinfo");
184 std::ofstream
out(
file, std::ios_base::binary);
186 out.write((
char *) & (
clusters->number),
sizeof(
int));
204 const bool report =
false)
206 file.replace_extension(
".cellinfo");
207 std::ofstream
out(
file, std::ios_base::binary);
208 cell_info.binary_output(
out);
220 const bool report =
false)
222 file.replace_extension(
".cellstate");
223 std::ofstream
out(
file, std::ios_base::binary);
224 cell_state.binary_output(
out);
242 if (!std::filesystem::create_directory(
folder))
246 std::cout <<
"ERROR: folder '" <<
folder <<
"' could not be created." << std::endl;
251 else if (!std::filesystem::is_directory(
folder))
255 std::cout <<
"ERROR: folder '" <<
folder <<
"' is not a valid folder." << std::endl;
274 const std::string &
text,
275 const std::string &
suffix,
276 const std::string &
ext )
283 const size_t event_number,
284 const std::string &
suffix,
285 const std::string &
ext,
286 const unsigned int num_width = 9 )
288 std::ostringstream event_ID_format;
289 event_ID_format << std::setfill(
'0') << std::setw(num_width) << event_number;
290 const std::string event_ID = event_ID_format.str();
298 const std::string &
prefix =
"",
299 const std::string &
suffix =
"",
300 const bool output_errors =
true)
307 auto filename = [&] (
const std::string &
text,
const std::string &
ext)
328 const std::string &
prefix =
"",
329 const std::string &
suffix =
"",
330 const unsigned int num_width = 9,
331 const bool output_errors =
true)
338 std::ostringstream event_ID_format;
339 event_ID_format << std::setfill(
'0') << std::setw(num_width) << event_number;
340 const std::string event_ID = event_ID_format.str();
365 const std::string &
prefix =
"",
366 const std::string &
suffix =
"",
367 const unsigned int num_width = 9,
368 const bool output_errors =
true)
375 std::ostringstream event_ID_format;
376 event_ID_format << std::setfill(
'0') << std::setw(num_width) << event_number;
377 const std::string event_ID = event_ID_format.str();
394 const std::string &
prefix =
"",
395 const std::string &
suffix =
"",
396 const unsigned int num_width = 9,
397 const bool output_errors =
true)
404 std::ostringstream event_ID_format;
405 event_ID_format << std::setfill(
'0') << std::setw(num_width) << event_number;
406 const std::string event_ID = event_ID_format.str();
423 const std::string &
prefix =
"",
424 const std::string &
suffix =
"",
425 const unsigned int num_width = 9,
426 const bool output_errors =
true)
433 std::ostringstream event_ID_format;
434 event_ID_format << std::setfill(
'0') << std::setw(num_width) << event_number;
435 const std::string event_ID = event_ID_format.str();
451 std::map<std::string, CaloRecGPU::Helpers::CPU_object<CaloRecGPU::GeometryArr>>
geometry;
452 std::map<std::string, CaloRecGPU::Helpers::CPU_object<CaloRecGPU::CellNoiseArr>>
noise;
453 std::map<std::string, CaloRecGPU::Helpers::CPU_object<CaloRecGPU::ClusterInfoArr>>
cluster_info;
454 std::map<std::string, CaloRecGPU::Helpers::CPU_object<CaloRecGPU::CellInfoArr>>
cell_info;
455 std::map<std::string, CaloRecGPU::Helpers::CPU_object<CaloRecGPU::CellStateArr>>
cell_state;
495 const bool output_messages =
true)
498 if (!std::filesystem::is_directory(
folder))
502 std::cout <<
"ERROR: '" <<
folder <<
"' is not a valid folder." << std::endl;
506 std::set<std::string> read_one_part_of_v1_cells;
524 auto check_error = [&](
const ErrorState & es,
const std::string &
str)
532 std::cout <<
"ERROR: '" <<
file <<
"' is not a valid " <<
str <<
" file (" << (
int) es <<
")." << std::endl;
537 auto output_loading_message = [&](
const std::string &
str)
541 std::cout <<
"Loaded " <<
str <<
" from '" <<
file <<
"'." << std::endl;
545 if (
file.extension() ==
".geometry")
547 if (!flo.load_geometry)
557 output_loading_message(
"geometry");
559 else if (
file.extension() ==
".cellstate")
561 if (!flo.load_cell_state || !can_load_events)
571 output_loading_message(
"cell state");
578 else if (
file.extension() ==
".cellinfo")
580 if (!flo.load_cell_info || !can_load_events)
590 output_loading_message(
"cell info");
597 else if (
file.extension() ==
".clusterinfo")
599 if (!flo.load_cluster_info || !can_load_events)
609 output_loading_message(
"cluster info");
616 else if (
file.extension() ==
".noise")
628 output_loading_message(
"noise");
637 const bool output_messages =
true)
649 #endif //CALORECGPU_STANDALONEDATAIO_H
static std::string build_filename(const std::string &prefix, const std::string &text, const std::string &suffix, const std::string &ext)
static ErrorState save_constants_to_folder(const std::filesystem::path &folder, const CaloRecGPU::Helpers::CPU_object< CaloRecGPU::GeometryArr > &geo, const CaloRecGPU::Helpers::CPU_object< CaloRecGPU::CellNoiseArr > &noise, const std::string &prefix="", const std::string &suffix="", const bool output_errors=true)
path
python interpreter configuration --------------------------------------—
Holds one objects of type \T in memory context Context.
static ErrorState save_event_to_folder(const size_t event_number, const std::filesystem::path &folder, const CaloRecGPU::Helpers::CPU_object< CaloRecGPU::CellInfoArr > &cell_info, const CaloRecGPU::Helpers::CPU_object< CaloRecGPU::CellStateArr > &cell_state, const CaloRecGPU::Helpers::CPU_object< CaloRecGPU::ClusterInfoArr > &clusters, const std::string &prefix="", const std::string &suffix="", const unsigned int num_width=9, const bool output_errors=true)
static constexpr FolderLoadOptions None()
std::map< std::string, CaloRecGPU::Helpers::CPU_object< CaloRecGPU::ClusterInfoArr > > cluster_info
static FolderLoad load_folder(const std::filesystem::path &folder, int max_events=-1, const FolderLoadOptions &flo=FolderLoadOptions::None(), const bool output_messages=true)
std::map< std::string, CaloRecGPU::Helpers::CPU_object< CaloRecGPU::CellStateArr > > cell_state
static FolderLoad load_folder_filter(F &&filter_function, const std::filesystem::path &folder, int max_events=-1, const FolderLoadOptions &flo=FolderLoadOptions::None(), const bool output_messages=true)
static std::string build_filename(const std::string &prefix, const size_t event_number, const std::string &suffix, const std::string &ext, const unsigned int num_width=9)
static ErrorState save_cell_state_to_folder(const size_t event_number, const std::filesystem::path &folder, const CaloRecGPU::Helpers::CPU_object< CaloRecGPU::CellStateArr > &cell_state, const std::string &prefix="", const std::string &suffix="", const unsigned int num_width=9, const bool output_errors=true)
static ErrorState prepare_folder_for_output(const std::filesystem::path &folder, const bool output_errors=true)
std::map< std::string, CaloRecGPU::Helpers::CPU_object< CaloRecGPU::GeometryArr > > geometry
static bool create_or_check_folder(const std::filesystem::path &folder, const bool output_errors=true)
std::map< std::string, CaloRecGPU::Helpers::CPU_object< CaloRecGPU::CellInfoArr > > cell_info
std::map< std::string, CaloRecGPU::Helpers::CPU_object< CaloRecGPU::CellNoiseArr > > noise
static ErrorState save_cell_info_to_folder(const size_t event_number, const std::filesystem::path &folder, const CaloRecGPU::Helpers::CPU_object< CaloRecGPU::CellInfoArr > &cell_info, const std::string &prefix="", const std::string &suffix="", const unsigned int num_width=9, const bool output_errors=true)
constexpr int NMaxClusters
static ErrorState save_clusters_to_folder(const size_t event_number, const std::filesystem::path &folder, const CaloRecGPU::Helpers::CPU_object< CaloRecGPU::ClusterInfoArr > &clusters, const std::string &prefix="", const std::string &suffix="", const unsigned int num_width=9, const bool output_errors=true)
static constexpr FolderLoadOptions All()
static void report_error(const std::filesystem::path &file, const std::string &kind, const bool really_report=false)