10 #include "FairLogger.h"
11 #include "FairRootManager.h"
12 #include "FairTrackParam.h"
14 #include <TClonesArray.h>
18 #include <TMatrixFSym.h>
29 : FairTask(
"MuchToTrdVectors")
45 FairRootManager* ioman = FairRootManager::Instance();
46 if (ioman == NULL) Fatal(
"Init",
"RootManager not instantiated!");
49 fTrackArray =
new TClonesArray(
"CbmMuchTrack", 100);
50 ioman->Register(
"GlobalVector",
"Much",
fTrackArray, kTRUE);
51 fMuchTracks =
static_cast<TClonesArray*
>(ioman->GetObject(
"MuchVectorTrack"));
52 fTrdTracks =
static_cast<TClonesArray*
>(ioman->GetObject(
"TrdVector"));
75 if (nTrd == 0)
return;
95 const Int_t nMinSeg = 5;
107 TMatrixF matr = TMatrixF(5, 5);
108 TMatrixF unit(TMatrixF::kUnit, matr);
110 for (Int_t itr = 0; itr < nMuch; ++itr) {
113 if (nvecTr < nMinSeg)
continue;
146 fXmap.insert(pair<Double_t, Int_t>(parFirst.GetX(), itr));
156 const Double_t window = 35.0, chi2max = 24;
157 multimap<Double_t, Int_t>::iterator mit, mitb, mite;
158 FairTrackParam parOk;
160 TMatrixF matr = TMatrixF(5, 5);
161 TMatrixF unit(TMatrixF::kUnit, matr);
165 for (Int_t itr = 0; itr < nTrd; ++itr) {
170 Double_t zbeg = par1.GetZ();
171 Double_t dz =
fZ0 - zbeg;
173 par1.SetX(par1.GetX() + dz * par1.GetTx());
174 par1.SetY(par1.GetY() + dz * par1.GetTy());
175 par1.SetZ(par1.GetZ() + dz);
183 ff(2, 0) = ff(3, 1) = dz;
185 TMatrixF cf(cov, TMatrixF::kMult, ff);
186 TMatrixF fcf(ff, TMatrixF::kTransposeMult, cf);
187 cov.SetMatrixArray(fcf.GetMatrixArray());
190 par1.SetCovMatrix(cov);
194 Double_t xv = par1.GetX();
195 Double_t yv = par1.GetY();
196 mitb =
fXmap.lower_bound(xv - window);
197 mite =
fXmap.upper_bound(xv + window);
202 Float_t pars1[5] = {(Float_t) par1.GetX(),
203 (Float_t) par1.GetY(),
204 (Float_t) par1.GetTx(),
205 (Float_t) par1.GetTy(),
207 TMatrixF p1(5, 1, pars1);
208 TMatrixF wp1(w1, TMatrixF::kTransposeMult, p1);
211 for (mit = mitb; mit != mite; ++mit) {
212 Int_t indx = mit->second;
215 if (par2->GetY() < yv - window || par2->GetY() > yv + window)
continue;
219 TMatrixFSym w20 = w2;
220 Float_t pars2[5] = {(Float_t) par2->GetX(),
221 (Float_t) par2->GetY(),
222 (Float_t) par2->GetTx(),
223 (Float_t) par2->GetTy(),
225 TMatrixF p2(5, 1, pars2);
226 TMatrixF wp2(w2, TMatrixF::kTransposeMult, p2);
230 TMatrixF p12(w2, TMatrixF::kTransposeMult, wp2);
235 TMatrixF pMerge = p12;
237 TMatrixF wDp1(w1, TMatrixF::kMult, p12);
238 TMatrixF chi21(p12, TMatrixF::kTransposeMult, wDp1);
240 TMatrixF wDp2(w20, TMatrixF::kMult, p122);
241 TMatrixF chi22(p122, TMatrixF::kTransposeMult, wDp2);
242 Double_t c2 = chi21(0, 0) + chi22(0, 0);
244 if (c2 < 0 || c2 > chi2max)
continue;
247 parOk.SetX(pMerge(0, 0));
248 parOk.SetY(pMerge(1, 0));
249 parOk.SetZ(par2->GetZ());
250 parOk.SetTx(pMerge(2, 0));
251 parOk.SetTy(pMerge(3, 0));
252 parOk.SetCovMatrix(w2);
253 AddTrack(muchTr, tr, indx, itr, parOk, c2);
264 FairTrackParam& parOk,
283 gLogger->Info(MESSAGE_ORIGIN,
284 "CbmMuchToTrdVectors::AddTrack: trID1=%i, trID2=%i, chi2=%f",
298 multimap<Double_t, Int_t> qMap;
299 multimap<Double_t, Int_t>::iterator it, it1;
301 for (Int_t
i = 0;
i < nvec; ++
i) {
305 qMap.insert(pair<Double_t, Int_t>(qual,
i));
308 for (it = qMap.begin(); it != qMap.end(); ++it) {
310 if (vec == NULL)
continue;
314 for (++it1; it1 != qMap.end(); ++it1) {
317 if (vec1 == NULL)
continue;
329 cout <<
" Global vectors after clones removed: " << nvec <<
" " <<
fNofTracks