146 LOG(debug2) <<
"<I> TrkMap/Vec resized for " <<
fHits->GetEntriesFast() <<
" entries ";
148 for (Int_t iHit = 0; iHit <
fHits->GetEntriesFast(); iHit++) {
161 for (Int_t iHit = 0; iHit <
fHits->GetEntriesFast(); iHit++) {
167 LOG(debug2) << Form(
"<I> TofTracklet Chkseed St0 %2d, St1 %2d, Mul %2d, Hit %2d, addr = "
168 "0x%08x - X %6.2f, Y %6.2f Z %6.2f R %6.2f T %6.2f TM %lu",
172 LOG(debug1) << Form(
"<I> TofTracklet seed St0 %2d, St1 %2d, Mul %2d, Hit %2d, addr = "
173 "0x%08x - X %6.2f, Y %6.2f Z %6.2f T %6.2f TM %lu",
180 Double_t hitpos[3] = {3 * 0.};
181 Double_t hitpos_local[3] = {3 * 0.};
182 Double_t dSizey = 1.;
185 if (NULL == fChannelInfo) {
186 LOG(fatal) <<
"<D> CbmTofTrackFinderNN::DoFind0: Invalid Channel Pointer for ChId "
187 << Form(
" 0x%08x ", iChId) <<
", Ch " << iCh;
192 gGeoManager->FindNode(fChannelInfo->
GetX(), fChannelInfo->
GetY(), fChannelInfo->
GetZ());
194 hitpos[0] = pHit->
GetX();
195 hitpos[1] = pHit->
GetY();
196 hitpos[2] = pHit->
GetZ();
197 gGeoManager->GetCurrentNode();
198 gGeoManager->MasterToLocal(hitpos, hitpos_local);
204 "<D> Tracklet start %d, Hit %d - yloc %6.2f, dy %6.2f, scal %6.2f -> addrs 0x%08x, 0x%08x",
fiNtrks, iHit,
208 if (TMath::Abs(hitpos_local[1]) < dSizey *
fPosYMaxScal)
209 for (Int_t iHit1 = 0; iHit1 <
fHits->GetEntriesFast(); iHit1++)
211 if (
HitUsed(iHit1) == 1)
continue;
220 Double_t hitpos1[3] = {3 * 0.};
221 Double_t hitpos1_local[3] = {3 * 0.};
222 Double_t dSizey1 = 1.;
223 if (NULL == fChannelInfo1) {
224 LOG(debug1) <<
"CbmTofTrackFinderNN::DoFindi: Invalid Channel "
226 << Form(
" 0x%08x ", iChId1) <<
", Ch " << iCh1;
231 gGeoManager->FindNode(fChannelInfo1->
GetX(), fChannelInfo1->
GetY(), fChannelInfo1->
GetZ());
232 hitpos1[0] = pHit1->
GetX();
233 hitpos1[1] = pHit1->
GetY();
234 hitpos1[2] = pHit1->
GetZ();
235 gGeoManager->GetCurrentNode();
236 gGeoManager->MasterToLocal(hitpos1, hitpos1_local);
237 dSizey1 = fChannelInfo1->
GetSizey();
242 Double_t dLz = pHit1->
GetZ() - pHit->
GetZ();
243 Double_t dTx = (pHit1->
GetX() - pHit->
GetX()) / dLz;
244 Double_t dTy = (pHit1->
GetY() - pHit->
GetY()) / dLz;
245 Double_t dDist = TMath::Sqrt(TMath::Power((pHit->
GetX() - pHit1->
GetX()), 2)
246 + TMath::Power((pHit->
GetY() - pHit1->
GetY()), 2)
247 + TMath::Power((pHit->
GetZ() - pHit1->
GetZ()), 2));
248 LOG(debug2) << Form(
"<I> TofTracklet %d, Hits %d, %d, add = 0x%08x,0x%08x - DT "
249 "%6.2f, DD %6.2f, Tx %6.2f Ty %6.2f Tt %6.2f pos %6.2f %6.2f %6.2f ",
251 dDT / dLz, hitpos1_local[0], hitpos1_local[1], hitpos1_local[2]);
252 LOG(debug3) << Form(
" DT %f from %f - %f ", dDT, pHit1->
GetTime(), pHit->
GetTime());
253 LOG(debug3) << Form(
" selection: y %6.2f < %6.2f, T %f < %6.5f, "
254 "Tx Abs(%6.2f - %6.2f) < %6.2f, Ty Abs(%6.2f - %6.2f) < %6.2f",
258 if (TMath::Abs(hitpos1_local[1]) < dSizey1 *
fPosYMaxScal)
262 LOG(debug3) <<
"Construct new tracklet";
274 Double_t dR = pTrk->
Dist3D(pHit1, pHit);
277 Double_t T0Fake = pHit->
GetTime();
279 T0Fake = (T0Fake * (w - 1.) + (pHit1->
GetTime() - dTt * dR)) / w;
280 LOG(debug1) << Form(
"<I> TofTracklet %d, Fake T0, old %8.0f -> new %8.0f",
fiNtrks,
285 if (pHit1->
GetZ() < pHit->
GetZ()) dSign = -1.;
286 dTt = dSign * dDT / dR;
297 LOG(debug1) << Form(
"<I> TofTracklet %d, Hits %d, %d initialized, "
298 "add 0x%08x,0x%08x, DT %6.3f, Sgn %2.0f, DR "
299 "%6.3f, T0 %6.2f, Tt %6.4f ",
310 if (iNTrks >= 0 &&
static_cast<size_t>(iNTrks) ==
fTracks.size())
continue;
312 PrintStatus((
char*) Form(
"after seeds of St0 %d, St1 %d, Mul %d", iSt0, iSt1, iNTrks));
314 const Int_t MAXNCAND = 1000;
318 Int_t iHitInd[MAXNCAND];
320 Double_t dChi2[MAXNCAND];
321 for (
size_t iTrk = 0; iTrk <
fTracks.size(); iTrk++) {
323 LOG(debug3) <<
" Propagate Loop " << iTrk <<
" pTrk " << pTrk
325 if (NULL == pTrk)
continue;
327 for (Int_t iHit = 0; iHit <
fHits->GetEntriesFast(); iHit++) {
328 if (
HitUsed(iHit) == 1)
continue;
337 Double_t hitpos[3] = {3 * 0.};
338 Double_t hitpos_local[3] = {3 * 0.};
339 Double_t dSizey = 1.;
341 if (NULL == fChannelInfo) {
342 LOG(debug1) <<
"CbmTofTrackFinderNN::DoFind: Invalid Channel "
344 << iHit <<
" for ChId " << Form(
" 0x%08x ", iChId) <<
", Ch " << iCh;
349 gGeoManager->FindNode(fChannelInfo->
GetX(), fChannelInfo->
GetY(), fChannelInfo->
GetZ());
350 hitpos[0] = pHit->
GetX();
351 hitpos[1] = pHit->
GetY();
352 hitpos[2] = pHit->
GetZ();
353 gGeoManager->GetCurrentNode();
354 gGeoManager->MasterToLocal(hitpos, hitpos_local);
357 if (TMath::Abs(hitpos_local[1]) < dSizey *
fPosYMaxScal) {
364 if (iHit0 < 0 || iHit0 >=
fHits->GetEntriesFast())
365 LOG(fatal) <<
"CbmTofTrackFinderNN::DoFind Invalid Hit Index " << iHit0 <<
" for Track " << iTrk <<
"("
367 Double_t dDz = pHit->
GetZ() - tPar->
GetZ();
368 Double_t dXex = tPar->
GetX() + tPar->
GetTx() * dDz;
369 Double_t dYex = tPar->
GetY() + tPar->
GetTy() * dDz;
374 Double_t dTex = pTrk->
GetTex(pHit);
383 LOG(debug2) << Form(
"<IP> TofTracklet %lu, HMul %d, Hits %d, %d check %d, Station "
384 "%d: DT %f, DX %f, DY %f, Chi %f",
385 iTrk, pTrk->
GetNofHits(), iHit0, iHit1, iHit, iDet,
392 LOG(fatal) << Form(
"Missing resolution for station %d, addr 0x%08x", iDet, iAddr);
398 LOG(debug1) << Form(
"<IP> TofTracklet %lu, HMul %d, Hits %d, %d "
399 "mark for extension by %d, add = 0x%08x, DT "
400 "%6.2f, DX %6.2f, DY=%6.2f ",
406 LOG(debug1) << Form(
"CbmTofTrackFinderNN::DoFind new match %d "
407 "of Hit %d, Trk %lu, chi2 = %f",
408 iNCand, iHit, iTrk, dChi);
410 if (iNCand == MAXNCAND) iNCand--;
412 for (Int_t iCand = 0; iCand < iNCand; iCand++) {
413 if (dChi < dChi2[iCand]) {
414 for (Int_t iCC = iNCand; iCC > iCand; iCC--) {
415 pTrkInd[iCC] = pTrkInd[iCC - 1];
416 iHitInd[iCC] = iHitInd[iCC - 1];
417 dChi2[iCC] = dChi2[iCC - 1];
419 pTrkInd[iCand] = pTrk;
420 iHitInd[iCand] = iHit;
422 dChi2[iNCand] = 1.E8;
423 LOG(debug2) << Form(
" <D> candidate inserted at pos %d", iCand);
429 LOG(debug1) << Form(
"CbmTofTrackFinderNN::DoFind first match "
430 "%d of Hit %d, Trk %p, chi2 = %f",
431 iNCand, iHit, pTrk, dChi);
432 pTrkInd[iNCand] = pTrk;
433 iHitInd[iNCand] = iHit;
434 dChi2[iNCand] = dChi;
436 dChi2[iNCand] = 1.E8;
446 if (NULL == pTrk)
continue;
447 LOG(debug1) << Form(
"%d hit match candidates in station %d to %lu TofTracklets", iNCand, iDet,
449 for (Int_t iM = 0; iM < iNCand; iM++) {
451 if (NULL == pTrk)
break;
452 std::vector<CbmTofTracklet*>::iterator it = std::find(
fTracks.begin(),
fTracks.end(), pTrk);
453 if (it ==
fTracks.end())
break;
456 << Form(
"Hit %d, Trk %p with chi2 %f (%f)", iHitInd[iM], pTrkInd[iM], dChi2[iM],
464 for (; iTr <
fTracks.size(); iTr++) {
466 LOG(debug1) <<
"Track " << pTrk <<
" active at pos " << iTr;
472 for (Int_t iCand = 0; iCand < iNCand; iCand++) {
473 pTrkInd[iCand] = pTrkInd[iCand + 1];
474 iHitInd[iCand] = iHitInd[iCand + 1];
475 dChi2[iCand] = dChi2[iCand + 1];
484 LOG(fatal) <<
" No or more Tracklet hits than stations ! Stop ";
486 Int_t iHit = iHitInd[0];
490 LOG(debug2) << Form(
" -D- Add hit %d at %p, Addr 0x%08x, Chi2 %6.2f to size %u", iHit, pHit, iAddr,
497 Bool_t bkeep = kFALSE;
500 LOG(debug1) << Form(
"Add hit %d invalidates tracklet with Chi "
501 "%6.2f > %6.2f -> undo ",
511 for (Int_t iCand = 0; iCand < iNCand; iCand++) {
512 pTrkInd[iCand] = pTrkInd[iCand + 1];
513 iHitInd[iCand] = iHitInd[iCand + 1];
514 dChi2[iCand] = dChi2[iCand + 1];
521 for (Int_t iCand = 0; iCand < iNCand; iCand++) {
522 if (pTrk != pTrkInd[iCand] && iHit != iHitInd[iCand]) {
523 pTrkInd[iNCandNew] = pTrkInd[iCand];
524 iHitInd[iNCandNew] = iHitInd[iCand];
525 dChi2[iNCandNew] = dChi2[iCand];
533 if (dChi2[0] < dLastChi2) {
534 LOG(fatal) << Form(
"-D- Replace %d, Addr 0x%08x, at %p, Chi2 %6.2f", iHit, iAddr, pHit, dChi2[0]);
540 LOG(debug1) << Form(
" -D- Ignore %d, Det %d, Addr 0x%08x, at 0x%p, Chi2 %6.2f", iHit, iDet, iAddr,
561 Double_t dTt = pTrk->
GetTt();
563 LOG(debug1) << Form(
"<Res> TofTracklet %p, HMul %d, Hits %d, %d, %d, "
564 "NDF %d, Chi2 %6.2f, T0 %6.2f, Tt %6.4f ",
568 LOG(debug2) <<
" Match loop status: NCand " << iNCand <<
", iDet " << iDet;
604 LOG(debug1) <<
"Clean-up " <<
fTracks.size() <<
" tracklet candidates";
606 for (
size_t iTr = 0; iTr <
fTracks.size(); iTr++) {
607 if (
fTracks[iTr] == NULL)
continue;
608 if (
fTracks[iTr]->GetNofHits() < 3)
continue;
612 if (fair::Logger::Logging(fair::Severity::debug)) {
613 LOG(info) <<
"Found Trkl " << iTr;
616 for (Int_t iHit = 0; iHit < pTrk->
GetNofHits(); iHit++) {
619 LOG(debug1) << Form(
" hit %d at %d flagged to %d ", iHit, pTrk->
GetHitIndex(iHit), pHit->
GetFlag());
622 if (fair::Logger::Logging(fair::Severity::debug)) {
627 for (
size_t iTr = 0; iTr <
fTracks.size(); iTr++) {
628 if (
fTracks[iTr] == NULL)
continue;
631 LOG(debug1) << Form(
"<I> TofTracklet %lu, %p deleted", iTr,
fTracks[iTr]);
754 for (Int_t iHit = 0; iHit < pTrk->
GetNofHits(); iHit++) {
757 Int_t NTrks =
fvTrkVec[iHitInd].size();
766 <<
", iHit " << iHit;
770 while (iterClean > 0) {
771 LOG(debug2) <<
" <D1> UpdateTrackList for Trk " << pTrk
772 << Form(
", %d.Hit(%d) at ind %d with %d(%d) registered tracks", iHit, pTrk->
GetNofHits(), iHitInd,
773 (
int)
fvTrkVec[iHitInd].size(), NTrks);
776 for (std::vector<CbmTofTracklet*>::iterator iT =
fvTrkVec[iHitInd].begin(); iT !=
fvTrkVec[iHitInd].end();
779 LOG(debug2) <<
"Inspect track " << iTrkPos <<
" of " <<
fvTrkVec[iHitInd].size() <<
" for HitInd " << iHitInd;
783 LOG(debug2) <<
" <D2> process Trk " << *iT <<
" with " << (*iT)->GetNofHits() <<
" hits";
785 LOG(debug2) <<
" <D2a> continue with next tracklet ";
788 for (Int_t iH = 0; iH < (*iT)->GetNofHits(); iH++) {
790 Int_t iHi = (*iT)->GetTofHitIndex(iH);
791 LOG(debug2) <<
" <D3> process Hit " << iH <<
" at index " << iHi;
792 Int_t iAddri = ((*iT)->GetTofHitPointer(iH)->GetAddress() &
DetMask);
793 LOG(debug2) <<
" --- iHitInd " << iHitInd <<
"(" <<
fvTrkVec.size() <<
"), size "
794 <<
fvTrkVec[iHitInd].size() <<
" - iH " << iH <<
"(" << (*iT)->GetNofHits() <<
"), iHi " << iHi
795 <<
" Hi vec size " <<
fvTrkVec[iHi].size()
796 << Form(
" poi %p, iTpoi %p, SmAddr 0x%08x, 0x%08x, 0x%08x ", pTrk, *iT,
800 LOG(debug2) <<
" Hit in beam counter, continue ...";
804 LOG(fatal) <<
"CbmTofTrackFinderNN::UpdateTrackList no track "
805 <<
" for hit " << iH <<
", Hind " << iHi <<
", size " <<
fvTrkVec[iHi].size();
809 for (std::vector<CbmTofTracklet*>::iterator it =
fvTrkVec[iHi].begin(); it !=
fvTrkVec[iHi].end(); it++) {
810 LOG(debug2) <<
" UpdateTrackList for pTrk " << pTrk <<
" <-> " << *iT <<
" <-> " << *it <<
", clean "
811 << iterClean <<
", hit " << iHi <<
", size " <<
fvTrkVec[iHi].size();
814 for (iTr = 0; iTr <
fTracks.size(); iTr++) {
816 LOG(debug2) << Form(
" found track entry %p(%d) at %lu "
817 "of iHi %d, pTrk %p",
824 LOG(fatal) <<
"CbmTofTrackFinderNN::UpdateTrackList: "
825 "Invalid iTr for pTrk "
826 << pTrk <<
", iTr " << iTr <<
", size " <<
fvTrkVec[iHi].size();
830 LOG(debug2) << Form(
"<D4> number of registered hits %3d at "
831 "%p while keeping iHi = %d, pTrk at %p",
832 (*it)->GetNofHits(), (*it), iHi, pTrk);
836 for (Int_t iht = 0; iht < pKill->
GetNofHits(); iht++) {
838 LOG(debug2) << Form(
"<D5> remove track link %p for hit iHi "
839 "= %d, loop index %d: iHI = %3d ",
840 pKill, iHi, iht, iHI);
842 for (std::vector<CbmTofTracklet*>::iterator itt =
fvTrkVec[iHI].begin(); itt !=
fvTrkVec[iHI].end();
844 if ((*itt) == pTrk)
continue;
845 if ((*itt) == pKill) {
846 LOG(debug2) << Form(
"<D6> remove track link %p for hit "
847 "iHi = %d, iHI = %3d, #Trks %3d",
850 LOG(debug2) <<
"<D6a> clear vector fvTrkVec for " << iHI;
857 LOG(debug2) <<
"<D6b> reduce fvTrkVec size of " << iHI <<
" to " <<
fvTrkVec[iHI].size();
862 LOG(debug2) << Form(
"<D7> removed track link %p for hit "
863 "iHi = %d, loop %d: iHI = %3d ",
864 pKill, iHi, iht, iHI);
869 LOG(debug2) <<
"<D8> remove tracklet at pos " << iTr;
872 if (fair::Logger::Logging(fair::Severity::debug2)) {
873 LOG(debug2) <<
"Erase1 for pTrk " << pTrk <<
", at " << iTr <<
", hit " << iHi <<
", size "
903 LOG(debug2) <<
"Track loop of iHi = " << iHi <<
" finished";
907 LOG(debug2) <<
"Hit loop of iTrkPos = " << iTrkPos <<
" finished";
909 LOG(debug2) <<
"Track loop of iHitInd = " << iHitInd <<
" finished";
1023 if (
fTracks.size() < 2)
return;
1025 Double_t dTvtx = 0.;
1026 Double_t dT2vtx = 0.;
1027 Double_t dSigTvtx = 0.;
1028 Double_t nValidTracks = 0.;
1029 Double_t dToff = 0.;
1034 for (
size_t it = 0; it <
fTracks.size(); it++) {
1036 if (NULL == pTrk)
continue;
1038 if (nValidTracks == 0) dToff = pTrk->
GetT0();
1039 dTvtx += pTrk->
GetT0() - dToff;
1044 dT2vtx += (pTrk->
GetT0() - dToff) * (pTrk->
GetT0() - dToff);
1048 LOG(debug1) << Form(
"AddVertex valid tracks %3.0f: %6.3f, %6.3f, %15.3f", nValidTracks, dTvtx, dT2vtx, dToff);
1050 dTvtx /= nValidTracks;
1051 dT2vtx /= nValidTracks;
1052 dSigTvtx = TMath::Sqrt(dT2vtx - dTvtx * dTvtx);
1053 dVx /= nValidTracks;
1054 dVy /= nValidTracks;
1055 dVx2 /= nValidTracks;
1056 dVy2 /= nValidTracks;
1057 LOG(debug1) << Form(
"AddVertex time %15.3f, sig %8.3f from %3.0f tracks ", dTvtx, dSigTvtx, nValidTracks);
1065 double dSigVx = TMath::Sqrt(dVx2 - dVx * dVx);
1066 double dSigVy = TMath::Sqrt(dVy2 - dVy * dVy);
1068 dSigVx /= nValidTracks;
1069 dSigVy /= nValidTracks;
1071 const TVector3 hitPos(dVx, dVy, 0.);
1072 const TVector3 hitPosErr(dSigVx, dSigVy, 0.1);
1073 const Double_t dTime0 = dTvtx + dToff;
1081 Int_t iHitVtx =
fHits->GetEntriesFast();
1083 new ((*fHits)[iHitVtx])
CbmTofHit(iDetId, hitPos,
1089 LOG(debug1) <<
"CbmTofTrackFinderNN::DoFind: Fake Vtx Hit at pos " << iHitVtx << Form(
", T0 %f ", dTime0)
1097 LOG(debug2) <<
"<I> TrkMap/Vec resized for " <<
fHits->GetEntriesFast() <<
" entries ";
1099 for (
size_t it = 0; it <
fTracks.size(); it++) {
1101 if (NULL == pTrk)
continue;
1107 LOG(debug1) << Form(
"Add hit %d invalidates tracklet with Chi "
1108 "%6.2f > %6.2f -> undo ",
1116 Double_t dTt = pTrk->
GetTt();
1117 LOG(debug1) <<
"Vtx added to track " << it <<
"; chi2 " << pTrk->
GetChiSq() <<
", Tt " << dTt;