Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,26 @@ class TrackITS : public o2::track::TrackParCov
o2::track::TrackParCov& getParamOut() { return mParamOut; }
const o2::track::TrackParCov& getParamOut() const { return mParamOut; }

void setPattern(uint16_t p) { mPattern = p; }
void setPattern(uint32_t p) { mPattern = p; }
int getPattern() const { return mPattern; }
bool hasHitOnLayer(int i) { return mPattern & (0x1 << i); }
bool isFakeOnLayer(int i) { return !(mPattern & (0x1 << (16 + i))); }

private:
o2::track::TrackParCov mParamOut; ///< parameter at largest radius
ClusRefs mClusRef; ///< references on clusters
float mChi2 = 0.; ///< Chi2 for this track
uint16_t mPattern = 0; ///< layers pattern
uint32_t mPattern = 0; ///< layers pattern

ClassDefNV(TrackITS, 4);
ClassDefNV(TrackITS, 5);
mconcas marked this conversation as resolved.
Show resolved Hide resolved
};

class TrackITSExt : public TrackITS
{
///< heavy version of TrackITS, with clusters embedded
public:
static constexpr int MaxClusters = 16; /// Prepare for overlaps and new detector configurations
using TrackITS::TrackITS; // inherit base constructors
using TrackITS::TrackITS; // inherit base constructors

TrackITSExt(o2::track::TrackParCov&& parCov, short ncl, float chi2,
o2::track::TrackParCov&& outer, std::array<int, MaxClusters> cls)
Expand All @@ -115,6 +116,13 @@ class TrackITSExt : public TrackITS
setNumberOfClusters(ncl);
}

TrackITSExt(o2::track::TrackParCov& parCov, short ncl, float chi2, std::uint32_t rof,
o2::track::TrackParCov& outer, std::array<int, MaxClusters> cls)
: TrackITS(parCov, chi2, outer), mIndex{cls}
{
setNumberOfClusters(ncl);
}

void setClusterIndex(int l, int i)
{
int ncl = getNumberOfClusters();
Expand All @@ -128,10 +136,18 @@ class TrackITSExt : public TrackITS
{
if (newCluster) {
getClusterRefs().setEntries(getNumberOfClusters() + 1);
uint32_t pattern = getPattern();
pattern |= 0x1 << layer;
setPattern(pattern);
}
mIndex[layer] = idx;
}

std::array<int, MaxClusters>& getClusterIndexes()
{
return mIndex;
}

private:
std::array<int, MaxClusters> mIndex = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; ///< Indices of associated clusters
ClassDefNV(TrackITSExt, 2);
Expand Down
51 changes: 34 additions & 17 deletions 51 Detectors/ITSMFT/ITS/tracking/include/ITStracking/ROframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,29 @@ class ROframe final
const auto& getTrackingFrameInfo() const { return mTrackingFrameInfo; }

const TrackingFrameInfo& getClusterTrackingFrameInfo(int layerId, const Cluster& cl) const;
const MCCompLabel& getClusterLabels(int layerId, const Cluster& cl) const;
const MCCompLabel& getClusterLabels(int layerId, const int clId) const;
const MCCompLabel& getClusterFirstLabel(int layerId, const Cluster& cl) const;
const MCCompLabel& getClusterFirstLabel(int layerId, const int clId) const;
gsl::span<o2::MCCompLabel> getClusterLabels(int layerId, const int clId) const;
gsl::span<o2::MCCompLabel> getClusterLabels(int layerId, const Cluster& cl) const;
int getClusterExternalIndex(int layerId, const int clId) const;
std::vector<int> getTracksId(const int layerId, const std::vector<Cluster>& cl);

template <typename... T>
void addClusterToLayer(int layer, T&&... args);
template <typename... T>
void addTrackingFrameInfoToLayer(int layer, T&&... args);
void addClusterLabelToLayer(int layer, const MCCompLabel label);
void setMClabelsContainer(const dataformats::MCTruthContainer<MCCompLabel>* ptr);
void addClusterExternalIndexToLayer(int layer, const int idx);
bool hasMCinformation() const;

void clear();

private:
const int mROframeId;
o2::dataformats::MCTruthContainer<MCCompLabel>* mMClabels = nullptr;
std::vector<float3> mPrimaryVertices;
std::vector<std::vector<Cluster>> mClusters;
std::vector<std::vector<TrackingFrameInfo>> mTrackingFrameInfo;
std::vector<std::vector<MCCompLabel>> mClusterLabels;
std::vector<std::vector<int>> mClusterExternalIndices;
};

