 |
ATLAS Offline Software
|
Go to the documentation of this file.
20 #include "boost/chrono/chrono.hpp"
21 #include "boost/chrono/thread_clock.hpp"
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;
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;
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)
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);
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);
285 if (m_useCPUPropertiesCalculation)
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]);
296 if (m_saveUncalibrated)
312 record_times(ctx.evt(), time_cast(
start, after_send),
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;
330 print_times(
"Transfer_from_GPU Cluster_Creation Cell_Adding Sorting Collection_Filling", 5);
332 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
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.
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.