Belle II Software  release-08-01-10
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 44 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 89 of file CDCSimpleSimulation.cc.

90 {
91 
92  // Sort the hits along side their wire hits
93  std::stable_sort(simpleSimHits.begin(), simpleSimHits.end(),
94  [](const SimpleSimHit & lhs, const SimpleSimHit & rhs) -> bool {
95  return lhs.m_wireHit < rhs.m_wireHit;
96  });
97 
98  // Discard multiple hits on the same wire up to the maximal exceeding the maximal desired number
99  if (m_maxNHitOnWire > 0) {
100  const CDCWire* lastWire = nullptr;
101  size_t nSameWire = 0;
102  const size_t maxNHitOnWire = m_maxNHitOnWire;
103 
104  auto exceedsMaxNHitOnWire =
105  [&lastWire, &nSameWire, maxNHitOnWire](const SimpleSimHit & simpleSimHit) -> bool {
106 
107  if (&(simpleSimHit.m_wireHit.getWire()) == lastWire)
108  {
109  ++nSameWire;
110  } else {
111  nSameWire = 1;
112  lastWire = &(simpleSimHit.m_wireHit.getWire());
113  }
114  return nSameWire > maxNHitOnWire ? true : false;
115  };
116 
117  auto itLast = std::remove_if(simpleSimHits.begin(), simpleSimHits.end(), exceedsMaxNHitOnWire);
118  simpleSimHits.erase(itLast, simpleSimHits.end());
119  }
120 
121  // Write the created hits and move them to the their storage place.
122  {
123  std::vector<CDCWireHit> wireHits;
124  wireHits.reserve(simpleSimHits.size());
125  for (SimpleSimHit& simpleSimHit : simpleSimHits) {
126  wireHits.push_back(simpleSimHit.m_wireHit);
127  }
128 
129  B2ASSERT("WireHits should be sorted as a result from sorting the SimpleSimHits. "
130  "Algorithms may relay on the sorting o the WireHits",
131  std::is_sorted(wireHits.begin(), wireHits.end()));
132 
133  m_sharedWireHits.reset(new const std::vector<CDCWireHit>(std::move(wireHits)));
134  }
135 
136  // TODO: Decide if the EventMeta should be incremented after write.
137 
138  // Now construct the tracks.
139  std::vector<CDCTrack> mcTracks;
140  mcTracks.resize(nMCTracks);
142  const size_t nWireHits = wireHits.size();
143 
144  for (size_t iWireHit = 0; iWireHit < nWireHits; ++iWireHit) {
145  const CDCWireHit& wireHit = wireHits[iWireHit];
146  const SimpleSimHit& simpleSimHit = simpleSimHits[iWireHit];
147 
148  CDCTrack& mcTrack = mcTracks[simpleSimHit.m_iMCTrack];
149 
150  CDCRLWireHit rlWireHit(&wireHit, simpleSimHit.m_rlInfo);
151  CDCRecoHit3D recoHit3D(rlWireHit, simpleSimHit.m_pos3D, simpleSimHit.m_arcLength2D);
152  mcTrack.push_back(recoHit3D);
153  }
154 
156  for (CDCTrack& mcTrack : mcTracks) {
157  mcTrack.sortByArcLength2D();
158  }
159 
160  return mcTracks;
161 }
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
Definition: CDCRLWireHit.h:41
Class representing a three dimensional reconstructed hit.
Definition: CDCRecoHit3D.h:52
ConstVectorRange< CDCWireHit > getWireHits() const
Getter for the wire hits created in the simulation.
std::shared_ptr< const std::vector< CDCWireHit > > m_sharedWireHits
Space for the memory of the generated wire hits.
int m_maxNHitOnWire
Maximal number of hits allowed on each wire (0 means all).
Class representing a sequence of three dimensional reconstructed hits.
Definition: CDCTrack.h:41
void sortByArcLength2D()
Sort the recoHits according to their perpS information.
Definition: CDCTrack.cc:412
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:55
Class representing a sense wire in the central drift chamber.
Definition: CDCWire.h:58
A pair of iterators usable with the range base for loop.
Definition: Range.h:25
std::size_t size() const
Returns the total number of objects in this range.
Definition: Range.h:76

◆ 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 274 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 48 of file CDCSimpleSimulation.cc.


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