Skip to content

Commit c9bb022

Browse files
shahor02Benedikt Volkel
authored andcommitted
Do not const_cast/modify sh.mem. objetcs from upstream procsesses
1 parent 6122bfe commit c9bb022

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

DataFormats/simulation/include/SimulationDataFormat/MCCompLabel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class MCCompLabel
129129
int getEventID() const { return (mLabel >> nbitsTrackID) & maskEvID; }
130130
int getSourceID() const { return (mLabel >> (nbitsTrackID + nbitsEvID)) & maskSrcID; }
131131
uint64_t getTrackEventSourceID() const { return static_cast<uint64_t>(mLabel & maskFull); }
132-
void get(int& trackID, int& evID, int& srcID, bool& fake)
132+
void get(int& trackID, int& evID, int& srcID, bool& fake) const
133133
{
134134
/// parse label
135135
trackID = getTrackID();

Detectors/GlobalTracking/include/GlobalTracking/TrackCuts.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,11 @@ class TrackCuts
104104
const auto& tpcTrk = data.getTPCTrack(contributorsGID[GID::TPC]);
105105
math_utils::Point3D<float> v{}; // vertex not defined?!
106106
std::array<float, 2> dca;
107-
if (tpcTrk.getPt() < mPtTPCCut ||
108-
std::abs(tpcTrk.getEta()) > mEtaTPCCut || // TODO: define 2 different values for min and max (***)
109-
tpcTrk.getNClusters() < mNTPCClustersCut ||
110-
(!(const_cast<o2::tpc::TrackTPC&>(tpcTrk).propagateParamToDCA(v, mBz, &dca, mDCATPCCut)) ||
111-
std::abs(dca[0]) > mDCATPCCutY) ||
112-
std::hypot(dca[0], dca[1]) > mDCATPCCut) {
107+
if (tpcTrk.getPt() < mPtTPCCut || std::abs(tpcTrk.getEta()) > mEtaTPCCut || tpcTrk.getNClusters() < mNTPCClustersCut) { // TODO: define 2 different values for min and max (***)
108+
return false;
109+
}
110+
o2::track::TrackPar trTmp(tpcTrk);
111+
if (!trTmp.propagateParamToDCA(v, mBz, &dca, mDCATPCCut) || std::abs(dca[0]) > mDCATPCCutY || std::hypot(dca[0], dca[1]) > mDCATPCCut) {
113112
return false;
114113
}
115114
}

Detectors/ITSMFT/ITS/postprocessing/studies/src/ImpactParameter.cxx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,13 @@ void ImpactParameterStudy::process(o2::globaltracking::RecoContainer& recoData)
360360
auto pt = trc.getPt();
361361
o2::gpu::gpustd::array<float, 2> dcaInfo{-999., -999.};
362362
// LOGP(info, " ---> Bz={}", o2::base::Propagator::Instance()->getNominalBz());
363-
if (o2::base::Propagator::Instance()->propagateToDCABxByBz({Pvtx_refitted.getX(), Pvtx_refitted.getY(), Pvtx_refitted.getZ()}, const_cast<o2::track::TrackParCov&>(trc), 2.f, matCorr, &dcaInfo)) {
363+
o2::track::TrackPar trcTmp{trc};
364+
if (o2::base::Propagator::Instance()->propagateToDCABxByBz({Pvtx_refitted.getX(), Pvtx_refitted.getY(), Pvtx_refitted.getZ()}, trcTmp, 2.f, matCorr, &dcaInfo)) {
364365
impParRPhi = dcaInfo[0] * toMicrometers;
365366
impParZ = dcaInfo[1] * toMicrometers;
366367
mHistoImpParXy->Fill(pt, impParRPhi);
367368
mHistoImpParZ->Fill(pt, impParZ);
368-
double phi = trc.getPhi();
369+
double phi = trcTmp.getPhi();
369370
mHistoImpParXyPhi->Fill(phi, impParRPhi);
370371
mHistoImpParZPhi->Fill(phi, impParZ);
371372
if (phi < TMath::Pi()) {
@@ -376,7 +377,7 @@ void ImpactParameterStudy::process(o2::globaltracking::RecoContainer& recoData)
376377
mHistoImpParXyBottom->Fill(pt, impParRPhi);
377378
mHistoImpParZBottom->Fill(pt, impParZ);
378379
}
379-
double sign = trc.getSign();
380+
double sign = trcTmp.getSign();
380381
if (sign < 0) {
381382
mHistoImpParXyNegativeCharge->Fill(pt, impParRPhi);
382383
mHistoImpParZNegativeCharge->Fill(pt, impParZ);
@@ -557,4 +558,4 @@ DataProcessorSpec getImpactParameterStudy(mask_t srcTracksMask, mask_t srcCluste
557558

558559
} // namespace study
559560
} // namespace its
560-
} // namespace o2
561+
} // namespace o2

Detectors/ITSMFT/ITS/postprocessing/studies/src/TrackCheck.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ void TrackCheckStudy::process()
477477
}
478478
int trackID, evID, srcID;
479479
bool fake;
480-
const_cast<o2::MCCompLabel&>(lab).get(trackID, evID, srcID, fake);
480+
lab.get(trackID, evID, srcID, fake);
481481
auto& cluster = mClusters[iCluster];
482482
auto layer = mGeometry->getLayer(cluster.getSensorID());
483483
mParticleInfo[srcID][evID][trackID].clusters |= (1 << layer);
@@ -510,7 +510,7 @@ void TrackCheckStudy::process()
510510
}
511511
int trackID, evID, srcID;
512512
bool fake;
513-
const_cast<o2::MCCompLabel&>(lab).get(trackID, evID, srcID, fake);
513+
lab.get(trackID, evID, srcID, fake);
514514

