Belle II Software development
TrackFindingCDCTestWithSimpleSimulation Class Reference

Equivalent to. More...

#include <TrackFindingCDCTestWithSimpleSimulation.h>

Inheritance diagram for TrackFindingCDCTestWithSimpleSimulation:
TrackFindingCDCTestWithTopology TestWithGearbox

Public Member Functions

void SetUp () override
 Preparations before the test.
 
void simulate (const std::initializer_list< Helix > &helices)
 Populate the event with hits generated from the given helices.
 
void simulate (const std::vector< Helix > &helices)
 Populate the event with hits generated from the given helices.
 
void simulate (const std::initializer_list< CDCTrajectory3D > &trajectories)
 Populate the event with hits generated from the given trajectories.
 
void simulate (const std::vector< CDCTrajectory3D > &trajectories)
 Populate the event with hits generated from the given trajectories.
 
void loadPreparedEvent ()
 Populate the event with hits hard codes presimulated hits.
 
void fillCaches ()
 Prepare a set of hits, axial hits, segments, axial segments and track hits.
 
void plotMCTracks ()
 Add the Monte Carlo tracks to the event plot.
 
void plotMCTrajectories ()
 Add the Monte Carlo trajectories to the event plot.
 
void saveDisplay (const std::string &svgFileName)
 Save content of the plotter to svg file only if running in unrestricted mode –gtest_also_run_disabled_tests.
 
template<class AFunction >
TimeItResult timeIt (size_t nExecutions, bool activateCallgrind, const AFunction &function, const std::function< void()> &setUp=doNothing, const std::function< void()> &tearDown=doNothing)
 Repeat a time critical simulation section a couple of times.
 
template<class... Ts>
void draw (Ts &&... args)
 Forwarding draw class to the plotter instance.
 
void TearDown () override
 Clean up after test.
 

Static Public Member Functions

static void SetUpTestCase ()
 Implementation of hook method to setup the environment for all tests in this test case Unpacks the wire topology from the CDCGeometryPar.
 
static void TearDownTestCase ()
 Implementation of hook method to clean up the environment for all tests in this test case.
 

Protected Attributes

LogConfig::ELogLevel m_savedLogLevel = LogConfig::c_Info
 Memory for the log level that was set before the test.
 
unsigned int m_savedDebugLogInfo = 100
 Memory for the log info of debug that was set before the test.
 
const std::array< std::string, 6 > m_colors {{ "red", "blue", "green", "yellow", "violet", "cyan" }}
 Some colors to cycle for plotting.
 
CDCSimpleSimulation m_simpleSimulation
 Simple simulation generating the hits.
 
std::vector< CDCTrajectory3Dm_mcTrajectories
 Memory for the Monte Carlo trajectories of the current event.
 
std::vector< CDCTrackm_mcTracks
 Memory for the Monte Carlo tracks of the current event.
 
std::vector< CDCSegment2Dm_mcSegment2Ds
 Memory for the Monte Carlo segments of the current event.
 
std::vector< const CDCSegment2D * > m_mcAxialSegment2Ds
 Memory for the axial Monte Carlo segments of the current event.
 
std::vector< const CDCWireHit * > m_axialWireHits
 Memory for the axial hits of the current event.
 
std::vector< const CDCWireHit * > m_wireHits
 Memory for the hits of the current event.
 

Private Attributes

EventDataPlotter m_plotter
 Plotter facility to generate visual representations.
 

Detailed Description

Equivalent to.

See also
TrackFindingCDCTestWithTopology for disabled tests.

Definition at line 35 of file TrackFindingCDCTestWithSimpleSimulation.h.

Constructor & Destructor Documentation

◆ TrackFindingCDCTestWithSimpleSimulation()

Member Function Documentation

◆ draw()

void draw ( Ts &&...  args)
inline

Forwarding draw class to the plotter instance.

Definition at line 203 of file TrackFindingCDCTestWithSimpleSimulation.h.

204 {
205 m_plotter.draw(std::forward<Ts>(args) ...);
206 }
void draw(const Belle2::TrackFindingCDC::Circle2D &circle, AttributeMap attributeMap=AttributeMap())
Draws a filled circle.
EventDataPlotter m_plotter
Plotter facility to generate visual representations.

