10 #include <tracking/modules/recoTrackParticleLoader/RecoTrackParticleLoaderModule.h>
12 #include <framework/datastore/StoreArray.h>
14 #include <analysis/dataobjects/Particle.h>
15 #include <analysis/dataobjects/ParticleList.h>
16 #include <analysis/dataobjects/ParticleExtraInfoMap.h>
17 #include <tracking/dataobjects/RecoTrack.h>
20 #include <TLorentzVector.h>
21 #include <TMatrixDSym.h>
33 "Takes fitted RecoTracks and creates Particles from them directly, skipping the step of creating Tracks and TrackFitResults.");
34 setPropertyFlags(c_ParallelProcessingCertified);
36 addParam(
"recoTrackColName", m_recoTrackColName,
37 "Name of the collection holding the input RecoTrack", m_recoTrackColName);
38 addParam(
"particleListName", m_particleListName,
39 "Name of the particleList holding the output Particles", m_particleListName);
40 addParam(
"pdgCode", m_pdgCode,
41 "PDG code of the hypothesis of the output Particles", m_pdgCode);
47 recoTracks.isRequired();
50 particles.registerInDataStore();
51 particles.registerRelationTo(recoTracks);
54 extraInfo.registerInDataStore();
57 pList.registerInDataStore();
68 for (
auto& recoTrack : recoTracks) {
69 if (!recoTrack.wasFitSuccessful()) {
70 B2DEBUG(20,
"Skipping unfitted RecoTrack.");
73 auto rep = recoTrack.getCardinalRepresentation();
74 int pdg = rep->getPDG();
75 auto firstHit = recoTrack.getMeasuredStateOnPlaneFromFirstHit(rep);
78 extrapolatedMSoP.extrapolateToLine(TVector3(0.0, 0.0, 0.0), TVector3(0.0, 0.0, 1.0));
80 B2WARNING(
"Could not extrapolate the fit result for pdg " << pdg <<
81 " to the IP. Why, I don't know.");
87 extrapolatedMSoP.getPosMomCov(pos, mom, cov);
88 double mass = rep->getMass(extrapolatedMSoP);
89 double charge = rep->getCharge(extrapolatedMSoP);
90 double E = std::sqrt(mom.x() * mom.x() + mom.y() * mom.y() + mom.z() * mom.z() + mass * mass);
91 double pValue = recoTrack.getTrackFitStatus(rep)->getPVal();
92 TLorentzVector lorentzMom(mom.x(), mom.y(), mom.z(), E);
94 Particle* newPart = particles.appendNew(lorentzMom, pdg);
100 if (std::abs(pdg) ==
m_pdgCode) pList->addParticle(newPart);