Skip to content

Commit d23bf26

Browse files
committed
Add asString getter to MCCompLabel
1 parent 4034611 commit d23bf26

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

DataFormats/simulation/include/SimulationDataFormat/MCCompLabel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include <cstdint>
1616
#include "GPUCommonRtypes.h"
17+
#include <string>
1718

1819
namespace o2
1920
{
@@ -138,6 +139,7 @@ class MCCompLabel
138139
}
139140

140141
void print() const;
142+
std::string asString() const;
141143

142144
static constexpr int maxSourceID() { return maskSrcID; }
143145
static constexpr int maxEventID() { return maskEvID; }

DataFormats/simulation/src/MCCompLabel.cxx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <ios>
1515
#include <iostream>
1616
#include <cassert>
17+
#include <fmt/format.h>
1718

1819
namespace o2
1920
{
@@ -31,6 +32,16 @@ std::ostream& operator<<(std::ostream& os, MCCompLabel const& c)
3132
return os;
3233
}
3334

35+
//_____________________________________________
36+
std::string MCCompLabel::asString() const
37+
{
38+
// describe itself
39+
if (isValid()) {
40+
return fmt::format("[{}/{}{}/{:6d}]", getSourceID(), getEventID(), isFake() ? '-' : '+', getTrackID());
41+
}
42+
return isNoise() ? "[noise]" : "[unset]";
43+
}
44+
3445
//_____________________________________________
3546
void MCCompLabel::print() const
3647
{

0 commit comments

Comments
 (0)