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 CDCWireHit, CDCSegment2D > CompositeProcessingSignalListener ProcessingSignalListener

Public Types

using IOTypes = std::tuple< AIOTypes... >
 Types that should be served to apply on invokation.
 
using IOVectors = std::tuple< std::vector< AIOTypes >... >
 Vector types that should be served to apply on invokation.
 

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< CDCWireHit > &inputWireHits, std::vector< 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 = typename ToVectorImpl< T >::Type
 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 = Findlet< const CDCWireHit, 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 immitating 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 = false
 Flag to keep track whether initialization happend before.
 
bool m_terminated = false
 Flag to keep track whether termination happend 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 26 of file SegmentCreatorMCTruth.h.

Member Typedef Documentation

◆ IOTypes

using IOTypes = std::tuple<AIOTypes...>
inherited

Types that should be served to apply on invokation.

Definition at line 30 of file Findlet.h.

◆ IOVectors

using IOVectors = std::tuple< std::vector<AIOTypes>... >
inherited

Vector types that should be served to apply on invokation.

Definition at line 53 of file Findlet.h.

◆ Super

using Super = Findlet<const CDCWireHit, CDCSegment2D>
private

Type of the base class.

Definition at line 30 of file SegmentCreatorMCTruth.h.

◆ ToVector

using ToVector = typename ToVectorImpl<T>::Type
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 55 of file CompositeProcessingSignalListener.cc.

56{
58}
std::vector< ProcessingSignalListener * > m_subordinaryProcessingSignalListeners
References to subordinary signal processing listener contained in this findlet.

◆ apply()

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

Main function of the segment finding by the cellular automaton.

Definition at line 67 of file SegmentCreatorMCTruth.cc.

