Skip to content

Commit 4600e37

Browse files
committed
get rid of magic constants
1 parent 6a93189 commit 4600e37

File tree

3 files changed

+68
-57
lines changed

3 files changed

+68
-57
lines changed

DPG/Tasks/TPC/tpcSkimsTableCreator.cxx

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,15 @@ struct TreeWriterTpcV0 {
133133
ctpRateFetcher mRateFetcher;
134134

135135
struct V0Daughter {
136-
double downsamplingTsalis{-999.};
137-
double mass{-999.};
138-
double maxPt4dwnsmplTsalis{-999.};
139-
double tpcNSigma{-999.};
140-
double tofNSigma{-999.};
141-
double tpcExpSignal{-999.};
136+
double downsamplingTsalis{UndefValueDouble};
137+
double mass{UndefValueDouble};
138+
double maxPt4dwnsmplTsalis{UndefValueDouble};
139+
double tpcNSigma{UndefValueDouble};
140+
double tofNSigma{UndefValueDouble};
141+
double tpcExpSignal{UndefValueDouble};
142142
o2::track::PID::ID id{0};
143-
double dwnSmplFactor{-999.};
144-
double nSigmaTofDauTrack{-999.};
143+
double dwnSmplFactor{UndefValueDouble};
144+
double nSigmaTofDauTrack{UndefValueDouble};
145145
bool rejectNoTofDauTrack{false};
146146
};
147147

@@ -165,8 +165,8 @@ struct TreeWriterTpcV0 {
165165
}
166166

167167
struct V0Mother {
168-
int posDaughterId{-999};
169-
int negDaughterId{-999};
168+
int posDaughterId{UndefValueInt};
169+
int negDaughterId{UndefValueInt};
170170
};
171171

172172
V0Mother createV0Mother(const int motherId)
@@ -209,7 +209,7 @@ struct TreeWriterTpcV0 {
209209
}
210210

211211
LOGP(fatal, "getStrangenessTofNSigma for V0: wrong combination of motherId, daughterId and sign");
212-
return -999.f;
212+
return UndefValueFloat;
213213
}
214214

215215
float getStrangenessTofNSigma(CascsWithID::iterator const& casc, const int motherId, const int daughterId, bool)
@@ -218,7 +218,7 @@ struct TreeWriterTpcV0 {
218218
return casc.tofNSigmaOmKa();
219219

220220
LOGP(fatal, "getStrangenessTofNSigma for cascade: wrong combination of motherId and daughterId");
221-
return -999.f;
221+
return UndefValueFloat;
222222
}
223223

