9#include <cdc/modules/CDCDedxPID/CDCDedxHitSaverModule.h>
10#include <cdc/dataobjects/CDCHit.h>
11#include <cdc/dataobjects/CDCRecoHit.h>
12#include <genfit/KalmanFitterInfo.h>
13#include <genfit/Exception.h>
14#include <genfit/MaterialEffects.h>
37 setDescription(
"Module that stores CDC hit information from recoTracks, which is needed for dedx.");
49 m_hits.registerInDataStore();
52 if (not genfit::MaterialEffects::getInstance()->isInitialized()) {
53 B2FATAL(
"Need to have SetupGenfitExtrapolationModule in path before this one.");
69 B2WARNING(
"No related recoTrack for this track");
75 B2ERROR(
"GFTrack is pruned, please run CDCDedxHitSaver only on unpruned tracks! Skipping this track.");
84 const auto* rawMeasurement = hitPoint->getRawMeasurement(0);
85 if (not rawMeasurement)
continue;
86 const auto* cdcRecoHit =
dynamic_cast<const CDCRecoHit*
>(rawMeasurement);
87 if (not cdcRecoHit)
continue;
88 const auto* cdcHit = cdcRecoHit->
getCDCHit();
89 if (not cdcHit)
continue;
92 const auto* fitterInfo = hitPoint->getFitterInfo();
93 if (not fitterInfo)
continue;
97 int foundByTrackFinder = hitInfo ? hitInfo->
getFoundByTrackFinder() : RecoHitInformation::c_undefinedTrackFinder;
100 std::map<int, double> weights;
102 const auto* kalmanFitterInfo = hitPoint->getKalmanFitterInfo(rep);
103 if (not kalmanFitterInfo)
continue;
104 auto wts = kalmanFitterInfo->getWeights();
106 for (
double w : wts)
if (w > wt) wt = w;
107 weights[std::abs(rep->getPDG())] = wt;
112 const genfit::MeasuredStateOnPlane& mop = fitterInfo->getFittedState();
113 auto pocaMom = ROOT::Math::XYZVector(mop.getMom());
114 auto pocaOnTrack = ROOT::Math::XYZVector(mop.getPos());
115 auto pocaOnWire = ROOT::Math::XYZVector(mop.getPlane()->getO());
117 auto* hit =
m_hits.appendNew(cdcRecoHit->getWireID(), cdcHit->getTDCCount(), cdcHit->getADCCount(),
118 pocaMom, pocaOnTrack, pocaOnWire, foundByTrackFinder,
119 weights[211], weights[321], weights[2212]);
120 track.addRelationTo(hit);
121 }
catch (genfit::Exception&) {
122 B2WARNING(
"Track: " << track.getArrayIndex() <<
": genfit::MeasuredStateOnPlane exception occurred");
StoreArray< Track > m_tracks
required collection of tracks
StoreArray< RecoTrack > m_recoTracks
required collection of reco tracks
StoreArray< CDCDedxHit > m_hits
output collection of hits
This class is used to transfer CDC information to the track fit.
const CDCHit * getCDCHit() const
get the pointer to the CDCHit object that was used to create this CDCRecoHit object.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
This is the Reconstruction Event-Data Model Track.
const std::vector< genfit::AbsTrackRep * > & getRepresentations() const
Return a list of track representations. You are not allowed to modify or delete them!
bool hasTrackFitStatus(const genfit::AbsTrackRep *representation=nullptr) const
Check, if there is a fit status for the given representation or for the cardinal one.
RecoHitInformation * getRecoHitInformation(HitType *hit) const
Return the reco hit information for a generic hit from the storeArray.
const genfit::FitStatus * getTrackFitStatus(const genfit::AbsTrackRep *representation=nullptr) const
Return the track fit status for the given representation or for the cardinal one. You are not allowed...
const std::vector< genfit::TrackPoint * > & getHitPointsWithMeasurement() const
Return a list of measurements and track points, which can be used e.g. to extrapolate....
CDCDedxHitSaverModule()
Default constructor.
virtual void initialize() override
Initialize the module.
virtual void event() override
This method is called for each event.
virtual ~CDCDedxHitSaverModule()
Destructor.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.