ATLAS Offline Software
Loading...
Searching...
No Matches
OnDemandMinbiasSvc.h
Go to the documentation of this file.
1/* -*- C++ -*- */
2/*
3 Copyright (C) 2002-2024 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
19#include "Gaudi/Property.h"
20#include "GaudiKernel/IEvtSelector.h"
21#include "GaudiKernel/ServiceHandle.h"
27
28class OnDemandMinbiasSvc final : public extends<AthService, IMinbiasSvc> {
29 public:
31 OnDemandMinbiasSvc(const std::string& name, ISvcLocator* svc);
33 ~OnDemandMinbiasSvc() final;
34
36 StatusCode initialize() final;
37
38 StatusCode beginHardScatter(const EventContext& ctx) override;
39 StoreGateSvc* getMinbias(const EventContext& ctx,
40 std::uint64_t mb_id) override;
41 std::size_t getNumForBunch(const EventContext& ctx, int bunch) const override;
42 inline virtual
43 std::int64_t get_hs_id(const EventContext& ctx) const override {
44 return m_skippedHSEvents.value() + ctx.evt();
45 }
46
47 StatusCode endHardScatter(const EventContext& ctx) override;
48
49 private:
51
52 Gaudi::Property<std::uint64_t> m_seed{this, "Seed", 0,
53 "Additional seed for PRNGs"};
54 Gaudi::Property<bool> m_onDemandMB{
55 this, "OnDemandMB", false,
56 "Should minbias event contents be read on demand"};
57 Gaudi::Property<int> m_skippedHSEvents{this, "SkippedHSEvents", 0,
58 "Number of skipped HS events"};
59 Gaudi::Property<float> m_nPerBunch{
60 this, "AvgMBPerBunch", 0.f,
61 "Average (max) number of minbias events per bunch"};
62 Gaudi::Property<bool> m_usePoisson{this, "UsePoisson", true,
63 "Whether to use a Poisson distribution "
64 "(if False, use a delta distribution)"};
65 Gaudi::Property<bool> m_useBeamInt{
66 this, "UseBeamInt", true, "Whether to use the beam intensity service"};
67 Gaudi::Property<bool> m_useBeamLumi{
68 this, "UseBeamLumi", true, "Whether to use the beam luminosity service"};
69 Gaudi::Property<int> m_earliestDeltaBC{
70 this, "EarliestDeltaBC", -32,
71 "Earliest bunch crossing to consider (as delta)"};
72 Gaudi::Property<int> m_latestDeltaBC{
73 this, "LatestDeltaBC", +6,
74 "Latest bunch crossing to consider (as delta)"};
76 this, "SkipEvtIdxSvc", "SkipEventIdxSvc",
77 "Skipped event index (run / lb num) provider"};
79 this, "BkgEventSelector", {}, "Event selector for minbias events"};
80 ServiceHandle<IBeamIntensity> m_beamInt{this, "BeamIntSvc", "FlatBM",
81 "Beam intensity service"};
83 this, "BeamLumiSvc", "LumiProfileSvc", "Beam luminosity service"};
85 this, "ActiveStoreSvc", "ActiveStoreSvc", "ActiveStoreSvc"};
86
87 SGHandle m_spare_store{this, "StoreGateSvc",
88 std::format("StoreGateSvc/discards_{}", name()),
89 "StoreGate for discarding events"};
90 IEvtSelector::Context* m_bkg_evt_sel_ctx;
92
93 std::vector<std::vector<SGHandle>> m_stores;
94 std::vector<std::vector<std::uint64_t>> m_num_mb_by_bunch;
95 std::vector<std::vector<std::uint64_t>> m_idx_lists;
96 // prevents attempting to read multiple batches at once
98 std::atomic_int64_t m_last_loaded_hs{-1};
99
100 static constexpr std::size_t s_NoSlot =
101 std::numeric_limits<std::size_t>::max(); // "slot" to pass when we don't
102 // have a slot
103 std::size_t calcMBRequired(std::int64_t hs_id, std::size_t slot,
104 unsigned int run, unsigned int lumi,
105 std::uint64_t event);
106};
107
108#endif // PILEUPMT_ONDEMANDMINBIASSVC_H
provides the relative beam intensity as a function of the bunch xing.
provides the relative beam luminosity as a function of the bunch xing.
std::vector< std::vector< std::uint64_t > > m_num_mb_by_bunch
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::vector< std::vector< SGHandle > > m_stores
std::size_t getNumForBunch(const EventContext &ctx, int bunch) const override
Gaudi::Property< int > m_skippedHSEvents
Gaudi::Property< bool > m_useBeamInt
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::vector< std::vector< std::uint64_t > > m_idx_lists
Gaudi::Property< bool > m_onDemandMB
std::size_t calcMBRequired(std::int64_t hs_id, std::size_t slot, unsigned int run, unsigned int lumi, std::uint64_t event)
ServiceHandle< IBeamLuminosity > m_beamLumi
Gaudi::Property< int > m_earliestDeltaBC
The Athena Transient Store API.
Definition run.py:1