9#include <alignment/reconstruction/AlignableBKLMRecoHit.h>
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>
19#include <genfit/DetPlane.h>
45 double localU = local[1];
46 double localV = local[2];
53 double dn = nStrips - 1.5;
54 double factor = std::pow((0.9 + 0.4 * dn * dn), 1.5) * 0.60;
55 errorU = errorU *
sqrt(factor);
59 factor = std::pow((0.9 + 0.4 * dn * dn), 1.5) * 0.55;
60 errorV = errorV *
sqrt(factor);
64 rawHitCoords_(0) = localU;
65 rawHitCoords_(1) = localV;
67 rawHitCov_(0, 0) = errorU * errorU;
68 rawHitCov_(0, 1) = 0.;
69 rawHitCov_(1, 0) = 0.;
70 rawHitCov_(1, 1) = errorV * errorV;
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;
82 B2Vector3D origin_mid(gOrigin_midway[0], gOrigin_midway[1], gOrigin_midway[2]);
85 B2Vector3D uGlobal(gUaxis[0], gUaxis[1], gUaxis[2]);
87 B2Vector3D vGlobal(gVaxis[0], gVaxis[1], gVaxis[2]);
89 genfit::SharedPlanePtr detPlane(
new genfit::DetPlane(origin_mid, uGlobal, vGlobal, 0));
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);
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;
112 correctedLocal[1] = local_corrected_z[2];
114 correctedLocal[0] = rawHitCoords_[0];
115 correctedLocal[1] = rawHitCoords_[1];
119 return std::vector<genfit::MeasurementOnPlane*>(1,
new genfit::MeasurementOnPlane(correctedLocal, rawHitCov_, state.getPlane(),
120 state.getRep(), this->constructHMatrix(state.getRep())));
125 std::vector<int> labGlobal;
135 TMatrixD derGlobal(2, 6);
139 double uSlope = sop->getState()[1];
141 double vSlope = sop->getState()[2];
143 double uPos = sop->getState()[3];
145 double vPos = sop->getState()[4];
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;
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;
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.
@ HIT_DIMENSIONS
sensitive Dimensions of the Hit
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.
AlignableBKLMRecoHit()
Constructor.
uint16_t m_KLMModule
KLM module number.
static GlobalLabel construct(gidTYPE element, gidTYPE param)
Construct label for given DB object (template argument) and its element and parameter.
@ 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).
static const KLMElementNumbers & Instance()
Instantiation.
KLMModuleNumber moduleNumberBKLM(int section, int sector, int layer) const
Get module number for BKLM.
bool inRPC() const
Determine whether this 2D hit is in RPC or scintillator.
int getLayer() const
Get layer number.
int getZStripMax() const
Get last strip number for z plane.
int getSection() const
Get section number.
float getPositionZ() const
Get hit global position z coordinate.
int getSector() const
Get sector number.
float getPositionX() const
Get hit global position x coordinate.
int getPhiStripMin() const
Get strip number for phi plane.
int getZStripMin() const
Get strip number for z plane.
int getPhiStripMax() const
Get last strip number for phi plane.
float getPositionY() const
Get hit global position y coordinate.
Class for easier manipulation with global derivatives (and their labels)
Provides BKLM geometry parameters for simulation, reconstruction etc (from Gearbox or DataBase)
const Module * findModule(int section, int sector, int layer) const
Get the pointer to the definition of a module.
static GeometryPar * instance(void)
Static method to get a reference to the singleton GeometryPar instance.
B2Vector3< double > B2Vector3D
typedef for common usage with double
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.