9 #include <cdc/dataobjects/CDCRecoHit.h>
13 #include <genfit/WireTrackCandHit.h>
14 #include <genfit/AbsTrackRep.h>
15 #include <genfit/RKTrackRep.h>
16 #include <genfit/TrackPoint.h>
17 #include <genfit/AbsFitterInfo.h>
18 #include <genfit/Exception.h>
19 #include <genfit/HMatrixU.h>
25 std::unique_ptr<ADCCountTranslatorBase> CDCRecoHit::s_adcCountTranslator = 0;
26 std::unique_ptr<CDCGeometryTranslatorBase> CDCRecoHit::s_cdcGeometryTranslator = 0;
27 std::unique_ptr<TDCCountTranslatorBase> CDCRecoHit::s_tdcCountTranslator = 0;
28 bool CDCRecoHit::s_useTrackTime =
false;
30 bool CDCRecoHit::s_cosmics =
false;
37 bool useTrackTime,
bool cosmics)
39 s_adcCountTranslator.reset(adcCountTranslator);
40 s_cdcGeometryTranslator.reset(cdcGeometryTranslator);
41 s_tdcCountTranslator.reset(tdcCountTranslator);
42 s_useTrackTime = useTrackTime;
47 CDCRecoHit::CDCRecoHit()
48 :
genfit::AbsMeasurement(1),
49 m_tdcCount(0), m_adcCount(0), m_wireID(
WireID()), m_cdcHit(nullptr), m_leftRight(0)
54 :
genfit::AbsMeasurement(1), m_cdcHit(cdcHit), m_leftRight(0)
57 B2FATAL(
"Can't produce CDCRecoHits without setting of the translators.");
67 if (aTrackCandHitPtr) {
68 signed char lrInfo = aTrackCandHitPtr->getLeftRightResolution();
69 B2DEBUG(250,
"l/r: " <<
int(lrInfo));
95 B2Vector3D noSagWireDirection = noSagWire2 - noSagWire1;
96 noSagWireDirection.
SetMag(1.);
103 double zPOCA = (noSagWire1.
Z()
104 + noSagWireDirection.
Dot(noSagPoca - noSagWire1) * noSagWireDirection.
Z());
119 const B2Vector3D& pocaOnWire = wire1 + wireDirection.
Dot(poca - wire1) * wireDirection;
126 if (fabs(wireDirection.
Angle(dirInPoca)) < 0.01) {
127 genfit::Exception exc(
"CDCRecoHit::constructPlane(): Cannot construct detector plane, direction is parallel to wire", __LINE__,
142 double z = state.getPos().Z();
152 const double wx = state.getPlane()->getO().X();
153 const double wy = state.getPlane()->getO().Y();
154 const double px = p.X();
155 const double py = p.Y();
156 const double cross = wx * py - wy * px;
157 const double dot = wx * px + wy * py;
158 double alpha = atan2(cross,
dot);
159 double theta = atan2(p.Perp(), p.Z());
177 if (atan2(py, px) > 0.) {
200 static TVectorD m(1);
201 static TMatrixDSym cov(1);
234 double weight = 0.5 * pow(std::max(0., 1 - (mR + mL) / 2 / rMax), 2);
235 mopL->setWeight(weight);
236 mopR->setWeight(weight);
241 if (mL < 0. || mR < 0.) {
242 B2DEBUG(150,
"Ignoring hit with negative drift time.");
254 B2FATAL(
"CDCRecoHit can only handle state vectors of type RKTrackRep!");
263 double z = state.getPos().Z();
273 const double wx = state.getPlane()->getO().X();
274 const double wy = state.getPlane()->getO().Y();
275 const double px = p.X();
276 const double py = p.Y();
277 const double cross = wx * py - wy * px;
278 const double dot = wx * px + wy * py;
279 double alpha = atan2(cross,
dot);
280 double theta = atan2(p.Perp(), p.Z());
299 auto fL = [&](
const double & t) ->
double {
303 auto fR = [&](
const double & t) ->
double {
316 double rightShort[2], rightFull[2];
317 double leftShort[2], leftFull[2];
318 const double defaultStepT = 1e-3 * trackTime;
321 double temp = trackTime + defaultStepT / 2;
335 stepT = 2 * (temp - trackTime);
337 rightShort[0] = fL(trackTime + .5 * stepT);
338 rightShort[1] = fR(trackTime + .5 * stepT);
341 leftShort[0] = fL(trackTime - .5 * stepT);
342 leftShort[1] = fR(trackTime - .5 * stepT);
345 rightFull[0] = fL(trackTime + stepT);
346 rightFull[1] = fR(trackTime + stepT);
349 leftFull[0] = fL(trackTime - stepT);
350 leftFull[1] = fR(trackTime - stepT);
356 double derivShort[2];
357 for (
size_t j = 0; j < 2; ++j) {
358 derivFull[j] = (rightFull[j] - leftFull[j]) / (2.*stepT);
359 derivShort[j] = (rightShort[j] - leftShort[j]) / stepT;
362 return { +(4.*derivShort[0] - derivFull[0]) / 3.,
363 -(4.*derivShort[1] - derivFull[1]) / 3.};
371 bool usePlaneFromFit)
375 B2ERROR(
"No genfit::TrackPoint for CDCRecoHit.");
380 B2DEBUG(200,
"No genfit::AbsFitterInfo for this CDCRecoHit.");
392 ? mop.getPlane()->getO()
396 pointingVector = fittedPoca - pocaOnWire;
398 trackDir = mop.getMom();
B2Vector3< DataType > Cross(const B2Vector3< DataType > &p) const
Cross product.
void SetMag(DataType mag)
Set magnitude keeping theta and phi constant.
DataType Z() const
access variable Z (= .at(2) without boundary check)
DataType Dot(const B2Vector3< DataType > &p) const
Scalar product.
DataType Angle(const B2Vector3< DataType > &q) const
The angle w.r.t.
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
short getTDCCount() const
Getter for TDC count.
unsigned short getID() const
Getter for encoded wire number.
unsigned short getADCCount() const
Getter for integrated charge.
This class is used to transfer CDC information to the track fit.
signed char m_leftRight
Flag showing left/right passage.
std::vector< genfit::MeasurementOnPlane * > constructMeasurementsOnPlane(const genfit::StateOnPlane &state) const override
build MeasurementsOnPlane
static std::unique_ptr< CDC::ADCCountTranslatorBase > s_adcCountTranslator
Object for ADC Count translation.
unsigned short m_tdcCount
TDC Count as out of CDCHit.
static bool s_cosmics
Switch to use cosmic events, or physics events from IP.
unsigned short m_adcCount
ADC Count as out of CDCHit.
static bool s_useTrackTime
Whether to use the track time or not when building the measurementOnPlane.
bool getFlyByDistanceVector(B2Vector3D &pointingVector, B2Vector3D &trackDir, const genfit::AbsTrackRep *rep=nullptr, bool usePlaneFromFit=false)
Get the vector pointing from the wire to the fitted trajectory as well as the direction of the track ...
static std::unique_ptr< CDC::TDCCountTranslatorBase > s_tdcCountTranslator
Object for getting drift-length and -resolution.
std::vector< double > timeDerivativesMeasurementsOnPlane(const genfit::StateOnPlane &state) const
Get the time derivative of the MesuredStateOnPlane (derived from the track fit).
virtual const genfit::HMatrixU * constructHMatrix(const genfit::AbsTrackRep *) const override
construct error matrix
WireID m_wireID
Wire Identifier.
genfit::SharedPlanePtr constructPlane(const genfit::StateOnPlane &state) const override
Methods that actually interface to Genfit.
void setLeftRightResolution(int lr)
select how to resolve the left/right ambiguity: -1: negative (left) side on vector (wire direction) x...
CDCRecoHit()
Default Constructor for ROOT IO.
CDCRecoHit * clone() const override
Creating a copy of this hit.
static std::unique_ptr< CDC::CDCGeometryTranslatorBase > s_cdcGeometryTranslator
Object for geometry translation.
Abstract Base class for the ADC count translator.
Abstract Base class for the geometry translator.
Base class for translation of Drift Time into Drift Length.
Class to identify a wire inside the CDC.
unsigned short getISuperLayer() const
Getter for Super-Layer.
This class collects all information needed and produced by a specific AbsFitter and is specific to on...
Abstract base class for a track representation.
virtual double extrapolateToLine(StateOnPlane &state, const TVector3 &linePoint, const TVector3 &lineDirection, bool stopAtBoundary=false, bool calcJacobianNoise=false) const =0
Extrapolates the state to the POCA to a line, and returns the extrapolation length and,...
virtual TVector3 getMom(const StateOnPlane &state) const =0
Get the cartesian momentum vector of a state.
virtual TVector3 getPos(const StateOnPlane &state) const =0
Get the cartesian position of a state.
Exception class for error handling in GENFIT (provides storage for diagnostic information)
AbsHMatrix implementation for one-dimensional MeasurementOnPlane and RKTrackRep parameterization.
#StateOnPlane with additional covariance matrix.
Measured coordinates on a plane.
AbsTrackRep with 5D track parameterization in plane coordinates: (q/p, u', v', u, v)
A state with arbitrary dimension defined in a DetPlane.
Hit object for use in TrackCand.
Object containing AbsMeasurement and AbsFitterInfo objects.
AbsFitterInfo * getFitterInfo(const AbsTrackRep *rep=nullptr) const
Get fitterInfo for rep. Per default, use cardinal rep.
Hit object for use in TrackCand.
T dot(GeneralVector< T > a, GeneralVector< T > b)
dot product of two general vectors
Abstract base class for different kinds of events.
Defines for I/O streams used for error and debug printing.
std::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.