// //
////////////////////////////////////////////////////////////////////////////
+#include <cstdio>
+#include <cstdarg>
+
#include "TClonesArray.h"
#include "TTree.h"
#include "AliTRDarrayDictionary.h"
#include "AliTRDSignalIndex.h"
#include "AliTRDtrackletWord.h"
+#include "AliESDTrdTrack.h"
+#include "AliTreeLoader.h"
#include "AliTRDrawStream.h"
// some static information
const Int_t AliTRDrawStream::fgkMcmOrder[] = {12, 13, 14, 15,
- 8, 9, 10, 11,
- 4, 5, 6, 7,
- 0, 1, 2, 3};
+ 8, 9, 10, 11,
+ 4, 5, 6, 7,
+ 0, 1, 2, 3};
const Int_t AliTRDrawStream::fgkRobOrder [] = {0, 1, 2, 3};
const Int_t AliTRDrawStream::fgkNlinks = 12;
const Int_t AliTRDrawStream::fgkNstacks = 5;
const UInt_t AliTRDrawStream::fgkDataEndmarker = 0x00000000;
const UInt_t AliTRDrawStream::fgkTrackletEndmarker = 0x10001000;
-char* AliTRDrawStream::fgErrorMessages[] = {
+const char* AliTRDrawStream::fgErrorMessages[] = {
"Unknown error",
"Link monitor active",
"Pretrigger counter mismatch",
"Missing MCM headers"
};
+const Int_t AliTRDrawStream::fgErrorDebugLevel[] = {
+ 0,
+ 0,
+ 2,
+ 1,
+ 0,
+ 1,
+ 1,
+ 1,
+ 1,
+ 2,
+ 1,
+ 1,
+ 1,
+ 1,
+ 2,
+ 1,
+ 1,
+ 1
+};
+
+AliTRDrawStream::ErrorBehav_t AliTRDrawStream::fgErrorBehav[] = {
+ AliTRDrawStream::kTolerate,
+ AliTRDrawStream::kDiscardHC,
+ AliTRDrawStream::kTolerate,
+ AliTRDrawStream::kAbort,
+ AliTRDrawStream::kAbort,
+ AliTRDrawStream::kAbort,
+ AliTRDrawStream::kAbort,
+ AliTRDrawStream::kDiscardHC,
+ AliTRDrawStream::kDiscardHC,
+ AliTRDrawStream::kTolerate,
+ AliTRDrawStream::kTolerate,
+ AliTRDrawStream::kTolerate,
+ AliTRDrawStream::kTolerate,
+ AliTRDrawStream::kTolerate,
+ AliTRDrawStream::kTolerate,
+ AliTRDrawStream::kTolerate,
+ AliTRDrawStream::kTolerate,
+ AliTRDrawStream::kTolerate
+};
+
AliTRDrawStream::AliTRDrawStream(AliRawReader *rawReader) :
+ fStats(),
+ fStoreError(&AliTRDrawStream::StoreErrorTree),
fRawReader(rawReader),
fDigitsManager(0x0),
fDigitsParam(0x0),
fErrors(0x0),
fLastError(),
+ fErrorFlags(0),
fPayloadStart(0x0),
fPayloadCurr(0x0),
fPayloadSize(0),
fCurrBC(-1),
fCurrPtrgCnt(-1),
fCurrPtrgPhase(-1),
+ fNDumpMCMs(0),
fTrackletArray(0x0),
fAdcArray(0x0),
fSignalIndex(0x0),
- fTrackletTree(0x0)
+ fTrackletTree(0x0),
+ fTracklets(0x0),
+ fTracks(0x0),
+ fMarkers(0x0)
{
// default constructor
fCurrLinkMonitorFlags = new UInt_t[fgkNstacks * fgkNlinks];
fCurrLinkDataTypeFlags = new UInt_t[fgkNstacks * fgkNlinks];
fCurrLinkDebugFlags = new UInt_t[fgkNstacks * fgkNlinks];
+ for (Int_t i = 0; i < 100; i++)
+ fDumpMCM[i] = 0;
// preparing TClonesArray
fTrackletArray = new TClonesArray("AliTRDtrackletWord", 256);
// setting up the error tree
fErrors = new TTree("errorStats", "Error statistics");
fErrors->SetDirectory(0x0);
- fErrors->Branch("error", &fLastError, "sector/I:stack:link:error:rob:mcm");
+ fErrors->Branch("error", &fLastError);
fErrors->SetCircular(1000);
+ for (Int_t i = 0; i < 100; i++) {
+ fErrorBuffer[i] = 0;
+ }
+
}
AliTRDrawStream::~AliTRDrawStream()
AliDebug(2, Form("equipment: %i", fCurrEquipmentId));
if (fCurrEquipmentId < 1024 || fCurrEquipmentId > 1041) {
- AliError(EquipmentError(kNonTrdEq, "Skipping"));
+ EquipmentError(kNonTrdEq, "Skipping");
continue;
}
// setting the pointer to data and current reading position
fPayloadCurr = fPayloadStart = (UInt_t*) (buffer);
fPayloadSize = fRawReader->GetDataSize() / sizeof(UInt_t);
+ fStats.fStatsSector[fCurrEquipmentId - 1024].fBytes = fRawReader->GetDataSize();
AliDebug(2, Form("Read buffer of size: %i", fRawReader->GetDataSize()));
// read SMU index header
if ((fCurrLinkMask[fCurrSlot] & (1 << fCurrLink)) == 0)
continue;
+ fErrorFlags = 0;
+ // check for link monitor error flag
if (fCurrLinkMonitorFlags[fCurrSlot*fgkNlinks + fCurrLink] != 0)
LinkError(kLinkMonitor);
- AliDebug(2, Form("Payload for S%il%i", fCurrSlot, fCurrLink));
- for (Int_t i = 0; i < 10; i++) //???
- AliDebug(5, Form("%3i: 0x%08x 0x%08x 0x%08x 0x%08x", i*4,
- fPayloadCurr[4*i], fPayloadCurr[4*i+1],
- fPayloadCurr[4*i+2], fPayloadCurr[4*i+3]));
// read the data from one HC
ReadLinkData();
// read all data endmarkers
- while (fPayloadCurr - fPayloadStart < fPayloadSize &&
- *fPayloadCurr == fgkDataEndmarker)
- fPayloadCurr++;
-
+ SeekNextLink();
}
}
}
AliDebug(2, Form("equipment: %i", fCurrEquipmentId));
if (fCurrEquipmentId < 1024 || fCurrEquipmentId > 1041) {
- AliError(EquipmentError(kNonTrdEq, "Skipping"));
+ EquipmentError(kNonTrdEq, "Skipping");
continue;
}
fDigitsManager = digMgr;
fDigitsParam = 0x0;
+ fErrorFlags = 0;
+
// tracklet output preparation
TTree *trklTree = 0x0;
AliRunLoader *rl = AliRunLoader::Instance();
AliLoader* trdLoader = rl ? rl->GetLoader("TRDLoader") : NULL;
AliDataLoader *trklLoader = trdLoader ? trdLoader->GetDataLoader("tracklets") : NULL;
if (trklLoader) {
- trklTree = trklLoader->Tree();
+ AliTreeLoader *trklTreeLoader = (AliTreeLoader*) trklLoader->GetBaseLoader("tracklets-raw");
+ if (trklTreeLoader)
+ trklTree = trklTreeLoader->Tree();
+ else
+ trklTree = trklLoader->Tree();
}
if (fTrackletTree != trklTree)
ReadLinkData();
// read all data endmarkers
- while (fPayloadCurr - fPayloadStart < fPayloadSize &&
- *fPayloadCurr == fgkDataEndmarker)
- fPayloadCurr++;
+ SeekNextLink();
if (fCurrLink % 2 == 0) {
// if we just read the A-side HC then also check the B-side
fCurrLink++;
+ fCurrHC++;
if (fCurrLinkMask[fCurrSlot] & (1 << fCurrLink)) {
ReadLinkData();
- while (fPayloadCurr - fPayloadStart < fPayloadSize &&
- *fPayloadCurr == fgkDataEndmarker)
- fPayloadCurr++;
+ SeekNextLink();
}
}
(((fCurrStackMask & (1 << fCurrSlot)) == 0) ||
((fCurrLinkMask[fCurrSlot] & (1 << fCurrLink))) == 0));
- return (fCurrSm * 30 + fCurrStack * 6 + fCurrLayer);
+ // return chamber information from HC if it is valid
+ // otherwise return information from link position
+ if (fCurrSm < 0 || fCurrSm > 17 || fCurrStack < 0 || fCurrStack > 4 || fCurrLayer < 0 || fCurrLayer > 5)
+ return ((fCurrEquipmentId-1024) + fCurrSlot * 6 + fCurrLink/2);
+ else
+ return (fCurrSm * 30 + fCurrStack * 6 + fCurrLayer);
}
// and store the information in the corresponding variables
if (fPayloadCurr - fPayloadStart >= fPayloadSize - 1) {
- AliError(EquipmentError(kUnknown, "SM Header incomplete"));
+ EquipmentError(kUnknown, "SM Header incomplete");
return -1;
}
fCurrSmuIndexHeaderSize = ((*fPayloadCurr) >> 16) & 0xffff;
fCurrSmuIndexHeaderVersion = ((*fPayloadCurr) >> 12) & 0xf;
+ // fCurrSmuIndexHeaderTrgAvail = ((*fPayloadCurr) >> 9) & 0x1;
+ // fCurrSmuIndexHeaderEvType = ((*fPayloadCurr) >> 7) & 0x3;
fCurrTrackEnable = ((*fPayloadCurr) >> 6) & 0x1;
fCurrTrackletEnable = ((*fPayloadCurr) >> 5) & 0x1;
fCurrStackMask = ((*fPayloadCurr) ) & 0x1f;
fCurrTrackEnable,
fCurrTrackletEnable,
fCurrStackMask));
-
+
+ // decode GTU track words
+ UInt_t trackWord[2];
+ Int_t stack = 0;
+ Int_t idx = 0;
+ for (UInt_t iWord = 4; iWord < fCurrSmuIndexHeaderSize; iWord++) {
+ if (fPayloadCurr[iWord] == 0x10000000) {
+ stack++;
+ idx = 0;
+ }
+ else {
+ if ((idx == 0) &&
+ ((fPayloadCurr[iWord] & 0xfffff0f0) == 0x13370000)) {
+ AliDebug(1,Form("stack %i: fast trigger word: 0x%08x", stack, fPayloadCurr[iWord]));
+ continue;
+ }
+ else if ((idx & 0x1)==0x1) {
+ trackWord[idx&0x1] = fPayloadCurr[iWord];
+ AliDebug(1,Form("track debug word: 0x%08x%08x", trackWord[1], trackWord[0]));
+// if (fTracks)
+// new ((*fTracks)[fTracks->GetEntriesFast()]) AliESDTrdTrack(0, 0, trackWord[0], trackWord[1], fCurrEquipmentId-1024);
+ }
+ else {
+ trackWord[idx&0x1] = fPayloadCurr[iWord];
+ }
+ idx++;
+ }
+ }
+
fPayloadCurr += fCurrSmuIndexHeaderSize + 1;
return fCurrSmuIndexHeaderSize + 1;
fCurrLinkMask[stack] = (*fPayloadCurr) & 0xfff;
if (fPayloadCurr - fPayloadStart >= fPayloadSize - (Int_t) fCurrStackHeaderSize[stack]) {
- AliError(StackError(kStackHeaderInvalid, "Stack index header aborted"));
+ StackError(kStackHeaderInvalid, "Stack index header aborted");
return -1;
}
switch (fCurrStackHeaderVersion[stack]) {
case 0xa:
if (fCurrStackHeaderSize[stack] < 8) {
- AliError(StackError(kStackHeaderInvalid, "Stack header smaller than expected!"));
+ StackError(kStackHeaderInvalid, "Stack header smaller than expected!");
return -1;
}
break;
default:
- AliError(StackError(kStackHeaderInvalid, Form("Invalid Stack Index Header version %x",
- fCurrStackHeaderVersion[stack])));
+ StackError(kStackHeaderInvalid, "Invalid Stack Index Header version %x", fCurrStackHeaderVersion[stack]);
}
fPayloadCurr += fCurrStackHeaderSize[stack];
Int_t AliTRDrawStream::ReadLinkData()
{
// read the data in one link (one HC) until the data endmarker is reached
+ // returns the number of words read!
Int_t count = 0;
+ UInt_t* startPosLink = fPayloadCurr;
+
+// printf("----- HC: %i -----\n", fCurrHC);
+// for (Int_t i = 0; i < 3; i++) {
+// printf("0x%08x 0x%08x 0x%08x 0x%08x\n",
+// fPayloadCurr[i*4+0], fPayloadCurr[i*4+1], fPayloadCurr[i*4+2], fPayloadCurr[i*4+3]);
+// }
+
+ if (fMarkers)
+ new ((*fMarkers)[fMarkers->GetEntriesFast()])
+ AliTRDrawStreamError(-kHCactive, fCurrSm, fCurrStack, fCurrLink);
+
+ if (fErrorFlags & kDiscardHC)
+ return count;
count += ReadTracklets();
+ if (fErrorFlags & kDiscardHC)
+ return count;
count += ReadHcHeader();
+ if (fErrorFlags & kDiscardHC)
+ return count;
Int_t det = fCurrSm * 30 + fCurrStack * 6 + fCurrLayer;
fAdcArray->Allocate(16, 144, fCurrNtimebins);
}
else {
- AliError(LinkError(kNoDigits));
+ LinkError(kNoDigits);
}
if (!fDigitsParam) {
}
}
else {
- AliError(LinkError(kInvalidDetector, Form("%i", det)));
- UInt_t *startPos = fPayloadCurr;
+ LinkError(kInvalidDetector, "%i", det);
while (fPayloadCurr - fPayloadStart < fPayloadSize &&
*fPayloadCurr != fgkDataEndmarker)
fPayloadCurr++;
- count += fPayloadCurr - startPos;
}
+ fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fBytes += (fPayloadCurr - startPosLink) * sizeof(UInt_t);
+ fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fBytesRead += count * sizeof(UInt_t);
+ fStats.fStatsSector[fCurrSm].fBytesRead += count * sizeof(UInt_t);
+ fStats.fBytesRead += count * sizeof(UInt_t);
+
return count;
}
while (*(fPayloadCurr) != fgkTrackletEndmarker &&
fPayloadCurr - fPayloadStart < fPayloadSize) {
- new ((*fTrackletArray)[fTrackletArray->GetEntriesFast()]) AliTRDtrackletWord(*(fPayloadCurr));
+ new ((*fTrackletArray)[fTrackletArray->GetEntriesFast()]) AliTRDtrackletWord(*(fPayloadCurr), fCurrHC);
fPayloadCurr++;
}
if (fTrackletArray->GetEntriesFast() > 0) {
AliDebug(1, Form("Found %i tracklets in %i %i %i (ev. %i)", fTrackletArray->GetEntriesFast(),
fCurrSm, fCurrSlot, fCurrLink, fRawReader->GetEventIndex()));
+ if (fCurrSm > -1 && fCurrSm < 18) {
+ fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fNTracklets += fTrackletArray->GetEntriesFast();
+ fStats.fStatsSector[fCurrSm].fNTracklets += fTrackletArray->GetEntriesFast();
+ }
if (fTrackletTree)
fTrackletTree->Fill();
+ if (fTracklets)
+ for (Int_t iTracklet = 0; iTracklet < fTrackletArray->GetEntriesFast(); iTracklet++) {
+ new ((*fTracklets)[fTracklets->GetEntriesFast()]) AliTRDtrackletWord(*((AliTRDtrackletWord*)(*fTrackletArray)[iTracklet]));
+ }
}
// loop over remaining tracklet endmarkers
fPayloadCurr - fPayloadStart < fPayloadSize))
fPayloadCurr++;
- return (fPayloadCurr - start) / sizeof(UInt_t);
+ return fPayloadCurr - start;
}
Int_t AliTRDrawStream::ReadHcHeader()
fCurrStack != fCurrSlot ||
fCurrLayer != fCurrLink / 2 ||
fCurrSide != fCurrLink % 2) {
- AliError(LinkError(kHCmismatch,
- Form("HC: %i, %i, %i, %i\n 0x%08x 0x%08x 0x%08x 0x%08x",
- fCurrSm, fCurrStack, fCurrLayer, fCurrSide,
- fPayloadCurr[0], fPayloadCurr[1], fPayloadCurr[2], fPayloadCurr[3]) ));
+ LinkError(kHCmismatch,
+ "HC: %i, %i, %i, %i\n 0x%08x 0x%08x 0x%08x 0x%08x",
+ fCurrSm, fCurrStack, fCurrLayer, fCurrSide,
+ fPayloadCurr[0], fPayloadCurr[1], fPayloadCurr[2], fPayloadCurr[3]);;
}
if (fCurrCheck != 0x1) {
- AliError(LinkError(kHCcheckFailed));
+ LinkError(kHCcheckFailed);
}
if (fCurrAddHcWords > 0) {
fPayloadCurr += 1 + fCurrAddHcWords;
- return (fPayloadCurr - start) / sizeof(UInt_t);
+ return (fPayloadCurr - start);
}
Int_t AliTRDrawStream::ReadTPData(Int_t mode)
lastrobpos = GetROBReadoutPos(ROB(*fPayloadCurr) / 2);
}
else {
- AliError(ROBError(kPosUnexp));
+ ROBError(kPosUnexp);
}
fCurrRobPos = ROB(*fPayloadCurr);
lastmcmpos = GetMCMReadoutPos(MCM(*fPayloadCurr));
}
else {
- AliError(MCMError(kPosUnexp));
+ MCMError(kPosUnexp);
}
fCurrMcmPos = MCM(*fPayloadCurr);
}
else {
expword = 0;
- AliError(LinkError(kTPmodeInvalid, "Just reading"));
+ LinkError(kTPmodeInvalid, "Just reading");
}
diff = *fPayloadCurr ^ expword;
if (diff != 0) {
- AliError(MCMError(kTPmismatch,
- Form("Seen 0x%08x, expected 0x%08x, diff: 0x%08x (0x%02x)",
- *fPayloadCurr, expword, diff, 0xff & (diff | diff >> 8 | diff >> 16 | diff >> 24)) ));
+ MCMError(kTPmismatch,
+ "Seen 0x%08x, expected 0x%08x, diff: 0x%08x (0x%02x)",
+ *fPayloadCurr, expword, diff, 0xff & (diff | diff >> 8 | diff >> 16 | diff >> 24));;
}
fPayloadCurr++;
count++;
if (fCurrNtimebins != fNtimebins) {
if (fNtimebins > 0)
- AliError(LinkError(kNtimebinsChanged,
- Form("No. of timebins changed from %i to %i", fNtimebins, fCurrNtimebins) ));
+ LinkError(kNtimebinsChanged,
+ "No. of timebins changed from %i to %i", fNtimebins, fCurrNtimebins);
fNtimebins = fCurrNtimebins;
}
// ----- Checking MCM Header -----
AliDebug(2, Form("MCM header: 0x%08x", *fPayloadCurr));
+ UInt_t *startPosMCM = fPayloadCurr;
// ----- checking for proper readout order - ROB -----
if (GetROBReadoutPos(ROB(*fPayloadCurr) / 2) >= lastrobpos) {
lastrobpos = GetROBReadoutPos(ROB(*fPayloadCurr) / 2);
}
else {
- AliError(ROBError(kPosUnexp));
+ ROBError(kPosUnexp);
}
fCurrRobPos = ROB(*fPayloadCurr);
lastmcmpos = GetMCMReadoutPos(lastmcmpos);
}
else {
- AliError(MCMError(kPosUnexp));
+ MCMError(kPosUnexp);
}
fCurrMcmPos = MCM(*fPayloadCurr);
if (evno == -1)
evno = EvNo(*fPayloadCurr);
else {
- AliError(MCMError(kPtrgCntMismatch,
- Form("%i <-> %i", evno, EvNo(*fPayloadCurr)) ));
+ MCMError(kPtrgCntMismatch, "%i <-> %i", evno, EvNo(*fPayloadCurr));
}
}
Int_t adccoloff = AdcColOffset(*fPayloadCurr);
}
while (channelcountExp < channelcountMax && channelcountExp < 21 &&
fPayloadCurr - fPayloadStart < fPayloadSize - 10 * channelcountExp - 1) {
- AliError(MCMError(kAdcMaskInconsistent,
- Form("Possible MCM-H: 0x%08x, possible ADC-mask: 0x%08x",
- *(fPayloadCurr + 10 * channelcountExp),
- *(fPayloadCurr + 10 * channelcountExp + 1) ) ));
+ MCMError(kAdcMaskInconsistent,
+ "Possible MCM-H: 0x%08x, possible ADC-mask: 0x%08x",
+ *(fPayloadCurr + 10 * channelcountExp),
+ *(fPayloadCurr + 10 * channelcountExp + 1) );
if (!CouldBeMCMhdr( *(fPayloadCurr + 10 * channelcountExp)) && !CouldBeADCmask( *(fPayloadCurr + 10 * channelcountExp + 1)))
channelcountExp++;
else {
break;
}
}
- AliError(MCMError(kAdcMaskInconsistent,
- Form("Inconsistency in no. of active channels: Counter: %i, Mask: %i, chosen: %i!",
- GetNActiveChannels(fPayloadCurr[-1]), GetNActiveChannelsFromMask(fPayloadCurr[-1]), channelcountExp) ));
+ MCMError(kAdcMaskInconsistent,
+ "Inconsistency in no. of active channels: Counter: %i, Mask: %i, chosen: %i!",
+ GetNActiveChannels(fPayloadCurr[-1]), GetNActiveChannelsFromMask(fPayloadCurr[-1]), channelcountExp);
}
AliDebug(2, Form("expecting %i active channels, timebins: %i", channelcountExp, fCurrNtimebins));
// ----- reading marked ADC channels -----
while (channelcount < channelcountExp && *(fPayloadCurr) != fgkDataEndmarker) {
- if (channelno < 21)
+ if (channelno < 20)
channelno++;
- while (channelno < 21 && (channelmask & 1 << channelno) == 0)
+ while (channelno < 20 && (channelmask & 1 << channelno) == 0)
channelno++;
if (fCurrNtimebins > 30) {
AliDebug(2, Form("Now looking %i words", timebins / 3));
Int_t adccol = adccoloff - channelno;
Int_t padcol = padcoloff - channelno;
+// if (adccol < 3 || adccol > 165)
+// AliInfo(Form("writing channel %i of det %3i %i:%2i to adcrow/-col: %i/%i padcol: %i",
+// channelno, fCurrHC/2, fCurrRobPos, fCurrMcmPos, row, adccol, padcol));
+
while (adcwc < timebins / 3 &&
*(fPayloadCurr) != fgkDataEndmarker &&
fPayloadCurr - fPayloadStart < fPayloadSize) {
int check = 0x3 & *fPayloadCurr;
if (channelno % 2 != 0) { // odd channel
if (check != 0x2 && channelno < 21) {
- AliError(MCMError(kAdcCheckInvalid,
- Form("Invalid check bits: %i for %2i. ADC word in odd channel: %i",
- check, adcwc+1, channelno) ));
+ MCMError(kAdcCheckInvalid,
+ "%i for %2i. ADC word in odd channel %i",
+ check, adcwc+1, channelno);
}
}
else { // even channel
if (check != 0x3 && channelno < 21) {
- AliError(MCMError(kAdcCheckInvalid,
- Form("Invalid check bits: %i for %2i. ADC word in even channel: %i",
- check, adcwc+1, channelno) ));
+ MCMError(kAdcCheckInvalid,
+ "%i for %2i. ADC word in even channel %i",
+ check, adcwc+1, channelno);
}
}
}
if (adcwc != timebins / 3)
- AliError(MCMError(kAdcDataAbort));
+ MCMError(kAdcDataAbort);
// adding index
if (padcol > 0 && padcol < 144) {
channelcount++;
}
-
+
+ fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fNChannels += channelcount;
+ fStats.fStatsSector[fCurrSm].fNChannels += channelcount;
if (channelcount != channelcountExp)
- AliError(MCMError(kAdcChannelsMiss));
+ MCMError(kAdcChannelsMiss);
mcmcount++;
+ fStats.fStatsSector[fCurrSm].fStatsHC[fCurrHC%60].fNMCMs++;
+ fStats.fStatsSector[fCurrSm].fNMCMs++;
+
+ if (IsDumping() && DumpingMCM(fCurrHC/2, fCurrRobPos, fCurrMcmPos)) {
+ DumpRaw(Form("Event %i: Det %3i ROB %i MCM %2i", fRawReader->GetEventIndex(), fCurrHC/2, fCurrRobPos, fCurrMcmPos),
+ startPosMCM, fPayloadCurr - startPosMCM);
+ }
+
// continue with next MCM
}
// check for missing MCMs (if header suppression is inactive)
if (((fCurrMajor & 0x1) == 0) && (mcmcount != mcmcountExp)) {
- AliError(LinkError(kMissMcmHeaders,
- Form("No. of MCM headers %i not as expected: %i",
- mcmcount, mcmcountExp) ));
+ LinkError(kMissMcmHeaders,
+ "No. of MCM headers %i not as expected: %i",
+ mcmcount, mcmcountExp);
}
return (fPayloadCurr - start);
if (fCurrNtimebins != fNtimebins) {
if (fNtimebins > 0)
- AliError(LinkError(kNtimebinsChanged,
- Form("No. of timebins changed from %i to %i", fNtimebins, fCurrNtimebins) ));
+ LinkError(kNtimebinsChanged,
+ "No. of timebins changed from %i to %i", fNtimebins, fCurrNtimebins);
fNtimebins = fCurrNtimebins;
}
lastrobpos = GetROBReadoutPos(ROB(*fPayloadCurr) / 2);
}
else {
- AliError(ROBError(kPosUnexp));
+ ROBError(kPosUnexp);
}
fCurrRobPos = ROB(*fPayloadCurr);
lastmcmpos = GetMCMReadoutPos(*fPayloadCurr);
}
else {
- AliError(MCMError(kPosUnexp));
+ MCMError(kPosUnexp);
}
fCurrMcmPos = MCM(*fPayloadCurr);
if (evno == -1)
evno = EvNo(*fPayloadCurr);
else {
- AliError(MCMError(kPtrgCntMismatch,
- Form("%i <-> %i", evno, EvNo(*fPayloadCurr)) ));
+ MCMError(kPtrgCntMismatch, "%i <-> %i", evno, EvNo(*fPayloadCurr));
}
}
// ----- reading marked ADC channels -----
while (channelcount < channelcountExp &&
*(fPayloadCurr) != fgkDataEndmarker) {
- if (channelno < 21)
+ if (channelno < 20)
channelno++;
currentTimebin = 0;
int check = 0x3 & *fPayloadCurr;
if (channelno % 2 != 0) { // odd channel
if (check != 0x2 && channelno < 21) {
- AliError(MCMError(kAdcCheckInvalid,
- Form("Invalid check bits: %i for %2i. ADC word in odd channel: %i",
- check, adcwc+1, channelno) ));
+ MCMError(kAdcCheckInvalid,
+ "%i for %2i. ADC word in odd channel %i",
+ check, adcwc+1, channelno);
}
}
else { // even channel
if (check != 0x3 && channelno < 21) {
- AliError(MCMError(kAdcCheckInvalid,
- Form("Invalid check bits: %i for %2i. ADC word in even channel: %i",
- check, adcwc+1, channelno) ));
+ MCMError(kAdcCheckInvalid,
+ "%i for %2i. ADC word in even channel %i",
+ check, adcwc+1, channelno);
}
}
}
if (adcwc != timebins / 3)
- AliError(MCMError(kAdcDataAbort));
+ MCMError(kAdcDataAbort);
// adding index
if (padcol > 0 && padcol < 144) {
}
if (channelcount != channelcountExp)
- AliError(MCMError(kAdcChannelsMiss));
+ MCMError(kAdcChannelsMiss);
mcmcount++;
// continue with next MCM
}
// check for missing MCMs (if header suppression is inactive)
if (mcmcount != mcmcountExp) {
- AliError(LinkError(kMissMcmHeaders,
- Form("%i not as expected: %i", mcmcount, mcmcountExp) ));
+ LinkError(kMissMcmHeaders,
+ "%i not as expected: %i", mcmcount, mcmcountExp);
}
return (fPayloadCurr - start);
}
+Int_t AliTRDrawStream::SeekNextLink()
+{
+ UInt_t *start = fPayloadCurr;
+
+ // read until data endmarkers
+ while (fPayloadCurr - fPayloadStart < fPayloadSize &&
+ *fPayloadCurr != fgkDataEndmarker)
+ fPayloadCurr++;
+
+ // read all data endmarkers
+ while (fPayloadCurr - fPayloadStart < fPayloadSize &&
+ *fPayloadCurr == fgkDataEndmarker)
+ fPayloadCurr++;
+
+ return (fPayloadCurr - start);
+}
+
Bool_t AliTRDrawStream::ConnectTracklets(TTree *trklTree)
{
fTrackletTree = trklTree;
if (!fTrackletTree)
return kTRUE;
- TString trackletBranch("trkl");
-
- if (!fTrackletTree->GetBranch(trackletBranch.Data())) {
- TTree *t = new TTree("test", "test");
- // t->SetDirectory(0x0);
- t->Branch("branch", &fCurrSm);
- fTrackletTree->AddFriend(t, "friend");
+ if (!fTrackletTree->GetBranch("hc"))
fTrackletTree->Branch("hc", &fCurrHC, "hc/I");
- fTrackletTree->Branch("trkl", &fTrackletArray);
- }
- else {
+ else
fTrackletTree->SetBranchAddress("hc", &fCurrHC);
+
+ if (!fTrackletTree->GetBranch("trkl"))
+ fTrackletTree->Branch("trkl", &fTrackletArray);
+ else
fTrackletTree->SetBranchAddress("trkl", &fTrackletArray);
- }
+
return kTRUE;
}
-TString AliTRDrawStream::EquipmentError(ErrorCode_t err, TString msg)
+void AliTRDrawStream::EquipmentError(ErrorCode_t err, const char *const msg, ...)
{
// register error according to error code on equipment level
// and return the corresponding error message
fLastError.fRob = -1;
fLastError.fMcm = -1;
fLastError.fError = err;
- fErrors->Fill();
-
- return (Form("Event %6i: Eq. %2d - %s : ",
- fRawReader->GetEventIndex(), fCurrEquipmentId, fgErrorMessages[err]) + msg);
+ (this->*fStoreError)();
+
+ va_list ap;
+ if (fgErrorDebugLevel[err] > 10)
+ AliDebug(fgErrorDebugLevel[err],
+ Form("Event %6i: Eq. %2d - %s : %s",
+ fRawReader->GetEventIndex(), fCurrEquipmentId, fgErrorMessages[err],
+ (va_start(ap, msg), vsprintf(fErrorBuffer, msg, ap), va_end(ap), fErrorBuffer) ));
+ else
+ AliError(Form("Event %6i: Eq. %2d - %s : %s",
+ fRawReader->GetEventIndex(), fCurrEquipmentId, fgErrorMessages[err],
+ (va_start(ap, msg), vsprintf(fErrorBuffer, msg, ap), va_end(ap), fErrorBuffer) ));
+ fErrorFlags |= fgErrorBehav[err];
}
-TString AliTRDrawStream::StackError(ErrorCode_t err, TString msg)
+void AliTRDrawStream::StackError(ErrorCode_t err, const char *const msg, ...)
{
// register error according to error code on stack level
// and return the corresponding error message
fLastError.fRob = -1;
fLastError.fMcm = -1;
fLastError.fError = err;
- fErrors->Fill();
-
- return (Form("Event %6i: Eq. %2d S %i - %s : ",
- fRawReader->GetEventIndex(), fCurrEquipmentId, fCurrSlot, fgErrorMessages[err]) + msg);
+ (this->*fStoreError)();
+
+ va_list ap;
+ if (fgErrorDebugLevel[err] > 0)
+ AliDebug(fgErrorDebugLevel[err],
+ Form("Event %6i: Eq. %2d S %i - %s : %s",
+ fRawReader->GetEventIndex(), fCurrEquipmentId, fCurrSlot, fgErrorMessages[err],
+ (va_start(ap, msg), vsprintf(fErrorBuffer, msg, ap), va_end(ap), fErrorBuffer) ));
+ else
+ AliError(Form("Event %6i: Eq. %2d S %i - %s : %s",
+ fRawReader->GetEventIndex(), fCurrEquipmentId, fCurrSlot, fgErrorMessages[err],
+ (va_start(ap, msg), vsprintf(fErrorBuffer, msg, ap), va_end(ap), fErrorBuffer) ));
+ fErrorFlags |= fgErrorBehav[err];
}
-TString AliTRDrawStream::LinkError(ErrorCode_t err, TString msg)
+void AliTRDrawStream::LinkError(ErrorCode_t err, const char *const msg, ...)
{
// register error according to error code on link level
// and return the corresponding error message
fLastError.fRob = -1;
fLastError.fMcm = -1;
fLastError.fError = err;
- fErrors->Fill();
-
- return (Form("Event %6i: Eq. %2d S %i l %2i - %s : ",
- fRawReader->GetEventIndex(), fCurrEquipmentId, fCurrSlot, fCurrLink, fgErrorMessages[err]) + msg);
+ (this->*fStoreError)();
+
+ va_list ap;
+ if (fgErrorDebugLevel[err] > 0)
+ AliDebug(fgErrorDebugLevel[err],
+ Form("Event %6i: Eq. %2d S %i l %2i - %s : %s",
+ fRawReader->GetEventIndex(), fCurrEquipmentId, fCurrSlot, fCurrLink, fgErrorMessages[err],
+ (va_start(ap, msg), vsprintf(fErrorBuffer, msg, ap), va_end(ap), fErrorBuffer) ));
+ else
+ AliError(Form("Event %6i: Eq. %2d S %i l %2i - %s : %s",
+ fRawReader->GetEventIndex(), fCurrEquipmentId, fCurrSlot, fCurrLink, fgErrorMessages[err],
+ (va_start(ap, msg), vsprintf(fErrorBuffer, msg, ap), va_end(ap), fErrorBuffer) ));
+ fErrorFlags |= fgErrorBehav[err];
}
-TString AliTRDrawStream::ROBError(ErrorCode_t err, TString msg)
+void AliTRDrawStream::ROBError(ErrorCode_t err, const char *const msg, ...)
{
// register error according to error code on ROB level
// and return the corresponding error message
fLastError.fRob = fCurrRobPos;
fLastError.fMcm = -1;
fLastError.fError = err;
- fErrors->Fill();
-
- return (Form("Event %6i: Eq. %2d S %i l %2i ROB %i - %s : ",
- fRawReader->GetEventIndex(), fCurrEquipmentId, fCurrSlot, fCurrLink, fCurrRobPos, fgErrorMessages[err]) + msg);
+ (this->*fStoreError)();
+
+ va_list ap;
+ if (fgErrorDebugLevel[err] > 0)
+ AliDebug(fgErrorDebugLevel[err],
+ Form("Event %6i: Eq. %2d S %i l %2i ROB %i - %s : %s",
+ fRawReader->GetEventIndex(), fCurrEquipmentId, fCurrSlot, fCurrLink, fCurrRobPos, fgErrorMessages[err],
+ (va_start(ap, msg), vsprintf(fErrorBuffer, msg, ap), va_end(ap), fErrorBuffer) ));
+ else
+ AliError(Form("Event %6i: Eq. %2d S %i l %2i ROB %i - %s : %s",
+ fRawReader->GetEventIndex(), fCurrEquipmentId, fCurrSlot, fCurrLink, fCurrRobPos, fgErrorMessages[err],
+ (va_start(ap, msg), vsprintf(fErrorBuffer, msg, ap), va_end(ap), fErrorBuffer) ));
+ fErrorFlags |= fgErrorBehav[err];
}
-TString AliTRDrawStream::MCMError(ErrorCode_t err, TString msg)
+void AliTRDrawStream::MCMError(ErrorCode_t err, const char *const msg, ...)
{
// register error according to error code on MCM level
// and return the corresponding error message
fLastError.fRob = fCurrRobPos;
fLastError.fMcm = fCurrMcmPos;
fLastError.fError = err;
- fErrors->Fill();
-
- return (Form("Event %6i: Eq. %2d S %i l %2i ROB %i MCM %2i - %s : ",
- fRawReader->GetEventIndex(), fCurrEquipmentId, fCurrSlot, fCurrLink, fCurrRobPos, fCurrMcmPos, fgErrorMessages[err]) + msg);
+ (this->*fStoreError)();
+
+ va_list ap;
+ if (fgErrorDebugLevel[err] > 0)
+ AliDebug(fgErrorDebugLevel[err],
+ Form("Event %6i: Eq. %2d S %i l %2i ROB %i MCM %2i - %s : %s",
+ fRawReader->GetEventIndex(), fCurrEquipmentId, fCurrSlot, fCurrLink, fCurrRobPos, fCurrMcmPos, fgErrorMessages[err],
+ (va_start(ap, msg), vsprintf(fErrorBuffer, msg, ap), va_end(ap), fErrorBuffer) ));
+ else
+ AliError(Form("Event %6i: Eq. %2d S %i l %2i ROB %i MCM %2i - %s : %s",
+ fRawReader->GetEventIndex(), fCurrEquipmentId, fCurrSlot, fCurrLink, fCurrRobPos, fCurrMcmPos, fgErrorMessages[err],
+ (va_start(ap, msg), vsprintf(fErrorBuffer, msg, ap), va_end(ap), fErrorBuffer) ));
+ fErrorFlags |= fgErrorBehav[err];
}
const char* AliTRDrawStream::GetErrorMessage(ErrorCode_t errCode)
else
return "";
}
+
+void AliTRDrawStream::AliTRDrawStats::ClearStats()
+{
+ // clear statistics (includes clearing sector-wise statistics)
+
+ fBytesRead = 0;
+ for (Int_t iSector = 0; iSector < 18; iSector++) {
+ fStatsSector[iSector].ClearStats();
+ }
+
+}
+
+void AliTRDrawStream::AliTRDrawStats::AliTRDrawStatsSector::ClearStats()
+{
+ // clear statistics (includes clearing HC-wise statistics)
+
+ fBytes = 0;
+ fBytesRead = 0;
+ fNTracklets = 0;
+ fNMCMs = 0;
+ fNChannels = 0;
+
+ for (Int_t iHC = 0; iHC < 60; iHC++) {
+ fStatsHC[iHC].ClearStats();
+ }
+}
+
+void AliTRDrawStream::AliTRDrawStats::AliTRDrawStatsSector::AliTRDrawStatsHC::ClearStats()
+{
+ // clear statistics
+
+ fBytes = 0;
+ fBytesRead = 0;
+ fNTracklets = 0;
+ fNMCMs = 0;
+ fNChannels = 0;
+}
+
+void AliTRDrawStream::SetDumpMCM(Int_t det, Int_t rob, Int_t mcm, Bool_t dump)
+{
+ // mark MCM for dumping of raw data
+
+ if (dump) {
+ fDumpMCM[fNDumpMCMs++] = (det << 7) | (rob << 4) | mcm;
+ }
+ else {
+ Int_t iMCM;
+ for (iMCM = 0; iMCM < fNDumpMCMs; iMCM++) {
+ if (fDumpMCM[iMCM] == ((det << 7) | (rob << 4) | mcm)) {
+ fNDumpMCMs--;
+ break;
+ }
+ }
+ for ( ; iMCM < fNDumpMCMs; iMCM++) {
+ fDumpMCM[iMCM] = fDumpMCM[iMCM+1];
+ }
+ }
+}
+
+Bool_t AliTRDrawStream::DumpingMCM(Int_t det, Int_t rob, Int_t mcm)
+{
+ // check if MCM data should be dumped
+
+ for (Int_t iMCM = 0; iMCM < fNDumpMCMs; iMCM++) {
+ if (fDumpMCM[iMCM] == ((det << 7) | (rob << 4) | mcm)) {
+ return kTRUE;
+ }
+ }
+ return kFALSE;
+}
+
+void AliTRDrawStream::DumpRaw(TString title, UInt_t *start, Int_t length)
+{
+ // dump raw data
+
+ title += "\n";
+ Int_t pos = 0;
+ for ( ; pos+3 < length; pos += 4) {
+ title += Form("0x%08x 0x%08x 0x%08x 0x%08x\n",
+ start[pos+0], start[pos+1], start[pos+2], start[pos+3]);
+ }
+ for ( ; pos < length; pos++) {
+ title += Form("0x%08x ", start[pos]);
+ }
+ AliInfo(title);
+}
+
+AliTRDrawStream::AliTRDrawStreamError::AliTRDrawStreamError(Int_t error, Int_t sector, Int_t stack, Int_t link, Int_t rob, Int_t mcm) :
+ fError(error),
+ fSector(sector),
+ fStack(stack),
+ fLink(link),
+ fRob(rob),
+ fMcm(mcm)
+{
+ // ctor
+
+}