◆ fillCaches()

void fillCaches ( )
inline

Prepare a set of hits, axial hits, segments, axial segments and track hits.

Definition at line 114 of file TrackFindingCDCTestWithSimpleSimulation.h.

115 {
116 for (size_t iTrack = 0; iTrack < m_mcTracks.size(); ++iTrack) {
117 B2INFO("Size mc track " << iTrack << " : " << m_mcTracks[iTrack].size());
118 }
119
120 // Prepare the monte carlo segments
121 for (const CDCTrack& mcTrack : m_mcTracks) {
122 std::vector<CDCSegment3D> segment3DsInTrack = mcTrack.splitIntoSegments();
123 for (const CDCSegment3D& segment3D : segment3DsInTrack) {
124 m_mcSegment2Ds.push_back(segment3D.stereoProjectToRef());
125 }
126 }
127
128 // Filter the axial segments
129 for (const CDCSegment2D& segment2D : m_mcSegment2Ds) {
130 if (segment2D.getStereoKind() == EStereoKind::c_Axial) {
131 m_mcAxialSegment2Ds.push_back(&segment2D);
132 }
133 }
134
135 // Filter for axial hits
136 for (const CDCWireHit& wireHit : m_simpleSimulation.getWireHits()) {
137 if (wireHit.isAxial()) {
138 m_axialWireHits.push_back(&wireHit);
139 }
140 }
141
142 // Pick up points for all hits
143 for (const CDCWireHit& wireHit : m_simpleSimulation.getWireHits()) {
144 m_wireHits.push_back(&wireHit);
145 }
146
148 for (const CDCWireHit& wireHit : m_simpleSimulation.getWireHits()) {
149 m_plotter.draw(wireHit);
150 }
151 }
ConstVectorRange< CDCWireHit > getWireHits() const
Getter for the wire hits created in the simulation.
static CDCWireTopology & getInstance()
Getter for the singleton instance of the wire topology.
std::vector< CDCTrack > m_mcTracks
Memory for the Monte Carlo tracks of the current event.
std::vector< const CDCSegment2D * > m_mcAxialSegment2Ds
Memory for the axial Monte Carlo segments of the current event.
std::vector< CDCSegment2D > m_mcSegment2Ds
Memory for the Monte Carlo segments of the current event.
std::vector< const CDCWireHit * > m_wireHits
Memory for the hits of the current event.
std::vector< const CDCWireHit * > m_axialWireHits
Memory for the axial hits of the current event.

◆ loadPreparedEvent()

void loadPreparedEvent ( )
inline

Populate the event with hits hard codes presimulated hits.

Definition at line 102 of file TrackFindingCDCTestWithSimpleSimulation.h.

103 {
104 // No trajectory information present
105 m_mcTrajectories.clear();
106
107 // Load prepared tracks wire hits are stored in the simple simulation
109
110 fillCaches();
111 }
std::vector< CDCTrack > loadPreparedEvent()
Fills the wire hits with a hard coded event from the real simulation.
void fillCaches()
Prepare a set of hits, axial hits, segments, axial segments and track hits.
std::vector< CDCTrajectory3D > m_mcTrajectories
Memory for the Monte Carlo trajectories of the current event.

◆ plotMCTracks()

void plotMCTracks ( )
inline

Add the Monte Carlo tracks to the event plot.

Definition at line 154 of file TrackFindingCDCTestWithSimpleSimulation.h.

155 { for (const CDCTrack& mcTrack : m_mcTracks) m_plotter.draw(mcTrack); }

◆ plotMCTrajectories()

void plotMCTrajectories ( )
inline

Add the Monte Carlo trajectories to the event plot.

Definition at line 158 of file TrackFindingCDCTestWithSimpleSimulation.h.

159 {
160 for (const CDCTrajectory3D& mcTrajectory : m_mcTrajectories) {
161 m_plotter.draw(mcTrajectory.getTrajectory2D());
162 }
163 }

◆ saveDisplay()

void saveDisplay ( const std::string &  svgFileName)
inline

Save content of the plotter to svg file only if running in unrestricted mode –gtest_also_run_disabled_tests.

