|
ATLAS Offline Software
|
Go to the documentation of this file.
26 #include "boost/chrono/chrono.hpp"
27 #include "boost/chrono/thread_clock.hpp"
35 m_constantDataSent(false)
51 bool any_failed =
false;
53 auto retrieve_and_report = [&](
auto &
var,
const auto &
type,
bool & falsify_if_empty)
57 falsify_if_empty =
false;
60 else if (
var.retrieve().isFailure())
116 return StatusCode::FAILURE;
137 return StatusCode::SUCCESS;
175 return StatusCode::SUCCESS;
201 ATH_CHECK( cluster_collection.
record (std::make_unique<xAOD::CaloClusterContainer>(), std::make_unique<xAOD::CaloClusterTrigAuxContainer> () ));
214 std::lock_guard<std::mutex> lock_guard(
m_mutex);
231 ATH_MSG_ERROR(
"Could not get valid Event Data Holder! Event: " << ctx.evt() );
232 return StatusCode::FAILURE;
244 if (!temporaries_data_ptr_holder)
246 ATH_MSG_ERROR(
"temporaries_data_ptr_holder is null in CaloGPUHybridClusterProcessor::execute" );
247 return StatusCode::FAILURE;
254 ATH_MSG_ERROR(
"Could not get valid temporary buffer holder! Event: " << ctx.evt() );
255 return StatusCode::FAILURE;
261 using clock_type = boost::chrono::thread_clock;
262 auto time_cast = [](
const auto & before,
const auto & after)
264 return boost::chrono::duration_cast<boost::chrono::microseconds>(after - before).count();
267 std::vector<size_t>
times;
269 size_t plot_time = 0;
276 times.reserve(time_size);
286 plot_time += time_cast(
t1,
t2);
292 time_clusMaker.start();
298 ATH_CHECK( pre_GPU_tool->execute(ctx, cluster_collection_ptr) );
311 plot_time += time_cast(
t3,
t4);
334 plot_time += time_cast(
t1,
t2);
341 ATH_CHECK( GPU_tool->execute(ctx, constant_data_holder, *event_data_ptr, temporaries_data_ptr_holder->
get_pointer()) );
350 ATH_CHECK(
m_plotterTool->update_plots(ctx, constant_data_holder, cluster_collection_ptr, *event_data_ptr, GPU_tool.get()) );
354 plot_time += time_cast(
t3,
t4);
377 plot_time += time_cast(
t1,
t2);
383 time_clusMaker.stop();
384 time_clusCorr.start();
390 ATH_CHECK( post_GPU_tool->execute(ctx, cluster_collection_ptr) );
394 times.push_back(time_cast(t9, t10));
403 plot_time += time_cast(
t3,
t4);
415 plot_time += time_cast(
t1,
t2);
428 decor_handle(*
cl) = 0;
432 decor_handle(*
cl) = cell_links->
size();
437 ATH_MSG_DEBUG(
"Created cluster container with " << cluster_collection->
size() <<
" clusters");
447 times.push_back(plot_time);
455 time_clusCorr.stop();
460 std::vector<double> clus_phi;
461 std::vector<double> clus_eta;
462 std::vector<double> N_BAD_CELLS;
463 std::vector<double> ENG_FRAC_MAX;
464 std::vector<unsigned int> sizeVec;
475 auto moncount_1thrsigma_by_mu2 =
Monitored::Scalar(
"count_1thrsigma_by_mu2", -999.0);
476 auto moncount_2thrsigma_by_mu2 =
Monitored::Scalar(
"count_2thrsigma_by_mu2", -999.0);
478 mon_clusEt, mon_clusPhi, mon_clusEta, mon_clusSignalState, mon_clusSize,
479 mon_badCells, mon_engFrac, mon_size, monmu, moncount_1thrsigma, moncount_2thrsigma,
480 mon_container_size_by_mu, moncount_1thrsigma_by_mu2, moncount_2thrsigma_by_mu2 );
483 mon_container_size = cluster_collection_ptr->
size();
488 if (! num_cell_links)
490 sizeVec.push_back(0);
494 sizeVec.push_back(num_cell_links->
size());
496 clus_phi.push_back(
cl->phi());
497 clus_eta.push_back(
cl->eta());
507 read_mu = eventInfoDecor(0);
512 int count_1thrsigma = 0, count_2thrsigma = 0;
517 if ( !cell_collection.
isValid() )
519 ATH_MSG_ERROR(
" Cannot retrieve CaloCellContainer: " << cell_collection.
name() );
520 return StatusCode::FAILURE;
525 for (
const auto &
cell : *cell_collection)
535 count_1thrsigma += 1;
538 count_2thrsigma += 1;
544 moncount_1thrsigma = count_1thrsigma;
545 moncount_2thrsigma = count_2thrsigma;
549 const float rev_mu = 1.f / read_mu;
550 mon_container_size_by_mu = rev_mu * cluster_collection_ptr->size();
551 const float sqr_rev_mu = rev_mu * rev_mu;
552 moncount_1thrsigma_by_mu2 = sqr_rev_mu * count_1thrsigma;
553 moncount_2thrsigma_by_mu2 = sqr_rev_mu * count_2thrsigma;
559 return StatusCode::SUCCESS;
566 std::string header_string;
568 auto add_name_to_string = [&](
const auto &
obj)
570 std::string
rep =
obj->name();
572 header_string +=
rep +
" ";
577 add_name_to_string(pre_GPU_tool);
587 add_name_to_string(GPU_tool);
597 add_name_to_string(post_GPU_tool);
613 return StatusCode::SUCCESS;
std::vector< LUCID_DigitContainer_p2 > t6
std::string replace(std::string s, const std::string &s2, const std::string &s3)
ToolHandle< ICaloClusterGPUOutputTransformer > m_transformBackToCPU
The tool that will convert the data from the GPU back to the CPU.
Gaudi::Property< bool > m_skipConversions
If true, both constant and event data conversion is skipped.
static StatusCode finalizeClusters(SG::WriteHandle< CaloClusterCellLinkContainer > &h, xAOD::CaloClusterContainer *pClusterColl)
Finalize clusters (move CaloClusterCellLink to a separate container).
Group
Properties of a chain group.
virtual StatusCode finalize() override
static StatusCode AddContainerWriteHandle(SG::WriteHandle< xAOD::CaloClusterContainer > &clusColl)
Creates a new xAOD::CaloClusterContainer in the given WriteHandle + CaloClusterAuxContainer and recor...
std::vector< LUCID_SimHit_p3 > t8
const std::string & name() const
Return the StoreGate ID for the referenced object.
void allocate(const size_t size)
std::vector< LUCID_RawData_p1 > t3
size_t m_temporariesSize
The size of the temporary buffer to allocate for the GPU tools that will be called.
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Gaudi::Property< bool > m_doMonitoring
If true, uses the monitoring tool specified by m_monitorTool.
std::vector< ALFA_RawDataCollection_p1 > t1
SG::ReadDecorHandleKey< xAOD::EventInfo > m_avgMuKey
Event input: To get <mu> from Event Info.
Gaudi::Property< bool > m_writeTriggerSpecificInfo
If true, writes some trigger-specific decorations.
ToolHandle< ICaloClusterGPUPlotter > m_plotterTool
An optional plotter, for testing and/or debugging purposes.
bool isPresent() const
Is the referenced container present in SG?
std::vector< LUCID_SimHit_p2 > t7
const T * get(size_type n) const
Access an element, as an rvalue.
State signalState() const
Get the current signal state.
const std::string & key() const
Return the StoreGate ID for the referenced object.
@ ENG_FRAC_MAX
Energy fraction of hottest cell.
ToolHandleArray< CaloClusterGPUProcessor > m_GPUoperations
Tools to be applied to the clusters on the GPU.
float getNoise(const IdentifierHash h, const int gain) const
Accessor by IdentifierHash and gain.
virtual StatusCode execute(const EventContext &ctx) const override
virtual StatusCode initialize_CUDA() override
Initialization that invokes CUDA functions.
Base class to provide some basic common infrastructure for timing measurements...
Gaudi::Property< float > m_monitoring1thr
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
CaloGPUHybridClusterProcessor(const std::string &name, ISvcLocator *pSvcLocator)
An algorithm that can be simultaneously executed in multiple threads.
Gaudi::Property< bool > m_doPlots
If true, calls the plotter specified by m_plotterTool at every tool execution.
virtual StatusCode initialize_non_CUDA() override
Initialization that does not invoke CUDA functions.
Gaudi::Property< float > m_monitoring2thr
Bookkeeping of cells that make up a cluster Simplified replacement for CaloCellLink,...
ClusterSize clusterSize() const
Get cluster size.
SG::ReadCondHandleKey< CaloNoise > m_noiseCDOKey
ToolHandle< GenericMonitoringTool > m_moniTool
Monitoring tool.
Description of a calorimeter cluster.
CaloRecGPU::Helpers::separate_thread_holder< CaloRecGPU::EventDataHolder > m_eventDataThreadedHolder ATLAS_THREAD_SAFE
A way to reduce allocations over multiple threads by keeping a cache of previously allocated objects ...
std::mutex m_mutex
This mutex is locked when sending the constant data on the first event to ensure thread safety.
void allocate(const bool also_GPU=true)
Handle class for reading a decoration on an object.
::StatusCode StatusCode
StatusCode definition for legacy code.
pointer_type ptr()
Dereference the pointer.
Handle class for adding a decoration to an object.
Handle class for adding a decoration to an object.
void print_times(const std::string &header, const size_t time_size) const
Gaudi::Property< bool > m_deferConstantDataToFirstEvent
If true, the constant data is only converted and sent to the GPU on the first event,...
Gaudi::Property< bool > m_monitorCells
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Header file to be included by clients of the Monitored infrastructure.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
std::atomic< bool > m_constantDataSent
A flag to signal that the constant data has been adequately sent to the GPU.
std::vector< LUCID_RawDataContainer_p1 > t4
SG::WriteHandleKey< CaloClusterCellLinkContainer > m_clusterCellLinkOutput
The name of the key in StoreGate for the output CaloClusterCellLinkContainer.
bool is_tile() const
cell belongs to Tile
SG::ReadHandleKey< CaloCellContainer > m_cellsKey
vector of names of the cell containers to use as input.
IdentifierHash identifyHash() const override final
cell subcalo hash same as subcalo_hash(), but kept for backward compatibility
size_t size() const
size method
Helpers for checking error return status codes and reporting errors.
StatusCode initialize(bool used=true)
ToolHandleArray< CaloClusterCollectionProcessor > m_postGPUoperations
Tools to be applied to the clusters after returning from the GPU.
std::vector< LUCID_Digit_p2 > t5
std::vector< ALFA_RawDataContainer_p1 > t2
SG::WriteDecorHandleKey< xAOD::CaloClusterContainer > m_mDecor_ncells
Key to the handle for writing the number of cells as a decoration.
A simple RAII wrapper to ensure proper allocation and deallocation of GPU memory in a void * for the ...
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
void record_times(const size_t event_num, const std::vector< size_t > ×) const
Gaudi::Property< bool > m_measureTimes
If true, times are recorded to the file given by m_timeFileName.
Gaudi::Property< size_t > m_numPreAllocatedGPUData
Number of events for which to pre-allocate space on GPU memory (should ideally be set to the expected...
ToolHandleArray< CaloClusterCollectionProcessor > m_preGPUoperations
Tools to be applied to the clusters before being sent to the GPU for processing.
Declare a monitored scalar variable.
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
size_type size() const noexcept
Returns the number of elements in the collection.
@ N_BAD_CELLS
number of bad cells
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_clusterOutput
The name of the key in StoreGate for the output CaloClusterContainer.
ToolHandle< ICaloClusterGPUConstantTransformer > m_transformConstantData
The tool that will convert the constant data from the CPU to the GPU.
ToolHandle< ICaloClusterGPUInputTransformer > m_transformForGPU
The tool that will actually convert the data from the CPU to the GPU.