Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
BatchedMinbiasSvc Class Reference

#include <BatchedMinbiasSvc.h>

Inheritance diagram for BatchedMinbiasSvc:
Collaboration diagram for BatchedMinbiasSvc:

Public Member Functions

 BatchedMinbiasSvc (const std::string &name, ISvcLocator *svc)
 Constructor. More...
 
 ~BatchedMinbiasSvc ()
 Destructor. More...
 
StatusCode initialize () override
 AthService initialize. More...
 
StatusCode beginHardScatter (const EventContext &ctx) override
 
StoreGateSvcgetMinbias (const EventContext &ctx, std::uint64_t mb_id) override
 
std::size_t getNumForBunch (const EventContext &ctx, int bunch) const override
 
virtual std::int64_t get_hs_id (const EventContext &ctx) const override
 
StatusCode endHardScatter (const EventContext &ctx) override
 

Private Types

using SGHandle = ServiceHandle< StoreGateSvc >
 
using SGHandleArray = std::vector< SGHandle >
 

Private Member Functions

int event_to_batch (std::int64_t hs_id)
 
std::size_t calcMBRequired (std::int64_t hs_id, std::size_t slot, unsigned int run, unsigned int lumi, std::uint64_t event)
 

Private Attributes

Gaudi::Property< std::uint64_t > m_seed
 
Gaudi::Property< bool > m_onDemandMB
 
Gaudi::Property< bool > m_usePoisson
 
Gaudi::Property< bool > m_useBeamInt
 
Gaudi::Property< bool > m_useBeamLumi
 
Gaudi::Property< int > m_MBBatchSize
 
Gaudi::Property< int > m_NSimultaneousBatches
 
Gaudi::Property< int > m_HSBatchSize
 
Gaudi::Property< int > m_skippedHSEvents
 
Gaudi::Property< float > m_nPerBunch
 
Gaudi::Property< int > m_earliestDeltaBC
 
Gaudi::Property< int > m_latestDeltaBC
 
Gaudi::Property< std::vector< int > > m_actualNHSEventsPerBatch
 
ServiceHandle< ISkipEventIdxSvcm_skipEventIdxSvc
 
ServiceHandle< IEvtSelector > m_bkgEventSelector
 
ServiceHandle< IBeamIntensitym_beamInt
 
ServiceHandle< IBeamLuminositym_beamLumi
 
ServiceHandle< ActiveStoreSvcm_activeStoreSvc
 
SGHandle m_spare_store
 
IEvtSelector::Context * m_bkg_evt_sel_ctx
 
std::vector< std::vector< std::uint64_t > > m_num_mb_by_bunch
 
std::vector< std::vector< std::uint64_t > > m_idx_lists
 
std::map< int, std::unique_ptr< SGHandleArray > > m_cache
 
std::map< int, std::mutex > m_cache_mtxs
 
std::mutex m_reading_batch_mtx
 
std::deque< std::unique_ptr< SGHandleArray > > m_empty_caches
 
std::mutex m_empty_caches_mtx
 
std::vector< std::unique_ptr< std::atomic_int > > m_batch_use_count
 
std::atomic_int m_last_loaded_batch
 

Detailed Description

Definition at line 27 of file BatchedMinbiasSvc.h.

Member Typedef Documentation

◆ SGHandle

Definition at line 48 of file BatchedMinbiasSvc.h.

◆ SGHandleArray

using BatchedMinbiasSvc::SGHandleArray = std::vector<SGHandle>
private

Definition at line 49 of file BatchedMinbiasSvc.h.

Constructor & Destructor Documentation

◆ BatchedMinbiasSvc()

BatchedMinbiasSvc::BatchedMinbiasSvc ( const std::string &  name,
ISvcLocator *  svc 
)

Constructor.

Definition at line 33 of file BatchedMinbiasSvc.cxx.

34  : base_class(name, svc),
35  m_bkg_evt_sel_ctx(nullptr),

◆ ~BatchedMinbiasSvc()

BatchedMinbiasSvc::~BatchedMinbiasSvc ( )

Destructor.

Definition at line 38 of file BatchedMinbiasSvc.cxx.