Definition at line 166 of file TrackFindingCDCTestWithSimpleSimulation.h.

167 {
168 bool run_disabled = ::testing::GTEST_FLAG(also_run_disabled_tests);
169 if (run_disabled) {
170 m_plotter.save(svgFileName);
171 } else {
172 B2INFO("Not writing display file. To activate svg display output run with --gtest_also_run_disabled_tests");
173 }
174 }
const std::string save(const std::string &fileName)
Saves the current plot stead to a file.

◆ SetUp()

void SetUp ( )
inlineoverride

Preparations before the test.

Definition at line 45 of file TrackFindingCDCTestWithSimpleSimulation.h.

46 {
47
50 bool run_disabled = ::testing::GTEST_FLAG(also_run_disabled_tests);
51 if (run_disabled) {
54 }
55
57 m_mcAxialSegment2Ds.clear();
58 m_mcSegment2Ds.clear();
59 m_mcTracks.clear();
60 m_mcTrajectories.clear();
61 m_axialWireHits.clear();
62 m_wireHits.clear();
63 }
ELogLevel getLogLevel() const
Returns the configured log level.
Definition: LogConfig.h:91
@ c_Debug
Debug: for code development.
Definition: LogConfig.h:26
unsigned int getLogInfo(ELogLevel logLevel) const
Returns the configured log information for the given level.
Definition: LogConfig.h:134
@ c_Level
Log level of the message.
Definition: LogConfig.h:36
@ c_Message
Log message text.
Definition: LogConfig.h:37
void setLogLevel(ELogLevel logLevel)
Configure the log level.
Definition: LogConfig.cc:25
void setLogInfo(ELogLevel logLevel, unsigned int logInfo)
Configure the printed log information for the given level.
Definition: LogConfig.h:127
LogConfig * getLogConfig()
Returns global log system configuration.
Definition: LogSystem.h:78
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
Definition: LogSystem.cc:31
void clear()
Clears all drawed elements from the plotter.
LogConfig::ELogLevel m_savedLogLevel
Memory for the log level that was set before the test.
unsigned int m_savedDebugLogInfo
Memory for the log info of debug that was set before the test.

◆ SetUpTestCase()

void SetUpTestCase ( )
staticinherited

Implementation of hook method to setup the environment for all tests in this test case Unpacks the wire topology from the CDCGeometryPar.

Manually open the database and prepare the cdc geometry parameters.

Definition at line 19 of file TrackFindingCDCTestWithTopology.cc.

20{
23
24 // Prepare the wires for the cdc track finders.
26}
static void loadDatabase()
Helper function to open the database - only for tests offside the standard event processing.

◆ simulate() [1/4]

void simulate ( const std::initializer_list< CDCTrajectory3D > &  trajectories)
inline

Populate the event with hits generated from the given trajectories.

Definition at line 85 of file TrackFindingCDCTestWithSimpleSimulation.h.

86 {
87 simulate(std::vector<CDCTrajectory3D>(trajectories));
88 }
void simulate(const std::initializer_list< Helix > &helices)
Populate the event with hits generated from the given helices.

◆ simulate() [2/4]

void simulate ( const std::initializer_list< Helix > &  helices)
inline

Populate the event with hits generated from the given helices.

Definition at line 66 of file TrackFindingCDCTestWithSimpleSimulation.h.

67 {
68 simulate(std::vector<Helix>(helices));
69 }

◆ simulate() [3/4]

void simulate ( const std::vector< CDCTrajectory3D > &  trajectories)
inline

Populate the event with hits generated from the given trajectories.

Definition at line 91 of file TrackFindingCDCTestWithSimpleSimulation.h.

92 {
93 m_mcTrajectories = trajectories;
94
95 // Construct tracks. Wire hits are stored in the simple simulation
97
98 fillCaches();
99 }
std::vector< CDCTrack > simulate(const std::vector< CDCTrajectory3D > &trajectories3D)
Propagates the trajectories through the CDC as without energy loss until they first leave the CDC.

◆ simulate() [4/4]

void simulate ( const std::vector< Helix > &  helices)
inline

Populate the event with hits generated from the given helices.

Definition at line 73 of file TrackFindingCDCTestWithSimpleSimulation.h.

