|
ATLAS Offline Software
|
Standard tool to convert the GPU data representation back to CPU.
More...
#include <BasicGPUToAthenaImporter.h>
|
| BasicGPUToAthenaImporter (const std::string &type, const std::string &name, const IInterface *parent) |
|
virtual StatusCode | initialize () override |
|
virtual StatusCode | convert (const EventContext &ctx, const CaloRecGPU::ConstantDataHolder &constant_data, CaloRecGPU::EventDataHolder &event_data, xAOD::CaloClusterContainer *cluster_collection) const override |
| Fill the @xAODCaloClusterContainer with the relevant information. More...
|
|
virtual StatusCode | finalize () override |
|
virtual | ~BasicGPUToAthenaImporter ()=default |
|
ServiceHandle< StoreGateSvc > & | evtStore () |
| The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
const ServiceHandle< StoreGateSvc > & | evtStore () const |
| The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
const ServiceHandle< StoreGateSvc > & | detStore () const |
| The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
virtual StatusCode | sysInitialize () override |
| Perform system initialization for an algorithm. More...
|
|
virtual StatusCode | sysStart () override |
| Handle START transition. More...
|
|
virtual std::vector< Gaudi::DataHandle * > | inputHandles () const override |
| Return this algorithm's input handles. More...
|
|
virtual std::vector< Gaudi::DataHandle * > | outputHandles () const override |
| Return this algorithm's output handles. More...
|
|
Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Property< T > &t) |
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &) |
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, T &property, const std::string &doc="none") |
| Declare a new Gaudi property. More...
|
|
void | updateVHKA (Gaudi::Details::PropertyBase &) |
|
MsgStream & | msg () const |
|
MsgStream & | msg (const MSG::Level lvl) const |
|
bool | msgLvl (const MSG::Level lvl) const |
|
| DeclareInterfaceID (ICaloClusterGPUOutputTransformer, 1, 0) |
|
|
Gaudi::Property< bool > | m_keepGPUData {this, "KeepGPUData", true, "Keep GPU allocated data"} |
| If true , do not delete the GPU data representation. More...
|
|
Gaudi::Property< bool > | m_useCPUPropertiesCalculation {this, "UseCPUClusterPropertiesCalculation", false, "Use CaloClusterKineHelper::calculateKine instead of GPU-calculated cluster properties"} |
| if set to true, cluster properties are (re-)calculated using CaloClusterKineHelper::calculateKine . More...
|
|
SG::ReadHandleKey< CaloCellContainer > | m_cellsKey {this, "CellsName", "", "Name(s) of Cell Containers"} |
| vector of names of the cell containers to use as input. More...
|
|
Gaudi::Property< std::string > | m_clusterSizeString {this, "ClusterSize", "Topo_420", "The size/type of the clusters"} |
| Cluster size. Should be set accordingly to the threshold. More...
|
|
xAOD::CaloCluster::ClusterSize | m_clusterSize |
|
Gaudi::Property< std::vector< int > > | m_missingCellsToFill {this, "MissingCellsToFill", {}, "Force fill these cells as disabled on empty containers."} |
| Cell indices to fill as disabled cells (useful if the cell vector is always missing the same cells). More...
|
|
const CaloCell_ID * | m_calo_id {nullptr} |
| Pointer to Calo ID Helper. More...
|
|
Gaudi::Property< bool > | m_saveUncalibrated {this, "SaveUncalibratedSignalState", true, "Use CaloClusterKineHelper::calculateKine instead of GPU-calculated cluster properties"} |
| if set to true, the uncalibrated state is saved when importing the clusters. More...
|
|
StoreGateSvc_t | m_evtStore |
| Pointer to StoreGate (event store by default) More...
|
|
StoreGateSvc_t | m_detStore |
| Pointer to StoreGate (detector store by default) More...
|
|
std::vector< SG::VarHandleKeyArray * > | m_vhka |
|
bool | m_varHandleArraysDeclared |
|
Standard tool to convert the GPU data representation back to CPU.
- 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
- 30 May 2022
Definition at line 29 of file BasicGPUToAthenaImporter.h.
◆ StoreGateSvc_t
◆ BasicGPUToAthenaImporter()
BasicGPUToAthenaImporter::BasicGPUToAthenaImporter |
( |
const std::string & |
type, |
|
|
const std::string & |
name, |
|
|
const IInterface * |
parent |
|
) |
| |
◆ ~BasicGPUToAthenaImporter()
virtual BasicGPUToAthenaImporter::~BasicGPUToAthenaImporter |
( |
| ) |
|
|
virtualdefault |
◆ convert()
Fill the @xAODCaloClusterContainer with the relevant information.
- Parameters
-
ctx | The event context. |
constant_data | Data held in GPU memory that is common to all events (cell noise and geometry). |
event_data | Data held in GPU memory that is specific to this event (including the description of the clusters themselves). |
cluster_collection | The cluster collection, in the standard Athena structures. |
Implements ICaloClusterGPUOutputTransformer.
Definition at line 92 of file BasicGPUToAthenaImporter.cxx.
99 using clock_type = boost::chrono::thread_clock;
100 auto time_cast = [](
const auto & before,
const auto & after)
102 return boost::chrono::duration_cast<boost::chrono::microseconds>(after - before).count();
108 if ( !cell_collection.isValid() )
110 ATH_MSG_ERROR(
" Cannot retrieve CaloCellContainer: " << cell_collection.name() );
111 return StatusCode::FAILURE;
119 std::vector<std::unique_ptr<CaloClusterCellLink>> cell_links;
121 cell_links.reserve(ed.m_clusters->number);
123 for (
int i = 0;
i < ed.m_clusters->number; ++
i)
125 if (ed.m_clusters->seedCellID[
i] >= 0)
127 cell_links.emplace_back(std::make_unique<CaloClusterCellLink>(cell_collection_link));
128 cell_links.back()->reserve(256);
133 cell_links.emplace_back(
nullptr);
143 const auto process_cell = [&](
const int cell_index,
const int cell_count)
145 const ClusterTag this_tag = ed.m_cell_state->clusterTag[cell_index];
153 std::memcpy(&tempf, &weight_pattern,
sizeof(
float));
158 const float reverse_weight = tempf;
160 const float this_weight = 1.0f - reverse_weight;
162 if (cell_links[this_index])
164 cell_links[this_index]->addCell(cell_count, this_weight);
166 if (cell_index == ed.m_clusters->seedCellID[this_index] && cell_links[this_index]->size() > 1)
173 const unsigned int first_idx = begin_it.
index();
174 const double first_wgt = begin_it.
weight();
191 if (cell_links[other_index])
193 cell_links[other_index]->addCell(cell_count, reverse_weight);
199 if (cell_collection->isOrderedAndComplete())
202 for (
int cell_index = 0; cell_index <
NCaloCells; ++cell_index)
204 process_cell(cell_index, cell_index);
209 size_t missing_cell_count = 0;
210 for (
int cell_index = 0; cell_index <
NCaloCells; ++cell_index)
214 ++missing_cell_count;
217 process_cell(cell_index, cell_index - missing_cell_count);
225 for (
int cell_count = 0; iCells != cell_collection->end(); ++iCells, ++cell_count)
230 const int cell_index =
cell->caloDDE()->calo_hash();
232 process_cell(cell_index, cell_count);
237 std::vector<int> cluster_order(ed.m_clusters->number);
239 std::iota(cluster_order.begin(), cluster_order.end(), 0);
241 std::sort(cluster_order.begin(), cluster_order.end(), [&](
const int a,
const int b) ->
bool
243 const bool a_valid = ed.m_clusters->seedCellID[a] >= 0;
244 const bool b_valid = ed.m_clusters->seedCellID[b] >= 0;
245 if (a_valid && b_valid)
247 return ed.m_clusters->clusterEt[a]
248 > ed.m_clusters->clusterEt[b];
273 cluster_container->clear();
274 cluster_container->reserve(cell_links.size());
276 for (
size_t i = 0;
i < cluster_order.size(); ++
i)
278 const int cluster_index = cluster_order[
i];
280 if (cell_links[cluster_index] !=
nullptr && cell_links[cluster_index]->
size() > 0)
283 cluster_container->push_back(cluster);
293 cluster->
setE(ed.m_clusters->clusterEnergy[cluster_index]);
294 cluster->
setEta(ed.m_clusters->clusterEta[cluster_index]);
295 cluster->
setPhi(ed.m_clusters->clusterPhi[cluster_index]);
315 time_cast(after_send, after_creation),
316 time_cast(after_creation, after_cells),
317 time_cast(after_cells, after_sort),
318 time_cast(after_sort, after_fill)
322 return StatusCode::SUCCESS;
◆ declareGaudiProperty() [1/4]
specialization for handling Gaudi::Property<SG::VarHandleKeyArray>
Definition at line 170 of file AthCommonDataStore.h.
175 hndl.documentation());
◆ declareGaudiProperty() [2/4]
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition at line 156 of file AthCommonDataStore.h.
161 hndl.documentation());
◆ declareGaudiProperty() [3/4]
specialization for handling Gaudi::Property<SG::VarHandleBase>
Definition at line 184 of file AthCommonDataStore.h.
189 hndl.documentation());
◆ declareGaudiProperty() [4/4]
◆ DeclareInterfaceID()
◆ declareProperty() [1/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
hndl | Object holding the property value. |
doc | Documentation string for the property. |
This is the version for types that derive from SG::VarHandleBase
. The property value object is put on the input and output lists as appropriate; then we forward to the base class.
Definition at line 245 of file AthCommonDataStore.h.
250 this->declare(hndl.
vhKey());
251 hndl.
vhKey().setOwner(
this);
253 return PBASE::declareProperty(
name,hndl,
doc);
◆ declareProperty() [2/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
hndl | Object holding the property value. |
doc | Documentation string for the property. |
This is the version for types that derive from SG::VarHandleKey
. The property value object is put on the input and output lists as appropriate; then we forward to the base class.
Definition at line 221 of file AthCommonDataStore.h.
229 return PBASE::declareProperty(
name,hndl,
doc);
◆ declareProperty() [3/6]
◆ declareProperty() [4/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
property | Object holding the property value. |
doc | Documentation string for the property. |
This is the generic version, for types that do not derive from SG::VarHandleKey
. It just forwards to the base class version of declareProperty
.
Definition at line 333 of file AthCommonDataStore.h.
338 return PBASE::declareProperty(
name, property,
doc);
◆ declareProperty() [5/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
property | Object holding the property value. |
doc | Documentation string for the property. |
This dispatches to either the generic declareProperty
or the one for VarHandle/Key/KeyArray.
Definition at line 352 of file AthCommonDataStore.h.
◆ declareProperty() [6/6]
◆ detStore()
◆ evtStore() [1/2]
◆ evtStore() [2/2]
◆ extraDeps_update_handler()
Add StoreName to extra input/output deps as needed.
use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given
◆ finalize()
StatusCode BasicGPUToAthenaImporter::finalize |
( |
| ) |
|
|
overridevirtual |
◆ initialize()
StatusCode BasicGPUToAthenaImporter::initialize |
( |
| ) |
|
|
overridevirtual |
Definition at line 35 of file BasicGPUToAthenaImporter.cxx.
41 auto get_option_from_string = [](
const std::string &
str,
bool & failed)
74 bool size_failed =
false;
84 return StatusCode::FAILURE;
87 return StatusCode::SUCCESS;
◆ inputHandles()
Return this algorithm's input handles.
We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.
◆ msg() [1/2]
◆ msg() [2/2]
◆ msgLvl()
◆ outputHandles()
Return this algorithm's output handles.
We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.
◆ print_times()
void CaloGPUTimed::print_times |
( |
const std::string & |
header, |
|
|
const size_t |
time_size |
|
) |
| const |
|
inlineprotectedinherited |
Definition at line 143 of file CaloGPUTimed.h.
145 std::shared_lock<std::shared_mutex> lock(
m_timeMutex);
152 std::vector<size_t>
indices(m_eventNumbers.size());
157 return m_eventNumbers[a] < m_eventNumbers[b];
162 out <<
"Event_Number Total " <<
header <<
"\n";
166 out << m_eventNumbers[
idx] <<
" ";
170 for (
size_t i = 0;
i < time_size; ++
i)
172 total += m_times[
idx * time_size +
i];
177 for (
size_t i = 0;
i < time_size; ++
i)
179 out << m_times[
idx * time_size +
i] <<
" ";
◆ record_times() [1/3]
template<class ... Args>
void CaloGPUTimed::record_times |
( |
const size_t |
event_num, |
|
|
const size_t & |
value |
|
) |
| const |
|
inlineprotectedinherited |
Definition at line 105 of file CaloGPUTimed.h.
107 const size_t time_size = 1;
112 std::unique_lock<std::shared_mutex> lock(
m_timeMutex);
113 old_size = m_times.size();
114 m_times.resize(old_size + time_size);
115 m_eventNumbers.push_back(event_num);
118 std::shared_lock<std::shared_mutex> lock(
m_timeMutex);
◆ record_times() [2/3]
template<class ... Args>
void CaloGPUTimed::record_times |
( |
const size_t |
event_num, |
|
|
const size_t & |
value, |
|
|
Args &&... |
args |
|
) |
| const |
|
inlineprotectedinherited |
Definition at line 124 of file CaloGPUTimed.h.
126 const size_t time_size =
sizeof...(args) + 1;
131 std::unique_lock<std::shared_mutex> lock(
m_timeMutex);
132 old_size = m_times.size();
133 m_times.resize(old_size + time_size);
134 m_eventNumbers.push_back(event_num);
137 std::shared_lock<std::shared_mutex> lock(
m_timeMutex);
◆ record_times() [3/3]
void CaloGPUTimed::record_times |
( |
const size_t |
event_num, |
|
|
const std::vector< size_t > & |
times |
|
) |
| const |
|
inlineprotectedinherited |
Definition at line 86 of file CaloGPUTimed.h.
90 std::unique_lock<std::shared_mutex> lock(
m_timeMutex);
91 old_size = m_times.size();
92 m_times.resize(old_size +
times.size());
93 m_eventNumbers.push_back(event_num);
96 std::shared_lock<std::shared_mutex> lock(
m_timeMutex);
97 for (
size_t i = 0;
i <
times.size(); ++
i)
99 m_times[old_size +
i] =
times[
i];
◆ record_times_helper() [1/3]
template<class Arg >
void CaloGPUTimed::record_times_helper |
( |
const size_t |
index, |
|
|
Arg && |
arg |
|
) |
| const |
|
inlineprivateinherited |
◆ record_times_helper() [2/3]
void CaloGPUTimed::record_times_helper |
( |
const |
size_t | ) |
const |
|
inlineprivateinherited |
◆ record_times_helper() [3/3]
template<class ... Args>
void CaloGPUTimed::record_times_helper |
( |
size_t |
index, |
|
|
Args &&... |
args |
|
) |
| const |
|
inlineprivateinherited |
◆ renounce()
◆ renounceArray()
◆ sysInitialize()
◆ sysStart()
Handle START transition.
We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.
◆ updateVHKA()
◆ ATLAS_THREAD_SAFE [1/2]
std::vector<size_t> m_times CaloGPUTimed::ATLAS_THREAD_SAFE |
|
mutableprotectedinherited |
Vector to hold execution times to be recorded if necessary.
Definition at line 35 of file CaloGPUTimed.h.
◆ ATLAS_THREAD_SAFE [2/2]
std::vector<size_t> m_eventNumbers CaloGPUTimed::ATLAS_THREAD_SAFE |
|
mutableprotectedinherited |
Vector to hold the event numbers to be recorded if necessary.
Definition at line 40 of file CaloGPUTimed.h.
◆ m_calo_id
◆ m_cellsKey
◆ m_clusterSize
◆ m_clusterSizeString
Gaudi::Property<std::string> BasicGPUToAthenaImporter::m_clusterSizeString {this, "ClusterSize", "Topo_420", "The size/type of the clusters"} |
|
private |
◆ m_detStore
◆ m_evtStore
◆ m_keepGPUData
Gaudi::Property<bool> BasicGPUToAthenaImporter::m_keepGPUData {this, "KeepGPUData", true, "Keep GPU allocated data"} |
|
private |
◆ m_measureTimes
Gaudi::Property<bool> CaloGPUTimed::m_measureTimes |
|
protectedinherited |
If true
, times are recorded to the file given by m_timeFileName
.
Defaults to false
.
Definition at line 46 of file CaloGPUTimed.h.
◆ m_missingCellsToFill
Gaudi::Property<std::vector<int> > BasicGPUToAthenaImporter::m_missingCellsToFill {this, "MissingCellsToFill", {}, "Force fill these cells as disabled on empty containers."} |
|
private |
Cell indices to fill as disabled cells (useful if the cell vector is always missing the same cells).
Definition at line 71 of file BasicGPUToAthenaImporter.h.
◆ m_saveUncalibrated
Gaudi::Property<bool> BasicGPUToAthenaImporter::m_saveUncalibrated {this, "SaveUncalibratedSignalState", true, "Use CaloClusterKineHelper::calculateKine instead of GPU-calculated cluster properties"} |
|
private |
◆ m_timeFileName
Gaudi::Property<std::string> CaloGPUTimed::m_timeFileName |
|
protectedinherited |
File to which times should be saved.
Definition at line 50 of file CaloGPUTimed.h.
◆ m_timeMutex
std::shared_mutex CaloGPUTimed::m_timeMutex |
|
mutableprotectedinherited |
Mutex that is locked when recording times.
Definition at line 32 of file CaloGPUTimed.h.
◆ m_useCPUPropertiesCalculation
Gaudi::Property<bool> BasicGPUToAthenaImporter::m_useCPUPropertiesCalculation {this, "UseCPUClusterPropertiesCalculation", false, "Use CaloClusterKineHelper::calculateKine instead of GPU-calculated cluster properties"} |
|
private |
◆ m_varHandleArraysDeclared
◆ m_vhka
The documentation for this class was generated from the following files:
def retrieve(aClass, aKey=None)
Const iterator class for DataVector/DataList.
void setRawM(flt_t)
Set mass for singal state UNCALIBRATED.
constexpr int32_t secondary_cluster_index() const
constexpr bool is_shared_between_clusters() const
std::shared_mutex m_timeMutex
Mutex that is locked when recording times.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
flt_t calE() const
Geet Energy in signal state CALIBRATED.
std::pair< long int, long int > indices
flt_t calEta() const
Get in signal state CALIBRATED.
Gaudi::Property< std::string > m_clusterSizeString
Cluster size. Should be set accordingly to the threshold.
weight_t weight() const
Accessor for weight associated to this cell.
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Gaudi::Property< std::string > m_timeFileName
File to which times should be saved.
std::vector< SG::VarHandleKeyArray * > m_vhka
unsigned index() const
Accessor for the index of the cell in the CaloCellContainer.
Gaudi::Property< bool > m_keepGPUData
If true, do not delete the GPU data representation.
flt_t calM() const
Get mass in signal state CALIBRATED.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual void setOwner(IDataHandleHolder *o)=0
xAOD::CaloCluster::ClusterSize m_clusterSize
#define CRGPU_CHEAP_STRING_TO_ENUM(VAR, PREFIX, ONE,...)
Checks a string variable, VAR, for matching enum identifiers (ONE and the remaining variadic argument...
constexpr int32_t cluster_index() const
SG::ReadHandleKey< CaloCellContainer > m_cellsKey
vector of names of the cell containers to use as input.
Description of a calorimeter cluster.
void setRawE(flt_t)
Set Energy for signal state UNCALIBRATED.
Gaudi::Property< std::vector< int > > m_missingCellsToFill
Cell indices to fill as disabled cells (useful if the cell vector is always missing the same cells).
#define CRGPU_RECURSIVE_MACRO(...)
Expands recursive macros.
void print_times(const std::string &header, const size_t time_size) const
void setRawEta(flt_t)
Set for signal state UNCALIBRATED.
flt_t calPhi() const
Get in signal state CALIBRATED.
Gaudi::Property< bool > m_useCPUPropertiesCalculation
if set to true, cluster properties are (re-)calculated using CaloClusterKineHelper::calculateKine.
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
virtual void renounce()=0
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
const CaloCell_ID * m_calo_id
Pointer to Calo ID Helper.
void reindex(const unsigned newIndex)
Update the index.
constexpr bool is_part_of_cluster() const
void record_times_helper(const size_t) const
void addCellLink(CaloClusterCellLink *CCCL)
Data object for each calorimeter readout cell.
void setClusterSize(const ClusterSize)
Get cluster size.
void record_times(const size_t event_num, const std::vector< size_t > ×) const
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Gaudi::Property< bool > m_measureTimes
If true, times are recorded to the file given by m_timeFileName.
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
bool setPhi(const CaloSample sampling, const float phi)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
static void calculateKine(xAOD::CaloCluster *clu, const bool useweight=true, const bool updateLayers=true, const bool useGPUCriteria=false)
Helper class to calculate cluster kinematics based on cells.
bool setEta(const CaloSample sampling, const float eta)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
void reweight(const weight_t newWeight)
Update the weight.
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
constexpr int32_t secondary_cluster_weight() const
Gaudi::Property< bool > m_saveUncalibrated
if set to true, the uncalibrated state is saved when importing the clusters.
void setRawPhi(flt_t)
Set for signal state UNCALIBRATED.