Belle II Software development
SegmentCreatorMCTruth Class Referenceabstract

Findlet that generates segments from wire hits using the mc truth information. More...

#include <SegmentCreatorMCTruth.h>

Inheritance diagram for SegmentCreatorMCTruth:
Findlet< const TrackingUtilities::CDCWireHit, TrackingUtilities::CDCSegment2D > CompositeProcessingSignalListener ProcessingSignalListener

Public Types

using IOTypes
 Types that should be served to apply on invocation.
 
using IOTypes
 Types that should be served to apply on invocation.
 
using IOVectors
 Vector types that should be served to apply on invocation.
 
using IOVectors
 Vector types that should be served to apply on invocation.
 

Public Member Functions

void exposeParameters (ModuleParamList *moduleParamList, const std::string &prefix) final
 Expose the parameters to a module.
 
std::string getDescription () final
 Short description of the findlet.
 
void initialize () final
 Initialize the Module before event processing.
 
void beginEvent () final
 Start processing the current event.
 
void apply (const std::vector< TrackingUtilities::CDCWireHit > &inputWireHits, std::vector< TrackingUtilities::CDCSegment2D > &outputSegments) final
 Main function of the segment finding by the cellular automaton.
 
virtual void apply (ToVector< AIOTypes > &... ioVectors)=0
 Main function executing the algorithm.
 
void beginRun () override
 Receive and dispatch signal for the beginning of a new run.
 
void endRun () override
 Receive and dispatch signal for the end of the run.
 
void terminate () override
 Receive and dispatch Signal for termination of the event processing.
 

Protected Types

using ToVector
 Short hand for ToRangeImpl.
 
using ToVector
 Short hand for ToRangeImpl.
 

Protected Member Functions

void addProcessingSignalListener (ProcessingSignalListener *psl)
 Register a processing signal listener to be notified.
 
int getNProcessingSignalListener ()
 Get the number of currently registered listeners.
 

Private Types

using Super = TrackingUtilities::Findlet<const TrackingUtilities::CDCWireHit, TrackingUtilities::CDCSegment2D>
 Type of the base class.
 

Private Attributes

bool m_param_reconstructedDriftLength = false
 Parameter : Setup the drift length as it can be estimated from two dimensional information.
 
bool m_param_reconstructedPositions = false
 Parameter : Switch to reconstruct the positions in the segments imitating the facet ca picking up all correct hits.
 
std::vector< ProcessingSignalListener * > m_subordinaryProcessingSignalListeners
 References to subordinary signal processing listener contained in this findlet.
 
bool m_initialized
 Flag to keep track whether initialization happened before.
 
bool m_terminated
 Flag to keep track whether termination happened before.
 
std::string m_initializedAs
 Name of the type during initialisation.
 

Detailed Description

Findlet that generates segments from wire hits using the mc truth information.

Definition at line 29 of file SegmentCreatorMCTruth.h.

Member Typedef Documentation

◆ IOTypes [1/2]

using IOTypes
inherited

Types that should be served to apply on invocation.

Definition at line 30 of file Findlet.h.

◆ IOTypes [2/2]

using IOTypes
inherited

Types that should be served to apply on invocation.

Definition at line 30 of file Findlet.h.

◆ IOVectors [1/2]

using IOVectors
inherited

Vector types that should be served to apply on invocation.

Definition at line 53 of file Findlet.h.

◆ IOVectors [2/2]

using IOVectors
inherited

Vector types that should be served to apply on invocation.

Definition at line 53 of file Findlet.h.

◆ Super

Type of the base class.

Definition at line 34 of file SegmentCreatorMCTruth.h.

◆ ToVector [1/2]

using ToVector
protectedinherited

Short hand for ToRangeImpl.

Definition at line 49 of file Findlet.h.

◆ ToVector [2/2]

using ToVector
protectedinherited

Short hand for ToRangeImpl.

Definition at line 49 of file Findlet.h.

Member Function Documentation

◆ addProcessingSignalListener()

void addProcessingSignalListener ( ProcessingSignalListener * psl)
protectedinherited

