Project
Loading...
Searching...
No Matches
o2::aodmchelpers Namespace Reference

Classes

struct  TableCursor
 

Typedefs

using CollisionCursor = TableCursor< aod::McCollisions >::type
 
using ParticleCursor = TableCursor< aod::StoredMcParticles_001 >::type
 
using XSectionCursor = TableCursor< aod::HepMCXSections >::type
 
using PdfInfoCursor = TableCursor< aod::HepMCPdfInfos >::type
 
using HeavyIonCursor = TableCursor< aod::HepMCHeavyIons >::type
 
using TrackToIndex = std::unordered_map< int, int >
 

Enumerations

enum  HepMCUpdate { never , always , anyKey , allKeys }
 

Functions

bool hasKeys (o2::dataformats::MCEventHeader const &header, const std::vector< std::string > &keys, bool anyNotall=true)
 
template<typename T >
const T getEventInfo (o2::dataformats::MCEventHeader const &header, std::string const &key, T const &def)
 
short updateMCCollisions (const CollisionCursor &cursor, int bcId, float time, o2::dataformats::MCEventHeader const &header, short generatorId=0, int sourceId=0, unsigned int mask=0xFFFFFFF0)
 
bool updateHepMCXSection (const XSectionCursor &cursor, int collisionID, short generatorID, o2::dataformats::MCEventHeader const &header, HepMCUpdate when=HepMCUpdate::anyKey)
 
bool updateHepMCPdfInfo (const PdfInfoCursor &cursor, int collisionID, short generatorID, o2::dataformats::MCEventHeader const &header, HepMCUpdate when=HepMCUpdate::anyKey)
 
bool updateHepMCHeavyIon (const HeavyIonCursor &cursor, int collisionID, short generatorID, o2::dataformats::MCEventHeader const &header, HepMCUpdate when=HepMCUpdate::anyKey)
 
void updateParticle (const ParticleCursor &cursor, const TrackToIndex &toStore, int collisionID, o2::MCTrack const &track, std::vector< MCTrack > const &tracks, uint8_t flags=0, uint32_t weightMask=0xFFFFFFF0, uint32_t momentumMask=0xFFFFFFF0, uint32_t positionMask=0xFFFFFFF0)
 
uint32_t updateParticles (const ParticleCursor &cursor, int collisionID, std::vector< MCTrack > const &tracks, TrackToIndex &preselect, uint32_t offset=0, bool filter=false, bool background=false, uint32_t weightMask=0xFFFFFFF0, uint32_t momentumMask=0xFFFFFFF0, uint32_t positionMask=0xFFFFFFF0)
 

Detailed Description

Utilities to transform simulated data into AO2D tables.

The function templates below are templated on the cursor type over the relevant AOD tables. Such a table can be obtained from the ProcessingContext pc

auto builder = pc.make<TableBulder>(OutputForTable<Table>::ref());
auto cursor = builder->cursor<Table>();

If the task uses the Produces<Table> template,

then a cursor is obtained via,

auto cursor = mTable.cursor;
decltype(FFL(std::declval< cursor_t >())) cursor

Note that these functions cannot be moved into a compilation unit, because that would require deducing the table cursor type, by f.ex.

template <typename Table>
struct TableCursor {
using cursor_t = decltype(std::declval<framework::TableBuilder>()
.cursor<Table>());
};
using CollisionCursor = TableCursor<aod::McCollisions>:cursor_t;
TableCursor< aod::McCollisions >::type CollisionCursor

but since cursors are really Lambdas and Lambda types are specific to the compilation unit, then the implementation file (compilation unit) of these functions definitions and their use (another compilation unit) would have different types of the the cursers, and thus not be able to link. More information is given at https://stackoverflow.com/questions/50033797.

Typedef Documentation

◆ CollisionCursor

◆ HeavyIonCursor

using o2::aodmchelpers::HeavyIonCursor = typedef TableCursor<aod::HepMCHeavyIons>::type

Cursor over aod::HepMCHeavyIons

Definition at line 92 of file AODMcProducerHelpers.h.

◆ ParticleCursor

using o2::aodmchelpers::ParticleCursor = typedef TableCursor<aod::StoredMcParticles_001>::type

