ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCPUOutput Class Reference

Standard tool to output CPU cluster info to the non-standard file format that we have been using for plotting and validation purposes. More...

#include <CaloCPUOutput.h>

Inheritance diagram for CaloCPUOutput:
Collaboration diagram for CaloCPUOutput:

Public Member Functions

 CaloCPUOutput (const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize () override
virtual StatusCode execute (const EventContext &ctx, xAOD::CaloClusterContainer *cluster_collection) const override
virtual ~CaloCPUOutput ()=default
virtual StatusCode execute (xAOD::CaloClusterContainer *collection) final
 Execute on an entire collection of clusters.

Private Attributes

Gaudi::Property< std::string > m_savePath {this, "SavePath", "./saved_clusters", "Path to where the files should be saved"}
 The path specifying the folder to which the files should be saved.
Gaudi::Property< std::string > m_filePrefix {this, "FilePrefix", "", "Prefix of the saved files"}
 The prefix of the saved files.
Gaudi::Property< std::string > m_fileSuffix {this, "FileSuffix", "", "Suffix of the saved files"}
 The suffix of the saved files.
Gaudi::Property< unsigned int > m_numWidth {this, "NumberWidth", 9, "The number of digits to reserve for the events"}
 The number of digits to reserve for the events.
Gaudi::Property< bool > m_saveCellInfo
 If true, also outputs the cell energies, times, gains, qualities and provenances.
Gaudi::Property< bool > m_outputTags {this, "OutputCellsAsTags", true, "Whether to output cell assignment as tags instead of a list of indices per cluster."}
 Whether to output cell assignment as tags instead of a list of indices per cluster.
SG::ReadHandleKey< CaloCellContainerm_cellsKey {this, "CellsName", "", "Name(s) of Cell Containers"}
 vector of names of the cell containers to use as input.
const CaloCell_IDm_calo_id {nullptr}
 Pointer to Calo ID Helper.

Detailed Description

Standard tool to output CPU cluster info to the non-standard file format that we have been using for plotting and validation purposes.

Author
Nuno Fernandes nuno..nosp@m.dos..nosp@m.santo.nosp@m.s.fe.nosp@m.rnand.nosp@m.es@c.nosp@m.ern.c.nosp@m.h
Date
31 May 2022

There are likely more elegant/general/generic/portable solutions, some of which might even avoid Root too, but our workflow was built around this one...

Definition at line 30 of file CaloCPUOutput.h.

Constructor & Destructor Documentation

◆ CaloCPUOutput()

CaloCPUOutput::CaloCPUOutput ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 17 of file CaloCPUOutput.cxx.

17 :
18 base_class(type, name, parent)
19{
20}

◆ ~CaloCPUOutput()

virtual CaloCPUOutput::~CaloCPUOutput ( )
virtualdefault

Member Function Documentation

◆ execute() [1/2]

StatusCode CaloCPUOutput::execute ( const EventContext & ctx,
xAOD::CaloClusterContainer * cluster_collection ) const
overridevirtual

Definition at line 32 of file CaloCPUOutput.cxx.

33{
34 SG::ReadHandle<CaloCellContainer> cell_collection(m_cellsKey, ctx);
35 if ( !cell_collection.isValid() )
36 {
37 ATH_MSG_ERROR( " Cannot retrieve CaloCellContainer: " << cell_collection.name() );
38 return StatusCode::FAILURE;
39 }
40
41 EventDataHolder ed;
42
43 ed.allocate(false);
44
45 ed.importCells(static_cast<const CaloCellContainer *>(&(*cell_collection)));
46
47 ed.importClusters(cluster_collection, MomentsOptionsArray::all(), m_outputTags, true, false, false);
48
50 {
51 const auto err = StandaloneDataIO::save_event_to_folder(ctx.evt(), std::string(m_savePath),
54
56 {
57 return StatusCode::FAILURE;
58 }
59 }
60 else
61 {
62 const auto err = StandaloneDataIO::save_clusters_to_folder(ctx.evt(), std::string(m_savePath),
64
66 {
67 return StatusCode::FAILURE;
68 }
69 }
70
71 return StatusCode::SUCCESS;
72
73}
#define ATH_MSG_ERROR(x)
Gaudi::Property< std::string > m_fileSuffix
The suffix of the saved files.
Gaudi::Property< bool > m_outputTags
Whether to output cell assignment as tags instead of a list of indices per cluster.
Gaudi::Property< std::string > m_filePrefix
The prefix of the saved files.
Gaudi::Property< std::string > m_savePath
The path specifying the folder to which the files should be saved.
SG::ReadHandleKey< CaloCellContainer > m_cellsKey
vector of names of the cell containers to use as input.
Gaudi::Property< bool > m_saveCellInfo
If true, also outputs the cell energies, times, gains, qualities and provenances.
Gaudi::Property< unsigned int > m_numWidth
The number of digits to reserve for the events.
CaloRecGPU::Helpers::CUDA_pinned_CPU_object< CaloRecGPU::CellInfoArr > m_cell_info
CaloRecGPU::Helpers::CUDA_pinned_CPU_object< CaloRecGPU::ClusterInfoArr > m_clusters
void allocate(const bool also_GPU=true)
static MomentsOptionsArray all()
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::ClusterInfoArr > &clusters, const std::string &prefix="", const std::string &suffix="", const unsigned int num_width=9, const bool output_errors=true)
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)

◆ execute() [2/2]

virtual StatusCode CaloClusterCollectionProcessor::execute ( xAOD::CaloClusterContainer * collection)
inlinefinal

Execute on an entire collection of clusters.

Parameters
collectionThe container of clusters. (deprecated)

Definition at line 50 of file CaloClusterCollectionProcessor.h.

51 {
52 return execute (Gaudi::Hive::currentContext(), collection);
53 }
virtual StatusCode execute(const EventContext &ctx, xAOD::CaloClusterContainer *cluster_collection) const override

◆ initialize()

StatusCode CaloCPUOutput::initialize ( )
overridevirtual

Definition at line 23 of file CaloCPUOutput.cxx.

24{
25 ATH_CHECK( m_cellsKey.initialize() );
26
27 ATH_CHECK( detStore()->retrieve(m_calo_id, "CaloCell_ID") );
28
29 return StatusCode::SUCCESS;
30}
#define ATH_CHECK
Evaluate an expression and check for errors.
const CaloCell_ID * m_calo_id
Pointer to Calo ID Helper.
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

Member Data Documentation

◆ m_calo_id

const CaloCell_ID* CaloCPUOutput::m_calo_id {nullptr}
private

Pointer to Calo ID Helper.

Definition at line 90 of file CaloCPUOutput.h.

90{nullptr};

◆ m_cellsKey

SG::ReadHandleKey<CaloCellContainer> CaloCPUOutput::m_cellsKey {this, "CellsName", "", "Name(s) of Cell Containers"}
private

vector of names of the cell containers to use as input.

Definition at line 85 of file CaloCPUOutput.h.

85{this, "CellsName", "", "Name(s) of Cell Containers"};

◆ m_filePrefix

Gaudi::Property<std::string> CaloCPUOutput::m_filePrefix {this, "FilePrefix", "", "Prefix of the saved files"}
private

The prefix of the saved files.

Empty string by default.

Definition at line 57 of file CaloCPUOutput.h.

57{this, "FilePrefix", "", "Prefix of the saved files"};

◆ m_fileSuffix

Gaudi::Property<std::string> CaloCPUOutput::m_fileSuffix {this, "FileSuffix", "", "Suffix of the saved files"}
private

The suffix of the saved files.

Empty string by default.

Definition at line 62 of file CaloCPUOutput.h.

62{this, "FileSuffix", "", "Suffix of the saved files"};

◆ m_numWidth

Gaudi::Property<unsigned int> CaloCPUOutput::m_numWidth {this, "NumberWidth", 9, "The number of digits to reserve for the events"}
private

The number of digits to reserve for the events.

9 by default.

Definition at line 67 of file CaloCPUOutput.h.

67{this, "NumberWidth", 9, "The number of digits to reserve for the events"};

◆ m_outputTags

Gaudi::Property<bool> CaloCPUOutput::m_outputTags {this, "OutputCellsAsTags", true, "Whether to output cell assignment as tags instead of a list of indices per cluster."}
private

Whether to output cell assignment as tags instead of a list of indices per cluster.

True by default.

Definition at line 80 of file CaloCPUOutput.h.

80{this, "OutputCellsAsTags", true, "Whether to output cell assignment as tags instead of a list of indices per cluster."};

◆ m_saveCellInfo

Gaudi::Property<bool> CaloCPUOutput::m_saveCellInfo
private
Initial value:
{this, "AlsoOutputCellInfo", false,
"Whether to output cell energies, gains, times, etc., as this information is repeated in the GPU side too."}

If true, also outputs the cell energies, times, gains, qualities and provenances.

As the GPU output contains exactly the same information, this will be redundant and thus it is defaulted to false.

Definition at line 74 of file CaloCPUOutput.h.

74 {this, "AlsoOutputCellInfo", false,
75 "Whether to output cell energies, gains, times, etc., as this information is repeated in the GPU side too."};

◆ m_savePath

Gaudi::Property<std::string> CaloCPUOutput::m_savePath {this, "SavePath", "./saved_clusters", "Path to where the files should be saved"}
private

The path specifying the folder to which the files should be saved.

Default ./saved_clusters

Definition at line 52 of file CaloCPUOutput.h.

52{this, "SavePath", "./saved_clusters", "Path to where the files should be saved"};

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