Belle II Software  release-05-01-25
BKLMTrackFinder.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Yinghui GUAN *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 /* Own header. */
12 #include <klm/bklm/modules/bklmTracking/BKLMTrackFinder.h>
13 
14 /* KLM headers. */
15 #include <klm/dataobjects/bklm/BKLMHit2d.h>
16 
17 /* Belle 2 headers. */
18 #include <framework/logging/Logger.h>
19 
20 using namespace Belle2;
21 using namespace std;
22 using namespace CLHEP;
23 
26 {
27 }
28 
30  m_Fitter(fitter),
31  m_globalFit(false)
32 {
33 }
34 
37 {
38 }
39 
42 {
43  m_Fitter = fitter;
45 }
46 
48 bool BKLMTrackFinder::filter(const std::list<BKLMHit2d*>& seed,
49  std::list<BKLMHit2d*>& hits,
50  std::list<BKLMHit2d*>& track)
51 {
52 
53  std::list<BKLMHit2d*>::iterator i;
54 
55  track = seed;
56 
57  if (m_Fitter == 0) {
58  B2ERROR("BKLMTrackFinder: Fitter not registered");
59  return (false);
60  }
61 
62  m_Fitter->fit(track);//fit seed
63 
64  for (i = hits.begin(); i != hits.end(); ++i) {
65 
66  // Prevent duplicate hits or hits on same layer
67  // no duplicate hit is alreday guaranteed and now we allow hits on same layer so the following is commented out
68  // bool skip = false;
69  // for (j = track.begin(); j != track.end(); ++j) {
70  // if ((*j)->getLayer() == (*i)->getLayer()) skip = true;
71  // }
72  // if (skip == true) continue;
73 
74  if ((*i)->isOnStaTrack() == false) {
75  double error, sigma;
76  if (m_globalFit) m_Fitter->globalDistanceToHit(*i, error, sigma);
77  else m_Fitter->distanceToHit(*i, error, sigma);
78  //B2INFO("BKLMTrackFinder" << " Error: " << error << " Sigma: " << sigma);
79  if (sigma < 5.0) {
80  track.push_back(*i);
81  }
82  }
83  }
84 
85  if (track.size() < 3) 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 (i = track.begin(); i != track.end(); ++i) {
94  hitLayers.push_back((*i)->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 }
Belle2::BKLMTrackFitter::distanceToHit
double distanceToHit(BKLMHit2d *hit, double &error, double &sigma)
Distance from track to a hit in the plane of the module.
Definition: BKLMTrackFitter.cc:158
Belle2::BKLMTrackFitter
track fitting procedure
Definition: BKLMTrackFitter.h:39
Belle2::BKLMTrackFinder::filter
bool filter(const std::list< BKLMHit2d * > &seed, std::list< BKLMHit2d * > &hits, std::list< BKLMHit2d * > &track)
find associated hits and do fit.
Definition: BKLMTrackFinder.cc:48
Belle2::BKLMTrackFitter::setGlobalFit
void setGlobalFit(bool localOrGlobal)
set the fitting mode, local system or global system
Definition: BKLMTrackFitter.h:129
Belle2::BKLMTrackFinder::BKLMTrackFinder
BKLMTrackFinder()
Default constructor.
Definition: BKLMTrackFinder.cc:25
Belle2::BKLMTrackFinder::registerFitter
void registerFitter(BKLMTrackFitter *fitter)
Register a fitter if not constructed with one.
Definition: BKLMTrackFinder.cc:41
Belle2::BKLMTrackFinder::m_Fitter
BKLMTrackFitter * m_Fitter
pointer to the fitter
Definition: BKLMTrackFinder.h:65
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::BKLMTrackFinder::m_globalFit
bool m_globalFit
do fit in the local system or global system false: local sys; true: global sys.
Definition: BKLMTrackFinder.h:68
Belle2::BKLMTrackFinder::~BKLMTrackFinder
~BKLMTrackFinder()
Destructor.
Definition: BKLMTrackFinder.cc:36
Belle2::BKLMTrackFitter::globalDistanceToHit
double globalDistanceToHit(BKLMHit2d *hit, double &error, double &sigma)
Distance from track to a hit in the global system.
Definition: BKLMTrackFitter.cc:236
Belle2::BKLMTrackFitter::fit
double fit(std::list< BKLMHit2d * > &listTrackPoint)
do fit and returns chi square of the fit.
Definition: BKLMTrackFitter.cc:63