515515
if (srcID == 99) { // skip QED
516516
unaccounted++;
@@ -723,7 +723,7 @@ void TrackCheckStudy::process()
723723
}
724724

725725
bool fakec;
726-
const_cast<o2::MCCompLabel&>(lab).get(TrackID, EvID, SrcID, fakec);
726+
lab.get(TrackID, EvID, SrcID, fakec);
727727
double intHisto = 0;
728728
for (int hg = 0; hg < 7; hg++) {
729729
if (mParticleInfo[SrcID][EvID][TrackID].pdg == PdgcodeClusterFake[hg] || mParticleInfo[SrcID][EvID][TrackID].pdg == -1 * (PdgcodeClusterFake[hg])) {
@@ -819,7 +819,7 @@ void TrackCheckStudy::process()
819819
}
820820
int trackID, evID, srcID;
821821
bool fake;
822-
const_cast<o2::MCCompLabel&>(lab).get(trackID, evID, srcID, fake);
822+
lab.get(trackID, evID, srcID, fake);
823823
if (srcID == 99) {
824824
continue; // skip QED
825825
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ class ROframe final
5858
const TrackingFrameInfo& getClusterTrackingFrameInfo(int layerId, const Cluster& cl) const;
5959
const MCCompLabel& getClusterFirstLabel(int layerId, const Cluster& cl) const;
6060
const MCCompLabel& getClusterFirstLabel(int layerId, const int clId) const;
61-
gsl::span<o2::MCCompLabel> getClusterLabels(int layerId, const int clId) const;
62-
gsl::span<o2::MCCompLabel> getClusterLabels(int layerId, const Cluster& cl) const;
61+
const gsl::span<const o2::MCCompLabel> getClusterLabels(int layerId, const int clId) const;
62+
const gsl::span<const o2::MCCompLabel> getClusterLabels(int layerId, const Cluster& cl) const;
6363
int getClusterExternalIndex(int layerId, const int clId) const;
6464
std::vector<int> getTracksId(const int layerId, const std::vector<Cluster>& cl);
6565

@@ -75,7 +75,7 @@ class ROframe final
7575

7676
private:
7777
const int mROframeId;
78-
o2::dataformats::MCTruthContainer<MCCompLabel>* mMClabels = nullptr;
78+
const o2::dataformats::MCTruthContainer<MCCompLabel>* mMClabels = nullptr;
7979
std::vector<float3> mPrimaryVertices;
8080
std::vector<std::vector<Cluster>> mClusters;
8181
std::vector<std::vector<TrackingFrameInfo>> mTrackingFrameInfo;
@@ -115,12 +115,12 @@ inline const MCCompLabel& ROframe::getClusterFirstLabel(int layerId, const int c
115115
return *(mMClabels->getLabels(getClusterExternalIndex(layerId, clId)).begin());
116116
}
117117

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

123-
inline gsl::span<o2::MCCompLabel> ROframe::getClusterLabels(int layerId, const Cluster& cl) const
123+
inline const gsl::span<const o2::MCCompLabel> ROframe::getClusterLabels(int layerId, const Cluster& cl) const
124124
{
125125
return getClusterLabels(layerId, cl.clusterId);
126126
}
@@ -153,7 +153,7 @@ void ROframe::addTrackingFrameInfoToLayer(int layer, T&&... values)
153153

154154
inline void ROframe::setMClabelsContainer(const dataformats::MCTruthContainer<MCCompLabel>* ptr)
155155
{
156-
mMClabels = const_cast<dataformats::MCTruthContainer<MCCompLabel>*>(ptr);
156+
mMClabels = ptr;
157157
}
158158

159159
inline void ROframe::addClusterExternalIndexToLayer(int layer, const int idx)

0 commit comments

Comments
 (0)