Register a processing signal listener to be notified.

Definition at line 53 of file CompositeProcessingSignalListener.cc.

56{
58}
Interface for a minimal algorithm part that wants to expose some parameters to a module.
Definition Findlet.h:26

◆ apply()

void apply ( const std::vector< TrackingUtilities::CDCWireHit > & inputWireHits,
std::vector< TrackingUtilities::CDCSegment2D > & outputSegments )
final

Main function of the segment finding by the cellular automaton.

Definition at line 69 of file SegmentCreatorMCTruth.cc.

71{
72 const CDCMCTrackStore& mcTrackStore = CDCMCTrackStore::getInstance();
73 const CDCSimHitLookUp& simHitLookUp = CDCSimHitLookUp::getInstance();
74
75 using CDCHitVector = CDCMCTrackStore::CDCHitVector;
76
77 const std::map<ITrackType, std::vector<CDCHitVector>>& mcSegmentsByMCParticleIdx =
78 mcTrackStore.getMCSegmentsByMCParticleIdx();
79
80 std::size_t nSegments = 0;
81 for (const std::pair<ITrackType, std::vector<CDCHitVector>> mcSegmentsAndMCParticleIdx : mcSegmentsByMCParticleIdx) {
82 const std::vector<CDCHitVector>& mcSegments = mcSegmentsAndMCParticleIdx.second;
83 nSegments += mcSegments.size();
84 }
85
86 outputSegments.reserve(outputSegments.size() + nSegments);
87 for (const std::pair<ITrackType, std::vector<CDCHitVector>> mcSegmentsAndMCParticleIdx : mcSegmentsByMCParticleIdx) {
88
89 const std::vector<CDCHitVector>& mcSegments = mcSegmentsAndMCParticleIdx.second;
90 for (const CDCHitVector& mcSegment : mcSegments) {
91 outputSegments.push_back(CDCSegment2D());
92 CDCSegment2D& segment2D = outputSegments.back();
93 for (const CDCHit* ptrHit : mcSegment) {
94 const CDCWireHit* wireHit = simHitLookUp.getWireHit(ptrHit, inputWireHits);
95 if (not wireHit) continue;
96
97 CDCRecoHit2D recoHit2D = simHitLookUp.getClosestPrimaryRecoHit2D(ptrHit, inputWireHits);
98 segment2D.push_back(recoHit2D);
99 }
100 if (segment2D.size() < 3) outputSegments.pop_back();
101 }
102 }
103
104 CDC::RealisticTDCCountTranslator tdcCountTranslator;
105 for (CDCSegment2D& segment : outputSegments) {
106 for (CDCRecoHit2D& recoHit2D : segment) {
107 Vector2D flightDirection = recoHit2D.getFlightDirection2D();
108 Vector2D recoPos2D = recoHit2D.getRecoPos2D();
109 double alpha = recoPos2D.angleWith(flightDirection);
110
111 const CDCWire& wire = recoHit2D.getWire();
112 const CDCHit* hit = recoHit2D.getWireHit().getHit();
113 const bool rl = recoHit2D.getRLInfo() == ERightLeft::c_Right;
114
115 double driftLength = recoHit2D.getRefDriftLength();
117 // Setup the drift length such that only information
118 // that would be present in two dimensional reconstruction is used
119 const double beta = 1;
120 double flightTimeEstimate = 0;
121 FlightTimeEstimator::instance().getFlightTime2D(recoPos2D, alpha, beta);
122
123 driftLength =
124 tdcCountTranslator.getDriftLength(hit->getTDCCount(),
125 wire.getWireID(),
126 flightTimeEstimate,
127 rl,
128 wire.getRefZ(),
129 alpha);
130 } else {
131 // In case the true drift length should be kept at least smear it with its variance.
132 double driftLengthVariance = tdcCountTranslator.getDriftLengthResolution(driftLength,
133 wire.getWireID(),
134 rl,
135 wire.getRefZ(),
136 alpha);
137
138 driftLength += gRandom->Gaus(0, std::sqrt(driftLengthVariance));
139 }
140 bool snapRecoPos = true;
141 recoHit2D.setRefDriftLength(driftLength, snapRecoPos);
142 }
143 }
144
146 for (CDCSegment2D& segment : outputSegments) {
147 if (segment.size() > 1) {
148 CDCRLWireHitSegment rlWireHitSegment = segment.getRLWireHitSegment();
149 segment = CDCSegment2D::reconstructUsingFacets(rlWireHitSegment);
150 }
151 }
152 }
153
154 for (CDCSegment2D& segment : outputSegments) {
155 segment.receiveISuperCluster();
156 }
157 std::sort(outputSegments.begin(), outputSegments.end());
158}
short getTDCCount() const
Getter for TDC count.
Definition CDCHit.h:219
const WireID & getWireID() const
Getter for the wire id.
Definition CDCWire.h:114
double getRefZ() const
Getter for the wire reference z coordinate Gives the wire's reference z coordinate.
Definition CDCWire.h:228
double getDriftLength(unsigned short tdcCount, const WireID &wireID=WireID(), double timeOfFlightEstimator=0, bool leftRight=false, double z=0, double alpha=0, double theta=static_cast< double >(TMath::Pi()/2.), unsigned short adcCount=0) override
Get Drift length.
double getDriftLengthResolution(double driftLength, const WireID &wireID=WireID(), bool leftRight=false, double z=0, double alpha=0, double=static_cast< double >(TMath::Pi()/2.)) override
Get position resolution^2 corresponding to the drift length from getDriftLength of this class.
static const CDCMCTrackStore & getInstance()
Getter for the singletone instance.
std::vector< const CDCHit * > CDCHitVector
Type for an ordered sequence of pointers to the CDCHit.
const std::map< ITrackType, std::vector< Belle2::TrackFindingCDC::CDCMCTrackStore::CDCHitVector > > & getMCSegmentsByMCParticleIdx() const
Getter for the stored Monte Carlo segments ordered by their Monte Carlo Id.
static const CDCSimHitLookUp & getInstance()
Getter for the singletone instance.
TrackingUtilities::CDCRecoHit2D getClosestPrimaryRecoHit2D(const CDCHit *ptrHit, const std::vector< TrackingUtilities::CDCWireHit > &wireHits) const
Construct an TrackingUtilities::CDCRecoHit2D from the closest primary CDCSimHit information related t...
const TrackingUtilities::CDCWireHit * getWireHit(const CDCHit *ptrHit, const std::vector< TrackingUtilities::CDCWireHit > &wireHits) const
Retrieve the wire hit the given CDCHit form the given wire hits.
virtual double getFlightTime2D(const TrackingUtilities::Vector2D &, double, double=1) const
Default estimator for the flight time.
static const FlightTimeEstimator & instance(std::unique_ptr< FlightTimeEstimator > replacement=nullptr)
Getter for the instance.
bool m_param_reconstructedDriftLength
Parameter : Setup the drift length as it can be estimated from two dimensional information.
bool m_param_reconstructedPositions
Parameter : Switch to reconstruct the positions in the segments imitating the facet ca picking up all...
const CDCWireHit & getWireHit() const
Getter for the wire hit associated with the reconstructed hit.
void setRefDriftLength(double driftLength, bool snapRecoPos)
Setter for the drift length at the wire reference position.
double getRefDriftLength() const
Getter for the drift length at the wire reference position.
const CDC::CDCWire & getWire() const
Getter for the wire the reconstructed hit associated to.
Vector2D getFlightDirection2D() const
Getter for the direction of flight.
Vector2D getRecoPos2D() const
Getter for the position in the reference plane.
ERightLeft getRLInfo() const
Getter for the right left passage information.
static CDCSegment2D reconstructUsingFacets(const CDCRLWireHitSegment &rlWireHitSegment)
Reconstruct from wire hits with attached right left passage hypotheses by constructing facets between...
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
Definition CDCWireHit.h:162
double angleWith(const Vector2D &rhs) const
The angle between this and rhs.
Definition Vector2D.h:228

