|
ATLAS Offline Software
|
#include <BatchedMinbiasSvc.h>
Definition at line 27 of file BatchedMinbiasSvc.h.
◆ SGHandle
◆ SGHandleArray
◆ BatchedMinbiasSvc()
BatchedMinbiasSvc::BatchedMinbiasSvc |
( |
const std::string & |
name, |
|
|
ISvcLocator * |
svc |
|
) |
| |
◆ ~BatchedMinbiasSvc()
BatchedMinbiasSvc::~BatchedMinbiasSvc |
( |
| ) |
|
◆ beginHardScatter()
StatusCode BatchedMinbiasSvc::beginHardScatter |
( |
const EventContext & |
ctx | ) |
|
|
override |
Definition at line 293 of file BatchedMinbiasSvc.cxx.
294 using namespace std::chrono_literals;
295 bool first_wait =
true;
296 std::chrono::steady_clock::time_point cache_wait_start{};
297 std::chrono::steady_clock::time_point order_wait_start{};
298 const std::int64_t hs_id =
get_hs_id(ctx);
301 ctx.eventID().run_number(),
302 ctx.eventID().lumi_block(),
303 ctx.eventID().event_number());
310 return StatusCode::SUCCESS;
314 ATH_MSG_INFO(
"Waiting to prevent out-of-order loading of batches");
317 std::this_thread::sleep_for(50
ms);
321 "Waited {:%M:%S} to prevent out-of-order loading", wait_time));
335 std::this_thread::sleep_for(100
ms);
341 fmt::format(
"Waited {:%M:%S} for a free cache", wait_time));
345 ATH_MSG_INFO(
"Reading next batch in event " << ctx.evt() <<
", slot "
346 << ctx.slot() <<
" (hs_id "
362 return StatusCode::FAILURE;
364 IOpaqueAddress* addr =
nullptr;
368 return StatusCode::FAILURE;
370 if (addr ==
nullptr) {
372 return StatusCode::FAILURE;
377 for (
const auto* proxy_ptr : sg->proxies()) {
378 if (!proxy_ptr->isValid()) {
384 sg->proxy_exact(proxy_ptr->sgkey())->accessData();
397 return StatusCode::SUCCESS;
400 return StatusCode::SUCCESS;
◆ calcMBRequired()
std::size_t BatchedMinbiasSvc::calcMBRequired |
( |
std::int64_t |
hs_id, |
|
|
std::size_t |
slot, |
|
|
unsigned int |
run, |
|
|
unsigned int |
lumi, |
|
|
std::uint64_t |
event |
|
) |
| |
|
private |
Definition at line 199 of file BatchedMinbiasSvc.cxx.
208 bool sf_updated_throwaway;
209 const float beam_lumi_sf =
212 std::vector<float> avg_num_mb_by_bunch(n_bunches,
222 avg_num_mb_by_bunch[
idx] *=
m_beamInt->normFactor(bunch);
227 num_mb_by_bunch.clear();
228 num_mb_by_bunch.resize(n_bunches);
231 std::transform(avg_num_mb_by_bunch.begin(), avg_num_mb_by_bunch.end(),
232 num_mb_by_bunch.begin(), [&prng](
float avg) {
233 return std::poisson_distribution<std::uint64_t>(avg)(prng);
236 std::transform(avg_num_mb_by_bunch.begin(), avg_num_mb_by_bunch.end(),
237 num_mb_by_bunch.begin(), [](
float f) {
238 return static_cast<std::uint64_t>(std::round(f));
243 std::vector<std::uint64_t>& index_array =
m_idx_lists[slot];
246 if (num_mb > mbBatchSize) {
249 rv::iota(0ULL, num_mb_by_bunch.size()) |
251 bool good =
idx != center_bunch;
253 good && num_mb_by_bunch[
idx] > 0;
256 ranges::to<std::vector>;
259 [center_bunch](std::size_t
idx) {
260 return std::size_t(std::abs(
int(
idx) - center_bunch));
267 num_mb_by_bunch[
idx] -= num_subtracted;
268 num_mb -= num_subtracted;
269 if (num_mb <= mbBatchSize) {
274 ATH_MSG_ERROR(
"We need " << num_mb <<
" events but the batch size is "
275 << mbBatchSize <<
". Restricting to "
276 << mbBatchSize <<
" events!");
278 index_array = rv::ints(0,
int(mbBatchSize)) |
rv::sample(num_mb, prng) |
279 ranges::to<std::vector<std::uint64_t>>;
280 ranges::shuffle(index_array, prng);
282 ATH_MSG_DEBUG(
"HS ID " << hs_id <<
" uses " << num_mb <<
" events");
284 ATH_MSG_DEBUG(
"HS ID " << hs_id <<
" uses " << num_mb <<
" events\n"
◆ endHardScatter()
StatusCode BatchedMinbiasSvc::endHardScatter |
( |
const EventContext & |
ctx | ) |
|
|
override |
Definition at line 422 of file BatchedMinbiasSvc.cxx.
423 using namespace std::chrono_literals;
424 const std::int64_t hs_id =
get_hs_id(ctx);
433 for (
auto&& sg : *temp) {
443 return StatusCode::SUCCESS;
◆ event_to_batch()
int BatchedMinbiasSvc::event_to_batch |
( |
std::int64_t |
hs_id | ) |
|
|
private |
◆ get_hs_id()
virtual std::int64_t BatchedMinbiasSvc::get_hs_id |
( |
const EventContext & |
ctx | ) |
const |
|
inlineoverridevirtual |
◆ getMinbias()
StoreGateSvc * BatchedMinbiasSvc::getMinbias |
( |
const EventContext & |
ctx, |
|
|
std::uint64_t |
mb_id |
|
) |
| |
|
override |
◆ getNumForBunch()
std::size_t BatchedMinbiasSvc::getNumForBunch |
( |
const EventContext & |
ctx, |
|
|
int |
bunch |
|
) |
| const |
|
override |
Definition at line 412 of file BatchedMinbiasSvc.cxx.
416 "Tried to request bunch {} which is outside the range [{}, {}]", bunch,
◆ initialize()
StatusCode BatchedMinbiasSvc::initialize |
( |
| ) |
|
|
override |
AthService initialize.
Definition at line 47 of file BatchedMinbiasSvc.cxx.
51 std::size_t n_concurrent =
52 Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents();
70 ATH_MSG_ERROR(
"Failed to create background event selector context");
71 return StatusCode::FAILURE;
76 SmartIF<IProxyProviderSvc> proxyProviderSvc{
77 serviceLocator()->service(
fmt::format(
"ProxyProviderSvc/BkgPPSvc_{}",
name()))
83 if (!addressProvider) {
85 "Could not cast background event selector to IAddressProvider");
87 proxyProviderSvc->addProvider(addressProvider);
90 SmartIF<IAddressProvider> athPoolAP{
91 serviceLocator()->service(
fmt::format(
"AthenaPoolAddressProviderSvc/BkgAPAPSvc_{}",
name()))
95 "Could not cast AthenaPoolAddressProviderSvc to IAddressProvider");
97 proxyProviderSvc->addProvider(athPoolAP);
100 SmartIF<IAddressProvider> addRemapAP{
101 serviceLocator()->service(
fmt::format(
"AddressRemappingSvc/BkgARSvc_{}",
name()))
104 ATH_MSG_WARNING(
"Could not cast AddressRemappingSvc to IAddressProvider");
106 proxyProviderSvc->addProvider(addRemapAP);
113 auto& sgs =
m_empty_caches.emplace_back(std::make_unique<SGHandleArray>());
114 sgs->reserve(mbBatchSize);
115 for (
int j = 0; j < mbBatchSize; ++j) {
117 auto& sg = sgs->emplace_back(
121 sg->setProxyProviderSvc(proxyProviderSvc);
131 auto skipEvent_callback = [
this, mbBatchSize](
134 using namespace std::chrono_literals;
135 auto evts = ranges::make_subrange(
begin,
end);
141 std::vector<std::tuple<int, int>> batches_with_counts{};
143 for (
int batch : batches_all) {
145 if (batches_with_counts.empty()) {
146 batches_with_counts.emplace_back(
batch, 1);
150 auto& last_entry = batches_with_counts.back();
151 if (
batch == std::get<0>(last_entry)) {
152 std::get<1>(last_entry) += 1;
155 batches_with_counts.emplace_back(
batch, 1);
163 for (
const auto& [
batch,
count] : batches_with_counts) {
171 std::this_thread::sleep_for(50
ms);
184 return StatusCode::FAILURE;
191 return StatusCode::SUCCESS;
196 return StatusCode::SUCCESS;
◆ m_activeStoreSvc
Initial value:{
this, "ActiveStoreSvc", "ActiveStoreSvc", "ActiveStoreSvc"}
Definition at line 96 of file BatchedMinbiasSvc.h.
◆ m_actualNHSEventsPerBatch
Gaudi::Property<std::vector<int> > BatchedMinbiasSvc::m_actualNHSEventsPerBatch |
|
private |
Initial value:{
this,
"actualNHSEventsPerBatch",
{},
"Dynamic map of actual number of HS events for each batch, in this run."}
Definition at line 82 of file BatchedMinbiasSvc.h.
◆ m_batch_use_count
std::vector<std::unique_ptr<std::atomic_int> > BatchedMinbiasSvc::m_batch_use_count |
|
private |
◆ m_beamInt
Initial value:{this, "BeamIntSvc", "FlatBM",
"Beam intensity service"}
Definition at line 92 of file BatchedMinbiasSvc.h.
◆ m_beamLumi
Initial value:{
this, "BeamLumiSvc", "LumiProfileSvc", "Beam luminosity service"}
Definition at line 94 of file BatchedMinbiasSvc.h.
◆ m_bkg_evt_sel_ctx
IEvtSelector::Context* BatchedMinbiasSvc::m_bkg_evt_sel_ctx |
|
private |
◆ m_bkgEventSelector
ServiceHandle<IEvtSelector> BatchedMinbiasSvc::m_bkgEventSelector |
|
private |
Initial value:{
this, "BkgEventSelector", {}, "Event selector for minbias events"}
Definition at line 90 of file BatchedMinbiasSvc.h.
◆ m_cache
std::map<int, std::unique_ptr<SGHandleArray> > BatchedMinbiasSvc::m_cache |
|
private |
◆ m_cache_mtxs
std::map<int, std::mutex> BatchedMinbiasSvc::m_cache_mtxs |
|
private |
◆ m_earliestDeltaBC
Gaudi::Property<int> BatchedMinbiasSvc::m_earliestDeltaBC |
|
private |
Initial value:{
this, "EarliestDeltaBC", -32,
"Earliest bunch crossing to consider (as delta)"}
Definition at line 76 of file BatchedMinbiasSvc.h.
◆ m_empty_caches
std::deque<std::unique_ptr<SGHandleArray> > BatchedMinbiasSvc::m_empty_caches |
|
private |
◆ m_empty_caches_mtx
std::mutex BatchedMinbiasSvc::m_empty_caches_mtx |
|
private |
◆ m_HSBatchSize
Gaudi::Property<int> BatchedMinbiasSvc::m_HSBatchSize |
|
private |
Initial value:{
this, "HSBatchSize", 1,
"Number of HS events per batch (aka max reuse factor)"}
Definition at line 68 of file BatchedMinbiasSvc.h.
◆ m_idx_lists
std::vector<std::vector<std::uint64_t> > BatchedMinbiasSvc::m_idx_lists |
|
private |
◆ m_last_loaded_batch
std::atomic_int BatchedMinbiasSvc::m_last_loaded_batch |
|
private |
◆ m_latestDeltaBC
Gaudi::Property<int> BatchedMinbiasSvc::m_latestDeltaBC |
|
private |
Initial value:{
this, "LatestDeltaBC", +6,
"Latest bunch crossing to consider (as delta)"}
Definition at line 79 of file BatchedMinbiasSvc.h.
◆ m_MBBatchSize
Gaudi::Property<int> BatchedMinbiasSvc::m_MBBatchSize |
|
private |
Initial value:{
this, "MBBatchSize", 10000,
"Number of low pT minbias events to load per batch"}
Definition at line 62 of file BatchedMinbiasSvc.h.
◆ m_nPerBunch
Gaudi::Property<float> BatchedMinbiasSvc::m_nPerBunch |
|
private |
Initial value:{
this, "AvgMBPerBunch", 0,
"Average (max) number of minbias events per bunch"}
Definition at line 73 of file BatchedMinbiasSvc.h.
◆ m_NSimultaneousBatches
Gaudi::Property<int> BatchedMinbiasSvc::m_NSimultaneousBatches |
|
private |
Initial value:{
this, "NSimultaneousBatches", 1,
"Max number of batches to load simultaneously"}
Definition at line 65 of file BatchedMinbiasSvc.h.
◆ m_num_mb_by_bunch
std::vector<std::vector<std::uint64_t> > BatchedMinbiasSvc::m_num_mb_by_bunch |
|
private |
◆ m_onDemandMB
Gaudi::Property<bool> BatchedMinbiasSvc::m_onDemandMB |
|
private |
Initial value:{
this, "OnDemandMB", false,
"Should minbias event contents be read on demand"}
Definition at line 52 of file BatchedMinbiasSvc.h.
◆ m_reading_batch_mtx
std::mutex BatchedMinbiasSvc::m_reading_batch_mtx |
|
private |
◆ m_seed
Gaudi::Property<std::uint64_t> BatchedMinbiasSvc::m_seed |
|
private |
Initial value:{this, "Seed", 0,
"Additional seed for PRNGs"}
Definition at line 50 of file BatchedMinbiasSvc.h.
◆ m_skipEventIdxSvc
Initial value:{
this, "SkipEvtIdxSvc", "SkipEventIdxSvc",
"Skipped event index (run / lb num) provider"}
Definition at line 87 of file BatchedMinbiasSvc.h.
◆ m_skippedHSEvents
Gaudi::Property<int> BatchedMinbiasSvc::m_skippedHSEvents |
|
private |
Initial value:{this, "SkippedHSEvents", 0,
"Number of skipped HS events"}
Definition at line 71 of file BatchedMinbiasSvc.h.
◆ m_spare_store
SGHandle BatchedMinbiasSvc::m_spare_store |
|
private |
Initial value:{this, "StoreGateSvc",
"StoreGate for discarding events"}
Definition at line 99 of file BatchedMinbiasSvc.h.
◆ m_useBeamInt
Gaudi::Property<bool> BatchedMinbiasSvc::m_useBeamInt |
|
private |
Initial value:{
this, "UseBeamInt", true, "Whether to use the beam intensity service"}
Definition at line 58 of file BatchedMinbiasSvc.h.
◆ m_useBeamLumi
Gaudi::Property<bool> BatchedMinbiasSvc::m_useBeamLumi |
|
private |
Initial value:{
this, "UseBeamLumi", true, "Whether to use the beam luminosity service"}
Definition at line 60 of file BatchedMinbiasSvc.h.
◆ m_usePoisson
Gaudi::Property<bool> BatchedMinbiasSvc::m_usePoisson |
|
private |
Initial value:{this, "UsePoisson", true,
"Whether to use a Poisson distribution "
"(if False, use a delta distribution)"}
Definition at line 55 of file BatchedMinbiasSvc.h.
The documentation for this class was generated from the following files:
ServiceHandle< ISkipEventIdxSvc > m_skipEventIdxSvc
std::deque< std::unique_ptr< SGHandleArray > > m_empty_caches
Gaudi::Property< int > m_earliestDeltaBC
Gaudi::Property< int > m_MBBatchSize
std::pair< long int, long int > indices
int event_to_batch(std::int64_t hs_id)
bool accumulate(AccumulateMap &map, std::vector< module_t > const &modules, FPGATrackSimMatrixAccumulator const &acc)
Accumulates an accumulator (e.g.
Temporarily change the current store.
Gaudi::Property< std::uint64_t > m_seed
std::mutex m_empty_caches_mtx
bool greater(double a, double b)
Compare two FP numbers, working around x87 precision issues.
Gaudi::Property< bool > m_usePoisson
Gaudi::Property< int > m_HSBatchSize
Gaudi::Property< bool > m_useBeamInt
Gaudi::Property< bool > m_onDemandMB
std::map< int, std::mutex > m_cache_mtxs
POOL::TEvent event(POOL::TEvent::kClassAccess)
std::vector< EvtId >::const_iterator EvtIter
std::map< int, std::unique_ptr< SGHandleArray > > m_cache
::StatusCode StatusCode
StatusCode definition for legacy code.
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
AthROOTErrorHandlerSvc * svc
IEvtSelector::Context * m_bkg_evt_sel_ctx
Gaudi::Property< int > m_latestDeltaBC
ServiceHandle< ActiveStoreSvc > m_activeStoreSvc
std::size_t calcMBRequired(std::int64_t hs_id, std::size_t slot, unsigned int run, unsigned int lumi, std::uint64_t event)
std::string join(const std::vector< std::string > &v, const char c=',')
std::vector< std::unique_ptr< std::atomic_int > > m_batch_use_count
Gaudi::Property< std::vector< int > > m_actualNHSEventsPerBatch
Gaudi::Property< float > m_nPerBunch
std::vector< std::vector< std::uint64_t > > m_num_mb_by_bunch
virtual std::int64_t get_hs_id(const EventContext &ctx) const override
Gaudi::Property< int > m_skippedHSEvents
#define ATH_MSG_WARNING(x)
ServiceHandle< IEvtSelector > m_bkgEventSelector
Gaudi::Property< int > m_NSimultaneousBatches
Gaudi::Property< bool > m_useBeamLumi
std::vector< std::vector< std::uint64_t > > m_idx_lists
std::atomic_int m_last_loaded_batch
ServiceHandle< IBeamLuminosity > m_beamLumi
std::mutex m_reading_batch_mtx
ServiceHandle< IBeamIntensity > m_beamInt