74 {
75 std::vector<CDCTrajectory3D> trajectories;
76 trajectories.reserve(helices.size());
77 for (const Helix& helix : helices) {
78 // had to make the implicit convesion to an explicit conversion. Maybe there is a more elegant way to do it
79 trajectories.emplace_back(UncertainHelix(helix));
80 }
81 simulate(trajectories);
82 }

◆ TearDown()

void TearDown ( )
inlineoverride

◆ TearDownTestCase()

void TearDownTestCase ( )
staticinherited

Implementation of hook method to clean up the environment for all tests in this test case.

Definition at line 28 of file TrackFindingCDCTestWithTopology.cc.

29{
31}
static void closeDatabase()
Helper function to close and reset the database - only for tests offside the standard event processin...

◆ timeIt()

TimeItResult timeIt ( size_t  nExecutions,
bool  activateCallgrind,
const AFunction &  function,
const std::function< void()> &  setUp = doNothing,
const std::function< void()> &  tearDown = doNothing 
)
inline

Repeat a time critical simulation section a couple of times.

The repeated execution is only done if the test is run in unrestricted mode. The default is to run it once.

Definition at line 183 of file TrackFindingCDCTestWithSimpleSimulation.h.

188 {
189 bool run_disabled = ::testing::GTEST_FLAG(also_run_disabled_tests);
190 if (not run_disabled) {
191 nExecutions = 1;
192 }
193 return Belle2::TrackFindingCDC::timeIt(nExecutions,
194 activateCallgrind,
195 function,
196 setUp,
197 tearDown);
198
199 }

Member Data Documentation

◆ m_axialWireHits

std::vector<const CDCWireHit*> m_axialWireHits
protected

Memory for the axial hits of the current event.

Definition at line 249 of file TrackFindingCDCTestWithSimpleSimulation.h.

◆ m_colors

const std::array<std::string, 6> m_colors {{ "red", "blue", "green", "yellow", "violet", "cyan" }}
protected

Some colors to cycle for plotting.

Definition at line 231 of file TrackFindingCDCTestWithSimpleSimulation.h.

◆ m_mcAxialSegment2Ds

std::vector<const CDCSegment2D*> m_mcAxialSegment2Ds
protected

Memory for the axial Monte Carlo segments of the current event.

Definition at line 246 of file TrackFindingCDCTestWithSimpleSimulation.h.

◆ m_mcSegment2Ds

std::vector<CDCSegment2D> m_mcSegment2Ds
protected

Memory for the Monte Carlo segments of the current event.

Definition at line 243 of file TrackFindingCDCTestWithSimpleSimulation.h.

◆ m_mcTracks

std::vector<CDCTrack> m_mcTracks
protected

Memory for the Monte Carlo tracks of the current event.

Definition at line 240 of file TrackFindingCDCTestWithSimpleSimulation.h.

◆ m_mcTrajectories

std::vector<CDCTrajectory3D> m_mcTrajectories
protected

Memory for the Monte Carlo trajectories of the current event.

Definition at line 237 of file TrackFindingCDCTestWithSimpleSimulation.h.

◆ m_plotter

EventDataPlotter m_plotter
private

Plotter facility to generate visual representations.

Definition at line 256 of file TrackFindingCDCTestWithSimpleSimulation.h.

◆ m_savedDebugLogInfo

unsigned int m_savedDebugLogInfo = 100
protected

Memory for the log info of debug that was set before the test.

Definition at line 228 of file TrackFindingCDCTestWithSimpleSimulation.h.

◆ m_savedLogLevel

LogConfig::ELogLevel m_savedLogLevel = LogConfig::c_Info
protected

Memory for the log level that was set before the test.

Definition at line 225 of file TrackFindingCDCTestWithSimpleSimulation.h.

◆ m_simpleSimulation

CDCSimpleSimulation m_simpleSimulation
protected

Simple simulation generating the hits.

Definition at line 234 of file TrackFindingCDCTestWithSimpleSimulation.h.

◆ m_wireHits

std::vector<const CDCWireHit*> m_wireHits
protected

Memory for the hits of the current event.

Definition at line 252 of file TrackFindingCDCTestWithSimpleSimulation.h.


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