|
ATLAS Offline Software
|
Go to the documentation of this file.
20 #include "boost/chrono/chrono.hpp"
21 #include "boost/chrono/thread_clock.hpp"
29 declareInterface<ICaloClusterGPUOutputTransformer> (
this);
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;
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;
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)
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);
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);
287 if (m_useCPUPropertiesCalculation)
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]);
298 if (m_saveUncalibrated)
314 record_times(ctx.evt(), time_cast(
start, after_send),
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;
332 print_times(
"Transfer_from_GPU Cluster_Creation Cell_Adding Sorting Collection_Filling", 5);
334 return StatusCode::SUCCESS;
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
const std::string & name() const
Return the StoreGate ID for the referenced object.
flt_t calE() const
Geet Energy in signal state CALIBRATED.
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.
bool isOrdered() const
tell wether container is ordered
unsigned index() const
Accessor for the index of the cell in the CaloCellContainer.
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.
Gaudi::Property< bool > m_keepGPUData
If true, do not delete the GPU data representation.
flt_t calM() const
Get mass in signal state CALIBRATED.
Base class to provide some basic common infrastructure for timing measurements...
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition of CaloDetDescrManager.
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
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.
::StatusCode StatusCode
StatusCode definition for legacy code.
BasicGPUToAthenaImporter(const std::string &type, const std::string &name, const IInterface *parent)
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.
void returnToCPU(const bool clear_GPU=false, const bool return_cells=true, const bool return_clusters=true, const bool return_moments=true)
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
virtual StatusCode finalize() override
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const CaloCell_ID * m_calo_id
Pointer to Calo ID Helper.
void reindex(const unsigned newIndex)
Update the index.
Helpers for checking error return status codes and reporting errors.
constexpr bool is_part_of_cluster() const
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
virtual StatusCode initialize() override
bool isOrderedAndComplete() const
tell wether container is complete and in order
void addCellLink(CaloClusterCellLink *CCCL)
Data object for each calorimeter readout cell.
void setClusterSize(const ClusterSize)
Get cluster size.
CaloRecGPU::Helpers::CUDA_pinned_CPU_object< CaloRecGPU::ClusterInfoArr > m_clusters
Gaudi::Property< bool > m_measureTimes
If true, times are recorded to the file given by m_timeFileName.
CaloRecGPU::Helpers::CUDA_pinned_CPU_object< CaloRecGPU::CellStateArr > m_cell_state
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
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
void setRawPhi(flt_t)
Set for signal state UNCALIBRATED.