Belle II Software  release-05-01-25
CDCSimpleSimulation.test.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <tracking/trackFindingCDC/testFixtures/TrackFindingCDCTestWithSimpleSimulation.h>
11 
12 #include <tracking/trackFindingCDC/sim/CDCSimpleSimulation.h>
13 #include <tracking/trackFindingCDC/display/EventDataPlotter.h>
14 
15 using namespace Belle2;
16 using namespace TrackFindingCDC;
17 
18 TEST_F(TrackFindingCDCTestWithSimpleSimulation, sim_CDCSimpleSimulation_straight)
19 {
20  Helix straightOriginLine(0, 0, 0, 0, 0);
21  simulate({straightOriginLine});
22  saveDisplay("straight.svg");
23 }
24 
25 
26 TEST_F(TrackFindingCDCTestWithSimpleSimulation, sim_CDCSimpleSimulation_high)
27 {
28  Helix lowCurvOriginHelix(0.015, 0, 0, 1, 0);
29  simulate({lowCurvOriginHelix});
30 
31  for (const CDCRecoHit3D& recoHit3D : m_mcTracks[0]) {
32  EventDataPlotter::AttributeMap rl {{"stroke", recoHit3D.getRLInfo() == ERightLeft::c_Right ? "green" : "red"}};
33  draw(recoHit3D, rl);
34  }
35 
36  saveDisplay("low.svg");
37 }
38 
39 
40 TEST_F(TrackFindingCDCTestWithSimpleSimulation, sim_CDCSimpleSimulation_cosmic)
41 {
42  Helix straightOffOriginLine(0, 1, 20, 1, 75);
43  double outerWallR = CDCWireTopology::getInstance().getOuterCylindricalR();
44  double arcLengthToOuterWall =
45  straightOffOriginLine.arcLength2DToCylindricalR(outerWallR);
46 
47  Vector3D startPoint = straightOffOriginLine.atArcLength2D(-arcLengthToOuterWall);
48  CDCTrajectory3D cosmicTrajectory(straightOffOriginLine);
49  cosmicTrajectory.setLocalOrigin(startPoint);
50 
51  simulate({cosmicTrajectory});
52  saveDisplay("cosmic.svg");
53 }
54 
55 
56 TEST_F(TrackFindingCDCTestWithSimpleSimulation, sim_CDCSimpleSimulation_curl)
57 {
58  Helix highCurvOriginHelix(0.02, 1, 0, 0.5, 0);
59  simulate({highCurvOriginHelix});
60  saveDisplay("curl.svg");
61 }
62 
63 TEST_F(TrackFindingCDCTestWithSimpleSimulation, sim_CDCSimpleSimulation_secondary_curl)
64 {
65  Helix highCurvOffOriginHelix(0.02, 1, -30, 0.2, 0);
66  simulate({highCurvOffOriginHelix});
67  saveDisplay("secondary_curl.svg");
68 }
69 
70 
71 TEST_F(TrackFindingCDCTestWithSimpleSimulation, sim_CDCSimpleSimulation_photon_conversion)
72 {
73  // Should probably be placed at a vxd ladder
74  Vector3D vertex(1.0, 0.0, 0.0);
75  Vector3D momentum(1.0, 0.0, 0.0);
76  double time = 0.0;
77 
78  CDCTrajectory3D electronTrajectory(vertex, time, momentum, -1, 1.5);
79  CDCTrajectory3D positronTrajectory(vertex, time, momentum, 1, 1.5);
80 
81  simulate({electronTrajectory, positronTrajectory});
82  saveDisplay("photon_conversion.svg");
83 }
84 
85 TEST_F(TrackFindingCDCTestWithSimpleSimulation, sim_CDCSimpleSimulation_cosmic_with_delay)
86 {
87  m_simpleSimulation.activateTOFDelay();
88  m_simpleSimulation.activateInWireSignalDelay();
89 
90  Helix straightOffOriginLine(0, 1, 20, 1, 50);
91  double outerWallR = CDCWireTopology::getInstance().getOuterCylindricalR();
92  double arcLengthToOuterWall =
93  straightOffOriginLine.arcLength2DToCylindricalR(outerWallR);
94 
95  Vector3D startPoint = straightOffOriginLine.atArcLength2D(-arcLengthToOuterWall);
96  CDCTrajectory3D cosmicTrajectory(straightOffOriginLine);
97  cosmicTrajectory.setLocalOrigin(startPoint);
98 
99 
100  CDCTrack mcTrack = m_simpleSimulation.simulate(cosmicTrajectory);
102  draw(mcTrack);
103  saveDisplay("cosmic_with_delay.svg");
104 }
105 
106 
107 TEST_F(TrackFindingCDCTestWithSimpleSimulation, sim_prepared_event_rl_flags)
108 {
109  std::string svgFileName = "rl_flags_prepared_event.svg";
110  loadPreparedEvent();
111 
112  for (CDCTrack& track : m_mcTracks) {
113  for (const CDCRecoHit3D& recoHit3D : track) {
114  const CDCRLWireHit& rlWireHit = recoHit3D.getRLWireHit();
115  std::string color = "blue";
116  if (rlWireHit.getRLInfo() == ERightLeft::c_Right) {
117  color = "green";
118  } else if (rlWireHit.getRLInfo() == ERightLeft::c_Left) {
119  color = "red";
120  }
121  EventDataPlotter::AttributeMap strokeAttr {{"stroke", color}};
122  draw(rlWireHit.getWireHit(), strokeAttr);
123  }
124  }
125  saveDisplay(svgFileName);
126 }
Belle2::Vector3D
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition: Cell.h:35
Belle2::TrackFindingCDC::CDCWireTopology::getInstance
static CDCWireTopology & getInstance()
Getter for the singleton instance of the wire topology.
Definition: CDCWireTopology.cc:22
Belle2::TrackFindingCDC::EventDataPlotter::AttributeMap
PrimitivePlotter::AttributeMap AttributeMap
Forward the Attributre map from the primitive plotter.
Definition: EventDataPlotter.h:69
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TEST_F
TEST_F(GlobalLabelTest, LargeNumberOfTimeDependentParameters)
Test large number of time-dep params for registration and retrieval.
Definition: globalLabel.cc:65
Belle2::CDC::Helix
Helix parameter class.
Definition: Helix.h:51
Belle2::TrackFindingCDC::CDCWireTopology::getOuterCylindricalR
double getOuterCylindricalR() const
Getter for the outer radius of the outer most wire layer.
Definition: CDCWireTopology.h:481