Expand All @@ -102,14 +104,24 @@ inline const TrackingFrameInfo& ROframe::getClusterTrackingFrameInfo(int layerId
return mTrackingFrameInfo[layerId][cl.clusterId];
}

inline const MCCompLabel& ROframe::getClusterLabels(int layerId, const Cluster& cl) const
inline const MCCompLabel& ROframe::getClusterFirstLabel(int layerId, const Cluster& cl) const
{
return mClusterLabels[layerId][cl.clusterId];
return getClusterFirstLabel(layerId, cl.clusterId);
}

inline const MCCompLabel& ROframe::getClusterLabels(int layerId, const int clId) const
inline const MCCompLabel& ROframe::getClusterFirstLabel(int layerId, const int clId) const
{
return mClusterLabels[layerId][clId];
return *(mMClabels->getLabels(getClusterExternalIndex(layerId, clId)).begin());
}

inline gsl::span<o2::MCCompLabel> ROframe::getClusterLabels(int layerId, const int clId) const
{
return mMClabels->getLabels(getClusterExternalIndex(layerId, clId));
}

inline gsl::span<o2::MCCompLabel> ROframe::getClusterLabels(int layerId, const Cluster& cl) const
{
return getClusterLabels(layerId, cl.clusterId);
}

inline int ROframe::getClusterExternalIndex(int layerId, const int clId) const
Expand All @@ -121,7 +133,7 @@ inline std::vector<int> ROframe::getTracksId(const int layerId, const std::vecto
{
std::vector<int> tracksId;
for (auto& cluster : cl) {
tracksId.push_back(getClusterLabels(layerId, cluster).isNoise() ? -1 : getClusterLabels(layerId, cluster).getTrackID());
tracksId.push_back(getClusterFirstLabel(layerId, cluster).isNoise() ? -1 : getClusterFirstLabel(layerId, cluster).getTrackID());
}
return tracksId;
}
Expand All @@ -138,7 +150,10 @@ void ROframe::addTrackingFrameInfoToLayer(int layer, T&&... values)
mTrackingFrameInfo[layer].emplace_back(std::forward<T>(values)...);
}

inline void ROframe::addClusterLabelToLayer(int layer, const MCCompLabel label) { mClusterLabels[layer].emplace_back(label); }
inline void ROframe::setMClabelsContainer(const dataformats::MCTruthContainer<MCCompLabel>* ptr)
{
mMClabels = const_cast<dataformats::MCTruthContainer<MCCompLabel>*>(ptr);
}

inline void ROframe::addClusterExternalIndexToLayer(int layer, const int idx)
{
Expand All @@ -150,20 +165,22 @@ inline void ROframe::clear()
for (unsigned int iL = 0; iL < mClusters.size(); ++iL) {
mClusters[iL].clear();
mTrackingFrameInfo[iL].clear();
mClusterLabels[iL].clear();
// mClusterLabels[iL].clear();
mClusterExternalIndices[iL].clear();
}
mPrimaryVertices.clear();
mMClabels = nullptr;
}

