Skip to content

Commit 11e00c0

Browse files
committed
Register contributions from all sources in vertex-track references
1 parent 8f5e731 commit 11e00c0

File tree

13 files changed

+185
-27
lines changed

13 files changed

+185
-27
lines changed

DataFormats/Reconstruction/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ o2_add_library(ReconstructionDataFormats
2020
src/PID.cxx
2121
src/DCA.cxx
2222
src/VtxTrackIndex.cxx
23+
src/VtxTrackRef.cxx
2324
PUBLIC_LINK_LIBRARIES O2::GPUCommon
2425
O2::DetectorsCommonDataFormats
2526
O2::CommonDataFormat)
@@ -36,7 +37,8 @@ o2_target_root_dictionary(
3637
include/ReconstructionDataFormats/TrackLTIntegral.h
3738
include/ReconstructionDataFormats/PID.h
3839
include/ReconstructionDataFormats/DCA.h
39-
include/ReconstructionDataFormats/VtxTrackIndex.h)
40+
include/ReconstructionDataFormats/VtxTrackIndex.h
41+
include/ReconstructionDataFormats/VtxTrackRef.h)
4042

4143
o2_add_test(Vertex
4244
SOURCES test/testVertex.cxx

DataFormats/Reconstruction/include/ReconstructionDataFormats/VtxTrackIndex.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "CommonDataFormat/AbstractRef.h"
1919
#include <iosfwd>
2020
#include <string>
21+
#include <array>
22+
#include <string_view>
2123

2224
namespace o2
2325
{
@@ -33,6 +35,11 @@ class VtxTrackIndex : public AbstractRef<26, 3, 3>
3335
TPC,
3436
NSources
3537
};
38+
static constexpr std::array<std::string_view, NSources> SourceNames = {
39+
"TPCITS",
40+
"ITS",
41+
"TPC"};
42+
3643
enum Flags : uint8_t {
3744
Contributor, // flag that it contributes to vertex fit
3845
Reserved, //
@@ -42,6 +49,7 @@ class VtxTrackIndex : public AbstractRef<26, 3, 3>
4249

4350
using AbstractRef<26, 3, 3>::AbstractRef;
4451

52+
static constexpr std::string_view getSourceName(int i) { return SourceNames[i]; }
4553
void print() const;
4654
std::string asString() const;
4755

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
/// @file VtxTrackRef.h
12+
/// \brief Referenc on track indices contributing to the vertex, with possibility chose tracks from specific source (global, ITS, TPC...)
13+
/// \author ruben.shahoyan@cern.ch
14+
15+
#ifndef O2_VERTEX_TRACK_REF
16+
#define O2_VERTEX_TRACK_REF
17+
18+
#include "CommonDataFormat/RangeReference.h"
19+
#include "ReconstructionDataFormats/VtxTrackIndex.h"
20+
#include <cassert>
21+
#include <array>
22+
#include <iosfwd>
23+
#include <string>
24+
25+
namespace o2
26+
{
27+
namespace dataformats
28+
{
29+
30+
class VtxTrackRef : public RangeReference<int, int>
31+
{
32+
public:
33+
VtxTrackRef(int ent, int n) : RangeReference(ent, n)
34+
{
35+
auto end = ent + n;
36+
for (int i = VtxTrackIndex::Source::NSources - 1; i--;) {
37+
mFirstEntrySource[i] = end; // only 1st source (base reference) is filled at constructor level
38+
}
39+
}
40+
using RangeReference<int, int>::RangeReference;
41+
void print() const;
42+
std::string asString() const;
43+
44+
// get 1st of entry of indices for given source
45+
int getFirstEntryOfSource(int s) const
46+
{
47+
assert(s >= 0 && s < VtxTrackIndex::NSources);
48+
return s ? mFirstEntrySource[s - 1] : getFirstEntry();
49+
}
50+
51+
// get number of entries for given source
52+
int getEntriesOfSource(int s) const
53+
{
54+
return (s == VtxTrackIndex::NSources - 1 ? (getFirstEntry() + getEntries()) : getFirstEntryOfSource(s + 1)) - getFirstEntryOfSource(s);
55+
}
56+
57+
void setFirstEntryOfSource(int s, int i)
58+
{
59+
assert(s >= 0 && s < VtxTrackIndex::NSources);
60+
if (s) {
61+
mFirstEntrySource[s - 1] = i;
62+
} else {
63+
setFirstEntry(i);
64+
}
65+
}
66+
67+
private:
68+
std::array<int, VtxTrackIndex::Source::NSources - 1> mFirstEntrySource{0};
69+
70+
ClassDefNV(VtxTrackRef, 1);
71+
};
72+
73+
std::ostream& operator<<(std::ostream& os, const o2::dataformats::VtxTrackRef& v);
74+
75+
} // namespace dataformats
76+
} // namespace o2
77+
78+
#endif

DataFormats/Reconstruction/src/ReconstructionDataFormatsLinkDef.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
#pragma link C++ class o2::dataformats::VtxTrackIndex + ;
4545
#pragma link C++ class std::vector < o2::dataformats::VtxTrackIndex> + ;
4646

47+
#pragma link C++ class o2::dataformats::VtxTrackRef + ;
48+
#pragma link C++ class std::vector < o2::dataformats::VtxTrackRef> + ;
49+
4750
#pragma link C++ class o2::dataformats::DCA + ;
4851

4952
#endif

DataFormats/Reconstruction/src/VtxTrackIndex.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ std::string VtxTrackIndex::asString() const
2626
return fmt::format("[{:d}/{:d}/{:s}]", getIndex(), getSource(), bits.to_string());
2727
}
2828

29-
std::ostream& operator<<(std::ostream& os, const o2::dataformats::VtxTrackIndex& v)
29+
std::ostream& o2::dataformats::operator<<(std::ostream& os, const o2::dataformats::VtxTrackIndex& v)
3030
{
3131
// stream itself
3232
os << v.asString();
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
/// @file VtxTrackIndex.h
12+
/// \brief Index of track attached to vertx: index in its proper container, container source and flags
13+
/// \author ruben.shahoyan@cern.ch
14+
15+
#include "ReconstructionDataFormats/VtxTrackRef.h"
16+
#include "Framework/Logger.h"
17+
#include <fmt/printf.h>
18+
#include <iostream>
19+
#include <bitset>
20+
21+
using namespace o2::dataformats;
22+
23+
std::string VtxTrackRef::asString() const
24+
{
25+
std::string str = fmt::format("1st entry: {:d} ", getFirstEntry());
26+
for (int i = 0; i < VtxTrackIndex::NSources; i++) {
27+
str += fmt::format(", N{:s} : {:d}", VtxTrackIndex::getSourceName(i), getEntriesOfSource(i));
28+
}
29+
return str;
30+
}
31+
32+
std::ostream& o2::dataformats::operator<<(std::ostream& os, const o2::dataformats::VtxTrackRef& v)
33+
{
34+
// stream itself
35+
os << v.asString();
36+
return os;
37+
}
38+
39+
void VtxTrackRef::print() const
40+
{
41+
LOG(INFO) << asString();
42+
}

Detectors/GlobalTrackingWorkflow/include/GlobalTrackingWorkflow/PrimaryVertexReaderSpec.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include "Framework/Task.h"
2121

2222
#include "CommonDataFormat/TimeStamp.h"
23-
#include "CommonDataFormat/RangeReference.h"
2423
#include "ReconstructionDataFormats/VtxTrackIndex.h"
24+
#include "ReconstructionDataFormats/VtxTrackRef.h"
2525
#include "ReconstructionDataFormats/PrimaryVertex.h"
2626
#include "SimulationDataFormat/MCEventLabel.h"
2727

@@ -34,7 +34,7 @@ namespace vertexing
3434
class PrimaryVertexReader : public o2::framework::Task
3535
{
3636
using Label = o2::MCEventLabel;
37-
using V2TRef = o2::dataformats::RangeReference<int, int>;
37+
using V2TRef = o2::dataformats::VtxTrackRef;
3838
using PVertex = o2::dataformats::PrimaryVertex;
3939
using GIndex = o2::dataformats::VtxTrackIndex;
4040

Detectors/GlobalTrackingWorkflow/src/PrimaryVertexReaderSpec.cxx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,24 @@ void PrimaryVertexReader::run(ProcessingContext& pc)
5252
if (mUseMC) {
5353
lb = mLabels[cnt];
5454
}
55-
LOG(INFO) << "#" << cnt << " " << vtx << "| NAttached= " << mPV2MatchIdxRef[cnt].getEntries() << " | MC:" << lb;
56-
int idMin = mPV2MatchIdxRef[cnt].getFirstEntry(), idMax = idMin + mPV2MatchIdxRef[cnt].getEntries();
57-
std::string trIDs;
58-
int cntT = 0;
59-
for (int i = idMin; i < idMax; i++) {
60-
trIDs += mPV2MatchIdx[i].asString() + " ";
61-
if (!((++cntT) % 15)) {
55+
LOG(INFO) << "#" << cnt << " " << vtx << " | MC:" << lb;
56+
LOG(INFO) << "References: " << mPV2MatchIdxRef[cnt];
57+
for (int is = 0; is < GIndex::NSources; is++) {
58+
LOG(INFO) << GIndex::getSourceName(is) << " : " << mPV2MatchIdxRef[cnt].getEntriesOfSource(is) << " attached:";
59+
int idMin = mPV2MatchIdxRef[cnt].getFirstEntryOfSource(is), idMax = idMin + mPV2MatchIdxRef[cnt].getEntriesOfSource(is);
60+
std::string trIDs;
61+
int cntT = 0;
62+
for (int i = idMin; i < idMax; i++) {
63+
trIDs += mPV2MatchIdx[i].asString() + " ";
64+
if (!((++cntT) % 15)) {
65+
LOG(INFO) << trIDs;
66+
trIDs = "";
67+
}
68+
}
69+
if (!trIDs.empty()) {
6270
LOG(INFO) << trIDs;
63-
trIDs = "";
6471
}
6572
}
66-
if (!trIDs.empty()) {
67-
LOG(INFO) << trIDs;
68-
}
6973
cnt++;
7074
}
7175
}

Detectors/GlobalTrackingWorkflow/src/VertexTrackMatcherSpec.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ void VertexTrackMatcherSpec::run(ProcessingContext& pc)
5959
const auto tracksITSROF = pc.inputs().get<gsl::span<o2::itsmft::ROFRecord>>("itsROF");
6060
const auto vertices = pc.inputs().get<gsl::span<o2::dataformats::PrimaryVertex>>("vertices");
6161
const auto vtxTracks = pc.inputs().get<gsl::span<o2::dataformats::VtxTrackIndex>>("vtxTracks");
62-
const auto vtxTrackRefs = pc.inputs().get<gsl::span<o2::dataformats::RangeReference<int, int>>>("vtxTrackRefs");
62+
const auto vtxTrackRefs = pc.inputs().get<gsl::span<o2::dataformats::VtxTrackRef>>("vtxTrackRefs");
6363

6464
std::vector<o2::dataformats::VtxTrackIndex> trackIndex;
65-
std::vector<o2::dataformats::RangeReference<int, int>> vtxRefs;
65+
std::vector<o2::dataformats::VtxTrackRef> vtxRefs;
6666

6767
mMatcher.process(vertices, vtxTracks, vtxTrackRefs, tracksITSTPC, tracksITS, tracksITSROF, tracksTPC, trackIndex, vtxRefs);
6868

Detectors/Vertexing/include/DetectorsVertexing/PVertexer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <utility>
2020
#include "CommonConstants/LHCConstants.h"
2121
#include "CommonDataFormat/TimeStamp.h"
22-
#include "CommonDataFormat/RangeReference.h"
2322
#include "CommonDataFormat/BunchFilling.h"
2423
#include "SimulationDataFormat/MCEventLabel.h"
2524
#include "SimulationDataFormat/MCCompLabel.h"

0 commit comments

Comments
 (0)