Belle II Software  release-05-01-25
AlignableSVDRecoHit.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2012, 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Tadeas Bilka *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <alignment/reconstruction/AlignableSVDRecoHit.h>
12 
13 #include <alignment/dbobjects/VXDAlignment.h>
14 #include <alignment/GlobalDerivatives.h>
15 #include <alignment/Hierarchy.h>
16 #include <alignment/Manager.h>
17 #include <framework/geometry/BFieldManager.h>
18 #include <svd/geometry/SensorInfo.h>
19 #include <vxd/geometry/GeoCache.h>
20 
21 using namespace std;
22 using namespace Belle2;
23 using namespace alignment;
24 
25 bool AlignableSVDRecoHit::s_enableLorentzGlobalDerivatives = false;
26 
27 std::pair<std::vector<int>, TMatrixD> AlignableSVDRecoHit::globalDerivatives(const genfit::StateOnPlane* sop)
28 {
29  auto alignment = GlobalCalibrationManager::getInstance().getAlignmentHierarchy().getGlobalDerivatives<VXDAlignment>(getPlaneId(),
30  sop);
31 
32  auto globals = GlobalDerivatives(alignment);
33 
34  if (s_enableLorentzGlobalDerivatives) {
35  auto lorentz = GlobalCalibrationManager::getInstance().getLorentzShiftHierarchy().getGlobalDerivatives<VXDAlignment>(getPlaneId(),
36  sop, BFieldManager::getInstance().getField(sop->getPos()));
37  globals.add(lorentz);
38  }
39 
40  const SVD::SensorInfo& geometry = dynamic_cast<const SVD::SensorInfo&>(VXD::GeoCache::get(getSensorID()));
41 
42  // Legendre parametrization of deformation
43  auto L1 = [](double x) {return x;};
44  auto L2 = [](double x) {return (3 * x * x - 1) / 2;};
45  auto L3 = [](double x) {return (5 * x * x * x - 3 * x) / 2;};
46  auto L4 = [](double x) {return (35 * x * x * x * x - 30 * x * x + 3) / 8;};
47 
48  double du_dw = sop->getState()[1]; // slope in U direction
49  double dv_dw = sop->getState()[2]; // slope in V direction
50  double u = 0.0;
51  double v = 0.0;
52 
53  if (isU()) {
54  u = getPosition(); // U coordinate of hit
55  v = sop->getState()[4]; // V coordinate of hit
56  } else {
57  v = getPosition(); // V coordinate of hit
58  u = sop->getState()[3]; // U coordinate of hit
59  }
60 
61  double width = geometry.getWidth(v); // Width of sensor (U side)
62  double length = geometry.getLength(); // Length of sensor (V side)
63  u = u * 2 / width; // Legendre parametrization required U in (-1, 1)
64  v = v * 2 / length; // Legendre parametrization required V in (-1, 1)
65 
66  // Add parameters of surface deformation to alignment
67  // Numbering of VXD alignment parameters:
68  // -> 0-6: Rigid body alignment
69  // -> 31-33: First level of surface deformation
70  // -> 41-44: Second level of surface deformation
71  // -> 51-55: Third level of surface deformation
72 
73  globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 31), std::vector<double> {L2(u)*du_dw, L2(u)*dv_dw});
74  globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 32), std::vector<double> {L1(u)*L1(v)*du_dw, L1(u)*L1(v)*dv_dw});
75  globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 33), std::vector<double> {L2(v)*du_dw, L2(v)*dv_dw});
76 
77  globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 41), std::vector<double> {L3(u)*du_dw, L3(u)*dv_dw});
78  globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 42), std::vector<double> {L2(u)*L1(v)*du_dw, L2(u)*L1(v)*dv_dw});
79  globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 43), std::vector<double> {L1(u)*L2(v)*du_dw, L1(u)*L2(v)*dv_dw});
80  globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 44), std::vector<double> {L3(v)*du_dw, L3(v)*dv_dw});
81 
82  globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 51), std::vector<double> {L4(u)*du_dw, L4(u)*dv_dw});
83  globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 52), std::vector<double> {L3(u)*L1(v)*du_dw, L3(u)*L1(v)*dv_dw});
84  globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 53), std::vector<double> {L2(u)*L2(v)*du_dw, L2(u)*L2(v)*dv_dw});
85  globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 54), std::vector<double> {L1(u)*L3(v)*du_dw, L1(u)*L3(v)*dv_dw});
86  globals.add(GlobalLabel::construct<VXDAlignment>(getSensorID(), 55), std::vector<double> {L4(v)*du_dw, L4(v)*dv_dw});
87 
88  return globals;
89 }
genfit::StateOnPlane
A state with arbitrary dimension defined in a DetPlane.
Definition: StateOnPlane.h:47
Belle2::SVD::SensorInfo
Specific implementation of SensorInfo for SVD Sensors which provides additional sensor specific infor...
Definition: SensorInfo.h:35
Belle2::DBObjCalibrationConstMapBase::add
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 (optionaly with minus sign)
Definition: DBObjCalibrationConstMapBase.cc:37
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::getPosition
ExpRunEvt getPosition(const std::vector< Evt > &events, double tEdge)
Get the exp-run-evt number from the event time [hours].
Definition: Splitter.h:344
Belle2::VXDAlignment
VXD alignment (and maybe some calibration) parameters.
Definition: VXDAlignment.h:29