Belle II Software  release-08-01-10
DriftTimeUtil.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 #pragma once
9 
10 #include <cdc/geometry/CDCGeometryPar.h>
11 #include <TRandom.h>
12 #include <cdc/geometry/CDCGeoControlPar.h>
13 
14 namespace Belle2 {
19  namespace TrackFindingCDC {
20 
22  struct DriftTimeUtil {
23 
32  static double getDriftV(double driftTime,
33  unsigned short iCLayer,
34  unsigned short lr,
35  double alpha = 0.,
36  double theta = 0.5 * M_PI)
37  {
38  return CDC::CDCGeometryPar::Instance().getDriftV(driftTime, iCLayer, lr, alpha, theta);
39  }
40 
49  static double getDriftLength(double driftTime,
50  unsigned short iCLayer,
51  unsigned short lr,
52  double alpha = 0.,
53  double theta = 0.5 * M_PI)
54  {
55  return CDC::CDCGeometryPar::Instance().getDriftLength(driftTime, iCLayer, lr, alpha, theta);
56  }
57 
66  static double getDriftTime(double dist,
67  unsigned short iCLayer,
68  unsigned short lr,
69  double alpha,
70  double theta)
71  {
72  return CDC::CDCGeometryPar::Instance().getDriftTime(dist, iCLayer, lr, alpha, theta);
73  }
74 
80  static double getPropTime(const WireID& wireID, double z)
81  {
82  unsigned short iCLayer = wireID.getICLayer();
85  B2Vector3D backwardWirePos =
86  geometryPar.wireBackwardPosition(wireID, CDC::CDCGeometryPar::c_Aligned);
87  B2Vector3D forwardWirePos =
88  geometryPar.wireForwardPosition(wireID, CDC::CDCGeometryPar::c_Aligned);
89  double zDistance = z - backwardWirePos.Z();
90 
91  // Actually are very small correction
92  double stereoFactor =
93  (forwardWirePos - backwardWirePos).Mag() / (forwardWirePos.Z() - backwardWirePos.Z());
94 
95  double distance = zDistance * stereoFactor;
96  if (controlPar.getSenseWireZposMode() == 1) {
97  distance += geometryPar.getBwdDeltaZ(iCLayer);
98  }
99  return distance * geometryPar.getPropSpeedInv(iCLayer);
100  }
101 
108  static double getTimeWalk(const WireID& wireID, unsigned short adcCount)
109  {
110  return CDC::CDCGeometryPar::Instance().getTimeWalk(wireID, adcCount);
111  }
112 
120  static double getMeasuredTime(const WireID& wireID, unsigned short tdcCount, bool smear)
121  {
122  double smearing = 0;
123  if (smear) {
124  smearing = gRandom->Rndm() - 0.5;
125  }
126  double channelT0 = static_cast<double>(CDC::CDCGeometryPar::Instance().getT0(wireID));
127  double measuredTime =
128  channelT0 - (tdcCount + smearing) * CDC::CDCGeometryPar::Instance().getTdcBinWidth();
129  if (measuredTime > 2000) {
130  B2INFO("channelT0 " << channelT0);
131  B2INFO("measuredTime " << measuredTime);
132  }
133  return measuredTime;
134  }
135 
136  };
137  }
139 }
DataType Z() const
access variable Z (= .at(2) without boundary check)
Definition: B2Vector3.h:435
The Class for CDC Geometry Control Parameters.
int getSenseWireZposMode() const
Get sense wire z position mode.
static CDCGeoControlPar & getInstance()
Static method to get a reference to the CDCGeoControlPar instance.
The Class for CDC Geometry Parameters.
double getTimeWalk(const WireID &wID, unsigned short adcCount) const
Returns time-walk.
const B2Vector3D wireForwardPosition(uint layerId, int cellId, EWirePosition set=c_Base) const
Returns the forward position of the input sense wire.
double getDriftV(double dt, unsigned short layer, unsigned short lr, double alpha=0., double theta=0.5 *M_PI) const
Get the realistic drift velocity.
const B2Vector3D wireBackwardPosition(uint layerId, int cellId, EWirePosition set=c_Base) const
Returns the backward position of the input sense wire.
double getTdcBinWidth() const
Return TDC bin width (nsec).
float getT0(const WireID &wireID) const
Returns t0 parameter of the specified sense wire.
double getBwdDeltaZ(unsigned short layerID) const
Return backward 'deltaZ'.
double getPropSpeedInv(const unsigned int layerID) const
Get the inversel of propagation speed in the sense wire.
double getDriftTime(double dist, unsigned short layer, unsigned short lr, double alpha, double theta) const
Return the drift time to the sense wire.
double getDriftLength(double dt, unsigned short layer, unsigned short lr, double alpha=0., double theta=0.5 *M_PI, bool calculateMinTime=true, double minTime=0.) const
Return the drift dength to the sense wire.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
Class to identify a wire inside the CDC.
Definition: WireID.h:34
unsigned short getICLayer() const
Getter for continuous layer numbering.
Definition: WireID.cc:24
Abstract base class for different kinds of events.
Structure to expose some drift time and length functions from the CDCGeometryPar to Python.
Definition: DriftTimeUtil.h:22
static double getPropTime(const WireID &wireID, double z)
Getter for the in wire propagation time.
Definition: DriftTimeUtil.h:80
static double getDriftTime(double dist, unsigned short iCLayer, unsigned short lr, double alpha, double theta)
Return the drift time to the sense wire.
Definition: DriftTimeUtil.h:66
static double getMeasuredTime(const WireID &wireID, unsigned short tdcCount, bool smear)
Returns the time measured at the readout board.
static double getDriftV(double driftTime, unsigned short iCLayer, unsigned short lr, double alpha=0., double theta=0.5 *M_PI)
Get the realistic drift velocity.
Definition: DriftTimeUtil.h:32
static double getTimeWalk(const WireID &wireID, unsigned short adcCount)
Returns time-walk.
static double getDriftLength(double driftTime, unsigned short iCLayer, unsigned short lr, double alpha=0., double theta=0.5 *M_PI)
Return the drift length to the sense wire.
Definition: DriftTimeUtil.h:49