38 {}

Member Function Documentation

◆ beginHardScatter()

StatusCode BatchedMinbiasSvc::beginHardScatter ( const EventContext &  ctx)
override

Definition at line 290 of file BatchedMinbiasSvc.cxx.

290  {
291  using namespace std::chrono_literals;
292  bool first_wait = true;
293  std::chrono::steady_clock::time_point cache_wait_start{};
294  std::chrono::steady_clock::time_point order_wait_start{};
295  const std::int64_t hs_id = get_hs_id(ctx);
296  const int batch = event_to_batch(hs_id);
297  calcMBRequired(hs_id, ctx.slot(),
298  ctx.eventID().run_number(), // don't need the total, only
299  ctx.eventID().lumi_block(), // need to populate the arrays
300  ctx.eventID().event_number());
301  while (true) {
302  if (m_cache.count(batch) != 0) {
303  // batch already loaded
304  // mutex prevents returning when batch is partially loaded
305  m_cache_mtxs[batch].lock();
306  m_cache_mtxs[batch].unlock();
307  return StatusCode::SUCCESS;
308  }
309  // prevent batches loading out-of-order
310  if (m_last_loaded_batch < (batch - 1)) {
311  ATH_MSG_INFO("Waiting to prevent out-of-order loading of batches");
312  order_wait_start = std::chrono::steady_clock::now();
313  while (m_last_loaded_batch < (batch - 1)) {
314  std::this_thread::sleep_for(50ms);
315  }
316  auto wait_time = std::chrono::steady_clock::now() - order_wait_start;
318  "Waited {:%M:%S} to prevent out-of-order loading", wait_time));
319  }
320  // See if there are any free caches
321  // Using try_lock here to avoid reading same batch twice
322  if (m_empty_caches_mtx.try_lock()) {
323  if (m_empty_caches.empty()) {
324  // Unlock mutex if we got the lock but there were no free caches
325  m_empty_caches_mtx.unlock();
326  if (first_wait) {
327  ATH_MSG_INFO("Waiting for a free cache");
328  first_wait = false;
329  cache_wait_start = std::chrono::steady_clock::now();
330  }
331  // Wait 100ms then try again
332  std::this_thread::sleep_for(100ms);
333  continue;
334  }
335  if (!first_wait) {
336  auto wait_time = std::chrono::steady_clock::now() - cache_wait_start;
337  ATH_MSG_INFO(
338  fmt::format("Waited {:%M:%S} for a free cache", wait_time));
339  }
340  std::scoped_lock reading{m_cache_mtxs[batch], m_reading_batch_mtx};
341  if (m_HSBatchSize != 0) {
342  ATH_MSG_INFO("Reading next batch in event " << ctx.evt() << ", slot "
343  << ctx.slot() << " (hs_id "
344  << hs_id << ")");
345  }
346  auto start_time = std::chrono::system_clock::now();
347  m_cache[batch] = std::move(m_empty_caches.front());
348  m_empty_caches.pop_front();
349  // Remember old store to reset later
350  auto* old_store = m_activeStoreSvc->activeStore();
351  for (auto&& sg : *m_cache[batch]) {
352  // Change active store
353  m_activeStoreSvc->setStore(sg.get());
354  SG::CurrentEventStore::Push reader_sg_ces(sg.get());
355  // Read next event
356  ATH_CHECK(sg->clearStore(true));
357  if (!(m_bkgEventSelector->next(*m_bkg_evt_sel_ctx)).isSuccess()) {
358  ATH_MSG_FATAL("Ran out of minbias events");
359  return StatusCode::FAILURE;
360  }
361  IOpaqueAddress* addr = nullptr;
362  if (!m_bkgEventSelector->createAddress(*m_bkg_evt_sel_ctx, addr)
363  .isSuccess()) {
364  ATH_MSG_WARNING("Failed to create address. No more events?");
365  return StatusCode::FAILURE;
366  }
367  if (addr == nullptr) {
368  ATH_MSG_WARNING("createAddress returned nullptr. No more events?");
369  return StatusCode::FAILURE;
370  }
371  ATH_CHECK(sg->recordAddress(addr));
372  ATH_CHECK(sg->loadEventProxies());
373  // Read data now if desired
374  for (const auto* proxy_ptr : sg->proxies()) {
375  if (!proxy_ptr->isValid()) {
376  continue;
377  }
378 
379  if (!m_onDemandMB) {
380  // Sort of a const_cast, then ->accessData()
381  sg->proxy_exact(proxy_ptr->sgkey())->accessData();
382  }
383  }
384  }
385  // Reset active store
386  m_activeStoreSvc->setStore(old_store);
387  if (m_HSBatchSize != 0) {
389  "Reading {} events took {:%OMm %OSs}", m_cache[batch]->size(),
390  std::chrono::system_clock::now() - start_time));
391  }
392  m_empty_caches_mtx.unlock();
393  m_last_loaded_batch.exchange(batch);
394  return StatusCode::SUCCESS;
395  }
396  }
397  return StatusCode::SUCCESS;
398 }