◆ beginEvent()

void beginEvent ( )
finalvirtual

Start processing the current event.

Reimplemented from CompositeProcessingSignalListener.

Definition at line 63 of file SegmentCreatorMCTruth.cc.

◆ beginRun()

void beginRun ( )
overrideinherited

Receive and dispatch signal for the beginning of a new run.

Definition at line 33 of file CompositeProcessingSignalListener.cc.

24{
27 psl->beginRun();
28 }
29}
void beginRun() override
Receive and dispatch signal for the beginning of a new run.
virtual void beginRun()
Receive signal for the beginning of a new run.

◆ endRun()

void endRun ( )
overrideinherited

Receive and dispatch signal for the end of the run.

Definition at line 39 of file CompositeProcessingSignalListener.cc.

40{
42 psl->endRun();
43 }
45}
void endRun() override
Receive and dispatch signal for the end of the run.
virtual void endRun()
Receive signal for the end of the run.

◆ exposeParameters()

void exposeParameters ( ModuleParamList * moduleParamList,
const std::string & prefix )
finalvirtual

Expose the parameters to a module.

Reimplemented from CompositeProcessingSignalListener.

Definition at line 35 of file SegmentCreatorMCTruth.cc.

36{
37 moduleParamList->addParameter(prefixed(prefix, "reconstructedDriftLength"),
39 "Switch to assign the reconstructed drift length to each hit, "
40 "as it can be estimated from two dimensional information only.",
42
43 moduleParamList->addParameter(prefixed(prefix, "reconstructedPositions"),
45 "Switch to reconstruct the positions in the segments "
46 "imitating the facet ca picking up all correct hits.",
48}
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.

◆ getDescription()

std::string getDescription ( )
finalvirtual

Short description of the findlet.

Reimplemented from Findlet< const TrackingUtilities::CDCWireHit, TrackingUtilities::CDCSegment2D >.

Definition at line 50 of file SegmentCreatorMCTruth.cc.

51{
52 return "Constructs segments from wire hits using the mc truth information.";
53}

◆ getNProcessingSignalListener()

int getNProcessingSignalListener ( )
protectedinherited

Get the number of currently registered listeners.

Definition at line 56 of file CompositeProcessingSignalListener.cc.

61{
63}

◆ initialize()

void initialize ( )
finalvirtual

◆ terminate()

void terminate ( )
overrideinherited

Receive and dispatch Signal for termination of the event processing.

Definition at line 42 of file CompositeProcessingSignalListener.cc.

48{
50 psl->terminate();
51 }
53}
void terminate() override
Receive and dispatch Signal for termination of the event processing.
virtual void terminate()
Receive Signal for termination of the event processing.

Member Data Documentation

◆ m_initialized

bool m_initialized
privateinherited

Flag to keep track whether initialization happened before.

Definition at line 52 of file ProcessingSignalListener.h.

◆ m_initializedAs

std::string m_initializedAs
privateinherited

Name of the type during initialisation.

Definition at line 58 of file ProcessingSignalListener.h.

◆ m_param_reconstructedDriftLength

bool m_param_reconstructedDriftLength = false
private

Parameter : Setup the drift length as it can be estimated from two dimensional information.

Definition at line 55 of file SegmentCreatorMCTruth.h.

◆ m_param_reconstructedPositions

bool m_param_reconstructedPositions = false
private

Parameter : Switch to reconstruct the positions in the segments imitating the facet ca picking up all correct hits.

Definition at line 58 of file SegmentCreatorMCTruth.h.

◆ m_subordinaryProcessingSignalListeners

std::vector<ProcessingSignalListener*> m_subordinaryProcessingSignalListeners
privateinherited

References to subordinary signal processing listener contained in this findlet.

Definition at line 60 of file CompositeProcessingSignalListener.h.

◆ m_terminated

bool m_terminated
privateinherited

Flag to keep track whether termination happened before.

Definition at line 55 of file ProcessingSignalListener.h.


The documentation for this class was generated from the following files: