 |
Belle II Software
release-05-01-25
|
10 #include <tracking/modules/reattachCDCWireHitsToRecoTracks/ReattachCDCWireHitsToRecoTracksModule.h>
12 #include <tracking/trackFindingCDC/topology/CDCWire.h>
13 #include <tracking/trackFindingCDC/geometry/Vector3D.h>
14 #include <tracking/trackFindingCDC/geometry/Vector2D.h>
15 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory3D.h>
16 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
17 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectorySZ.h>
18 #include <tracking/trackFitting/fitter/base/TrackFitter.h>
19 #include <tracking/dataobjects/RecoHitInformation.h>
22 using namespace TrackFindingCDC;
30 Module to loop over low-ADC/TOT CDCWireHits and RecoTracks
31 and reattach the hits to the tracks if they are closer
32 than a given distance.)DOC");
33 setPropertyFlags(c_ParallelProcessingCertified);
35 addParam(
"CDCWireHitsStoreArrayName", m_CDCWireHitsStoreArrayName,
36 "Name of the input CDCWireHit StoreArray", m_CDCWireHitsStoreArrayName);
37 addParam(
"inputRecoTracksStoreArrayName", m_inputRecoTracksStoreArrayName,
38 "Name of the input RecoTrack StoreArray", m_inputRecoTracksStoreArrayName);
39 addParam(
"outputRecoTracksStoreArrayName", m_outputRecoTracksStoreArrayName,
40 "Name of the output RecoTrack StoreArray", m_outputRecoTracksStoreArrayName);
41 addParam(
"MaximumDistance", m_maximumDistance,
42 "Distance (cm) below which (exclusive) a CDC hit can be reattached to a track", m_maximumDistance);
43 addParam(
"MinimumADC", m_minimumADC,
44 "ADC above which (inclusive) a CDC hit can be reattached to a track", m_minimumADC);
45 addParam(
"MinimumTOT", m_minimumTOT,
46 "TOT above which (inclusive) a CDC hit can be reattached to a track", m_minimumTOT);
47 addParam(
"MaximumAbsD0", m_maximumAbsD0,
48 "Only tracks with an absolute value of d0 below (exclusive) this parameter (cm) are considered", m_maximumAbsD0);
49 addParam(
"MaximumAbsZ0", m_maximumAbsZ0,
50 "Only tracks with an absolute value of z0 below (exclusive) this parameter (cm) are considered", m_maximumAbsZ0);
78 const Vector3D trackPosition(recoTrack.getPositionSeed());
79 const Vector3D trackMomentum(recoTrack.getMomentumSeed());
80 const CDCTrajectory3D trajectory(trackPosition, recoTrack.getTimeSeed(), trackMomentum, recoTrack.getChargeSeed());
84 const double z0Estimate(trajectorySZ.
getZ0());
86 if (trackFitter.
fit(recoTrack)) {
95 if ((wireHit.getAutomatonCell().hasBadADCOrTOTFlag()) and
101 ERightLeft currentRlInfo(ERightLeft::c_Unknown);
108 bool neighborFound(
false);
116 neighborFound =
true;
123 recoTrack.getRecoHitInformation(hitOnTrack)));
125 if (not results.isValid) {
129 if (std::abs(results.distanceToTrack) < currentMinimalDistance) {
131 currentMinimalDistance = std::abs(results.distanceToTrack);
132 currentClosestTrack = &recoTrack;
133 currentRlInfo = results.rlInfo;
135 B2DEBUG(29,
"Background hit close to the track found..." << std::endl
136 <<
"Layer of the hit on track: " << hitOnTrack->getICLayer() << std::endl
137 <<
"Layer of the background hit: " << wireHit.getHit()->getICLayer() << std::endl
138 <<
"ID of the background hit: " << wireHit.getHit()->getID() << std::endl
139 <<
"ADC of the background hit: " << wireHit.getHit()->getADCCount() << std::endl
140 <<
"TOT of the background hit: " << wireHit.getHit()->getTOT() << std::endl
141 <<
"Distance from track to hit: " << results.distanceToTrack << std::endl);
148 hitToAddInfo.
hit = &wireHit;
149 hitToAddInfo.
rlInfo = currentRlInfo;
170 std::unordered_map<CDCWireHit*, double> previousArcLength;
171 std::unordered_map<CDCWireHit*, double> currentArcLength;
174 previousArcLength[hitToAddInfo.hit] = 0.0;
175 currentArcLength[hitToAddInfo.hit] = 0.0;
176 (hitToAddInfo.hit)->getAutomatonCell().setTakenFlag(
false);
177 (hitToAddInfo.hit)->getAutomatonCell().setBackgroundFlag(
false);
180 unsigned int sortingParameter(0);
188 recoTrack.getRecoHitInformation(hitOnTrack)));
190 previousArcLength[&hitToAdd] = currentArcLength[&hitToAdd];
191 currentArcLength[&hitToAdd] = results.arcLength;
193 B2DEBUG(29,
"Hit to be added..." << std::endl
194 <<
"Layer of the hit on track: " << hitOnTrack->getICLayer() << std::endl
195 <<
"Layer of the background hit: " << hitToAdd.
getHit()->
getICLayer() << std::endl
196 <<
"ID of the background hit: " << hitToAdd.
getHit()->
getID() << std::endl
197 <<
"ADC of the background hit: " << hitToAdd.
getHit()->
getADCCount() << std::endl
198 <<
"TOT of the background hit: " << hitToAdd.
getHit()->
getTOT() << std::endl
199 <<
"Distance from track to hit: " << results.distanceToTrack << std::endl
200 <<
"Previous arc lenght of the hit: " << previousArcLength[&hitToAdd] << std::endl
201 <<
"Current arc lenght of the hit: " << currentArcLength[&hitToAdd] << std::endl);
203 if ((previousArcLength[&hitToAdd] > 0) and (currentArcLength[&hitToAdd] < 0)) {
206 newRecoTrack->
addCDCHit(hitToAdd.
getHit(), sortingParameter, rl, RecoHitInformation::c_ReattachCDCWireHitsToRecoTracks);
215 newRecoTrack->
addCDCHit(hitOnTrack, sortingParameter, rl, foundBy);
233 const Vector3D trackPosition(mSoP.getPos());
234 const Vector3D trackMomentum(mSoP.getMom());
235 const CDCTrajectory3D trajectory(trackPosition, mSoP.getTime(), trackMomentum, mSoP.getCharge());
248 const double z(trajectorySZ.
mapSToZ(arcLength));
254 Vector2D disp2D(recoPosOnTrajectory - wirePos2DAtZ);
256 recoPos2D = wirePos2DAtZ + disp2D;
261 results.z = trajectorySZ.
mapSToZ(results.arcLength);
262 results.distanceToTrack = trajectory2D.
getDist2D(recoPos2D);
266 Vector3D trackPosToWire{hitPosition - trackPosition};
267 results.rlInfo = trackPosToWire.xy().isRightOrLeftOf(trackMomentum.
xy());
269 results.isValid =
true;
272 B2WARNING(
"Distance measurement does not work.");
273 results.isValid =
false;
284 if (rlInfo == ERightLeft::c_Left) {
285 return RightLeftInformation::c_left;
286 }
else if (rlInfo == ERightLeft::c_Right) {
287 return RightLeftInformation::c_right;
288 }
else if (rlInfo == ERightLeft::c_Invalid) {
289 return RightLeftInformation::c_invalidRightLeftInformation;
291 return RightLeftInformation::c_undefinedRightLeftInformation;
AutomatonCell & getAutomatonCell() const
Mutable getter for the automaton cell.
double m_maximumDistance
Distance (cm) below which (exclusive) a CDC hit can be reattached to a track.
static void registerRequiredRelations(StoreArray< RecoTrack > &recoTracks, std::string const &pxdHitsStoreArrayName="", std::string const &svdHitsStoreArrayName="", std::string const &cdcHitsStoreArrayName="", std::string const &bklmHitsStoreArrayName="", std::string const &eklmHitsStoreArrayName="", std::string const &recoHitInformationStoreArrayName="")
Convenience method which registers all relations required to fully use a RecoTrack.
std::string m_inputRecoTracksStoreArrayName
Name of the input RecoTrack StoreArray.
Internal structure to store the results of the reconstruction.
size_t addHitsFromRecoTrack(const RecoTrack *recoTrack, unsigned int sortingParameterOffset=0, bool reversed=false, boost::optional< double > optionalMinimalWeight=boost::none)
Add all hits from another RecoTrack to this RecoTrack.
StoreArray< RecoTrack > m_outputRecoTracks
Output tracks.
Vector3D getWirePos3DAtZ(const double z) const
Gives position of the wire at the given z coordinate.
double normalizeTo(const double toLength)
Normalizes the vector to the given length.
bool fit(RecoTrack &recoTrack, genfit::AbsTrackRep *trackRepresentation) const
Fit a reco track with a given non-default track representation.
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
#StateOnPlane with additional covariance matrix.
double getRefDriftLength() const
Getter for the drift length at the reference position of the wire.
unsigned short getID() const
Getter for encoded wire number.
const genfit::MeasuredStateOnPlane & getMeasuredStateOnPlaneFromRecoHit(const RecoHitInformation *recoHitInfo, const genfit::AbsTrackRep *representation=nullptr) const
Return genfit's MeasuredStateOnPlane on plane for associated with one RecoHitInformation.
double m_maximumAbsD0
Only tracks with an absolute value of d0 below (exclusive) this parameter (cm) are considered.
void initialize() override
Declare required StoreArray.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
int m_minimumADC
ADC above which (inclusive) a CDC hit can be reattached to a track.
void setTakenFlag(bool setTo=true)
Sets the taken flag to the given value. Default value true.
Module to loop over low-ADC/TOT CDCWireHits and fitted RecoTracks, and reattach the hits to the track...
std::unordered_map< RecoTrack *, std::vector< HitToAddInfo > > m_mapToHitsToAdd
Map from a RecoTrack ptr to the vector of the hits that need to be added to this track.
unsigned short getICLayer() const
Getter for iCLayer (0-55).
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
Linear trajectory in sz space.
std::string m_CDCWireHitsStoreArrayName
Name of the input CDCWireHit StoreWrappedObjPtr.
Vector2D getClosest(const Vector2D &point) const
Calculates the closest approach on the trajectory to the given point.
RecoTrack * copyToStoreArray(StoreArray< RecoTrack > &storeArray) const
Append a new RecoTrack to the given store array and copy its general properties, but not the hits the...
Particle trajectory as it is seen in xy projection represented as a circle.
Vector2D getWirePos2DAtZ(const double z) const
Gives the xy projected position of the wire at the given z coordinate.
unsigned short getTOT() const
Getter for TOT.
double mapSToZ(const double s=0) const
Translates the travel distance to the z coordinate.
unsigned short getADCCount() const
Getter for integrated charge.
bool addCDCHit(const UsedCDCHit *cdcHit, const unsigned int sortingParameter, RightLeftInformation rightLeftInformation=RightLeftInformation::c_undefinedRightLeftInformation, OriginTrackFinder foundByTrackFinder=OriginTrackFinder::c_undefinedTrackFinder)
Adds a cdc hit with the given information to the reco track.
Algorithm class to handle the fitting of RecoTrack objects.
This is the Reconstruction Event-Data Model Track.
ReconstructionResults reconstruct(const CDCWireHit &wireHit, const RecoTrack &recoTrack, const RecoHitInformation *recoHitInformation) const
Compute distance from a CDCWireHit to a RecoTrack using the mSoP found with a RecoHitInformation.
StoreArray< RecoTrack > m_inputRecoTracks
Input tracks.
CDCTrajectory2D getTrajectory2D() const
Getter for the two dimensional trajectory.
CDCTrajectorySZ getTrajectorySZ() const
Getter for the sz trajectory.
double getZ0() const
Getter for the z coordinate at zero travel distance.
void event() override
Event processing, combine store array.
Abstract base class for different kinds of events.
std::unordered_map< RecoTrack *, std::vector< CDCHit * > > m_mapToHitsOnTrack
Map from a RecoTrack ptr to the vector of the hits that belong to this track.
A three dimensional vector.
static const CDCWire * getInstance(const WireID &wireID)
Getter from the wireID convinience object. Does not construct a new object.
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
bool hasTakenFlag() const
Gets the current state of the taken marker flag.
const Vector2D & xy() const
Getter for the xy projected vector ( reference ! )
const CDCWire & getWire() const
Getter for the CDCWire the hit is located on.
Internal structure to store the information about a hit to be added.
Class representing a sense wire in the central drift chamber.
void addHits()
Add the selected CDC hits to the RecoTracks.
RecoHitInformation::RightLeftInformation rightLeftInformationTranslator(ERightLeft rlInfo) const
Translate a TrackFindingCDC::ERightLeft into a RecoHitInformation::RightLeftInformation.
double getDist2D(const Vector2D &point) const
Calculates the distance from the point to the trajectory as seen from the xy projection.
CDCWireHit * hit
Pointer the hit to be added.
double z() const
Getter for the z coordinate.
std::string m_outputRecoTracksStoreArrayName
Name of the output RecoTrack StoreArray.
Class representing a hit wire in the central drift chamber.
double m_maximumAbsZ0
Only tracks with an absolute value of z0 below (exclusive) this parameter (cm) are considered.
void findHits()
Find the hits that can be added to the RecoTracks.
int m_minimumTOT
TOT above which (inclusive) a CDC hit can be reattached to a track.
Vector2D reconstruct2D(const CDCTrajectory2D &trajectory2D) const
Reconstructs a position of primary ionisation on the drift circle.
double calcArcLength2D(const Vector2D &point) const
Calculate the travel distance from the start position of the trajectory.
ERightLeft rlInfo
Right-left information of the hit.
Particle full three dimensional trajectory.
bool isAxial() const
Indicator if the underlying wire is axial.
StoreWrappedObjPtr< std::vector< CDCWireHit > > m_CDCWireHits
Input CDCWireHits.