2121
2222#include " PWGLF/DataModel/LFStrangenessTables.h"
2323
24+ #include " ALICE3/Core/GeometryContainer.h"
2425#include " ALICE3/Core/TrackUtilities.h"
2526#include " ALICE3/DataModel/OTFPIDTrk.h"
2627#include " ALICE3/DataModel/OTFRICH.h"
3132#include " Common/Core/trackUtilities.h"
3233#include " Common/DataModel/TrackSelectionTables.h"
3334
35+ #include < CCDB/BasicCCDBManager.h>
3436#include < CommonConstants/PhysicsConstants.h>
3537#include < DCAFitter/DCAFitterN.h>
3638#include < DetectorsBase/Propagator.h>
6062#include < vector>
6163
6264using namespace o2 ;
63- // using namespace o2::analysis;
6465using namespace o2 ::framework;
6566using namespace o2 ::constants::physics;
6667
@@ -73,6 +74,9 @@ struct Alice3strangenessFinder {
7374 SliceCache cache;
7475
7576 HistogramRegistry histos{" histos" , {}, OutputObjHandlingPolicy::AnalysisObject};
77+ Service<o2::ccdb::BasicCCDBManager> ccdb{};
78+ o2::fastsim::GeometryContainer geoContainer;
79+ std::vector<std::vector<float >> trackingLayers;
7680
7781 Produces<aod::V0CandidateIndices> v0CandidateIndices; // contains V0 candidate indices
7882 Produces<aod::V0CandidateCores> v0CandidateCores; // contains V0 candidate core information
@@ -145,8 +149,10 @@ struct Alice3strangenessFinder {
145149 Configurable<bool > useOriginalTrackParams{" useOriginalTrackParams" , false , " use original track parameters instead of the ones propagated to PCA (effective only if skipFitter is false) and for MC truth info" };
146150
147151 o2::vertexing::DCAFitterN<2 > fitter;
148- Service<o2::framework::O2DatabasePDG> pdgDB;
152+ Service<o2::framework::O2DatabasePDG> pdgDB{} ;
149153 static constexpr float ToMicrons = 1e+4 ;
154+ static constexpr int LutConfig = 0 ; // todo
155+ static constexpr int LayerNotFound = -99 ;
150156
151157 // partitions for v0/casc dau tracks
152158 Partition<Alice3TracksACTS> positiveSecondaryTracksACTS =
@@ -194,7 +200,7 @@ struct Alice3strangenessFinder {
194200 float dcaToPV{};
195201 };
196202
197- void init (InitContext&)
203+ void init (InitContext& initContext )
198204 {
199205 // Initialization code here
200206 fitter.setBz (magneticField);
@@ -275,6 +281,30 @@ struct Alice3strangenessFinder {
275281 histos.add (" Generated/hGeneratedAntiOmega" , " hGeneratedAntiOmega" , kTH2D , {{axisPt}, {axisEta}});
276282 }
277283
284+ if (doprocessFindV0CandidateOTF) {
285+ ccdb->setURL (" http://alice-ccdb.cern.ch" );
286+ ccdb->setTimestamp (-1 );
287+ geoContainer.setCcdbManager (ccdb.operator ->());
288+ geoContainer.init (initContext);
289+ const int nGeometries = geoContainer.getNumberOfConfigurations ();
290+ trackingLayers.resize (nGeometries);
291+
292+ for (int icfg = 0 ; icfg < nGeometries; ++icfg) {
293+ auto globalConfiguration = geoContainer.getConfigurations (icfg);
294+
295+ for (const auto & [outerKey, innerMap] : globalConfiguration) {
296+ if (outerKey.empty () || outerKey[0 ] != ' B' ) {
297+ continue ;
298+ }
299+
300+ auto it = innerMap.find (" r" );
301+ if (it != innerMap.end ()) {
302+ trackingLayers[icfg].push_back (std::stof (it->second ));
303+ }
304+ }
305+ }
306+ }
307+
278308 if (buildCascade) {
279309 histos.add (" CascadeBuilding/hDcaBetweenDaus" , " hDcaBetweenDaus" , kTH1D , {{axisDCA}});
280310 histos.add (" CascadeBuilding/hXiMass" , " " , kTH1D , {axisXiMass});
@@ -333,6 +363,20 @@ struct Alice3strangenessFinder {
333363 } // end association check
334364 return returnValue;
335365 }
366+
367+ template <typename TTrackType>
368+ [[nodiscard]] float getFirstLayerHitRadius (const TTrackType& track, const std::vector<float >& layers)
369+ {
370+ const float trueRadius = std::hypot (track.x (), track.y ());
371+ for (const float layerRadius : layers) {
372+ if (layerRadius >= trueRadius) {
373+ return layerRadius;
374+ }
375+ }
376+ static constexpr float OutsideALICE3 = 100 .f ;
377+ return OutsideALICE3;
378+ }
379+
336380 template <typename TTrackType>
337381 bool buildDecayCandidateTwoBody (TTrackType const & t0, TTrackType const & t1, std::array<float , 3 > vtx, Candidate& thisCandidate)
338382 {
@@ -373,8 +417,8 @@ struct Alice3strangenessFinder {
373417 t0.getPxPyPzGlo (thisCandidate.pDau0 );
374418 t1.getPxPyPzGlo (thisCandidate.pDau1 );
375419 }
376- histos.fill (HIST (" hPtNegDauAfterV0Finding" ), std::sqrt (thisCandidate.pDau1 [0 ] * thisCandidate. pDau1 [ 0 ] + thisCandidate. pDau1 [ 1 ] + thisCandidate.pDau1 [1 ]), t1.getPt ());
377- histos.fill (HIST (" hPtPosDauAfterV0Finding" ), std::sqrt (thisCandidate.pDau0 [0 ] * thisCandidate. pDau0 [ 0 ] + thisCandidate. pDau0 [ 1 ] + thisCandidate.pDau0 [1 ]), t0.getPt ());
420+ histos.fill (HIST (" hPtNegDauAfterV0Finding" ), std::hypot (thisCandidate.pDau1 [0 ], thisCandidate.pDau1 [1 ]), t1.getPt ());
421+ histos.fill (HIST (" hPtPosDauAfterV0Finding" ), std::hypot (thisCandidate.pDau0 [0 ], thisCandidate.pDau0 [1 ]), t0.getPt ());
378422
379423 thisCandidate.dcaDau = std::sqrt (fitter.getChi2AtPCACandidate ());
380424 thisCandidate.p [0 ] = thisCandidate.pDau0 [0 ] + thisCandidate.pDau1 [0 ];
@@ -416,8 +460,6 @@ struct Alice3strangenessFinder {
416460 thisCandidate.dcaToPV = calculateDCAStraightToPV (thisCandidate.posSV [0 ], thisCandidate.posSV [1 ], thisCandidate.posSV [2 ],
417461 thisCandidate.p [0 ], thisCandidate.p [1 ], thisCandidate.p [2 ],
418462 vtx[0 ], vtx[1 ], vtx[2 ]);
419-
420- return true ;
421463 } else {
422464 t0.getPxPyPzGlo (thisCandidate.pDau0 );
423465 t1.getPxPyPzGlo (thisCandidate.pDau1 );
@@ -434,8 +476,8 @@ struct Alice3strangenessFinder {
434476 thisCandidate.dcaToPV = calculateDCAStraightToPV (thisCandidate.posSV [0 ], thisCandidate.posSV [1 ], thisCandidate.posSV [2 ],
435477 thisCandidate.p [0 ], thisCandidate.p [1 ], thisCandidate.p [2 ],
436478 vtx[0 ], vtx[1 ], vtx[2 ]);
437- return true ;
438479 }
480+ return true ;
439481 }
440482
441483 void processGenerated (aod::McParticles const &)
@@ -603,8 +645,26 @@ struct Alice3strangenessFinder {
603645 continue ; // candidate outside of acceptance
604646 }
605647
606- if (std::hypot (v0Cand.posSV [0 ], v0Cand.posSV [1 ]) < std::hypot (cascCand.posSV [0 ], cascCand.posSV [1 ])) {
607- continue ; // causality
648+ const float radiusV0 = std::hypot (v0Cand.posSV [0 ], v0Cand.posSV [1 ]);
649+ const float radiusCasc = std::hypot (cascCand.posSV [0 ], cascCand.posSV [1 ]);
650+ const float posCausalityRadius = getFirstLayerHitRadius (posTrack, trackingLayers[LutConfig]);
651+ const float negCausalityRadius = getFirstLayerHitRadius (negTrack, trackingLayers[LutConfig]);
652+ const float bachCausalityRadius = getFirstLayerHitRadius (bachTrack, trackingLayers[LutConfig]);
653+
654+ if (posCausalityRadius < radiusV0) {
655+ continue ; // positive track hit a layer before v0 decayed
656+ }
657+
658+ if (negCausalityRadius < radiusV0) {
659+ continue ; // negative track hit a layer before v0 decayed
660+ }
661+
662+ if (radiusV0 < radiusCasc) {
663+ continue ; // v0 decayed before cascade
664+ }
665+
666+ if (bachCausalityRadius < radiusCasc) {
667+ continue ; // bachelor track hit a layer before v0 decayed
608668 }
609669
610670 const float massXi = RecoDecay::m (std::array{std::array{cascCand.pDau0 [0 ], cascCand.pDau0 [1 ], cascCand.pDau0 [2 ]},
@@ -685,10 +745,12 @@ struct Alice3strangenessFinder {
685745 isLambda = (posParticle.pdgCode () == kProton && negParticle.pdgCode () == kPiMinus );
686746 isAntiLambda = (posParticle.pdgCode () == kPiPlus && negParticle.pdgCode () == kProtonBar );
687747 if (isK0s || isLambda || isAntiLambda) {
688- if (!isK0s && isK0Gun)
748+ if (!isK0s && isK0Gun) {
689749 continue ;
690- if (!isLambda && isLambdaGun)
750+ }
751+ if (!isLambda && isLambdaGun) {
691752 continue ;
753+ }
692754 Candidate v0cand;
693755 std::vector<double > v0DecayVertex;
694756 v0DecayVertex.push_back (negParticle.vx ());
@@ -700,8 +762,9 @@ struct Alice3strangenessFinder {
700762 o2::track::TrackParCov negParCov;
701763 o2::upgrade::convertTLorentzVectorToO2Track (1 , posLorVector, v0DecayVertex, posParCov);
702764 o2::upgrade::convertTLorentzVectorToO2Track (-1 , negLorVector, v0DecayVertex, negParCov);
703- if (!buildDecayCandidateTwoBody (posParCov, negParCov, vtx, v0cand))
765+ if (!buildDecayCandidateTwoBody (posParCov, negParCov, vtx, v0cand)) {
704766 continue ;
767+ }
705768 v0CandidateIndices (collision.globalIndex (),
706769 posParticle.globalIndex (),
707770 negParticle.globalIndex (),
0 commit comments