CbmRoot
CbmMuchFindVectors.cxx
Go to the documentation of this file.
1 
5 #include "CbmMuchFindVectors.h"
6 #include "CbmMuchDigiMatch.h"
7 #include "CbmMuchMergeVectors.h"
8 #include "CbmMuchModule.h"
9 #include "CbmMuchPoint.h"
10 #include "CbmMuchStation.h"
11 #include "CbmMuchTrack.h"
12 
13 #include "FairEventHeader.h"
14 #include "FairRootManager.h"
15 
16 #include <TClonesArray.h>
17 #include <TGeoManager.h>
18 #include <TMath.h>
19 #include <TMatrixD.h>
20 #include <TMatrixFLazy.h>
21 #include <TVectorD.h>
22 
23 #include <iostream>
24 
25 using std::cout;
26 using std::endl;
27 using std::map;
28 using std::multimap;
29 using std::pair;
30 using std::set;
31 using std::vector;
32 
33 //FILE *lun = fopen("chi2.dat","w");
34 
35 // ----- Default constructor -------------------------------------------
37  : FairTask("MuchFindVectors")
38  , fGeoScheme(CbmMuchGeoScheme::Instance())
39  , fTrackArray(NULL)
40  , fNofTracks(0)
41  , fHits(NULL)
42  , fPoints(NULL)
43  , fDigiMatches(NULL)
44  , fStatFirst(-1)
45  , fErrU(-1.0)
46  , fDiam(0.0)
47  , fCutChi2(24.0)
48  , // chi2/ndf=6 for 8 hits
49  //fCutChi2(20.0), // chi2/ndf=5 for 8 hits
50  fMinHits(10) {}
51 // -------------------------------------------------------------------------
52 
53 // ----- Destructor ----------------------------------------------------
55  fTrackArray->Delete();
56  for (Int_t i = 0; i < fgkStat; ++i) {
57  Int_t nVecs = fVectors[i].size();
58  for (Int_t j = 0; j < nVecs; ++j)
59  delete fVectors[i][j];
60  //nVecs = fVectorsHigh[i].size();
61  //for (Int_t j = 0; j < nVecs; ++j) delete fVectorsHigh[i][j];
62  }
63  for (map<Int_t, TDecompLU*>::iterator it = fLus.begin(); it != fLus.end();
64  ++it)
65  delete it->second;
66 }
67 // -------------------------------------------------------------------------
68 
69 // ----- Public method Init (abstract in base class) --------------------
71 
72  // Get and check FairRootManager
73  FairRootManager* ioman = FairRootManager::Instance();
74  if (ioman == NULL) Fatal("Init", "RootManager not instantiated!");
75 
76  // Create and register MuchTrack array (if necessary)
77  fTrackArray = static_cast<TClonesArray*>(ioman->GetObject("MuchVector"));
78  if (fTrackArray == NULL) {
79  fTrackArray = new TClonesArray("CbmMuchTrack", 100);
80  ioman->Register("MuchVector", "Much", fTrackArray, kTRUE);
81  }
82 
83  CbmMuchFindHitsStraws* hitFinder =
84  (CbmMuchFindHitsStraws*) FairRun::Instance()->GetTask(
85  "CbmMuchFindHitsStraws");
86  //if (hitFinder == NULL) Fatal("Init", "CbmMuchFindHitsStraws is not run!");
87  if (hitFinder == NULL) return kSUCCESS; // no straws
88 
89  fDiam = hitFinder->GetDiam(0);
90 
91  fHits = static_cast<TClonesArray*>(ioman->GetObject("MuchStrawHit"));
92  fPoints = static_cast<TClonesArray*>(ioman->GetObject("MuchPoint"));
93  fDigiMatches =
94  static_cast<TClonesArray*>(ioman->GetObject("MuchStrawDigiMatch"));
95 
96  // Find first straw station and get some geo constants
97  Int_t nSt = fGeoScheme->GetNStations();
98  for (Int_t i = 0; i < nSt; ++i) {
100  CbmMuchModule* mod = fGeoScheme->GetModule(i, 0, 0, 0);
101  if (mod->GetDetectorType() == 2) {
102  if (fStatFirst < 0)
104  //cout << " First station: " << fStatFirst << endl;
105  Int_t nLays = st->GetNLayers();
106  fRmin[i - fStatFirst] = st->GetRmin();
107  fRmax[i - fStatFirst] = st->GetRmax();
108  for (Int_t lay = 0; lay < nLays; ++lay) {
109  CbmMuchLayer* layer = st->GetLayer(lay);
110  Double_t phi = hitFinder->GetPhi(lay);
111  for (Int_t iside = 0; iside < 2; ++iside) {
112  CbmMuchLayerSide* side = layer->GetSide(iside);
113  Int_t plane = lay * 2 + iside;
114  if (plane == 0) fZ0[i - fStatFirst] = side->GetZ();
115  //plane += (i - fStatFirst) * fgkPlanes;
116  fDz[plane] = side->GetZ();
117  fCosa[plane] = TMath::Cos(phi);
118  fSina[plane] = TMath::Sin(phi);
119  if (lay) {
120  fDtubes[i - fStatFirst][lay - 1] =
121  fRmax[i - fStatFirst]
122  * TMath::Tan(TMath::ASin(fSina[plane])
123  - TMath::ASin(fSina[plane - 2]));
124  fDtubes[i - fStatFirst][lay - 1] =
125  TMath::Abs(fDtubes[i - fStatFirst][lay - 1]) / fDiam + 10;
126  }
127  }
128  }
129  }
130  }
131  for (Int_t i = fgkPlanes - 1; i >= 0; --i) {
132  fDz[i] -= fDz[0];
133  //cout << fDz[i] << " ";
134  }
135  //cout << endl;
136 
137  // Get absorbers
138  Double_t dzAbs[9] = {0}, zAbs[9] = {0}, radlAbs[9] = {0}, xyzl[3] = {0},
139  xyzg[3] = {0};
140  Int_t nAbs = 0;
141  TGeoVolume* vol = 0x0;
142  for (Int_t i = 1; i < 10; ++i) {
143  TString abso = "muchabsorber0";
144  abso += i;
145  vol = gGeoManager->GetVolume(abso);
146  if (vol == 0x0) break;
147  TString path = "/cave_1/much_0/";
148  path += abso;
149  path += "_0";
150  gGeoManager->cd(path);
151  gGeoManager->LocalToMaster(xyzl, xyzg);
152  zAbs[nAbs] = xyzg[2];
153  cout << vol->GetName() << " " << vol->GetShape()->GetName() << " "
154  << ((TGeoBBox*) vol->GetShape())->GetDZ() << endl;
155  //dzAbs[nAbs] = ((TGeoCone*) vol->GetShape())->GetDz();
156  dzAbs[nAbs] = ((TGeoBBox*) vol->GetShape())->GetDZ();
157  radlAbs[nAbs] = vol->GetMaterial()->GetRadLen();
158  fZabs0[nAbs][0] = zAbs[nAbs] - dzAbs[nAbs];
159  fZabs0[nAbs][1] = zAbs[nAbs] + dzAbs[nAbs];
160  fX0abs[nAbs] = radlAbs[nAbs];
161  ++nAbs;
162  }
163 
164  cout << " \n !!! MUCH Absorbers: " << nAbs << "\n Zbeg, Zend, X0:";
165  for (Int_t j = 0; j < nAbs; ++j)
166  cout << " " << fZabs0[j][0] << ", " << fZabs0[j][1] << ", " << fX0abs[j]
167  << ";";
168  cout << endl << endl;
169 
170  if (fStatFirst < 0) return kSUCCESS; // only GEM configuration
171 
172  ComputeMatrix(); // compute system matrices
173  return kSUCCESS;
174 }
175 // -------------------------------------------------------------------------
176 
177 // ----- SetParContainers -------------------------------------------------
179 // -------------------------------------------------------------------------
180 
181 // ----- Public method Exec --------------------------------------------
182 void CbmMuchFindVectors::Exec(Option_t* opt) {
183 
184  fTrackArray->Delete();
185  if (fStatFirst < 0) return; // only GEM configuration
186 
187  //FairTask *vecFinderGem = (FairTask*) FairRun::Instance()->GetTask("MuchFindVectorsGem");
188  //if (vecFinderGem == NULL) fTrackArray->Delete();
189 
190  for (Int_t i = 0; i < fgkStat; ++i) {
191  Int_t nVecs = fVectors[i].size();
192  for (Int_t j = 0; j < nVecs; ++j)
193  delete fVectors[i][j];
194  fVectors[i].clear();
195  //nVecs = fVectorsHigh[i].size();
196  //for (Int_t j = 0; j < nVecs; ++j) delete fVectorsHigh[i][j];
197  fVectorsHigh[i].clear();
198  }
199 
200  // Do all processing
201 
202  // Get hits
203  GetHits();
204 
205  // Build vectors
206  MakeVectors();
207 
208  // Remove vectors with wrong orientation
209  // (using empirical cuts for omega muons at 8 GeV)
210  CheckParams();
211 
212  // Match vectors from 2 stations
213  MatchVectors();
214 
215  // Go to the high resolution mode processing
216  Double_t err = fErrU;
217  //fErrU = 0.02;
218  fErrU = 0.04;
219  if (fErrU < 0.1) HighRes();
220  fErrU = err;
221 
222  // Remove clones
223  //RemoveClones();
224 
225  // Remove short tracks
226  RemoveShorts();
227 
228  // Store vectors
229  StoreVectors();
230 }
231 // -------------------------------------------------------------------------
232 
233 // ----- Public method Finish ------------------------------------------
235  fTrackArray->Clear();
236  for (Int_t i = 0; i < fgkStat; ++i) {
237  Int_t nVecs = fVectors[i].size();
238  for (Int_t j = 0; j < nVecs; ++j)
239  delete fVectors[i][j];
240  //nVecs = fVectorsHigh[i].size();
241  //for (Int_t j = 0; j < nVecs; ++j) delete fVectorsHigh[i][j];
242  }
243  for (map<Int_t, TDecompLU*>::iterator it = fLus.begin(); it != fLus.end();
244  ++it)
245  delete it->second;
246 }
247 // -------------------------------------------------------------------------
248 
249 // ----- Private method ComputeMatrix ----------------------------------
251  // Compute system matrices for different hit plane patterns
252 
253  Double_t cos2[fgkPlanes], sin2[fgkPlanes], sincos[fgkPlanes], dz2[fgkPlanes];
254  Bool_t onoff[fgkPlanes];
255 
256  for (Int_t i = 0; i < fgkPlanes; ++i) {
257  cos2[i] = fCosa[i] * fCosa[i];
258  sin2[i] = fSina[i] * fSina[i];
259  sincos[i] = fSina[i] * fCosa[i];
260  dz2[i] = fDz[i] * fDz[i];
261  onoff[i] = kTRUE;
262  }
263 
264  TMatrixD coef(4, 4);
265  Int_t pattMax = 1 << fgkPlanes, nDouble = 0, nTot = 0;
266 
267  // Loop over doublet patterns
268  for (Int_t ipat = 1; ipat < pattMax; ++ipat) {
269 
270  // Check if the pattern is valid:
271  // either all doublets are active or 3 the first ones (for high resolution mode)
272  nDouble = 0;
273  for (Int_t j = 0; j < fgkPlanes; j += 2)
274  if (ipat & (3 << j))
275  ++nDouble;
276  else
277  break;
278  if ((ipat & (3 << 6)) == 0) ++nDouble; // 3 doublets
279  if (nDouble < fgkPlanes / 2) continue;
280  ++nTot;
281 
282  for (Int_t j = 0; j < fgkPlanes; ++j)
283  onoff[j] = (ipat & (1 << j));
284 
285  coef = 0.0;
286  for (Int_t i = 0; i < fgkPlanes; ++i) {
287  if (!onoff[i]) continue;
288  coef(0, 0) += cos2[i];
289  coef(0, 1) += sincos[i];
290  coef(0, 2) += fDz[i] * cos2[i];
291  coef(0, 3) += fDz[i] * sincos[i];
292  }
293  for (Int_t i = 0; i < fgkPlanes; ++i) {
294  if (!onoff[i]) continue;
295  coef(1, 0) += sincos[i];
296  coef(1, 1) += sin2[i];
297  coef(1, 2) += fDz[i] * sincos[i];
298  coef(1, 3) += fDz[i] * sin2[i];
299  }
300  for (Int_t i = 0; i < fgkPlanes; ++i) {
301  if (!onoff[i]) continue;
302  coef(2, 0) += fDz[i] * cos2[i];
303  coef(2, 1) += fDz[i] * sincos[i];
304  coef(2, 2) += dz2[i] * cos2[i];
305  coef(2, 3) += dz2[i] * sincos[i];
306  }
307  for (Int_t i = 0; i < fgkPlanes; ++i) {
308  if (!onoff[i]) continue;
309  coef(3, 0) += fDz[i] * sincos[i];
310  coef(3, 1) += fDz[i] * sin2[i];
311  coef(3, 2) += dz2[i] * sincos[i];
312  coef(3, 3) += dz2[i] * sin2[i];
313  }
314 
315  TDecompLU* lu = new TDecompLU(4);
316  lu->SetMatrix(coef);
317  lu->SetTol(0.1 * lu->GetTol());
318  lu->Decompose();
319  fLus.insert(pair<Int_t, TDecompLU*>(ipat, lu));
320  TMatrixDSym cov(4);
321  cov.SetMatrixArray(coef.GetMatrixArray());
322  cov.Invert(); // covar. matrix
323  fMatr.insert(pair<Int_t, TMatrixDSym*>(ipat, new TMatrixDSym(cov)));
324  TString buf = "";
325  for (Int_t jp = 0; jp < fgkPlanes; ++jp)
326  buf += Bool_t(ipat & (1 << jp));
327  cout << " Determinant: " << buf << " " << ipat << " " << coef.Determinant()
328  << endl;
329  if (ipat == 255) {
330  coef.Print();
331  cout << " Number of configurations: " << nTot << endl;
332  }
333  cov *= (0.02 * 0.02);
334  cout << TMath::Sqrt(cov(0, 0)) << " " << TMath::Sqrt(cov(1, 1)) << " "
335  << TMath::Sqrt(cov(2, 2)) << " " << TMath::Sqrt(cov(3, 3)) << endl;
336  }
337 }
338 // -------------------------------------------------------------------------
339 
340 // ----- Private method GetHits ----------------------------------------
342  // Group hits according to their plane number
343 
344  for (Int_t ista = 0; ista < fgkStat; ++ista) {
345  for (Int_t i = 0; i < fgkPlanes; ++i)
346  fHitPl[ista][i].clear();
347  for (Int_t i = 0; i < fgkPlanes / 2; ++i)
348  fHit2d[ista][i].clear();
349  }
350 
351  Int_t nHits = fHits->GetEntriesFast(), nSelTu[fgkStat] = {0}, sel = 0;
352  for (Int_t i = 0; i < nHits; ++i) {
353  CbmMuchStrawHit* hit = (CbmMuchStrawHit*) fHits->UncheckedAt(i);
354 
356  sel = 1; //SelectHitId(hit);
357  if (!sel) continue;
358  //
359 
360  Int_t detId = hit->GetAddress();
361  CbmMuchModule* module = fGeoScheme->GetModuleByDetId(detId);
362  if (module->GetDetectorType() != 2) continue; // skip GEM hits
363  UInt_t address = CbmMuchAddress::GetElementAddress(detId, kMuchModule);
364  Int_t station3 = CbmMuchAddress::GetStationIndex(address); // station
365  Int_t doublet = CbmMuchAddress::GetLayerIndex(address); // doublet
366  Int_t layer =
367  CbmMuchAddress::GetLayerSideIndex(address); // layer in doublet
368  //cout << hit->GetZ() << " " << station3 << " " << doublet << " " << layer << endl;
369  //Int_t plane = (station3 - fStatFirst) * 8 + doublet * 2 + layer;
370  Int_t plane = doublet * 2 + layer;
371  fHitPl[station3 - fStatFirst][plane].insert(
372  pair<Int_t, Int_t>(hit->GetTube() + 1000 * hit->GetSegment(), i));
373  if (fErrU < 0) fErrU = hit->GetDu();
374  if (sel) ++nSelTu[station3 - fStatFirst];
375  }
376 
377  // Merge neighbouring hits from 2 layers of 1 doublet.
378  // If there is no neighbour, takes hit from a single layer (to account for inefficiency)
379  Int_t nlay2 = fgkPlanes / 2, indx1, indx2, tube1, tube2, next1, next2;
380  CbmMuchStrawHit *hit1 = NULL, *hit2 = NULL;
381 
382  for (Int_t ista = 0; ista < fgkStat; ++ista) {
383  // Loop over stations
384  Int_t nSelDouble = 0;
385 
386  for (Int_t i1 = 0; i1 < nlay2; ++i1) {
387  /* Debug
388  cout << " Doublet: " << ista << " " << i1 << " " << fHitPl[ista][i1*2].size() << " " << fHitPl[ista][i1*2+1].size() << endl << " Layer 1: " << endl;
389  for (multimap<Int_t,Int_t>::iterator it = fHitPl[ista][i1*2].begin(); it != fHitPl[ista][i1*2].end(); ++it)
390  cout << it->second << " ";
391  cout << endl;
392  for (multimap<Int_t,Int_t>::iterator it = fHitPl[ista][i1*2].begin(); it != fHitPl[ista][i1*2].end(); ++it)
393  cout << it->first << " ";
394  cout << endl << " Layer 2: " << endl;
395  for (multimap<Int_t,Int_t>::iterator it = fHitPl[ista][i1*2+1].begin(); it != fHitPl[ista][i1*2+1].end(); ++it)
396  cout << it->second << " ";
397  cout << endl;
398  for (multimap<Int_t,Int_t>::iterator it = fHitPl[ista][i1*2+1].begin(); it != fHitPl[ista][i1*2+1].end(); ++it)
399  cout << it->first << " ";
400  cout << endl;
401  */
402 
403  // Loop over doublets
404  multimap<Int_t, Int_t>::iterator it1 = fHitPl[ista][i1 * 2].begin(),
405  it2 = fHitPl[ista][i1 * 2 + 1].begin();
406  multimap<Int_t, Int_t>::iterator it1end = fHitPl[ista][i1 * 2].end(),
407  it2end = fHitPl[ista][i1 * 2 + 1].end();
408  set<Int_t> tubeOk[2];
409  next1 = next2 = 1;
410  if (it1 == it1end) next1 = 0;
411  if (it2 == it2end) next2 = 0;
412 
413  while (next1 || next2) {
414  // Loop over tubes
415  if (next1) {
416  indx1 = it1->second;
417  hit1 = (CbmMuchStrawHit*) fHits->UncheckedAt(indx1);
418  tube1 = it1->first;
419  }
420  if (next2) {
421  indx2 = it2->second;
422  hit2 = (CbmMuchStrawHit*) fHits->UncheckedAt(indx2);
423  tube2 = it2->first;
424  }
425 
426  if (it2 != it2end && tube2 < tube1 || it1 == it1end) {
427  // Single layer hit2 ?
428  if (tubeOk[1].find(tube2) == tubeOk[1].end()) {
429  sel = SelDoubleId(-1, indx2);
430  nSelDouble += sel;
431  if (sel) fHit2d[ista][i1].push_back(pair<Int_t, Int_t>(-1, indx2));
432  tubeOk[1].insert(tube2);
433  }
434  ++it2;
435  next2 = 1;
436  next1 = 0;
437  if (it2 == fHitPl[ista][i1 * 2 + 1].end()) next2 = 0;
438  continue;
439  }
440  if (it1 != it1end && tube2 > tube1 + 1 || it2 == it2end) {
441  // Single layer hit1 ?
442  if (tubeOk[0].find(tube1) == tubeOk[0].end()) {
443  sel = SelDoubleId(indx1, -1);
444  nSelDouble += sel;
445  if (sel) fHit2d[ista][i1].push_back(pair<Int_t, Int_t>(indx1, -1));
446  tubeOk[0].insert(tube1);
447  }
448  ++it1;
449  next1 = 1;
450  next2 = 0;
451  if (it1 == fHitPl[ista][i1 * 2].end()) next1 = 0;
452  continue;
453  }
454  // Double layer hit
455  sel = SelDoubleId(indx1, indx2);
456  nSelDouble += sel;
457  if (sel) fHit2d[ista][i1].push_back(pair<Int_t, Int_t>(indx1, indx2));
458  tubeOk[0].insert(tube1);
459  tubeOk[1].insert(tube2);
460  if (tube2 == tube1) {
461  ++it2;
462  next2 = 1;
463  next1 = 0;
464  if (it2 == fHitPl[ista][i1 * 2 + 1].end()) {
465  next2 = 0;
466  next1 = 1;
467  if (it1 == fHitPl[ista][i1 * 2].end()) next1 = 0;
468  }
469  } else {
470  ++it1;
471  next1 = 1;
472  next2 = 0;
473  if (it1 == fHitPl[ista][i1 * 2].end()) {
474  next1 = 0;
475  next2 = 1;
476  if (it2 == fHitPl[ista][i1 * 2 + 1].end()) next2 = 0;
477  }
478  }
479  continue;
480  } // while (next1...
481  }
482  cout << " Selected tubes: " << ista << " " << nSelTu[ista] << endl;
483 
484  cout << " Selected doublets: " << ista << " " << nSelDouble << endl;
485  }
486 }
487 // -------------------------------------------------------------------------
488 
489 // ----- Private method SelectHitId ------------------------------------
490 Bool_t CbmMuchFindVectors::SelectHitId(const CbmMuchStrawHit* hit) {
491  // Select hits with certain track IDs (for debugging)
492 
493  Int_t nSel = 2, idSel[2] = {0, 1}, id = 0;
494 
495  for (Int_t i = 0; i < nSel; ++i) {
496  if (hit->GetFlag() % 2) {
497  //if (0) {
498  // Mirror hit
499  return kFALSE;
500  } else {
501  CbmMuchDigiMatch* digiM =
502  (CbmMuchDigiMatch*) fDigiMatches->UncheckedAt(hit->GetRefId());
503  Int_t np = digiM->GetNofLinks();
504  for (Int_t ip = 0; ip < np; ++ip) {
505  CbmMuchPoint* point =
506  (CbmMuchPoint*) fPoints->UncheckedAt(digiM->GetLink(ip).GetIndex());
507  id = point->GetTrackID();
508  if (id == idSel[i]) return kTRUE;
509  }
510  }
511  }
512  return kFALSE;
513 }
514 // -------------------------------------------------------------------------
515 
516 // ----- Private method SelDoubleId ------------------------------------
517 Bool_t CbmMuchFindVectors::SelDoubleId(Int_t indx1, Int_t indx2) {
518  // Select doublets with certain track IDs (for debugging)
519 
520  return kTRUE; // no selection
521 
522  Int_t nId = 2, idSel[2] = {0, 1}, id = 0;
523  CbmMuchStrawHit* hit = NULL;
524  CbmMuchDigiMatch* digiM = NULL;
525  CbmMuchPoint* point = NULL;
526 
527  if (indx1 >= 0) {
528  hit = (CbmMuchStrawHit*) fHits->UncheckedAt(indx1);
529  if (hit->GetFlag() % 2 == 0) {
530  // Not a mirror hit
531  for (Int_t i = 0; i < nId; ++i) {
532  digiM = (CbmMuchDigiMatch*) fDigiMatches->UncheckedAt(hit->GetRefId());
533  Int_t np = digiM->GetNofLinks();
534  for (Int_t ip = 0; ip < np; ++ip) {
535  point =
536  (CbmMuchPoint*) fPoints->UncheckedAt(digiM->GetLink(ip).GetIndex());
537  id = point->GetTrackID();
538  if (id == idSel[i]) return kTRUE;
539  }
540  }
541  }
542  }
543  if (indx2 >= 0) {
544  hit = (CbmMuchStrawHit*) fHits->UncheckedAt(indx2);
545  if (hit->GetFlag() % 2 == 0) {
546  // Not a mirror hit
547  for (Int_t i = 0; i < nId; ++i) {
548  digiM = (CbmMuchDigiMatch*) fDigiMatches->UncheckedAt(hit->GetRefId());
549  Int_t np = digiM->GetNofLinks();
550  for (Int_t ip = 0; ip < np; ++ip) {
551  point =
552  (CbmMuchPoint*) fPoints->UncheckedAt(digiM->GetLink(ip).GetIndex());
553  id = point->GetTrackID();
554  if (id == idSel[i]) return kTRUE;
555  }
556  }
557  }
558  }
559  return kFALSE;
560 }
561 // -------------------------------------------------------------------------
562 
563 // ----- Private method MakeVectors ------------------------------------
565  // Make vectors for stations
566 
567  for (Int_t ista = 0; ista < fgkStat; ++ista) {
568  Int_t nvec = fVectors[ista].size();
569  for (Int_t j = 0; j < nvec; ++j)
570  delete fVectors[ista][j];
571  fVectors[ista].clear();
572  Int_t lay2 = 0, patt = 0, flag = 0, ndoubl = fHit2d[ista][lay2].size();
573  CbmMuchStrawHit* hit = NULL;
574 
575  cout << " Doublets: " << ista << " " << ndoubl << endl;
576  for (Int_t id = 0; id < ndoubl; ++id) {
577  Int_t indx1 = fHit2d[ista][lay2][id].first;
578  Int_t indx2 = fHit2d[ista][lay2][id].second;
579  if (indx1 >= 0) {
580  hit = (CbmMuchStrawHit*) fHits->UncheckedAt(indx1);
581  fUz[lay2 * 2][0] = hit->GetU();
582  //fUz[lay2*2][2] = hit->GetPhi();
583  fUzi[lay2 * 2][0] = hit->GetSegment();
584  fUzi[lay2 * 2][1] = indx1;
585  fUzi[lay2 * 2][2] = hit->GetTube();
586  }
587  if (indx2 >= 0) {
588  hit = (CbmMuchStrawHit*) fHits->UncheckedAt(indx2);
589  fUz[lay2 * 2 + 1][0] = hit->GetU();
590  //fUz[lay2*2+1][2] = hit->GetPhi();
591  fUzi[lay2 * 2 + 1][0] = hit->GetSegment();
592  fUzi[lay2 * 2 + 1][1] = indx2;
593  fUzi[lay2 * 2 + 1][2] = hit->GetTube();
594  }
595  Bool_t ind1 = indx1 + 1;
596  Bool_t ind2 = indx2 + 1;
597  patt = ind1;
598  patt |= (ind2 << 1);
599  //cout << plane0 << " " << hit->GetX() << " " << hit->GetY() << " " << hit->GetZ() << " " << hit->GetU() << " " << u << endl;
601  ista, lay2 + 1, patt, flag, hit->GetTube(), hit->GetSegment());
602  }
603  }
604 }
605 // -------------------------------------------------------------------------
606 
607 // ----- Private method ProcessDouble ----------------------------------
609  Int_t lay2,
610  Int_t patt,
611  Int_t flag,
612  Int_t tube0,
613  Int_t segment0) {
614  // Main processing engine (recursively adds doublet hits to the vector)
615 
616  // !!! Tube differences between the same views for mu from omega at 8 GeV !!!
617  const Int_t dTubes2 = 30;
618  Double_t pars[4] = {0.0};
619 
620  Int_t ndoubl = fHit2d[ista][lay2].size();
621 
622  for (Int_t id = 0; id < ndoubl; ++id) {
623  Int_t indx1 = fHit2d[ista][lay2][id].first;
624  Int_t indx2 = fHit2d[ista][lay2][id].second;
625  CbmMuchStrawHit* hit =
626  (CbmMuchStrawHit*) fHits->UncheckedAt(TMath::Max(indx1, indx2));
627  Int_t segment = hit->GetSegment();
628  Int_t tube = hit->GetTube();
629  //if (segment != segment0) continue; // do not combine two half-stations - wrong due to stereo angles
630 
631  if (TMath::Abs(tube - tube0) > fDtubes[ista][lay2 - 1])
632  continue; // !!! cut
633 
634  // Check the same views
635  Int_t ok = 1;
636  for (Int_t il = 0; il < lay2; ++il) {
637  Int_t pl = il * 2;
638  if (TMath::Abs(fSina[pl] - fSina[lay2 * 2]) < 0.01) {
639  // The same views
640  Int_t seg = fUzi[pl][0];
641  if (!(patt & (1 << pl))) seg = fUzi[pl + 1][0];
642  if (segment != seg) {
643  ok = 0;
644  break;
645  }
646  // Check tube difference
647  Double_t z = fDz[pl];
648  Int_t tu = fUzi[pl][2];
649  if (!(patt & (1 << pl))) {
650  z = fDz[pl + 1];
651  tu = fUzi[pl + 1][2];
652  }
653  z += fZ0[ista];
654  Double_t dzz = (hit->GetZ() - z) / z;
655  if (TMath::Abs(tube - tu - dzz * tu) > dTubes2) {
656  ok = 0;
657  break;
658  } // !!! cut
659  }
660  }
661  if (!ok) continue; // !!! cut
662 
663  /*
664  if (lay2 > 1) {
665  // Tube difference with previous to previous doublet
666  Int_t pl = (lay2 - 2) * 2;
667  Int_t tu = fUzi[pl][2];
668  if (patt & (1 << pl+1)) tu = fUzi[pl+1][2];
669  Double_t dtu = tube - tu;
670  if (lay2 == 3) dtu -= slope[ista] * tu;
671  //if (TMath::Abs(dtu) > dTubes2[lay2-2]) continue; // !!! cut
672  }
673  */
674 
675  if (indx1 >= 0) {
676  hit = (CbmMuchStrawHit*) fHits->UncheckedAt(indx1);
677  fUz[lay2 * 2][0] = hit->GetU();
678  //fUz[lay2*2][2] = hit->GetPhi();
679  fUzi[lay2 * 2][0] = hit->GetSegment();
680  fUzi[lay2 * 2][1] = indx1;
681  fUzi[lay2 * 2][2] = hit->GetTube();
682  }
683  if (indx2 >= 0) {
684  hit = (CbmMuchStrawHit*) fHits->UncheckedAt(indx2);
685  fUz[lay2 * 2 + 1][0] = hit->GetU();
686  //fUz[lay2*2+1][2] = hit->GetPhi();
687  fUzi[lay2 * 2 + 1][0] = hit->GetSegment();
688  fUzi[lay2 * 2 + 1][1] = indx2;
689  fUzi[lay2 * 2 + 1][2] = hit->GetTube();
690  }
691 
692  // Check intersection
693  //if (!IntersectViews(ista, lay2, indx1, indx2, patt)) continue;
694 
695  Bool_t ind1 = indx1 + 1;
696  Bool_t ind2 = indx2 + 1;
697  // Clear bits
698  patt &= ~(1 << lay2 * 2);
699  patt &= ~(1 << lay2 * 2 + 1);
700  // Set bits
701  patt |= (ind1 << lay2 * 2);
702  patt |= (ind2 << lay2 * 2 + 1);
703  //cout << plane << " " << patt << " " << hit->GetX() << " " << hit->GetY() << " " << hit->GetZ() << " " << hit->GetU() << " " << u << endl;
704 
705  if (lay2 + 1 < fgkPlanes / 2)
706  ProcessDouble(ista, lay2 + 1, patt, flag, tube, segment);
707  else {
708  // Straight line fit of the vector
709  FindLine(patt, pars);
710  Double_t chi2 = FindChi2(ista, patt, pars);
711  //cout << " *** Stat: " << ista << " " << id << " " << indx1 << " " << indx2 << " " << chi2 << " " << pars[0] << " " << pars[1] << endl;
712  if (chi2 <= fCutChi2)
713  AddVector(
714  ista, patt, chi2, pars); // add vector to the temporary container
715  }
716  } // for (id = 0; id < ndoubl;
717 }
718 // -------------------------------------------------------------------------
719 
720 // ----- Private method IntersectViews ---------------------------------
722  Int_t curLay,
723  Int_t indx1,
724  Int_t indx2,
725  Int_t patt) {
726  // Intersect 2 views
727 
728  Int_t lay2 = curLay * 2;
729  if (indx1 < 0) ++lay2;
730  Double_t u2 = fUz[lay2][0];
731 
732  Int_t lay1 = curLay * 2 - 2;
733  if (!(patt & (1 << lay1))) ++lay1;
734  Double_t u1 = fUz[lay1][0];
735 
736  Double_t yint = u1 * fCosa[lay2] - u2 * fCosa[lay1];
737  yint /= (fSina[lay1] * fCosa[lay2] - fSina[lay2] * fCosa[lay1]);
738  if (TMath::Abs(yint) > fRmax[ista] + 10.0)
739  return kFALSE; // outside outer dim. + safety margin
740 
741  Double_t xint = u2 / fCosa[lay2] - yint * fSina[lay2] / fCosa[lay2];
742 
743  Double_t v1 = -xint * fSina[lay1] + yint * fCosa[lay1];
744  Double_t v2 = -xint * fSina[lay2] + yint * fCosa[lay2];
745 
746  cout << xint << " " << yint << " " << v1 << " " << v2 << " " << fUzi[lay1][0]
747  << " " << fUzi[lay2][0] << endl;
748  if (TMath::Abs(v1) > 10.0 && v1 * fUzi[lay1][0] < 0)
749  cout << " Outside !!! " << endl;
750  if (TMath::Abs(v2) > 10.0 && v2 * fUzi[lay2][0] < 0)
751  cout << " Outside !!! " << endl;
752  if (TMath::Abs(v1) > 30.0 && v1 * fUzi[lay1][0] < 0) return kFALSE;
753  if (TMath::Abs(v2) > 30.0 && v2 * fUzi[lay2][0] < 0) return kFALSE;
754  return kTRUE;
755 }
756 // -------------------------------------------------------------------------
757 
758 // ----- Private method AddVector --------------------------------------
760  Int_t patt,
761  Double_t chi2,
762  Double_t* pars,
763  Bool_t lowRes) {
764  // Add vector to the temporary container (as a MuchTrack)
765 
766  CbmMuchTrack* track = new CbmMuchTrack();
767  track->SetChiSq(chi2);
768  TMatrixDSym cov(*fMatr[patt]);
769  cov *= (fErrU * fErrU);
770  //cov *= (0.2 * 0.2); //
771  cov.ResizeTo(5, 5);
772  FairTrackParam par(pars[0], pars[1], fZ0[ista], pars[2], pars[3], 0.0, cov);
773  track->SetParamFirst(&par);
774  par.SetZ(fZ0[ista] + fDz[fgkPlanes - 1]);
775  par.SetX(pars[0] + fDz[fgkPlanes - 1] * pars[2]);
776  par.SetY(pars[1] + fDz[fgkPlanes - 1] * pars[3]);
777  track->SetParamLast(&par);
778  track->SetUniqueID(ista + fStatFirst); // just to pass the value
779 
780  for (Int_t ipl = 0; ipl < fgkPlanes; ++ipl) {
781  if (!(patt & (1 << ipl))) continue;
782  track->AddHit(fUzi[ipl][1], kMUCHSTRAWHIT);
783  if (lowRes) continue;
784  // Store selected hit coordinate (resolved left-right ambig.) as data member fDphi
785  CbmMuchStrawHit* hit = (CbmMuchStrawHit*) fHits->UncheckedAt(fUzi[ipl][1]);
786  hit->SetDphi(fUz[ipl][0]);
787  }
788  Int_t ndf = (track->GetNofHits() > 4) ? track->GetNofHits() - 4 : 1;
789  track->SetNDF(ndf);
790  SetTrackId(track); // set track ID as its flag
791  if (lowRes)
792  fVectors[ista].push_back(track);
793  else
794  fVectorsHigh[ista].push_back(track);
795 }
796 // -------------------------------------------------------------------------
797 
798 // ----- Private method SetTrackId -------------------------------------
800  // Set vector ID as its flag (maximum track ID of its poins)
801 
802  map<Int_t, Int_t> ids;
803  Int_t nhits = vec->GetNofHits(), id = 0;
804 
805  for (Int_t ih = 0; ih < nhits; ++ih) {
806  CbmMuchStrawHit* hit =
807  (CbmMuchStrawHit*) fHits->UncheckedAt(vec->GetHitIndex(ih));
808  if (hit->GetFlag() % 2) {
809  //if (0) {
810  // Mirror hit
811  id = -1;
812  if (ids.find(id) == ids.end())
813  ids.insert(pair<Int_t, Int_t>(id, 1));
814  else
815  ++ids[id];
816  } else {
817  CbmMuchDigiMatch* digiM =
818  (CbmMuchDigiMatch*) fDigiMatches->UncheckedAt(hit->GetRefId());
819  Int_t np = digiM->GetNofLinks();
820  for (Int_t ip = 0; ip < np; ++ip) {
821  //CbmMuchPoint* point = (CbmMuchPoint*) fPoints->UncheckedAt(digiM->GetLink(0).GetIndex());
822  CbmMuchPoint* point =
823  (CbmMuchPoint*) fPoints->UncheckedAt(digiM->GetLink(ip).GetIndex());
824  id = point->GetTrackID();
825  //if (np > 1) cout << ip << " " << id << endl;
826  if (ids.find(id) == ids.end())
827  ids.insert(pair<Int_t, Int_t>(id, 1));
828  else
829  ++ids[id];
830  }
831  //if (np > 1) { cout << " digi " << digiM->GetNofLinks() << " " << ista << " " << hit->GetX() << " " << hit->GetY() << endl; exit(0); }
832  }
833  }
834  Int_t maxim = -1, idmax = -9;
835  for (map<Int_t, Int_t>::iterator it = ids.begin(); it != ids.end(); ++it) {
836  if (it->second > maxim) {
837  maxim = it->second;
838  idmax = it->first;
839  }
840  }
841  // Set vector ID as its flag
842  vec->SetFlag(idmax);
843 }
844 // -------------------------------------------------------------------------
845 
846 // ----- Private method FindLine ---------------------------------------
847 void CbmMuchFindVectors::FindLine(Int_t patt, Double_t* pars) {
848  // Fit of hits to the straight line
849 
850  // Solve system of linear equations
851  Bool_t ok = kFALSE, onoff;
852  TVectorD b(4);
853  for (Int_t i = 0; i < fgkPlanes; ++i) {
854  onoff = patt & (1 << i);
855  if (!onoff) continue;
856  b[0] += fUz[i][0] * fCosa[i];
857  b[1] += fUz[i][0] * fSina[i];
858  b[2] += fUz[i][0] * fDz[i] * fCosa[i];
859  b[3] += fUz[i][0] * fDz[i] * fSina[i];
860  }
861 
862  //lu.Print();
863  TVectorD solve = fLus[patt]->Solve(b, ok);
864  //TVectorD solve = lu.TransSolve(b, ok);
865  //lu.Print();
866  for (Int_t i = 0; i < 4; ++i)
867  pars[i] = solve[i];
868  //for (Int_t i = 0; i < 4; ++i) { cout << pars[i] << " "; if (i == 3) cout << endl; }
869  //Double_t y1 = cosa / sina * (uz[1][0] * cosa - uz[0][0]) + uz[1][0] * sina;
870  //Double_t y2 = -cosa / sina * (uz[2][0] * cosa - uz[0][0]) - uz[2][0] * sina;
871  //cout << " OK " << ok << " " << y1 << " " << y2 << endl;
872 }
873 // -------------------------------------------------------------------------
874 
875 // ----- Private method FindChi2 ---------------------------------------
876 Double_t CbmMuchFindVectors::FindChi2(Int_t ista, Int_t patt, Double_t* pars) {
877  // Compute chi2 of the fit
878 
879  Double_t chi2 = 0, x = 0, y = 0, u = 0, errv = 1.;
880  if (fErrU > 0.1) errv = 10;
881  static Int_t first = 1;
882  if (first) {
883  first = 0;
884  /*
885  mcFile->Get("FairBaseParSet");
886  cout << gGeoManager << " " << gGeoManager->GetVolume("muchstation05") << " " << gGeoManager->GetVolume("muchstation06") << endl;
887  for (Int_t i = 0; i < 2; ++i) {
888  TString volName = "muchstation0";
889  volName += (i+4);
890  TGeoVolume *vol = gGeoManager->GetVolume(volName);
891  TGeoTube *shape = (TGeoTube*) vol->GetShape();
892  rad[i] = shape->GetRmin();
893  }
894  cout << " Rads: " << rad[0] << " " << rad[1] << endl;
895  */
896  }
897 
898  fChi2Map.clear();
899  Bool_t onoff;
900  for (Int_t i = 0; i < fgkPlanes; ++i) {
901  onoff = patt & (1 << i);
902  if (!onoff) continue;
903  x = pars[0] + pars[2] * fDz[i];
904  y = pars[1] + pars[3] * fDz[i];
905  u = x * fCosa[i] + y * fSina[i];
906  Double_t du = (u - fUz[i][0]) / fErrU, du2 = du * du;
907  chi2 += du2;
908  multimap<Double_t, Int_t>::iterator it =
909  fChi2Map.insert(pair<Double_t, Int_t>(du2, i));
910  //cout << " " << i << " " << x << " " << y << " " << u << " " << fUz[i][0] << " " << du*du << endl;
911 
912  // Edge effect
913  //if (errv < 2.0) continue; // skip for high-res. mode
914  Int_t iseg = fUzi[i][0];
915  Double_t v = -x * fSina[i] + y * fCosa[i];
916  Double_t v0 = 0;
917  //cout << v << " " << iseg << endl;
918  if (TMath::Abs(fUz[i][0]) > fRmin[ista] && v * iseg > 0) continue;
919 
920  if (TMath::Abs(fUz[i][0]) < fRmin[ista]) {
921  v0 = TMath::Sign(
922  TMath::Sqrt(fRmin[ista] * fRmin[ista] - fUz[i][0] * fUz[i][0]),
923  iseg * 1.); // beam hole
924  if ((v - v0) * iseg > 0) continue;
925  }
926  Double_t dv = (v - v0) / errv, dv2 = dv * dv;
927  chi2 += dv2;
928  fChi2Map.erase(it);
929  fChi2Map.insert(pair<Double_t, Int_t>(du2 + dv2, i));
930  }
931  //cout << " Chi2 = " << chi2 << endl;
932  return chi2;
933 }
934 // -------------------------------------------------------------------------
935 
936 // ----- Private method CheckParams ------------------------------------
938  // Remove vectors with wrong orientation
939  // using empirical cuts for omega muons at 8 Gev
940 
941  Double_t cut[2] = {0.6, 0.7}; // !!! empirical !!!
942 
943  for (Int_t ista = 0; ista < fgkStat; ++ista) {
944  Int_t nvec = fVectors[ista].size();
945 
946  for (Int_t iv = 0; iv < nvec; ++iv) {
947  CbmMuchTrack* vec = fVectors[ista][iv];
948  const FairTrackParam* params = vec->GetParamFirst();
949  Double_t dTx = params->GetTx() - params->GetX() / params->GetZ();
950  Double_t dTy = params->GetTy() - params->GetY() / params->GetZ();
951  if (TMath::Abs(dTx) > cut[0] || TMath::Abs(dTy) > cut[1])
952  vec->SetChiSq(-1.0);
953  }
954 
955  for (Int_t iv = nvec - 1; iv >= 0; --iv) {
956  CbmMuchTrack* vec = fVectors[ista][iv];
957  if (vec->GetChiSq() < 0) {
958  delete fVectors[ista][iv];
959  fVectors[ista].erase(fVectors[ista].begin() + iv);
960  }
961  }
962  cout << " Vectors after parameter check in station " << ista << ": " << nvec
963  << " " << fVectors[ista].size() << endl;
964  }
965 }
966 // -------------------------------------------------------------------------
967 
968 // ----- Private method HighRes ----------------------------------------
970  // High resolution processing (resolve ghost hits and make high resolution vectors)
971 
972  for (Int_t ista = 0; ista < fgkStat; ++ista) {
973  Int_t nvec = fVectors[ista].size();
974 
975  for (Int_t iv = 0; iv < nvec; ++iv) {
976  CbmMuchTrack* vec = fVectors[ista][iv];
977  Int_t nhits = vec->GetNofHits(), patt = 0,
978  size0 = fVectorsHigh[ista].size();
979  Double_t uu[fgkPlanes][2];
980 
981  for (Int_t ih = 0; ih < nhits; ++ih) {
982  CbmMuchStrawHit* hit =
983  (CbmMuchStrawHit*) fHits->UncheckedAt(vec->GetHitIndex(ih));
984  Int_t lay = fGeoScheme->GetLayerIndex(hit->GetAddress());
985  Int_t side = fGeoScheme->GetLayerSideIndex(hit->GetAddress());
986  Int_t plane = lay * 2 + side;
987  uu[plane][0] = hit->GetU();
988  uu[plane][1] = hit->GetDouble()[2];
989  patt |= (1 << plane);
990  fUzi[plane][0] = hit->GetSegment();
991  fUzi[plane][1] = vec->GetHitIndex(ih);
992  }
993 
994  // Number of hit combinations is 2
995  // - left-right ambiguity resolution does not really work for doublets
996  Int_t nCombs = (patt & 1) ? 2 : 1, flag = 1, nok = nCombs - 1;
997  fFailed.clear();
998 
999  for (Int_t icomb = -1; icomb < nCombs; icomb += 2) {
1000  fUz[0][0] = (nCombs == 2) ? uu[0][0] + uu[0][1] * icomb : 0.0;
1001  ProcessSingleHigh(ista, 1, patt, flag, nok, uu);
1002  }
1003  if (Int_t(fVectorsHigh[ista].size()) > size0) continue; // successful fit
1004  // Failed fit
1005  RemoveOutliers(ista, patt, uu);
1006 
1007  } // for (Int_t iv = 0;
1008  } // for (Int_t ista = 0;
1009 
1010  MoveVectors(); // move vectors from one container to another, i.e. drop low resolution ones
1011 }
1012 // -------------------------------------------------------------------------
1013 
1014 // ----- Private method ProcessDoubleHigh ------------------------------
1016  Int_t plane,
1017  Int_t patt,
1018  Int_t flag,
1019  Int_t nok,
1020  Double_t uu[fgkPlanes][2]) {
1021  // Main processing engine for high resolution mode
1022  // (recursively adds singlet hits to the vector)
1023 
1024  Double_t pars[4] = {0.0};
1025  const Double_t thresh = 10.0; // chi2-threshold
1026 
1027  // Number of hit combinations is 2
1028  Int_t nCombs = (patt & (1 << plane)) ? 2 : 1;
1029  nok += (nCombs - 1);
1030 
1031  for (Int_t icomb = -1; icomb < nCombs; icomb += 2) {
1032  fUz[plane][0] = (nCombs == 2) ? uu[plane][0] + uu[plane][1] * icomb : 0.0;
1033  if (plane == fgkPlanes - 1 || nok == fMinHits && flag) {
1034  // Straight line fit of the vector
1035  Int_t patt1 = patt & ((1 << plane + 1) - 1); // apply mask
1036  FindLine(patt1, pars);
1037  Double_t chi2 = FindChi2(ista, patt1, pars);
1038  /*
1039  TString str;
1040  str += patt1;
1041  str = TString::BaseConvert(str,10,2);
1042  cout << " *** Stat: " << ista << " " << plane << " " << str.CountChar('1') << " " << chi2 << " "
1043  << pars[0] << " " << pars[1] << endl;
1044  for (multimap<Double_t,Int_t>::reverse_iterator rit = fChi2Map.rbegin(); rit != fChi2Map.rend(); ++rit)
1045  cout << rit->first << " ";
1046  cout << endl;
1047  */
1048  if (icomb > -1) flag = 0;
1049  if (chi2 > fCutChi2) {
1050  /*
1051  Double_t qual = 0.0, c2sum = 0.0, outl = 0.0;
1052  for (multimap<Double_t,Int_t>::reverse_iterator rit = fChi2Map.rbegin(); rit != fChi2Map.rend(); ++rit) {
1053  if (rit->first > thresh) { outl += 1; c2sum += rit->first; }
1054  else break;
1055  }
1056  qual = outl + TMath::Min(c2sum,999.) / 1000;
1057  fFailed.insert(pair<Double_t,multimap<Double_t,Int_t> >(qual,fChi2Map));
1058  */
1059  Int_t lrbits = 0;
1060  for (Int_t j = 0; j <= plane; ++j) {
1061  if (!(patt1 & (1 << j))) continue;
1062  if (fUz[j][0] > uu[j][0]) lrbits |= (1 << j);
1063  }
1064  fFailed.insert(
1065  pair<Int_t, multimap<Double_t, Int_t>>(lrbits, fChi2Map));
1066  continue; // too high chi2 - do not extend line
1067  }
1068  //if (plane + 1 < fgkPlanes) ProcessSingleHigh(ista, plane + 1, patt, flag, nok, uu);
1069  if (plane + 1 < fgkPlanes)
1070  ProcessSingleHigh(ista, plane + 1, patt, 0, nok, uu);
1071  else
1072  AddVector(ista,
1073  patt,
1074  chi2,
1075  pars,
1076  kFALSE); // add vector to the temporary container
1077  } else {
1078  ProcessSingleHigh(ista, plane + 1, patt, flag, nok, uu);
1079  }
1080  }
1081 }
1082 // -------------------------------------------------------------------------
1083 
1084 // ----- Private method MoveVectors ------------------------------------
1086  // Drop low-resolution vectors and move high-res. ones to their container
1087 
1088  for (Int_t ista = 0; ista < fgkStat; ++ista) {
1089  Int_t nVecs = fVectors[ista].size();
1090  for (Int_t j = 0; j < nVecs; ++j)
1091  delete fVectors[ista][j];
1092  fVectors[ista].clear();
1093 
1094  nVecs = fVectorsHigh[ista].size();
1095  for (Int_t j = 0; j < nVecs; ++j)
1096  fVectors[ista].push_back(fVectorsHigh[ista][j]);
1097  }
1098 }
1099 // -------------------------------------------------------------------------
1100 
1101 // ----- Private method RemoveClones -----------------------------------
1103  // Remove clone vectors (having at least 1 the same hit in each doublet (min. 4 the same hits))
1104 
1105  Int_t nthr = 4, planes[20];
1106 
1107  for (Int_t ista = 0; ista < fgkStat; ++ista) {
1108  Int_t nvec = fVectors[ista].size();
1109 
1110  // Do sorting according to "quality"
1111  multimap<Double_t, CbmMuchTrack*> qMap;
1112  multimap<Double_t, CbmMuchTrack*>::iterator it, it1;
1113 
1114  for (Int_t iv = 0; iv < nvec; ++iv) {
1115  CbmMuchTrack* vec = fVectors[ista][iv];
1116  Double_t qual =
1117  vec->GetNofHits() + (99 - TMath::Min(vec->GetChiSq(), 99.0)) / 100;
1118  qMap.insert(pair<Double_t, CbmMuchTrack*>(-qual, vec));
1119  }
1120 
1121  for (it = qMap.begin(); it != qMap.end(); ++it) {
1122  CbmMuchTrack* vec = it->second;
1123  if (vec->GetChiSq() < 0) continue;
1124  for (Int_t j = 0; j < fgkPlanes; ++j)
1125  planes[j] = -1;
1126 
1127  Int_t nhits = vec->GetNofHits();
1128  for (Int_t ih = 0; ih < nhits; ++ih) {
1129  CbmMuchStrawHit* hit =
1130  (CbmMuchStrawHit*) fHits->UncheckedAt(vec->GetHitIndex(ih));
1131  Int_t lay = fGeoScheme->GetLayerIndex(hit->GetAddress());
1132  Int_t side = fGeoScheme->GetLayerSideIndex(hit->GetAddress());
1133  planes[lay * 2 + side] = vec->GetHitIndex(ih);
1134  //cout << iv << " " << lay*2+side << " " << vec->GetHitIndex(ih) << endl;
1135  }
1136 
1137  it1 = it;
1138  for (++it1; it1 != qMap.end(); ++it1) {
1139  CbmMuchTrack* vec1 = it1->second;
1140  if (vec1->GetChiSq() < 0) continue;
1141  Int_t nsame = 0, same[fgkPlanes / 2] = {0};
1142 
1143  Int_t nhits1 = vec1->GetNofHits();
1144  //nthr = TMath::Min(nhits,nhits1) / 2;
1145  //nthr = TMath::Min(nhits,nhits1) * 0.75;
1146  for (Int_t ih = 0; ih < nhits1; ++ih) {
1147  CbmMuchStrawHit* hit =
1148  (CbmMuchStrawHit*) fHits->UncheckedAt(vec1->GetHitIndex(ih));
1149  Int_t lay = fGeoScheme->GetLayerIndex(hit->GetAddress());
1150  Int_t side = fGeoScheme->GetLayerSideIndex(hit->GetAddress());
1151  if (planes[lay * 2 + side] >= 0) {
1152  if (vec1->GetHitIndex(ih) == planes[lay * 2 + side]) same[lay] = 1;
1153  //else same[lay] = 0;
1154  }
1155  }
1156  for (Int_t lay = 0; lay < fgkPlanes / 2; ++lay)
1157  nsame += same[lay];
1158 
1159  if (nsame >= nthr) {
1160  // Too many the same hits
1161  Int_t clone = 0;
1162  if (nhits > nhits1 + 0) clone = 1;
1163  //else if (vec->GetChiSq() * 3.0 <= vec1->GetChiSq()) vec1->SetChiSq(-1.0); // the same number of hits on 2 tracks
1164  else if (fgkPlanes > -8 && vec->GetChiSq() * 1 <= vec1->GetChiSq())
1165  clone = 1; // the same number of hits on 2 tracks
1166  if (clone) {
1167  vec1->SetChiSq(-1.0);
1168  /* Debug
1169  const FairTrackParam *params = vec->GetParamFirst();
1170  const FairTrackParam *params1 = vec1->GetParamFirst();
1171  if (vec1->GetFlag() < 2) cout << " Remove: " << vec->GetFlag() << " " << vec1->GetFlag() << " " << nhits << " " << nhits1 << " " << nsame << " " << vec->GetChiSq() << " " << vec1->GetChiSq() << " " << params->GetX() << " " << params1->GetX() << " " << params->GetY() << " " << params1->GetY() << endl;
1172  //
1173  Double_t dx = params->GetX() - params1->GetX();
1174  dx /= 0.2;
1175  Double_t dy = params->GetY() - params1->GetY();
1176  dy /= 1.5;
1177  Double_t chi2 = dx * dx + dy * dy;
1178  if (chi2 < 10) vec1->SetChiSq(-1.0);
1179  */
1180  }
1181  }
1182  }
1183  }
1184 
1185  for (Int_t iv = nvec - 1; iv >= 0; --iv) {
1186  CbmMuchTrack* vec = fVectors[ista][iv];
1187  if (vec->GetChiSq() < 0) {
1188  delete fVectors[ista][iv];
1189  fVectors[ista].erase(fVectors[ista].begin() + iv);
1190  }
1191  }
1192  cout << " Vectors after clones removed: " << nvec << " "
1193  << fVectors[ista].size() << endl;
1194 
1195  } // for (Int_t ista = 0; ista < fgkStat;
1196 }
1197 // -------------------------------------------------------------------------
1198 
1199 // ----- Private method RemoveShorts -----------------------------------
1201  // Remove short tracks
1202 
1203  Int_t nshort = fgkPlanes / 2, planes[20];
1204 
1205  for (Int_t ista = 0; ista < fgkStat; ++ista) {
1206  Int_t nvec = fVectors[ista].size();
1207  Int_t remove = 0;
1208 
1209  for (Int_t iv = 0; iv < nvec; ++iv) {
1210  CbmMuchTrack* vec = fVectors[ista][iv];
1211  if (vec->GetChiSq() < 0) continue;
1212  Int_t nhits = vec->GetNofHits();
1213  if (nhits != nshort) continue;
1214  set<Int_t> overlap;
1215  //multiset<Int_t> overlap1;
1216  for (Int_t j = 0; j < fgkPlanes; ++j)
1217  planes[j] = -1;
1218  for (Int_t ih = 0; ih < nhits; ++ih) {
1219  CbmMuchStrawHit* hit =
1220  (CbmMuchStrawHit*) fHits->UncheckedAt(vec->GetHitIndex(ih));
1221  Int_t lay = fGeoScheme->GetLayerIndex(hit->GetAddress());
1222  Int_t side = fGeoScheme->GetLayerSideIndex(hit->GetAddress());
1223  planes[lay * 2 + side] = vec->GetHitIndex(ih);
1224  }
1225 
1226  for (Int_t iv1 = iv + 1; iv1 < nvec; ++iv1) {
1227  CbmMuchTrack* vec1 = fVectors[ista][iv1];
1228  if (vec1->GetChiSq() < 0) continue;
1229  Int_t nhits1 = vec1->GetNofHits();
1230 
1231  // Compare hits
1232  for (Int_t ih = 0; ih < nhits1; ++ih) {
1233  CbmMuchStrawHit* hit =
1234  (CbmMuchStrawHit*) fHits->UncheckedAt(vec1->GetHitIndex(ih));
1235  Int_t lay = fGeoScheme->GetLayerIndex(hit->GetAddress());
1236  Int_t side = fGeoScheme->GetLayerSideIndex(hit->GetAddress());
1237  if (vec1->GetHitIndex(ih) == planes[lay * 2 + side]
1238  && planes[lay * 2 + side] >= 0)
1239  overlap.insert(ih);
1240  }
1241  //if (overlap.size() == nshort) {
1242  if (overlap.size() > 0) {
1243  // Hits are shared with other tracks
1244  remove = 1;
1245  break;
1246  }
1247  } // for (Int_t iv1 = iv + 1;
1248  if (remove) vec->SetChiSq(-1.0);
1249  } // for (Int_t iv = 0; iv < nvec;
1250 
1251  for (Int_t iv = nvec - 1; iv >= 0; --iv) {
1252  CbmMuchTrack* vec = fVectors[ista][iv];
1253  if (vec->GetChiSq() < 0) {
1254  delete fVectors[ista][iv];
1255  fVectors[ista].erase(fVectors[ista].begin() + iv);
1256  }
1257  }
1258  cout << " Vectors after shorts removed: " << nvec << " "
1259  << fVectors[ista].size() << endl;
1260 
1261  } // for (Int_t ista = 0;
1262 }
1263 // -------------------------------------------------------------------------
1264 
1265 // ----- Private method StoreVectors -----------------------------------
1267  // Store vectors (CbmMuchTracks) into TClonesArray
1268 
1269  Int_t ntrs = fTrackArray->GetEntriesFast();
1270  Int_t nHitsTot = fHits->GetEntriesFast();
1271 
1272  for (Int_t ist = 0; ist < fgkStat; ++ist) {
1273  set<Int_t> usedHits;
1274  Int_t nvec = fVectors[ist].size();
1275 
1276  for (Int_t iv = 0; iv < nvec; ++iv) {
1277  CbmMuchTrack* tr =
1278  new ((*fTrackArray)[ntrs++]) CbmMuchTrack(*(fVectors[ist][iv]));
1279  //cout << " Track: " << tr->GetNofHits() << endl;
1280  //for (Int_t j = 0; j < tr->GetNofHits(); ++j) cout << j << " " << tr->GetHitIndex(j) << " " << fVectors[ist][iv]->GetHitIndex(j) << endl;
1281  // Set hit flag (to check Lit tracking)
1282  Int_t nhits = tr->GetNofHits();
1283  /*
1284  for (Int_t j = 0; j < nhits; ++j) {
1285  CbmMuchStrawHit *hit = (CbmMuchStrawHit*) fHits->UncheckedAt(tr->GetHitIndex(j));
1286  if (usedHits.find(tr->GetHitIndex(j)) == usedHits.end()) {
1287  hit->SetFlag(ntrs-1);
1288  usedHits.insert(tr->GetHitIndex(j));
1289  } else {
1290  // Ugly interim solution for the tracking - create new hit
1291  CbmMuchStrawHit *hitNew = new ((*fHits)[nHitsTot++]) CbmMuchStrawHit(*hit);
1292  hitNew->SetFlag(ntrs-1);
1293  usedHits.insert(nHitsTot-1);
1294  }
1295  }
1296  */
1297  }
1298  }
1299 }
1300 // -------------------------------------------------------------------------
1301 
1302 // ----- Private method CountBits --------------------------------------
1303 //This is better when most bits in x are 0
1304 //It uses 3 arithmetic operations and one comparison/branch per "1" bit in x.
1305 // Wikipedia "Hamming weight"
1307 
1308  Int_t count;
1309  for (count = 0; x; count++)
1310  x &= x - 1;
1311  return count;
1312 }
1313 // -------------------------------------------------------------------------
1314 
1315 // ----- Private method MatchVectors -----------------------------------
1317  // Match vectors from 2 stations
1318 
1319  const Int_t iabs = 3;
1320  CbmMuchMergeVectors* merger =
1321  (CbmMuchMergeVectors*) FairRun::Instance()->GetTask("MuchMergeVectors");
1322  TMatrixF matr = TMatrixF(5, 5);
1323  TMatrixF unit(TMatrixF::kUnit, matr);
1324 
1325  for (Int_t ista = 0; ista < fgkStat; ++ista) {
1326  Int_t nvec = fVectors[ista].size();
1327 
1328  // Propagate vectors to the absorber face
1329  for (Int_t iv = 0; iv < nvec; ++iv) {
1330  CbmMuchTrack* vec = fVectors[ista][iv];
1331  FairTrackParam parFirst = *vec->GetParamFirst();
1332  Double_t zbeg = parFirst.GetZ();
1333  Double_t dz = fZabs0[iabs][0] - zbeg;
1334  // Propagate params
1335  parFirst.SetX(parFirst.GetX() + dz * parFirst.GetTx());
1336  parFirst.SetY(parFirst.GetY() + dz * parFirst.GetTy());
1337  parFirst.SetZ(parFirst.GetZ() + dz);
1338  TMatrixFSym cov(5);
1339  parFirst.CovMatrix(cov);
1340  cov(4, 4) = 1.0;
1341  TMatrixF ff = unit;
1342  ff(2, 0) = ff(3, 1) = dz;
1343  TMatrixF cf(cov, TMatrixF::kMult, ff);
1344  TMatrixF fcf(ff, TMatrixF::kTransposeMult, cf);
1345  cov.SetMatrixArray(fcf.GetMatrixArray());
1346  if (ista == 1)
1347  merger->PassAbsorber(
1348  ista + iabs * 2, fZabs0[iabs], fX0abs[iabs], parFirst, cov, 0);
1349  cov.Invert(); // weight matrix
1350  parFirst.SetCovMatrix(cov);
1351  vec->SetParamLast(&parFirst);
1352  }
1353  }
1354 
1355  Int_t ista0 = 0, ista1 = 1;
1356  vector<Int_t> matchOK[2];
1357  Int_t nvec0 = fVectors[ista0].size(), nvec1 = fVectors[ista1].size();
1358  matchOK[0].assign(nvec0, -1);
1359  matchOK[1].assign(nvec1, -1);
1360 
1361  for (Int_t iv = 0; iv < nvec0; ++iv) {
1362  CbmMuchTrack* tr1 = fVectors[ista0][iv];
1363  FairTrackParam parOk = *tr1->GetParamLast();
1364  FairTrackParam par1 = *tr1->GetParamLast();
1365  TMatrixFSym w1(5);
1366  par1.CovMatrix(w1);
1367  Float_t pars1[5] = {(Float_t) par1.GetX(),
1368  (Float_t) par1.GetY(),
1369  (Float_t) par1.GetTx(),
1370  (Float_t) par1.GetTy(),
1371  1.0};
1372  TMatrixF p1(5, 1, pars1);
1373  TMatrixF wp1(w1, TMatrixF::kTransposeMult, p1);
1374 
1375  for (Int_t iv1 = 0; iv1 < nvec1; ++iv1) {
1376  CbmMuchTrack* tr2 = fVectors[ista1][iv1];
1377  FairTrackParam par2 = *tr2->GetParamLast();
1378  TMatrixFSym w2(5);
1379  par2.CovMatrix(w2);
1380  TMatrixFSym w20 = w2;
1381  Float_t pars2[5] = {(Float_t) par2.GetX(),
1382  (Float_t) par2.GetY(),
1383  (Float_t) par2.GetTx(),
1384  (Float_t) par2.GetTy(),
1385  1.0};
1386  TMatrixF p2(5, 1, pars2);
1387  TMatrixF wp2(w2, TMatrixF::kTransposeMult, p2);
1388  wp2 += wp1;
1389  w2 += w1;
1390  w2.Invert();
1391  TMatrixF p12(w2, TMatrixF::kTransposeMult, wp2);
1392 
1393  // Compute Chi2
1394  TMatrixF p122 = p12;
1395  TMatrixF pMerge = p12;
1396  p12 -= p1;
1397  TMatrixF wDp1(w1, TMatrixF::kMult, p12);
1398  TMatrixF chi21(p12, TMatrixF::kTransposeMult, wDp1);
1399  p122 -= p2;
1400  TMatrixF wDp2(w20, TMatrixF::kMult, p122);
1401  TMatrixF chi22(p122, TMatrixF::kTransposeMult, wDp2);
1402  Double_t c2 = chi21(0, 0) + chi22(0, 0);
1403  //cout << " Chi2: " << chi21(0,0) << " " << chi22(0,0) << " " << c2 << endl;
1404  if (c2 < 0 || c2 > fCutChi2 * 2) continue;
1405  matchOK[0][iv] = matchOK[1][iv1] = 1; // match OK
1406  // Merged track parameters
1407  parOk.SetX(pMerge(0, 0));
1408  parOk.SetY(pMerge(1, 0));
1409  parOk.SetZ(par2.GetZ());
1410  parOk.SetTx(pMerge(2, 0));
1411  parOk.SetTy(pMerge(3, 0));
1412  parOk.SetCovMatrix(w2);
1413  //AddTrack(ista0, tr1, tr2, it->first, it1->first, parOk, c2); // add track
1414  //Int_t evNo = FairRun::Instance()->GetEventHeader()->GetMCEntryNumber();
1415  }
1416  }
1417 
1418  for (Int_t ista = 0; ista < fgkStat; ++ista) {
1419  Int_t nvec = fVectors[ista].size();
1420 
1421  for (Int_t iv = nvec - 1; iv >= 0; --iv) {
1422  if (matchOK[ista][iv] > 0) continue;
1423  fVectors[ista].erase(fVectors[ista].begin() + iv);
1424  }
1425  }
1426 
1427  cout << " Vectors after matching: " << fVectors[0].size() << " "
1428  << fVectors[1].size() << endl;
1429 }
1430 // -------------------------------------------------------------------------
1431 
1432 // ----- Private method RemoveOutliers ---------------------------------
1434  Int_t patt0,
1435  Double_t uu[fgkPlanes][2]) {
1436  // Find line with the lowest number of outliers and smallest sum of their chi2
1437  // - remove outliers and refit
1438 
1439  const Double_t thresh = 6.0; // chi2-cut
1440  Double_t qualmin = 99.0, qual = 0.0;
1441  multimap<Int_t, multimap<Double_t, Int_t>>::iterator mit = fFailed.begin(),
1442  mit0 = mit;
1443  Int_t patt = patt0, pattmin = patt0;
1444 
1445  for (; mit != fFailed.end(); ++mit) {
1446  multimap<Double_t, Int_t>& chi2s = mit->second;
1447  Double_t c2sum = 0.0, outl = 0.0;
1448  patt = patt0;
1449 
1450  for (multimap<Double_t, Int_t>::reverse_iterator rit = chi2s.rbegin();
1451  rit != chi2s.rend();
1452  ++rit) {
1453  if (rit->first <= thresh) break;
1454  outl += 1;
1455  c2sum += rit->first;
1456  patt &= ~(1 << rit->second);
1457  }
1458  // Check doublets
1459  Int_t nDouble = 0;
1460  for (Int_t j = 0; j < fgkPlanes; j += 2)
1461  if (patt & (3 << j))
1462  ++nDouble;
1463  else
1464  break;
1465  if (nDouble < fgkPlanes / 2) continue;
1466  qual = outl + TMath::Min(c2sum, 999.) / 1000;
1467  if (qual < qualmin) {
1468  qualmin = qual;
1469  mit0 = mit;
1470  pattmin = patt;
1471  }
1472  }
1473 
1474  if (Int_t(qualmin) > 3) return; // too many outliers
1475 
1476  Int_t nCombs = (patt & 1) ? 2 : 1, flag = 1, nok = nCombs - 1;
1477 
1478  for (Int_t icomb = -1; icomb < nCombs; icomb += 2) {
1479  fUz[0][0] = (nCombs == 2) ? uu[0][0] + uu[0][1] * icomb : 0.0;
1480  //if (ichoice > 1 && nCombs > 1 && icomb != vecTmp.GetLR(0)) continue;
1481  //ProcessSingleHigh(ichoice, 1, patt, 1, 1, uu, &vecTmp);
1482  ProcessSingleHigh(ista, 1, pattmin, flag, nok, uu);
1483  }
1484 }
1485 // -------------------------------------------------------------------------
1486 
CbmMuchMergeVectors.h
CbmMuchModule.h
CbmTrack::GetChiSq
Double_t GetChiSq() const
Definition: CbmTrack.h:58
CbmMuchFindVectors::RemoveShorts
void RemoveShorts()
Definition: CbmMuchFindVectors.cxx:1200
CbmMuchFindVectors::MoveVectors
void MoveVectors()
Definition: CbmMuchFindVectors.cxx:1085
CbmTrack::GetParamLast
const FairTrackParam * GetParamLast() const
Definition: CbmTrack.h:62
CbmMuchGeoScheme
Definition: CbmMuchGeoScheme.h:43
CbmMuchPoint
Definition: CbmMuchPoint.h:21
CbmMuchGeoScheme::GetModule
CbmMuchModule * GetModule(Int_t iStation, Int_t iLayer, Bool_t iSide, Int_t iModule) const
Definition: CbmMuchGeoScheme.cxx:238
CbmMuchStation::GetLayer
CbmMuchLayer * GetLayer(Int_t iLayer) const
Definition: CbmMuchStation.h:58
CbmMuchStation
Definition: CbmMuchStation.h:22
CbmMatch::GetLink
const CbmLink & GetLink(Int_t i) const
Definition: CbmMatch.h:35
CbmMatch::GetNofLinks
Int_t GetNofLinks() const
Definition: CbmMatch.h:38
CbmMuchFindVectors::fgkPlanes
static const Int_t fgkPlanes
Definition: CbmMuchFindVectors.h:52
CbmMuchFindVectors::~CbmMuchFindVectors
virtual ~CbmMuchFindVectors()
Definition: CbmMuchFindVectors.cxx:54
CbmTrack::GetNofHits
virtual Int_t GetNofHits() const
Definition: CbmTrack.h:53
CbmMuchFindVectors::fZ0
Double_t fZ0[fgkStat]
Definition: CbmMuchFindVectors.h:79
CbmMuchFindVectors::fMinHits
Int_t fMinHits
Definition: CbmMuchFindVectors.h:78
CbmMuchFindVectors::fCosa
Double_t fCosa[fgkPlanes2]
Definition: CbmMuchFindVectors.h:71
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmMuchFindVectors.h
CbmMuchMergeVectors::PassAbsorber
void PassAbsorber(Int_t ist, Double_t *zabs, Double_t x0, FairTrackParam &parFirst, TMatrixFSym &cov, Int_t pFlag=0)
Definition: CbmMuchMergeVectors.cxx:658
CbmMuchFindVectors::StoreVectors
void StoreVectors()
Definition: CbmMuchFindVectors.cxx:1266
CbmMuchFindVectors::HighRes
void HighRes()
Definition: CbmMuchFindVectors.cxx:969
CbmMuchFindVectors::Init
virtual InitStatus Init()
Definition: CbmMuchFindVectors.cxx:70
CbmMuchFindVectors::ComputeMatrix
void ComputeMatrix()
failed fits
Definition: CbmMuchFindVectors.cxx:250
CbmMuchFindVectors::fRmax
Double_t fRmax[fgkStat]
Definition: CbmMuchFindVectors.h:81
CbmMuchFindVectors::fDigiMatches
TClonesArray * fDigiMatches
Definition: CbmMuchFindVectors.h:61
CbmMuchFindVectors::fMatr
std::map< Int_t, TMatrixDSym * > fMatr
Definition: CbmMuchFindVectors.h:84
Cbm::Sign
int Sign(const T &x)
Definition: CbmUtils.h:36
CbmMuchFindVectors::fX0abs
Double_t fX0abs[9]
Definition: CbmMuchFindVectors.h:88
CbmMuchFindVectors::fHits
TClonesArray * fHits
Definition: CbmMuchFindVectors.h:59
CbmTrack::SetParamLast
void SetParamLast(const FairTrackParam *par)
Definition: CbmTrack.h:76
CbmTrack::SetNDF
void SetNDF(Int_t ndf)
Definition: CbmTrack.h:71
CbmMuchFindVectors::ProcessDouble
void ProcessDouble(Int_t ista, Int_t lay2, Int_t patt, Int_t flag, Int_t tube0, Int_t segment0)
Definition: CbmMuchFindVectors.cxx:608
ClassImp
ClassImp(CbmMuchFindVectors)
CbmMuchFindVectors::fUz
Double_t fUz[fgkPlanes2][3]
Definition: CbmMuchFindVectors.h:68
CbmMuchLayer::GetSide
CbmMuchLayerSide * GetSide(Bool_t side)
Definition: CbmMuchLayer.h:49
CbmMuchTrack
Definition: CbmMuchTrack.h:16
CbmMuchDigiMatch
Definition: CbmMuchDigiMatch.h:17
CbmTrack::SetFlag
void SetFlag(Int_t flag)
Definition: CbmTrack.h:69
CbmMuchFindVectors::GetHits
void GetHits()
Definition: CbmMuchFindVectors.cxx:341
CbmMuchFindVectors::RemoveOutliers
void RemoveOutliers(Int_t ista, Int_t patt, Double_t uu[fgkPlanes][2])
Definition: CbmMuchFindVectors.cxx:1433
CbmMuchGeoScheme::GetLayerSideIndex
static Int_t GetLayerSideIndex(Int_t address)
Definition: CbmMuchGeoScheme.h:74
CbmMuchFindVectors::SetTrackId
void SetTrackId(CbmMuchTrack *vec)
Definition: CbmMuchFindVectors.cxx:799
CbmMuchFindVectors::fVectors
std::vector< CbmMuchTrack * > fVectors[fgkStat]
Definition: CbmMuchFindVectors.h:65
CbmMuchFindVectors::fgkStat
static const Int_t fgkStat
Definition: CbmMuchFindVectors.h:51
CbmMuchGeoScheme::GetNStations
Int_t GetNStations() const
Definition: CbmMuchGeoScheme.h:79
CbmMuchGeoScheme::GetLayerIndex
static Int_t GetLayerIndex(Int_t address)
Definition: CbmMuchGeoScheme.h:71
CbmMuchFindVectors::fFailed
std::multimap< Int_t, std::multimap< Double_t, Int_t > > fFailed
Definition: CbmMuchFindVectors.h:90
CbmMuchPoint.h
CbmMuchTrack.h
CbmMuchMergeVectors
Definition: CbmMuchMergeVectors.h:23
CbmMuchStation::GetRmax
Double_t GetRmax() const
Definition: CbmMuchStation.h:52
CbmMuchFindVectors::fHitPl
std::multimap< Int_t, Int_t > fHitPl[fgkStat][fgkPlanes2]
Definition: CbmMuchFindVectors.h:64
CbmTrack::GetHitIndex
Int_t GetHitIndex(Int_t iHit) const
Definition: CbmTrack.h:54
CbmMuchFindVectors::AddVector
void AddVector(Int_t ista, Int_t patt, Double_t chi2, Double_t *pars, Bool_t lowRes=kTRUE)
Definition: CbmMuchFindVectors.cxx:759
CbmMuchFindVectors::fTrackArray
TClonesArray * fTrackArray
Definition: CbmMuchFindVectors.h:57
CbmMuchFindVectors::fLus
std::map< Int_t, TDecompLU * > fLus
Definition: CbmMuchFindVectors.h:74
CbmTrack::SetChiSq
void SetChiSq(Double_t chiSq)
Definition: CbmTrack.h:70
CbmMuchStation::GetDetectorId
Int_t GetDetectorId() const
Definition: CbmMuchStation.h:48
CbmMuchLayerSide
Definition: CbmMuchLayerSide.h:22
first
bool first
Definition: LKFMinuit.cxx:143
CbmTrack::GetParamFirst
const FairTrackParam * GetParamFirst() const
Definition: CbmTrack.h:61
CbmMuchModule
Definition: CbmMuchModule.h:24
CbmMuchAddress::GetLayerIndex
static Int_t GetLayerIndex(Int_t address)
Definition: CbmMuchAddress.h:106
CbmMuchAddress::GetStationIndex
static Int_t GetStationIndex(Int_t address)
Definition: CbmMuchAddress.h:103
CbmMuchFindVectors::SelDoubleId
Bool_t SelDoubleId(Int_t indx1, Int_t indx2)
Definition: CbmMuchFindVectors.cxx:517
CbmMuchFindVectors::fVectorsHigh
std::vector< CbmMuchTrack * > fVectorsHigh[fgkStat]
Definition: CbmMuchFindVectors.h:67
CbmMuchFindVectors::RemoveClones
void RemoveClones()
Definition: CbmMuchFindVectors.cxx:1102
CbmMuchModule::GetDetectorType
Int_t GetDetectorType() const
Definition: CbmMuchModule.h:52
CbmMuchFindVectors::fHit2d
std::vector< std::pair< Int_t, Int_t > > fHit2d[fgkStat][fgkPlanes2]
Definition: CbmMuchFindVectors.h:86
CbmMuchFindVectors::FindChi2
Double_t FindChi2(Int_t ista, Int_t patt, Double_t *pars)
Definition: CbmMuchFindVectors.cxx:876
CbmMuchAddress::GetElementAddress
static Int_t GetElementAddress(Int_t address, Int_t level)
Definition: CbmMuchAddress.h:122
CbmMuchFindVectors::fSina
Double_t fSina[fgkPlanes2]
Definition: CbmMuchFindVectors.h:72
CbmMuchFindVectors::fGeoScheme
CbmMuchGeoScheme * fGeoScheme
Definition: CbmMuchFindVectors.h:56
CbmMuchFindVectors::fDtubes
Double_t fDtubes[fgkStat][fgkPlanes2]
Definition: CbmMuchFindVectors.h:82
CbmMuchFindVectors::Finish
virtual void Finish()
Definition: CbmMuchFindVectors.cxx:234
v
__m128 v
Definition: L1/vectors/P4_F32vec4.h:1
CbmMuchFindVectors::CountBits
Int_t CountBits(Int_t x)
Definition: CbmMuchFindVectors.cxx:1306
CbmMuchFindVectors::fErrU
Double_t fErrU
Definition: CbmMuchFindVectors.h:75
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmMuchFindVectors::CbmMuchFindVectors
CbmMuchFindVectors()
Definition: CbmMuchFindVectors.cxx:36
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
kMUCHSTRAWHIT
@ kMUCHSTRAWHIT
Definition: CbmHit.h:24
CbmTrack::SetParamFirst
void SetParamFirst(const FairTrackParam *par)
Definition: CbmTrack.h:75
CbmMuchFindVectors::CheckParams
void CheckParams()
Definition: CbmMuchFindVectors.cxx:937
CbmMuchFindVectors
Definition: CbmMuchFindVectors.h:25
CbmMuchFindVectors::fChi2Map
std::multimap< Double_t, Int_t > fChi2Map
Definition: CbmMuchFindVectors.h:89
CbmMuchFindVectors::ProcessSingleHigh
void ProcessSingleHigh(Int_t ista, Int_t plane, Int_t patt, Int_t flag, Int_t nok, Double_t uu[fgkPlanes][2])
Definition: CbmMuchFindVectors.cxx:1015
CbmMuchFindVectors::SetParContainers
virtual void SetParContainers()
Definition: CbmMuchFindVectors.cxx:178
CbmMuchGeoScheme::GetStation
CbmMuchStation * GetStation(Int_t iStation) const
Definition: CbmMuchGeoScheme.cxx:209
CbmMuchStation::GetNLayers
Int_t GetNLayers() const
Definition: CbmMuchStation.h:50
kMuchModule
@ kMuchModule
Module.
Definition: CbmMuchAddress.h:20
CbmMuchDigiMatch.h
CbmMuchFindVectors::FindLine
void FindLine(Int_t patt, Double_t *pars)
Definition: CbmMuchFindVectors.cxx:847
CbmMuchFindVectors::fStatFirst
Int_t fStatFirst
Definition: CbmMuchFindVectors.h:62
CbmMuchFindVectors::fUzi
Double_t fUzi[fgkPlanes2][3]
Definition: CbmMuchFindVectors.h:69
CbmMuchFindVectors::fZabs0
Double_t fZabs0[9][2]
Definition: CbmMuchFindVectors.h:87
CbmMuchFindVectors::fDiam
Double_t fDiam
Definition: CbmMuchFindVectors.h:76
CbmMuchFindVectors::fCutChi2
Double_t fCutChi2
Definition: CbmMuchFindVectors.h:77
CbmMuchLayer
Definition: CbmMuchLayer.h:21
CbmMuchFindVectors::Exec
virtual void Exec(Option_t *opt)
Definition: CbmMuchFindVectors.cxx:182
CbmMuchLayerSide::GetZ
Double_t GetZ()
Definition: CbmMuchLayerSide.h:49
CbmMuchStation::GetRmin
Double_t GetRmin() const
Definition: CbmMuchStation.h:51
CbmMuchFindVectors::fRmin
Double_t fRmin[fgkStat]
Definition: CbmMuchFindVectors.h:80
CbmMuchGeoScheme::GetModuleByDetId
CbmMuchModule * GetModuleByDetId(Int_t detId) const
Definition: CbmMuchGeoScheme.cxx:278
CbmMuchStation.h
CbmTrack::AddHit
void AddHit(Int_t index, HitType type)
Definition: CbmTrack.cxx:75
CbmMuchFindVectors::MatchVectors
void MatchVectors()
Definition: CbmMuchFindVectors.cxx:1316
CbmMuchAddress::GetLayerSideIndex
static Int_t GetLayerSideIndex(Int_t address)
Definition: CbmMuchAddress.h:109
CbmMuchFindVectors::fPoints
TClonesArray * fPoints
Definition: CbmMuchFindVectors.h:60
CbmMuchFindVectors::IntersectViews
Bool_t IntersectViews(Int_t ista, Int_t curLay, Int_t indx1, Int_t indx2, Int_t patt)
Definition: CbmMuchFindVectors.cxx:721
CbmMuchFindVectors::MakeVectors
void MakeVectors()
Definition: CbmMuchFindVectors.cxx:564
CbmMuchFindVectors::fDz
Double_t fDz[fgkPlanes2]
Definition: CbmMuchFindVectors.h:70