Cursor over aod::McParticles

Definition at line 86 of file AODMcProducerHelpers.h.

◆ PdfInfoCursor

using o2::aodmchelpers::PdfInfoCursor = typedef TableCursor<aod::HepMCPdfInfos>::type

Cursor over aod::HepMCPdfInfos

Definition at line 90 of file AODMcProducerHelpers.h.

◆ TrackToIndex

using o2::aodmchelpers::TrackToIndex = typedef std::unordered_map<int, int>

Type of mapping from track number to row index

Definition at line 229 of file AODMcProducerHelpers.h.

◆ XSectionCursor

using o2::aodmchelpers::XSectionCursor = typedef TableCursor<aod::HepMCXSections>::type

Cursor over aod::HepMCXSections

Definition at line 88 of file AODMcProducerHelpers.h.

Enumeration Type Documentation

◆ HepMCUpdate

Types of updates on HepMC tables.

Enumerator
never 
always 
anyKey 
allKeys 

Definition at line 95 of file AODMcProducerHelpers.h.

Function Documentation

◆ getEventInfo()

template<typename T >
const T o2::aodmchelpers::getEventInfo ( o2::dataformats::MCEventHeader const &  header,
std::string const &  key,
T const &  def 
)

Get a property from the header, or if not set or not valid, a default value.

Parameters
headerThe MC event header
keyKey to look for
defValue to return if key is not found
Returns
Value of key or def if key is not found

Definition at line 131 of file AODMcProducerHelpers.h.

◆ hasKeys()

bool o2::aodmchelpers::hasKeys ( o2::dataformats::MCEventHeader const &  header,
const std::vector< std::string > &  keys,
bool  anyNotall = true 
)

Check if header has keys. If the argument anyNotAll is true, then this member function returns true if any of the keys were found. If anyNotAll is false, then return true only if all keys were found.

Parameters
headerMC event header
keysKeys to look for
anyNotAllIf true, return true if any key was found. If false, return true only if all keys were found
Returns
true if any or all keys were found

Definition at line 25 of file AODMcProducerHelpers.cxx.

◆ updateHepMCHeavyIon()

bool o2::aodmchelpers::updateHepMCHeavyIon ( const HeavyIonCursor cursor,
int  collisionID,
short  generatorID,
o2::dataformats::MCEventHeader const &  header,
HepMCUpdate  when = HepMCUpdate::anyKey 
)

Fill in HepMC heavy-ion table from generator event header.

Parameters
cursorCursor over o2::aod::HepMCXSections table
collisionIDIdentifier of collision (as given updateMCCollision)
generatorIDEncoded generator ID
headerEvent header from generator
anyNotAllIf true, then any key present trigger and update. If false, then all keys must be present to update the table.
Returns
true if table was updated

Definition at line 147 of file AODMcProducerHelpers.cxx.

◆ updateHepMCPdfInfo()

bool o2::aodmchelpers::updateHepMCPdfInfo ( const PdfInfoCursor cursor,
int  collisionID,
short  generatorID,
o2::dataformats::MCEventHeader const &  header,
HepMCUpdate  when = HepMCUpdate::anyKey 
)

Fill in HepMC parton distribution function table from event generator header

Parameters
cursorCursor over o2::aod::HepMCXSections table
collisionIDIdentifier of collision (as given updateMCCollision)
generatorIDEncoded generator ID
headerEvent header from generator
anyNotAllIf true, then any key present trigger and update. If false, then all keys must be present to update the table.
Returns
true if table was updated

Definition at line 107 of file AODMcProducerHelpers.cxx.

◆ updateHepMCXSection()

bool o2::aodmchelpers::updateHepMCXSection ( const XSectionCursor cursor,
int  collisionID,
short  generatorID,
o2::dataformats::MCEventHeader const &  header,
HepMCUpdate  when = HepMCUpdate::anyKey 
)

Fill in HepMC cross-section table from event generator header.

Parameters
cursorCursor over o2::aod::HepMCXSections table
collisionIDIdentifier of collision (as given updateMCCollision)
generatorIDEncoded generator ID
headerEvent header from generator
anyNotAllIf true, then any key present trigger and update. If false, then all keys must be present to update the table.
Returns
true if table was updated

