ATLAS Offline Software
Loading...
Searching...
No Matches
OnDemandMinbiasSvc.h
Go to the documentation of this file.
1/* -*- C++ -*- */
2/*
3 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
4*/
5
6#ifndef PILEUPMT_ONDEMANDMINBIASSVC_H
7#define PILEUPMT_ONDEMANDMINBIASSVC_H
8
9#include <atomic>
10#include <deque>
11#include <format>
12#include <map>
13#include <memory>
14#include <mutex>
15#include <string>
16#include <vector>
17
20#include "Gaudi/Property.h"
21#include "GaudiKernel/IEvtSelector.h"
22#include "GaudiKernel/ServiceHandle.h"
28
29class OnDemandMinbiasSvc final : public extends<AthService, IMinbiasSvc> {
30 public:
32 OnDemandMinbiasSvc(const std::string& name, ISvcLocator* svc);
34 ~OnDemandMinbiasSvc() final;
35
37 StatusCode initialize() final;
38
39 StatusCode beginHardScatter(const EventContext& ctx) override;
40 StoreGateSvc* getMinbias(const EventContext& ctx,
41 std::uint64_t mb_id) override;
42 std::size_t getNumForBunch(const EventContext& ctx, int bunch) const override;
43 inline virtual
44 std::int64_t get_hs_id(const EventContext& ctx) const override {
45 return m_skippedHSEvents.value() + ctx.evt();
46 }
47
48 StatusCode endHardScatter(const EventContext& ctx) override;
49
50 private:
52
53 Gaudi::Property<std::uint64_t> m_seed{this, "Seed", 0,
54 "Additional seed for PRNGs"};
55 Gaudi::Property<bool> m_onDemandMB{
56 this, "OnDemandMB", false,
57 "Should minbias event contents be read on demand"};
58 Gaudi::Property<int> m_skippedHSEvents{this, "SkippedHSEvents", 0,
59 "Number of skipped HS events"};
60 Gaudi::Property<float> m_nPerBunch{
61 this, "AvgMBPerBunch", 0.f,
62 "Average (max) number of minbias events per bunch"};
63 Gaudi::Property<bool> m_usePoisson{this, "UsePoisson", true,
64 "Whether to use a Poisson distribution "
65 "(if False, use a delta distribution)"};
66 Gaudi::Property<bool> m_useBeamInt{
67 this, "UseBeamInt", true, "Whether to use the beam intensity service"};
68 Gaudi::Property<bool> m_useBeamLumi{
69 this, "UseBeamLumi", true, "Whether to use the beam luminosity service"};
70 Gaudi::Property<int> m_earliestDeltaBC{
71 this, "EarliestDeltaBC", -32,
72 "Earliest bunch crossing to consider (as delta)"};
73 Gaudi::Property<int> m_latestDeltaBC{
74 this, "LatestDeltaBC", +6,
75 "Latest bunch crossing to consider (as delta)"};
77 this, "SkipEvtIdxSvc", "SkipEventIdxSvc",
78 "Skipped event index (run / lb num) provider"};
80 this, "BkgEventSelector", {}, "Event selector for minbias events"};
81 ServiceHandle<IBeamIntensity> m_beamInt{this, "BeamIntSvc", "FlatBM",
82 "Beam intensity service"};
84 this, "BeamLumiSvc", "LumiProfileSvc", "Beam luminosity service"};
86 this, "ActiveStoreSvc", "ActiveStoreSvc", "ActiveStoreSvc"};
87
88 SGHandle m_spare_store{this, "StoreGateSvc",
89 std::format("StoreGateSvc/discards_{}", name()),
90 "StoreGate for discarding events"};
91 IEvtSelector::Context* m_bkg_evt_sel_ctx;
93
97
98 // prevents attempting to read multiple batches at once
100 std::atomic_int64_t m_last_loaded_hs{-1};
101
102 static constexpr std::size_t s_NoSlot =
103 std::numeric_limits<std::size_t>::max(); // "slot" to pass when we don't
104 // have a slot
105 std::size_t calcMBRequired(std::int64_t hs_id, const EventContext& ctx);
106};
107
108#endif // PILEUPMT_ONDEMANDMINBIASSVC_H
Maintain a set of objects, one per slot.
provides the relative beam intensity as a function of the bunch xing.
provides the relative beam luminosity as a function of the bunch xing.
ServiceHandle< StoreGateSvc > SGHandle
~OnDemandMinbiasSvc() final
Destructor.
virtual std::int64_t get_hs_id(const EventContext &ctx) const override
StatusCode initialize() final
AthService initialize.
IEvtSelector::Context * m_bkg_evt_sel_ctx
Gaudi::Property< int > m_latestDeltaBC
StatusCode beginHardScatter(const EventContext &ctx) override
StoreGateSvc * getMinbias(const EventContext &ctx, std::uint64_t mb_id) override
Gaudi::Property< bool > m_useBeamLumi
ServiceHandle< ActiveStoreSvc > m_activeStoreSvc
ServiceHandle< IEvtSelector > m_bkgEventSelector
std::size_t getNumForBunch(const EventContext &ctx, int bunch) const override
Gaudi::Property< int > m_skippedHSEvents
SG::SlotSpecificObj< std::vector< std::uint64_t >, SG::InvalidSlot::Enabled > m_num_mb_by_bunch
SG::SlotSpecificObj< std::vector< std::uint64_t > > m_idx_lists
Gaudi::Property< bool > m_useBeamInt
SG::SlotSpecificObj< std::vector< SGHandle > > m_stores
OnDemandMinbiasSvc(const std::string &name, ISvcLocator *svc)
Constructor.
Gaudi::Property< bool > m_usePoisson
Gaudi::Property< std::uint64_t > m_seed
static constexpr std::size_t s_NoSlot
std::atomic_int64_t m_last_loaded_hs
ServiceHandle< IProxyProviderSvc > m_proxyProviderSvc
ServiceHandle< IBeamIntensity > m_beamInt
StatusCode endHardScatter(const EventContext &ctx) override
ServiceHandle< ISkipEventIdxSvc > m_skipEventIdxSvc
Gaudi::Property< float > m_nPerBunch
std::size_t calcMBRequired(std::int64_t hs_id, const EventContext &ctx)
Gaudi::Property< bool > m_onDemandMB
ServiceHandle< IBeamLuminosity > m_beamLumi
Gaudi::Property< int > m_earliestDeltaBC
Maintain a set of objects, one per slot.
The Athena Transient Store API.