Skip to content

Commit 3cd6298

Browse files
mconcassawenzel
authored andcommitted
Make Traits RTypes indipendent
1 parent 5b65760 commit 3cd6298

7 files changed

Lines changed: 71 additions & 46 deletions

File tree

Detectors/ITSMFT/ITS/tracking/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ set(NO_DICT_HEADERS
3333
include/${MODULE_NAME}/Config.h
3434
include/${MODULE_NAME}/Definitions.h
3535
include/${MODULE_NAME}/TrackerTraits.h
36-
# include/${MODULE_NAME}/VertexerTraits.h
3736
include/${MODULE_NAME}/Tracklet.h
3837
)
3938

Detectors/ITSMFT/ITS/tracking/include/ITStracking/Vertexer.h

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
/// \brief
1313
///
1414

15-
#ifndef VERTEXER_H_
16-
#define VERTEXER_H_
15+
#ifndef O2_ITS_TRACKING_VERTEXER_H_
16+
#define O2_ITS_TRACKING_VERTEXER_H_
1717

1818
#include <chrono>
1919
#include <fstream>
@@ -42,28 +42,29 @@ class Vertexer
4242

4343
Vertexer(const Vertexer&) = delete;
4444
Vertexer& operator=(const Vertexer&) = delete;
45-
//virtual ~Vertexer();
4645

4746
void setROframe(const uint32_t ROframe) { mROframe = ROframe; }
4847
void setParameters(const VertexingParameters& verPar) { mVertParams = verPar; }
4948

5049
uint32_t getROFrame() const { return mROframe; }
51-
std::vector<Vertex> getVertices();
50+
std::vector<Vertex> exportVertices();
5251
VertexingParameters getVertParameters() const { return mVertParams; }
5352
VertexerTraits* getTraits() const { return mTraits; };
5453

55-
void clustersToVertices(const ROframe&, std::ostream& = std::cout);
54+
void clustersToVertices(ROframe&, std::ostream& = std::cout);
5655
template <typename... T>
5756
void initialiseVertexer(T&&... args);
5857
void findTracklets(const bool useMCLabel = false);
5958
void findVertices();
59+
// void writeEvent(ROframe*);
6060

6161
// Utils
6262
void dumpTraits();
6363
template <typename... T>
6464
float evaluateTask(void (Vertexer::*)(T...), const char*, std::ostream& ostream, T&&... args);
6565

6666
private:
67+
// ROframe* mFrame;
6768
std::uint32_t mROframe = 0;
6869
VertexerTraits* mTraits = nullptr;
6970
VertexingParameters mVertParams;
@@ -80,9 +81,13 @@ void Vertexer::dumpTraits()
8081
mTraits->dumpVertexerTraits();
8182
}
8283

83-
std::vector<Vertex> Vertexer::getVertices()
84+
std::vector<Vertex> Vertexer::exportVertices()
8485
{
85-
std::vector<Vertex> vertices = mTraits->exportVertices();
86+
std::vector<Vertex> vertices;
87+
for (auto& vertex : mTraits->getVertices()) {
88+
vertices.emplace_back(Point3D<float>(vertex.mX, vertex.mY, vertex.mZ), vertex.mRMS2, vertex.mContributors, vertex.mAvgDistance2);
89+
vertices.back().setTimeStamp(vertex.mTimeStamp);
90+
}
8691
return vertices;
8792
}
8893

@@ -114,4 +119,4 @@ float Vertexer::evaluateTask(void (Vertexer::*task)(T...), const char* taskName,
114119

115120
} // namespace ITS
116121
} // namespace o2
117-
#endif
122+
#endif

Detectors/ITSMFT/ITS/tracking/include/ITStracking/VertexerTraits.h

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,43 @@
1212
/// \brief
1313
///
1414

15-
#ifndef VERTEXERTRAITS_H_
16-
#define VERTEXERTRAITS_H_
15+
#ifndef O2_ITS_TRACKING_VERTEXER_TRAITS_H_
16+
#define O2_ITS_TRACKING_VERTEXER_TRAITS_H_
1717

1818
#include "ITStracking/Configuration.h"
1919
#include <array>
2020
#include <vector>
2121

2222
#include "ITStracking/Cluster.h"
23-
#include "ITStracking/ROframe.h"
2423
#include "ClusterLines.h"
25-
#include "ReconstructionDataFormats/Vertex.h"
2624

