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>
39 setDescription(
"Module that stores CDC hit information from recoTracks, which is needed for dedx.");
51 m_hits.registerInDataStore();
54 if (not genfit::MaterialEffects::getInstance()->isInitialized()) {
55 B2FATAL(
"Need to have SetupGenfitExtrapolationModule in path before this one.");
69 B2WARNING(
"No related recoTrack for this track");
73 B2ERROR(
"GFTrack is pruned, please run CDCDedxHitSaver only on unpruned tracks! Skipping this track.");
80 const auto* rawMeasurement = hitPoint->getRawMeasurement(0);
81 if (not rawMeasurement)
continue;
82 const auto* cdcRecoHit =
dynamic_cast<const CDCRecoHit*
>(rawMeasurement);
83 if (not cdcRecoHit)
continue;
84 const auto* cdcHit = cdcRecoHit->
getCDCHit();
85 if (not cdcHit)
continue;
88 const auto* fitterInfo = hitPoint->getFitterInfo();
89 if (not fitterInfo)
continue;
93 int foundByTrackFinder = hitInfo ? hitInfo->
getFoundByTrackFinder() : RecoHitInformation::c_undefinedTrackFinder;
96 std::map<int, double> weights;
98 const auto* kalmanFitterInfo = hitPoint->getKalmanFitterInfo(rep);
99 if (not kalmanFitterInfo)
continue;
100 auto wts = kalmanFitterInfo->getWeights();
102 for (
double w : wts)
if (w > wt) wt = w;
103 weights[abs(rep->getPDG())] = wt;
108 const genfit::MeasuredStateOnPlane& mop = fitterInfo->getFittedState();
109 auto pocaMom = ROOT::Math::XYZVector(mop.getMom());
110 auto pocaOnTrack = ROOT::Math::XYZVector(mop.getPos());
111 auto pocaOnWire = ROOT::Math::XYZVector(mop.getPlane()->getO());
113 auto* hit =
m_hits.appendNew(cdcRecoHit->getWireID(), cdcHit->getTDCCount(), cdcHit->getADCCount(),
114 pocaMom, pocaOnTrack, pocaOnWire, foundByTrackFinder,
115 weights[211], weights[321], weights[2212]);
116 track.addRelationTo(hit);
117 }
catch (genfit::Exception&) {
118 B2WARNING(
"Track: " << track.getArrayIndex() <<
": genfit::MeasuredStateOnPlane exception occured");
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!
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....
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
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.