◆ 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 196 of file BatchedMinbiasSvc.cxx.

200  {
201  const int n_bunches = m_latestDeltaBC.value() - m_earliestDeltaBC.value() + 1;
202  FastReseededPRNG prng{m_seed.value(), hs_id};
203 
204  // First apply the beam luminosity SF
205  bool sf_updated_throwaway;
206  const float beam_lumi_sf =
207  m_useBeamLumi ? m_beamLumi->scaleFactor(run, lumi, sf_updated_throwaway)
208  : 1.f;
209  std::vector<float> avg_num_mb_by_bunch(n_bunches,
210  beam_lumi_sf * m_nPerBunch.value());
211  // Now update using beam intensities
212  if (m_useBeamInt) {
213  // Supposed to be once per event, but ends up running once per minbias type
214  // per event now
215  m_beamInt->selectT0(run, event);
216  for (int bunch = m_earliestDeltaBC.value();
217  bunch <= m_latestDeltaBC.value(); ++bunch) {
218  std::size_t idx = bunch - m_earliestDeltaBC.value();
219  avg_num_mb_by_bunch[idx] *= m_beamInt->normFactor(bunch);
220  }
221  }
222 
223  std::vector<std::uint64_t>& num_mb_by_bunch = m_num_mb_by_bunch[slot];
224  num_mb_by_bunch.clear();
225  num_mb_by_bunch.resize(n_bunches);
226 
227  if (m_usePoisson) {
228  std::transform(avg_num_mb_by_bunch.begin(), avg_num_mb_by_bunch.end(),
229  num_mb_by_bunch.begin(), [&prng](float avg) {
230  return std::poisson_distribution<std::uint64_t>(avg)(prng);
231  });
232  } else {
233  std::transform(avg_num_mb_by_bunch.begin(), avg_num_mb_by_bunch.end(),
234  num_mb_by_bunch.begin(), [](float f) {
235  return static_cast<std::uint64_t>(std::round(f));
236  });
237  }
238 
239  std::uint64_t num_mb = ranges::accumulate(num_mb_by_bunch, 0UL);
240  std::vector<std::uint64_t>& index_array = m_idx_lists[slot];
241  const std::uint64_t mbBatchSize = m_MBBatchSize.value();
242  // Prevent running out of events
243  if (num_mb > mbBatchSize) {
244  const int center_bunch = -m_earliestDeltaBC.value();
245  auto indices =
246  rv::iota(0ULL, num_mb_by_bunch.size()) |
247  rv::filter([center_bunch, &num_mb_by_bunch](int idx) {
248  bool good = idx != center_bunch; // filter out the central bunch
249  good =
250  good && num_mb_by_bunch[idx] > 0; // filter out unfilled bunches
251  return good;
252  }) |
253  ranges::to<std::vector>;
254  // sort by distance from central bunch
255  ranges::stable_sort(indices, std::greater{},
256  [center_bunch](std::size_t idx) {
257  return std::size_t(std::abs(int(idx) - center_bunch));
258  });
259  // subtract from bunches until we aren't using too many events
260  for (auto idx : indices) {
261  const std::uint64_t max_to_subtract = num_mb - mbBatchSize;
262  const std::uint64_t num_subtracted =
263  std::min(max_to_subtract, num_mb_by_bunch[idx]);
264  num_mb_by_bunch[idx] -= num_subtracted;
265  num_mb -= num_subtracted;
266  if (num_mb <= mbBatchSize) {
267  break;
268  }
269  }
270  // Print an error anyway so we can fix the job
271  ATH_MSG_ERROR("We need " << num_mb << " events but the batch size is "
272  << mbBatchSize << ". Restricting to "
273  << mbBatchSize << " events!");
274  }
275  index_array = rv::ints(0, int(mbBatchSize)) | rv::sample(num_mb, prng) |
276  ranges::to<std::vector<std::uint64_t>>;
277  ranges::shuffle(index_array, prng);
278  if (m_HSBatchSize > 1) {
279  ATH_MSG_DEBUG("HS ID " << hs_id << " uses " << num_mb << " events");
280  } else {
281  ATH_MSG_DEBUG("HS ID " << hs_id << " uses " << num_mb << " events\n"
282  << fmt::format("\t\tBy bunch: [{}]\n",
283  fmt::join(num_mb_by_bunch, ", "))
284  << fmt::format("\t\tOrder: [{}]",
285  fmt::join(index_array, ", ")));
286  }
287  return num_mb;
288 }