2725
namespace o2
2826
{
27+
2928
namespace ITS
3029
{
3130

32-
using Vertex = o2::dataformats::Vertex<o2::dataformats::TimeStamp<int>>;
31+
class ROframe;
32+
3333
using Constants::IndexTable::PhiBins;
3434
using Constants::IndexTable::ZBins;
3535
using Constants::ITS::LayersNumberVertexer;
3636

37+
struct lightVertex {
38+
lightVertex(float x, float y, float z, std::array<float, 6> rms2, float avgdis2, int cont, int stamp);
39+
float mX;
40+
float mY;
41+
float mZ;
42+
std::array<float, 6> mRMS2;
43+
float mAvgDistance2;
44+
int mContributors;
45+
int mTimeStamp;
46+
};
47+
48+
inline lightVertex::lightVertex(float x, float y, float z, std::array<float, 6> rms2, float avgdis2, int cont, int stamp) : mX(x), mY(y), mZ(z), mRMS2(rms2), mAvgDistance2(avgdis2), mContributors(cont), mTimeStamp(stamp)
49+
{
50+
}
51+
3752
class VertexerTraits
3853
{
3954
public:
@@ -42,22 +57,20 @@ class VertexerTraits
4257

4358
// virtual vertexer interface
4459
virtual void reset();
45-
virtual void initialise(const ROframe&);
60+
virtual void initialise(ROframe*);
4661
virtual void computeTracklets(const bool useMCLabel = false);
4762
virtual void computeVertices();
4863

4964
void updateVertexingParameters(const VertexingParameters& vrtPar);
50-
std::vector<Vertex> exportVertices() { return mVertices; }
51-
5265
static const std::vector<std::pair<int, int>> selectClusters(const std::array<int, ZBins * PhiBins + 1>& indexTable,
5366
const std::array<int, 4>& selectedBinsRect);
54-
std::vector<Vertex> getVertices() const { return mVertices; }
67+
std::vector<lightVertex> getVertices() const { return mVertices; }
5568
void dumpVertexerTraits();
5669

5770
protected:
5871
VertexingParameters mVrtParams;
5972
std::array<std::array<int, ZBins * PhiBins + 1>, LayersNumberVertexer> mIndexTables;
60-
std::vector<Vertex> mVertices;
73+
std::vector<lightVertex> mVertices;
6174

6275
// Frame related quantities
6376
o2::ITS::ROframe* mEvent;
@@ -77,4 +90,4 @@ inline void VertexerTraits::updateVertexingParameters(const VertexingParameters&
7790

7891
} // namespace ITS
7992
} // namespace o2
80-
#endif /* VERTEXERTRAITS_H_ */
93+
#endif /* O2_ITS_TRACKING_VERTEXER_TRAITS_H_ */

Detectors/ITSMFT/ITS/tracking/src/Vertexer.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ Vertexer::Vertexer(VertexerTraits* traits)
2828
mTraits = traits;
2929
}
3030

31-
void Vertexer::clustersToVertices(const ROframe& event, std::ostream& timeBenchmarkOutputStream)
31+
void Vertexer::clustersToVertices(ROframe& event, std::ostream& timeBenchmarkOutputStream)
3232
{
33+
ROframe* eventptr = &event;
3334
float total{ 0.f };
34-
total += evaluateTask(&Vertexer::initialiseVertexer, "Vertexer initialisation", timeBenchmarkOutputStream, event);
35+
total += evaluateTask(&Vertexer::initialiseVertexer, "Vertexer initialisation", timeBenchmarkOutputStream, eventptr);
3536
total += evaluateTask(&Vertexer::findTracklets, "Tracklet finding", timeBenchmarkOutputStream, false);
3637
total += evaluateTask(&Vertexer::findVertices, "Vertex finding", timeBenchmarkOutputStream);
3738
}

Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "ITStracking/VertexerTraits.h"
1616
#include "ITStracking/ROframe.h"
1717
#include "ITStracking/ClusterLines.h"
18+
// #include "ReconstructionDataFormats/Vertex.h"
1819

1920
#include <iostream>
2021

@@ -45,12 +46,12 @@ void VertexerTraits::reset()
4546
mMaxDirectorCosine3 = 0.f;
4647
}
4748

