|
ATLAS Offline Software
|
#include <OnDemandMinbiasSvc.h>
|
std::size_t | calcMBRequired (std::int64_t hs_id, std::size_t slot, unsigned int run, unsigned int lumi, std::uint64_t event) |
|
Definition at line 29 of file OnDemandMinbiasSvc.h.
◆ SGHandle
◆ OnDemandMinbiasSvc()
OnDemandMinbiasSvc::OnDemandMinbiasSvc |
( |
const std::string & |
name, |
|
|
ISvcLocator * |
svc |
|
) |
| |
◆ ~OnDemandMinbiasSvc()
OnDemandMinbiasSvc::~OnDemandMinbiasSvc |
( |
| ) |
|
|
final |
◆ beginHardScatter()
StatusCode OnDemandMinbiasSvc::beginHardScatter |
( |
const EventContext & |
ctx | ) |
|
|
override |
Definition at line 218 of file OnDemandMinbiasSvc.cxx.
219 using namespace std::chrono_literals;
220 std::chrono::steady_clock::time_point order_wait_start{};
222 const std::int64_t hs_id =
get_hs_id(ctx);
223 const std::size_t slot = ctx.slot();
224 const std::size_t num_to_load =
226 ctx.eventID().lumi_block(), ctx.eventID().event_number());
229 if (stores.size() < num_to_load) {
230 ATH_MSG_INFO(
"Adding " << num_to_load - stores.size() <<
" stores");
231 stores.reserve(num_to_load);
232 for (std::size_t
i = stores.size();
i < num_to_load; ++
i) {
233 auto& sg = stores.emplace_back(
243 ATH_MSG_INFO(
"Waiting to prevent out-of-order loading. Last loaded is "
247 std::this_thread::sleep_for(50
ms);
258 for (std::size_t
i = 0;
i < num_to_load; ++
i) {
259 auto& sg = stores[
i];
267 return StatusCode::FAILURE;
269 IOpaqueAddress* addr =
nullptr;
273 return StatusCode::FAILURE;
275 if (addr ==
nullptr) {
277 return StatusCode::FAILURE;
282 for (
const auto* proxy_ptr : sg->proxies()) {
285 sg->proxy_exact(proxy_ptr->sgkey())->accessData();
295 return StatusCode::SUCCESS;
◆ calcMBRequired()
std::size_t OnDemandMinbiasSvc::calcMBRequired |
( |
std::int64_t |
hs_id, |
|
|
std::size_t |
slot, |
|
|
unsigned int |
run, |
|
|
unsigned int |
lumi, |
|
|
std::uint64_t |
event |
|
) |
| |
|
private |
Definition at line 153 of file OnDemandMinbiasSvc.cxx.
159 <<
"| hs_id " << hs_id);
162 std::vector<std::uint64_t> stack_num_mb_by_bunch{};
163 std::vector<std::uint64_t>& num_mb_by_bunch =
165 num_mb_by_bunch.clear();
166 num_mb_by_bunch.resize(n_bunches);
170 bool sf_updated_throwaway;
171 const float beam_lumi_sf =
174 const float beam_lumi = beam_lumi_sf *
m_nPerBunch.value();
175 std::vector<float> avg_num_mb_by_bunch(n_bunches, beam_lumi);
184 avg_num_mb_by_bunch[
idx] *=
m_beamInt->normFactor(bunch);
189 std::transform(avg_num_mb_by_bunch.begin(), avg_num_mb_by_bunch.end(),
190 num_mb_by_bunch.begin(), [&prng](
float avg) {
191 return std::poisson_distribution<std::uint64_t>(avg)(prng);
194 std::transform(avg_num_mb_by_bunch.begin(), avg_num_mb_by_bunch.end(),
195 num_mb_by_bunch.begin(), [](
float f) {
196 return static_cast<std::uint64_t>(std::round(f));
206 std::vector<std::uint64_t>& index_array =
m_idx_lists[slot];
208 index_array.resize(num_mb);
209 std::iota(index_array.begin(), index_array.end(), 0);
212 ATH_MSG_DEBUG(
"HS ID " << hs_id <<
" uses " << num_mb <<
" events\n"
◆ endHardScatter()
StatusCode OnDemandMinbiasSvc::endHardScatter |
( |
const EventContext & |
ctx | ) |
|
|
override |
◆ get_hs_id()
virtual std::int64_t OnDemandMinbiasSvc::get_hs_id |
( |
const EventContext & |
ctx | ) |
const |
|
inlineoverridevirtual |
◆ getMinbias()
StoreGateSvc * OnDemandMinbiasSvc::getMinbias |
( |
const EventContext & |
ctx, |
|
|
std::uint64_t |
mb_id |
|
) |
| |
|
override |
◆ getNumForBunch()
std::size_t OnDemandMinbiasSvc::getNumForBunch |
( |
const EventContext & |
ctx, |
|
|
int |
bunch |
|
) |
| const |
|
override |
Definition at line 305 of file OnDemandMinbiasSvc.cxx.
309 "Tried to request bunch {} which is outside the range [{}, {}]", bunch,
◆ initialize()
StatusCode OnDemandMinbiasSvc::initialize |
( |
| ) |
|
|
final |
AthService initialize.
Definition at line 45 of file OnDemandMinbiasSvc.cxx.
58 ATH_MSG_ERROR(
"Failed to create background event selector context");
59 return StatusCode::FAILURE;
68 if (!addressProvider) {
70 "Could not cast background event selector to IAddressProvider");
75 SmartIF<IAddressProvider> athPoolAP{
76 serviceLocator()->service(
fmt::format(
"AthenaPoolAddressProviderSvc/BkgAPAPSvc_{}",
name()))
80 "Could not cast AthenaPoolAddressProviderSvc to IAddressProvider");
85 SmartIF<IAddressProvider> addRemapAP{
86 serviceLocator()->service(
fmt::format(
"AddressRemappingSvc/BkgARSvc_{}",
name()))
89 ATH_MSG_WARNING(
"Could not cast AddressRemappingSvc to IAddressProvider");
94 const std::size_t n_concurrent =
95 Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents();
105 const int n_stores = 50;
107 for (std::size_t
i = 0;
i < n_concurrent; ++
i) {
109 sgs.reserve(n_stores);
110 for (
int j = 0; j < n_stores; ++j) {
112 auto& sg = sgs.emplace_back(
124 auto skipEvent_callback = [
this](
127 using namespace std::chrono_literals;
131 for (
auto iter =
begin; iter <
end; ++iter) {
132 const auto&
evt = *iter;
136 << n_to_skip <<
" pileup events");
137 for (std::size_t
i = 0;
i < n_to_skip; ++
i) {
140 return StatusCode::FAILURE;
146 return StatusCode::SUCCESS;
150 return StatusCode::SUCCESS;
◆ m_activeStoreSvc
Initial value:{
this, "ActiveStoreSvc", "ActiveStoreSvc", "ActiveStoreSvc"}
Definition at line 85 of file OnDemandMinbiasSvc.h.
◆ m_beamInt
Initial value:{this, "BeamIntSvc", "FlatBM",
"Beam intensity service"}
Definition at line 81 of file OnDemandMinbiasSvc.h.
◆ m_beamLumi
Initial value:{
this, "BeamLumiSvc", "LumiProfileSvc", "Beam luminosity service"}
Definition at line 83 of file OnDemandMinbiasSvc.h.
◆ m_bkg_evt_sel_ctx
IEvtSelector::Context* OnDemandMinbiasSvc::m_bkg_evt_sel_ctx |
|
private |
◆ m_bkgEventSelector
ServiceHandle<IEvtSelector> OnDemandMinbiasSvc::m_bkgEventSelector |
|
private |
Initial value:{
this, "BkgEventSelector", {}, "Event selector for minbias events"}
Definition at line 79 of file OnDemandMinbiasSvc.h.
◆ m_earliestDeltaBC
Gaudi::Property<int> OnDemandMinbiasSvc::m_earliestDeltaBC |
|
private |
Initial value:{
this, "EarliestDeltaBC", -32,
"Earliest bunch crossing to consider (as delta)"}
Definition at line 70 of file OnDemandMinbiasSvc.h.
◆ m_idx_lists
std::vector<std::vector<std::uint64_t> > OnDemandMinbiasSvc::m_idx_lists |
|
private |
◆ m_last_loaded_hs
std::atomic_int64_t OnDemandMinbiasSvc::m_last_loaded_hs {-1} |
|
private |
◆ m_latestDeltaBC
Gaudi::Property<int> OnDemandMinbiasSvc::m_latestDeltaBC |
|
private |
Initial value:{
this, "LatestDeltaBC", +6,
"Latest bunch crossing to consider (as delta)"}
Definition at line 73 of file OnDemandMinbiasSvc.h.
◆ m_nPerBunch
Gaudi::Property<float> OnDemandMinbiasSvc::m_nPerBunch |
|
private |
Initial value:{
this, "AvgMBPerBunch", 0.f,
"Average (max) number of minbias events per bunch"}
Definition at line 60 of file OnDemandMinbiasSvc.h.
◆ m_num_mb_by_bunch
std::vector<std::vector<std::uint64_t> > OnDemandMinbiasSvc::m_num_mb_by_bunch |
|
private |
◆ m_onDemandMB
Gaudi::Property<bool> OnDemandMinbiasSvc::m_onDemandMB |
|
private |
Initial value:{
this, "OnDemandMB", false,
"Should minbias event contents be read on demand"}
Definition at line 55 of file OnDemandMinbiasSvc.h.
◆ m_proxyProviderSvc
◆ m_reading_batch_mtx
std::mutex OnDemandMinbiasSvc::m_reading_batch_mtx |
|
private |
◆ m_seed
Gaudi::Property<std::uint64_t> OnDemandMinbiasSvc::m_seed |
|
private |
Initial value:{this, "Seed", 0,
"Additional seed for PRNGs"}
Definition at line 53 of file OnDemandMinbiasSvc.h.
◆ m_skipEventIdxSvc
Initial value:{
this, "SkipEvtIdxSvc", "SkipEventIdxSvc",
"Skipped event index (run / lb num) provider"}
Definition at line 76 of file OnDemandMinbiasSvc.h.
◆ m_skippedHSEvents
Gaudi::Property<int> OnDemandMinbiasSvc::m_skippedHSEvents |
|
private |
Initial value:{this, "SkippedHSEvents", 0,
"Number of skipped HS events"}
Definition at line 58 of file OnDemandMinbiasSvc.h.
◆ m_spare_store
SGHandle OnDemandMinbiasSvc::m_spare_store |
|
private |
Initial value:{this, "StoreGateSvc",
"StoreGate for discarding events"}
Definition at line 88 of file OnDemandMinbiasSvc.h.
◆ m_stores
std::vector<std::vector<SGHandle> > OnDemandMinbiasSvc::m_stores |
|
private |
◆ m_useBeamInt
Gaudi::Property<bool> OnDemandMinbiasSvc::m_useBeamInt |
|
private |
Initial value:{
this, "UseBeamInt", true, "Whether to use the beam intensity service"}
Definition at line 66 of file OnDemandMinbiasSvc.h.
◆ m_useBeamLumi
Gaudi::Property<bool> OnDemandMinbiasSvc::m_useBeamLumi |
|
private |
Initial value:{
this, "UseBeamLumi", true, "Whether to use the beam luminosity service"}
Definition at line 68 of file OnDemandMinbiasSvc.h.
◆ m_usePoisson
Gaudi::Property<bool> OnDemandMinbiasSvc::m_usePoisson |
|
private |
Initial value:{this, "UsePoisson", true,
"Whether to use a Poisson distribution "
"(if False, use a delta distribution)"}
Definition at line 63 of file OnDemandMinbiasSvc.h.
◆ s_NoSlot
constexpr std::size_t OnDemandMinbiasSvc::s_NoSlot |
|
staticconstexprprivate |
The documentation for this class was generated from the following files:
ServiceHandle< IBeamLuminosity > m_beamLumi
Gaudi::Property< bool > m_useBeamInt
bool accumulate(AccumulateMap &map, std::vector< module_t > const &modules, FPGATrackSimMatrixAccumulator const &acc)
Accumulates an accumulator (e.g.
std::vector< std::vector< std::uint64_t > > m_num_mb_by_bunch
Temporarily change the current store.
ServiceHandle< ISkipEventIdxSvc > m_skipEventIdxSvc
std::size_t calcMBRequired(std::int64_t hs_id, std::size_t slot, unsigned int run, unsigned int lumi, std::uint64_t event)
ServiceHandle< IEvtSelector > m_bkgEventSelector
std::vector< std::vector< std::uint64_t > > m_idx_lists
Gaudi::Property< bool > m_usePoisson
ServiceHandle< IProxyProviderSvc > m_proxyProviderSvc
virtual std::int64_t get_hs_id(const EventContext &ctx) const override
POOL::TEvent event(POOL::TEvent::kClassAccess)
std::atomic_int64_t m_last_loaded_hs
std::vector< EvtId >::const_iterator EvtIter
Gaudi::Property< bool > m_onDemandMB
::StatusCode StatusCode
StatusCode definition for legacy code.
Gaudi::Property< bool > m_useBeamLumi
static constexpr std::size_t s_NoSlot
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
std::vector< std::vector< SGHandle > > m_stores
AthROOTErrorHandlerSvc * svc
IEvtSelector::Context * m_bkg_evt_sel_ctx
std::string join(const std::vector< std::string > &v, const char c=',')
Gaudi::Property< float > m_nPerBunch
Gaudi::Property< int > m_latestDeltaBC
Gaudi::Property< int > m_skippedHSEvents
ServiceHandle< IBeamIntensity > m_beamInt
#define ATH_MSG_WARNING(x)
std::mutex m_reading_batch_mtx
Gaudi::Property< int > m_earliestDeltaBC
ServiceHandle< ActiveStoreSvc > m_activeStoreSvc
Gaudi::Property< std::uint64_t > m_seed