Belle II Software development
BKLMTrackFinder.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/* Own header. */
10#include <klm/bklm/modules/bklmTracking/BKLMTrackFinder.h>
11
12/* KLM headers. */
13#include <klm/dataobjects/KLMHit2d.h>
14
15/* Basf2 headers. */
16#include <framework/logging/Logger.h>
17
18using namespace Belle2;
19using namespace CLHEP;
20
23{
24}
25
27 m_Fitter(fitter),
28 m_globalFit(false)
29{
30}
31
34{
35}
36
39{
40 m_Fitter = fitter;
42}
43
45bool BKLMTrackFinder::filter(const std::list<KLMHit2d*>& seed,
46 std::list<KLMHit2d*>& hits,
47 std::list<KLMHit2d*>& track)
48{
49 track = seed;
50
51 if (m_Fitter == 0) {
52 B2ERROR("BKLMTrackFinder: Fitter not registered");
53 return (false);
54 }
55
56 m_Fitter->fit(track);//fit seed
57
58 for (KLMHit2d* hit2d : hits) {
59 if (hit2d->getSubdetector() != KLMElementNumbers::c_BKLM)
60 continue;
61
62 // Prevent duplicate hits or hits on same layer
63 // no duplicate hit is already guaranteed and now we allow hits on same layer so the following is commented out
64 // bool skip = false;
65 // for (j = track.begin(); j != track.end(); ++j) {
66 // if ((*j)->getLayer() == (*i)->getLayer())
67 // skip = true;
68 // }
69 // if (skip == true)
70 // continue;
71
72 if (hit2d->isOnStaTrack() == false) {
73 double error, sigma;
74 if (m_globalFit)
75 m_Fitter->globalDistanceToHit(hit2d, error, sigma);
76 else m_Fitter->distanceToHit(hit2d, error, sigma);
77 //B2INFO("BKLMTrackFinder" << " Error: " << error << " Sigma: " << sigma);
78 if (sigma < 5.0) {
79 track.push_back(hit2d);
80 }
81 }
82 }
83
84 if (track.size() < 3)
85 return false;
86
87 // Fit with new hits
88 double chisqr = m_Fitter->fit(track);
89 B2DEBUG(20, "BKLMTrackFinder:" << "ChiSqr: " << chisqr);
90
91 // Do this the hard way to count each layer separately.
92 std::list<int> hitLayers;
93 for (KLMHit2d* hit2d : track) {
94 hitLayers.push_back(hit2d->getLayer());
95 }
96 hitLayers.sort();
97 hitLayers.unique();
98
99 int layers = (*(--hitLayers.end()) - * (hitLayers.begin()));
100 int noHits = hitLayers.size();
101
102 if (noHits >= 4 && double(noHits) / double(layers) >= 0.75) {
103 return true;
104 } else {
105 return false;
106 }
107}
bool filter(const std::list< KLMHit2d * > &seed, std::list< KLMHit2d * > &hits, std::list< KLMHit2d * > &track)
find associated hits and do fit.
void registerFitter(BKLMTrackFitter *fitter)
Register a fitter if not constructed with one.
bool m_globalFit
do fit in the local system or global system false: local sys; true: global sys.
BKLMTrackFinder()
Default constructor.
BKLMTrackFitter * m_Fitter
pointer to the fitter
track fitting procedure
double fit(std::list< KLMHit2d * > &listTrackPoint)
do fit and returns chi square of the fit.
double globalDistanceToHit(KLMHit2d *hit, double &error, double &sigma)
Distance from track to a hit in the global system.
double distanceToHit(KLMHit2d *hit, double &error, double &sigma)
Distance from track to a hit in the plane of the module.
void setGlobalFit(bool localOrGlobal)
set the fitting mode, local system or global system
KLM 2d hit.
Definition: KLMHit2d.h:33
Abstract base class for different kinds of events.