69{
70 const CDCMCTrackStore& mcTrackStore = CDCMCTrackStore::getInstance();
71 const CDCSimHitLookUp& simHitLookUp = CDCSimHitLookUp::getInstance();
72
73 using CDCHitVector = CDCMCTrackStore::CDCHitVector;
74
75 const std::map<ITrackType, std::vector<CDCHitVector>>& mcSegmentsByMCParticleIdx =
76 mcTrackStore.getMCSegmentsByMCParticleIdx();
77
78 std::size_t nSegments = 0;
79 for (const std::pair<ITrackType, std::vector<CDCHitVector>> mcSegmentsAndMCParticleIdx : mcSegmentsByMCParticleIdx) {
80 const std::vector<CDCHitVector>& mcSegments = mcSegmentsAndMCParticleIdx.second;
81 nSegments += mcSegments.size();
82 }
83
84 outputSegments.reserve(outputSegments.size() + nSegments);
85 for (const std::pair<ITrackType, std::vector<CDCHitVector>> mcSegmentsAndMCParticleIdx : mcSegmentsByMCParticleIdx) {
86
87 const std::vector<CDCHitVector>& mcSegments = mcSegmentsAndMCParticleIdx.second;
88 for (const CDCHitVector& mcSegment : mcSegments) {
89 outputSegments.push_back(CDCSegment2D());
90 CDCSegment2D& segment2D = outputSegments.back();
91 for (const CDCHit* ptrHit : mcSegment) {
92 const CDCWireHit* wireHit = simHitLookUp.getWireHit(ptrHit, inputWireHits);
93 if (not wireHit) continue;
94
95 CDCRecoHit2D recoHit2D = simHitLookUp.getClosestPrimaryRecoHit2D(ptrHit, inputWireHits);
96 segment2D.push_back(recoHit2D);
97 }
98 if (segment2D.size() < 3) outputSegments.pop_back();
99 }
100 }
101
102 CDC::RealisticTDCCountTranslator tdcCountTranslator;
103 for (CDCSegment2D& segment : outputSegments) {
104 for (CDCRecoHit2D& recoHit2D : segment) {
105 Vector2D flightDirection = recoHit2D.getFlightDirection2D();
106 Vector2D recoPos2D = recoHit2D.getRecoPos2D();
107 double alpha = recoPos2D.angleWith(flightDirection);
108
109 const CDCWire& wire = recoHit2D.getWire();
110 const CDCHit* hit = recoHit2D.getWireHit().getHit();
111 const bool rl = recoHit2D.getRLInfo() == ERightLeft::c_Right;
112
113 double driftLength = recoHit2D.getRefDriftLength();
115 // Setup the drift length such that only information
116 // that would be present in two dimensional reconstruction is used
117 const double beta = 1;
118 double flightTimeEstimate = 0;
119 FlightTimeEstimator::instance().getFlightTime2D(recoPos2D, alpha, beta);
120
121 driftLength =
122 tdcCountTranslator.getDriftLength(hit->getTDCCount(),
123 wire.getWireID(),
124 flightTimeEstimate,
125 rl,
126 wire.getRefZ(),
127 alpha);
128 } else {
129 // In case the true drift length should be kept at least smear it with its variance.
130 double driftLengthVariance = tdcCountTranslator.getDriftLengthResolution(driftLength,
131 wire.getWireID(),
132 rl,
133 wire.getRefZ(),
134 alpha);
135
136 driftLength += gRandom->Gaus(0, std::sqrt(driftLengthVariance));
137 }
138 bool snapRecoPos = true;
139 recoHit2D.setRefDriftLength(driftLength, snapRecoPos);
140 }
141 }
142
144 for (CDCSegment2D& segment : outputSegments) {
145 if (segment.size() > 1) {
146 CDCRLWireHitSegment rlWireHitSegment = segment.getRLWireHitSegment();
147 segment = CDCSegment2D::reconstructUsingFacets(rlWireHitSegment);
148 }
149 }
150 }
151
152 for (CDCSegment2D& segment : outputSegments) {
153 segment.receiveISuperCluster();
154 }
155 std::sort(outputSegments.begin(), outputSegments.end());
156}
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition: CDCHit.h:40
Translator mirroring the realistic Digitization.
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.
Class to organize and present the monte carlo hit information.
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.
A segment consisting of two dimensional reconsturcted hits.
Class representing a two dimensional reconstructed hit in the central drift chamber.
Definition: CDCRecoHit2D.h:47
const CDCWireHit & getWireHit() const
Getter for the wire hit assoziated with the reconstructed hit.
Definition: CDCRecoHit2D.h:193
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.
Definition: CDCRecoHit2D.h:217
const CDCWire & getWire() const
Getter for the wire the reconstructed hit assoziated to.
Definition: CDCRecoHit2D.h:175
Vector2D getFlightDirection2D() const
Getter for the direction of flight.
Definition: CDCRecoHit2D.h:256
Vector2D getRecoPos2D() const
Getter for the position in the reference plane.
Definition: CDCRecoHit2D.h:238
ERightLeft getRLInfo() const
Getter for the right left passage information.
Definition: CDCRecoHit2D.h:205
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
static CDCSegment2D reconstructUsingFacets(const CDCRLWireHitSegment &rlWireHitSegment)
Reconstruct from wire hits with attached right left passage hypotheses by constructing facets between...
Singletone class to gather local information about the hits.
static const CDCSimHitLookUp & getInstance()
Getter for the singletone instance.
const CDCWireHit * getWireHit(const CDCHit *ptrHit, const std::vector< CDCWireHit > &wireHits) const
Retrieve the wire hit the given CDCHit form the given wire hits.
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 hit wire in the central drift chamber.
Definition: CDCWireHit.h:55
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
Definition: CDCWireHit.h:159
Class representing a sense wire in the central drift chamber.
Definition: CDCWire.h:58
const WireID & getWireID() const
Getter for the wire id.
Definition: CDCWire.h:122
double getRefZ() const
Getter for the wire reference z coordinate Gives the wire's reference z coordinate.
Definition: CDCWire.h:236
static const FlightTimeEstimator & instance(std::unique_ptr< FlightTimeEstimator > replacement=nullptr)
Getter for the instance.
virtual double getFlightTime2D(const Vector2D &, double, double=1) const
Default estimator for the flight time.
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 immitating the facet ca picking up al...
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:32
double angleWith(const Vector2D &rhs) const
The angle between this and rhs.
Definition: Vector2D.h:197

