CbmRoot
CbmMuchFindVectorsGem.cxx
Go to the documentation of this file.
1 
6 #include "CbmMCDataArray.h"
7 #include "CbmMCDataManager.h"
8 #include "CbmMuchCluster.h"
9 #include "CbmMuchDigiMatch.h"
10 #include "CbmMuchMergeVectors.h"
11 #include "CbmMuchModule.h"
12 #include "CbmMuchModuleGem.h"
13 #include "CbmMuchPixelHit.h"
14 #include "CbmMuchPoint.h"
15 #include "CbmMuchStation.h"
16 #include "CbmMuchTrack.h"
17 #include "CbmSetup.h"
18 
19 #include "FairEventHeader.h"
20 #include "FairRootManager.h"
21 
22 #include <TClonesArray.h>
23 #include <TGeoManager.h>
24 #include <TMath.h>
25 #include <TMatrixD.h>
26 #include <TMatrixFLazy.h>
27 #include <TVectorD.h>
28 
29 #include <iostream>
30 
31 using std::cout;
32 using std::endl;
33 using std::map;
34 using std::multimap;
35 using std::pair;
36 using std::set;
37 using std::vector;
38 
39 //FILE *lun = fopen("chi2.dat","w");
40 
41 // ----- Default constructor -------------------------------------------
43  : FairTask("MuchFindVectorsGem")
44  , fGeoScheme(CbmMuchGeoScheme::Instance())
45  , fVecPool(NULL)
46  , fTrackArray(NULL)
47  , fNofTracks(0)
48  , fHits(NULL)
49  , fClusters(NULL)
50  , fPoints(NULL)
51  , fDigiMatches(NULL)
52  , fTrdVectors(NULL)
53  , fStatFirst(-1)
54 //fCutChi2(40.0)
55 {
56  for (Int_t i = 0; i < 9; ++i)
57  fCutChi2[i] = 12; // chi2/ndf = 6 for 3 hits
58  //for (Int_t i = 0; i < 9; ++i) fCutChi2[i] = 20;
59  //AZ fCutChi2[0] *= 2;
60 }
61 // -------------------------------------------------------------------------
62 
63 // ----- Destructor ----------------------------------------------------
65  fTrackArray->Delete();
66  fVecPool->Delete();
67 
68  for (map<Int_t, TDecompLU*>::iterator it = fLus.begin(); it != fLus.end();
69  ++it)
70  delete it->second;
71 }
72 // -------------------------------------------------------------------------
73 
74 // ----- Public method Init (abstract in base class) --------------------
76 
77  // Get and check FairRootManager
78  FairRootManager* ioman = FairRootManager::Instance();
79  if (ioman == NULL) Fatal("Init", "RootManager not instantiated!");
80 
81  // Create and register MuchTrack array (if necessary)
82  fTrackArray = static_cast<TClonesArray*>(ioman->GetObject("MuchVector"));
83  if (fTrackArray == NULL) {
84  fTrackArray = new TClonesArray("CbmMuchTrack", 100);
85  ioman->Register("MuchVector", "Much", fTrackArray, kTRUE);
86  } else {
87  // MuchVector already exists (from CbmMuchFindVector task)
88  //Fatal("Init", "CbmMuchFindVectors should go after !!!");
89  }
90  fVecPool = new TClonesArray("CbmMuchTrack", 1000);
91 
92  /*
93  CbmMuchFindHitsStraws *hitFinder = (CbmMuchFindHitsStraws*)
94  FairRun::Instance()->GetTask("CbmMuchFindHitsStraws");
95  if (hitFinder == NULL) Fatal("CbmMuchFindTracks::Init", "CbmMuchFindHitsStraws not run!");
96  fDiam = hitFinder->GetDiam(0);
97  */
98 
99  fHits = static_cast<TClonesArray*>(ioman->GetObject("MuchPixelHit"));
100  fClusters = static_cast<TClonesArray*>(ioman->GetObject("MuchCluster"));
101  fDigiMatches = static_cast<TClonesArray*>(ioman->GetObject("MuchDigiMatch"));
102  fTrdVectors = static_cast<TClonesArray*>(ioman->GetObject("TrdVector"));
103  CbmMCDataManager* mcManager =
104  (CbmMCDataManager*) ioman->GetObject("MCDataManager");
105  if (NULL == mcManager) LOG(fatal) << GetName() << ": No CbmMCDataManager!";
106  //fPoints = static_cast<TClonesArray*> (ioman->GetObject("MuchPoint"));
107  fPoints = mcManager->InitBranch("MuchPoint");
108 
109  // Find first GEM station and get some geo constants
110  Int_t nSt = fGeoScheme->GetNStations();
111  for (Int_t i = 0; i < nSt; ++i) {
113  CbmMuchModule* mod = fGeoScheme->GetModule(i, 0, 0, 0);
114  fRmax[i] = 0;
115  if (mod->GetDetectorType() == 2) continue;
116  if (fStatFirst < 0)
118  //cout << " First station: " << fStatFirst << endl;
119  Int_t nLays = st->GetNLayers();
120  fRmin[i - fStatFirst] = st->GetRmin();
121  fRmax[i - fStatFirst] = st->GetRmax();
122  for (Int_t lay = 0; lay < nLays; ++lay) {
123  CbmMuchLayer* layer = st->GetLayer(lay);
124  //Double_t phi = hitFinder->GetPhi(lay);
125  for (Int_t iside = 0; iside < 2; ++iside) {
126  CbmMuchLayerSide* side = layer->GetSide(iside);
127  Int_t plane = lay * 2 + iside;
128  fDz[plane] = side->GetZ();
129  //fCosa[plane] = TMath::Cos(phi);
130  //fSina[plane] = TMath::Sin(phi);
131  if (plane == 0) fZ0[i - fStatFirst] = side->GetZ();
132  fNsect[i - fStatFirst] = side->GetNModules() * 2;
133  /*
134  if (lay) {
135  fDtubes[i-fStatFirst][lay-1] =
136  fRmax[i-fStatFirst] * TMath::Tan (TMath::ASin(fSina[plane]) - TMath::ASin(fSina[plane-2]));
137  fDtubes[i-fStatFirst][lay-1] = TMath::Abs(fDtubes[i-fStatFirst][lay-1]) / fDiam + 10;
138  }
139  */
140  }
141  }
142  }
143  for (Int_t i = fgkPlanes - 1; i >= 0; --i) {
144  fDz[i] -= fDz[0];
145  //cout << fDz[i] << " ";
146  }
147  //cout << endl;
148 
149  // Get absorbers
150  TString tag, fileName;
152  //CbmSetup::Instance()->GetGeoFileName(kMuch, fileName);
153  cout << " ******* MUCH tag ******** " << tag << endl;
154  tag.Prepend("much_");
155 
156  Double_t dzAbs[9] = {0}, zAbs[9] = {0}, radlAbs[9] = {0}, xyzl[3] = {0},
157  xyzg[3] = {0};
158  Int_t nAbs = 0;
159  TGeoVolume* vol = NULL;
160  TGeoNode* much = NULL;
161 
162  // Go to MUCH
163  gGeoManager->CdTop();
164  TGeoNode* cave = gGeoManager->GetCurrentNode();
165  for (Int_t iNode = 0; iNode < cave->GetNdaughters(); iNode++) {
166  TGeoNode* node = cave->GetDaughter(iNode);
167  TString name = node->GetName();
168  if (name.Contains("much")) {
169  much = node;
170  gGeoManager->CdDown(iNode);
171  break;
172  }
173  }
174 
175  TGeoVolume* muchV = gGeoManager->GetVolume(tag);
176  Int_t ndaught = muchV->GetNdaughters();
177 
178  // Loop over daughters
179  for (Int_t i = 0; i < ndaught; ++i) {
180  vol = muchV->GetNode(i)->GetVolume();
181  if (!(TString(vol->GetName()).Contains("absorber"))) continue;
182  gGeoManager->CdDown(i);
183  nAbs = vol->GetNdaughters();
184  //cout << " aaaaa " << nAbs << endl;
185 
186  for (Int_t iabs = 0; iabs < nAbs; ++iabs) {
187  TGeoVolume* block = vol->GetNode(iabs)->GetVolume();
188  gGeoManager->CdDown(iabs);
189  TGeoVolume* abso = block->GetNode(0)->GetVolume();
190  gGeoManager->CdDown(0);
191  //cout << gGeoManager->GetPath() << endl;
192  gGeoManager->LocalToMaster(xyzl, xyzg);
193  zAbs[iabs] = xyzg[2];
194  //cout << abso->GetName() << " " << abso->GetShape()->GetName() << " "
195  // << ((TGeoBBox*)abso->GetShape())->GetDZ() << " " << xyzg[2] << endl;
196  dzAbs[iabs] = ((TGeoBBox*) abso->GetShape())->GetDZ();
197  radlAbs[iabs] = abso->GetMaterial()->GetRadLen();
198  fZabs0[iabs][0] = zAbs[iabs] - dzAbs[iabs];
199  fZabs0[iabs][1] = zAbs[iabs] + dzAbs[iabs];
200  fX0abs[iabs] = radlAbs[iabs];
201  gGeoManager->CdUp();
202  gGeoManager->CdUp();
203  }
204  }
205 
206  // Combine 2 first absorbers into 1
207  for (Int_t i = 1; i < nAbs; ++i) {
208  if (i == 1)
209  fZabs0[i - 1][1] = fZabs0[i][1];
210  else {
211  fZabs0[i - 1][0] = fZabs0[i][0];
212  fZabs0[i - 1][1] = fZabs0[i][1];
213  fX0abs[i - 1] = fX0abs[i];
214  }
215  }
216  --nAbs;
217  fX0abs[nAbs] = 1.e9; // flag
218 
219  cout << " \n !!! MUCH Absorbers: " << nAbs << "\n Zbeg, Zend, X0:";
220  for (Int_t j = 0; j < nAbs; ++j)
221  cout << " " << std::setprecision(4) << fZabs0[j][0] << ", " << fZabs0[j][1]
222  << ", " << fX0abs[j] << ";";
223  cout << endl << endl;
224 
225  // Station dependent errors
226  //Double_t errs[9] = {0.4, 0.6, 1.2, 1.7, 0};
227  Double_t errs[9] = {0.6, 0.8, 1.2, 1.7, 0};
228  for (Int_t j = 0; j < fgkStat; ++j)
229  fErrX[j] = fErrY[j] = errs[j];
230 
231  ComputeMatrix(); // compute system matrices
232 
233  return kSUCCESS;
234 }
235 // -------------------------------------------------------------------------
236 
237 // ----- SetParContainers -------------------------------------------------
239 // -------------------------------------------------------------------------
240 
241 // ----- Public method Exec --------------------------------------------
242 void CbmMuchFindVectorsGem::Exec(Option_t* opt) {
243 
244  //fTrackArray->Delete();
245  fVecPool->Delete();
246  FairTask* strawHitFinder =
247  FairRun::Instance()->GetTask("CbmMuchFindHitsStraws");
248  if (strawHitFinder == NULL) fTrackArray->Delete();
249 
250  for (Int_t i = 0; i < fgkStat; ++i) {
251  fVectors[i].clear();
252  fSecVec[i].clear();
253  }
254 
255  // Do all processing
256 
257  // Get hits
258  GetHits();
259 
260  for (Int_t ista = fgkStat - 1; ista >= 0; --ista) {
261  // Build vectors
262  MakeVectors(ista);
263 
264  // Remove vectors with wrong orientation
265  // (using empirical cuts for omega muons at 8 GeV)
266  CheckParams(ista);
267 
268  // Match vectors from 2 stations
269  //MatchVectors();
270 
271  // Remove clones
272  RemoveClones(ista);
273  }
274 
275  // Store vectors
276  StoreVectors();
277 }
278 // -------------------------------------------------------------------------
279 
280 // ----- Public method Finish ------------------------------------------
282  fTrackArray->Delete();
283  fVecPool->Delete();
284 
285  for (map<Int_t, TDecompLU*>::iterator it = fLus.begin(); it != fLus.end();
286  ++it)
287  delete it->second;
288 }
289 // -------------------------------------------------------------------------
290 
291 // ----- Private method ComputeMatrix ----------------------------------
293  // Compute system matrices for different hit plane patterns
294 
295  Double_t dz2[fgkPlanes];
296  Bool_t onoff[fgkPlanes];
297 
298  for (Int_t i = 0; i < fgkPlanes; ++i) {
299  dz2[i] = fDz[i] * fDz[i];
300  onoff[i] = kTRUE;
301  }
302 
303  TMatrixD coef(4, 4);
304  Int_t pattMax = 1 << fgkPlanes, nDouble = 0, nTot = 0;
305 
306  // Loop over doublet patterns
307  for (Int_t ipat = 1; ipat < pattMax; ++ipat) {
308 
309  // Check if the pattern is valid: all doublets are active
310  nDouble = 0;
311  //AZ for (Int_t j = 0; j < fgkPlanes; j += 2) if (ipat & (3 << j)) ++nDouble; else break;
312  for (Int_t j = 0; j < fgkPlanes; j += 2)
313  if (ipat & (3 << j)) ++nDouble;
314  if (nDouble < fgkPlanes / 2 - 1) continue; // allow 2-hit vectors
315  ++nTot;
316 
317  for (Int_t j = 0; j < fgkPlanes; ++j)
318  onoff[j] = (ipat & (1 << j));
319 
320  coef = 0.0;
321  for (Int_t i = 0; i < fgkPlanes; ++i) {
322  if (!onoff[i]) continue;
323  coef(0, 0) += 1;
324  coef(0, 1) += 0;
325  coef(0, 2) += fDz[i];
326  coef(0, 3) += 0;
327  }
328  for (Int_t i = 0; i < fgkPlanes; ++i) {
329  if (!onoff[i]) continue;
330  coef(1, 0) += 0;
331  coef(1, 1) += 1;
332  coef(1, 2) += 0;
333  coef(1, 3) += fDz[i];
334  }
335  for (Int_t i = 0; i < fgkPlanes; ++i) {
336  if (!onoff[i]) continue;
337  coef(2, 0) += fDz[i];
338  coef(2, 1) += 0;
339  coef(2, 2) += dz2[i];
340  coef(2, 3) += 0;
341  }
342  for (Int_t i = 0; i < fgkPlanes; ++i) {
343  if (!onoff[i]) continue;
344  coef(3, 0) += 0;
345  coef(3, 1) += fDz[i];
346  coef(3, 2) += 0;
347  coef(3, 3) += dz2[i];
348  }
349 
350  TDecompLU* lu = new TDecompLU(4);
351  lu->SetMatrix(coef);
352  lu->SetTol(0.1 * lu->GetTol());
353  lu->Decompose();
354  fLus.insert(pair<Int_t, TDecompLU*>(ipat, lu));
355  TMatrixDSym cov(4);
356  cov.SetMatrixArray(coef.GetMatrixArray());
357  cov.Invert(); // covar. matrix
358  fMatr.insert(pair<Int_t, TMatrixDSym*>(ipat, new TMatrixDSym(cov)));
359  TString buf = "";
360  for (Int_t jp = 0; jp < fgkPlanes; ++jp)
361  buf += Bool_t(ipat & (1 << jp));
362  Info("ComputeMatrix",
363  " Determinant: %s %i %f",
364  buf.Data(),
365  ipat,
366  coef.Determinant());
367  if (ipat == 63) {
368  coef.Print();
369  Info("ComputeMatrix", " Number of configurations: %i", nTot);
370  }
371  //cout << " Number of configurations: " << nTot << endl; }
372  cov *= (1.2 * 1.2);
373  cout << TMath::Sqrt(cov(0, 0)) << " " << TMath::Sqrt(cov(1, 1)) << " "
374  << TMath::Sqrt(cov(2, 2)) << " " << TMath::Sqrt(cov(3, 3)) << endl;
375  cov *= (1.7 * 1.7 / 1.2 / 1.2);
376  cout << TMath::Sqrt(cov(0, 0)) << " " << TMath::Sqrt(cov(1, 1)) << " "
377  << TMath::Sqrt(cov(2, 2)) << " " << TMath::Sqrt(cov(3, 3)) << endl;
378  }
379 }
380 // -------------------------------------------------------------------------
381 
382 // ----- Private method GetHits ----------------------------------------
384  // Group hits according to their plane number
385 
386  for (Int_t ista = 0; ista < fgkStat; ++ista) {
387  for (Int_t i = 0; i < fgkPlanes; ++i) {
388  fHitPl[ista][i].clear();
389  fHitX[ista][i].clear();
390  }
391  //for (Int_t i = 0; i < fgkPlanes / 2; ++i) fHit2d[ista][i].clear();
392  }
393 
394  Int_t nHits = fHits->GetEntriesFast(), nSelTu[fgkStat] = {0}, sel = 0;
395  for (Int_t i = 0; i < nHits; ++i) {
396  CbmMuchPixelHit* hit = (CbmMuchPixelHit*) fHits->UncheckedAt(i);
397 
399  sel = 1; //SelectHitId(hit);
400  if (!sel) continue;
401  //
402 
403  Int_t detId = hit->GetAddress();
404  CbmMuchModule* module = fGeoScheme->GetModuleByDetId(detId);
405  if (module->GetDetectorType() == 2) continue; // skip straw hits
406  UInt_t address = CbmMuchAddress::GetElementAddress(detId, kMuchModule);
407  Int_t station3 = CbmMuchAddress::GetStationIndex(address); // station
408  Int_t doublet = CbmMuchAddress::GetLayerIndex(address); // doublet
409  Int_t layer =
410  CbmMuchAddress::GetLayerSideIndex(address); // layer in doublet
411  Int_t sector = CbmMuchAddress::GetModuleIndex(address); // sector
412  fHitPl[station3 - fStatFirst][doublet].insert(
413  pair<Int_t, Int_t>(sector, i));
414  fHitX[station3 - fStatFirst][doublet].insert(
415  pair<Double_t, Int_t>(hit->GetX(), i));
416  //cout << station3 << " " << doublet << " " << sector << endl;
417  //if (fErrU < 0) fErrU = hit->GetDu();
418  if (sel) ++nSelTu[station3 - fStatFirst];
419  }
420 }
421 // -------------------------------------------------------------------------
422 
423 // ----- Private method SelectHitId ------------------------------------
425  // Select hits with certain track IDs (for debugging) - FIXME (it is for straws)
426 
427  Int_t nSel = 2, idSel[2] = {0, 1}, id = 0;
428 
429  for (Int_t i = 0; i < nSel; ++i) {
430  if (hit->GetFlag() % 2) {
431  //if (0) {
432  // Mirror hit
433  return kFALSE;
434  } else {
435  CbmMuchDigiMatch* digiM =
436  (CbmMuchDigiMatch*) fDigiMatches->UncheckedAt(hit->GetRefId());
437  Int_t np = digiM->GetNofLinks();
438  for (Int_t ip = 0; ip < np; ++ip) {
439  //CbmMuchPoint* point = (CbmMuchPoint*) fPoints->UncheckedAt(digiM->GetLink(ip).GetIndex());
440  CbmLink link = digiM->GetLink(ip);
441  //CbmMuchPoint* point = (CbmMuchPoint*)
442  //fPoints->Get(0,digiM->GetLink(ip).GetEntry(),digiM->GetLink(ip).GetIndex());
443  CbmMuchPoint* point =
444  (CbmMuchPoint*) fPoints->Get(0, link.GetEntry(), link.GetIndex());
445  id = point->GetTrackID();
446  if (id == idSel[i]) return kTRUE;
447  }
448  }
449  }
450  return kFALSE;
451 }
452 // -------------------------------------------------------------------------
453 
454 // ----- Private method GetDowns ---------------------------------------
456  Int_t ista,
457  vector<pair<Double_t, Double_t>>& vecDowns) {
458  // Get extrapolated coordinates of vectors from the downstream station
459 
460  Int_t nvec = 0, straw = 0;
461  if (ista != fgkStat - 1 && fRmax[ista + 1] < 1.0) {
462  nvec = fTrackArray->GetEntriesFast();
463  straw = 1;
464  } else if (ista != fgkStat - 1)
465  nvec = fVectors[ista + 1].size();
466 
467  for (Int_t i = 0; i < nvec; ++i) {
468  CbmMuchTrack* tr = (straw) ? (CbmMuchTrack*) fTrackArray->UncheckedAt(i)
469  : fVectors[ista + 1][i];
470  if (tr->GetUniqueID() != ista + 1) continue;
471  FairTrackParam parFirst = *tr->GetParamFirst();
472  Double_t zbeg = parFirst.GetZ();
473  Double_t dz = fZ0[ista] + fDz[fgkPlanes - 1] - zbeg;
474  // Propagate params
475  Double_t x = parFirst.GetX() + dz * parFirst.GetTx();
476  Double_t y = parFirst.GetY() + dz * parFirst.GetTy();
477  vecDowns.push_back(pair<Double_t, Double_t>(x, y));
478  }
479  return vecDowns.size();
480 }
481 // -------------------------------------------------------------------------
482 
483 // ----- Private method MakeVectors ------------------------------------
485  // Make vectors for stations - either all or using windows defined
486  // by vectors from the next (downstream) station
487 
488  const Double_t window0 = 5.0; //7.0; //10.0;
489  //const Double_t window0 = 7.5; //10.0;
490  Int_t nvec = 0;
491 
492  //for (Int_t ista = 0; ista < fgkStat; ++ista) {
493  //for (Int_t ista = fgkStat-1; ista >= 0; --ista) {
494  for (Int_t ista = ista0; ista >= ista0; --ista) {
495  fVectors[ista].clear();
496  CbmMuchPixelHit* hit = NULL;
497 
498  // Get vectors from the downstream station
499  if (fRmax[ista] < 1.0) continue;
500  //Int_t lay2 = 0, patt = 0, flag = 0, nhits = fHitPl[ista][lay2].size();
501  Int_t lay2 = fgkPlanes / 2 - 1, patt = 0, flag = 0,
502  nhits = fHitPl[ista][lay2].size();
503  cout << " Hits: " << ista << " " << lay2 << " " << nhits << endl;
504  vector<pair<Double_t, Double_t>> vecDowns;
505  //nvec = GetDowns(ista, vecDowns);
506  multimap<Double_t, Int_t>::iterator mit, mitb, mite, mit1;
507  Double_t window = window0;
508  //if (ista == 0) window /= 1.5;
509 
510  //if (ista == fgkStat - 1) { // no constraints for st. 4
511  if (ista >= fgkStat - 2) { // no constraints for st. 3 and 4
512  // All-GEM configuration
513  //if (CbmSetup::Instance()->IsActive(kTrd)) {
514  if (0) {
515  // Use TRD vectors for guidance
516  nvec = GetTrdVectors(vecDowns);
517  } else {
518  // No TRD present
519  nvec = 2; // account for missing last layer
520  vecDowns.push_back(pair<Double_t, Double_t>(0.0, 0.0));
521  vecDowns.push_back(pair<Double_t, Double_t>(0.0, 0.0));
522  window = 999.0;
523  }
524  } else
525  nvec = GetDowns(ista, vecDowns);
526  Int_t indsta0 = 1 + ista * fgkPlanes;
527 
528  for (Int_t iv = 0; iv < nvec; ++iv) {
529  if (ista > 1 && iv == 1) --lay2; // take last but one layer
530  Double_t xv = vecDowns[iv].first, yv = vecDowns[iv].second;
531  mitb = fHitX[ista][lay2].lower_bound(xv - window); // lower X-window edge
532  mite = fHitX[ista][lay2].upper_bound(xv + window); // upper X-window edge
533  /*
534  if (mitb == mite && ista > 1) {
535  // If no hit in the last layer of the last or last but one stations - take last but one layer
536  --lay2;
537  mitb = fHitX[ista][lay2].lower_bound(xv-window); // lower X-window edge
538  mite = fHitX[ista][lay2].upper_bound(xv+window); // upper X-window edge
539  }
540  */
541  mit1 = mite;
542  Int_t inWin = 0;
543  Double_t ywin1 = yv - window, ywin2 = yv + window;
544 
545  for (mit = mitb; mit != mite; ++mit) {
546  if (mit1 != mite) {
547  fHitX[ista][lay2].erase(mit1); // remove processed hit
548  mit1 = mite;
549  }
550  Int_t indx = mit->second;
551  hit = (CbmMuchPixelHit*) fHits->UncheckedAt(indx);
552  if (hit->GetY() < ywin1 || hit->GetY() > ywin2) continue;
553  //Int_t lay = hit->GetPlaneId() - 1 - ista * fgkPlanes;
554  Int_t lay = hit->GetPlaneId() - indsta0;
555  fXy[lay][0] = hit->GetX();
556  fXy[lay][1] = hit->GetY();
557  //fXy[lay][2] = hit->GetDx();
558  //fXy[lay][3] = hit->GetDy();
559  fXy[lay][2] = TMath::Max(hit->GetDx(), fErrX[ista]);
560  fXy[lay][3] = TMath::Max(hit->GetDy(), fErrY[ista]);
561  fXy[lay][4] = hit->GetZ();
562  fXyi[lay][0] =
563  CbmMuchAddress::GetModuleIndex(hit->GetAddress()); // sector No.
564  fXyi[lay][1] = indx;
565  //patt = lay + 1;
566  patt = (1 << lay);
567  //cout << lay << " " << hit->GetX() << " " << hit->GetY() << " " << hit->GetZ() << " " << endl;
568  //ProcessPlane(ista, lay2+1, patt, flag);
569  ProcessPlane(ista, lay2 - 1, patt, flag);
570  mit1 = mit;
571  inWin = 1;
572  }
573 
574  if (inWin == 0 && ista == 1) {
575  //if (0) {
576  // No hits inside window - increase window size and repeat (for one station only)
577  window = window0 * 1.5;
578  mitb =
579  fHitX[ista][lay2].lower_bound(xv - window); // lower X-window edge
580  mite =
581  fHitX[ista][lay2].upper_bound(xv + window); // upper X-window edge
582  mit1 = mite;
583 
584  for (mit = mitb; mit != mite; ++mit) {
585  //AZ if (mit1 != mite) fHitX[ista][lay2].erase(mit1); // remove processed hit
586  if (mit1 != mite) {
587  fHitX[ista][lay2].erase(mit1);
588  break;
589  } // remove processed hit
590  mit1 = mite;
591  Int_t indx = mit->second;
592  hit = (CbmMuchPixelHit*) fHits->UncheckedAt(indx);
593  if (hit->GetY() < yv - window || hit->GetY() > yv + window) continue;
594  Int_t lay = hit->GetPlaneId() - indsta0;
595  fXy[lay][0] = hit->GetX();
596  fXy[lay][1] = hit->GetY();
597  //fXy[lay][2] = hit->GetDx();
598  //fXy[lay][3] = hit->GetDy();
599  fXy[lay][2] = TMath::Max(hit->GetDx(), fErrX[ista]);
600  fXy[lay][3] = TMath::Max(hit->GetDy(), fErrY[ista]);
601  fXy[lay][4] = hit->GetZ();
602  fXyi[lay][0] =
603  CbmMuchAddress::GetModuleIndex(hit->GetAddress()); // sector No.
604  fXyi[lay][1] = indx;
605  //patt = lay + 1;
606  patt = (1 << lay);
607  //cout << lay << " " << hit->GetX() << " " << hit->GetY() << " " << hit->GetZ() << " " << endl;
608  //ProcessPlane(ista, lay2+1, patt, flag);
609  ProcessPlane(ista, lay2 - 1, patt, flag);
610  mit1 = mit;
611  }
612  window = window0;
613  }
614  } // for (Int_t iv = 0;
615  }
616 }
617 // -------------------------------------------------------------------------
618 
619 // ----- Private method GetTrdVectors ----------------------------------
621  vector<pair<Double_t, Double_t>>& vecDowns) {
622  // Get extrapolated coordinates of vectors from the TRD
623 
624  Int_t nvec = fTrdVectors->GetEntriesFast();
625 
626  for (Int_t i = 0; i < nvec; ++i) {
627  CbmMuchTrack* tr = (CbmMuchTrack*) fTrdVectors->UncheckedAt(i);
628  FairTrackParam parFirst = *tr->GetParamFirst();
629  Double_t zbeg = parFirst.GetZ();
630  Double_t dz = fZ0[fgkStat - 1] + fDz[fgkPlanes - 1] - zbeg;
631  // Propagate params
632  Double_t x = parFirst.GetX() + dz * parFirst.GetTx();
633  Double_t y = parFirst.GetY() + dz * parFirst.GetTy();
634  vecDowns.push_back(pair<Double_t, Double_t>(x, y));
635  }
636  return vecDowns.size();
637 }
638 // -------------------------------------------------------------------------
639 
640 // ----- Private method ProcessPlane -----------------------------------
642  Int_t lay2,
643  Int_t patt,
644  Int_t flag) {
645  // Main processing engine (recursively adds layer hits to the vector)
646 
647  //const Double_t cut[2] = {0.8, 0.8}; // !!! empirical !!!
648  //const Double_t cut[2] = {0.5, 0.5}; // !!! empirical !!!
649  //AZ const Double_t cut[2][2] = {{0.5, 0.5},{0.6,0.6}}; // !!! empirical !!!
650  //const Double_t cut[2][2] = {{0.5,0.6}, {0.5,0.6}}; // !!! empirical !!!
651  //const Double_t cut[2][2] = {{0.45,0.55}, {0.45,0.55}}; // !!! empirical !!!
652  const Double_t cut[2][2] = {{0.4, 0.5}, {0.4, 0.5}}; // !!! empirical !!!
653 
654  Double_t pars[4] = {0.0};
655  Int_t nhits = fHitPl[ista][lay2].size();
656  //Int_t sec0 = (patt & (1 << lay2*2-1)) ? fXyi[lay2*2-1][0] : fXyi[lay2*2-2][0];
657  Int_t sec0 = (patt & (1 << lay2 * 2 + 3)) ? fXyi[lay2 * 2 + 3][0]
658  : fXyi[lay2 * 2 + 2][0];
659  multimap<Int_t, Int_t>::iterator it;
660  pair<multimap<Int_t, Int_t>::iterator, multimap<Int_t, Int_t>::iterator> ret;
661  Int_t indsta0 = 1 + ista * fgkPlanes;
662 
663  for (Int_t dsec = -1; dsec < 2; ++dsec) {
664  Int_t isec = sec0 + dsec;
665  if (isec < 0)
666  isec += fNsect[ista];
667  else if (isec == fNsect[ista])
668  isec = 0;
669 
670  ret = fHitPl[ista][lay2].equal_range(isec);
671  for (it = ret.first; it != ret.second; ++it) {
672  Int_t indx = it->second, sector = it->first;
673 
674  CbmMuchPixelHit* hit = (CbmMuchPixelHit*) fHits->UncheckedAt(indx);
675  //Int_t lay = hit->GetPlaneId() - 1 - ista * fgkPlanes;
676  Int_t lay = hit->GetPlaneId() - indsta0;
677  fXy[lay][0] = hit->GetX();
678  fXy[lay][1] = hit->GetY();
679  //fXy[lay][2] = hit->GetDx();
680  //fXy[lay][3] = hit->GetDy();
681  fXy[lay][2] = TMath::Max(hit->GetDx(), fErrX[ista]);
682  fXy[lay][3] = TMath::Max(hit->GetDy(), fErrY[ista]);
683  fXy[lay][4] = hit->GetZ();
684 
685  // Check slopes
686  //AZ Int_t lay0 = fgkPlanes - 1;
687  //AZ if (!(patt & (1 << lay0))) --lay0;;
688  Int_t lay0 = TString::Itoa(patt, 2).Length() - 1;
689  Double_t dx = fXy[lay][0] - fXy[lay0][0];
690  Double_t dz = fXy[lay][4] - fXy[lay0][4];
691  Double_t dTx = TMath::Abs(dx / dz - fXy[lay][0] / fXy[lay][4]);
692  if (TMath::Abs(dTx) > cut[0][TMath::Min(ista, 1)]) continue;
693  Double_t dy = fXy[lay][1] - fXy[lay0][1];
694  Double_t dTy = TMath::Abs(dy / dz - fXy[lay][1] / fXy[lay][4]);
695  if (TMath::Abs(dTy) > cut[1][TMath::Min(ista, 1)]) continue;
696 
697  fXyi[lay][0] = sector;
698  fXyi[lay][1] = indx;
699 
700  // Clear bits
701  patt &= ~(1 << lay2 * 2);
702  patt &= ~(1 << lay2 * 2 + 1);
703  // Set bit
704  patt |= (1 << lay);
705  //cout << lay << " " << patt << " " << hit->GetX() << " " << hit->GetY() << " " << hit->GetZ() << " " << endl;
706 
707  //if (lay2 < fgkPlanes / 2 - 1) ProcessPlane(ista, lay2+1, patt, flag);
708  if (lay2 > 0)
709  ProcessPlane(ista, lay2 - 1, patt, flag);
710  else {
711  // Straight line fit of the vector
712  FindLine(patt, pars);
713  Double_t chi2 = FindChi2(ista, patt, pars);
714  //cout << " *** Stat: " << ista << " " << id << " " << indx1 << " " << indx2 << " " << chi2 << " " << pars[0] << " " << pars[1] << endl;
715  if (chi2 <= fCutChi2[ista])
716  AddVector(
717  ista, patt, chi2, pars); // add vector to the temporary container
718  }
719  } // for (it = ret.first;
720  } // for (Int_t dsec = -1; dsec < 2;
721 }
722 // -------------------------------------------------------------------------
723 
724 // ----- Private method AddVector --------------------------------------
726  Int_t patt,
727  Double_t chi2,
728  Double_t* pars) {
729  // Add vector to the temporary container (as a MuchTrack)
730 
731  Bool_t refit = kFALSE; //kTRUE;
732  TMatrixDSym cov(4);
733 
734  if (refit) {
735  // Refit line with individual hit errors
736  //cout << " Before: " << chi2 << endl;
737  Refit(patt, chi2, pars, cov);
738  //cout << " After: " << chi2 << endl;
739  } else {
740  cov = *fMatr[patt];
741  cov *= (fErrX[ista] * fErrX[ista]); // the same error in X and Y
742  }
743  cov.ResizeTo(5, 5);
744  cov(4, 4) = 1.0;
745 
746  Int_t npool = fVecPool->GetEntriesFast();
747  //CbmMuchTrack *track = new ((*fVecPool)[npool]) CbmMuchTrack();
748  CbmMuchTrack* track = (CbmMuchTrack*) fVecPool->ConstructedAt(npool);
749  track->SetChiSq(chi2);
750  FairTrackParam par(pars[0], pars[1], fZ0[ista], pars[2], pars[3], 0.0, cov);
751  track->SetParamFirst(&par);
752  par.SetZ(fZ0[ista] + fDz[fgkPlanes - 1]);
753  par.SetX(pars[0] + fDz[fgkPlanes - 1] * pars[2]);
754  par.SetY(pars[1] + fDz[fgkPlanes - 1] * pars[3]);
755  track->SetParamLast(&par);
756  track->SetUniqueID(ista); // just to pass the value
757 
758  for (Int_t ipl = 0; ipl < fgkPlanes; ++ipl) {
759  if (!(patt & (1 << ipl))) continue;
760  track->AddHit(fXyi[ipl][1], kMUCHPIXELHIT);
761  }
762  Int_t ndf = (track->GetNofHits() > 2) ? track->GetNofHits() * 2 - 4 : 1;
763  track->SetNDF(ndf);
764  SetTrackId(track); // set track ID as its flag
765  fVectors[ista].push_back(track);
766 }
767 // -------------------------------------------------------------------------
768 
769 // ----- Private method SetTrackId -------------------------------------
771  // Set vector ID as its flag (maximum track ID of its poins)
772 
773  map<Int_t, Int_t> ids;
774  Int_t nhits = vec->GetNofHits(), id = 0;
775 
776  for (Int_t ih = 0; ih < nhits; ++ih) {
777  CbmMuchPixelHit* hit =
778  (CbmMuchPixelHit*) fHits->UncheckedAt(vec->GetHitIndex(ih));
779  CbmMuchCluster* clus =
780  (CbmMuchCluster*) fClusters->UncheckedAt(hit->GetRefId());
781  Int_t nDigis = clus->GetNofDigis();
782  for (Int_t j = 0; j < nDigis; ++j) {
783  CbmMuchDigiMatch* digiM =
784  (CbmMuchDigiMatch*) fDigiMatches->UncheckedAt(clus->GetDigi(j));
785  Int_t np = digiM->GetNofLinks();
786  for (Int_t ip = 0; ip < np; ++ip) {
787  //CbmMuchPoint* point = (CbmMuchPoint*) fPoints->UncheckedAt(digiM->GetLink(0).GetIndex());
788  //cout << nhits << " " << ih << " " << j << " " << nDigis << " " << ip << " " << np << " " << fPoints->GetEntriesFast() << " " << fHits->GetEntriesFast() << endl;
789  CbmLink link = digiM->GetLink(ip);
790  //cout << nhits << " " << ih << " " << j << " " << nDigis << " " << ip << " " << np << " " << fPoints->Size(link.GetFile(),link.GetEntry()) << " " << fHits->GetEntriesFast() << endl;
791  //CbmMuchPoint* point = (CbmMuchPoint*) fPoints->UncheckedAt(digiM->GetLink(ip).GetIndex());
792  CbmMuchPoint* point =
793  (CbmMuchPoint*) fPoints->Get(0, link.GetEntry(), link.GetIndex());
794  id = point->GetTrackID();
795  //if (np > 1) cout << ip << " " << id << endl;
796  if (ids.find(id) == ids.end())
797  ids.insert(pair<Int_t, Int_t>(id, 1));
798  else
799  ++ids[id];
800  }
801  //if (np > 1) { cout << " digi " << digiM->GetNofLinks() << " " << ista << " " << hit->GetX() << " " << hit->GetY() << endl; exit(0); }
802  }
803  }
804  Int_t maxim = -1, idmax = -9;
805  for (map<Int_t, Int_t>::iterator it = ids.begin(); it != ids.end(); ++it) {
806  if (it->second > maxim) {
807  maxim = it->second;
808  idmax = it->first;
809  }
810  }
811  // Set vector ID as its flag
812  vec->SetFlag(idmax);
813 }
814 // -------------------------------------------------------------------------
815 
816 // ----- Private method FindLine ---------------------------------------
817 void CbmMuchFindVectorsGem::FindLine(Int_t patt, Double_t* pars) {
818  // Fit of hits to the straight line
819 
820  // Solve system of linear equations
821  Bool_t ok = kFALSE, onoff;
822  TVectorD b(4);
823  for (Int_t i = 0; i < fgkPlanes; ++i) {
824  onoff = patt & (1 << i);
825  if (!onoff) continue;
826  b[0] += fXy[i][0];
827  b[1] += fXy[i][1];
828  b[2] += fXy[i][0] * fDz[i];
829  b[3] += fXy[i][1] * fDz[i];
830  }
831 
832  //lu.Print();
833  TVectorD solve = fLus[patt]->Solve(b, ok);
834  //TVectorD solve = lu.TransSolve(b, ok);
835  //lu.Print();
836  for (Int_t i = 0; i < 4; ++i)
837  pars[i] = solve[i];
838  //for (Int_t i = 0; i < 4; ++i) { cout << pars[i] << " "; if (i == 3) cout << endl; }
839  //Double_t y1 = cosa / sina * (uz[1][0] * cosa - uz[0][0]) + uz[1][0] * sina;
840  //Double_t y2 = -cosa / sina * (uz[2][0] * cosa - uz[0][0]) - uz[2][0] * sina;
841  //cout << " OK " << ok << " " << y1 << " " << y2 << endl;
842 }
843 // -------------------------------------------------------------------------
844 
845 // ----- Private method FindChi2 ---------------------------------------
846 Double_t
847 CbmMuchFindVectorsGem::FindChi2(Int_t ista, Int_t patt, Double_t* pars) {
848  // Compute chi2 of the fit
849 
850  Double_t chi2 = 0, x = 0, y = 0;
851  Bool_t onoff;
852 
853  for (Int_t i = 0; i < fgkPlanes; ++i) {
854  onoff = patt & (1 << i);
855  if (!onoff) continue;
856  x = pars[0] + pars[2] * fDz[i];
857  y = pars[1] + pars[3] * fDz[i];
858  Double_t dx = (x - fXy[i][0]) / fErrX[ista];
859  Double_t dy = (y - fXy[i][1]) / fErrY[ista];
860  chi2 += dx * dx;
861  chi2 += dy * dy;
862  }
863  //cout << " Chi2 = " << chi2 << endl;
864  return chi2;
865 }
866 // -------------------------------------------------------------------------
867 
868 // ----- Private method CheckParams ------------------------------------
870  // Remove vectors with wrong orientation
871  // using empirical cuts for omega muons at 8 Gev
872 
873  //AZ const Double_t cut[2] = {0.6, 0.6}; // !!! empirical !!!
874  const Double_t cut[2] = {0.7, 0.7}; // !!! empirical !!!
875 
876  //AZ for (Int_t ista = 0; ista < fgkStat; ++ista) {
877  for (Int_t ista = ista0; ista <= ista0; ++ista) {
878  Int_t nvec = fVectors[ista].size();
879 
880  for (Int_t iv = 0; iv < nvec; ++iv) {
881  CbmMuchTrack* vec = fVectors[ista][iv];
882  const FairTrackParam* params = vec->GetParamFirst();
883  Double_t dTx = params->GetTx() - params->GetX() / params->GetZ();
884  if (TMath::Abs(dTx) > cut[0])
885  vec->SetChiSq(-1.0);
886  else {
887  Double_t dTy = params->GetTy() - params->GetY() / params->GetZ();
888  if (TMath::Abs(dTy) > cut[1]) vec->SetChiSq(-1.0);
889  }
890  }
891 
892  for (Int_t iv = nvec - 1; iv >= 0; --iv) {
893  CbmMuchTrack* vec = fVectors[ista][iv];
894  if (vec->GetChiSq() < 0)
895  fVectors[ista].erase(fVectors[ista].begin() + iv);
896  }
897  cout << " Vectors after parameter check in station " << ista << ": " << nvec
898  << " " << fVectors[ista].size() << endl;
899 
900  nvec = fVectors[ista].size();
901  for (Int_t iv = 0; iv < nvec; ++iv) {
902  CbmMuchTrack* vec = fVectors[ista][iv];
903  CbmMuchPixelHit* hit =
904  (CbmMuchPixelHit*) fHits->UncheckedAt(vec->GetHitIndex(0));
905  UInt_t address = hit->GetAddress();
906  Int_t isec = CbmMuchAddress::GetModuleIndex(address); // sector
907  fSecVec[ista].insert(pair<Int_t, CbmMuchTrack*>(isec, vec));
908  }
909  }
910 }
911 // -------------------------------------------------------------------------
912 
913 // ----- Private method HighRes ----------------------------------------
914 /*
915 void CbmMuchFindVectorsGem::HighRes()
916 {
917  // High resolution processing (resolve ghost hits and make high resolution vectors)
918 
919  for (Int_t ista = 0; ista < fgkStat; ++ista) {
920  Int_t nvec = fVectors[ista].size();
921 
922  for (Int_t iv = 0; iv < nvec; ++iv) {
923  CbmMuchTrack *vec = fVectors[ista][iv];
924  Int_t nhits = vec->GetNofHits(), patt = 0;
925  Double_t uu[fgkPlanes][2];
926 
927  for (Int_t ih = 0; ih < nhits; ++ih) {
928  CbmMuchPixelHit *hit = (CbmMuchPixelHit*) fHits->UncheckedAt(vec->GetHitIndex(ih));
929  Int_t lay = fGeoScheme->GetLayerIndex(hit->GetAddress());
930  Int_t side = fGeoScheme->GetLayerSideIndex(hit->GetAddress());
931  Int_t plane = lay*2+side;
932  uu[plane][0] = hit->GetU();
933  uu[plane][1] = hit->GetDouble()[2];
934  patt |= (1 << plane);
935  fUzi[plane][0] = hit->GetSegment();
936  fUzi[plane][1] = vec->GetHitIndex(ih);
937  }
938 
939  // Number of hit combinations is 2
940  // - left-right ambiguity resolution does not really work for doublets
941  Int_t nCombs = (patt & 1) ? 2 : 1, flag = 1, nok = nCombs - 1;
942 
943  for (Int_t icomb = -1; icomb < nCombs; icomb += 2) {
944  fUz[0][0] = (nCombs == 2) ? uu[0][0] + uu[0][1] * icomb : 0.0;
945  ProcessSingleHigh(ista, 1, patt, flag, nok, uu);
946  }
947 
948  } // for (Int_t iv = 0;
949  } // for (Int_t ista = 0;
950 
951  MoveVectors(); // move vectors from one container to another, i.e. drop low resolution ones
952 
953 }
954 */
955 // -------------------------------------------------------------------------
956 
957 // ----- Private method ProcessDoubleHigh ------------------------------
958 /*
959 void CbmMuchFindVectorsGem::ProcessSingleHigh(Int_t ista, Int_t plane, Int_t patt, Int_t flag,
960  Int_t nok, Double_t uu[fgkPlanes][2])
961 {
962  // Main processing engine for high resolution mode
963  // (recursively adds singlet hits to the vector)
964 
965  Double_t pars[4] = {0.0};
966 
967  // Number of hit combinations is 2
968  Int_t nCombs = (patt & (1 << plane)) ? 2 : 1;
969  nok += (nCombs - 1);
970 
971  for (Int_t icomb = -1; icomb < nCombs; icomb += 2) {
972  fUz[plane][0] = (nCombs == 2) ? uu[plane][0] + uu[plane][1] * icomb : 0.0;
973  if (plane == fgkPlanes - 1 || nok == fMinHits && flag) {
974  // Straight line fit of the vector
975  Int_t patt1 = patt & ((1 << plane + 1) - 1); // apply mask
976  FindLine(patt1, pars);
977  Double_t chi2 = FindChi2(ista, patt1, pars);
978  //cout << " *** Stat: " << ista << " " << plane << " " << chi2 << " " << pars[0] << " " << pars[1] << endl;
979  if (icomb > -1) flag = 0;
980  if (chi2 > fCutChi2[ista]) continue; // too high chi2 - do not extend line
981  //if (plane + 1 < fgkPlanes) ProcessSingleHigh(ista, plane + 1, patt, flag, nok, uu);
982  if (plane + 1 < fgkPlanes) ProcessSingleHigh(ista, plane + 1, patt, 0, nok, uu);
983  else AddVector(ista, patt, chi2, pars, kFALSE); // add vector to the temporary container
984  } else {
985  ProcessSingleHigh(ista, plane + 1, patt, flag, nok, uu);
986  }
987  }
988 
989 }
990 */
991 // -------------------------------------------------------------------------
992 
993 // ----- Private method RemoveClones -----------------------------------
995  // Remove clone vectors (having at least 1 the same hit)
996 
997  Int_t nthr = 2, planes[20];
998  //Int_t nthr = 1, planes[20];
999  pair<multimap<Int_t, CbmMuchTrack*>::iterator,
1000  multimap<Int_t, CbmMuchTrack*>::iterator>
1001  ret;
1002  multimap<Int_t, CbmMuchTrack*>::iterator itsec;
1003 
1004  //AZ for (Int_t ista = 0; ista < fgkStat; ++ista) {
1005  for (Int_t ista = ista0; ista <= ista0; ++ista) {
1006  // Process according to sector number of the first hit in vector
1007  Int_t nvec = fVectors[ista].size();
1008 
1009  for (Int_t isec = 0; isec < fNsect[ista]; ++isec) {
1010  ret = fSecVec[ista].equal_range(isec);
1011  // Do sorting according to "quality"
1012  multimap<Double_t, CbmMuchTrack*> qMap;
1013  multimap<Double_t, CbmMuchTrack*>::iterator it, it1;
1014 
1015  for (itsec = ret.first; itsec != ret.second; ++itsec) {
1016  CbmMuchTrack* vec = itsec->second;
1017  Double_t qual =
1018  vec->GetNofHits() + (99 - TMath::Min(vec->GetChiSq(), 99.0)) / 100;
1019  qMap.insert(pair<Double_t, CbmMuchTrack*>(-qual, vec));
1020  }
1021 
1022  for (it = qMap.begin(); it != qMap.end(); ++it) {
1023  CbmMuchTrack* vec = it->second;
1024  if (vec->GetChiSq() < 0) continue;
1025  for (Int_t j = 0; j < fgkPlanes; ++j)
1026  planes[j] = -1;
1027 
1028  Int_t nhits = vec->GetNofHits();
1029  for (Int_t ih = 0; ih < nhits; ++ih) {
1030  CbmMuchPixelHit* hit =
1031  (CbmMuchPixelHit*) fHits->UncheckedAt(vec->GetHitIndex(ih));
1032  Int_t lay = fGeoScheme->GetLayerIndex(hit->GetAddress());
1033  Int_t side = fGeoScheme->GetLayerSideIndex(hit->GetAddress());
1034  planes[lay * 2 + side] = vec->GetHitIndex(ih);
1035  //cout << iv << " " << lay*2+side << " " << vec->GetHitIndex(ih) << endl;
1036  }
1037 
1038  it1 = it;
1039  for (++it1; it1 != qMap.end(); ++it1) {
1040  CbmMuchTrack* vec1 = it1->second;
1041  if (vec1->GetChiSq() < 0) continue;
1042  Int_t nsame = 0, same[fgkPlanes / 2] = {0};
1043 
1044  Int_t nhits1 = vec1->GetNofHits();
1045  //nthr = TMath::Min(nhits,nhits1) / 2;
1046  //nthr = TMath::Min(nhits,nhits1) * 0.75;
1047  for (Int_t ih = 0; ih < nhits1; ++ih) {
1048  CbmMuchPixelHit* hit =
1049  (CbmMuchPixelHit*) fHits->UncheckedAt(vec1->GetHitIndex(ih));
1050  Int_t lay = fGeoScheme->GetLayerIndex(hit->GetAddress());
1051  Int_t side = fGeoScheme->GetLayerSideIndex(hit->GetAddress());
1052  if (planes[lay * 2 + side] >= 0) {
1053  if (vec1->GetHitIndex(ih) == planes[lay * 2 + side])
1054  same[lay] = 1;
1055  //else same[lay] = 0;
1056  }
1057  }
1058  for (Int_t lay = 0; lay < fgkPlanes / 2; ++lay)
1059  nsame += same[lay];
1060 
1061  if (nsame >= nthr) {
1062  // Too many the same hits
1063  Int_t clone = 0;
1064  if (nhits > nhits1 + 0) clone = 1;
1065  //else if (vec->GetChiSq() * 1 <= vec1->GetChiSq()) clone = 1; // the same number of hits on 2 tracks
1066  else if (vec->GetChiSq() * 1.5 <= vec1->GetChiSq())
1067  clone = 1; // the same number of hits on 2 tracks
1068  if (clone) vec1->SetChiSq(-1.0);
1069  }
1070  }
1071  } // for (it = qMap.begin();
1072  } // for (Int_t isec = 0; isec < fNsect[ista];
1073 
1074  for (Int_t iv = nvec - 1; iv >= 0; --iv) {
1075  CbmMuchTrack* vec = fVectors[ista][iv];
1076  if (vec->GetChiSq() < 0)
1077  fVectors[ista].erase(fVectors[ista].begin() + iv);
1078  }
1079  cout << " Vectors after clones removed: " << nvec << " "
1080  << fVectors[ista].size() << endl;
1081 
1082  } // for (Int_t ista = 0; ista < fgkStat;
1083 }
1084 // -------------------------------------------------------------------------
1085 
1086 // ----- Private method StoreVectors -----------------------------------
1088  // Store vectors (CbmMuchTracks) into TClonesArray
1089 
1090  Int_t ntrs = fTrackArray->GetEntriesFast();
1091  Int_t nHitsTot = fHits->GetEntriesFast();
1092 
1093  for (Int_t ist = 0; ist < fgkStat; ++ist) {
1094  //set<Int_t> usedHits;
1095  Int_t nvec = fVectors[ist].size();
1096 
1097  for (Int_t iv = 0; iv < nvec; ++iv) {
1098  CbmMuchTrack* tr =
1099  new ((*fTrackArray)[ntrs++]) CbmMuchTrack(*(fVectors[ist][iv]));
1100  //cout << " Track: " << tr->GetNofHits() << endl;
1101  //for (Int_t j = 0; j < tr->GetNofHits(); ++j) cout << j << " " << tr->GetHitIndex(j) << " " << fVectors[ist][iv]->GetHitIndex(j) << endl;
1102  // Set hit flag (to check Lit tracking)
1103  Int_t nhits = tr->GetNofHits();
1104  /*
1105  for (Int_t j = 0; j < nhits; ++j) {
1106  CbmMuchStrawHit *hit = (CbmMuchStrawHit*) fHits->UncheckedAt(tr->GetHitIndex(j));
1107  if (usedHits.find(tr->GetHitIndex(j)) == usedHits.end()) {
1108  hit->SetFlag(ntrs-1);
1109  usedHits.insert(tr->GetHitIndex(j));
1110  } else {
1111  // Ugly interim solution for the tracking - create new hit
1112  CbmMuchStrawHit *hitNew = new ((*fHits)[nHitsTot++]) CbmMuchStrawHit(*hit);
1113  hitNew->SetFlag(ntrs-1);
1114  usedHits.insert(nHitsTot-1);
1115  }
1116  }
1117  */
1118  }
1119  }
1120 }
1121 // -------------------------------------------------------------------------
1122 
1123 // ----- Private method CountBits --------------------------------------
1124 //This is better when most bits in x are 0
1125 //It uses 3 arithmetic operations and one comparison/branch per "1" bit in x.
1126 // Wikipedia "Hamming weight"
1128 
1129  Int_t count;
1130  for (count = 0; x; count++)
1131  x &= x - 1;
1132  return count;
1133 }
1134 // -------------------------------------------------------------------------
1135 
1136 // ----- Private method Refit ------------------------------------------
1138  Double_t& chi2,
1139  Double_t* pars,
1140  TMatrixDSym& cov) {
1141  // Refit line with individual hit errors
1142 
1143  Double_t dz2[fgkPlanes], errx2[fgkPlanes], erry2[fgkPlanes];
1144  Bool_t onoff[fgkPlanes];
1145 
1146  for (Int_t i = 0; i < fgkPlanes; ++i) {
1147  dz2[i] = fDz[i] * fDz[i];
1148  onoff[i] = kTRUE;
1149  }
1150 
1151  TMatrixD coef(4, 4);
1152 
1153  for (Int_t j = 0; j < fgkPlanes; ++j) {
1154  onoff[j] = (patt & (1 << j));
1155  if (!onoff[j]) continue;
1156  errx2[j] = fXy[j][2] * fXy[j][2];
1157  erry2[j] = fXy[j][3] * fXy[j][3];
1158  }
1159 
1160  coef = 0.0;
1161  for (Int_t i = 0; i < fgkPlanes; ++i) {
1162  if (!onoff[i]) continue;
1163  coef(0, 0) += 1 / errx2[i];
1164  coef(0, 1) += 0;
1165  coef(0, 2) += fDz[i] / errx2[i];
1166  coef(0, 3) += 0;
1167  }
1168  for (Int_t i = 0; i < fgkPlanes; ++i) {
1169  if (!onoff[i]) continue;
1170  coef(1, 0) += 0;
1171  coef(1, 1) += 1 / erry2[i];
1172  coef(1, 2) += 0;
1173  coef(1, 3) += fDz[i] / erry2[i];
1174  }
1175  for (Int_t i = 0; i < fgkPlanes; ++i) {
1176  if (!onoff[i]) continue;
1177  coef(2, 0) += fDz[i] / errx2[i];
1178  coef(2, 1) += 0;
1179  coef(2, 2) += dz2[i] / errx2[i];
1180  coef(2, 3) += 0;
1181  }
1182  for (Int_t i = 0; i < fgkPlanes; ++i) {
1183  if (!onoff[i]) continue;
1184  coef(3, 0) += 0;
1185  coef(3, 1) += fDz[i] / erry2[i];
1186  coef(3, 2) += 0;
1187  coef(3, 3) += dz2[i] / erry2[i];
1188  }
1189 
1190  /*
1191  TDecompLU *lu = new TDecompLU(4);
1192  lu->SetMatrix(coef);
1193  lu->SetTol(0.1*lu->GetTol());
1194  lu->Decompose();
1195  */
1196  TDecompLU lu(4);
1197  lu.SetMatrix(coef);
1198  lu.SetTol(0.1 * lu.GetTol());
1199  lu.Decompose();
1200  //fLus.insert(pair<Int_t,TDecompLU*>(ipat,lu));
1201 
1202  TVectorD b(4);
1203  for (Int_t i = 0; i < fgkPlanes; ++i) {
1204  if (!onoff[i]) continue;
1205  b[0] += fXy[i][0] / errx2[i];
1206  b[1] += fXy[i][1] / erry2[i];
1207  b[2] += fXy[i][0] * fDz[i] / errx2[i];
1208  b[3] += fXy[i][1] * fDz[i] / erry2[i];
1209  }
1210 
1211  Bool_t ok = kFALSE;
1212  //TVectorD solve = fLus[patt]->Solve(b, ok);
1213  //TVectorD solve = lu->Solve(b, ok);
1214  TVectorD solve = lu.Solve(b, ok);
1215  for (Int_t i = 0; i < 4; ++i)
1216  pars[i] = solve[i];
1217 
1218  cov.SetMatrixArray(coef.GetMatrixArray());
1219  cov.Invert(); // covar. matrix
1220 
1221  // Compute Chi2
1222  Double_t x = 0, y = 0;
1223  chi2 = 0;
1224 
1225  for (Int_t i = 0; i < fgkPlanes; ++i) {
1226  if (!onoff[i]) continue;
1227  x = pars[0] + pars[2] * fDz[i];
1228  y = pars[1] + pars[3] * fDz[i];
1229  Double_t dx = (x - fXy[i][0]) / fXy[i][2];
1230  Double_t dy = (y - fXy[i][1]) / fXy[i][3];
1231  chi2 += dx * dx;
1232  chi2 += dy * dy;
1233  }
1234  //cout << " Chi2 = " << chi2 << endl;
1235 }
1236 // -------------------------------------------------------------------------
1237 
1238 // ----- Private method MatchVectors -----------------------------------
1240  // Match vectors from 2 stations
1241 
1242  const Int_t iabs = 1;
1243  CbmMuchMergeVectors* merger =
1244  (CbmMuchMergeVectors*) FairRun::Instance()->GetTask("MuchMergeVectors");
1245  TMatrixF matr = TMatrixF(5, 5);
1246  TMatrixF unit(TMatrixF::kUnit, matr);
1247 
1248  for (Int_t ista = 0; ista < fgkStat; ++ista) {
1249  Int_t nvec = fVectors[ista].size();
1250 
1251  // Propagate vectors to the absorber face
1252  for (Int_t iv = 0; iv < nvec; ++iv) {
1253  CbmMuchTrack* vec = fVectors[ista][iv];
1254  FairTrackParam parFirst = *vec->GetParamFirst();
1255  Double_t zbeg = parFirst.GetZ();
1256  Double_t dz = fZabs0[iabs][0] - zbeg;
1257  // Propagate params
1258  parFirst.SetX(parFirst.GetX() + dz * parFirst.GetTx());
1259  parFirst.SetY(parFirst.GetY() + dz * parFirst.GetTy());
1260  parFirst.SetZ(parFirst.GetZ() + dz);
1261  TMatrixFSym cov(5);
1262  parFirst.CovMatrix(cov);
1263  cov(4, 4) = 1.0;
1264  TMatrixF ff = unit;
1265  ff(2, 0) = ff(3, 1) = dz;
1266  TMatrixF cf(cov, TMatrixF::kMult, ff);
1267  TMatrixF fcf(ff, TMatrixF::kTransposeMult, cf);
1268  cov.SetMatrixArray(fcf.GetMatrixArray());
1269  if (ista == 1)
1270  merger->PassAbsorber(
1271  ista + iabs * 2, fZabs0[iabs], fX0abs[iabs], parFirst, cov, 0);
1272  cov.Invert(); // weight matrix
1273  parFirst.SetCovMatrix(cov);
1274  vec->SetParamLast(&parFirst);
1275  }
1276  }
1277 
1278  Int_t ista0 = 0, ista1 = 1;
1279  vector<Int_t> matchOK[2];
1280  Int_t nvec0 = fVectors[ista0].size(), nvec1 = fVectors[ista1].size();
1281  matchOK[0].assign(nvec0, -1);
1282  matchOK[1].assign(nvec1, -1);
1283 
1284  for (Int_t iv = 0; iv < nvec0; ++iv) {
1285  CbmMuchTrack* tr1 = fVectors[ista0][iv];
1286  FairTrackParam parOk = *tr1->GetParamLast();
1287  FairTrackParam par1 = *tr1->GetParamLast();
1288  TMatrixFSym w1(5);
1289  par1.CovMatrix(w1);
1290  Float_t pars1[5] = {(Float_t) par1.GetX(),
1291  (Float_t) par1.GetY(),
1292  (Float_t) par1.GetTx(),
1293  (Float_t) par1.GetTy(),
1294  1.0};
1295  TMatrixF p1(5, 1, pars1);
1296  TMatrixF wp1(w1, TMatrixF::kTransposeMult, p1);
1297 
1298  for (Int_t iv1 = 0; iv1 < nvec1; ++iv1) {
1299  CbmMuchTrack* tr2 = fVectors[ista1][iv1];
1300  FairTrackParam par2 = *tr2->GetParamLast();
1301  TMatrixFSym w2(5);
1302  par2.CovMatrix(w2);
1303  TMatrixFSym w20 = w2;
1304  Float_t pars2[5] = {(Float_t) par2.GetX(),
1305  (Float_t) par2.GetY(),
1306  (Float_t) par2.GetTx(),
1307  (Float_t) par2.GetTy(),
1308  1.0};
1309  TMatrixF p2(5, 1, pars2);
1310  TMatrixF wp2(w2, TMatrixF::kTransposeMult, p2);
1311  wp2 += wp1;
1312  w2 += w1;
1313  w2.Invert();
1314  TMatrixF p12(w2, TMatrixF::kTransposeMult, wp2);
1315 
1316  // Compute Chi2
1317  TMatrixF p122 = p12;
1318  TMatrixF pMerge = p12;
1319  p12 -= p1;
1320  TMatrixF wDp1(w1, TMatrixF::kMult, p12);
1321  TMatrixF chi21(p12, TMatrixF::kTransposeMult, wDp1);
1322  p122 -= p2;
1323  TMatrixF wDp2(w20, TMatrixF::kMult, p122);
1324  TMatrixF chi22(p122, TMatrixF::kTransposeMult, wDp2);
1325  Double_t c2 = chi21(0, 0) + chi22(0, 0);
1326  //cout << " Chi2: " << chi21(0,0) << " " << chi22(0,0) << " " << c2 << endl;
1327  if (c2 < 0 || c2 > fCutChi2[0]) continue;
1328  matchOK[0][iv] = matchOK[1][iv1] = 1; // match OK
1329  // Merged track parameters
1330  parOk.SetX(pMerge(0, 0));
1331  parOk.SetY(pMerge(1, 0));
1332  parOk.SetZ(par2.GetZ());
1333  parOk.SetTx(pMerge(2, 0));
1334  parOk.SetTy(pMerge(3, 0));
1335  parOk.SetCovMatrix(w2);
1336  //AddTrack(ista0, tr1, tr2, it->first, it1->first, parOk, c2); // add track
1337  //Int_t evNo = FairRun::Instance()->GetEventHeader()->GetMCEntryNumber();
1338  }
1339  }
1340 
1341  for (Int_t ista = 0; ista < fgkStat; ++ista) {
1342  Int_t nvec = fVectors[ista].size();
1343 
1344  for (Int_t iv = nvec - 1; iv >= 0; --iv) {
1345  if (matchOK[ista][iv] > 0) continue;
1346  fVectors[ista].erase(fVectors[ista].begin() + iv);
1347  }
1348  }
1349 
1350  cout << " Vectors after matching: " << fVectors[0].size() << " "
1351  << fVectors[1].size() << endl;
1352 }
1353 // -------------------------------------------------------------------------
1354 
1355 // ------ Public method GetAbsorbers -----------------------------------
1356 Int_t CbmMuchFindVectorsGem::GetAbsorbers(Double_t zabs[9][2],
1357  Double_t* x0abs) {
1358  // Get information about absorbers
1359 
1360  Int_t nabs = 0;
1361 
1362  while (fX0abs[nabs] < 1.e+8) {
1363  zabs[nabs][0] = fZabs0[nabs][0];
1364  zabs[nabs][1] = fZabs0[nabs][1];
1365  x0abs[nabs] = fX0abs[nabs];
1366  ++nabs;
1367  }
1368  return nabs;
1369 }
1370 
1371 // -------------------------------------------------------------------------
1372 
CbmMuchFindVectorsGem::CountBits
Int_t CountBits(Int_t x)
Definition: CbmMuchFindVectorsGem.cxx:1127
CbmMuchMergeVectors.h
CbmHit::GetZ
Double_t GetZ() const
Definition: CbmHit.h:70
CbmMuchModule.h
CbmMuchFindVectorsGem::ComputeMatrix
void ComputeMatrix()
Definition: CbmMuchFindVectorsGem.cxx:292
CbmMCDataManager::GetObject
CbmMCDataObject * GetObject(const char *name)
Definition: CbmMCDataManager.cxx:137
CbmTrack::GetChiSq
Double_t GetChiSq() const
Definition: CbmTrack.h:58
CbmMCDataManager.h
CbmTrack::GetParamLast
const FairTrackParam * GetParamLast() const
Definition: CbmTrack.h:62
CbmMuchFindVectorsGem::fGeoScheme
CbmMuchGeoScheme * fGeoScheme
Definition: CbmMuchFindVectorsGem.h:61
CbmMuchGeoScheme
Definition: CbmMuchGeoScheme.h:43
CbmMuchPoint
Definition: CbmMuchPoint.h:21
CbmMuchFindVectorsGem::fHitPl
std::multimap< Int_t, Int_t > fHitPl[fgkStat][fgkPlanes]
Definition: CbmMuchFindVectorsGem.h:73
CbmMuchGeoScheme::GetModule
CbmMuchModule * GetModule(Int_t iStation, Int_t iLayer, Bool_t iSide, Int_t iModule) const
Definition: CbmMuchGeoScheme.cxx:238
ClassImp
ClassImp(CbmMuchFindVectorsGem)
CbmMuchStation::GetLayer
CbmMuchLayer * GetLayer(Int_t iLayer) const
Definition: CbmMuchStation.h:58
CbmMuchStation
Definition: CbmMuchStation.h:22
CbmPixelHit::GetX
Double_t GetX() const
Definition: CbmPixelHit.h:83
CbmMatch::GetLink
const CbmLink & GetLink(Int_t i) const
Definition: CbmMatch.h:35
CbmMatch::GetNofLinks
Int_t GetNofLinks() const
Definition: CbmMatch.h:38
CbmMuchFindVectorsGem::Exec
virtual void Exec(Option_t *opt)
Definition: CbmMuchFindVectorsGem.cxx:242
CbmTrack::GetNofHits
virtual Int_t GetNofHits() const
Definition: CbmTrack.h:53
CbmPixelHit::GetY
Double_t GetY() const
Definition: CbmPixelHit.h:84
CbmMuchFindVectorsGem::fTrdVectors
TClonesArray * fTrdVectors
Definition: CbmMuchFindVectorsGem.h:69
CbmPixelHit::GetDx
Double_t GetDx() const
Definition: CbmPixelHit.h:85
CbmMuchCluster
Data container for MUCH clusters.
Definition: CbmMuchCluster.h:20
CbmMuchFindVectorsGem::fTrackArray
TClonesArray * fTrackArray
Definition: CbmMuchFindVectorsGem.h:62
CbmMuchFindVectorsGem::MakeVectors
void MakeVectors(Int_t ista)
Definition: CbmMuchFindVectorsGem.cxx:484
CbmMuchFindVectorsGem::fCutChi2
Double_t fCutChi2[9]
Definition: CbmMuchFindVectorsGem.h:85
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmMuchFindVectorsGem::StoreVectors
void StoreVectors()
Definition: CbmMuchFindVectorsGem.cxx:1087
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
CbmMCDataManager::InitBranch
CbmMCDataArray * InitBranch(const char *name)
Definition: CbmMCDataManager.cxx:106
CbmMuchFindVectorsGem::fErrY
Double_t fErrY[9]
Definition: CbmMuchFindVectorsGem.h:84
CbmMuchFindVectorsGem::fgkPlanes
static const Int_t fgkPlanes
Definition: CbmMuchFindVectorsGem.h:58
CbmMCDataArray.h
CbmMuchFindVectorsGem::ProcessPlane
void ProcessPlane(Int_t ista, Int_t lay2, Int_t patt, Int_t flag)
Definition: CbmMuchFindVectorsGem.cxx:641
CbmMuchFindVectorsGem::fHits
TClonesArray * fHits
Definition: CbmMuchFindVectorsGem.h:66
CbmMuchFindVectorsGem::fVecPool
TClonesArray * fVecPool
Definition: CbmMuchFindVectorsGem.h:64
CbmMuchFindVectorsGem::GetTrdVectors
Int_t GetTrdVectors(std::vector< std::pair< Double_t, Double_t >> &vecDowns)
Definition: CbmMuchFindVectorsGem.cxx:620
CbmHit::GetRefId
Int_t GetRefId() const
Definition: CbmHit.h:72
CbmTrack::SetParamLast
void SetParamLast(const FairTrackParam *par)
Definition: CbmTrack.h:76
CbmTrack::SetNDF
void SetNDF(Int_t ndf)
Definition: CbmTrack.h:71
CbmPixelHit::GetDy
Double_t GetDy() const
Definition: CbmPixelHit.h:86
CbmMuchFindVectorsGem::CheckParams
void CheckParams(Int_t ista)
Definition: CbmMuchFindVectorsGem.cxx:869
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
CbmCluster::GetNofDigis
Int_t GetNofDigis() const
Number of digis in cluster.
Definition: CbmCluster.h:69
CbmMuchFindVectorsGem::fZ0
Double_t fZ0[fgkStat]
Definition: CbmMuchFindVectorsGem.h:86
CbmMuchFindVectorsGem::fRmin
Double_t fRmin[fgkStat]
Definition: CbmMuchFindVectorsGem.h:87
CbmMuchCluster.h
Data container for MUCH clusters.
CbmMuchAddress::GetModuleIndex
static Int_t GetModuleIndex(Int_t address)
Definition: CbmMuchAddress.h:112
CbmMuchGeoScheme::GetLayerSideIndex
static Int_t GetLayerSideIndex(Int_t address)
Definition: CbmMuchGeoScheme.h:74
CbmMuchFindVectorsGem::AddVector
void AddVector(Int_t ista, Int_t patt, Double_t chi2, Double_t *pars)
Definition: CbmMuchFindVectorsGem.cxx:725
CbmMuchFindVectorsGem::Refit
void Refit(Int_t patt, Double_t &chi2, Double_t *pars, TMatrixDSym &cov)
Definition: CbmMuchFindVectorsGem.cxx:1137
CbmMuchFindVectorsGem::Init
virtual InitStatus Init()
Definition: CbmMuchFindVectorsGem.cxx:75
CbmMuchGeoScheme::GetNStations
Int_t GetNStations() const
Definition: CbmMuchGeoScheme.h:79
CbmMuchGeoScheme::GetLayerIndex
static Int_t GetLayerIndex(Int_t address)
Definition: CbmMuchGeoScheme.h:71
CbmMuchPoint.h
CbmMuchFindVectorsGem::GetHits
void GetHits()
Definition: CbmMuchFindVectorsGem.cxx:383
CbmMuchTrack.h
CbmMuchFindVectorsGem::~CbmMuchFindVectorsGem
virtual ~CbmMuchFindVectorsGem()
Definition: CbmMuchFindVectorsGem.cxx:64
CbmSetup.h
CbmMuchFindVectorsGem::SetParContainers
virtual void SetParContainers()
Definition: CbmMuchFindVectorsGem.cxx:238
CbmMuchFindVectorsGem::FindChi2
Double_t FindChi2(Int_t ista, Int_t patt, Double_t *pars)
Definition: CbmMuchFindVectorsGem.cxx:847
CbmMuchMergeVectors
Definition: CbmMuchMergeVectors.h:23
CbmMuchFindVectorsGem::fZabs0
Double_t fZabs0[9][2]
Definition: CbmMuchFindVectorsGem.h:95
CbmMuchStation::GetRmax
Double_t GetRmax() const
Definition: CbmMuchStation.h:52
CbmSetup::Instance
static CbmSetup * Instance()
Definition: CbmSetup.cxx:115
CbmMCDataArray::Get
TObject * Get(const CbmLink *lnk)
Definition: CbmMCDataArray.h:47
CbmTrack::GetHitIndex
Int_t GetHitIndex(Int_t iHit) const
Definition: CbmTrack.h:54
CbmHit::GetAddress
Int_t GetAddress() const
Definition: CbmHit.h:73
CbmMuchFindVectorsGem::fHitX
std::multimap< Double_t, Int_t > fHitX[fgkStat][fgkPlanes]
Definition: CbmMuchFindVectorsGem.h:75
CbmMuchFindVectorsGem::fVectors
std::vector< CbmMuchTrack * > fVectors[fgkStat]
Definition: CbmMuchFindVectorsGem.h:76
CbmTrack::SetChiSq
void SetChiSq(Double_t chiSq)
Definition: CbmTrack.h:70
CbmMuchFindVectorsGem::CbmMuchFindVectorsGem
CbmMuchFindVectorsGem()
Definition: CbmMuchFindVectorsGem.cxx:42
CbmMuchStation::GetDetectorId
Int_t GetDetectorId() const
Definition: CbmMuchStation.h:48
CbmMuchLayerSide
Definition: CbmMuchLayerSide.h:22
CbmMuchFindVectorsGem::GetDowns
Int_t GetDowns(Int_t ista, std::vector< std::pair< Double_t, Double_t >> &vecDowns)
Definition: CbmMuchFindVectorsGem.cxx:455
CbmSetup::GetGeoTag
Bool_t GetGeoTag(ECbmModuleId moduleId, TString &tag)
Definition: CbmSetup.cxx:101
CbmMuchFindVectorsGem::fClusters
TClonesArray * fClusters
Definition: CbmMuchFindVectorsGem.h:67
CbmMuchFindVectorsGem::fLus
std::map< Int_t, TDecompLU * > fLus
Definition: CbmMuchFindVectorsGem.h:82
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
CbmMuchFindVectorsGem::fXy
Double_t fXy[fgkPlanes][5]
Definition: CbmMuchFindVectorsGem.h:78
CbmMuchFindVectorsGem::GetAbsorbers
Int_t GetAbsorbers(Double_t zabs[9][2], Double_t *x0abs)
Definition: CbmMuchFindVectorsGem.cxx:1356
CbmMuchAddress::GetStationIndex
static Int_t GetStationIndex(Int_t address)
Definition: CbmMuchAddress.h:103
CbmMCDataManager
Task class creating and managing CbmMCDataArray objects.
Definition: CbmMCDataManager.h:27
CbmMuchModule::GetDetectorType
Int_t GetDetectorType() const
Definition: CbmMuchModule.h:52
CbmMuchFindVectorsGem::RemoveClones
void RemoveClones(Int_t ista)
Definition: CbmMuchFindVectorsGem.cxx:994
CbmMuchFindVectorsGem::fRmax
Double_t fRmax[fgkStat]
Definition: CbmMuchFindVectorsGem.h:88
CbmMuchFindVectorsGem::fX0abs
Double_t fX0abs[9]
Definition: CbmMuchFindVectorsGem.h:96
CbmMuchFindVectorsGem::fErrX
Double_t fErrX[9]
Definition: CbmMuchFindVectorsGem.h:83
CbmMuchPixelHit::GetPlaneId
virtual Int_t GetPlaneId() const
Inherited from CbmBaseHit.
Definition: CbmMuchPixelHit.h:93
CbmMuchAddress::GetElementAddress
static Int_t GetElementAddress(Int_t address, Int_t level)
Definition: CbmMuchAddress.h:122
CbmMuchFindVectorsGem::fMatr
std::map< Int_t, TMatrixDSym * > fMatr
Definition: CbmMuchFindVectorsGem.h:92
CbmMuchFindVectorsGem.h
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmMuchFindVectorsGem::fDigiMatches
TClonesArray * fDigiMatches
Definition: CbmMuchFindVectorsGem.h:68
CbmMuchPixelHit.h
Class for pixel hits in MUCH detector.
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmMuchFindVectorsGem::fDz
Double_t fDz[fgkPlanes]
Definition: CbmMuchFindVectorsGem.h:80
CbmMuchFindVectorsGem::fXyi
Double_t fXyi[fgkPlanes][3]
Definition: CbmMuchFindVectorsGem.h:79
CbmMuchFindVectorsGem::fgkStat
static const Int_t fgkStat
Definition: CbmMuchFindVectorsGem.h:57
CbmTrack::SetParamFirst
void SetParamFirst(const FairTrackParam *par)
Definition: CbmTrack.h:75
CbmMuchFindVectorsGem::MatchVectors
void MatchVectors()
Definition: CbmMuchFindVectorsGem.cxx:1239
CbmMuchFindVectorsGem::fNsect
Int_t fNsect[fgkStat]
Definition: CbmMuchFindVectorsGem.h:89
kMUCHPIXELHIT
@ kMUCHPIXELHIT
Definition: CbmHit.h:23
CbmMuchGeoScheme::GetStation
CbmMuchStation * GetStation(Int_t iStation) const
Definition: CbmMuchGeoScheme.cxx:209
CbmMuchStation::GetNLayers
Int_t GetNLayers() const
Definition: CbmMuchStation.h:50
ECbmModuleId::kMuch
@ kMuch
Muon detection system.
kMuchModule
@ kMuchModule
Module.
Definition: CbmMuchAddress.h:20
CbmMuchDigiMatch.h
CbmMuchPixelHit
Definition: CbmMuchPixelHit.h:17
CbmMuchFindVectorsGem::FindLine
void FindLine(Int_t patt, Double_t *pars)
Definition: CbmMuchFindVectorsGem.cxx:817
CbmMuchFindVectorsGem::Finish
virtual void Finish()
Definition: CbmMuchFindVectorsGem.cxx:281
CbmMuchFindVectorsGem::fSecVec
std::multimap< Int_t, CbmMuchTrack * > fSecVec[fgkStat]
Definition: CbmMuchFindVectorsGem.h:94
CbmMuchFindVectorsGem::fPoints
CbmMCDataArray * fPoints
Definition: CbmMuchFindVectorsGem.h:70
CbmMuchLayer
Definition: CbmMuchLayer.h:21
CbmMuchLayerSide::GetZ
Double_t GetZ()
Definition: CbmMuchLayerSide.h:49
CbmMuchStation::GetRmin
Double_t GetRmin() const
Definition: CbmMuchStation.h:51
CbmMuchGeoScheme::GetModuleByDetId
CbmMuchModule * GetModuleByDetId(Int_t detId) const
Definition: CbmMuchGeoScheme.cxx:278
CbmMuchFindVectorsGem::SetTrackId
void SetTrackId(CbmMuchTrack *vec)
Definition: CbmMuchFindVectorsGem.cxx:770
CbmMuchStation.h
CbmCluster::GetDigi
Int_t GetDigi(Int_t index) const
Get digi at position index.
Definition: CbmCluster.h:76
CbmMuchFindVectorsGem::fStatFirst
Int_t fStatFirst
Definition: CbmMuchFindVectorsGem.h:71
CbmTrack::AddHit
void AddHit(Int_t index, HitType type)
Definition: CbmTrack.cxx:75
CbmMuchPixelHit::GetFlag
Int_t GetFlag() const
Definition: CbmMuchPixelHit.h:96
CbmMuchModuleGem.h
CbmMuchAddress::GetLayerSideIndex
static Int_t GetLayerSideIndex(Int_t address)
Definition: CbmMuchAddress.h:109
CbmMuchFindVectorsGem
Definition: CbmMuchFindVectorsGem.h:27
CbmMuchLayerSide::GetNModules
Int_t GetNModules() const
Definition: CbmMuchLayerSide.h:47
CbmMuchFindVectorsGem::SelectHitId
Bool_t SelectHitId(const CbmMuchPixelHit *hit)
Definition: CbmMuchFindVectorsGem.cxx:424