48-
void VertexerTraits::initialise(const ROframe& event)
49+
void VertexerTraits::initialise(ROframe* event)
4950
{
5051
reset();
51-
mEvent = const_cast<o2::ITS::ROframe*>(&event);
52+
mEvent = event;
5253
for (int iLayer{ 0 }; iLayer < Constants::ITS::LayersNumberVertexer; ++iLayer) {
53-
const auto& currentLayer{ event.getClustersOnLayer(iLayer) };
54+
const auto& currentLayer{ event->getClustersOnLayer(iLayer) };
5455
const size_t clustersNum{ currentLayer.size() };
5556
if (clustersNum > 0) {
5657
mClusters[iLayer].clear();
@@ -289,16 +290,15 @@ void VertexerTraits::computeVertices()
289290
if (mTrackletClusters[iCluster].getVertex()[0] * mTrackletClusters[iCluster].getVertex()[0] +
290291
mTrackletClusters[iCluster].getVertex()[1] * mTrackletClusters[iCluster].getVertex()[1] <
291292
1.98 * 1.98) {
292-
mVertices.emplace_back(
293-
Point3D<float>{ mTrackletClusters[iCluster].getVertex()[0], mTrackletClusters[iCluster].getVertex()[1],
294-
mTrackletClusters[iCluster].getVertex()[2] },
295-
mTrackletClusters[iCluster].getRMS2(), // Symm matrix. Diagonal: RMS2 components,
296-
// off-diagonal: square mean of projections on planes.
297-
mTrackletClusters[iCluster].getSize(), // Contributors
298-
mTrackletClusters[iCluster].getAvgDistance2() // In place of chi2
299-
);
300-
mVertices.back().setTimeStamp(mEvent->getROFrameId());
301-
mEvent->addPrimaryVertex(mVertices.back().getX(), mVertices.back().getY(), mVertices.back().getZ());
293+
mVertices.emplace_back(mTrackletClusters[iCluster].getVertex()[0],
294+
mTrackletClusters[iCluster].getVertex()[1],
295+
mTrackletClusters[iCluster].getVertex()[2],
296+
mTrackletClusters[iCluster].getRMS2(), // Symm matrix. Diagonal: RMS2 components,
297+
// off-diagonal: square mean of projections on planes.
298+
mTrackletClusters[iCluster].getSize(), // Contributors
299+
mTrackletClusters[iCluster].getAvgDistance2(), // In place of chi2
300+
mEvent->getROFrameId());
301+
mEvent->addPrimaryVertex(mVertices.back().mX, mVertices.back().mY, mVertices.back().mZ);
302302
}
303303
}
304304
}

macro/run_test_vert_ca_its.C

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@
3939
#include "SimulationDataFormat/MCCompLabel.h"
4040
#include "SimulationDataFormat/MCTruthContainer.h"
4141

42+
#include "AliGPUReconstruction.h"
43+
4244
R__LOAD_LIBRARY(libITStracking)
45+
// R__LOAD_LIBRARY(libTPCReconstruction)
46+
// gSystem->Load("libTPCReconstruction")
4347

4448
using Vertex = o2::dataformats::Vertex<o2::dataformats::TimeStamp<int>>;
4549

@@ -119,11 +123,15 @@ int run_test_vert_ca_its(const int inspEvt = -1,
119123

120124
const int stopAt = (inspEvt == -1) ? itsClusters.GetEntries() : inspEvt + 1;
121125
o2::ITS::ROframe frame(-123);
122-
o2::ITS::VertexerTraits* traits = new o2::ITS::VertexerTraits();
123-
o2::ITS::Vertexer vertexer(traits);
126+
127+
// o2::ITS::Vertexer vertexer(AliGPUReconstruction::CreateInstance()->GetITSVerterTraits());
128+
AliGPUReconstruction* instance = AliGPUReconstruction::CreateInstance();
129+
o2::ITS::VertexerTraits* traits = instance->GetITSVertexerTraits();
130+
std::cout << "macro -> traits ptr -> " << traits << std::endl;
131+
// traits->dumpVertexerTraits();
124132

125133
std::uint32_t ROframe{ 0 };
126-
vertexer.setROframe(ROframe);
134+
// vertexer.setROframe(ROframe);
127135
for (int iEvent = (inspEvt == -1) ? 0 : inspEvt; iEvent < stopAt; ++iEvent) {
128136
itsClusters.GetEntry(iEvent);
129137
mcHeaderTree.GetEntry(iEvent);
@@ -136,13 +144,16 @@ int run_test_vert_ca_its(const int inspEvt = -1,
136144
} else {
137145
o2::ITS::IOUtils::loadEventData(frame, clusters, labels);
138146
}
139-
vertexer.clustersToVertices(frame);
140-
std::vector<Vertex> vertITS = vertexer.getVertices();
141-
verticesITS->swap(vertITS);
147+
// vertexer.clustersToVertices(frame);
148+
// ROframe* frameptr = &frame;
149+
// vertexer.initialiseVertexer(&frame);
150+
// vertexer.dumpTraits();
151+
// std::vector<Vertex> vertITS = vertexer.exportVertices();
152+
// verticesITS->swap(vertITS);
142153
outTree.Fill();
143154
} // loop on events
144155
outTree.Write();
145156
outputfile->Close();
146157
return 0;
147158
}
148-
#endif
159+
#endif

macro/run_vert_ca_its.C

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@
3838
#include "SimulationDataFormat/MCCompLabel.h"
3939
#include "SimulationDataFormat/MCTruthContainer.h"
4040

41-
using o2::ITS::Cluster;
42-
using o2::ITS::Line;
43-
using o2::ITS::MathUtils::calculatePhiCoordinate;
44-
using o2::ITS::MathUtils::calculateRCoordinate;
4541
using Vertex = o2::dataformats::Vertex<o2::dataformats::TimeStamp<int>>;
4642

4743
void run_vert_ca_its(const int inspEvt = -1, bool useMC = false,

0 commit comments

Comments
 (0)