◆ endHardScatter()

StatusCode BatchedMinbiasSvc::endHardScatter ( const EventContext &  ctx)
override

Definition at line 419 of file BatchedMinbiasSvc.cxx.

419  {
420  using namespace std::chrono_literals;
421  const std::int64_t hs_id = get_hs_id(ctx);
422  const int batch = event_to_batch(hs_id);
423  const int uses = m_batch_use_count[batch]->fetch_add(1) + 1;
424 
425  // If we're done with every event in the batch, clear the stores and return
426  // them
427  if (uses == m_HSBatchSize.value()) {
428  std::unique_ptr temp = std::move(m_cache[batch]);
429  m_cache.erase(batch);
430  for (auto&& sg : *temp) {
431  ATH_CHECK(sg->clearStore());
432  }
433  std::lock_guard lg{m_empty_caches_mtx};
434  m_empty_caches.emplace_back(std::move(temp));
435  } else {
436  ATH_MSG_DEBUG("BATCH " << batch << ": " << uses << " uses out of "
437  << m_HSBatchSize << " "
439  }
440  return StatusCode::SUCCESS;
441 }

◆ event_to_batch()

int BatchedMinbiasSvc::event_to_batch ( std::int64_t  hs_id)
private

Definition at line 40 of file BatchedMinbiasSvc.cxx.

40  {
41  return int(hs_id / m_HSBatchSize.value());
42 }

◆ get_hs_id()

virtual std::int64_t BatchedMinbiasSvc::get_hs_id ( const EventContext &  ctx) const
inlineoverridevirtual

Definition at line 42 of file BatchedMinbiasSvc.h.

42  {
43  return m_skippedHSEvents.value() + ctx.evt();
44  }

◆ getMinbias()

StoreGateSvc * BatchedMinbiasSvc::getMinbias ( const EventContext &  ctx,
std::uint64_t  mb_id 
)
override

Definition at line 400 of file BatchedMinbiasSvc.cxx.

401  {
402  const std::int64_t hs_id = get_hs_id(ctx);
403  const std::size_t slot = ctx.slot();
404  const std::size_t index = m_idx_lists.at(slot).at(mb_id);
405  const int batch = event_to_batch(hs_id);
406  return m_cache[batch]->at(index).get();
407 }

◆ getNumForBunch()

std::size_t BatchedMinbiasSvc::getNumForBunch ( const EventContext &  ctx,
int  bunch 
) const
override

Definition at line 409 of file BatchedMinbiasSvc.cxx.

410  {
411  if (bunch < m_earliestDeltaBC.value() || bunch > m_latestDeltaBC.value()) {
412  throw std::logic_error(fmt::format(
413  "Tried to request bunch {} which is outside the range [{}, {}]", bunch,
414  m_earliestDeltaBC.value(), m_latestDeltaBC.value()));
415  }
416  return m_num_mb_by_bunch.at(ctx.slot()).at(bunch - m_earliestDeltaBC.value());
417 }

◆ initialize()

StatusCode BatchedMinbiasSvc::initialize ( )
override

AthService initialize.

Definition at line 44 of file BatchedMinbiasSvc.cxx.

44  {
45  ATH_CHECK(m_skipEventIdxSvc.retrieve());
46  ATH_CHECK(m_beamInt.retrieve());
47  ATH_CHECK(m_beamLumi.retrieve());
48  std::size_t n_concurrent =
49  Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents();
50  m_idx_lists.clear();
51  m_idx_lists.resize(n_concurrent);
52 
53  m_num_mb_by_bunch.clear();
54  m_num_mb_by_bunch.resize(n_concurrent);
55 
56  m_cache.clear();
57  m_empty_caches.clear();
58  m_batch_use_count.clear();
59  m_batch_use_count.reserve(m_actualNHSEventsPerBatch.value().size());
60  for (std::size_t i = 0; i < m_actualNHSEventsPerBatch.value().size(); ++i) {
61  m_batch_use_count.emplace_back(std::make_unique<std::atomic_int>(0));
62  }
63  ATH_CHECK(m_bkgEventSelector.retrieve());
64  ATH_CHECK(m_activeStoreSvc.retrieve());
65  // Setup context
66  if (!m_bkgEventSelector->createContext(m_bkg_evt_sel_ctx).isSuccess()) {
67  ATH_MSG_ERROR("Failed to create background event selector context");
68  return StatusCode::FAILURE;
69  }
70  ATH_CHECK(SmartIF<IService>(m_bkgEventSelector.get())->start());
71 
72  // Setup proxy provider
73  SmartIF<IProxyProviderSvc> proxyProviderSvc{
74  serviceLocator()->service(fmt::format("ProxyProviderSvc/BkgPPSvc_{}", name()))
75  };
76  ATH_CHECK(proxyProviderSvc.isValid());
77 
78  // Setup Address Providers
79  SmartIF<IAddressProvider> addressProvider{m_bkgEventSelector.get()};
80  if (!addressProvider) {
82  "Could not cast background event selector to IAddressProvider");
83  } else {
84  proxyProviderSvc->addProvider(addressProvider);
85  }
86  // AthenaPoolAddressProviderSvc
87  SmartIF<IAddressProvider> athPoolAP{
88  serviceLocator()->service(fmt::format("AthenaPoolAddressProviderSvc/BkgAPAPSvc_{}", name()))
89  };
90  if (!athPoolAP) {
92  "Could not cast AthenaPoolAddressProviderSvc to IAddressProvider");
93  } else {
94  proxyProviderSvc->addProvider(athPoolAP);
95  }
96  // AddressRemappingSvc
97  SmartIF<IAddressProvider> addRemapAP{
98  serviceLocator()->service(fmt::format("AddressRemappingSvc/BkgARSvc_{}", name()))
99  };
100  if (!addRemapAP) {
101  ATH_MSG_WARNING("Could not cast AddressRemappingSvc to IAddressProvider");
102  } else {
103  proxyProviderSvc->addProvider(addRemapAP);
104  }
105 
106  int mbBatchSize = m_MBBatchSize.value();
107  // setup NSimultaneousBatches vectors of MBBatchSize StoreGates in
108  // m_empty_caches
109  for (int i = 0; i < m_NSimultaneousBatches.value(); ++i) {
110  auto& sgs = m_empty_caches.emplace_back(std::make_unique<SGHandleArray>());
111  sgs->reserve(mbBatchSize);
112  for (int j = 0; j < mbBatchSize; ++j) {
113  // creates / retrieves a different StoreGateSvc for each slot
114  auto& sg = sgs->emplace_back(
115  fmt::format("StoreGateSvc/StoreGate_{}_{}_{}", name(), i, j), name());
116  ATH_CHECK(sg.retrieve());
117  sg->setStoreID(StoreID::PILEUP_STORE);
118  sg->setProxyProviderSvc(proxyProviderSvc);
119  }
120  }
121 
122  // Setup the spare store for event skipping
123  ATH_CHECK(m_spare_store.retrieve());
125  m_spare_store->setProxyProviderSvc(proxyProviderSvc);
126 
127  // Setup the callback for event skipping
128  auto skipEvent_callback = [this, mbBatchSize](
131  using namespace std::chrono_literals;
132  auto evts = ranges::make_subrange(begin, end);
133  ATH_MSG_INFO("Skipping " << end - begin << " HS events.");
134  auto batches_all =
135  evts | rv::transform([this](const ISkipEventIdxSvc::EvtId& evt) {
136  return event_to_batch(evt.evtIdx);
137  });
138  std::vector<std::tuple<int, int>> batches_with_counts{};
139  // Produce a list of batches, and how many times they appear
140  for (int batch : batches_all) {
141  // First entry
142  if (batches_with_counts.empty()) {
143  batches_with_counts.emplace_back(batch, 1);
144  continue;
145  }
146  // Subsequent entries
147  auto& last_entry = batches_with_counts.back();
148  if (batch == std::get<0>(last_entry)) {
149  std::get<1>(last_entry) += 1;
150  continue;
151  }
152  batches_with_counts.emplace_back(batch, 1);
153  }
154 
155  // Discard batches
156  const int hs_batch_size = m_HSBatchSize.value();
157  auto* const old_store = m_activeStoreSvc->activeStore();
158  m_activeStoreSvc->setStore(m_spare_store.get());
159  ATH_CHECK(m_spare_store->clearStore());
160  for (const auto& [batch, count] : batches_with_counts) {
161  if (m_cache.count(batch) != 0) {
162  // batch is currently loaded, just update the use count
163  m_batch_use_count[batch]->fetch_add(count);
164  continue;
165  }
166  // force ordering in background stream
167  while (m_last_loaded_batch < batch - 1) {
168  std::this_thread::sleep_for(50ms);
169  }
170  // if we aren't skipping all the hardscatters in the batch, do nothing
171  if ((m_batch_use_count[batch]->fetch_add(count) + count) <
172  hs_batch_size) {
173  continue;
174  }
175  // otherwise discard the batch
176  ATH_MSG_INFO("Discarding batch " << batch);
177  std::unique_lock lck{m_reading_batch_mtx};
178  if (!m_bkgEventSelector->next(*m_bkg_evt_sel_ctx, mbBatchSize)
179  .isSuccess()) {
180  ATH_MSG_INFO("Ran out of background events");
181  return StatusCode::FAILURE;
182  }
183  // increment counters
184  m_last_loaded_batch.fetch_add(1);
185  }
186  ATH_CHECK(m_spare_store->clearStore());
187  m_activeStoreSvc->setStore(old_store);
188  return StatusCode::SUCCESS;
189  };
190 
191  // register callback
192  ATH_CHECK(m_skipEventIdxSvc->registerCallback(skipEvent_callback));
193  return StatusCode::SUCCESS;
194 }

