Belle II Software  release-05-02-19
CDCSimpleSimulation Class Reference

Class providing a simple simulation of the CDC mainly for quick unit test checks. More...

#include <CDCSimpleSimulation.h>

Collaboration diagram for CDCSimpleSimulation:

Classes

struct  SimpleSimHit
 Structure to accomdate information about the individual hits during the simluation. More...
 

Public Member Functions

ConstVectorRange< CDCWireHitgetWireHits () const
 Getter for the wire hits created in the simulation.
 
std::vector< CDCTracksimulate (const std::vector< CDCTrajectory3D > &trajectories3D)
 Propagates the trajectories through the CDC as without energy loss until they first leave the CDC. More...
 
CDCTrack simulate (const CDCTrajectory3D &trajectory3D)
 Same as above for one trajectory.
 
std::vector< CDCTrackloadPreparedEvent ()
 Fills the wire hits with a hard coded event from the real simulation.
 
double getEventTime () const
 Getter for a global event time offset.
 
void setEventTime (double eventTime)
 Setter for a global event time offset.
 
void activateTOFDelay (bool activate=true)
 Activate the TOF time delay.
 
void activateInWireSignalDelay (bool activate=true)
 Activate the in wire signal delay.
 
int getMaxNHitOnWire () const
 Getter for the maximal number of hits that are allowed on each layer.
 
void setMaxNHitOnWire (int maxNHitOnWire)
 Setter for the maximal number of hits that are allowed on each layer.
 

Private Member Functions

std::vector< CDCTrackconstructMCTracks (int nMCTracks, std::vector< SimpleSimHit > simpleSimHits)
 Creates CDCWireHits and uses them to construct the true CDCTracks. More...
 
std::vector< SimpleSimHitcreateHits (const Helix &globalHelix, double arcLength2DOffset) const
 Generate hits for the given helix in starting from the two dimensional arc length.
 
std::vector< SimpleSimHitcreateHitsForLayer (const CDCWire &nearWire, const Helix &globalHelix, double arcLength2DOffset) const
 Generate connected hits for wires in the same layer close to the given wire. More...
 
SimpleSimHit createHitForCell (const CDCWire &wire, const Helix &globalHelix, double arcLength2DOffset) const
 Generate a hit for the given wire.
 

Private Attributes

std::shared_ptr< const std::vector< CDCWireHit > > m_sharedWireHits
 Space for the memory of the generated wire hits.
 
const double s_nominalDriftLengthVariance = 0.000169
 Default drift length variance.
 
const double s_nominalPropSpeed = 27.25
 Default in wire signal propagation speed - 27.25 cm / ns.
 
const double s_nominalDriftSpeed = 4e-3
 Default electron drift speed in cdc gas - 4 * 10^-3 cm / ns.
 
int m_maxNHitOnWire = 0
 Maximal number of hits allowed on each wire (0 means all).
 
double m_eventTime = 0
 A global event time.
 
bool m_addTOFDelay = false
 Switch to activate the addition of the time of flight.
 
bool m_addInWireSignalDelay = false
 Switch to activate the in wire signal delay.
 
double m_driftLengthVariance = s_nominalDriftLengthVariance
 Variance by which the drift length should be smeared.
 
double m_driftLengthSigma = std::sqrt(m_driftLengthVariance)
 Standard deviation by which the drift length should be smeared.
 
double m_propSpeed = s_nominalPropSpeed
 Electrical current propagation speed in the wires.
 
double m_driftSpeed = s_nominalDriftSpeed
 Electron drift speed in the cdc gas.
 

Detailed Description

Class providing a simple simulation of the CDC mainly for quick unit test checks.

Most aspects of the detection are idealized

  • Trajectories are ideal helices
  • Wires are straight lines
  • Drift relation linear
  • No detection inefficiencies are enabled
  • T0, TOF and signal delay in the wire are not taken into account (but can eventually implemented to study them)

Nevertheless drift length a smeared by one gaussian distribution of fixed width to have a realistic check for the accuracy of fast fitting procedures in terms of their chi2 distributions.

Definition at line 54 of file CDCSimpleSimulation.h.

Member Function Documentation

◆ constructMCTracks()

std::vector< CDCTrack > constructMCTracks ( int  nMCTracks,
std::vector< SimpleSimHit simpleSimHits 
)
private

