9#include <alignment/reconstruction/AlignableCDCRecoHit.h>
11#include <alignment/GlobalLabel.h>
12#include <alignment/GlobalDerivatives.h>
13#include <cdc/dataobjects/WireID.h>
14#include <cdc/dbobjects/CDCTimeZeros.h>
15#include <cdc/dbobjects/CDCTimeWalks.h>
16#include <cdc/geometry/CDCGeometryPar.h>
17#include "Math/ChebyshevPol.h"
22using namespace alignment;
30 GlobalDerivatives globals;
31 unsigned short LR = (int(
m_leftRight) > 0.) ? 1 : 0;
34 const B2Vector3D& wirePositon = sop->getPlane()->getO();
38 double alpha = cdcgeo.
getAlpha(wirePositon, mom);
40 const TVectorD& stateOnPlane = sop->getState();
41 const double driftLengthEstimate = std::abs(stateOnPlane(3));
42 const double driftTime = cdcgeo.
getDriftTime(driftLengthEstimate, layer, LR, alpha, theta);
43 const double driftVelocity = cdcgeo.
getDriftV(driftTime, layer, LR, alpha, theta);
48 if (driftTime > 20 && driftTime < 200 && fabs(driftVelocity) < 1.0e-2) {
59 const std::vector<float> param = tws->getTimeWalkParams(board);
71 if (driftTime > 20 && driftTime < 500 && fabs(driftVelocity) < 1.0e-2) {
78 auto xtid = xts->getXtID(
getWireID().getICLayer(), LR, (
float)alpha, (
float)theta);
79 const auto& par = xts->getXtParams(xtid);
80 auto boundary = par.at(6);
81 if (driftTime < boundary) {
84 ROOT::Math::Chebyshev5(driftTime, 1, 0, 0, 0, 0, 0) *
double(
int(
m_leftRight))
88 ROOT::Math::Chebyshev5(driftTime, 0, 1, 0, 0, 0, 0) *
double(
int(
m_leftRight))
92 ROOT::Math::Chebyshev5(driftTime, 0, 0, 1, 0, 0, 0) *
double(
int(
m_leftRight))
96 ROOT::Math::Chebyshev5(driftTime, 0, 0, 0, 1, 0, 0) *
double(
int(
m_leftRight))
100 ROOT::Math::Chebyshev5(driftTime, 0, 0, 0, 0, 1, 0) *
double(
int(
m_leftRight))
104 ROOT::Math::Chebyshev5(driftTime, 0, 0, 0, 0, 0, 1) *
double(
int(
m_leftRight))
121 auto tdir = sop->getDir();
122 auto ndir = sop->getPlane()->getNormal();
123 auto udir = sop->getPlane()->getU();
124 auto vdir = sop->getPlane()->getV();
125 auto pos = sop->getPos();
127 auto tn = tdir[0] * ndir[0] + tdir[1] * ndir[1] + tdir[2] * ndir [2];
129 auto drdm = TMatrixD(3, 3);
131 for (
int i = 0; i < 3; ++i) {
132 for (
int j = 0; j < 3; ++j) {
133 drdm(i, j) -= tdir[i] * ndir[j] / tn;
137 auto dmdg = TMatrixD(3, 6);
139 dmdg[0][0] = 1.; dmdg[0][4] = -pos[2]; dmdg[0][5] = pos[1];
140 dmdg[1][1] = 1.; dmdg[1][3] = pos[2]; dmdg[1][5] = -pos[0];
141 dmdg[2][2] = 1.; dmdg[2][3] = -pos[1]; dmdg[2][4] = pos[0];
143 auto drldrg = TMatrixD(3, 3);
144 for (
int i = 0; i < 3; ++i) {
145 drldrg(0, i) = udir[i];
146 drldrg(1, i) = vdir[i];
147 drldrg(2, i) = ndir[i];
150 auto drldg = drldrg * (drdm * dmdg);
156 const double zRel = std::max(0., std::min(1., (pos[2] - zWireM) / (zWireP - zWireM)));
204 double zRelM = fabs(1. - zRel);
206 double zRelP = fabs(zRel - 0.);
238 drldg(0, 1) * 4.0 * zRel * (1.0 - zRel)
253 unsigned short LR = (int(
m_leftRight) > 0.) ? 1 : 0;
256 const B2Vector3D& wirePositon = sop->getPlane()->getO();
260 const double alpha = cdcgeo.
getAlpha(wirePositon, mom);
261 const double theta = cdcgeo.
getTheta(mom);
262 const TVectorD& stateOnPlane = sop->getState();
263 const double driftLengthEstimate = std::abs(stateOnPlane(3));
264 const double driftTime = cdcgeo.
getDriftTime(driftLengthEstimate, layer, LR, alpha, theta);
265 const double driftVelocity = cdcgeo.
getDriftV(driftTime, layer, LR, alpha, theta);
267 TMatrixD locals(2, 1);
268 if (driftTime > 20 && driftTime < 200 && fabs(driftVelocity) < 1.0e-2) {
269 locals(0, 0) = - double(
int(
m_leftRight)) * driftVelocity;
virtual TMatrixD localDerivatives(const genfit::StateOnPlane *sop) override
Derivatives for (local) fit parameters.
static bool s_enableWireSaggingGlobalDerivative
Static enabling(true) or disabling(false) addition of global derivative for wire sagging coefficient ...
static bool s_enableWireByWireAlignmentGlobalDerivatives
Static enabling(true) or disabling(false) addition of global derivatives for wire-by-wire alignment.
virtual std::pair< std::vector< int >, TMatrixD > globalDerivatives(const genfit::StateOnPlane *sop) override
Labels and derivatives of residuals (local measurement coordinates) w.r.t.
static bool s_enableTrackT0LocalDerivative
Static enabling(true) or disabling(false) addition of local derivative for track T0.
static const baseType layerDPhi
Layer rotation in global X-Y plane (gamma) dPhi = forward - backward endplate.
static const baseType layerDy
Layer shift in global Y dY = forward - backward endplate.
static const baseType layerDx
Layer shift in global X dX = forward - backward endplate.
static const baseType wireBwdY
Wire Y position w.r.t. nominal on backward endplate.
static const baseType wireFwdY
Wire Y position w.r.t. nominal on forward endplate.
static const baseType wireFwdX
Wire X position w.r.t. nominal on forward endplate.
static const baseType wireBwdX
Wire X position w.r.t. nominal on backward endplate.
static const baseType layerY
Layer shift in global Y at backward endplate.
static const baseType layerX
Layer shift in global X at backward endplate.
static const baseType layerPhi
Layer rotation in global X-Y plane (gamma) at backward endplate.
static const baseType wireTension
Wire tension w.r.t. nominal (=50. ?)
signed char m_leftRight
Flag showing left/right passage.
WireID getWireID() const
Getter for WireID object.
unsigned short m_adcCount
ADC Count as out of CDCHit.
static std::unique_ptr< CDC::CDCGeometryTranslatorBase > s_cdcGeometryTranslator
Object for geometry translation.
The Class for CDC Geometry Parameters.
double getTheta(const B2Vector3D &momentum) const
Returns track incident angle (theta in rad.).
unsigned short getBoardID(const WireID &wID) const
Returns frontend board id. corresponding to the wire id.
double getAlpha(const B2Vector3D &posOnWire, const B2Vector3D &momentum) const
Returns track incident angle in rphi plane (alpha in rad.).
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.
double getOutgoingAlpha(const double alpha) const
Converts incoming- to outgoing-alpha.
double getOutgoingTheta(const double alpha, const double theta) const
Converts incoming- to outgoing-theta.
double getDriftTime(double dist, unsigned short layer, unsigned short lr, double alpha, double theta) const
Return the drift time to the sense wire.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
Class for accessing objects in the database.
static GlobalLabel construct(gidTYPE element, gidTYPE param)
Construct label for given DB object (template argument) and its element and parameter.
Class to identify a wire inside the CDC.
unsigned short getICLayer() const
Getter for continuous layer numbering.
B2Vector3< double > B2Vector3D
typedef for common usage with double
Abstract base class for different kinds of events.