Loading [MathJax]/extensions/tex2jax.js
 |
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>
14 #include <boost/core/demangle.hpp>
16 #include <range/v3/all.hpp>
18 #include "EventInfo/EventInfo.h"
28 namespace rv = ranges::views;
41 std::unique_ptr<const xAOD::EventInfo>& ei_,
42 std::unique_ptr<xAOD::EventAuxInfo>& ei_aux_,
44 std::string
key =
pileup ?
"EventInfo" :
"HSEventInfo";
59 return StatusCode::FAILURE;
66 if (attr_list_p !=
nullptr) {
67 if (attr_list_p->size() <= 6) {
71 const auto runNum = attr_list[
"RunNumber"].data<
unsigned>();
72 const auto evtNum = attr_list[
"EventNumber"].data<
unsigned long long>();
73 const auto lbNum = attr_list[
"LumiBlockN"].data<
unsigned>();
80 "Could not read Input attribute list and EventInfo has no event "
84 newEi->setEvtStore(&sg);
87 return StatusCode::SUCCESS;
91 const std::vector<std::uint32_t>&
bcid,
95 int bc,
const EventContext& ctx,
unsigned long subevt_id,
96 std::vector<std::uint64_t>& trace) {
100 std::unique_ptr<const xAOD::EventInfo> ei;
101 std::unique_ptr<xAOD::EventAuxInfo> eiAux;
113 return StatusCode::FAILURE;
115 return StatusCode::SUCCESS;
119 using namespace std::chrono;
123 fmt::format(
"pileup_trace_skipping-{}_{:%Y-%m-%dT%H%M}.txt",
158 fmt::memory_buffer trace_buf{};
159 auto trace = std::back_inserter(trace_buf);
161 fmt::format_to(trace,
"SKIPPING Run: {} LB: {} EVT: {} HS ID: {}\n",
162 it->runNum,
it->lbNum,
it->evtNum,
it->evtIdx);
164 m_pileupTrace.print(trace_buf);
165 return StatusCode::SUCCESS;
167 if (!m_skiptrace_written) {
169 m_skiptrace_written =
true;
172 return StatusCode::SUCCESS;
181 return StatusCode::SUCCESS;
186 fmt::memory_buffer trace_buf{};
187 auto trace = std::back_inserter(trace_buf);
189 const EventContext& ctx = Gaudi::Hive::currentContext();
190 const auto& evtID = ctx.eventID();
193 setFilterPassed(
false);
197 std::unique_ptr<const xAOD::EventInfo> hsEvt =
nullptr;
198 std::unique_ptr<xAOD::EventAuxInfo> hsEvtAux =
nullptr;
204 std::make_unique<xAOD::EventAuxInfo>()));
205 *overlaidEvt = *hsEvt;
214 overlaidEvt->
setBCID(evtID.bunch_crossing_id());
219 if (!beamSpotHandle.isValid()) {
221 return StatusCode::FAILURE;
225 beamSpotHandle->beamPos()[
Amg::y],
226 beamSpotHandle->beamPos()[
Amg::z]);
228 beamSpotHandle->beamSigma(1),
229 beamSpotHandle->beamSigma(2));
238 std::make_unique<xAOD::EventInfoAuxContainer>()));
241 m_beamInt->selectT0(evtID.run_number(), evtID.event_number());
249 bool sf_updated =
false;
250 float lumi_sf =
m_beamLumi->scaleFactor(evtID.run_number(),
251 evtID.lumi_block(), sf_updated);
252 float cur_avg_mu = lumi_sf *
m_avgMu;
259 fmt::format_to(trace,
260 "Idx: {} Run: {} LB: {} EVT: {} "
262 ctx.evt(), evtID.run_number(), evtID.lumi_block(),
267 [
this](
int bc) {
return int(
m_beamInt->normFactor(bc)); }) |
268 #
if RANGE_V3_VERSION >= 1200
269 rv::chunk_by(std::equal_to{}) |
271 rv::group_by(std::equal_to{}) |
277 fmt::format_to(trace,
"mu = {}, central BCID = {}, bunch pattern = [{}]\n",
278 cur_avg_mu,
m_beamInt->getCurrentT0BunchCrossing(),
311 std::vector<std::uint32_t>
bcid{};
336 std::vector<std::uint64_t> subevts_vec{};
339 fmt::format_to(trace,
"\tBC {:03} : LOW PT {} ", bc,
342 for (std::size_t
i = 0;
i <
m_lowptMBSvc->getNumForBunch(ctx, bc); ++
i) {
351 fmt::format_to(trace,
"HIGH PT {} | ",
363 fmt::format_to(trace,
"CAVERN {} | ",
375 fmt::format_to(trace,
"BEAM HALO {} | ",
388 fmt::format_to(trace,
"BEAM GAS {} | ",
400 fmt::format_to(trace,
"TOTAL {} | HASH {:08X}\n", subevts_vec.size(),
405 fmt::format_to(trace,
"\n");
406 m_pileupTrace.print(trace_buf);
415 return StatusCode::FAILURE;
418 if (!
tool->filterPassed()) {
419 setFilterPassed(
false);
437 setFilterPassed(
true);
453 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.
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.
void setBeamPos(float x, float y, float z)
Set the beam spot position.
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.
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
Gaudi::Property< int > m_latestDeltaBC
#define ATH_MSG_VERBOSE(x)
void setBeamPosSigma(float x, float y, float z)
Set the size of the beam spot.
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
void setBeamTiltYZ(float value)
Set the beam's tilt in radians in YZ.
Gaudi::Property< int > m_earliestDeltaBC
void setPileUpMixtureID(const PileUpMixtureID &value)
Set unique pile-up mixture identifier.
void setBeamStatus(uint32_t value)
Set the beam spot's status word.
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
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)
void setBeamPosSigmaXY(float value)
Set the beam spot shape's X-Y correlation.
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
StatusCode initialize(bool used=true)
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 setBeamTiltXZ(float value)
Set the beam's tilt in radians in XZ.
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