Member Data Documentation

◆ m_activeStoreSvc

ServiceHandle<ActiveStoreSvc> BatchedMinbiasSvc::m_activeStoreSvc
private
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

Definition at line 112 of file BatchedMinbiasSvc.h.

◆ m_beamInt

ServiceHandle<IBeamIntensity> BatchedMinbiasSvc::m_beamInt
private
Initial value:
{this, "BeamIntSvc", "FlatBM",
"Beam intensity service"}

Definition at line 92 of file BatchedMinbiasSvc.h.

◆ m_beamLumi

ServiceHandle<IBeamLuminosity> BatchedMinbiasSvc::m_beamLumi
private
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

Definition at line 102 of file BatchedMinbiasSvc.h.

◆ 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

Definition at line 106 of file BatchedMinbiasSvc.h.

◆ m_cache_mtxs

std::map<int, std::mutex> BatchedMinbiasSvc::m_cache_mtxs
private

Definition at line 107 of file BatchedMinbiasSvc.h.

◆ 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

Definition at line 110 of file BatchedMinbiasSvc.h.

◆ m_empty_caches_mtx

std::mutex BatchedMinbiasSvc::m_empty_caches_mtx
private

Definition at line 111 of file BatchedMinbiasSvc.h.

◆ 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

Definition at line 105 of file BatchedMinbiasSvc.h.

