|
ATLAS Offline Software
|
Go to the documentation of this file.
9 #include <fmt/chrono.h>
10 #include <fmt/format.h>
11 #include <fmt/ostream.h>
15 #include <boost/core/demangle.hpp>
17 #include <range/v3/all.hpp>
21 #include "CLHEP/Random/RandPoisson.h"
22 #include "CLHEP/Random/RandomEngine.h"
24 #include "EventInfo/EventInfo.h"
35 namespace rv = ranges::views;
48 std::unique_ptr<const xAOD::EventInfo>& ei_,
49 std::unique_ptr<xAOD::EventAuxInfo>& ei_aux_,
51 std::string
key =
pileup ?
"EventInfo" :
"HSEventInfo";
66 return StatusCode::FAILURE;
73 if (attr_list_p !=
nullptr) {
74 if (attr_list_p->size() <= 6) {
78 const auto runNum = attr_list[
"RunNumber"].data<
unsigned>();
79 const auto evtNum = attr_list[
"EventNumber"].data<
unsigned long long>();
80 const auto lbNum = attr_list[
"LumiBlockN"].data<
unsigned>();
87 "Could not read Input attribute list and EventInfo has no event "
91 newEi->setEvtStore(&sg);
94 return StatusCode::SUCCESS;
98 const std::vector<std::uint32_t>&
bcid,
102 int bc,
const EventContext& ctx,
unsigned long subevt_id,
103 std::vector<std::uint64_t>& trace) {
107 std::unique_ptr<const xAOD::EventInfo> ei;
108 std::unique_ptr<xAOD::EventAuxInfo> eiAux;
120 return StatusCode::FAILURE;
122 return StatusCode::SUCCESS;
126 using namespace std::chrono;
130 fmt::format(
"pileup_trace_skipping-{}_{:%Y-%m-%dT%H%M}.txt",
164 fmt::memory_buffer trace_buf{};
165 auto trace = std::back_inserter(trace_buf);
167 fmt::format_to(trace,
"SKIPPING Run: {} LB: {} EVT: {} HS ID: {}\n",
168 it->runNum,
it->lbNum,
it->evtNum,
it->evtIdx);
170 m_pileupTrace.print(trace_buf);
171 return StatusCode::SUCCESS;
173 if (!m_skiptrace_written) {
175 m_skiptrace_written =
true;
178 return StatusCode::SUCCESS;
187 return StatusCode::SUCCESS;
192 fmt::memory_buffer trace_buf{};
193 auto trace = std::back_inserter(trace_buf);
195 const EventContext& ctx = Gaudi::Hive::currentContext();
196 const auto& evtID = ctx.eventID();
199 setFilterPassed(
false);
203 std::unique_ptr<const xAOD::EventInfo> hsEvt =
nullptr;
204 std::unique_ptr<xAOD::EventAuxInfo> hsEvtAux =
nullptr;
210 std::make_unique<xAOD::EventAuxInfo>()));
211 *overlaidEvt = *hsEvt;
220 overlaidEvt->
setBCID(evtID.bunch_crossing_id());
226 std::make_unique<xAOD::EventInfoAuxContainer>()));
229 m_beamInt->selectT0(evtID.run_number(), evtID.event_number());
237 bool sf_updated =
false;
238 float lumi_sf =
m_beamLumi->scaleFactor(evtID.run_number(),
239 evtID.lumi_block(), sf_updated);
240 float cur_avg_mu = lumi_sf *
m_avgMu;
247 fmt::format_to(trace,
248 "Idx: {} Run: {} LB: {} EVT: {} "
250 ctx.evt(), evtID.run_number(), evtID.lumi_block(),
255 [
this](
int bc) {
return int(
m_beamInt->normFactor(bc)); }) |
260 fmt::format_to(trace,
"mu = {}, central BCID = {}, bunch pattern = [{}]\n",
261 cur_avg_mu,
m_beamInt->getCurrentT0BunchCrossing(),
294 std::vector<std::uint32_t>
bcid{};
319 std::vector<std::uint64_t> subevts_vec{};
322 fmt::format_to(trace,
"\tBC {:03} : LOW PT {} ", bc,
325 for (std::size_t
i = 0;
i <
m_lowptMBSvc->getNumForBunch(ctx, bc); ++
i) {
334 fmt::format_to(trace,
"HIGH PT {} | ",
346 fmt::format_to(trace,
"CAVERN {} | ",
358 fmt::format_to(trace,
"BEAM HALO {} | ",
371 fmt::format_to(trace,
"BEAM GAS {} | ",
383 fmt::format_to(trace,
"TOTAL {} | HASH {:08X}\n", subevts_vec.size(),
388 fmt::format_to(trace,
"\n");
389 m_pileupTrace.print(trace_buf);
398 return StatusCode::FAILURE;
401 if (!
tool->filterPassed()) {
402 setFilterPassed(
false);
420 setFilterPassed(
true);
436 return StatusCode::SUCCESS;
def retrieve(aClass, aKey=None)
A helper class to compute a hash of pile-up events.
void setActualInteractionsPerCrossing(float value)
Set average interactions per crossing for the current BCID.
void setEventNumber(uint64_t value)
Set the current event's event number.
EventInfo_v1 EventInfo
Definition of the latest event info version.
uint64_t eventNumber() const
The current event's event number.
This class provides information about an overlaid event. It extends EventInfo with a list of sub-evts...
Gaudi::Property< float > m_numBeamHalo
virtual StatusCode initialize() override
uncomment and implement methods as required
Auxiliary information about the event.
virtual StatusCode finalize() override
void clearSubEvents()
Clear all the currently held sub-events.
ServiceHandle< IMinbiasSvc > m_lowptMBSvc
Other useful methods provided by base class are: evtStore() : ServiceHandle to main event data storeg...
Gaudi::Property< float > m_fracLowPt
PileUpType
Enumerator describing the types of pileup events.
static const std::type_info * CLIDToTypeinfo(CLID clid)
Translate between CLID and type_info.
static xAOD::EventInfo::PileUpMixtureID uuidToPileUpMixtureId(const uuid_t &hash)
Convert uuid_t to xAOD::EventInfo::PileUpMixtureID.
uint32_t eventTypeBitmask() const
The event type bitmask.
std::string hashSource() const
Get the current hash base.
const_pointer_type cptr() const
Dereference the pointer.
Gaudi::Property< int > m_latestDeltaBC
#define ATH_MSG_VERBOSE(x)
Gaudi::Property< float > m_avgMu
@ IS_SIMULATION
true: simulation, false: data
ServiceHandle< IBeamIntensity > m_beamInt
PileUpMixtureID pileUpMixtureID() const
Unique pile-up mixture identifier.
void handler(int sig)
signal handler
Gaudi::Property< bool > m_writeTrace
SG::WriteHandleKey< xAOD::EventInfoContainer > m_evtInfoContKey
Gaudi::Property< float > m_numCavern
Gaudi::Property< int > m_earliestDeltaBC
void setPileUpMixtureID(const PileUpMixtureID &value)
Set unique pile-up mixture identifier.
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode execute() override
The Athena Transient Store API.
ServiceHandle< IMinbiasSvc > m_highptMBSvc
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
std::string dump() const
dump objects in store.
std::string CLIDToString(const CLID &clid)
void setEventTypeBitmask(uint32_t value)
Set the event type bitmask.
Gaudi::Property< float > m_numBeamGas
void setStore(const SG::IConstAuxStore *store)
Set the store associated with this object.
ToolHandle< xAODMaker::IEventInfoCnvTool > m_xAODEICnvTool
std::vector< EvtId >::const_iterator EvtIter
::StatusCode StatusCode
StatusCode definition for legacy code.
pointer_type ptr()
Dereference the pointer.
const_pointer_type get() const
Dereference the pointer, but don't cache anything.
ServiceHandle< IBeamLuminosity > m_beamLumi
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
void addToHashSource(const std::string &string)
Add a plain string to the stream.
ServiceHandle< IMinbiasSvc > m_beamgasMBSvc
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
C++ native wrapper for the C xxhash API.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
unsigned int get_BCID(int bc, unsigned int central_BCID) const
void setTimeStamp(uint32_t value)
Set the POSIX time of the event.
void setBCID(uint32_t value)
Set the bunch crossing ID of the event.
ServiceHandle< IMinbiasSvc > m_beamhaloMBSvc
uint32_t CLID
The Class ID type.
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)
EventAuxInfo_v3 EventAuxInfo
Definition of the latest event auxiliary info version.
std::string join(const std::vector< std::string > &v, const char c=',')
ServiceHandle< IAthRNGSvc > m_rngSvc
Gaudi::Property< int > m_BCSpacing
void setAverageInteractionsPerCrossing(float value)
Set average interactions per crossing for all BCIDs.
Gaudi::Property< int > m_skippedHSEvents
setEventNumber setTimeStamp bcid
const T * tryConstRetrieve() const
Class describing the basic event information.
ServiceHandle< ISkipEventIdxSvc > m_skipEventIdxSvc
void setTimeStampNSOffset(uint32_t value)
Set the nanosecond offset wrt. the time stamp.
std::uint64_t hash64(const void *data, std::size_t size)
Passthrough to XXH3_64bits.
@ Signal
The signal event.
Gaudi::Property< float > m_fracHighPt
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
#define ATH_MSG_WARNING(x)
void setRunNumber(uint32_t value)
Set the current event's run number.
ServiceHandle< IMinbiasSvc > m_cavernMBSvc
PileUpMTAlg(const std::string &name, ISvcLocator *pSvcLocator)
void calculateHash(uuid_t &hash) const
Calculate the hash.
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
StatusCode get_ei(StoreGateSvc &sg, std::unique_ptr< const xAOD::EventInfo > &ei, std::unique_ptr< xAOD::EventAuxInfo > &eiAux, bool pileup=false) const
ToolHandleArray< IPileUpTool > m_puTools
void setLumiBlock(uint32_t value)
Set the current event's luminosity block number.
const std::vector< SubEvent > & subEvents() const
Get the pileup events that were used in the simulation.
uint32_t bcid() const
The bunch crossing ID of the event.
xAOD::EventInfo::SubEvent SubEvent
Class describing the properties of one pileup sub-event.
xAOD::EventInfo * addSubEvent(xAOD::EventInfo *targetEv, const xAOD::EventInfo::SubEvent &subev, xAOD::EventInfoContainer *eiContainer, const std::string &eiContKey, StoreGateSvc *subev_store=nullptr)
SG::WriteHandleKey< xAOD::EventInfo > m_evtInfoKey