Belle II Software  release-05-02-19
CDCSimpleSimulation.h
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 #pragma once
11 
12 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
13 
14 #include <tracking/trackFindingCDC/utilities/VectorRange.h>
15 
16 #include <tracking/trackFindingCDC/geometry/Vector3D.h>
17 #include <vector>
18 #include <memory>
19 
20 namespace Belle2 {
25  namespace TrackFindingCDC {
26 
28  class CDCTrack;
29  class CDCTrajectory3D;
30  class Helix;
31 
46  class CDCSimpleSimulation {
47 
48  private:
49 
51  struct SimpleSimHit {
52 
57  SimpleSimHit(const CDCWireHit& wireHit,
58  size_t iMCTrack,
59  ERightLeft rlInfo) :
60  m_wireHit(wireHit),
61  m_iMCTrack(iMCTrack),
62  m_rlInfo(rlInfo)
63  {}
64 
69  SimpleSimHit(const CDCWireHit& wireHit,
70  size_t iMCTrack,
71  ERightLeft rlInfo,
72  const Vector3D& pos3D,
73  double arcLength2D = NAN,
74  double trueDriftLength = NAN) :
75  m_wireHit(wireHit),
76  m_iMCTrack(iMCTrack),
77  m_rlInfo(rlInfo),
78  m_pos3D(pos3D),
79  m_arcLength2D(arcLength2D),
80  m_trueDriftLength(trueDriftLength)
81  {}
82 
85 
87  size_t m_iMCTrack;
88 
91 
94 
96  double m_arcLength2D = NAN;
97 
99  double m_trueDriftLength = NAN;
100  };
101 
102  public:
105 
106  public:
113  std::vector<CDCTrack> simulate(const std::vector<CDCTrajectory3D>& trajectories3D);
114 
116  CDCTrack simulate(const CDCTrajectory3D& trajectory3D);
117 
119  std::vector<CDCTrack> loadPreparedEvent();
120 
121  private:
123  std::vector<CDCTrack> constructMCTracks(int nMCTracks, std::vector<SimpleSimHit> simpleSimHits);
124 
126  std::vector<SimpleSimHit> createHits(const Helix& globalHelix, double arcLength2DOffset) const;
127 
129  std::vector<SimpleSimHit> createHitsForLayer(const CDCWire& nearWire,
130  const Helix& globalHelix,
131  double arcLength2DOffset) const;
132 
135  const Helix& globalHelix,
136  double arcLength2DOffset) const;
137 
138  public:
140  double getEventTime() const
141  { return m_eventTime; }
142 
144  void setEventTime(double eventTime)
145  { m_eventTime = eventTime; }
146 
148  void activateTOFDelay(bool activate = true)
149  { m_addTOFDelay = activate; }
150 
152  void activateInWireSignalDelay(bool activate = true)
153  { m_addInWireSignalDelay = activate; }
154 
156  int getMaxNHitOnWire() const
157  { return m_maxNHitOnWire; }
158 
160  void setMaxNHitOnWire(int maxNHitOnWire)
161  { m_maxNHitOnWire = maxNHitOnWire; }
162 
163  private:
165  std::shared_ptr<const std::vector<CDCWireHit> > m_sharedWireHits;
166 
168  const double s_nominalDriftLengthVariance = 0.000169;
169 
171  const double s_nominalPropSpeed = 27.25;
172 
174  const double s_nominalDriftSpeed = 4e-3;
175 
177  int m_maxNHitOnWire = 0;
178 
180  double m_eventTime = 0;
181 
183  bool m_addTOFDelay = false;
184 
186  bool m_addInWireSignalDelay = false;
187 
188  // TODO: make them freely setable ?
191 
193  double m_driftLengthSigma = std::sqrt(m_driftLengthVariance);
194 
197 
200  };
201 
202  }
204 }
Belle2::TrackFindingCDC::CDCSimpleSimulation::createHitForCell
SimpleSimHit createHitForCell(const CDCWire &wire, const Helix &globalHelix, double arcLength2DOffset) const
Generate a hit for the given wire.
Definition: CDCSimpleSimulation.cc:316
Belle2::TrackFindingCDC::CDCSimpleSimulation::m_driftLengthSigma
double m_driftLengthSigma
Standard deviation by which the drift length should be smeared.
Definition: CDCSimpleSimulation.h:201
Belle2::TrackFindingCDC::CDCSimpleSimulation::constructMCTracks
std::vector< CDCTrack > constructMCTracks(int nMCTracks, std::vector< SimpleSimHit > simpleSimHits)
Creates CDCWireHits and uses them to construct the true CDCTracks.
Definition: CDCSimpleSimulation.cc:91
Belle2::TrackFindingCDC::CDCSimpleSimulation::simulate
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.
Definition: CDCSimpleSimulation.cc:50
Belle2::TrackFindingCDC::CDCTrack
Class representing a sequence of three dimensional reconstructed hits.
Definition: CDCTrack.h:51
Belle2::TrackFindingCDC::CDCSimpleSimulation::m_propSpeed
double m_propSpeed
Electrical current propagation speed in the wires.
Definition: CDCSimpleSimulation.h:204
Belle2::TrackFindingCDC::CDCSimpleSimulation::SimpleSimHit::m_iMCTrack
size_t m_iMCTrack
Memory for the true index of the track this hit is contained in.
Definition: CDCSimpleSimulation.h:95
Belle2::TrackFindingCDC::CDCSimpleSimulation::m_driftSpeed
double m_driftSpeed
Electron drift speed in the cdc gas.
Definition: CDCSimpleSimulation.h:207
Belle2::TrackFindingCDC::Helix
Extension of the generalized circle also caching the perigee coordinates.
Definition: Helix.h:38
Belle2::TrackFindingCDC::CDCSimpleSimulation::m_eventTime
double m_eventTime
A global event time.
Definition: CDCSimpleSimulation.h:188
Belle2::TrackFindingCDC::CDCSimpleSimulation::m_addInWireSignalDelay
bool m_addInWireSignalDelay
Switch to activate the in wire signal delay.
Definition: CDCSimpleSimulation.h:194
Belle2::TrackFindingCDC::CDCSimpleSimulation::m_maxNHitOnWire
int m_maxNHitOnWire
Maximal number of hits allowed on each wire (0 means all).
Definition: CDCSimpleSimulation.h:185
Belle2::TrackFindingCDC::CDCSimpleSimulation::SimpleSimHit::m_pos3D
Vector3D m_pos3D
Memory for the true position on the track closest to the wire.
Definition: CDCSimpleSimulation.h:101
Belle2::TrackFindingCDC::CDCSimpleSimulation::createHits
std::vector< SimpleSimHit > createHits(const Helix &globalHelix, double arcLength2DOffset) const
Generate hits for the given helix in starting from the two dimensional arc length.
Definition: CDCSimpleSimulation.cc:168
Belle2::TrackFindingCDC::CDCSimpleSimulation::activateTOFDelay
void activateTOFDelay(bool activate=true)
Activate the TOF time delay.
Definition: CDCSimpleSimulation.h:156
Belle2::TrackFindingCDC::CDCSimpleSimulation::activateInWireSignalDelay
void activateInWireSignalDelay(bool activate=true)
Activate the in wire signal delay.
Definition: CDCSimpleSimulation.h:160
Belle2::TrackFindingCDC::CDCSimpleSimulation::getMaxNHitOnWire
int getMaxNHitOnWire() const
Getter for the maximal number of hits that are allowed on each layer.
Definition: CDCSimpleSimulation.h:164
Belle2::TrackFindingCDC::CDCSimpleSimulation::m_sharedWireHits
std::shared_ptr< const std::vector< CDCWireHit > > m_sharedWireHits
Space for the memory of the generated wire hits.
Definition: CDCSimpleSimulation.h:173
Belle2::TrackFindingCDC::CDCSimpleSimulation::SimpleSimHit::m_rlInfo
ERightLeft m_rlInfo
Memory for the true right left passage information.
Definition: CDCSimpleSimulation.h:98
Belle2::TrackFindingCDC::CDCSimpleSimulation::getWireHits
ConstVectorRange< CDCWireHit > getWireHits() const
Getter for the wire hits created in the simulation.
Definition: CDCSimpleSimulation.cc:35
Belle2::TrackFindingCDC::CDCSimpleSimulation::setEventTime
void setEventTime(double eventTime)
Setter for a global event time offset.
Definition: CDCSimpleSimulation.h:152
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::CDCSimpleSimulation::createHitsForLayer
std::vector< SimpleSimHit > createHitsForLayer(const CDCWire &nearWire, const Helix &globalHelix, double arcLength2DOffset) const
Generate connected hits for wires in the same layer close to the given wire.
Definition: CDCSimpleSimulation.cc:276
Belle2::TrackFindingCDC::CDCSimpleSimulation::getEventTime
double getEventTime() const
Getter for a global event time offset.
Definition: CDCSimpleSimulation.h:148
Belle2::TrackFindingCDC::Vector3D
A three dimensional vector.
Definition: Vector3D.h:34
Belle2::TrackFindingCDC::CDCSimpleSimulation::s_nominalDriftSpeed
const double s_nominalDriftSpeed
Default electron drift speed in cdc gas - 4 * 10^-3 cm / ns.
Definition: CDCSimpleSimulation.h:182
Belle2::TrackFindingCDC::CDCSimpleSimulation::s_nominalPropSpeed
const double s_nominalPropSpeed
Default in wire signal propagation speed - 27.25 cm / ns.
Definition: CDCSimpleSimulation.h:179
Belle2::TrackFindingCDC::CDCSimpleSimulation::m_addTOFDelay
bool m_addTOFDelay
Switch to activate the addition of the time of flight.
Definition: CDCSimpleSimulation.h:191
Belle2::TrackFindingCDC::NRightLeft::ERightLeft
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Definition: ERightLeft.h:35
Belle2::TrackFindingCDC::Range
A pair of iterators usable with the range base for loop.
Definition: Range.h:35
Belle2::TrackFindingCDC::CDCSimpleSimulation::SimpleSimHit
Structure to accomdate information about the individual hits during the simluation.
Definition: CDCSimpleSimulation.h:59
Belle2::TrackFindingCDC::CDCSimpleSimulation::SimpleSimHit::m_wireHit
CDCWireHit m_wireHit
Memory for the wire hit instance that will be given to the reconstruction.
Definition: CDCSimpleSimulation.h:92
Belle2::TrackFindingCDC::CDCSimpleSimulation::setMaxNHitOnWire
void setMaxNHitOnWire(int maxNHitOnWire)
Setter for the maximal number of hits that are allowed on each layer.
Definition: CDCSimpleSimulation.h:168
Belle2::TrackFindingCDC::CDCSimpleSimulation::SimpleSimHit::m_arcLength2D
double m_arcLength2D
Memory for the true two dimensional arc length on the helix to this hit.
Definition: CDCSimpleSimulation.h:104
Belle2::TrackFindingCDC::CDCWire
Class representing a sense wire in the central drift chamber.
Definition: CDCWire.h:60
Belle2::TrackFindingCDC::CDCWireHit::getRefPos3D
const Vector3D & getRefPos3D() const
The three dimensional reference position of the underlying wire.
Definition: CDCWireHit.cc:219
Belle2::TrackFindingCDC::CDCSimpleSimulation::s_nominalDriftLengthVariance
const double s_nominalDriftLengthVariance
Default drift length variance.
Definition: CDCSimpleSimulation.h:176
Belle2::TrackFindingCDC::CDCSimpleSimulation::SimpleSimHit::m_trueDriftLength
double m_trueDriftLength
Memory for the true drift length from the true position to the wire.
Definition: CDCSimpleSimulation.h:107
Belle2::TrackFindingCDC::CDCWireHit
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:65
Belle2::TrackFindingCDC::CDCSimpleSimulation::SimpleSimHit::SimpleSimHit
SimpleSimHit(const CDCWireHit &wireHit, size_t iMCTrack, ERightLeft rlInfo)
Constructor from limited truth information Mainly used by the manually prepared event.
Definition: CDCSimpleSimulation.h:65
Belle2::TrackFindingCDC::CDCTrajectory3D
Particle full three dimensional trajectory.
Definition: CDCTrajectory3D.h:47
Belle2::TrackFindingCDC::CDCSimpleSimulation::loadPreparedEvent
std::vector< CDCTrack > loadPreparedEvent()
Fills the wire hits with a hard coded event from the real simulation.
Definition: CDCSimpleSimulation.cc:384
Belle2::TrackFindingCDC::CDCSimpleSimulation::m_driftLengthVariance
double m_driftLengthVariance
Variance by which the drift length should be smeared.
Definition: CDCSimpleSimulation.h:198