◆ m_last_loaded_batch

std::atomic_int BatchedMinbiasSvc::m_last_loaded_batch
private

Definition at line 113 of file BatchedMinbiasSvc.h.

◆ 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

Definition at line 104 of file BatchedMinbiasSvc.h.

◆ 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

Definition at line 109 of file BatchedMinbiasSvc.h.

◆ 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

ServiceHandle<ISkipEventIdxSvc> BatchedMinbiasSvc::m_skipEventIdxSvc
private
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",
fmt::format("StoreGateSvc/discards_{}", name()),
"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:
BatchedMinbiasSvc::m_skipEventIdxSvc
ServiceHandle< ISkipEventIdxSvc > m_skipEventIdxSvc
Definition: BatchedMinbiasSvc.h:87
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
BatchedMinbiasSvc::m_empty_caches
std::deque< std::unique_ptr< SGHandleArray > > m_empty_caches
Definition: BatchedMinbiasSvc.h:110
BatchedMinbiasSvc::m_earliestDeltaBC
Gaudi::Property< int > m_earliestDeltaBC
Definition: BatchedMinbiasSvc.h:76
ISkipEventIdxSvc::EvtId
Definition: ISkipEventIdxSvc.h:16
vtune_athena.format
format
Definition: vtune_athena.py:14
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
BatchedMinbiasSvc::m_MBBatchSize
Gaudi::Property< int > m_MBBatchSize
Definition: BatchedMinbiasSvc.h:62
index
Definition: index.py:1
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
Trk::indices
std::pair< long int, long int > indices
Definition: AlSymMatBase.h:24
BatchedMinbiasSvc::event_to_batch
int event_to_batch(std::int64_t hs_id)
Definition: BatchedMinbiasSvc.cxx:40
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
SG::CurrentEventStore::Push
Temporarily change the current store.
Definition: SGTools/SGTools/CurrentEventStore.h:58
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
BatchedMinbiasSvc::m_seed
Gaudi::Property< std::uint64_t > m_seed
Definition: BatchedMinbiasSvc.h:50
Preparation.batch
batch
Definition: Preparation.py:49
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
BatchedMinbiasSvc::m_empty_caches_mtx
std::mutex m_empty_caches_mtx
Definition: BatchedMinbiasSvc.h:111
CxxUtils::fpcompare::greater
bool greater(double a, double b)
Compare two FP numbers, working around x87 precision issues.
Definition: fpcompare.h:140
BatchedMinbiasSvc::m_usePoisson
Gaudi::Property< bool > m_usePoisson
Definition: BatchedMinbiasSvc.h:55
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
BatchedMinbiasSvc::m_HSBatchSize
Gaudi::Property< int > m_HSBatchSize
Definition: BatchedMinbiasSvc.h:68
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
covarianceTool.filter
filter
Definition: covarianceTool.py:514
BatchedMinbiasSvc::m_useBeamInt
Gaudi::Property< bool > m_useBeamInt
Definition: BatchedMinbiasSvc.h:58
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
BatchedMinbiasSvc::m_onDemandMB
Gaudi::Property< bool > m_onDemandMB
Definition: BatchedMinbiasSvc.h:52
python.handimod.now
now
Definition: handimod.py:675
BatchedMinbiasSvc::m_cache_mtxs
std::map< int, std::mutex > m_cache_mtxs
Definition: BatchedMinbiasSvc.h:107
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:116
StoreID::PILEUP_STORE
@ PILEUP_STORE
Definition: StoreID.h:31
lumiFormat.i
int i
Definition: lumiFormat.py:85
ISkipEventIdxSvc::EvtIter
std::vector< EvtId >::const_iterator EvtIter
Definition: ISkipEventIdxSvc.h:23
BatchedMinbiasSvc::m_cache
std::map< int, std::unique_ptr< SGHandleArray > > m_cache
Definition: BatchedMinbiasSvc.h:106
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Recovery.avg
def avg(a, b)
Definition: Recovery.py:79
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
python.LArMinBiasAlgConfig.int
int
Definition: LArMinBiasAlgConfig.py:59
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
hist_file_dump.f
f
Definition: hist_file_dump.py:141
run
Definition: run.py:1
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
BatchedMinbiasSvc::m_bkg_evt_sel_ctx
IEvtSelector::Context * m_bkg_evt_sel_ctx
Definition: BatchedMinbiasSvc.h:102
BatchedMinbiasSvc::m_latestDeltaBC
Gaudi::Property< int > m_latestDeltaBC
Definition: BatchedMinbiasSvc.h:79
BatchedMinbiasSvc::m_activeStoreSvc
ServiceHandle< ActiveStoreSvc > m_activeStoreSvc
Definition: BatchedMinbiasSvc.h:96
BatchedMinbiasSvc::calcMBRequired
std::size_t calcMBRequired(std::int64_t hs_id, std::size_t slot, unsigned int run, unsigned int lumi, std::uint64_t event)
Definition: BatchedMinbiasSvc.cxx:196
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
BatchedMinbiasSvc::m_batch_use_count
std::vector< std::unique_ptr< std::atomic_int > > m_batch_use_count
Definition: BatchedMinbiasSvc.h:112
BatchedMinbiasSvc::m_actualNHSEventsPerBatch
Gaudi::Property< std::vector< int > > m_actualNHSEventsPerBatch
Definition: BatchedMinbiasSvc.h:82
BatchedMinbiasSvc::m_nPerBunch
Gaudi::Property< float > m_nPerBunch
Definition: BatchedMinbiasSvc.h:73
BatchedMinbiasSvc::m_num_mb_by_bunch
std::vector< std::vector< std::uint64_t > > m_num_mb_by_bunch
Definition: BatchedMinbiasSvc.h:104
BatchedMinbiasSvc::get_hs_id
virtual std::int64_t get_hs_id(const EventContext &ctx) const override
Definition: BatchedMinbiasSvc.h:42
PlotCalibFromCool.lg
lg
Definition: PlotCalibFromCool.py:748
runIDAlign.accumulate
accumulate
Update flags based on parser line args.
Definition: runIDAlign.py:63
BatchedMinbiasSvc::m_skippedHSEvents
Gaudi::Property< int > m_skippedHSEvents
Definition: BatchedMinbiasSvc.h:71
ReadBchFromCool.good
good
Definition: ReadBchFromCool.py:433
lumiFormat.lumi
lumi
Definition: lumiFormat.py:106
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
BatchedMinbiasSvc::m_spare_store
SGHandle m_spare_store
Definition: BatchedMinbiasSvc.h:99
BatchedMinbiasSvc::m_bkgEventSelector
ServiceHandle< IEvtSelector > m_bkgEventSelector
Definition: BatchedMinbiasSvc.h:90
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
BatchedMinbiasSvc::m_NSimultaneousBatches
Gaudi::Property< int > m_NSimultaneousBatches
Definition: BatchedMinbiasSvc.h:65
BatchedMinbiasSvc::m_useBeamLumi
Gaudi::Property< bool > m_useBeamLumi
Definition: BatchedMinbiasSvc.h:60
BatchedMinbiasSvc::m_idx_lists
std::vector< std::vector< std::uint64_t > > m_idx_lists
Definition: BatchedMinbiasSvc.h:105
BatchedMinbiasSvc::m_last_loaded_batch
std::atomic_int m_last_loaded_batch
Definition: BatchedMinbiasSvc.h:113
BatchedMinbiasSvc::m_beamLumi
ServiceHandle< IBeamLuminosity > m_beamLumi
Definition: BatchedMinbiasSvc.h:94
BatchedMinbiasSvc::m_reading_batch_mtx
std::mutex m_reading_batch_mtx
Definition: BatchedMinbiasSvc.h:109
BatchedMinbiasSvc::m_beamInt
ServiceHandle< IBeamIntensity > m_beamInt
Definition: BatchedMinbiasSvc.h:92
FastReseededPRNG
Definition: FastReseededPRNG.h:28