 |
Belle II Software
release-05-01-25
|
10 #include <tracking/trackFindingCDC/mclookup/CDCSimHitLookUp.h>
12 #include <tracking/trackFindingCDC/mclookup/CDCMCManager.h>
13 #include <tracking/trackFindingCDC/mclookup/CDCMCMap.h>
15 #include <tracking/trackFindingCDC/eventdata/hits/CDCRecoHit3D.h>
16 #include <tracking/trackFindingCDC/eventdata/hits/CDCRecoHit2D.h>
17 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
19 #include <tracking/trackFindingCDC/topology/CDCWireTopology.h>
21 #include <tracking/trackFindingCDC/geometry/Vector3D.h>
23 #include <tracking/trackFindingCDC/utilities/VectorRange.h>
25 #include <cdc/dataobjects/CDCSimHit.h>
26 #include <cdc/dataobjects/CDCHit.h>
31 using namespace TrackFindingCDC;
48 B2DEBUG(100,
"In CDCSimHitLookUp::fill()");
62 B2WARNING(
"CDCMCMap not set. Cannot setup primary sim hit map");
67 int nMissingPrimarySimHits = 0;
70 const CDCHit* ptrHit = std::get<const CDCHit* const>(relation);
71 const CDCSimHit* ptrSimHit = std::get<const CDCSimHit*>(relation);
74 B2ERROR(
"CDCHit has no related CDCSimHit in CDCSimHitLookUp::fill()");
80 if (not primarySimHit) {
81 ++nMissingPrimarySimHits;
86 if (nMissingPrimarySimHits != 0) {
87 B2WARNING(
"NO primary hit found for " << nMissingPrimarySimHits <<
" reassigned secondaries");
99 B2WARNING(
"CDCMCMap not set. Cannot find primary sim hit");
112 if (not ptrMCParticle) {
117 std::vector<const CDCSimHit*> primarySimHitsOnSameOrNeighborWire;
120 for (
const auto& simHitByMCParticleRelation : mcMap.
getSimHits(ptrMCParticle)) {
122 const CDCSimHit* ptrPrimarySimHit = std::get<const CDCSimHit*>(simHitByMCParticleRelation);
125 const CDCSimHit& primarySimHit = *ptrPrimarySimHit;
131 primarySimHitsOnSameOrNeighborWire.push_back(ptrPrimarySimHit);
137 auto compareDistanceBetweenSimHits =
138 [&simHit](
const CDCSimHit * primarySimHit,
139 const CDCSimHit * otherPrimarySimHit) ->
bool {
141 Vector3D otherPrimaryHitPos(otherPrimarySimHit->getPosTrack());
143 return primaryHitPos.
distance(secondaryHitPos) < otherPrimaryHitPos.
distance(secondaryHitPos);
146 auto itClosestPrimarySimHit = std::min_element(primarySimHitsOnSameOrNeighborWire.begin(),
147 primarySimHitsOnSameOrNeighborWire.end(),
148 compareDistanceBetweenSimHits);
150 if (itClosestPrimarySimHit != primarySimHitsOnSameOrNeighborWire.end()) {
152 return *itClosestPrimarySimHit;
162 B2WARNING(
"CDCMCMap not set in look up of closest primary sim hit.");
170 const CDCSimHit* simHit = itFoundPrimarySimHit->second;
171 if (simHit)
return simHit;
183 B2WARNING(
"CDCMCMap not set. Cannot find direction of flight");
191 if (not ptrSimHit)
return Vector3D();
196 if (not ptrPrimarySimHit) {
198 ptrPrimarySimHit = ptrSimHit;
203 const CDCSimHit& primarySimHit = *ptrPrimarySimHit;
207 return directionOfFlight;
214 B2WARNING(
"CDCMCMap not set. Cannot setup right left passage information map");
221 const CDCHit* ptrHit = std::get<const CDCHit* const>(relation);
222 const CDCSimHit* ptrSimHit = std::get<const CDCSimHit*>(relation);
224 if (not ptrSimHit)
continue;
228 if (directionOfFlight.
isNull())
continue;
232 ERightLeft rlInfo = trackPosToWire.xy().isRightOrLeftOf(directionOfFlight.
xy());
240 return itFoundHit ==
m_rightLeftInfos.end() ? ERightLeft::c_Invalid : itFoundHit->second;
246 B2WARNING(
"CDCMCMap not set. Cannot find reconstructed position");
254 B2WARNING(
"No CDCSimHit related to CDCHit");
265 B2WARNING(
"CDCMCMap not set. Cannot find reconstructed position");
273 B2WARNING(
"No CDCSimHit related to CDCHit");
284 if (ptrPrimarySimHit) {
285 const CDCSimHit& primarySimHit = *ptrPrimarySimHit;
294 if (ptrPrimarySimHit) {
295 const CDCSimHit& primarySimHit = *ptrPrimarySimHit;
303 const std::vector<CDCWireHit>& wireHits)
const
305 if (not ptrHit)
return nullptr;
308 if (wireHit.empty()) {
311 return &(wireHit.front());
316 const std::vector<CDCWireHit>& wireHits)
const
321 B2ASSERT(
"Could not find CDCWireHit for the requested hit", wireHit);
326 const std::vector<CDCWireHit>& wireHits)
const
337 const std::vector<CDCWireHit>& wireHits)
const
347 const std::vector<CDCWireHit>& wireHits)
const
354 const std::vector<CDCWireHit>& wireHits)
const
Class to identify a wire inside the CDC.
static const CDCSimHitLookUp & getInstance()
Getter for the singletone instance.
HepGeom::Vector3D< double > Vector3D
3D Vector
auto getSimHits(const MCParticle *mcParticle) const
Getter for the range MCParticle to CDCSimHits relations which come from the given MCParticle.
Class representing a three dimensional reconstructed hit.
TVector3 getPosTrack() const
The method to get position on the track.
double getDriftLength(const CDCHit *ptrHit) const
Look up the drift length from the primary ionisation to the wire from related simulated hit.
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
static CDCWireTopology & getInstance()
Getter for the singleton instance of the wire topology.
Vector3D getDirectionOfFlight(const CDCHit *ptrHit)
Calculate the local direction of flight. If the hit is secondary take the direction of flight from a ...
CDCRLWireHit getRLWireHit(const CDCHit *ptrHit, const std::vector< CDCWireHit > &wireHits) const
Retrieve the wire hit including right left passage information for the given CDCHit form the given wi...
void clear()
Clear all information from the last event.
MayBePtr< const MCParticle > getMCParticle(const CDCHit *hit) const
Seeks the MCParticle related to the CDCHit.
Vector3D getRecoPos3D(const CDCHit *ptrHit) const
Look up the position of the primary ionisation from related simulated hit.
void fill(const CDCMCMap *ptrMCMap)
Gather the information about the right left passage using the CDCMCMap.
Vector3D getClosestPrimaryRecoPos3D(const CDCHit *ptrHit) const
Look up the position of the primary ionisation from the closest primary simulated hit.
CDCRecoHit2D getClosestPrimaryRecoHit2D(const CDCHit *ptrHit, const std::vector< CDCWireHit > &wireHits) const
Construct an CDCRecoHit2D from the closest primary CDCSimHit information related to the CDCHit.
Class representing a two dimensional reconstructed hit in the central drift chamber.
std::map< const CDCHit *, MayBePtr< const CDCSimHit > > m_primarySimHits
Memory for the look up relation of close primary CDCSimHits.
Abstract base class for different kinds of events.
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
A three dimensional vector.
CDCRecoHit2D getRecoHit2D(const CDCHit *ptrHit, const std::vector< CDCWireHit > &wireHits) const
Construct an CDCRecoHit2D from the (potential secondary) CDCSimHit information related to the CDCHit.
double getClosestPrimaryDriftLength(const CDCHit *ptrHit) const
Look up the drift length from the primary ionisation to the wire from related simulated hit.
double distance(const Vector3D &rhs=Vector3D(0.0, 0.0, 0.0)) const
Calculates the distance of this point to the rhs.
bool isNull() const
Checks if the vector is the null vector.
CDCRecoHit3D getClosestPrimaryRecoHit3D(const CDCHit *ptrHit, const std::vector< CDCWireHit > &wireHits) const
Construct an CDCRecoHit3D from the closest primary CDCSimHit information related to the CDCHit.
Singletone class to gather local information about the hits.
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
double getDriftLength() const
The method to get drift length.
bool arePrimaryNeighbors(const WireID &wireID, const WireID &otherWireID) const
Checks if two wires are primary neighbors.
void setRefDriftLength(double driftLength)
Setter for the drift length at the reference position of the wire.
A pair of iterators usable with the range base for loop.
static const CDCSimHitLookUp & getSimHitLookUp()
Getter for the singletone instance of the CDCSimHitLookUp.
TVector3 getPosWire() const
The method to get position on wire.
CDCRecoHit3D getRecoHit3D(const CDCHit *ptrHit, const std::vector< CDCWireHit > &wireHits) const
Construct an CDCRecoHit3D from the (potential secondary) CDCSimHit information related to the CDCHit.
const Vector2D & xy() const
Getter for the xy projected vector ( reference ! )
MayBePtr< const CDCSimHit > getSimHit(const CDCHit *hit) const
Seeks the CDCSimHit related to the CDCHit.
MayBePtr< const CDCSimHit > getClosestPrimarySimHit(const CDCSimHit *ptrSimHit) const
Helper function to find the closest primary hit for the given CDCSimHit from the same MCParticle - nu...
bool isReassignedSecondary(const CDCSimHit *ptrSimHit) const
Indicates if the CDCSimHit has been reassigned to a primary MCParticle.
const CDCWireHit * getWireHit(const CDCHit *ptrHit, const std::vector< CDCWireHit > &wireHits) const
Retrieve the wire hit the given CDCHit form the given wire hits.
TVector3 getMomentum() const
The method to get momentum.
A Class to store the Monte Carlo particle information.
Class representing a hit wire in the central drift chamber.
std::map< const CDCHit *, ERightLeft > m_rightLeftInfos
Memory for the look up relation of the right left passage information as defined in tracking.
const CDCMCMap * m_ptrMCMap
Reference to the CDCMCMap to be used in this event.
static constexpr const double c_simpleDriftLengthVariance
A default value for the drift length variance if no variance from the drift length translation is ava...
const std::multimap< const CDCHit *, const CDCSimHit * > & getSimHitsByHit() const
Getter for the CDCHit -> CDCSimHit relations.
Class to organize and present the monte carlo hit information.
WireID getWireID() const
Getter for WireID object.
void fillRLInfo()
Construct the look up relation for the right left passage information as used in track finding.
Class representating the sense wire arrangement in the whole of the central drift chamber.
void fillPrimarySimHits()
Constructs the relation from reassigned secondary to a close by primary hit from the same MCParticle.
CDCRecoHit2D getRecoHit2D() const
Constructs a two dimensional reconstructed hit by carrying out the stereo ! projection to the wire re...
ERightLeft getRLInfo(const CDCHit *ptrHit) const
Look up the Monte Carlo right left passage information for the given hit.