inline bool ROframe::hasMCinformation() const
{
for (const auto& vect : mClusterLabels) {
if (!vect.empty()) {
return true;
}
}
return false;
// for (const auto& vect : mClusterLabels) {
// if (!vect.empty()) {
// return true;
// }
// }
// return false;
return mMClabels;
}

} // namespace its
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct FakeTrackInfo {
if (extIndex == -1) {
continue;
}
o2::MCCompLabel mcLabel = event.getClusterLabels(iCluster, extIndex);
o2::MCCompLabel mcLabel = *(event.getClusterLabels(iCluster, extIndex).begin());
bool found = false;

for (size_t iOcc{0}; iOcc < occurrences.size(); ++iOcc) {
Expand Down Expand Up @@ -95,7 +95,7 @@ struct FakeTrackInfo {
if (extIndex == -1) {
continue;
}
o2::MCCompLabel lbl = event.getClusterLabels(iCluster, extIndex);
o2::MCCompLabel lbl = *(event.getClusterLabels(iCluster, extIndex).begin());
if (lbl == mainLabel && occurrences[0].second > 1 && !lbl.isNoise()) { // if we have MaxClusters fake clusters -> occurrences[0].second = 1
clusStatuses[iCluster] = 1;
} else {
Expand Down
104 changes: 52 additions & 52 deletions 104 Detectors/ITSMFT/ITS/tracking/src/IOUtils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -77,55 +77,55 @@ void ioutils::convertCompactClusters(gsl::span<const itsmft::CompClusterExt> clu
}
}

std::vector<ROframe> ioutils::loadEventData(const std::string& fileName)
{
std::vector<ROframe> events{};
std::ifstream inputStream{};
std::string line{}, unusedVariable{};
int layerId{}, monteCarlo{};
int clusterId{EventLabelsSeparator};
float xCoordinate{}, yCoordinate{}, zCoordinate{}, alphaAngle{};
float varZ{-1.f}, varY{-1.f};

inputStream.open(fileName);

/// THIS IS LEAKING IN THE BACKWARD COMPATIBLE MODE. KEEP IT IN MIND.
dataformats::MCTruthContainer<MCCompLabel>* mcLabels = nullptr;
while (std::getline(inputStream, line)) {

std::istringstream inputStringStream(line);
if (inputStringStream >> layerId >> xCoordinate >> yCoordinate >> zCoordinate) {

if (layerId == PrimaryVertexLayerId) {

if (clusterId != 0) {
events.emplace_back(events.size(), 7);
}

events.back().addPrimaryVertex(xCoordinate, yCoordinate, zCoordinate);
clusterId = 0;

} else {

if (inputStringStream >> varY >> varZ >> unusedVariable >> alphaAngle >> monteCarlo) {
events.back().addClusterToLayer(layerId, xCoordinate, yCoordinate, zCoordinate,
events.back().getClustersOnLayer(layerId).size());
const float sinAlpha = std::sin(alphaAngle);
const float cosAlpha = std::cos(alphaAngle);
const float xTF = xCoordinate * cosAlpha - yCoordinate * sinAlpha;
const float yTF = xCoordinate * sinAlpha + yCoordinate * cosAlpha;
events.back().addTrackingFrameInfoToLayer(layerId, xCoordinate, yCoordinate, zCoordinate, xTF, alphaAngle,
std::array<float, 2>{yTF, zCoordinate}, std::array<float, 3>{varY, 0.f, varZ});
events.back().addClusterLabelToLayer(layerId, MCCompLabel(monteCarlo));

++clusterId;
}
}
}
}
// std::vector<ROframe> ioutils::loadEventData(const std::string& fileName)
// {
// std::vector<ROframe> events{};
// std::ifstream inputStream{};
// std::string line{}, unusedVariable{};
// int layerId{}, monteCarlo{};
// int clusterId{EventLabelsSeparator};
// float xCoordinate{}, yCoordinate{}, zCoordinate{}, alphaAngle{};
// float varZ{-1.f}, varY{-1.f};

// inputStream.open(fileName);

// /// THIS IS LEAKING IN THE BACKWARD COMPATIBLE MODE. KEEP IT IN MIND.
// dataformats::MCTruthContainer<MCCompLabel>* mcLabels = nullptr;
// while (std::getline(inputStream, line)) {

// std::istringstream inputStringStream(line);
// if (inputStringStream >> layerId >> xCoordinate >> yCoordinate >> zCoordinate) {

// if (layerId == PrimaryVertexLayerId) {

// if (clusterId != 0) {
// events.emplace_back(events.size(), 7);
// }

// events.back().addPrimaryVertex(xCoordinate, yCoordinate, zCoordinate);
// clusterId = 0;

// } else {

// if (inputStringStream >> varY >> varZ >> unusedVariable >> alphaAngle >> monteCarlo) {
// events.back().addClusterToLayer(layerId, xCoordinate, yCoordinate, zCoordinate,
// events.back().getClustersOnLayer(layerId).size());
// const float sinAlpha = std::sin(alphaAngle);
// const float cosAlpha = std::cos(alphaAngle);
// const float xTF = xCoordinate * cosAlpha - yCoordinate * sinAlpha;
// const float yTF = xCoordinate * sinAlpha + yCoordinate * cosAlpha;
// events.back().addTrackingFrameInfoToLayer(layerId, xCoordinate, yCoordinate, zCoordinate, xTF, alphaAngle,
// std::array<float, 2>{yTF, zCoordinate}, std::array<float, 3>{varY, 0.f, varZ});
// events.back().addClusterLabelToLayer(layerId, MCCompLabel(monteCarlo));

// ++clusterId;
// }
// }
// }
// }

return events;
}
// return events;
// }

void ioutils::loadEventData(ROframe& event, gsl::span<const itsmft::CompClusterExt> clusters,
gsl::span<const unsigned char>::iterator& pattIt, const itsmft::TopologyDictionary& dict,
Expand Down Expand Up @@ -172,7 +172,8 @@ void ioutils::loadEventData(ROframe& event, gsl::span<const itsmft::CompClusterE
/// Rotate to the global frame
event.addClusterToLayer(layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), event.getClustersOnLayer(layer).size());
if (clsLabels) {
event.addClusterLabelToLayer(layer, *(clsLabels->getLabels(clusterId).begin()));
// event.addClusterLabelToLayer(layer, *(clsLabels->getLabels(clusterId).begin()));
event.setMClabelsContainer(clsLabels);
}
event.addClusterExternalIndexToLayer(layer, clusterId);
clusterId++;
Expand Down Expand Up @@ -221,7 +222,8 @@ int ioutils::loadROFrameData(const o2::itsmft::ROFRecord& rof, ROframe& event, g
/// Rotate to the global frame
event.addClusterToLayer(layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), event.getClustersOnLayer(layer).size());
if (mcLabels) {
event.addClusterLabelToLayer(layer, *(mcLabels->getLabels(first + clusterId).begin()));
// event.addClusterLabelToLayer(layer, *(mcLabels->getLabels(first + clusterId).begin()));
event.setMClabelsContainer(mcLabels);
}
event.addClusterExternalIndexToLayer(layer, first + clusterId);
clusterId++;
Expand Down Expand Up @@ -349,7 +351,5 @@ void ioutils::writeRoadsReport(std::ofstream& correctRoadsOutputStream, std::ofs
}
}



} // namespace its
} // namespace o2
2 changes: 1 addition & 1 deletion 2 Detectors/ITSMFT/ITS/tracking/src/ROframe.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ROframe::ROframe(int ROframeId, int nLayers) : mROframeId{ROframeId}
{
mClusters.resize(nLayers);
mTrackingFrameInfo.resize(nLayers);
mClusterLabels.resize(nLayers);
// mClusterLabels.resize(nLayers);
mClusterExternalIndices.resize(nLayers);
}

Expand Down
18 changes: 9 additions & 9 deletions 18 Detectors/ITSMFT/ITS/tracking/src/StandaloneDebugger.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ StandaloneDebugger::~StandaloneDebugger()
// Monte carlo oracle part
int StandaloneDebugger::getEventId(int firstClusterId, int secondClusterId, ROframe* event)
{
o2::MCCompLabel lblClus0 = event->getClusterLabels(0, firstClusterId);
o2::MCCompLabel lblClus1 = event->getClusterLabels(1, secondClusterId);
o2::MCCompLabel lblClus0 = *(event->getClusterLabels(0, firstClusterId).begin());
o2::MCCompLabel lblClus1 = *(event->getClusterLabels(1, secondClusterId).begin());
return lblClus0.compare(lblClus1) == 1 ? lblClus0.getEventID() : -1;
}

Expand All @@ -54,8 +54,8 @@ void StandaloneDebugger::fillCombinatoricsTree(std::array<std::vector<Cluster>,
assert(mTreeStream != nullptr);

for (auto& combination : comb01) {
o2::MCCompLabel lblClus0 = event->getClusterLabels(0, clusters[0][combination.firstClusterIndex].clusterId);
o2::MCCompLabel lblClus1 = event->getClusterLabels(1, clusters[1][combination.secondClusterIndex].clusterId);
o2::MCCompLabel lblClus0 = *(event->getClusterLabels(0, clusters[0][combination.firstClusterIndex].clusterId).begin());
o2::MCCompLabel lblClus1 = *(event->getClusterLabels(1, clusters[1][combination.secondClusterIndex].clusterId).begin());
float c0z{clusters[0][combination.firstClusterIndex].zCoordinate};
float c1z{clusters[1][combination.secondClusterIndex].zCoordinate};
unsigned char isValidated{lblClus0.compare(lblClus1) == 1};
Expand All @@ -72,8 +72,8 @@ void StandaloneDebugger::fillCombinatoricsTree(std::array<std::vector<Cluster>,
}

for (auto& combination : comb12) {
o2::MCCompLabel lblClus1 = event->getClusterLabels(1, clusters[1][combination.secondClusterIndex].clusterId);
o2::MCCompLabel lblClus2 = event->getClusterLabels(2, clusters[2][combination.secondClusterIndex].clusterId);
o2::MCCompLabel lblClus1 = *(event->getClusterLabels(1, clusters[1][combination.secondClusterIndex].clusterId).begin());
o2::MCCompLabel lblClus2 = *(event->getClusterLabels(2, clusters[2][combination.secondClusterIndex].clusterId).begin());
float c1z{clusters[1][combination.firstClusterIndex].zCoordinate};
float c2z{clusters[2][combination.secondClusterIndex].zCoordinate};
unsigned char isValidated{lblClus1.compare(lblClus2) == 1};
Expand All @@ -100,9 +100,9 @@ void StandaloneDebugger::fillTrackletSelectionTree(std::array<std::vector<Cluste
assert(mTreeStream != nullptr);
int id = event->getROFrameId();
for (auto& trackletPair : allowedTracklets) {
o2::MCCompLabel lblClus0 = event->getClusterLabels(0, clusters[0][comb01[trackletPair[0]].firstClusterIndex].clusterId);
o2::MCCompLabel lblClus1 = event->getClusterLabels(1, clusters[1][comb01[trackletPair[0]].secondClusterIndex].clusterId);
o2::MCCompLabel lblClus2 = event->getClusterLabels(2, clusters[2][comb12[trackletPair[1]].secondClusterIndex].clusterId);
o2::MCCompLabel lblClus0 = *(event->getClusterLabels(0, clusters[0][comb01[trackletPair[0]].firstClusterIndex].clusterId).begin());
o2::MCCompLabel lblClus1 = *(event->getClusterLabels(1, clusters[1][comb01[trackletPair[0]].secondClusterIndex].clusterId).begin());
o2::MCCompLabel lblClus2 = *(event->getClusterLabels(2, clusters[2][comb12[trackletPair[1]].secondClusterIndex].clusterId).begin());
unsigned char isValidated{lblClus0.compare(lblClus1) == 1 && lblClus0.compare(lblClus2) == 1};
float deltaPhi{comb01[trackletPair[0]].phiCoordinate - comb12[trackletPair[1]].phiCoordinate};
float deltaTanLambda{comb01[trackletPair[0]].tanLambda - comb12[trackletPair[1]].tanLambda};
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.