3131#include " PWGLF/DataModel/LFStrangenessPIDTables.h"
3232#include " PWGLF/Utils/strangenessBuilderHelper.h"
3333#include " CCDB/BasicCCDBManager.h"
34+ #include " DataFormatsParameters/GRPObject.h"
35+ #include " DataFormatsParameters/GRPMagField.h"
3436
3537using namespace o2 ;
3638using namespace o2 ::framework;
@@ -115,7 +117,7 @@ static constexpr int nTablesConst = 73;
115117
116118static const std::vector<std::string> parameterNames{" enable" };
117119static const int defaultParameters[nTablesConst][nParameters]{
118- {-1 }, {- 1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, // 0-9
120+ {-1 }, { 1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, // 0-9
119121 {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, // 10-19
120122 {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, // 20-29
121123 {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, {-1 }, // 30-39
@@ -384,20 +386,47 @@ struct StrangenessBuilder {
384386 return true ;
385387 }
386388
387- // acquire LUT for this timestamp
388389 auto timestamp = bc.timestamp ();
390+ o2::parameters::GRPObject* grpo = 0x0 ;
391+ o2::parameters::GRPMagField* grpmag = 0x0 ;
392+ if (doprocessRealDataRun2) {
393+ grpo = ccdb->getForTimeStamp <o2::parameters::GRPObject>(ccdbConfigurations.grpPath , timestamp);
394+ if (!grpo) {
395+ LOG (fatal) << " Got nullptr from CCDB for path " << ccdbConfigurations.grpPath << " of object GRPObject for timestamp " << timestamp;
396+ }
397+ o2::base::Propagator::initFieldFromGRP (grpo);
398+ } else {
399+ grpmag = ccdb->getForTimeStamp <o2::parameters::GRPMagField>(ccdbConfigurations.grpmagPath , timestamp);
400+ if (!grpmag) {
401+ LOG (fatal) << " Got nullptr from CCDB for path " << ccdbConfigurations.grpmagPath << " of object GRPMagField for timestamp " << timestamp;
402+ }
403+ o2::base::Propagator::initFieldFromGRP (grpmag);
404+ }
405+ // Fetch magnetic field from ccdb for current collision
406+ auto magneticField = o2::base::Propagator::Instance ()->getNominalBz ();
407+ LOG (info) << " Retrieved GRP for timestamp " << timestamp << " with magnetic field of " << magneticField << " kG" ;
408+
409+ // Set magnetic field value once known
410+ straHelper.fitter .setBz (magneticField);
411+
412+ // acquire LUT for this timestamp
389413 LOG (info) << " Loading material look-up table for timestamp: " << timestamp;
390414 lut = o2::base::MatLayerCylSet::rectifyPtrFromFile (ccdb->getForTimeStamp <o2::base::MatLayerCylSet>(ccdbConfigurations.lutPath , timestamp));
391415 o2::base::Propagator::Instance ()->setMatLUT (lut);
392416 straHelper.lut = lut;
393417
418+ LOG (info) << " Fully configured for run: " << bc.runNumber ();
419+ // mmark this run as configured
420+ mRunNumber = bc.runNumber ();
421+
394422 return true ;
395423 }
396424
397425 // __________________________________________________
398426 template <typename TV0s, typename TCascades>
399427 void markV0sUsedInCascades (TV0s const & v0s, TCascades const & cascades)
400428 {
429+ v0sFromCascades.clear ();
401430 v0Map.resize (v0s.size (), -2 ); // marks not used
402431 for (auto & cascade : cascades) {
403432 v0Map[cascade.v0Id ()] = -1 ; // marks used (but isn't the index of a properly built V0, which would be >= 0)
@@ -407,14 +436,28 @@ struct StrangenessBuilder {
407436 template <class TTracks , typename TCollisions, typename TV0s>
408437 void buildV0s (TCollisions const & collisions, TV0s const & v0s)
409438 {
439+ int nV0s = 0 ;
410440 // Loops over all V0s in the time frame
411441 for (auto & v0 : v0s) {
442+ if (!mEnabledTables [kV0CoresBase ] && v0Map[v0.globalIndex ()] == -2 ){
443+ // this hasn't been used by cascades and we're not generating V0s, so skip it
444+ continue ;
445+ }
446+
412447 // Get tracks and generate candidate
413448 auto const & collision = v0.collision ();
414449 auto const & posTrack = v0.template posTrack_as <TTracks>();
415450 auto const & negTrack = v0.template negTrack_as <TTracks>();
416- straHelper.buildV0Candidate (collision, posTrack, negTrack, v0.isCollinearV0 ());
451+ if (!straHelper.buildV0Candidate (collision, posTrack, negTrack, v0.isCollinearV0 ())){
452+ continue ;
453+ }
454+ nV0s++;
455+ if (v0Map[v0.globalIndex ()]==-1 ){
456+ v0Map[v0.globalIndex ()] = v0sFromCascades.size (); // provide actual valid index in buffer
457+ v0sFromCascades.push_back (straHelper.v0 );
458+ }
417459 }
460+ LOGF (info, " V0s in DF: %i, V0s built: %i, V0s built and buffered for cascades: %i." , v0s.size (), nV0s, v0sFromCascades.size ());
418461 }
419462
420463 void processPreselectTPCPID (aod::Collisions const & collisions, aod::V0s const & V0s, aod::Cascades const & Cascades, FullTracksExtIU const &, aod::BCsWithTimestamps const & bcs)
@@ -428,12 +471,11 @@ struct StrangenessBuilder {
428471 {
429472 if (!initCCDB (bcs, collisions)) return ;
430473 markV0sUsedInCascades (v0s, cascades);
431- if (mEnabledTables [kV0CoresBase ]){ // V0s have been requested
432- buildV0s<TTracks>(collisions, v0s);
433- }
434- if (mEnabledTables [kStoredCascCores ]){ // Cascades have been requested
435- // buildCascades<FullTracksExtIU>(Cascades);
436- }
474+
475+ // build V0s
476+ buildV0s<TTracks>(collisions, v0s);
477+
478+ // buildCascades<FullTracksExtIU>(Cascades);
437479 }
438480
439481 void processRealData (aod::Collisions const & collisions, aod::V0s const & v0s, aod::Cascades const & cascades, FullTracksExtIU const & tracks, aod::BCsWithTimestamps const & bcs)
@@ -443,7 +485,7 @@ struct StrangenessBuilder {
443485
444486 void processRealDataRun2 (aod::Collisions const & collisions, aod::V0s const & v0s, aod::Cascades const & cascades, FullTracksExt const & tracks, aod::BCsWithTimestamps const & bcs)
445487 {
446- // dataProcess(collisions, v0s, cascades, tracks, bcs);
488+ dataProcess (collisions, v0s, cascades, tracks, bcs);
447489 }
448490
449491 void processSimulationFindable (aod::Collisions const & collisions, aod::V0s const & V0s, aod::Cascades const & Cascades, FullTracksExtIU const &, aod::BCsWithTimestamps const & bcs)
0 commit comments