224224
template <bool DoUseCorrectedDeDx, int ModeId, typename T, typename C, typename V0Casc>
@@ -259,7 +259,7 @@ struct TreeWriterTpcV0 {
259259
track.y(),
260260
mass,
261261
bg,
262-
multTPC / 11000.,
262+
multTPC / MultiplicityNorm,
263263
std::sqrt(nClNorm / ncl),
264264
nclPID,
265265
id,
@@ -286,7 +286,7 @@ struct TreeWriterTpcV0 {
286286
track.y(),
287287
mass,
288288
bg,
289-
multTPC / 11000.,
289+
multTPC / MultiplicityNorm,
290290
std::sqrt(nClNorm / ncl),
291291
nclPID,
292292
id,
@@ -302,7 +302,7 @@ struct TreeWriterTpcV0 {
302302
pT,
303303
v0radius,
304304
gammapsipair,
305-
existTrkQA ? trackQA.tpcdEdxNorm() : -999);
305+
existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat);
306306
} else if constexpr (ModeId == ModeWithTrkQA) {
307307
rowTPCTreeWithTrkQA(usedDedx,
308308
1. / dEdxExp,
@@ -314,7 +314,7 @@ struct TreeWriterTpcV0 {
314314
track.y(),
315315
mass,
316316
bg,
317-
multTPC / 11000.,
317+
multTPC / MultiplicityNorm,
318318
std::sqrt(nClNorm / ncl),
319319
nclPID,
320320
id,
@@ -333,16 +333,16 @@ struct TreeWriterTpcV0 {
333333
bcGlobalIndex,
334334
bcTimeFrameId,
335335
bcBcInTimeFrame,
336-
existTrkQA ? trackQA.tpcClusterByteMask() : -999,
337-
existTrkQA ? trackQA.tpcdEdxMax0R() : -999,
338-
existTrkQA ? trackQA.tpcdEdxMax1R() : -999,
339-
existTrkQA ? trackQA.tpcdEdxMax2R() : -999,
340-
existTrkQA ? trackQA.tpcdEdxMax3R() : -999,
341-
existTrkQA ? trackQA.tpcdEdxTot0R() : -999,
342-
existTrkQA ? trackQA.tpcdEdxTot1R() : -999,
343-
existTrkQA ? trackQA.tpcdEdxTot2R() : -999,
344-
existTrkQA ? trackQA.tpcdEdxTot3R() : -999,
345-
existTrkQA ? trackQA.tpcdEdxNorm() : -999);
336+
existTrkQA ? trackQA.tpcClusterByteMask() : UndefValueInt,
337+
existTrkQA ? trackQA.tpcdEdxMax0R() : UndefValueInt,
338+
existTrkQA ? trackQA.tpcdEdxMax1R() : UndefValueInt,
339+
existTrkQA ? trackQA.tpcdEdxMax2R() : UndefValueInt,
340+
existTrkQA ? trackQA.tpcdEdxMax3R() : UndefValueInt,
341+
existTrkQA ? trackQA.tpcdEdxTot0R() : UndefValueInt,
342+
existTrkQA ? trackQA.tpcdEdxTot1R() : UndefValueInt,
343+
existTrkQA ? trackQA.tpcdEdxTot2R() : UndefValueInt,
344+
existTrkQA ? trackQA.tpcdEdxTot3R() : UndefValueInt,
345+
existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat);
346346
}
347347
}
348348
}
@@ -423,12 +423,12 @@ struct TreeWriterTpcV0 {
423423
const auto& cascs = myCascs.sliceBy(perCollisionCascs, collision.globalIndex());
424424
const auto& bc = collision.bc_as<BCType>();
425425
const int runnumber = bc.runNumber();
426-
const float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * 1.e-3;
426+
const float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * OneToKilo;
427427
const int bcGlobalIndex = bc.globalIndex();
428428
int bcTimeFrameId, bcBcInTimeFrame;
429429
if constexpr (ModeId == ModeWithdEdxTrkQA || ModeId == ModeStandard) {
430-
bcTimeFrameId = -999;
431-
bcBcInTimeFrame = -999;
430+
bcTimeFrameId = UndefValueInt;
431+
bcBcInTimeFrame = UndefValueInt;
432432
if constexpr (ModeId == ModeWithdEdxTrkQA) {
433433
rowTPCTreeWithdEdxTrkQA.reserve(2 * v0s.size() + cascs.size());
434434
} else if (ModeId == ModeStandard) {
@@ -676,7 +676,7 @@ struct TreeWriterTpcTof {
676676
track.y(),
677677
mass,
678678
bg,
679-
multTPC / 11000.,
679+
multTPC / MultiplicityNorm,
680680
std::sqrt(nClNorm / ncl),
681681
nclPID,
682682
id,
@@ -698,7 +698,7 @@ struct TreeWriterTpcTof {
698698
track.y(),
699699
mass,
700700
bg,
701-
multTPC / 11000.,
701+
multTPC / MultiplicityNorm,
702702
std::sqrt(nClNorm / ncl),
703703
nclPID,
704704
id,
@@ -709,7 +709,7 @@ struct TreeWriterTpcTof {
709709
ft0Occ,
710710
hadronicRate,
711711
nSigmaITS,
712-
existTrkQA ? trackQA.tpcdEdxNorm() : -999);
712+
existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat);
713713
} else if constexpr (ModeId == ModeWithTrkQA) {
714714
rowTPCTOFTreeWithTrkQA(usedEdx,
715715
1. / dEdxExp,
@@ -721,7 +721,7 @@ struct TreeWriterTpcTof {
721721
track.y(),
722722
mass,
723723
bg,
724-
multTPC / 11000.,
724+
multTPC / MultiplicityNorm,
725725
std::sqrt(nClNorm / ncl),
726726
nclPID,
727727
id,
@@ -735,16 +735,16 @@ struct TreeWriterTpcTof {
735735
bcGlobalIndex,
736736
bcTimeFrameId,
737737
bcBcInTimeFrame,
738-
existTrkQA ? trackQA.tpcClusterByteMask() : -999,
739-
existTrkQA ? trackQA.tpcdEdxMax0R() : -999,
740-
existTrkQA ? trackQA.tpcdEdxMax1R() : -999,
741-
existTrkQA ? trackQA.tpcdEdxMax2R() : -999,
742-
existTrkQA ? trackQA.tpcdEdxMax3R() : -999,
743-
existTrkQA ? trackQA.tpcdEdxTot0R() : -999,
744-
existTrkQA ? trackQA.tpcdEdxTot1R() : -999,
745-
existTrkQA ? trackQA.tpcdEdxTot2R() : -999,
746-
existTrkQA ? trackQA.tpcdEdxTot3R() : -999,
747-
existTrkQA ? trackQA.tpcdEdxNorm() : -999);
738+
existTrkQA ? trackQA.tpcClusterByteMask() : UndefValueInt,
739+
existTrkQA ? trackQA.tpcdEdxMax0R() : UndefValueInt,
740+
existTrkQA ? trackQA.tpcdEdxMax1R() : UndefValueInt,
741+
existTrkQA ? trackQA.tpcdEdxMax2R() : UndefValueInt,
742+
existTrkQA ? trackQA.tpcdEdxMax3R() : UndefValueInt,
743+
existTrkQA ? trackQA.tpcdEdxTot0R() : UndefValueInt,
744+
existTrkQA ? trackQA.tpcdEdxTot1R() : UndefValueInt,
745+
existTrkQA ? trackQA.tpcdEdxTot2R() : UndefValueInt,
746+
existTrkQA ? trackQA.tpcdEdxTot3R() : UndefValueInt,
747+
existTrkQA ? trackQA.tpcdEdxNorm() : UndefValueFloat);
748748
}
749749
}
750750
}
@@ -801,19 +801,18 @@ struct TreeWriterTpcTof {
801801

802802
const auto& bc = collision.bc_as<BCType>();
803803
const int runnumber = bc.runNumber();
804-
float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * 1.e-3;
805-
int bcGlobalIndex, bcTimeFrameId, bcBcInTimeFrame;
804+
const float hadronicRate = mRateFetcher.fetch(ccdb.service, bc.timestamp(), runnumber, irSource) * OneToKilo;
805+
const int bcGlobalIndex = bc.globalIndex();
806+
int bcTimeFrameId, bcBcInTimeFrame;
806807
if constexpr (ModeId == ModeStandard || ModeId == ModeWithdEdxTrkQA) {
807-
bcGlobalIndex = -999;
808-
bcTimeFrameId = -999;
809-
bcBcInTimeFrame = -999;
808+
bcTimeFrameId = UndefValueInt;
809+
bcBcInTimeFrame = UndefValueInt;
810810
if constexpr (ModeId == ModeStandard) {
811811
rowTPCTOFTree.reserve(tracks.size());
812812
} else {
813813
rowTPCTOFTreeWithdEdxTrkQA.reserve(tracks.size());
814814
}
815815
} else {
816-
bcGlobalIndex = bc.globalIndex();
817816
bcTimeFrameId = bc.tfId();
818817
bcBcInTimeFrame = bc.bcInTF();
819818
rowTPCTOFTreeWithTrkQA.reserve(tracks.size());
@@ -836,11 +835,11 @@ struct TreeWriterTpcTof {
836835

837836
TofTrack tofDeuteron(true, maxMomHardCutOnlyDe, maxMomTPCOnlyDe, trk.tpcNSigmaDe(), nSigmaTPCOnlyDe, downsamplingTsalisDeuterons, MassDeuteron, trk.tofNSigmaDe(), trk.itsNSigmaDe(), trk.tpcExpSignalDe(tpcSignalGeneric<IsCorrectedDeDx>(trk)), PidDeuteron, dwnSmplFactorDe, nSigmaTofTpctofDe, nSigmaTpcTpctofDe);
838837

839-
TofTrack tofProton(false, -999., maxMomTPCOnlyPr, trk.tpcNSigmaPr(), nSigmaTPCOnlyPr, downsamplingTsalisProtons, MassProton, trk.tofNSigmaPr(), trk.itsNSigmaPr(), trk.tpcExpSignalPr(tpcSignalGeneric<IsCorrectedDeDx>(trk)), PidProton, dwnSmplFactorPr, nSigmaTofTpctofPr, nSigmaTpcTpctofPr);
838+
TofTrack tofProton(false, UndefValueDouble, maxMomTPCOnlyPr, trk.tpcNSigmaPr(), nSigmaTPCOnlyPr, downsamplingTsalisProtons, MassProton, trk.tofNSigmaPr(), trk.itsNSigmaPr(), trk.tpcExpSignalPr(tpcSignalGeneric<IsCorrectedDeDx>(trk)), PidProton, dwnSmplFactorPr, nSigmaTofTpctofPr, nSigmaTpcTpctofPr);
840839

841840
TofTrack tofKaon(true, maxMomHardCutOnlyKa, maxMomTPCOnlyKa, trk.tpcNSigmaKa(), nSigmaTPCOnlyKa, downsamplingTsalisKaons, MassKPlus, trk.tofNSigmaKa(), trk.itsNSigmaKa(), trk.tpcExpSignalKa(tpcSignalGeneric<IsCorrectedDeDx>(trk)), PidKaon, dwnSmplFactorKa, nSigmaTofTpctofKa, nSigmaTpcTpctofKa);
842841

843-
TofTrack tofPion(false, -999., maxMomTPCOnlyPi, trk.tpcNSigmaPi(), nSigmaTPCOnlyPi, downsamplingTsalisPions, MassPiPlus, trk.tofNSigmaPi(), trk.itsNSigmaPi(), trk.tpcExpSignalPi(tpcSignalGeneric<IsCorrectedDeDx>(trk)), PidPion, dwnSmplFactorPi, nSigmaTofTpctofPi, nSigmaTpcTpctofPi);
842+
TofTrack tofPion(false, UndefValueDouble, maxMomTPCOnlyPi, trk.tpcNSigmaPi(), nSigmaTPCOnlyPi, downsamplingTsalisPions, MassPiPlus, trk.tofNSigmaPi(), trk.itsNSigmaPi(), trk.tpcExpSignalPi(tpcSignalGeneric<IsCorrectedDeDx>(trk)), PidPion, dwnSmplFactorPi, nSigmaTofTpctofPi, nSigmaTpcTpctofPi);
844843

845844
for (const auto& tofTrack : {&tofTriton, &tofDeuteron, &tofProton, &tofKaon, &tofPion}) {
846845
if ((!tofTrack->isApplyHardCutOnly || trk.tpcInnerParam() < tofTrack->maxMomHardCutOnly) &&

DPG/Tasks/TPC/tpcSkimsTableCreator.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,22 @@ DECLARE_SOA_TABLE(SkimmedTPCTOFTreeWithTrkQA, "AOD", "TPCTOFSKIMWQA",
133133
#undef TPCSKIMS_COLUMNS_V0
134134
#undef TPCSKIMS_COLUMNS_BASE
135135
} // namespace o2::aod
136+
137+
namespace o2::dpg_tpcskimstablecreator
138+
{
139+
enum {
140+
ModeStandard = 0,
141+
ModeWithdEdxTrkQA,
142+
ModeWithTrkQA
143+
};
144+
145+
constexpr int UndefValueInt{-999};
146+
constexpr float UndefValueFloat{-999.f};
147+
constexpr double UndefValueDouble{-999.};
148+
149+
// an arbitrary big value to convert multiplicity into a value between 0 and 1
150+
constexpr double MultiplicityNorm{11000.};
151+
152+
constexpr float OneToKilo{1e-3f};
153+
} // namespace o2::dpg_tpcskimstablecreator
136154
#endif // DPG_TASKS_TPC_TPCSKIMSTABLECREATOR_H_

DPG/Tasks/TPC/utilsTpcSkimsTableCreator.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ enum {
3939
EventSelectionRun3
4040
};
4141

42-
enum {
43-
ModeStandard = 0,
44-
ModeWithdEdxTrkQA,
45-
ModeWithTrkQA
46-
};
47-
4842
/// Event selection
4943
template <typename CollisionType>
5044
inline bool isEventSelected(const CollisionType& collision, const int applyEvSel)

0 commit comments

Comments
 (0)