@@ -289,7 +289,7 @@ struct OnTheFlyTracker {
289289
290290 o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE;
291291
292- // Track smearer
292+ // Track smearer array, one per geometry
293293 std::vector<std::unique_ptr<o2::delphes::DelphesO2TrackSmearer>> mSmearer ;
294294
295295 // For processing and vertexing
@@ -307,6 +307,7 @@ struct OnTheFlyTracker {
307307
308308 void init (o2::framework::InitContext&)
309309 {
310+ LOG (info) << " Initializing OnTheFlyTracker task" ;
310311 ccdb->setURL (" http://alice-ccdb.cern.ch" );
311312 ccdb->setTimestamp (-1 );
312313
@@ -786,23 +787,19 @@ struct OnTheFlyTracker {
786787 laDecayRadius2D = std::hypot (laDecayVertex[0 ], laDecayVertex[1 ]);
787788 }
788789 }
789- const auto pdg = std::abs (mcParticle.pdgCode ());
790- bool isV0 = std::find (v0PDGs.begin (), v0PDGs.end (), pdg) != v0PDGs.end ();
791- bool isK0 = (std::abs (pdg) == kK0Short );
792- bool isLambda = (std::abs (pdg) == kLambda0 );
793- bool isAntiLambda = (std::abs (pdg) == kLambda0Bar );
790+ const bool isV0 = std::find (v0PDGs.begin (), v0PDGs.end (), std::abs (mcParticle.pdgCode ())) != v0PDGs.end ();
794791
795792 if (v0DecaySettings.decayV0 && isV0) {
796- decayV0Particle (mcParticle, v0DecayProducts, v0DecayVertex, pdg );
793+ decayV0Particle (mcParticle, v0DecayProducts, v0DecayVertex, std::abs (mcParticle. pdgCode ()) );
797794 v0DecayRadius2D = std::hypot (v0DecayVertex[0 ], v0DecayVertex[1 ]);
798795 }
799796
800797 if (!mcParticle.isPhysicalPrimary ()) {
801798 continue ;
802799 }
803800
804- const bool longLivedToBeHandled = std::find (longLivedHandledPDGs.begin (), longLivedHandledPDGs.end (), pdg ) != longLivedHandledPDGs.end ();
805- const bool nucleiToBeHandled = std::find (nucleiPDGs.begin (), nucleiPDGs.end (), pdg ) != nucleiPDGs.end ();
801+ const bool longLivedToBeHandled = std::find (longLivedHandledPDGs.begin (), longLivedHandledPDGs.end (), std::abs (mcParticle. pdgCode ()) ) != longLivedHandledPDGs.end ();
802+ const bool nucleiToBeHandled = std::find (nucleiPDGs.begin (), nucleiPDGs.end (), std::abs (mcParticle. pdgCode ()) ) != nucleiPDGs.end ();
806803 const bool pdgsToBeHandled = longLivedToBeHandled || (enableNucleiSmearing && nucleiToBeHandled) || (cascadeDecaySettings.decayXi && mcParticle.pdgCode () == kXiMinus ) || (v0DecaySettings.decayV0 && isV0);
807804 if (!pdgsToBeHandled) {
808805 continue ;
@@ -814,14 +811,20 @@ struct OnTheFlyTracker {
814811 if (enablePrimarySmearing) {
815812 getHist (TH1, histPath + " hPtGenerated" )->Fill (mcParticle.pt ());
816813 getHist (TH1, histPath + " hPhiGenerated" )->Fill (mcParticle.phi ());
817- if (std::abs (mcParticle.pdgCode ()) == kElectron )
818- getHist (TH1, histPath + " hPtGeneratedEl" )->Fill (mcParticle.pt ());
819- if (std::abs (mcParticle.pdgCode ()) == kPiPlus )
820- getHist (TH1, histPath + " hPtGeneratedPi" )->Fill (mcParticle.pt ());
821- if (std::abs (mcParticle.pdgCode ()) == kKPlus )
822- getHist (TH1, histPath + " hPtGeneratedKa" )->Fill (mcParticle.pt ());
823- if (std::abs (mcParticle.pdgCode ()) == kProton )
824- getHist (TH1, histPath + " hPtGeneratedPr" )->Fill (mcParticle.pt ());
814+ switch (std::abs (mcParticle.pdgCode ())) {
815+ case kElectron :
816+ getHist (TH1, histPath + " hPtGeneratedEl" )->Fill (mcParticle.pt ());
817+ break ;
818+ case kPiPlus :
819+ getHist (TH1, histPath + " hPtGeneratedPi" )->Fill (mcParticle.pt ());
820+ break ;
821+ case kKPlus :
822+ getHist (TH1, histPath + " hPtGeneratedKa" )->Fill (mcParticle.pt ());
823+ break ;
824+ case kProton :
825+ getHist (TH1, histPath + " hPtGeneratedPr" )->Fill (mcParticle.pt ());
826+ break ;
827+ }
825828 }
826829 if (cascadeDecaySettings.doXiQA && mcParticle.pdgCode () == kXiMinus ) {
827830 histos.fill (HIST (" hGenXi" ), xiDecayRadius2D, mcParticle.pt ());
@@ -831,7 +834,10 @@ struct OnTheFlyTracker {
831834 }
832835 if (v0DecaySettings.doV0QA && isV0) {
833836 for (size_t indexV0 = 0 ; indexV0 < v0PDGs.size (); indexV0++) {
834- for (int indexDetector = 0 ; indexDetector < mGeoContainer .getNumberOfConfigurations (); indexDetector++) {
837+ if (mcParticle.pdgCode () != v0PDGs[indexV0]) {
838+ continue ;
839+ }
840+ for (int indexDetector = 0 ; indexDetector < NtypesDetectors; indexDetector++) {
835841 std::string path = Form (" V0Building_Configuration_%i/%s/" , indexDetector, NameV0s[indexV0].data ());
836842 fillHist (TH2, path + " hGen" , v0DecayRadius2D, mcParticle.pt ());
837843 fillHist (TH2, path + " hGenNegDaughterFromV0" , v0DecayRadius2D, v0DecayProducts[0 ].Pt ());
@@ -1131,15 +1137,21 @@ struct OnTheFlyTracker {
11311137 if (v0DecaySettings.doV0QA ) {
11321138 fillHist (TH1, Form (" V0Building_Configuration_%i/hV0Building" , icfg), 0 .0f );
11331139 }
1134- if (isK0) {
1135- o2::upgrade::convertTLorentzVectorToO2Track (kPiMinus , v0DecayProducts[0 ], v0DecayVertex, v0DaughterTrackParCovsPerfect[0 ], pdgDB);
1136- o2::upgrade::convertTLorentzVectorToO2Track (kPiPlus , v0DecayProducts[1 ], v0DecayVertex, v0DaughterTrackParCovsPerfect[1 ], pdgDB);
1137- } else if (isLambda) {
1138- o2::upgrade::convertTLorentzVectorToO2Track (kPiMinus , v0DecayProducts[0 ], v0DecayVertex, v0DaughterTrackParCovsPerfect[0 ], pdgDB);
1139- o2::upgrade::convertTLorentzVectorToO2Track (kProton , v0DecayProducts[1 ], v0DecayVertex, v0DaughterTrackParCovsPerfect[1 ], pdgDB);
1140- } else if (isAntiLambda) {
1141- o2::upgrade::convertTLorentzVectorToO2Track (kProtonBar , v0DecayProducts[0 ], v0DecayVertex, v0DaughterTrackParCovsPerfect[0 ], pdgDB);
1142- o2::upgrade::convertTLorentzVectorToO2Track (kPiPlus , v0DecayProducts[1 ], v0DecayVertex, v0DaughterTrackParCovsPerfect[1 ], pdgDB);
1140+ switch (mcParticle.pdgCode ()) {
1141+ case kK0Short :
1142+ o2::upgrade::convertTLorentzVectorToO2Track (kPiMinus , v0DecayProducts[0 ], v0DecayVertex, v0DaughterTrackParCovsPerfect[0 ], pdgDB);
1143+ o2::upgrade::convertTLorentzVectorToO2Track (kPiPlus , v0DecayProducts[1 ], v0DecayVertex, v0DaughterTrackParCovsPerfect[1 ], pdgDB);
1144+ break ;
1145+ case kLambda0 :
1146+ o2::upgrade::convertTLorentzVectorToO2Track (kPiMinus , v0DecayProducts[0 ], v0DecayVertex, v0DaughterTrackParCovsPerfect[0 ], pdgDB);
1147+ o2::upgrade::convertTLorentzVectorToO2Track (kProton , v0DecayProducts[1 ], v0DecayVertex, v0DaughterTrackParCovsPerfect[1 ], pdgDB);
1148+ break ;
1149+ case kLambda0Bar :
1150+ o2::upgrade::convertTLorentzVectorToO2Track (kProtonBar , v0DecayProducts[0 ], v0DecayVertex, v0DaughterTrackParCovsPerfect[0 ], pdgDB);
1151+ o2::upgrade::convertTLorentzVectorToO2Track (kPiPlus , v0DecayProducts[1 ], v0DecayVertex, v0DaughterTrackParCovsPerfect[1 ], pdgDB);
1152+ break ;
1153+ default :
1154+ LOG (fatal) << " Unhandled V0 PDG code " << mcParticle.pdgCode ();
11431155 }
11441156 for (int i = 0 ; i < kv0Prongs; i++) {
11451157 isV0Reco[i] = false ;
@@ -1183,21 +1195,21 @@ struct OnTheFlyTracker {
11831195 if (isReco[0 ] && isReco[1 ]) {
11841196 fillHist (TH1, Form (" V0Building_Configuration_%i/hV0Building" , icfg), 1 .0f );
11851197 for (size_t indexV0 = 0 ; indexV0 < v0PDGs.size (); indexV0++) {
1186- if (pdg == v0PDGs[indexV0]) {
1198+ if (mcParticle. pdgCode () == v0PDGs[indexV0]) {
11871199 fillHist (TH2, Form (" V0Building_Configuration_%i/%s/hReco" , icfg, NameV0s[indexV0].data ()), v0DecayRadius2D, mcParticle.pt ());
11881200 }
11891201 }
11901202 }
11911203 if (isReco[0 ]) {
11921204 for (size_t indexV0 = 0 ; indexV0 < v0PDGs.size (); indexV0++) {
1193- if (pdg == v0PDGs[indexV0]) {
1205+ if (mcParticle. pdgCode () == v0PDGs[indexV0]) {
11941206 fillHist (TH2, Form (" V0Building_Configuration_%i/%s/hRecoNegDaughterFromV0" , icfg, NameV0s[indexV0].data ()), v0DecayRadius2D, v0DecayProducts[0 ].Pt ());
11951207 }
11961208 }
11971209 }
11981210 if (isReco[1 ]) {
11991211 for (size_t indexV0 = 0 ; indexV0 < v0PDGs.size (); indexV0++) {
1200- if (pdg == v0PDGs[indexV0]) {
1212+ if (mcParticle. pdgCode () == v0PDGs[indexV0]) {
12011213 fillHist (TH2, Form (" V0Building_Configuration_%i/%s/hRecoPosDaughterFromV0" , icfg, NameV0s[indexV0].data ()), v0DecayRadius2D, v0DecayProducts[1 ].Pt ());
12021214 }
12031215 }
@@ -1257,7 +1269,7 @@ struct OnTheFlyTracker {
12571269 thisV0.v0radius = std::hypot (pos[0 ], pos[1 ]);
12581270 thisV0.pt = std::hypot (std::cos (v0DaughterTrackParCovsTracked[0 ].getPhi ()) * v0DaughterTrackParCovsTracked[0 ].getPt () + std::cos (v0DaughterTrackParCovsTracked[1 ].getPhi ()) * v0DaughterTrackParCovsTracked[1 ].getPt (),
12591271 std::sin (v0DaughterTrackParCovsTracked[0 ].getPhi ()) * v0DaughterTrackParCovsTracked[0 ].getPt () + std::sin (v0DaughterTrackParCovsTracked[1 ].getPhi ()) * v0DaughterTrackParCovsTracked[1 ].getPt ());
1260- if (isK0 ) {
1272+ if (std::abs (mcParticle. pdgCode ()) == kK0Short ) {
12611273 thisV0.mK0 = RecoDecay::m (std::array{std::array{posP[0 ], posP[1 ], posP[2 ]},
12621274 std::array{negP[0 ], negP[1 ], negP[2 ]}},
12631275 std::array{o2::constants::physics::MassPionCharged,
@@ -1266,7 +1278,7 @@ struct OnTheFlyTracker {
12661278 thisV0.mK0 = -1 ;
12671279 }
12681280
1269- if (isLambda ) {
1281+ if (mcParticle. pdgCode () == kLambda0 ) {
12701282 thisV0.mLambda = RecoDecay::m (std::array{std::array{posP[0 ], posP[1 ], posP[2 ]},
12711283 std::array{negP[0 ], negP[1 ], negP[2 ]}},
12721284 std::array{o2::constants::physics::MassPionCharged,
@@ -1275,7 +1287,7 @@ struct OnTheFlyTracker {
12751287 thisV0.mLambda = -1 ;
12761288 }
12771289
1278- if (isAntiLambda ) {
1290+ if (mcParticle. pdgCode () == kLambda0Bar ) {
12791291 thisV0.mAntiLambda = RecoDecay::m (std::array{std::array{posP[0 ], posP[1 ], posP[2 ]},
12801292 std::array{negP[0 ], negP[1 ], negP[2 ]}},
12811293 std::array{o2::constants::physics::MassProton,
0 commit comments