Belle II Software development
AlignableBKLMRecoHit.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/AlignableBKLMRecoHit.h>
10
11#include <alignment/GlobalDerivatives.h>
12#include <alignment/GlobalLabel.h>
13#include <framework/geometry/B2Vector3.h>
14#include <klm/bklm/geometry/GeometryPar.h>
15#include <klm/dataobjects/KLMElementNumbers.h>
16#include <klm/dataobjects/KLMHit2d.h>
17#include <klm/dbobjects/bklm/BKLMAlignment.h>
18
19#include <genfit/DetPlane.h>
20
21using namespace std;
22using namespace Belle2;
23
24AlignableBKLMRecoHit::AlignableBKLMRecoHit(const KLMHit2d* hit, const genfit::TrackCandHit*):
25 genfit::PlanarMeasurement(HIT_DIMENSIONS)
26{
27 int section = hit->getSection();
28 int sector = hit->getSector();
29 m_Layer = hit->getLayer();
30 const KLMElementNumbers* elementNumbers = &(KLMElementNumbers::Instance());
31 m_KLMModule = elementNumbers->moduleNumberBKLM(section, sector, m_Layer);
32
34 m_Module = m_GeoPar->findModule(section, sector, m_Layer);
35
36 //+++ global coordinates of the hit
37 global[0] = hit->getPositionX();
38 global[1] = hit->getPositionY();
39 global[2] = hit->getPositionZ();
40
41 //+++ local coordinates of the hit
42 CLHEP::Hep3Vector local = m_Module->globalToLocal(global);
43
44 //+++ local coordinates in KLM m_Layer of the hit
45 double localU = local[1]; //phi
46 double localV = local[2]; //z
47 double errorU = m_Module->getPhiStripWidth() / sqrt(12);
48 double errorV = m_Module->getZStripWidth() / sqrt(12);
49
50 if (hit->inRPC()) {
51 //+++ scale localU and localV based on measured-in-Belle resolution
52 int nStrips = hit->getPhiStripMax() - hit->getPhiStripMin() + 1;
53 double dn = nStrips - 1.5;
54 double factor = std::pow((0.9 + 0.4 * dn * dn), 1.5) * 0.60;//measured-in-Belle resolution
55 errorU = errorU * sqrt(factor);
56
57 nStrips = hit->getZStripMax() - hit->getZStripMin() + 1;
58 dn = nStrips - 1.5;
59 factor = std::pow((0.9 + 0.4 * dn * dn), 1.5) * 0.55;//measured-in-Belle resolution
60 errorV = errorV * sqrt(factor);
61 }
62
63 //Set positions
64 rawHitCoords_(0) = localU;
65 rawHitCoords_(1) = localV;
66 //Set the error covariance matrix
67 rawHitCov_(0, 0) = errorU * errorU; // error in U, squared
68 rawHitCov_(0, 1) = 0.;
69 rawHitCov_(1, 0) = 0.;
70 rawHitCov_(1, 1) = errorV * errorV; // error in V, squared
71
72 //+++ Construct vectors o, u, v of m_Layer in global coords.
73 CLHEP::Hep3Vector gOrigin = m_Module->getGlobalOrigin();
74 CLHEP::Hep3Vector lOrigin = m_Module->globalToLocal(gOrigin) + m_Module->getLocalReconstructionShift();
75 CLHEP::Hep3Vector gOrigin_midway = m_Module->localToGlobal(lOrigin);
76 CLHEP::Hep3Vector uAxis(0, 1, 0);
77 CLHEP::Hep3Vector vAxis(0, 0, 1);
78 CLHEP::Hep3Vector gUaxis = m_Module->localToGlobal(uAxis) - gOrigin;
79 CLHEP::Hep3Vector gVaxis = m_Module->localToGlobal(vAxis) - gOrigin;
80
82 B2Vector3D origin_mid(gOrigin_midway[0], gOrigin_midway[1], gOrigin_midway[2]);
83
85 B2Vector3D uGlobal(gUaxis[0], gUaxis[1], gUaxis[2]);
87 B2Vector3D vGlobal(gVaxis[0], gVaxis[1], gVaxis[2]);
88
89 genfit::SharedPlanePtr detPlane(new genfit::DetPlane(origin_mid, uGlobal, vGlobal, 0));
90 setPlane(detPlane, m_KLMModule);
91}
92
93genfit::AbsMeasurement* AlignableBKLMRecoHit::clone() const
94{
95 return new AlignableBKLMRecoHit(*this);
96}
97
98std::vector<genfit::MeasurementOnPlane*> AlignableBKLMRecoHit::constructMeasurementsOnPlane(const genfit::StateOnPlane& state) const
99{
100 TVectorD predFglo = state.get6DState();
101 TVectorD correctedLocal(2);
102 CLHEP::Hep3Vector localmom(predFglo[3], predFglo[4], predFglo[5]);
103 localmom = m_Module->RotateToLocal(localmom);
104
105 //do correction for scintillators
106 if (m_Layer == 1 || m_Layer == 2) {
107 CLHEP::Hep3Vector global_shift_z(0, 0, predFglo[5]*halfheight_sci / sqrt(predFglo[3]*predFglo[3] + predFglo[4]*predFglo[4]));
108 CLHEP::Hep3Vector local_corrected_z = m_Module->globalToLocal(global - global_shift_z);
109 double local_shift_u = localmom[1] / localmom[0] * halfheight_sci;
110 correctedLocal[0] = local_corrected_z[1] + local_shift_u;
111 //correctedLocal[0] = local_corrected_z[1];
112 correctedLocal[1] = local_corrected_z[2];
113 } else {
114 correctedLocal[0] = rawHitCoords_[0];
115 correctedLocal[1] = rawHitCoords_[1];
116 }
117
118 // return std::vector<genfit::MeasurementOnPlane*>(1, new genfit::MeasurementOnPlane(rawHitCoords_, rawHitCov_, state.getPlane(),
119 return std::vector<genfit::MeasurementOnPlane*>(1, new genfit::MeasurementOnPlane(correctedLocal, rawHitCov_, state.getPlane(),
120 state.getRep(), this->constructHMatrix(state.getRep())));
121}
122
123std::pair<std::vector<int>, TMatrixD> AlignableBKLMRecoHit::globalDerivatives(const genfit::StateOnPlane* sop)
124{
125 std::vector<int> labGlobal;
126
127 labGlobal.push_back(GlobalLabel::construct<BKLMAlignment>(m_KLMModule, KLMAlignmentData::c_DeltaU));
128 labGlobal.push_back(GlobalLabel::construct<BKLMAlignment>(m_KLMModule, KLMAlignmentData::c_DeltaV));
129 labGlobal.push_back(GlobalLabel::construct<BKLMAlignment>(m_KLMModule, KLMAlignmentData::c_DeltaW));
130 labGlobal.push_back(GlobalLabel::construct<BKLMAlignment>(m_KLMModule, KLMAlignmentData::c_DeltaAlpha));
131 labGlobal.push_back(GlobalLabel::construct<BKLMAlignment>(m_KLMModule, KLMAlignmentData::c_DeltaBeta));
132 labGlobal.push_back(GlobalLabel::construct<BKLMAlignment>(m_KLMModule, KLMAlignmentData::c_DeltaGamma));
133
134 // Matrix of global derivatives
135 TMatrixD derGlobal(2, 6);
136 derGlobal.Zero();
137
138 // track u-slope in local sensor system
139 double uSlope = sop->getState()[1];
140 // track v-slope in local sensor system
141 double vSlope = sop->getState()[2];
142 // Predicted track u-position in local sensor system
143 double uPos = sop->getState()[3];
144 // Predicted track v-position in local sensor system
145 double vPos = sop->getState()[4];
146
147 // Global derivatives for alignment in module local coordinates
148 derGlobal(0, 0) = 1.0;
149 derGlobal(0, 1) = 0.0;
150 derGlobal(0, 2) = - uSlope;
151 derGlobal(0, 3) = vPos * uSlope;
152 derGlobal(0, 4) = -uPos * uSlope;
153 derGlobal(0, 5) = vPos;
154
155 derGlobal(1, 0) = 0.0;
156 derGlobal(1, 1) = 1.0;
157 derGlobal(1, 2) = - vSlope;
158 derGlobal(1, 3) = vPos * vSlope;
159 derGlobal(1, 4) = -uPos * vSlope;
160 derGlobal(1, 5) = -uPos;
161
162 return alignment::GlobalDerivatives(labGlobal, derGlobal);
163
164}
165
166
167
168
virtual std::vector< genfit::MeasurementOnPlane * > constructMeasurementsOnPlane(const genfit::StateOnPlane &state) const override
Measurement construction.
CLHEP::Hep3Vector global
not streamed
const bklm::Module * m_Module
Module used to get geometry information.
const double halfheight_sci
not streamed
virtual std::pair< std::vector< int >, TMatrixD > globalDerivatives(const genfit::StateOnPlane *sop) override
Labels and derivatives of residuals (local measurement coordinates) w.r.t.
genfit::AbsMeasurement * clone() const override
Creating a deep copy of this hit.
uint16_t m_KLMModule
KLM module number.
@ c_DeltaAlpha
Rotation in alpha.
@ c_DeltaBeta
Rotation in beta.
@ c_DeltaU
Shift in U (EKLM: local X).
@ c_DeltaGamma
Rotation in gamma (EKLM: rotation in local plane).
@ c_DeltaV
Shift in V (EKLM: local Y).
KLM element numbers.
static const KLMElementNumbers & Instance()
Instantiation.
KLMModuleNumber moduleNumberBKLM(int section, int sector, int layer) const
Get module number for BKLM.
KLM 2d hit.
Definition: KLMHit2d.h:33
Class for easier manipulation with global derivatives (and their labels)
Provides BKLM geometry parameters for simulation, reconstruction etc (from Gearbox or DataBase)
Definition: GeometryPar.h:37
const Module * findModule(int section, int sector, int layer) const
Get the pointer to the definition of a module.
Definition: GeometryPar.cc:721
static GeometryPar * instance(void)
Static method to get a reference to the singleton GeometryPar instance.
Definition: GeometryPar.cc:27
const CLHEP::Hep3Vector globalToLocal(const CLHEP::Hep3Vector &v, bool reco=false) const
Transform space-point within this module from global to local coordinates.
Definition: Module.cc:339
double getPhiStripWidth() const
Get phi-strip width.
Definition: Module.h:137
const CLHEP::Hep3Vector getLocalReconstructionShift() const
Return the local-coordinate real-vs-ideal translation of this module's sensitive volume; nominally (0...
Definition: Module.h:279
const CLHEP::Hep3Vector getGlobalOrigin() const
Return the position (in global coordinates) of this module's sensitive-volume origin.
Definition: Module.h:285
const CLHEP::Hep3Vector localToGlobal(const CLHEP::Hep3Vector &v, bool reco=false) const
Transform space-point within this module from local to global coordinates.
Definition: Module.cc:326
const CLHEP::Hep3Vector RotateToLocal(const CLHEP::Hep3Vector &v) const
Rotate a vector from global to local system.
Definition: Module.h:262
double getZStripWidth() const
Get z-strip width.
Definition: Module.h:155
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
Abstract base class for different kinds of events.
STL namespace.