Definition at line 73 of file AODMcProducerHelpers.cxx.

◆ updateMCCollisions()

short o2::aodmchelpers::updateMCCollisions ( const CollisionCursor cursor,
int  bcId,
float  time,
o2::dataformats::MCEventHeader const &  header,
short  generatorId = 0,
int  sourceId = 0,
unsigned int  mask = 0xFFFFFFF0 
)

Fill in collision information. This is read from the passed MC header and stored in the MCCollision table. The member function returns the encoded generator ID.

Parameters
cursorCursor over o2::aod::McCollisions table
bcIdBunch-crossing Identifier
timeTime of collisions
headerEvent header from generator
generatorIdDefault generator
sourceIdIdentifier of source
Returns
encoded generator ID

Definition at line 38 of file AODMcProducerHelpers.cxx.

◆ updateParticle()

void o2::aodmchelpers::updateParticle ( const ParticleCursor cursor,
const TrackToIndex toStore,
int  collisionID,
o2::MCTrack const &  track,
std::vector< MCTrack > const &  tracks,
uint8_t  flags = 0,
uint32_t  weightMask = 0xFFFFFFF0,
uint32_t  momentumMask = 0xFFFFFFF0,
uint32_t  positionMask = 0xFFFFFFF0 
)

Update aod::McParticles table with information from an MC track.

Parameters
cursorCursor over aod::McParticles table
mappingMaps track number to index in table
collisionIDCollision identifier
trackTrack to update table with
tracksList of all tracks of current collision
flagsBase flags of this track
weightMaskMask on weight floating point value
momentumMaskMask on momentum floating point values
positionMaskMask on position floating point values

Definition at line 204 of file AODMcProducerHelpers.cxx.

◆ updateParticles()

uint32_t o2::aodmchelpers::updateParticles ( const ParticleCursor cursor,
int  collisionID,
std::vector< MCTrack > const &  tracks,
TrackToIndex preselect,
uint32_t  offset = 0,
bool  filter = false,
bool  background = false,
uint32_t  weightMask = 0xFFFFFFF0,
uint32_t  momentumMask = 0xFFFFFFF0,
uint32_t  positionMask = 0xFFFFFFF0 
)

Update aod::McParticles table with tracks from MC.

To add particles from many events, one will do

TrackToIndex preselect = findMcTracksToStore(...);
size_t offset = 0;
for (auto event : events)
event.getCollisionID(),
event.getTracks(),
event.isBackground(),
preselect);
struct _cl_event * event
Definition glcorearb.h:2982
GLintptr offset
Definition glcorearb.h:660
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition glcorearb.h:1308
std::unordered_map< int, int > TrackToIndex
uint32_t updateParticles(const ParticleCursor &cursor, int collisionID, std::vector< MCTrack > const &tracks, TrackToIndex &preselect, uint32_t offset=0, bool filter=false, bool background=false, uint32_t weightMask=0xFFFFFFF0, uint32_t momentumMask=0xFFFFFFF0, uint32_t positionMask=0xFFFFFFF0)

Here preselect must be a map from track number to a positive value. Tracks that are mapped as such in preselect are stored in addition to other tracks selected by the function. Note that preselect may be empty.

If filter is false, then all tracks will be stored.

If filter is true, then tracks that are

  • generated by the generator,
  • physical primaries (MCTrackNavigator::isPhysicalPrimary),
  • to be kept for physics (MCTrackNavigator::isKeepPhysics), or
  • is listed with a positive value in preselect, or
  • either a mother or daughter of one such track, then

that track is kept

On return, the preselect will map from track number (index in the tracks container) to the table row index (including offset from previous events in the same time-frame).

Parameters
cursorCursor over aod::McParticles
intCollision identifier
tracksList of all tracks of current collision
offsetIndex just beyond last table entry
filterFilter tracks
backgroundTrue of from background event
preselectMapping of preselected tracks
weightMaskMask on weight floating point value
momentumMaskMask on momentum floating point values
positionMaskMask on position floating point values
Returns
Index beyond the last particle added to table

Definition at line 299 of file AODMcProducerHelpers.cxx.