25 :
verbosity(ps.getUntrackedParameter<unsigned int>(
"verbosity", 0)),
26 minimumHitsPerProjectionPerRP(ps.getParameter<unsigned int>(
"minimumHitsPerProjectionPerRP")),
27 maxResidualToSigma(ps.getParameter<double>(
"maxResidualToSigma")) {}
33 printf(
">> LocalTrackFitter::Fit\n");
35 bool selectionChanged =
true;
36 unsigned int loopCounter = 0;
37 while (selectionChanged) {
39 while (selectionChanged) {
41 printf(
"* fit loop %u\n", loopCounter++);
43 bool fitFailed =
false;
66 bool &selectionChanged)
const {
68 printf(
" - LocalTrackFitter::FitAndRemoveOutliers\n");
70 if (selection.empty()) {
76 if (selection.size() < 4) {
82 TMatrixD
A(selection.size(), 4);
83 TMatrixD Vi(selection.size(), selection.size());
84 TVectorD measVec(selection.size());
86 for (
auto it = selection.begin(); it != selection.end(); ++it, ++
j) {
87 const unsigned int &detId = it->id;
92 A(j, 0) = it->z * dirData.dx;
94 A(j, 2) = it->z * dirData.dy;
97 measVec(j) = it->position + dirData.s - (it->z - d.
z) * dirData.dz;
99 Vi(j, j) = 1. / it->sigma / it->sigma;
103 TMatrixD AT(4, selection.size());
105 TMatrixD ATViA(4, 4);
107 TMatrixD ATViAI(ATViA);
110 ATViAI = ATViA.Invert();
117 theta = ATViAI * AT * Vi * measVec;
128 trackFit.
z0 = geometry.
z0;
129 trackFit.
ndf = selection.size() - 4;
131 for (
int i = 0;
i < R.GetNrows();
i++)
135 printf(
" ax = %.3f mrad, bx = %.4f mm, ay = %.3f mrad, by = %.4f mm, z0 = %.3f mm\n",
141 printf(
" ndof = %i, chi^2/ndof/si^2 = %.3f\n", trackFit.
ndf, trackFit.
chi_sq / trackFit.
ndf);
145 selectionChanged =
false;
146 TVectorD interpolation(A * theta);
148 for (
auto it = selection.begin(); it != selection.end(); ++
j) {
152 printf(
", dirIdx=%u: interpol = %+8.1f um, residual = %+6.1f um, residual / sigma = %+6.2f\n",
154 interpolation[j] * 1E3,
159 double resToSigma = R[
j] / it->sigma;
162 selectionChanged =
true;
174 printf(
" - RemoveInsufficientPots\n");
176 selectionChanged =
false;
179 map<unsigned int, pair<set<unsigned int>, set<unsigned int> > > planeMap;
180 for (
auto it = selection.begin(); it != selection.end(); ++it) {
182 const unsigned int rpId = senId.
rpId();
186 if ((plane % 2) == 0)
187 planeMap[rpId].first.insert(senId);
189 planeMap[rpId].second.insert(senId);
193 planeMap[rpId].first.insert(senId);
194 planeMap[rpId].second.insert(senId);
199 selectionChanged =
false;
201 for (
auto it = planeMap.begin(); it != planeMap.end(); ++it) {
205 printf(
"\tRP %u: projection1 = %lu, projection 2 = %lu\n",
207 it->second.first.size(),
208 it->second.second.size());
211 for (
auto dit = selection.begin(); dit != selection.end();) {
214 printf(
"\t\tremoving %u\n", dit->id);
215 selection.erase(dit);
216 selectionChanged =
true;
Detector ID class for TOTEM Si strip detectors.
double z0
the point where intercepts are measured, in mm
bool fit(HitCollection &, const AlignmentGeometry &, LocalTrackFit &) const
A structure to hold relevant geometrical information about one detector/sensor.
unsigned int minimumHitsPerProjectionPerRP
minimum of hits to accept data from a RP
Geom::Theta< T > theta() const
Local (linear) track description (or a fit result). Uses global reference system. ...
unsigned int verbosity
verbosity level
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
signed int ndf
the number of degrees of freedom
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
double maxResidualToSigma
hits with higher ratio residual/sigma will be dropped
double z
z postion at detector centre; mm
const DirectionData & getDirectionData(unsigned int idx) const
double chi_sq
the residual sum of squares
void printId(unsigned int id)
std::vector< Hit > HitCollection
const DetGeometry & get(unsigned int id) const
retrieves sensor geometry
Base class for CTPPS detector IDs.
LocalTrackFitter()
dummy constructor (not to be used)
void fitAndRemoveOutliers(HitCollection &, const AlignmentGeometry &, LocalTrackFit &, bool &failed, bool &selectionChanged) const
double z0
a characteristic z in mm
double bx
intercepts in mm
void removeInsufficientPots(HitCollection &, bool &selectionChanged) const
removes the hits of pots with too few planes active