8 #include <tracking/modules/recoTrackParticleLoader/RecoTrackParticleLoaderModule.h>
10 #include <framework/datastore/StoreArray.h>
12 #include <analysis/dataobjects/Particle.h>
13 #include <analysis/dataobjects/ParticleList.h>
14 #include <analysis/dataobjects/ParticleExtraInfoMap.h>
15 #include <tracking/dataobjects/RecoTrack.h>
18 #include <TLorentzVector.h>
19 #include <TMatrixDSym.h>
31 "Takes fitted RecoTracks and creates Particles from them directly, skipping the step of creating Tracks and TrackFitResults.");
32 setPropertyFlags(c_ParallelProcessingCertified);
34 addParam(
"recoTrackColName", m_recoTrackColName,
35 "Name of the collection holding the input RecoTrack", m_recoTrackColName);
36 addParam(
"particleListName", m_particleListName,
37 "Name of the particleList holding the output Particles", m_particleListName);
38 addParam(
"pdgCode", m_pdgCode,
39 "PDG code of the hypothesis of the output Particles", m_pdgCode);
48 particles.registerInDataStore();
49 particles.registerRelationTo(recoTracks);
52 extraInfo.registerInDataStore();
66 for (
auto& recoTrack : recoTracks) {
67 if (!recoTrack.wasFitSuccessful()) {
68 B2DEBUG(20,
"Skipping unfitted RecoTrack.");
71 auto rep = recoTrack.getCardinalRepresentation();
72 int pdg = rep->getPDG();
73 auto firstHit = recoTrack.getMeasuredStateOnPlaneFromFirstHit(rep);
76 extrapolatedMSoP.extrapolateToLine(TVector3(0.0, 0.0, 0.0), TVector3(0.0, 0.0, 1.0));
78 B2WARNING(
"Could not extrapolate the fit result for pdg " << pdg <<
79 " to the IP. Why, I don't know.");
85 extrapolatedMSoP.getPosMomCov(pos, mom, cov);
86 double mass = rep->getMass(extrapolatedMSoP);
87 double charge = rep->getCharge(extrapolatedMSoP);
88 double E = std::sqrt(mom.x() * mom.x() + mom.y() * mom.y() + mom.z() * mom.z() + mass * mass);
89 double pValue = recoTrack.getTrackFitStatus(rep)->getPVal();
90 TLorentzVector lorentzMom(mom.x(), mom.y(), mom.z(), E);
92 Particle* newPart = particles.appendNew(lorentzMom, pdg);
98 if (std::abs(pdg) ==
m_pdgCode) pList->addParticle(newPart);
Class to store reconstructed particles.
void setPValue(float pValue)
Sets chi^2 probability of fit.
void writeExtraInfo(const std::string &name, const float value)
Sets the user defined extraInfo.
void setVertex(const TVector3 &vertex)
Sets position (decay vertex)
Takes fitted RecoTracks and creates Particles from them directly, skipping the step of creating Track...
std::string m_particleListName
Name of the particleList holding the output Particles.
void initialize() override
Require and register the datastore arrays.
void event() override
Build Particle array.
std::string m_recoTrackColName
Name of the collection holding the input RecoTracks.
int m_pdgCode
PDG code of the hypothesis of the output Particles.
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
bool create(bool replace=false)
Create a default object in the data store.
Accessor to arrays stored in the data store.
Type-safe access to single objects in the data store.
#StateOnPlane with additional covariance matrix.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.