Skip to content

Commit 9a6abee

Browse files
authored
ITSMFT: add asString() for clusters (#14130)
Allows to get formatted string of clusters. Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent d8b8f6c commit 9a6abee

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

DataFormats/Detectors/ITSMFT/common/include/DataFormatsITSMFT/CompCluster.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class CompCluster
8888
}
8989

9090
void print() const;
91+
std::string asString() const;
9192

9293
ClassDefNV(CompCluster, 2);
9394
};
@@ -97,7 +98,7 @@ class CompCluster
9798
class CompClusterExt : public CompCluster
9899
{
99100
private:
100-
UShort_t mChipID; ///< chip id
101+
UShort_t mChipID; ///< chip id
101102

102103
public:
103104
CompClusterExt(UShort_t row = 0, UShort_t col = 0, UShort_t patt = 0, UShort_t chipID = 0) : CompCluster(row, col, patt), mChipID(chipID)
@@ -116,6 +117,7 @@ class CompClusterExt : public CompCluster
116117
void setChipID(UShort_t c) { mChipID = c; }
117118

118119
void print() const;
120+
std::string asString() const;
119121

120122
ClassDefNV(CompClusterExt, 1);
121123
};

DataFormats/Detectors/ITSMFT/common/src/CompCluster.cxx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,32 @@
1515
#include "DataFormatsITSMFT/CompCluster.h"
1616
#include <cassert>
1717
#include <iostream>
18+
#include <format>
1819

1920
using namespace o2::itsmft;
2021

2122
std::ostream& operator<<(std::ostream& stream, const CompCluster& cl)
2223
{
23-
stream << " row: " << cl.getRow() << " col: " << cl.getCol()
24-
<< " pattID " << cl.getPatternID() << " [flag: " << cl.getFlag() << "] ";
24+
stream << cl.asString();
2525
return stream;
2626
}
2727

2828
std::ostream& operator<<(std::ostream& stream, const CompClusterExt& cl)
2929
{
30-
stream << " chip: " << cl.getChipID() << ((const CompCluster&)cl);
30+
stream << cl.asString();
3131
return stream;
3232
}
3333

34+
std::string CompCluster::asString() const
35+
{
36+
return std::format(" row: {:4d} col: {:4d} pattID: {:4d} [flag: {:1d}]", getRow(), getCol(), getPatternID(), getFlag());
37+
}
38+
39+
std::string CompClusterExt::asString() const
40+
{
41+
return std::format(" chip: {:5d} row: {:4d} col: {:4d} pattID: {:4d} [flag: {:1d}]", getChipID(), getRow(), getCol(), getPatternID(), getFlag());
42+
}
43+
3444
//______________________________________________________________________________
3545
void CompCluster::print() const
3646
{

0 commit comments

Comments
 (0)