8 #include <tracking/modules/trackCreator/TrackCreatorModule.h>
10 #include <framework/datastore/StoreArray.h>
11 #include <framework/logging/Logger.h>
13 #include <mdst/dataobjects/MCParticle.h>
14 #include <mdst/dataobjects/Track.h>
15 #include <mdst/dataobjects/TrackFitResult.h>
17 #include <tracking/dataobjects/RecoTrack.h>
18 #include <tracking/trackFitting/trackBuilder/factories/TrackBuilder.h>
19 #include <tracking/trackFitting/fitter/base/TrackFitter.h>
29 "Build Tracks with the TrackFitResults. Needs RecoTracks as input, creates Belle2::Tracks and Belle2::TrackFitResults as output.");
30 setPropertyFlags(c_ParallelProcessingCertified);
33 addParam(
"recoTrackColName", m_recoTrackColName,
"Name of collection holding the RecoTracks (input).",
35 addParam(
"mcParticleColName", m_mcParticleColName,
"Name of collection holding the MCParticles (input, optional).",
38 addParam(
"trackColName", m_trackColName,
"Name of collection holding the Tracks (output).", m_trackColName);
39 addParam(
"trackFitResultColName", m_trackFitResultColName,
"Name of collection holding the TrackFitResult (output).",
40 m_trackFitResultColName);
42 addParam(
"beamSpot", m_beamSpot,
43 "BeamSpot (and BeamAxis) define the coordinate system in which the tracks will be extrapolated to the perigee.",
45 addParam(
"beamAxis", m_beamAxis,
46 "(BeamSpot and )BeamAxis define the coordinate system in which the tracks will be extrapolated to the perigee.",
48 addParam(
"pdgCodes", m_pdgCodes,
49 "PDG codes for which TrackFitResults will be created.",
52 addParam(
"useClosestHitToIP", m_useClosestHitToIP,
"Flag to turn on special handling which measurement "
53 "to choose; especially useful for Cosmics.", m_useClosestHitToIP);
54 addParam(
"useBFieldAtHit", m_useBFieldAtHit,
"Flag to calculate the BField at the used hit "
55 "(closest to IP or first one), instead of the one at the POCA. Use this for cosmics to prevent problems, when cosmics reconstruction end up in the QCS magnet.",
66 const bool mcParticlesPresent = mcParticles.
isOptional();
73 B2ASSERT(
"Could not register output store arrays.", (tracksRegistered and trackFitResultsRegistered));
75 tracks.registerRelationTo(recoTracks);
77 if (mcParticlesPresent) {
78 tracks.registerRelationTo(mcParticles);
81 B2ASSERT(
"BeamSpot should have exactly 3 parameters",
m_beamSpot.size() == 3);
84 B2ASSERT(
"BeamAxis should have exactly 3 parameters",
m_beamAxis.size() == 3);
91 B2FATAL(
"TrackFitMomentumRange parameters are not available.");
98 B2DEBUG(20,
"RecoTrack StoreArray does not contain any RecoTracks.");
104 for (
auto& recoTrack : recoTracks) {
108 B2DEBUG(25,
"Trying to fit with PDG = " << pdg);
110 pdg) <<
"\tSeed p: " << recoTrack.getMomentumSeed().Mag());
The ParticleType class for identifying different particle types.
@ c_ErrorIfAlreadyRegistered
If the object/array was already registered, produce an error (aborting initialisation).
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
Accessor to arrays stored in the data store.
int getEntries() const
Get the number of objects in the array.
TrackBuilder class to create the Track/TrackFitResult mdst output from the RecoTrack.
bool storeTrackFromRecoTrack(RecoTrack &recoTrack, const bool useClosestHitToIP=false, const bool useBFieldAtHit=false)
Stores a Belle2 Track from a Reco Track.
Takes RecoTracks coming from the event reconstructions and fits them with the configured list of part...
TVector3 m_beamSpotAsTVector
BeamSpot as TVector3.
std::vector< double > m_beamSpot
BeamSpot define the coordinate system in which the tracks will be extrapolated to the perigee.
void initialize() override
Require and register the store arrays.
void event() override
Build/fit the track fit results.
DBObjPtr< TrackFitMomentumRange > m_trackFitMomentumRange
TrackFitMomentumRange Database OjbPtr.
TVector3 m_beamAxisAsTVector
BeamAxis as TVector3.
bool m_useClosestHitToIP
Flag to turn on special handling which measurement to choose; especially useful for Cosmics.
std::vector< double > m_beamAxis
BeamAxis define the coordinate system in which the tracks will be extrapolated to the perigee.
std::string m_trackColName
Name of collection holding the Tracks (output).
void beginRun() override
Called when entering a new run, to load TrackFitMomentumRange parameters.
std::string m_mcParticleColName
Name of collection holding the MCParticles (input, optional).
std::string m_recoTrackColName
Name of collection holding the RecoTracks (input).
std::vector< int > m_pdgCodes
PDG codes for which TrackFitResults will be created.
std::string m_trackFitResultColName
Name of collection holding the TrackFitResult (output).
Algorithm class to handle the fitting of RecoTrack objects.
bool fit(RecoTrack &recoTrack, genfit::AbsTrackRep *trackRepresentation) const
Fit a reco track with a given non-default track representation.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.