5#ifndef PILEUPMT_PILEUPMTALG_H
6#define PILEUPMT_PILEUPMTALG_H
40 bool init(
const std::string& filename) {
41 using namespace std::chrono;
42 std::lock_guard lck{
m_mtx};
46 m_file = std::fopen(filename.c_str(),
"a");
50 auto time = system_clock::now();
51 auto header = std::format(
"FILE CREATED ON {:%Y-%m-%d} at {:%H:%M:%S %Z}\n",
57 std::lock_guard lck{
m_mtx};
65 std::lock_guard lck{
m_mtx};
73 PileUpMTAlg(
const std::string& name, ISvcLocator* pSvcLocator);
80 virtual StatusCode
execute()
override;
81 virtual StatusCode
finalize()
override;
84 virtual bool isClonable()
const override {
return true; }
98 "MinbiasSvc for low pT minbias"};
100 "MinbiasSvc for high pT minbias"};
102 "MinbiasSvc for cavern background"};
104 this,
"BeamHaloMinbiasSvc",
"",
"MinbiasSvc for beam halo background"};
106 this,
"BeamGasMinbiasSvc",
"",
"MinbiasSvc for beam gas background"};
108 "Beam intensity service"};
110 this,
"BeamLumiSvc",
"LumiProfileSvc",
"Beam luminosity service"};
112 "RNG service for pile-up digitization"};
114 this,
"PileUpTools", {},
"Pileup tools"};
115 Gaudi::Property<bool>
m_writeTrace{
this,
"WriteTrace",
false,
"Write trace of pileup events used"};
117 "Number of skipped HS events"};
118 Gaudi::Property<float>
m_avgMu{
this,
"AverageMu", 200,
"Average mu"};
120 "Fraction of pileup that has low pT"};
122 "Fraction of pileup that has high pT"};
124 this,
"NumCavern", 0.,
"Number of cavern background events per BC"};
126 this,
"NumBeamGas", 0.,
"Number of beam gas background events per BC"};
128 this,
"NumBeamHalo", 0.,
"Number of beam halo background events per BC"};
130 "Bunch crossing spacing in ns"};
132 this,
"EarliestDeltaBC", -32,
133 "Earliest bunch crossing to consider (as delta)"};
135 this,
"LatestDeltaBC", +6,
136 "Latest bunch crossing to consider (as delta)"};
138 this,
"SkipEvtIdxSvc",
"SkipEventIdxSvc",
139 "Skipped event index (run / lb num) provider"};
141 this,
"BeamSpotKey",
"BeamSpotData",
"Beam spot info key"};
143 this,
"EventInfoKey",
"OverlayEvent",
"Overlay EventInfo key"};
147 std::unique_ptr<const xAOD::EventInfo>& ei,
148 std::unique_ptr<xAOD::EventAuxInfo>& eiAux,
149 bool pileup =
false)
const;
150 inline unsigned int get_BCID(
int bc,
unsigned int central_BCID)
const {
151 constexpr int maxBCPerOrbit = 3564;
152 return static_cast<unsigned int>((bc +
static_cast<int>(central_BCID)) %
155 StatusCode
add_subevt(
const std::vector<std::uint32_t>& bcid,
160 const EventContext& ctx,
unsigned long subevt_id,
161 std::vector<std::uint64_t>& trace);
provides the relative beam intensity as a function of the bunch xing.
provides the relative beam luminosity as a function of the bunch xing.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Property< int > m_earliestDeltaBC
virtual StatusCode initialize() override
uncomment and implement methods as required
Gaudi::Property< int > m_latestDeltaBC
Gaudi::Property< bool > m_writeTrace
Gaudi::Property< float > m_avgMu
PileUpMTAlg(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< float > m_numCavern
virtual bool isClonable() const override
unsigned int get_BCID(int bc, unsigned int central_BCID) const
virtual StatusCode execute() override
Gaudi::Property< float > m_fracLowPt
static atomic_output m_pileupTrace ATLAS_THREAD_SAFE
ServiceHandle< IBeamLuminosity > m_beamLumi
ToolHandleArray< IPileUpTool > m_puTools
SG::WriteHandleKey< xAOD::EventInfoContainer > m_evtInfoContKey
ServiceHandle< IAthRNGSvc > m_rngSvc
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
StatusCode get_ei(StoreGateSvc &sg, std::unique_ptr< const xAOD::EventInfo > &ei, std::unique_ptr< xAOD::EventAuxInfo > &eiAux, bool pileup=false) const
ServiceHandle< IMinbiasSvc > m_beamgasMBSvc
ServiceHandle< IMinbiasSvc > m_highptMBSvc
ServiceHandle< IMinbiasSvc > m_cavernMBSvc
Gaudi::Property< float > m_fracHighPt
SG::WriteHandleKey< xAOD::EventInfo > m_evtInfoKey
ServiceHandle< IBeamIntensity > m_beamInt
ServiceHandle< ISkipEventIdxSvc > m_skipEventIdxSvc
Gaudi::Property< int > m_skippedHSEvents
ServiceHandle< IMinbiasSvc > m_lowptMBSvc
Other useful methods provided by base class are: evtStore() : ServiceHandle to main event data storeg...
Gaudi::Property< float > m_numBeamGas
Gaudi::Property< float > m_numBeamHalo
virtual StatusCode finalize() override
StatusCode add_subevt(const std::vector< std::uint32_t > &bcid, SG::WriteHandle< xAOD::EventInfo > &overlaidEvt, SG::WriteHandle< xAOD::EventInfoContainer > &puCont, ServiceHandle< IMinbiasSvc > &mbSvc, xAOD::EventInfo::PileUpType puType, int bc, const EventContext &ctx, unsigned long subevt_id, std::vector< std::uint64_t > &trace)
ServiceHandle< IMinbiasSvc > m_beamhaloMBSvc
Gaudi::Property< int > m_BCSpacing
Property holding a SG store/key/clid from which a WriteHandle is made.
The Athena Transient Store API.
bool init(const std::string &filename)
void print(const std::string &str)
PileUpType
Enumerator describing the types of pileup events.