Belle II Software  release-06-01-15
BKLMTrackingModule.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/BKLMTrackingModule.h>
11 
12 /* KLM headers. */
13 #include <klm/bklm/geometry/GeometryPar.h>
14 #include <klm/bklm/modules/bklmTracking/BKLMTrackFinder.h>
15 
16 /* Belle 2 headers. */
17 #include <framework/dataobjects/EventMetaData.h>
18 #include <framework/datastore/StoreObjPtr.h>
19 #include <framework/logging/Logger.h>
20 
21 using namespace std;
22 using namespace Belle2;
23 using namespace Belle2::bklm;
24 using namespace CLHEP;
25 
26 REG_MODULE(BKLMTracking)
27 
29  m_effiYX(nullptr),
30  m_effiYZ(nullptr),
31  m_passYX(nullptr),
32  m_totalYX(nullptr),
33  m_passYZ(nullptr),
34  m_totalYZ(nullptr),
35  m_runTotalEvents(0),
36  m_runTotalEventsWithTracks(0)
37 {
38  for (int i = 0; i < 8; ++i) {
39  m_total[0][i] = nullptr;
40  m_total[1][i] = nullptr;
41  m_pass[0][i] = nullptr;
42  m_pass[1][i] = nullptr;
43  m_effiVsLayer[0][i] = nullptr;
44  m_effiVsLayer[1][i] = nullptr;
45  }
46  setDescription("Perform standard-alone straight line tracking for BKLM");
47  addParam("MatchToRecoTrack", m_MatchToRecoTrack, "[bool], whether match BKLMTrack to RecoTrack; (default is false)", false);
48  addParam("MaxAngleRequired", m_maxAngleRequired,
49  "[degree], match BKLMTrack to RecoTrack; angle between them is required to be smaller than (default 10)", double(10.0));
50  addParam("fitGlobalBKLMTrack", m_globalFit,
51  "[bool], do the BKLMTrack fitting in global system (multi-sectors track) or local system (sector by sector) (default is false, local sys.)",
52  false);
53  addParam("StudyEffiMode", m_studyEffi, "[bool], run in efficieny study mode (default is false)", false);
54  addParam("outputName", m_outPath , "[string], output file name containing efficiencies plots ", string("bklmEffi.root"));
55 }
56 
57 BKLMTrackingModule::~BKLMTrackingModule()
58 {
59 
60 }
61 
62 void BKLMTrackingModule::initialize()
63 {
64 
65  hits2D.isRequired();
66  m_storeTracks.registerInDataStore();
67  m_storeTracks.registerRelationTo(hits2D);
68  m_storeTracks.registerRelationTo(recoTracks);
69  recoHitInformation.registerRelationTo(hits2D);
70  hits2D.registerRelationTo(recoTracks);
71 
72  if (m_studyEffi)
73  B2INFO("BKLMTrackingModule:: this module is running in efficiency study mode!");
74 
75  m_file = new TFile(m_outPath.c_str(), "recreate");
76  TString hname;
77  std::string labelFB[2] = {"BB", "BF"};
78  int Nbin = 16;
79  float gmin = -350;
80  float gmax = 350;
81  int gNbin = 150;
82 
83  m_totalYX = new TH2F("totalYX", " denominator Y vs. X", gNbin, gmin, gmax, gNbin, gmin, gmax);
84  m_passYX = new TH2F("passYX", " numerator Y vs. X", gNbin, gmin, gmax, gNbin, gmin, gmax);
85  m_totalYZ = new TH2F("totalYZ", " denominator Y vs. Z", gNbin, gmin, gmax, gNbin, gmin, gmax);
86  m_passYZ = new TH2F("passYZ", " numerator Y vs. Z", gNbin, gmin, gmax, gNbin, gmin, gmax);
87  m_effiYX = new TH2F("effiYX", " effi. Y vs. X", gNbin, gmin, gmax, gNbin, gmin, gmax);
88  m_effiYZ = new TH2F("effiYZ", " effi. Y vs. X", gNbin, gmin, gmax, gNbin, gmin, gmax);
89  m_effiYX->GetXaxis()->SetTitle("x (cm)");
90  m_effiYX->GetYaxis()->SetTitle("y (cm)");
91  m_effiYZ->GetXaxis()->SetTitle("z (cm)");
92  m_effiYZ->GetYaxis()->SetTitle("y (cm)");
93  for (int iF = 0; iF < 2; iF++) {
94  for (int iS = 0; iS < 8; iS++) {
95  hname.Form("effi_%s%i", labelFB[iF].c_str(), iS);
96  m_effiVsLayer[iF][iS] = new TEfficiency(hname, hname, Nbin, 0, 16);
97  hname.Form("total_%s%i", labelFB[iF].c_str(), iS);
98  m_total[iF][iS] = new TH1F(hname, hname, Nbin, 0, 16);
99  hname.Form("pass_%s%i", labelFB[iF].c_str(), iS);
100  m_pass[iF][iS] = new TH1F(hname, hname, Nbin, 0, 16);
101  }
102  }
103 
104 }
105 
106 void BKLMTrackingModule::beginRun()
107 {
108  StoreObjPtr<EventMetaData> eventMetaData("EventMetaData", DataStore::c_Event);
109  m_runNumber.push_back((int)eventMetaData->getRun());
110  m_runTotalEvents = 0;
111  m_runTotalEventsWithTracks = 0;
112 }
113 
114 void BKLMTrackingModule::event()
115 {
116  m_storeTracks.clear();
117  bool thereIsATrack = false;
118 
119  if (!m_studyEffi) {
120  runTracking(0, -1, -1, -1);
121  if (m_storeTracks.getEntries() > 0)
122  thereIsATrack = true;
123  } else {
124  for (int iSection = 0; iSection < 2; iSection++) {
125  for (int iSector = 0; iSector < 8; iSector++) {
126  for (int iLayer = 0; iLayer < 15; iLayer++) {
127  runTracking(1, iSection, iSector , iLayer);
128  if (m_storeTracks.getEntries() > 0)
129  thereIsATrack = true;
130  generateEffi(iSection, iSector, iLayer);
131  //clear tracks so prepare for the next layer efficieny study
132  m_storeTracks.clear();
133  }
134  }
135  }
136  }
137 
138  m_runTotalEvents++;
139  if (thereIsATrack)
140  m_runTotalEventsWithTracks++;
141 }
142 
143 void BKLMTrackingModule::runTracking(int mode, int iSection, int iSector, int iLayer)
144 {
145  m_storeTracks.clear();
146  //std::list<BKLMTrack*> tracks;
147  //tracks.clear();
148 
149  BKLMTrackFitter* m_fitter = new BKLMTrackFitter();
150  BKLMTrackFinder* m_finder = new BKLMTrackFinder();
151  m_finder->setGlobalFit(m_globalFit);
152  if (mode == 1)
153  m_finder->setGlobalFit(false);
154  m_finder->registerFitter(m_fitter);
155 
156  if (hits2D.getEntries() < 1)
157  return;
158  if (mode == 1) { //efficieny study
159  for (int j = 0; j < hits2D.getEntries(); j++) {
160  hits2D[j]->isOnStaTrack(false);
161  }
162  }
163 
164  for (int hi = 0; hi < hits2D.getEntries() - 1; ++hi) {
165 
166  if (mode == 1 && isLayerUnderStudy(iSection, iSector, iLayer, hits2D[hi]))
167  continue;
168  if (mode == 1 && !isSectorUnderStudy(iSection, iSector, hits2D[hi]))
169  continue;
170  if (hits2D[hi]->isOnStaTrack())
171  continue;
172  if (hits2D[hi]->isOutOfTime())
173  continue;
174  for (int hj = hi + 1; hj < hits2D.getEntries(); ++hj) {
175 
176  if (hits2D[hj]->isOnStaTrack())
177  continue;
178  if (hits2D[hj]->isOutOfTime())
179  continue;
180  if (!m_globalFit && !sameSector(hits2D[hi], hits2D[hj]))
181  continue;
182  if (sameSector(hits2D[hi], hits2D[hj]) && abs(hits2D[hi]->getLayer() - hits2D[hj]->getLayer()) < 3)
183  continue;
184 
185  std::list<BKLMHit2d*> sectorHitList;
186  //sectorHitList.push_back(hits2D[hi]);
187  //sectorHitList.push_back(hits2D[hj]);
188 
189  std::list<BKLMHit2d*> seed;
190  seed.push_back(hits2D[hi]);
191  seed.push_back(hits2D[hj]);
192 
193  for (int ho = 0; ho < hits2D.getEntries(); ++ho) {
194 
195  // Exclude seed hits.
196  if (ho == hi || ho == hj)
197  continue;
198  if (mode == 1 && isLayerUnderStudy(iSection, iSector, iLayer, hits2D[hj]))
199  continue;
200  if (mode == 1 && !isSectorUnderStudy(iSection, iSector, hits2D[hj]))
201  continue;
202  if (hits2D[ho]->isOnStaTrack())
203  continue;
204  if (!m_globalFit && !sameSector(hits2D[ho], hits2D[hi]))
205  continue;
206  // if (hits2D[ho]->getLayer() == hits2D[hi]->getLayer() || hits2D[ho]->getLayer() == hits2D[hj]->getLayer())
207  // continue;
208  if (hits2D[ho]->isOutOfTime())
209  continue;
210  sectorHitList.push_back(hits2D[ho]);
211  }
212 
213  /* Require at least four hits (minimum for good track, already two as seed, so here we require 2) but
214  * no more than 60 (most likely noise, 60 would be four good tracks).
215  */
216  if (sectorHitList.size() < 2 || sectorHitList.size() > 60)
217  continue;
218 
219  std::list<BKLMHit2d*> m_hits;
220  if (m_finder->filter(seed, sectorHitList, m_hits)) {
221  BKLMTrack* m_track = m_storeTracks.appendNew();
222  m_track->setTrackParam(m_fitter->getTrackParam());
223  m_track->setTrackParamErr(m_fitter->getTrackParamErr());
224  m_track->setLocalTrackParam(m_fitter->getTrackParamSector());
225  m_track->setLocalTrackParamErr(m_fitter->getTrackParamSectorErr());
226  m_track->setTrackChi2(m_fitter->getChi2());
227  m_track->setNumHitOnTrack(m_fitter->getNumHit());
228  m_track->setIsValid(m_fitter->isValid());
229  m_track->setIsGood(m_fitter->isGood());
230  std::list<BKLMHit2d*>::iterator j;
231  m_hits.sort(sortByLayer);
232  for (j = m_hits.begin(); j != m_hits.end(); ++j) {
233  (*j)->isOnStaTrack(true);
234  m_track->addRelationTo((*j));
235  }
236  //tracks.push_back(m_track);
237  //m_track->getTrackParam().Print();
238  //m_track->getTrackParamErr().Print();
239  //match BKLMTrack to RecoTrack
240  if (mode == 0) {
241  RecoTrack* closestTrack = nullptr;
242  if (m_MatchToRecoTrack) {
243  if (findClosestRecoTrack(m_track, closestTrack)) {
244  m_track->addRelationTo(closestTrack);
245  for (j = m_hits.begin(); j != m_hits.end(); ++j) {
246  unsigned int sortingParameter = closestTrack->getNumberOfTotalHits();
247  closestTrack->addBKLMHit((*j), sortingParameter, RecoHitInformation::OriginTrackFinder::c_LocalTrackFinder);
248  }
249  }
250  }//end match
251  }
252  }
253  }
254  }
255 
256  delete m_fitter;
257  delete m_finder;
258 
259 }
260 
261 void BKLMTrackingModule::endRun()
262 {
263  m_totalEvents.push_back(m_runTotalEvents);
264  m_totalEventsWithTracks.push_back(m_runTotalEventsWithTracks);
265 }
266 
267 void BKLMTrackingModule::terminate()
268 {
269  for (long unsigned int i = 0; i < m_runNumber.size(); i++) {
270  float ratio = (float)m_totalEventsWithTracks.at(i) / (float)m_totalEvents.at(i);
271  B2INFO("BKLMTrackingModule:: run " << m_runNumber.at(i) << " --> " << ratio * 100 << "% of events has 1+ BKLMTracks");
272  }
273 
274  m_file->cd();
275  for (int iF = 0; iF < 2; iF++) {
276  for (int iS = 0; iS < 8; iS++) {
277  m_effiVsLayer[iF][iS]->Write();
278  m_total[iF][iS]->Write();
279  m_pass[iF][iS]->Write();
280  }
281  }
282 
283  for (int i = 0; i < m_totalYX->GetNbinsX(); i++) {
284  for (int j = 0; j < m_totalYX->GetNbinsY(); j++) {
285  float num = m_passYX->GetBinContent(i + 1, j + 1);
286  float denom = m_totalYX->GetBinContent(i + 1, j + 1);
287  if (num > 0) {
288  m_effiYX->SetBinContent(i + 1, j + 1, num / denom);
289  m_effiYX->SetBinError(i + 1, j + 1, sqrt(num * (denom - num) / (denom * denom * denom)));
290  } else {
291  m_effiYX->SetBinContent(i + 1, j + 1, 0);
292  m_effiYX->SetBinError(i + 1, j + 1, 0);
293  }
294 
295  num = m_passYZ->GetBinContent(i + 1, j + 1);
296  denom = m_totalYZ->GetBinContent(i + 1, j + 1);
297  if (num > 0) {
298  m_effiYZ->SetBinContent(i + 1, j + 1, num / denom);
299  m_effiYZ->SetBinError(i + 1, j + 1, sqrt(num * (denom - num) / (denom * denom * denom)));
300  } else {
301  m_effiYZ->SetBinContent(i + 1, j + 1, 0);
302  m_effiYZ->SetBinError(i + 1, j + 1, 0);
303  }
304  }
305  }
306 
307  m_totalYX->Write();
308  m_passYX->Write();
309  m_totalYZ->Write();
310  m_passYZ->Write();
311  m_effiYX->Write();
312  m_effiYZ->Write();
313  m_file->Close();
314 
315 }
316 
317 bool BKLMTrackingModule::sameSector(BKLMHit2d* hit1, BKLMHit2d* hit2)
318 {
319  if (hit1->getSection() == hit2->getSection() && hit1->getSector() == hit2->getSector())
320  return true;
321  else return false;
322 }
323 
324 
325 bool BKLMTrackingModule::findClosestRecoTrack(BKLMTrack* bklmTrk, RecoTrack*& closestTrack)
326 {
327 
328  //StoreArray<RecoTrack> recoTracks;
329  RelationVector<BKLMHit2d> bklmHits = bklmTrk->getRelationsTo<BKLMHit2d> ();
330 
331  if (bklmHits.size() < 1) {
332  B2INFO("BKLMTrackingModule::something is wrong! there is BKLMTrack but no bklmHits");
333  return false;
334  }
335  if (recoTracks.getEntries() < 1) {
336  B2INFO("BKLMTrackingModule::there is no recoTrack");
337  return false;
338  }
339  double oldDistance = INFINITY;
340  double oldAngle = INFINITY;
341  closestTrack = nullptr;
342  //TVector3 poca = TVector3(0, 0, 0);
343  TVector3 firstBKLMHitPosition(0, 0, 0);
344  //bklmHits are already sorted by layer
345  //possible two hits in one layer?
346  firstBKLMHitPosition = bklmHits[0]->getGlobalPosition();
347 
348  TMatrixDSym cov(6);
349  TVector3 pos(0, 0, 0);
350  TVector3 mom(0, 0, 0);
351 
352  for (RecoTrack& track : recoTracks) {
353  try {
354  genfit::MeasuredStateOnPlane state = track.getMeasuredStateOnPlaneFromLastHit();
356  state.getPosMomCov(pos, mom, cov);
357  if (mom.Y() * pos.Y() < 0)
358  { state = track.getMeasuredStateOnPlaneFromFirstHit(); }
359  //pos.Print(); mom.Print();
360  const TVector3& distanceVec = firstBKLMHitPosition - pos;
361  state.extrapolateToPoint(firstBKLMHitPosition);
362  double newDistance = distanceVec.Mag2();
363  // two points on the track, (x1,TrkParam[0]+TrkParam[1]*x1, TrkParam[2]+TrkParam[3]*x1),
364  // and (x2,TrkParam[0]+TrkParam[1]*x2, TrkParam[2]+TrkParam[3]*x2),
365  // then we got the vector (x2-x1,....), that is same with (1,TrkParam[1], TrkParam[3]).
366  TVector3 trkVec(1, bklmTrk->getTrackParam()[1], bklmTrk->getTrackParam()[3]);
367  double angle = trkVec.Angle(mom);
368  // choose closest distance or minimum open angle ?
369  // overwrite old distance
370  if (newDistance < oldDistance) {
371  oldDistance = newDistance;
372  closestTrack = &track;
373  //poca = pos;
374  oldAngle = angle;
375  }
376 
377  /* if(angle<oldAngle)
378  {
379  oldAngle=angle;
380  closestTrack = &track;
381  }
382  */
383  } catch (genfit::Exception& e) {
384  }// try
385  }
386 
387  // can not find matched RecoTrack
388  // problem here is the errors of the track parameters are not considered!
389  // best way is the positon or vector direction are required within 5/10 sigma ?
390  if (oldAngle > m_maxAngleRequired)
391  return false;
392  // found matched RecoTrack
393  else return true;
394 }
395 
396 void BKLMTrackingModule::generateEffi(int iSection, int iSector, int iLayer)
397 {
398 
399  set<int> m_pointUsed;
400  m_pointUsed.clear();
401  if (m_storeTracks.getEntries() < 1)
402  return;
403 
404  for (int it = 0; it < m_storeTracks.getEntries(); it++) {
405  //if(m_storeTracks[it]->getTrackChi2()>10) continue;
406  //if(m_storeTracks[it]->getNumHitOnTrack()<6) continue;
407  int cnt1 = 0;
408  int cnt2 = 0;
409 
410  RelationVector<BKLMHit2d> relatedHit2D = m_storeTracks[it]->getRelationsTo<BKLMHit2d>();
411  for (const BKLMHit2d& hit2D : relatedHit2D) {
412  if (hit2D.getLayer() > iLayer + 1)
413  cnt1++;
414  if (hit2D.getLayer() < iLayer + 1)
415  cnt2++;
416  }
417 
418  if (iLayer != 0 && cnt2 < 1)
419  return;
420  if (iLayer != 14 && cnt1 < 1)
421  return;
422  m_GeoPar = GeometryPar::instance();
423  const bklm::Module* module = m_GeoPar->findModule(iSection, iSector + 1, iLayer + 1);
424  int minPhiStrip = module->getPhiStripMin();
425  int maxPhiStrip = module->getPhiStripMax();
426  int minZStrip = module->getZStripMin();
427  int maxZStrip = module->getZStripMax();
428 
429  CLHEP::Hep3Vector local = module->getLocalPosition(minPhiStrip, minZStrip);
430  CLHEP::Hep3Vector local2 = module->getLocalPosition(maxPhiStrip, maxZStrip);
431  float minLocalY, maxLocalY;
432  float minLocalZ, maxLocalZ;
433  if (local[1] > local2[1]) {
434  maxLocalY = local[1];
435  minLocalY = local2[1];
436  } else {
437  maxLocalY = local2[1];
438  minLocalY = local[1];
439  }
440  if (local[2] > local2[2]) {
441  maxLocalZ = local[2];
442  minLocalZ = local2[2];
443  } else {
444  maxLocalZ = local2[2];
445  minLocalZ = local[2];
446  }
447 
448  TVectorD trkPar = m_storeTracks[it]->getLocalTrackParam();
449 
450  //first layer is the reference layer
451  //if (iSection == 1 && (iSector + 1 ) == 5)
452  // cout<<" local X "<<m_GeoPar->getActiveMiddleRadius(iSection, iSector + 1, iLayer + 1) - m_GeoPar->getActiveMiddleRadius(iSection, iSector + 1, 1) << endl;
453  float reflocalX = fabs(m_GeoPar->getActiveMiddleRadius(iSection, iSector + 1,
454  iLayer + 1) - m_GeoPar->getActiveMiddleRadius(iSection, iSector + 1, 1));
455  //if (iSection == 1 && (iSector + 1 ) == 5)
456  // cout<<" local X "<<m_GeoPar->getActiveMiddleRadius(iSection, iSector + 1, iLayer + 1) - m_GeoPar->getActiveMiddleRadius(iSection, iSector + 1, 1) << endl;
457 
458  float reflocalY = trkPar[0] + trkPar[1] * reflocalX;
459  float reflocalZ = trkPar[2] + trkPar[3] * reflocalX;
460 
461  //reference module is the first layer
462  //module = m_GeoPar->findModule(iSection, iSector + 1, 1);
463  reflocalX = 0.0;
464  Hep3Vector reflocal(reflocalX, reflocalY, reflocalZ);
465  //Hep3Vector global(localX, localY, localZ);
466  Hep3Vector global(0, 0, 0);
467  module = m_GeoPar->findModule(iSection, iSector + 1, iLayer + 1);
468  global = module->localToGlobal(reflocal);
469  //float localX = module->globalToLocal(global)[0];
470  float localY = module->globalToLocal(global)[1];
471  float localZ = module->globalToLocal(global)[2];
472 
473 
474  //geometry cut
475  if (localY > minLocalY && localY < maxLocalY && localZ > minLocalZ && localZ < maxLocalZ) {
476 
477  bool m_iffound = false;
478  m_total[iSection][iSector]->Fill(iLayer + 1);
479  m_totalYX->Fill(global[0], global[1]);
480  m_totalYZ->Fill(global[2], global[1]);
481 
482  for (int he = 0; he < hits2D.getEntries(); ++he) {
483  if (!isLayerUnderStudy(iSection, iSector, iLayer, hits2D[he]))
484  continue;
485  if (hits2D[he]->isOutOfTime())
486  continue;
487  //if alreday used, skip
488  if (m_pointUsed.find(he) != m_pointUsed.end())
489  continue;
490 
491  double error, sigma;
492  float distance = distanceToHit(m_storeTracks[it], hits2D[he], error, sigma);
493 
494  if (distance < 10 && sigma < 5)
495  m_iffound = true;
496  if (m_iffound) {
497  m_pointUsed.insert(he);
498  //global[0] = hits2D[he]->getGlobalPosition()[0];
499  //global[1] = hits2D[he]->getGlobalPosition()[1];
500  //global[2] = hits2D[he]->getGlobalPosition()[2];
501  m_pass[iSection][iSector]->Fill(iLayer + 1);
502  m_passYX->Fill(global[0], global[1]);
503  m_passYZ->Fill(global[2], global[1]);
504  break;
505  }
506  }
507 
508  m_effiVsLayer[iSection][iSector]->Fill(m_iffound, iLayer + 1);
509  //cout<<" global "<<global[0]<<", "<< global[1]<<" "<<global[2]<<endl;
510  //m_effiYX->Fill(m_iffound, global[1], global[0]);
511  //m_effiYZ->Fill(m_iffound, global[1], global[2]);
512  //m_effiYX->SetPassedHistogram(*m_passYX);
513  //m_effiYX->SetTotalHistogram(*m_totalYX);
514  //m_effiYZ->SetPassedHistogram(*m_passYZ);
515  //m_effiYZ->SetTotalHistogram(*m_totalYZ);
516  }
517  }//end of loop tracks
518 
519 }
520 
521 bool BKLMTrackingModule::sortByLayer(BKLMHit2d* hit1, BKLMHit2d* hit2)
522 {
523 
524  return hit1->getLayer() < hit2->getLayer();
525 
526 }
527 
528 bool BKLMTrackingModule::isLayerUnderStudy(int section, int iSector, int iLayer, BKLMHit2d* hit)
529 {
530  if (hit->getSection() == section && hit->getSector() == iSector + 1 && hit->getLayer() == iLayer + 1)
531  return true;
532  else return false;
533 }
534 
535 bool BKLMTrackingModule::isSectorUnderStudy(int section, int iSector, BKLMHit2d* hit)
536 {
537  if (hit->getSection() == section && hit->getSector() == iSector + 1)
538  return true;
539  else return false;
540 }
541 
542 double BKLMTrackingModule::distanceToHit(BKLMTrack* track, BKLMHit2d* hit,
543  double& error,
544  double& sigma)
545 {
546 
547  double x, y, z, dy, dz;
548 
549  error = DBL_MAX;
550  sigma = DBL_MAX;
551 
552  TVectorD m_SectorPar = track->getLocalTrackParam();
553 
554  m_GeoPar = GeometryPar::instance();
555  const Belle2::bklm::Module* refMod = m_GeoPar->findModule(hit->getSection(), hit->getSector(), 1);
556  const Belle2::bklm::Module* corMod = m_GeoPar->findModule(hit->getSection(), hit->getSector(), hit->getLayer());
557 
558  CLHEP::Hep3Vector globalPos(hit->getGlobalPosition()[0], hit->getGlobalPosition()[1], hit->getGlobalPosition()[2]);
559  CLHEP::Hep3Vector local = refMod->globalToLocal(globalPos);
560 
561  x = local[0] ;
562 
563  y = m_SectorPar[ 0 ] + x * m_SectorPar[ 1 ];
564  z = m_SectorPar[ 2 ] + x * m_SectorPar[ 3 ];
565 
566  dy = y - local[1];
567  dz = z - local[2];
568 
569  double distance = sqrt(dy * dy + dz * dz);
570 
571  double hit_localPhiErr = corMod->getPhiStripWidth() / sqrt(12);
572  double hit_localZErr = corMod->getZStripWidth() / sqrt(12);
573 
574  //error from tracking is ignored here
575  error = sqrt(pow(hit_localPhiErr, 2) +
576  pow(hit_localZErr, 2));
577 
578  if (error != 0.0) {
579  sigma = distance / error;
580  } else {
581  sigma = DBL_MAX;
582  }
583 
584  return (distance);
585 
586 }
Store one BKLM strip hit as a ROOT object.
Definition: BKLMHit2d.h:32
int getLayer() const
Get layer number.
Definition: BKLMHit2d.h:80
int getSection() const
Get section number.
Definition: BKLMHit2d.h:66
int getSector() const
Get sector number.
Definition: BKLMHit2d.h:73
track finding procedure
bool filter(const std::list< BKLMHit2d * > &seed, std::list< BKLMHit2d * > &hits, std::list< BKLMHit2d * > &track)
find associated hits and do fit.
void registerFitter(BKLMTrackFitter *fitter)
Register a fitter if not constructed with one.
void setGlobalFit(bool localOrGlobal)
set the fitting mode, local system or global system
track fitting procedure
CLHEP::HepVector getTrackParamSector()
Get track parameters in the sector locan system, y = p0 + p1 * x, z = p2 + p3 *x, where the first lay...
float getChi2()
Chi square of the fit.
bool isGood()
Is fit good.
CLHEP::HepSymMatrix getTrackParamSectorErr()
Get invariance matrix of track parameters in the sector local system, where the first layer of the se...
int getNumHit()
number of the hits on this track
CLHEP::HepSymMatrix getTrackParamErr()
Get invariance matrix of track parameters in the global system.
CLHEP::HepVector getTrackParam()
Get track parameters in the global system. y = p0 + p1 * x; y = p2 + p3 * z, if in local sector fit m...
bool isValid()
Is fit valid.
Store one BKLM Track as a ROOT object.
Definition: BKLMTrack.h:35
void setIsValid(const bool valid)
set the fit valid status
Definition: BKLMTrack.h:120
void setTrackChi2(const float chi2)
Set the fitted chi2 of the track.
Definition: BKLMTrack.h:108
void setLocalTrackParam(const CLHEP::HepVector &trkPar)
Set track parameters in the sector local system, where the first layer of the sector is used as refer...
Definition: BKLMTrack.cc:140
void setTrackParamErr(const CLHEP::HepSymMatrix &trkParErr)
Set invariance matrix of track parameters in the global system.
Definition: BKLMTrack.cc:130
void setNumHitOnTrack(const int NumHit)
Set the number of 2d hits on the track.
Definition: BKLMTrack.h:114
TVectorD getTrackParam()
Get track parameters in the global system. y = p0 + p1 * x; z = p2 + p3 * x.
Definition: BKLMTrack.cc:71
void setIsGood(const bool good)
set the fit good status
Definition: BKLMTrack.h:126
void setLocalTrackParamErr(const CLHEP::HepSymMatrix &trkParErr)
Set invariance matrix of track parameters in the sector local system, where the first layer of the se...
Definition: BKLMTrack.cc:150
void setTrackParam(const CLHEP::HepVector &trkPar)
Set track parameters in the global system. y = p0 + p1 * x; z = p2 + p3 * x.
Definition: BKLMTrack.cc:120
This module perform straight line track finding and fitting for BKLM.
Base class for Modules.
Definition: Module.h:72
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:76
bool addBKLMHit(const UsedBKLMHit *bklmHit, const unsigned int sortingParameter, OriginTrackFinder foundByTrackFinder=OriginTrackFinder::c_undefinedTrackFinder)
Adds a bklm hit with the given information to the reco track.
Definition: RecoTrack.h:281
unsigned int getNumberOfTotalHits() const
Return the number of cdc + svd + pxd + bklm + eklm hits.
Definition: RecoTrack.h:431
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from this object to another store array.
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:95
Define the geometry of a BKLM module Each sector [octant] contains Modules.
Definition: Module.h:76
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:340
double getPhiStripWidth() const
Get phi-strip width.
Definition: Module.h:137
double getZStripWidth() const
Get z-strip width.
Definition: Module.h:155
Exception class for error handling in GENFIT (provides storage for diagnostic information)
Definition: Exception.h:48
#StateOnPlane with additional covariance matrix.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.