 |
ATLAS Offline Software
|
Standard tool to convert the GPU data representation back to CPU.
More...
#include <BasicGPUToAthenaImporter.h>
|
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...
|
|
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.
◆ BasicGPUToAthenaImporter()
BasicGPUToAthenaImporter::BasicGPUToAthenaImporter |
( |
const std::string & |
type, |
|
|
const std::string & |
name, |
|
|
const IInterface * |
parent |
|
) |
| |
◆ ~BasicGPUToAthenaImporter()
virtual BasicGPUToAthenaImporter::~BasicGPUToAthenaImporter |
( |
| ) |
|
|
virtualdefault |
◆ convert()
Definition at line 90 of file BasicGPUToAthenaImporter.cxx.
97 using clock_type = boost::chrono::thread_clock;
98 auto time_cast = [](
const auto & before,
const auto & after)
100 return boost::chrono::duration_cast<boost::chrono::microseconds>(after - before).count();
106 if ( !cell_collection.isValid() )
108 ATH_MSG_ERROR(
" Cannot retrieve CaloCellContainer: " << cell_collection.name() );
109 return StatusCode::FAILURE;
117 std::vector<std::unique_ptr<CaloClusterCellLink>> cell_links;
119 cell_links.reserve(ed.m_clusters->number);
121 for (
int i = 0;
i < ed.m_clusters->number; ++
i)
123 if (ed.m_clusters->seedCellID[
i] >= 0)
125 cell_links.emplace_back(std::make_unique<CaloClusterCellLink>(cell_collection_link));
126 cell_links.back()->reserve(256);
131 cell_links.emplace_back(
nullptr);
141 const auto process_cell = [&](
const int cell_index,
const int cell_count)
143 const ClusterTag this_tag = ed.m_cell_state->clusterTag[cell_index];
151 std::memcpy(&tempf, &weight_pattern,
sizeof(
float));
156 const float reverse_weight = tempf;
158 const float this_weight = 1.0f - reverse_weight;
160 if (cell_links[this_index])
162 cell_links[this_index]->addCell(cell_count, this_weight);
164 if (cell_index == ed.m_clusters->seedCellID[this_index] && cell_links[this_index]->size() > 1)
171 const unsigned int first_idx = begin_it.
index();
172 const double first_wgt = begin_it.
weight();
189 if (cell_links[other_index])
191 cell_links[other_index]->addCell(cell_count, reverse_weight);
197 if (cell_collection->isOrderedAndComplete())
200 for (
int cell_index = 0; cell_index <
NCaloCells; ++cell_index)
202 process_cell(cell_index, cell_index);
207 size_t missing_cell_count = 0;
208 for (
int cell_index = 0; cell_index <
NCaloCells; ++cell_index)
212 ++missing_cell_count;
215 process_cell(cell_index, cell_index - missing_cell_count);
223 for (
int cell_count = 0; iCells != cell_collection->end(); ++iCells, ++cell_count)
228 const int cell_index =
cell->caloDDE()->calo_hash();
230 process_cell(cell_index, cell_count);
235 std::vector<int> cluster_order(ed.m_clusters->number);
237 std::iota(cluster_order.begin(), cluster_order.end(), 0);
239 std::sort(cluster_order.begin(), cluster_order.end(), [&](
const int a,
const int b) ->
bool
241 const bool a_valid = ed.m_clusters->seedCellID[a] >= 0;
242 const bool b_valid = ed.m_clusters->seedCellID[b] >= 0;
243 if (a_valid && b_valid)
245 return ed.m_clusters->clusterEt[a]
246 > ed.m_clusters->clusterEt[b];
271 cluster_container->clear();
272 cluster_container->reserve(cell_links.size());
274 for (
size_t i = 0;
i < cluster_order.size(); ++
i)
276 const int cluster_index = cluster_order[
i];
278 if (cell_links[cluster_index] !=
nullptr && cell_links[cluster_index]->
size() > 0)
281 cluster_container->push_back(cluster);
291 cluster->
setE(ed.m_clusters->clusterEnergy[cluster_index]);
292 cluster->
setEta(ed.m_clusters->clusterEta[cluster_index]);
293 cluster->
setPhi(ed.m_clusters->clusterPhi[cluster_index]);
313 time_cast(after_send, after_creation),
314 time_cast(after_creation, after_cells),
315 time_cast(after_cells, after_sort),
316 time_cast(after_sort, after_fill)
320 return StatusCode::SUCCESS;
◆ finalize()
StatusCode BasicGPUToAthenaImporter::finalize |
( |
| ) |
|
|
overridevirtual |
◆ initialize()
StatusCode BasicGPUToAthenaImporter::initialize |
( |
| ) |
|
|
overridevirtual |
Definition at line 33 of file BasicGPUToAthenaImporter.cxx.
39 auto get_option_from_string = [](
const std::string &
str,
bool & failed)
72 bool size_failed =
false;
82 return StatusCode::FAILURE;
85 return StatusCode::SUCCESS;
◆ 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.
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;
113 old_size = m_times.size();
114 m_times.resize(old_size + time_size);
115 m_eventNumbers.push_back(event_num);
◆ 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;
132 old_size = m_times.size();
133 m_times.resize(old_size + time_size);
134 m_eventNumbers.push_back(event_num);
◆ 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.
91 old_size = m_times.size();
92 m_times.resize(old_size +
times.size());
93 m_eventNumbers.push_back(event_num);
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 |
◆ 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_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 |
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.
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.
Gaudi::Property< std::string > m_timeFileName
File to which times should be saved.
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.
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.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
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.
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.
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.