Belle II Software development
AlignableSVDRecoHit.cc
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
9#include <alignment/reconstruction/AlignableSVDRecoHit.h>
10
11#include <alignment/dbobjects/VXDAlignment.h>
12#include <alignment/GlobalDerivatives.h>
13#include <alignment/Hierarchy.h>
14#include <alignment/Manager.h>
15#include <framework/geometry/BFieldManager.h>
16#include <svd/geometry/SensorInfo.h>
17#include <vxd/geometry/GeoCache.h>
18
19using namespace std;
20using namespace Belle2;
21using namespace alignment;
22
24
25std::pair<std::vector<int>, TMatrixD> AlignableSVDRecoHit::globalDerivatives(const genfit::StateOnPlane* sop)
26{
27 auto alignment = GlobalCalibrationManager::getInstance().getAlignmentHierarchy().getGlobalDerivatives<VXDAlignment>(getPlaneId(),
28 sop);
29
30 auto globals = GlobalDerivatives(alignment);
31
33 auto lorentz = GlobalCalibrationManager::getInstance().getLorentzShiftHierarchy().getGlobalDerivatives<VXDAlignment>(getPlaneId(),
34 sop, BFieldManager::getInstance().getField(ROOT::Math::XYZVector(sop->getPos())));
35 globals.add(lorentz);
36 }
37
39
40 // Legendre parametrization of deformation
41 auto L1 = [](double x) {return x;};
42 auto L2 = [](double x) {return (3 * x * x - 1) / 2;};
43 auto L3 = [](double x) {return (5 * x * x * x - 3 * x) / 2;};
44 auto L4 = [](double x) {return (35 * x * x * x * x - 30 * x * x + 3) / 8;};
45
46 double du_dw = sop->getState()[1]; // slope in U direction
47 double dv_dw = sop->getState()[2]; // slope in V direction
48 double u = 0.0;
49 double v = 0.0;
50
51 if (isU()) {
52 u = getPosition(); // U coordinate of hit
53 v = sop->getState()[4]; // V coordinate of hit
54 } else {
55 v = getPosition(); // V coordinate of hit
56 u = sop->getState()[3]; // U coordinate of hit
57 }
58
59 double width = geometry.getWidth(v); // Width of sensor (U side)
60 double length = geometry.getLength(); // Length of sensor (V side)
61 u = u * 2 / width; // Legendre parametrization required U in (-1, 1)
62 v = v * 2 / length; // Legendre parametrization required V in (-1, 1)
63
64 // Add parameters of surface deformation to alignment
65 // Numbering of VXD alignment parameters:
66 // -> 0-6: Rigid body alignment
67 // -> 31-33: First level of surface deformation
68 // -> 41-44: Second level of surface deformation
69 // -> 51-55: Third level of surface deformation
70
71 globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 31), std::vector<double> {L2(u)*du_dw, L2(u)*dv_dw});
72 globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 32), std::vector<double> {L1(u)*L1(v)*du_dw, L1(u)*L1(v)*dv_dw});
73 globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 33), std::vector<double> {L2(v)*du_dw, L2(v)*dv_dw});
74
75 globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 41), std::vector<double> {L3(u)*du_dw, L3(u)*dv_dw});
76 globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 42), std::vector<double> {L2(u)*L1(v)*du_dw, L2(u)*L1(v)*dv_dw});
77 globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 43), std::vector<double> {L1(u)*L2(v)*du_dw, L1(u)*L2(v)*dv_dw});
78 globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 44), std::vector<double> {L3(v)*du_dw, L3(v)*dv_dw});
79
80 globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 51), std::vector<double> {L4(u)*du_dw, L4(u)*dv_dw});
81 globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 52), std::vector<double> {L3(u)*L1(v)*du_dw, L3(u)*L1(v)*dv_dw});
82 globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 53), std::vector<double> {L2(u)*L2(v)*du_dw, L2(u)*L2(v)*dv_dw});
83 globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 54), std::vector<double> {L1(u)*L3(v)*du_dw, L1(u)*L3(v)*dv_dw});
84 globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 55), std::vector<double> {L4(v)*du_dw, L4(v)*dv_dw});
85
86 return globals;
87}
static bool s_enableLorentzGlobalDerivatives
Static enabling(true) or disabling(false) addition of global derivatives for Lorentz shift.
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 BFieldManager & getInstance()
Return the instance of the magnetic field manager.
virtual double add(baseType id, baseType param, double value, bool subtractInsteadOfAdd=false)
Add correction to already stored (or to 0. if not set yet) constant value (optionally with minus sign...
static GlobalLabel construct(gidTYPE element, gidTYPE param)
Construct label for given DB object (template argument) and its element and parameter.
Definition GlobalLabel.h:81
bool isU() const
Is the coordinate u or v?
Definition SVDRecoHit.h:91
float getPosition() const
Get coordinate.
Definition SVDRecoHit.h:94
VxdID getSensorID() const
Get the compact ID.
Definition SVDRecoHit.h:82
Specific implementation of SensorInfo for SVD Sensors which provides additional sensor specific infor...
Definition SensorInfo.h:25
VXD alignment (and maybe some calibration) parameters.
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a reference to the SensorInfo of a given SensorID.
Definition GeoCache.cc:67
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition GeoCache.cc:214
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
Common code concerning the geometry representation of the detector.
Definition CreatorBase.h:25
Abstract base class for different kinds of events.
STL namespace.