Creates CDCWireHits and uses them to construct the true CDCTracks.

Sort the hits by the order of their occurance

Definition at line 91 of file CDCSimpleSimulation.cc.

92 {
93 
94  // Sort the hits along side their wire hits
95  std::stable_sort(simpleSimHits.begin(), simpleSimHits.end(),
96  [](const SimpleSimHit & lhs, const SimpleSimHit & rhs) -> bool {
97  return lhs.m_wireHit < rhs.m_wireHit;
98  });
99 
100  // Discard multiple hits on the same wire up to the maximal exceeding the maximal desired number
101  if (m_maxNHitOnWire > 0) {
102  const CDCWire* lastWire = nullptr;
103  size_t nSameWire = 0;
104  const size_t maxNHitOnWire = m_maxNHitOnWire;
105 
106  auto exceedsMaxNHitOnWire =
107  [&lastWire, &nSameWire, maxNHitOnWire](const SimpleSimHit & simpleSimHit) -> bool {
108 
109  if (&(simpleSimHit.m_wireHit.getWire()) == lastWire)
110  {
111  ++nSameWire;
112  } else {
113  nSameWire = 1;
114  lastWire = &(simpleSimHit.m_wireHit.getWire());
115  }
116  return nSameWire > maxNHitOnWire ? true : false;
117  };
118 
119  auto itLast = std::remove_if(simpleSimHits.begin(), simpleSimHits.end(), exceedsMaxNHitOnWire);
120  simpleSimHits.erase(itLast, simpleSimHits.end());
121  }
122 
123  // Write the created hits and move them to the their storage place.
124  {
125  std::vector<CDCWireHit> wireHits;
126  wireHits.reserve(simpleSimHits.size());
127  for (SimpleSimHit& simpleSimHit : simpleSimHits) {
128  wireHits.push_back(simpleSimHit.m_wireHit);
129  }
130 
131  B2ASSERT("WireHits should be sorted as a result from sorting the SimpleSimHits. "
132  "Algorithms may relay on the sorting o the WireHits",
133  std::is_sorted(wireHits.begin(), wireHits.end()));
134 
135  m_sharedWireHits.reset(new const std::vector<CDCWireHit>(std::move(wireHits)));
136  }
137 
138  // TODO: Decide if the EventMeta should be incremented after write.
139 
140  // Now construct the tracks.
141  std::vector<CDCTrack> mcTracks;
142  mcTracks.resize(nMCTracks);
143  ConstVectorRange<CDCWireHit> wireHits = getWireHits();
144  const size_t nWireHits = wireHits.size();
145 
146  for (size_t iWireHit = 0; iWireHit < nWireHits; ++iWireHit) {
147  const CDCWireHit& wireHit = wireHits[iWireHit];
148  const SimpleSimHit& simpleSimHit = simpleSimHits[iWireHit];
149 
150  CDCTrack& mcTrack = mcTracks[simpleSimHit.m_iMCTrack];
151 
152  CDCRLWireHit rlWireHit(&wireHit, simpleSimHit.m_rlInfo);
153  CDCRecoHit3D recoHit3D(rlWireHit, simpleSimHit.m_pos3D, simpleSimHit.m_arcLength2D);
154  mcTrack.push_back(recoHit3D);
155  }
156 
158  for (CDCTrack& mcTrack : mcTracks) {
159  mcTrack.sortByArcLength2D();
160  }
161 
162  return mcTracks;
163 }

◆ createHitsForLayer()

std::vector< CDCSimpleSimulation::SimpleSimHit > createHitsForLayer ( const CDCWire nearWire,
const Helix globalHelix,
double  arcLength2DOffset 
) const
private

Generate connected hits for wires in the same layer close to the given wire.

Iter counter clockwise for more hits

Iter clockwise for more hits

Definition at line 276 of file CDCSimpleSimulation.cc.

◆ 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.

Parameters
trajectories3DIdeal trajectories to be propagated.
Returns
The true tracks containing the hits generated in this process

Assign mc trajectories to the tracks

Definition at line 50 of file CDCSimpleSimulation.cc.


The documentation for this class was generated from the following files:
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::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::getWireHits
ConstVectorRange< CDCWireHit > getWireHits() const
Getter for the wire hits created in the simulation.
Definition: CDCSimpleSimulation.cc:35
Belle2::TrackFindingCDC::CDCWireHit
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:65