◆ beginEvent()

void beginEvent ( )
finalvirtual

Start processing the current event.

Reimplemented from ProcessingSignalListener.

Definition at line 61 of file SegmentCreatorMCTruth.cc.

62{
65}
void fill()
Fill Monte Carlo look up maps from the DataStore.
static CDCMCManager & getInstance()
Getter for the singletone instance.
Definition: CDCMCManager.cc:74
void beginEvent() override
Receive and dispatch signal for the start of a new event.

◆ beginRun()

void beginRun ( )
overridevirtualinherited

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

Reimplemented from ProcessingSignalListener.

Reimplemented in LayerRelationFilter< AFilter >, FourHitFilter, QualityIndicatorFilter, ThreeHitFilter, TwoHitVirtualIPFilter, TwoHitVirtualIPQIFilter, RecoTrackStorer, ROIFinder, SpacePointLoaderAndPreparer, and TrackCandidateResultRefiner.

Definition at line 23 of file CompositeProcessingSignalListener.cc.

24{
27 psl->beginRun();
28 }
29}
Interface for an algorithm part that needs to receive the module processing signals.
virtual void beginRun()
Receive signal for the beginning of a new run.

◆ endRun()

void endRun ( )
overridevirtualinherited

Receive and dispatch signal for the end of the run.

Reimplemented from ProcessingSignalListener.

Definition at line 39 of file CompositeProcessingSignalListener.cc.

40{
42 psl->endRun();
43 }
45}
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 Findlet< const CDCWireHit, CDCSegment2D >.

Definition at line 33 of file SegmentCreatorMCTruth.cc.

34{
35 moduleParamList->addParameter(prefixed(prefix, "reconstructedDriftLength"),
37 "Switch to assign the reconstructed drift length to each hit, "
38 "as it can be estimated from two dimensional information only.",
40
41 moduleParamList->addParameter(prefixed(prefix, "reconstructedPositions"),
43 "Switch to reconstruct the positions in the segments "
44 "immitating the facet ca picking up all correct hits.",
46}
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 CDCWireHit, CDCSegment2D >.

Definition at line 48 of file SegmentCreatorMCTruth.cc.

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

◆ getNProcessingSignalListener()

int getNProcessingSignalListener ( )
protectedinherited

Get the number of currently registered listeners.

Definition at line 60 of file CompositeProcessingSignalListener.cc.

61{
63}

◆ initialize()

void initialize ( )
finalvirtual

Initialize the Module before event processing.

Reimplemented from ProcessingSignalListener.

Definition at line 54 of file SegmentCreatorMCTruth.cc.

55{
58}
void requireTruthInformation()
Require the mc information store arrays.
void initialize() override
Receive and dispatch signal before the start of the event processing.

◆ terminate()

void terminate ( )
overridevirtualinherited

Receive and dispatch Signal for termination of the event processing.

Reimplemented from ProcessingSignalListener.

Reimplemented in StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::HyperHough >, StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::QuadraticLegendre >, and StereoHitTrackQuadTreeMatcher< Belle2::TrackFindingCDC::Z0TanLambdaLegendre >.

Definition at line 47 of file CompositeProcessingSignalListener.cc.

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

Member Data Documentation

◆ m_initialized

bool m_initialized = false
privateinherited

Flag to keep track whether initialization happend 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 51 of file SegmentCreatorMCTruth.h.

◆ m_param_reconstructedPositions

bool m_param_reconstructedPositions = false
private

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

Definition at line 54 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 52 of file CompositeProcessingSignalListener.h.

◆ m_terminated

bool m_terminated = false
privateinherited

Flag to keep track whether termination happend before.

Definition at line 55 of file ProcessingSignalListener.h.


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