Belle II Software development
CDCMCHitLookUp.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <tracking/trackFindingCDC/mclookup/CDCMCHitLookUp.h>
9
10#include <tracking/trackFindingCDC/mclookup/CDCSimHitLookUp.h>
11#include <tracking/trackFindingCDC/mclookup/CDCMCTrackStore.h>
12#include <tracking/trackFindingCDC/mclookup/CDCMCMap.h>
13#include <tracking/trackFindingCDC/mclookup/CDCMCManager.h>
14
15#include <tracking/trackingUtilities/eventdata/hits/CDCWireHit.h>
16
17#include <cdc/topology/CDCWire.h>
18
19#include <cdc/dataobjects/CDCHit.h>
20#include <cdc/dataobjects/CDCSimHit.h>
21#include <mdst/dataobjects/MCParticle.h>
22
23
24#include <Math/Vector3D.h>
25#include <Math/Vector2D.h>
26
27using namespace Belle2;
28using namespace CDC;
29using namespace TrackFindingCDC;
30using namespace TrackingUtilities;
31
32
37
38
40{
42}
43
44
46{
47 return CDCMCManager::getMCMap().getSimHit(ptrHit);
48}
49
50
52{
54}
55
56
57const ROOT::Math::XYVector CDCMCHitLookUp::getRefPos2D(const CDCHit* ptrHit) const
58{
59 if (not ptrHit) return ROOT::Math::XYVector();
60 const CDCHit& hit = *ptrHit;
61
62 const CDCWire* ptrWire = CDCWire::getInstance(hit);
63
64 if (not ptrWire) {
65 B2WARNING("Encountered CDCHit with wire ids that do not correspond to a valid wire in the CDC)");
66 return ROOT::Math::XYVector();
67 }
68
69 const CDCWire& wire = *ptrWire;
70 ROOT::Math::XYVector refPos2D = wire.getRefPos2D();
71 return refPos2D;
72}
73
74
75float CDCMCHitLookUp::getRefDriftLength(const CDCHit* ptrHit) const
76{
77
78 if (not ptrHit) return NAN;
79 CDCWireHit wireHit(ptrHit);
80 return wireHit.getRefDriftLength();
81
82}
83
84
85const ROOT::Math::XYZVector CDCMCHitLookUp::getRecoPos3D(const CDCHit* ptrHit) const
86{
88}
89
90
91const ROOT::Math::XYZVector CDCMCHitLookUp::getClosestPrimaryRecoPos3D(const CDCHit* ptrHit) const
92{
94}
95
96
98{
100}
101
102
103
108
109
110ERightLeft CDCMCHitLookUp::getRLInfo(const CDCHit* ptrHit) const
111{
113}
114
115
116bool CDCMCHitLookUp::isBackground(const CDCHit* ptrHit) const
117{
118 const CDCSimHit* ptrSimHit = getSimHit(ptrHit);
119 return ptrSimHit ? ptrSimHit->getBackgroundTag() != BackgroundMetaData::bg_none : false;
120}
121
122
123ITrackType CDCMCHitLookUp::getMCTrackId(const CDCHit* ptrHit) const
124{
125 const MCParticle* ptrMCParticle = getMCParticle(ptrHit);
126 return ptrMCParticle ? ptrMCParticle->getArrayIndex() : INVALID_ITRACK;
127}
128
129
130Index CDCMCHitLookUp::getInTrackId(const CDCHit* ptrHit) const
131{
133}
134
135
137{
139}
140
141
146
147
148Index CDCMCHitLookUp::getNLoops(const CDCHit* ptrHit) const
149{
151}
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition CDCHit.h:40
Example Detector.
Definition CDCSimHit.h:21
Class representing a sense wire in the central drift chamber.
Definition CDCWire.h:50
const ROOT::Math::XYVector & getRefPos2D() const
Getter for the wire reference position for 2D tracking Gives the wire's reference position projected ...
Definition CDCWire.h:221
static const CDCWire * getInstance(const WireID &wireID)
Getter from the wireID convenience object. Does not construct a new object.
Definition CDCWire.cc:24
A Class to store the Monte Carlo particle information.
Definition MCParticle.h:32
int getArrayIndex() const
Get 0-based index of the particle in the corresponding MCParticle list.
Definition MCParticle.h:233
virtual unsigned short getBackgroundTag() const
Get background tag.
Definition SimHitBase.h:46
TrackingUtilities::Index getNPassedSuperLayers(const CDCHit *ptrHit) const
Returns the number of superlayers the track traversed until this hit.
const ROOT::Math::XYZVector getClosestPrimaryRecoPos3D(const CDCHit *ptrHit) const
Getter for the three dimensional position of the ionisation of the primary simulated hit for the hit.
void fill() const
Method for forwarding a request to fill the Monte Carlo lookup tables from Python.
bool isReassignedSecondary(const CDCHit *ptrHit) const
Indicates if the hit was reassigned to a different mc particle because it was caused by a secondary.
float getRefDriftLength(const CDCHit *ptrHit) const
Getter for the reference drift length in the two dimensional projection.
CDCMCHitLookUp()=default
Default constructor, needs to be public for initialization in CDCMCManager.
const CDCSimHit * getClosestPrimarySimHit(const CDCHit *ptrHit) const
Getter for the closest simulated hit of a primary particle to the given hit - may return nullptr of n...
const ROOT::Math::XYVector getRefPos2D(const CDCHit *ptrHit) const
Getter for the two dimensional reference position of the wire the given hit is located on - mainly fo...
bool isBackground(const CDCHit *ptrHit) const
Returns if this hit is considered background.
TrackingUtilities::Index getInTrackSegmentId(const CDCHit *ptrHit) const
Returns the id of the segment in the track.
TrackingUtilities::Index getNLoops(const CDCHit *ptrHit) const
Returns the number of loops the track traversed until this hit.
ITrackType getMCTrackId(const CDCHit *ptrHit) const
Returns the track id for the hit.
const Belle2::MCParticle * getMCParticle(const CDCHit *ptrHit) const
Getter for the MCParticle which is related to the CDCHit contained in the given wire hit.
const ROOT::Math::XYZVector getRecoPos3D(const CDCHit *ptrHit) const
Getter for the three dimensional position of the primary ionisation for the hit.
const Belle2::CDCSimHit * getSimHit(const CDCHit *ptrHit) const
Getter for the CDCSimHit which is related to the CDCHit contained in the given wire hit.
TrackingUtilities::Index getInTrackId(const CDCHit *ptrHit) const
Returns the position of the wire hit in the track along the travel direction.
static const CDCMCHitLookUp & getInstance()
Getter for the singletone instance.
TrackingUtilities::ERightLeft getRLInfo(const CDCHit *ptrHit) const
Returns the true right left passage information.
static const CDCSimHitLookUp & getSimHitLookUp()
Getter for the singleton instance of the CDCSimHitLookUp.
static const CDCMCHitLookUp & getMCHitLookUp()
Getter for the singleton instance of the CDCMCHitLookUp.
static const CDCMCTrackStore & getMCTrackStore()
Getter for the singleton instance of the CDCMCTrackStore.
static const CDCMCMap & getMCMap()
Getter for the singleton instance of the CDCMCMap.
void fill()
Fill Monte Carlo look up maps from the DataStore.
static CDCMCManager & getInstance()
Getter for the singleton instance.
TrackingUtilities::MayBePtr< const CDCSimHit > getSimHit(const CDCHit *hit) const
Seeks the CDCSimHit related to the CDCHit.
Definition CDCMCMap.cc:250
TrackingUtilities::MayBePtr< const MCParticle > getMCParticle(const CDCHit *hit) const
Seeks the MCParticle related to the CDCHit.
Definition CDCMCMap.cc:270
bool isReassignedSecondary(const CDCSimHit *ptrSimHit) const
Indicates if the CDCSimHit has been reassigned to a primary MCParticle.
Definition CDCMCMap.h:110
TrackingUtilities::Index getNPassedSuperLayers(const CDCHit *ptrHit) const
Getter for the number of super layers traversed until this hit.
TrackingUtilities::Index getInTrackSegmentId(const CDCHit *ptrHit) const
Getter for the index of the segment of the hit within its track.
TrackingUtilities::Index getNLoops(const CDCHit *ptrHit) const
Getter for the number of traversed loops until this hit.
TrackingUtilities::Index getInTrackId(const CDCHit *ptrHit) const
Getter for the index of the hit within its track.
ROOT::Math::XYZVector getClosestPrimaryRecoPos3D(const CDCHit *ptrHit) const
Look up the position of the primary ionisation from the closest primary simulated hit.
TrackingUtilities::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...
TrackingUtilities::ERightLeft getRLInfo(const CDCHit *ptrHit) const
Look up the Monte Carlo right left passage information for the given hit.
ROOT::Math::XYZVector getRecoPos3D(const CDCHit *ptrHit) const
Look up the position of the primary ionisation from related simulated hit.
Class representing a hit wire in the central drift chamber.
Definition CDCWireHit.h:56
double getRefDriftLength() const
Getter for the drift length at the reference position of the wire.
Definition CDCWireHit.h:225
Abstract base class for different kinds of events.