5#ifndef PILEUPMT_PILEUPMTALG_H
6#define PILEUPMT_PILEUPMTALG_H
43 bool init(
const std::string& filename) {
44 using namespace std::chrono;
45 std::lock_guard lck{
m_mtx};
49 m_file = std::fopen(filename.c_str(),
"a");
53 auto time = system_clock::now();
54 auto header = std::format(
"FILE CREATED ON {:%Y-%m-%d} at {:%H:%M:%S %Z}\n",
60 std::lock_guard lck{
m_mtx};
68 std::lock_guard lck{
m_mtx};
76 PileUpMTAlg(
const std::string& name, ISvcLocator* pSvcLocator);
83 virtual StatusCode
execute()
override;
84 virtual StatusCode
finalize()
override;
87 virtual bool isClonable()
const override {
return true; }
101 "MinbiasSvc for low pT minbias"};
103 "MinbiasSvc for high pT minbias"};
105 "MinbiasSvc for cavern background"};
107 this,
"BeamHaloMinbiasSvc",
"",
"MinbiasSvc for beam halo background"};
109 this,
"BeamGasMinbiasSvc",
"",
"MinbiasSvc for beam gas background"};
111 "Beam intensity service"};
113 this,
"BeamLumiSvc",
"LumiProfileSvc",
"Beam luminosity service"};
115 "RNG service for pile-up digitization"};
117 this,
"PileUpTools", {},
"Pileup tools"};
118 Gaudi::Property<bool>
m_writeTrace{
this,
"WriteTrace",
false,
"Write trace of pileup events used"};
120 "Number of skipped HS events"};
121 Gaudi::Property<float>
m_avgMu{
this,
"AverageMu", 200,
"Average mu"};
123 "Fraction of pileup that has low pT"};
125 "Fraction of pileup that has high pT"};
127 this,
"NumCavern", 0.,
"Number of cavern background events per BC"};
129 this,
"NumBeamGas", 0.,
"Number of beam gas background events per BC"};
131 this,
"NumBeamHalo", 0.,
"Number of beam halo background events per BC"};
133 "Bunch crossing spacing in ns"};
135 this,
"EarliestDeltaBC", -32,
136 "Earliest bunch crossing to consider (as delta)"};
138 this,
"LatestDeltaBC", +6,
139 "Latest bunch crossing to consider (as delta)"};
141 this,
"SkipEvtIdxSvc",
"SkipEventIdxSvc",
142 "Skipped event index (run / lb num) provider"};
144 this,
"BeamSpotKey",
"BeamSpotData",
"Beam spot info key"};
146 this,
"EventInfoKey",
"OverlayEvent",
"Overlay EventInfo key"};
150 std::unique_ptr<const xAOD::EventInfo>& ei,
151 std::unique_ptr<xAOD::EventAuxInfo>& eiAux,
152 bool pileup =
false)
const;
153 inline unsigned int get_BCID(
int bc,
unsigned int central_BCID)
const {
154 constexpr int maxBCPerOrbit = 3564;
155 return static_cast<unsigned int>((bc +
static_cast<int>(central_BCID)) %
158 StatusCode
add_subevt(
const std::vector<std::uint32_t>& bcid,
163 const EventContext& ctx,
unsigned long subevt_id,
164 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.
atomic_output(const atomic_output &)=delete
atomic_output & operator=(const atomic_output &)=delete
bool init(const std::string &filename)
void print(const std::string &str)
PileUpType
Enumerator describing the types of pileup events.