@@ -313,30 +313,30 @@ struct HfTreeCreatorTccToD0D0Pi {
313313 {
314314
315315 for (const auto & collision : collisions) {
316- auto bc = collision.template bc_as <aod::BCsWithTimestamps>();
317316 auto primaryVertex = getPrimaryVertex (collision);
318- if (runNumber != bc.runNumber ()) {
319- LOG (info) << " >>>>>>>>>>>> Current run number: " << runNumber;
320- initCCDB (bc, runNumber, ccdb, isRun2 ? ccdbPathGrp : ccdbPathGrpMag, lut, isRun2);
321- bz = o2::base::Propagator::Instance ()->getNominalBz ();
322- LOG (info) << " >>>>>>>>>>>> Magnetic field: " << bz;
323- }
317+ auto bc = collision.template bc_as <aod::BCsWithTimestamps>();
318+ fillEvent (collision, 0 , bc.runNumber ());
324319
325320 if (buildVertex) {
321+ if (runNumber != bc.runNumber ()) {
322+ LOG (info) << " >>>>>>>>>>>> Current run number: " << runNumber;
323+ initCCDB (bc, runNumber, ccdb, isRun2 ? ccdbPathGrp : ccdbPathGrpMag, lut, isRun2);
324+ bz = o2::base::Propagator::Instance ()->getNominalBz ();
325+ LOG (info) << " >>>>>>>>>>>> Magnetic field: " << bz;
326+ }
326327 dfTcc.setBz (bz);
327328 dfD1.setBz (bz);
328329 dfD2.setBz (bz);
329330 }
330- fillEvent (collision, 0 , bc.runNumber ());
331331 auto thisCollId = collision.globalIndex ();
332332 auto candwD0ThisColl = candidates.sliceBy (candsD0PerCollisionWithMl, thisCollId);
333333 if (candwD0ThisColl.size () <= 1 )
334334 continue ; // only loop the collision that include at least 2 D candidates
335335 auto trackIdsThisCollision = trackIndices.sliceBy (trackIndicesPerCollision, thisCollId);
336336
337- for (const auto & candidateD1 : candidates ) {
338- for (auto candidateD2 = candidateD1 + 1 ; candidateD2 != candidates .end (); ++candidateD2) {
339- for (const auto & trackId : trackIndices ) {
337+ for (const auto & candidateD1 : candwD0ThisColl ) {
338+ for (auto candidateD2 = candidateD1 + 1 ; candidateD2 != candwD0ThisColl .end (); ++candidateD2) {
339+ for (const auto & trackId : trackIdsThisCollision ) {
340340
341341 auto trackPion = trackId.template track_as <TrkType>();
342342 if (usePionIsGlobalTrackWoDCA && !trackPion.isGlobalTrackWoDCA ()) {
0 commit comments