// ----- track finding -----
AliDebug(1,"--------- Running tracking units ----------");
for (Int_t zch = 0; zch < fGtuParam->GetNZChannels(); zch++) {
- AliDebug(2,Form("Track finder for Zchannel: %i", zch));
if (!RunTrackFinder(zch, ListOfTracks)) {
AliError(Form("Track Finder in z-channel %i failed", zch));
return kFALSE;
return kFALSE;
}
- if (esd) {
- TIter next(ListOfTracks);
- while (AliTRDtrackGTU *trk = (AliTRDtrackGTU*) next()) {
- AliESDTrdTrack *trdtrack = trk->CreateTrdTrack();
- esd->AddTrdTrack(trdtrack);
- delete trdtrack;
- }
+ // ----- label calculation and ESD storage -----
+ TIter next(ListOfTracks);
+ while (AliTRDtrackGTU *trk = (AliTRDtrackGTU*) next()) {
+ trk->CookLabel();
+ if (esd) {
+ AliESDTrdTrack *trdtrack = trk->CreateTrdTrack();
+ esd->AddTrdTrack(trdtrack);
+ delete trdtrack;
+ }
}
return kTRUE;
Int_t alpha = (trk->GetYbin() >> fGtuParam->GetBitExcessY()) * fGtuParam->GetCiAlpha(layer);
alpha = ( 2 * trk->GetdY() - (alpha >> fGtuParam->GetBitExcessAlpha()) + 1 ) >> 1;
- trk->SetAlpha(alpha);
+ // wrapping projected alpha as in hardware
+ if ((alpha < -64) || (alpha > 63))
+ AliError(Form("alpha out of range: %i", alpha));
+ alpha = alpha & 0x7f;
+ if (alpha & 0x40)
+ trk->SetAlpha(0xffffffc0 | alpha);
+ else
+ trk->SetAlpha(alpha);
Int_t yproj = trk->GetdY() * (fGtuParam->GetCiYProj(layer)); //??? sign?
yproj = ( ( ( (yproj >> fGtuParam->GetBitExcessYProj()) + trk->GetYbin() ) >> 2) + 1) >> 1;
for (Int_t refLayerIdx = 0; refLayerIdx < fGtuParam->GetNRefLayers(); refLayerIdx++) {
Int_t reflayer = fGtuParam->GetRefLayer(refLayerIdx);
- AliDebug(5,Form("~~~~~ Reflayer: %i", reflayer));
+ AliDebug(5,Form("Tracking for z-channel: %i, reflayer: %i", zch, reflayer));
ready = kFALSE; // ready if all channels done
if (0 <= ptrB[reflayer] && ptrB[reflayer] < notr[reflayer])
trkRB = (AliTRDtrackletGTU*) fZChannelTracklets[reflayer][zch].At(ptrB[reflayer]);
- AliDebug(10,Form("ptrRA: %i, ptrRB: %i", ptrA[reflayer], ptrB[reflayer]));
yPlus = trkRA->GetYProj() + fGtuParam->GetDeltaY();
yMinus = trkRA->GetYProj() - fGtuParam->GetDeltaY();
alphaPlus = trkRA->GetAlpha() + fGtuParam->GetDeltaAlpha();
}
} // end of loop over layers
- AliDebug(5,Form("logic calculation finished, Nhits: %i", nHits));
+ AliDebug(5,Form("logic calculation finished, Nhits: %i %s",
+ nHits, (nHits >= 4) ? "-> track found" : ""));
if (nHits >= 4) {
// ----- track registration -----
- AliDebug(1,"***** TMU: Track found *****");
AliTRDtrackGTU *track = new AliTRDtrackGTU();
track->SetSector(fSector);
track->SetStack(fStack);
}
ready = kTRUE;
- for (Int_t layer = 0; layer < fGtuParam->GetNLayers(); layer++) {
+ for (Int_t layer = fGtuParam->GetNLayers()-1; layer >= 0; layer--) {
bDone[layer] = ptrB[layer] < 0 || ptrB[layer] >= notr[layer];
ready = ready && bDone[layer];
AliError(Form("Invalid increment: %i at ptrA: %i, notr: %i", inc[layer], ptrA[layer], notr[layer]));
// AliInfo(Form("Shifting layer: %i, notr: %i, ptrA: %i, ptrB: %i, inc: %i", layer, notr[layer], ptrA[layer], ptrB[layer], inc[layer]));
- AliDebug(10,Form(" -- Layer: %i %2i(%2i)%s%s %2i(%2i)%s%s +%i %s (no: %i)",
+ AliDebug(10,Form(" Layer: %i %2i(%2i, %2i, %4i, %3i)%s%s %2i(%2i, %2i, %4i, %3i)%s%s +%i %s (no: %i)",
layer,
ptrA[layer],
(0 <= ptrA[layer] && ptrA[layer] < notr[layer]) ? ((AliTRDtrackletGTU*) fZChannelTracklets[layer][zch].At(ptrA[layer]))->GetIndex() : -1,
+ (0 <= ptrA[layer] && ptrA[layer] < notr[layer]) ? ((AliTRDtrackletGTU*) fZChannelTracklets[layer][zch].At(ptrA[layer]))->GetSubChannel(zch) : -1,
+ (0 <= ptrA[layer] && ptrA[layer] < notr[layer]) ? ((AliTRDtrackletGTU*) fZChannelTracklets[layer][zch].At(ptrA[layer]))->GetYProj() : -1,
+ (0 <= ptrA[layer] && ptrA[layer] < notr[layer]) ? ((AliTRDtrackletGTU*) fZChannelTracklets[layer][zch].At(ptrA[layer]))->GetAlpha() : -1,
bHitA[layer] ? "*" : " ", bAlignedA[layer] ? "+" : " ",
ptrB[layer],
(0 <= ptrB[layer] && ptrB[layer] < notr[layer]) ? ((AliTRDtrackletGTU*) fZChannelTracklets[layer][zch].At(ptrB[layer]))->GetIndex() : -1,
+ (0 <= ptrB[layer] && ptrB[layer] < notr[layer]) ? ((AliTRDtrackletGTU*) fZChannelTracklets[layer][zch].At(ptrB[layer]))->GetSubChannel(zch) : -1,
+ (0 <= ptrB[layer] && ptrB[layer] < notr[layer]) ? ((AliTRDtrackletGTU*) fZChannelTracklets[layer][zch].At(ptrB[layer]))->GetYProj() : -1,
+ (0 <= ptrB[layer] && ptrB[layer] < notr[layer]) ? ((AliTRDtrackletGTU*) fZChannelTracklets[layer][zch].At(ptrB[layer]))->GetAlpha() : -1,
bHitB[layer] ? "*" : " ", bAlignedB[layer] ? "+" : " ",
inc[layer], bDone[layer] ? "done" : " ", notr[layer]));
ptrA[layer] += inc[layer];
AliTRDtrackGTU **trkInRefLayer = new AliTRDtrackGTU*[fGtuParam->GetNRefLayers()];
- Bool_t done = kFALSE;
+ // Bool_t done = kFALSE;
Int_t minIdx = 0;
AliTRDtrackGTU *trkStage0 = 0x0;
for (Int_t zch = 0; zch < fGtuParam->GetNZChannels(); zch++) {
// ----- Merging and Unification in Reflayers (seed_merger) -----
do {
- done = kTRUE;
+ // done = kTRUE;
trkStage0 = 0x0;
for (Int_t refLayerIdx = 0; refLayerIdx < fGtuParam->GetNRefLayers(); refLayerIdx++) {
trkInRefLayer[refLayerIdx] = (AliTRDtrackGTU*) fTracks[zch][refLayerIdx].First();
else if (trkStage0 == 0x0 ) {
trkStage0 = trkInRefLayer[refLayerIdx];
minIdx = refLayerIdx;
- done = kFALSE;
+ // done = kFALSE;
}
else if (trkInRefLayer[refLayerIdx]->GetZSubChannel() < trkStage0->GetZSubChannel() ||
(trkInRefLayer[refLayerIdx]->GetZSubChannel() == trkStage0->GetZSubChannel() && trkInRefLayer[refLayerIdx]->GetYapprox() < trkStage0->GetYapprox()) ) {
minIdx = refLayerIdx;
trkStage0 = trkInRefLayer[refLayerIdx];
- done = kFALSE;
+ // done = kFALSE;
}
}
if (!trkStage0)
TIter trackRefMerged(tracksRefMerged[zch]);
while (AliTRDtrackGTU *trk = (AliTRDtrackGTU*) trackRefMerged())
AliDebug(2, Form("track ref layer %i : %i %i %i %i %i %i, y=%i, z_idx=%i",
- trk->GetRefLayerIdx(),
+ AliTRDgtuParam::GetRefLayer(trk->GetRefLayerIdx()),
trk->GetTrackletIndex(5),
trk->GetTrackletIndex(4),
trk->GetTrackletIndex(3),
TIter trackRefUnique(tracksRefUnique[zch]);
while (AliTRDtrackGTU *trk = (AliTRDtrackGTU*) trackRefUnique())
AliDebug(2, Form("track ref layer %i : %i %i %i %i %i %i, y=%i, z_idx=%i",
- trk->GetRefLayerIdx(),
+ AliTRDgtuParam::GetRefLayer(trk->GetRefLayerIdx()),
trk->GetTrackletIndex(5),
trk->GetTrackletIndex(4),
trk->GetTrackletIndex(3),
// ----- Merging in zchannels - 1st stage -----
do {
- done = kTRUE;
+ // done = kTRUE;
trkStage0 = 0x0;
- for (Int_t zch = fGtuParam->GetNZChannels() - 1; zch > -1; zch--) {
+ for (Int_t zch = fGtuParam->GetNZChannels() - 1; zch > -1; zch--) {
AliTRDtrackGTU *trk = (AliTRDtrackGTU*) tracksRefUnique[zch]->First();
if (trk == 0) {
continue;
else if (trkStage0 == 0x0 ) {
trkStage0 = trk;
minIdx = zch;
- done = kFALSE;
+ // done = kFALSE;
}
- else if ( ((trk->GetZChannel() + 3 * trk->GetZSubChannel()) / 2 - 1) < ((trkStage0->GetZChannel() + 3 * trkStage0->GetZSubChannel()) / 2 -1 ) ) {
+ else if ( ((trk->GetZChannel() + 3 * trk->GetZSubChannel()) / 2 - 1) < ((trkStage0->GetZChannel() + 3 * trkStage0->GetZSubChannel()) / 2 -1 ) ||
+ (((trk->GetZChannel() + 3 * trk->GetZSubChannel()) / 2 - 1) == ((trkStage0->GetZChannel() + 3 * trkStage0->GetZSubChannel()) / 2 -1 ) && (trk->GetYapprox() < trkStage0->GetYapprox()) ) ) {
minIdx = zch;
trkStage0 = trk;
- done = kFALSE;
+ // done = kFALSE;
}
}
Uniquifier(tracksZMergedStage0, tracksZUniqueStage0);
+ AliDebug(2, "stage 0:");
+ TIter trackZMergedStage0(tracksZMergedStage0);
+ while (AliTRDtrackGTU *trk = (AliTRDtrackGTU*) trackZMergedStage0())
+ AliDebug(2, Form("track ref layer %i : %i %i %i %i %i %i, y=%i, zch=%i idx=%i",
+ AliTRDgtuParam::GetRefLayer(trk->GetRefLayerIdx()),
+ trk->GetTrackletIndex(5),
+ trk->GetTrackletIndex(4),
+ trk->GetTrackletIndex(3),
+ trk->GetTrackletIndex(2),
+ trk->GetTrackletIndex(1),
+ trk->GetTrackletIndex(0),
+ trk->GetYapprox() >> 3,
+ trk->GetZChannel(),
+ trk->GetZSubChannel()));
+
+ AliDebug(2, "uniquified:");
+ TIter trackZUniqueStage0(tracksZUniqueStage0);
+ while (AliTRDtrackGTU *trk = (AliTRDtrackGTU*) trackZUniqueStage0())
+ AliDebug(2, Form("track ref layer %i : %i %i %i %i %i %i, y=%i, zch=%i idx=%i",
+ AliTRDgtuParam::GetRefLayer(trk->GetRefLayerIdx()),
+ trk->GetTrackletIndex(5),
+ trk->GetTrackletIndex(4),
+ trk->GetTrackletIndex(3),
+ trk->GetTrackletIndex(2),
+ trk->GetTrackletIndex(1),
+ trk->GetTrackletIndex(0),
+ trk->GetYapprox() >> 3,
+ trk->GetZChannel(),
+ trk->GetZSubChannel()));
+
// ----- Splitting in z -----
TIter next(tracksZUniqueStage0);
tracksZSplitted[(trk->GetZChannel() + 3 * (trk->GetZSubChannel() - 1)) % 2]->Add(trk);
}
+ for (Int_t i = 0; i < 2; i++) {
+ AliDebug(2, Form("split %i:", i));
+ TIter trackZSplit(tracksZSplitted[i]);
+ while (AliTRDtrackGTU *trk = (AliTRDtrackGTU*) trackZSplit())
+ AliDebug(2, Form("track ref layer %i : %i %i %i %i %i %i, y=%i, zch=%i idx=%i",
+ AliTRDgtuParam::GetRefLayer(trk->GetRefLayerIdx()),
+ trk->GetTrackletIndex(5),
+ trk->GetTrackletIndex(4),
+ trk->GetTrackletIndex(3),
+ trk->GetTrackletIndex(2),
+ trk->GetTrackletIndex(1),
+ trk->GetTrackletIndex(0),
+ trk->GetYapprox() >> 3,
+ trk->GetZChannel(),
+ trk->GetZSubChannel()));
+ }
+
// ----- Merging in zchanels - 2nd stage -----
do {
- done = kTRUE;
+ // done = kTRUE;
trkStage0 = 0x0;
for (Int_t i = 1; i >= 0; i--) {
AliTRDtrackGTU *trk = (AliTRDtrackGTU*) tracksZSplitted[i]->First();
else if (trkStage0 == 0x0 ) {
trkStage0 = trk;
minIdx = i;
- done = kFALSE;
+ // done = kFALSE;
}
- else if ( ((trk->GetZChannel() + 3 * (trk->GetZSubChannel() - 1)) / 2) < ((trkStage0->GetZChannel() + 3 * (trkStage0->GetZSubChannel() - 1)) / 2) ) {
+ else if ( (((trk->GetZChannel() + 3 * (trk->GetZSubChannel() - 1)) / 2) < ((trkStage0->GetZChannel() + 3 * (trkStage0->GetZSubChannel() - 1)) / 2)) ||
+ ((((trk->GetZChannel() + 3 * (trk->GetZSubChannel() - 1)) / 2) == ((trkStage0->GetZChannel() + 3 * (trkStage0->GetZSubChannel() - 1)) / 2)) && (trk->GetYapprox() < trkStage0->GetYapprox()) ) ) {
minIdx = i;
trkStage0 = trk;
- done = kFALSE;
+ // done = kFALSE;
}
}
Uniquifier(tracksZMergedStage1, ListOfTracks);
+ AliDebug(2, "merged:");
+ TIter trackZMergedStage1(tracksZMergedStage1);
+ while (AliTRDtrackGTU *trk = (AliTRDtrackGTU*) trackZMergedStage1())
+ AliDebug(2, Form("track ref layer %i : %i %i %i %i %i %i, y=%i, zch=%i idx=%i",
+ AliTRDgtuParam::GetRefLayer(trk->GetRefLayerIdx()),
+ trk->GetTrackletIndex(5),
+ trk->GetTrackletIndex(4),
+ trk->GetTrackletIndex(3),
+ trk->GetTrackletIndex(2),
+ trk->GetTrackletIndex(1),
+ trk->GetTrackletIndex(0),
+ trk->GetYapprox() >> 3,
+ trk->GetZChannel(),
+ trk->GetZSubChannel()));
+
+ AliDebug(2, "uniquified:");
+ TIter track(ListOfTracks);
+ while (AliTRDtrackGTU *trk = (AliTRDtrackGTU*) track())
+ AliDebug(2, Form("track ref layer %i : %i %i %i %i %i %i, y=%i, zch=%i idx=%i",
+ AliTRDgtuParam::GetRefLayer(trk->GetRefLayerIdx()),
+ trk->GetTrackletIndex(5),
+ trk->GetTrackletIndex(4),
+ trk->GetTrackletIndex(3),
+ trk->GetTrackletIndex(2),
+ trk->GetTrackletIndex(1),
+ trk->GetTrackletIndex(0),
+ trk->GetYapprox() >> 3,
+ trk->GetZChannel(),
+ trk->GetZSubChannel()));
+
// cleaning up
for (Int_t zch = 0; zch < fGtuParam->GetNZChannels(); zch++) {
delete tracksRefMerged[zch];
return kFALSE;
}
- if (AliTRDgtuParam::GetUseGTUconst) {
+ if (AliTRDgtuParam::GetUseGTUconst()) {
// averaging as in GTU
ULong64_t coeff;
}
}
- ULong64_t sumExt = (sum << 1) & 0xfff; // 11 bit -> 12 bit vector
- ULong64_t prod = (sumExt * coeff) & 0xfffffffffull; // 18x18 signed -> 36
- ULong64_t prodFinal = ((prod >> 18) + ((prod >> 17) & 1)) & 0xff; // rounding term is equivalent to adding 5 to sum_ext
+ sum = sum & 0x7ff;
+ ULong64_t prod = (sum * coeff) & 0xfffffffffull;
+ ULong64_t prodFinal = ((prod >> 17) + ((prod >> 16) & 1)) & 0xff;
track->SetPID(prodFinal & 0xff);
pidSum += trk->GetPID();
nTracklets++;
}
- track->SetPID(pidSum/nTracklets);
+
+ if (nTracklets>0)
+ track->SetPID(pidSum/nTracklets);
+ else
+ AliError("Track without contributing tracklets, no PID assigned");
return kTRUE;
}
AliError(Form("Could not get tracklet in layer %i\n", layer));
continue;
}
- AliDebug(10,Form("trk yprime: %i", trk->GetYPrime()));
+ AliDebug(10,Form(" layer %i trk yprime: %6i, aki: %6i", layer, trk->GetYPrime(), (Int_t) (2048 * fGtuParam->GetAki(track->GetTrackletMask(), layer))));
a += (((Int_t) (2048 * fGtuParam->GetAki(track->GetTrackletMask(), layer))) * trk->GetYPrime() + 1) >> 8;
b += fGtuParam->GetBki(track->GetTrackletMask(), layer) * trk->GetYPrime() * fGtuParam->GetBinWidthY();
c += fGtuParam->GetCki(track->GetTrackletMask(), layer) * trk->GetYPrime() * fGtuParam->GetBinWidthY();
a += 3;
a = a >> 2;
- fGtuParam->GetIntersectionPoints(track->GetTrackletMask(), x1, x2);
- AliDebug(10,Form("Intersection points: %f, %f", x1, x2));
- AliDebug(10,Form("Sum: a = %5i, b = %9.2f, c = %9.2f\n", a, b, c));
track->SetFitParams(a, b, c);
- Int_t pt = fGtuParam->GetPt(track->GetTrackletMask(), a, b, x1, x2);
- track->SetPtInt(pt);
- AliDebug(5,Form("Track parameters: a = %i, b = %f, c = %f, x1 = %f, x2 = %f, pt = %f (trkl mask: %i)", a, b, c, x1, x2, track->GetPt(), track->GetTrackletMask()));
- return kTRUE;
-}
+ fGtuParam->GetIntersectionPoints(track->GetTrackletMask(), x1, x2);
-Bool_t AliTRDgtuTMU::WriteTrackletsToTree(TTree *trklTree)
-{
- if (!trklTree) {
- AliError("No tree given");
- return kFALSE;
- }
- AliTRDtrackletGTU *trkl = 0x0;
- TBranch *branch = trklTree->GetBranch("gtutracklets");
- if (!branch) {
- branch = trklTree->Branch("gtutracklets", "AliTRDtrackletGTU", &trkl, 32000, 99);
- }
+ AliDebug(5,Form(" Track parameters: a = %i, b = %f, c = %f, x1 = %f, x2 = %f, pt = %f (trkl mask: %i)", a, b, c, x1, x2, track->GetPt(), track->GetTrackletMask()));
- AliDebug(5,Form("---------- Writing tracklets to tree (not yet) ----------"));
- for (Int_t layer = 0; layer < fGtuParam->GetNLayers(); layer++) {
- TIter next(fTrackletsPostInput[layer]);
- while ((trkl = (AliTRDtrackletGTU*) next())) {
- AliDebug(10,Form("InputUnit : GetIndex(): %3i, GetZbin(): %2i, GetY() : %5i, GetdY() : %3i, GetYPrime() : %5i, GetYProj() : %5i, GetAlpha() : %3i, Zidx(2..0): %i %i %i", trkl->GetIndex(), trkl->GetZbin(), trkl->GetYbin(), trkl->GetdY(), trkl->GetYPrime(), trkl->GetYProj(), trkl->GetAlpha(), trkl->GetSubChannel(2), trkl->GetSubChannel(1), trkl->GetSubChannel(0) ));
- branch->SetAddress(&trkl);
- trklTree->Fill();
- }
- }
return kTRUE;
}
-Bool_t AliTRDgtuTMU::Uniquifier(TList *inlist, TList *outlist)
+
+Bool_t AliTRDgtuTMU::Uniquifier(const TList *inlist, TList *outlist)
{
// remove multiple occurences of the same track