Skip to content

Commit 3205395

Browse files
authored
Refactor variable types for memory optimization
Updated data types for various variables to improve memory usage and consistency. Changed float and short types to more appropriate fixed-width integer types.
1 parent fd23dc5 commit 3205395

1 file changed

Lines changed: 23 additions & 21 deletions

File tree

PWGJE/TableProducer/tableDiffWake.cxx

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ struct tableDiffWake {
151151
soa::Join<aod::TracksIU, aod::TracksExtra, aod::TracksDCA, aod::TrackSelection> const& tracks,
152152
bcs const&)
153153
{
154+
const float maxMomentum = 173.0;
155+
154156
// Event selection corresponds to sel8FullPbPb
155157
if (!col.sel8())
156158
return;
@@ -175,7 +177,7 @@ struct tableDiffWake {
175177
//------- Only events with track above some thresh ----------
176178

177179
bool eventHighpT = false;
178-
for (auto& track : tracks) {
180+
for (auto const &track : tracks) {
179181

180182
if (!track.isGlobalTrack())
181183
continue;
@@ -188,8 +190,8 @@ struct tableDiffWake {
188190
return;
189191
//------------------------------------------------------------
190192
// Translate values to less memory consuming values
191-
Short_t Substitute_ep2 = (Short_t)(ep2 * 1000);
192-
Short_t Substitute_ep3 = (Short_t)(ep3 * 1000);
193+
int16_t Substitute_ep2 = (int16_t)(ep2 * 1000);
194+
int16_t Substitute_ep3 = (int16_t)(ep3 * 1000);
193195

194196
testcol(col.globalIndex(),
195197
run,
@@ -203,58 +205,58 @@ struct tableDiffWake {
203205
Substitute_ep2,
204206
Substitute_ep3);
205207

206-
for (auto& track : tracks) {
208+
for (auto const &track : tracks) {
207209

208210
// Track cut
209211
if (!track.isGlobalTrack())
210212
continue; // General track cuts
211213

212-
if (abs(track.px()) > 173.0 || abs(track.py()) > 173.0 || abs(track.pz()) > 173.0)
214+
if (std::abs(track.px()) > maxMomentum || std::abs(track.py()) > maxMomentum || std::abs(track.pz()) > maxMomentum)
213215
continue; // to avoid overflow in Substitute_p
214216

215217
histos.fill(HIST("etaHistogram"), track.eta());
216218
histos.fill(HIST("pTHistogram"), track.pt());
217219

218220
//------------ Translate values to less memory consuming values --------------------
219221
// Px, Py, Pz
220-
ULong64_t Substitute_p = 0;
222+
uint64_t Substitute_p = 0;
221223

222-
Long64_t Particle_px = (track.px() * 6000);
224+
int64_t Particle_px = (track.px() * 6000);
223225
if (Particle_px < 0)
224-
Substitute_p |= (ULong64_t)1 << 20;
226+
Substitute_p |= (uint64_t)1 << 20;
225227
if (Particle_px < 0)
226228
Particle_px = (-1) * Particle_px;
227229
for (Int_t i_bit = 0; i_bit < 20; i_bit++) {
228-
if ((Particle_px & ((Long64_t)1 << i_bit)))
229-
Substitute_p |= (ULong64_t)1 << i_bit;
230+
if ((Particle_px & ((int64_t)1 << i_bit)))
231+
Substitute_p |= (uint64_t)1 << i_bit;
230232
}
231233

232-
Long64_t Particle_py = (track.py() * 6000);
234+
int64_t Particle_py = (track.py() * 6000);
233235
if (Particle_py < 0)
234-
Substitute_p |= (ULong64_t)1 << 41;
236+
Substitute_p |= (uint64_t)1 << 41;
235237
if (Particle_py < 0)
236238
Particle_py = (-1) * Particle_py;
237239
for (Int_t i_bit = 21; i_bit < 41; i_bit++) {
238-
if ((Particle_py & ((Long64_t)1 << (i_bit - 21))))
239-
Substitute_p |= (ULong64_t)1 << i_bit;
240+
if ((Particle_py & ((int64_t)1 << (i_bit - 21))))
241+
Substitute_p |= (uint64_t)1 << i_bit;
240242
}
241243

242-
Long64_t Particle_pz = (track.pz() * 6000);
244+
int64_t Particle_pz = (track.pz() * 6000);
243245
if (Particle_pz < 0)
244-
Substitute_p |= (ULong64_t)1 << 62;
246+
Substitute_p |= (uint64_t)1 << 62;
245247
if (Particle_pz < 0)
246248
Particle_pz = (-1) * Particle_pz;
247249
for (Int_t i_bit = 42; i_bit < 62; i_bit++) {
248-
if ((Particle_pz & ((Long64_t)1 << (i_bit - 42))))
249-
Substitute_p |= (ULong64_t)1 << i_bit;
250+
if ((Particle_pz & ((int64_t)1 << (i_bit - 42))))
251+
Substitute_p |= (uint64_t)1 << i_bit;
250252
}
251253

252254
// dEdx
253-
UShort_t Substitute_dEdx = (UShort_t)(track.tpcSignal() * 10);
255+
uint16_t Substitute_dEdx = (uint16_t)(track.tpcSignal() * 10);
254256

255257
// DCA
256-
Short_t Substitute_DCAXY = (Short_t)(track.dcaXY() * 100);
257-
Short_t Substitute_DCAZ = (Short_t)(track.dcaZ() * 100);
258+
int16_t Substitute_DCAXY = (int16_t)(track.dcaXY() * 100);
259+
int16_t Substitute_DCAZ = (int16_t)(track.dcaZ() * 100);
258260

259261
//--------------- Fill track table ------------------
260262
testtrack(track.collisionId(),

0 commit comments

Comments
 (0)