//__________________________________________________________________________
AliITSRawStreamSPD::AliITSRawStreamSPD(AliRawReader* rawReader) :
AliITSRawStream(rawReader),
- fEventCounter(-1),fChipAddr(0),fHalfStaveNr(0),fCol(0),fRow(0),
+ fEventCounter(-1),fChipAddr(0),fHalfStaveNr(0),fCol(0),fRow(0),fCalHeadLen(0),
fData(0),fOffset(0),fHitCount(0),
fDataChar1(0),fDataChar2(0),fDataChar3(0),fDataChar4(0),
fFirstWord(kTRUE),fPrevEventId(0xffffffff),
}
for (UInt_t eq=0; eq<20; eq++) {
fActiveEq[eq]=kFALSE;
+ for (UInt_t hs=0; hs<6; hs++) {
+ fActiveHS[eq][hs]=kFALSE;
+ for (UInt_t chip=0; chip<10; chip++) {
+ fActiveChip[eq][hs][chip]=kFALSE;
+ fEventCounterFull[eq][hs][chip] = -1;
+ }
+ }
}
NewEvent();
}
//__________________________________________________________________________
AliITSRawStreamSPD::AliITSRawStreamSPD(const AliITSRawStreamSPD& rstream) :
AliITSRawStream(rstream.fRawReader),
- fEventCounter(-1),fChipAddr(0),fHalfStaveNr(0),fCol(0),fRow(0),
+ fEventCounter(-1),fChipAddr(0),fHalfStaveNr(0),fCol(0),fRow(0),fCalHeadLen(0),
fData(0),fOffset(0),fHitCount(0),
fDataChar1(0),fDataChar2(0),fDataChar3(0),fDataChar4(0),
fFirstWord(kTRUE),fPrevEventId(0xffffffff),
fEventCounter = -1;
fDDLID = -1;
fLastDDLID = -1;
+ for (UInt_t eq=0; eq<20; eq++) {
+ for (UInt_t hs=0; hs<6; hs++) {
+ for (UInt_t chip=0; chip<10; chip++) {
+ fFastOrSignal[eq][hs][chip] = kFALSE;
+ }
+ }
+ }
}
//__________________________________________________________________________
Int_t AliITSRawStreamSPD::ReadCalibHeader() {
fHeaderOrTrailerReadLast = kFALSE;
fFillOutOfSynch = kFALSE;
+ // check router error bits:
+ UInt_t statusBits = fRawReader->GetStatusBits();
+ if ((statusBits >> 5) & 1) { // linkrx/detector fatal error bit
+ TString errMess = "LinkRx Error Bit Set";
+ AliError(errMess.Data());
+ fRawReader->AddMajorErrorLog(kLinkRxDetectorFatalErr,errMess.Data());
+ if (fAdvancedErrorLog) fAdvLogger->ProcessError(kLinkRxDetectorFatalErr,ddlID,-1,-1,errMess.Data());
+ }
+ if ((statusBits >> 12) & 1) { // trigger sequence monitor error bit
+ TString errMess = "TSM Trigger Error Bit Set";
+ AliError(errMess.Data());
+ fRawReader->AddMajorErrorLog(kTSMtriggerErr,errMess.Data());
+ if (fAdvancedErrorLog) fAdvLogger->ProcessError(kTSMtriggerErr,ddlID,-1,-1,errMess.Data());
+ }
+ if (fRawReader->TestBlockAttribute(7)) { // bunch crossing difference error bit
+ TString errMess = "BC Difference Error Bit Set";
+ AliError(errMess.Data());
+ fRawReader->AddMajorErrorLog(kBCdiffErr,errMess.Data());
+ if (fAdvancedErrorLog) fAdvLogger->ProcessError(kBCdiffErr,ddlID,-1,-1,errMess.Data());
+ }
+
// set eq active and the participating half-staves (for access from outside this class),
- // set what number of chip headers/trailers to expect
+ // set what number of chip headers/trailers to expect (for the moment not used)
fActiveEq[ddlID]=kTRUE;
fExpectedHeaderTrailerCount = 0;
for (UInt_t hs=0; hs<6; hs++) {
if (fRawReader->TestBlockAttribute(6)) { // is the calib header present?
if (ReadNextInt()) {
// length of cal header:
- UInt_t calLen = fDataChar1+(fDataChar2<<8)+(fDataChar3<<16)+(fDataChar4<<24);
- if (calLen>kCalHeadLenMax) {
- TString errMess = Form("Header length %d > max = %d",calLen,kCalHeadLenMax);
+ fCalHeadLen = fDataChar1+(fDataChar2<<8)+(fDataChar3<<16)+(fDataChar4<<24);
+ if (fCalHeadLen>kCalHeadLenMax) {
+ TString errMess = Form("Header length %d > max = %d",fCalHeadLen,kCalHeadLenMax);
AliError(errMess.Data());
fRawReader->AddMajorErrorLog(kCalHeaderLengthErr,errMess.Data());
if (fAdvancedErrorLog) fAdvLogger->ProcessError(kCalHeaderLengthErr,ddlID,-1,-1,errMess.Data());
return -1;
}
else {
- for (UInt_t iword=0; iword<calLen; iword++) {
+ for (UInt_t iword=0; iword<fCalHeadLen; iword++) {
if (ReadNextInt()) {
fCalHeadWord[iword] = fDataChar1+(fDataChar2<<8)+(fDataChar3<<16)+(fDataChar4<<24);
}
return -1;
}
}
- return calLen;
+ return fCalHeadLen;
}
}
}
if (fAdvancedErrorLog) fAdvLogger->ProcessError(kHSNumberErr,fDDLID,fEqPLBytesRead,fEqPLChipHeadersRead,errMess.Data());
fHalfStaveNr=0;
}
+ fActiveChip[fDDLID][fHalfStaveNr][fChipAddr]=kTRUE;
+ fEventCounterFull[fDDLID][fHalfStaveNr][fChipAddr] = eventCounter;
// translate ("online") ddl, hs, chip nr to ("offline") module id :
fModuleID = GetOfflineModuleFromOnline(fDDLID,fHalfStaveNr,fChipAddr);
- }
+ }
+
else if ((fData & 0xC000) == 0x0000) { // trailer
if ( (fEqPLBytesRead+fFillOutOfSynch*2)%4 != 0 ) {
TString errMess = "Fill word is missing";
}
fHeaderOrTrailerReadLast = kFALSE;
fEqPLChipTrailersRead++;
- UShort_t hitCount = fData & 0x1FFF;
+ UShort_t hitCount = fData & 0x0FFF;
if (hitCount != fHitCount){
TString errMess = Form("Number of hits %d, while %d expected",fHitCount,hitCount);
AliError(errMess.Data());
fRawReader->AddMajorErrorLog(kNumberHitsErr,errMess.Data());
if (fAdvancedErrorLog) fAdvLogger->ProcessError(kNumberHitsErr,fDDLID,fEqPLBytesRead,fEqPLChipHeadersRead,errMess.Data());
}
+ Bool_t errorBit = fData & 0x1000;
+ if (errorBit) {
+ TString errMess = Form("Trailer error bit set for chip %d,%d,%d",fDDLID,fHalfStaveNr,fChipAddr);
+ AliError(errMess.Data());
+ fRawReader->AddMajorErrorLog(kTrailerErrorBitErr,errMess.Data());
+ if (fAdvancedErrorLog) fAdvLogger->ProcessError(kTrailerErrorBitErr,fDDLID,fEqPLBytesRead,fEqPLChipHeadersRead,errMess.Data());
+ }
+ Bool_t fastorBit = fData & 0x2000;
+ fFastOrSignal[fDDLID][fHalfStaveNr][fChipAddr] = fastorBit;
}
+
else if ((fData & 0xC000) == 0x8000) { // pixel hit
if (!fHeaderOrTrailerReadLast) {
TString errMess = "Chip header missing";
fCoord2 = GetOfflineRowFromOnline(fDDLID,fHalfStaveNr,fChipAddr,fRow);
return kTRUE;
- }
+ }
+
else { // fill word
if ((fData & 0xC000) != 0xC000) {
TString errMess = "Wrong fill word!";
fEqPLChipHeadersRead,fExpectedHeaderTrailerCount,ddlID);
AliError(errMess.Data());
fRawReader->AddMajorErrorLog(kHeaderCountErr,errMess.Data());
- if (fAdvancedErrorLog) fAdvLogger->ProcessError(kHeaderCountErr,ddlID,-1,-1,errMess.Data());
+ if (fAdvancedErrorLog) fAdvLogger->ProcessError(kHeaderCountErr,ddlID,fEqPLBytesRead,fEqPLChipHeadersRead,errMess.Data());
}
if (fEqPLChipTrailersRead != fExpectedHeaderTrailerCount) {
TString errMess = Form("Chip trailer count inconsistent %d != %d (expected) for ddl %d",
fEqPLChipTrailersRead,fExpectedHeaderTrailerCount,ddlID);
AliError(errMess.Data());
fRawReader->AddMajorErrorLog(kHeaderCountErr,errMess.Data());
- if (fAdvancedErrorLog) fAdvLogger->ProcessError(kTrailerCountErr,ddlID,-1,-1,errMess.Data());
+ if (fAdvancedErrorLog) fAdvLogger->ProcessError(kHeaderCountErr,ddlID,fEqPLBytesRead,fEqPLChipHeadersRead,errMess.Data());
}
}
//__________________________________________________________________________
else if (errorCode==kCalHeaderLengthErr) return "Calib Header Length Error";
else if (errorCode==kAdvEventCounterErr) return "Event Counter Error (Adv)";
else if (errorCode==kAdvEventCounterOrderErr) return "Event Counter Jump Error (Adv)";
+ else if (errorCode==kTrailerErrorBitErr) return "Trailer Error Bit Set";
+ else if (errorCode==kLinkRxDetectorFatalErr) return "LinkRx/Detector Fatal Error Bit Set";
+ else if (errorCode==kTSMtriggerErr) return "TSM Trigger Error Bit Set";
+ else if (errorCode==kBCdiffErr) return "BC Difference Error Bit Set";
else return "";
}
//__________________________________________________________________________
+Bool_t AliITSRawStreamSPD::GetFastOrSignal(UInt_t eq, UInt_t hs, UInt_t chip) {
+ // returns if there was a fastor signal from this chip
+ if (eq>=20 || hs>=6 || chip>=10) {
+ TString errMess = Form("eq,hs,chip = %d,%d,%d out of bounds. Return kFALSE.",eq,hs,chip);
+ AliError(errMess.Data());
+ return kFALSE;
+ }
+ return fFastOrSignal[eq][hs][chip];
+}
+//__________________________________________________________________________
+Bool_t AliITSRawStreamSPD::IsActiveEq(UInt_t eq) const {
+ // returns if the eq is active (seen in data)
+ if (eq>=20) {
+ TString errMess = Form("eq = %d out of bounds. Return kFALSE.",eq);
+ AliError(errMess.Data());
+ return kFALSE;
+ }
+ return fActiveEq[eq];
+}
+//__________________________________________________________________________
+Bool_t AliITSRawStreamSPD::IsActiveHS(UInt_t eq, UInt_t hs) const {
+ // returns if the hs is active (info from block attr)
+ if (eq>=20 || hs>=6) {
+ TString errMess = Form("eq,hs = %d,%d out of bounds. Return kFALSE.",eq,hs);
+ AliError(errMess.Data());
+ return kFALSE;
+ }
+ return fActiveHS[eq][hs];
+}
+//__________________________________________________________________________
+Bool_t AliITSRawStreamSPD::IsActiveChip(UInt_t eq, UInt_t hs, UInt_t chip) const {
+ // returns if the chip is active (seen in data)
+ if (eq>=20 || hs>=6 || chip>=10) {
+ TString errMess = Form("eq,hs,chip = %d,%d,%d out of bounds. Return kFALSE.",eq,hs,chip);
+ AliError(errMess.Data());
+ return kFALSE;
+ }
+ return fActiveChip[eq][hs][chip];
+}
+//__________________________________________________________________________
Bool_t AliITSRawStreamSPD::GetHalfStavePresent(UInt_t hs) {
// Reads the half stave present status from the block attributes
// This is not really needed anymore (kept for now in case it is still used somewhere).
}
}
//__________________________________________________________________________
+Bool_t AliITSRawStreamSPD::IsEventCounterFullConsistent() const {
+ // checks if the event counter values are consistent within the event
+ Short_t reference = -1;
+ for (UInt_t eq=0; eq<20; eq++) {
+ if (IsActiveEq(eq)) {
+ for (UInt_t hs=0; hs<6; hs++) {
+ if (IsActiveHS(eq,hs)) {
+ for (UInt_t chip=0; chip<10; chip++) {
+ if (fEventCounterFull[eq][hs][chip]!=-1) {
+ if (reference==-1) reference = fEventCounterFull[eq][hs][chip];
+ if (fEventCounterFull[eq][hs][chip] != reference) return kFALSE;
+ }
+ }
+ }
+ }
+ }
+ }
+ return kTRUE;
+}
+//__________________________________________________________________________
+Short_t AliITSRawStreamSPD::GetEventCounterFullEq(UInt_t eq) const {
+ // if the eq is active; returns the event counter value
+ if (eq>=20) {
+ TString errMess = Form("eq (%d) out of bounds",eq);
+ AliError(errMess.Data());
+ return -1;
+ }
+ if (IsActiveEq(eq)) {
+ for (UInt_t hs=0; hs<6; hs++) {
+ if (IsActiveHS(eq,hs)) {
+ for (UInt_t chip=0; chip<10; chip++) {
+ if (fEventCounterFull[eq][hs][chip]!=-1) {
+ return fEventCounterFull[eq][hs][chip];
+ }
+ }
+ }
+ }
+ }
+ return -1;
+}
+//__________________________________________________________________________
+Short_t AliITSRawStreamSPD::GetEventCounterFullHS(UInt_t eq, UInt_t hs) const {
+ // if the eq,hs is active; returns the event counter value
+ if (eq>=20 || hs>=6) {
+ TString errMess = Form("eq,hs (%d,%d) out of bounds",eq,hs);
+ AliError(errMess.Data());
+ return -1;
+ }
+ if (IsActiveEq(eq)) {
+ if (IsActiveHS(eq,hs)) {
+ for (UInt_t chip=0; chip<10; chip++) {
+ if (fEventCounterFull[eq][hs][chip]!=-1) {
+ return fEventCounterFull[eq][hs][chip];
+ }
+ }
+ }
+ }
+ return -1;
+}
+//__________________________________________________________________________
+Short_t AliITSRawStreamSPD::GetEventCounterFullChip(UInt_t eq, UInt_t hs, UInt_t chip) const {
+ // if the eq,hs,chip is active; returns the event counter value
+ if (eq>=20 || hs>=6 || chip>=10) {
+ TString errMess = Form("eq,hs,chip (%d,%d,%d) out of bounds",eq,hs,chip);
+ AliError(errMess.Data());
+ return -1;
+ }
+ if (IsActiveEq(eq)) {
+ if (IsActiveHS(eq,hs)) {
+ if (IsActiveChip(eq,hs,chip)) {
+ return fEventCounterFull[eq][hs][chip];
+ }
+ }
+ }
+ return -1;
+}
+//__________________________________________________________________________
+Int_t AliITSRawStreamSPD::GetHword(UInt_t index) {
+ if (index<kCalHeadLenMax) return fCalHeadWord[index];
+ else return 0;
+}
Bool_t AliITSRawStreamSPD::GetHhalfStaveScanned(UInt_t hs) const {
if (hs<6) return (Bool_t)((fCalHeadWord[0]>>(6+hs)) & (0x00000001));
else return kFALSE;
if (chip<10) return ((( fCalHeadWord[7]>>(16+chip)) & 0x00000001) == 1);
else return kFALSE;
}
+UInt_t AliITSRawStreamSPD::GetFOHnumDacs() const {
+ return (fCalHeadLen-37)/2;
+}
+UInt_t AliITSRawStreamSPD::GetFOHdacIndex(UInt_t index) const {
+ if (index>=GetFOHnumDacs()) {
+ TString errMess = Form("Only %d DACs in this run, returning 0",GetFOHnumDacs());
+ AliError(errMess.Data());
+ return 0;
+ }
+ return fCalHeadWord[7+index*2];
+}
+UInt_t AliITSRawStreamSPD::GetFOHdacValue(UInt_t index) const {
+ if (index>=GetFOHnumDacs()) {
+ TString errMess = Form("Only %d DACs in this run, returning 0",GetFOHnumDacs());
+ AliError(errMess.Data());
+ return 0;
+ }
+ return fCalHeadWord[7+1+index*2];
+}
+UInt_t AliITSRawStreamSPD::GetFOHchipCount(UInt_t hs, UInt_t chip) const {
+ if (hs<6 && chip<10) {
+ if (chip%2==0) {
+ return ((fCalHeadWord[7 + GetFOHnumDacs()*2 + (hs*10 + chip)/2] >> 16) & 0x0000ffff);
+ }
+ else {
+ return (fCalHeadWord[7 + GetFOHnumDacs()*2 + (hs*10 + chip)/2] & 0x0000ffff);
+ }
+ }
+ else return 0;
+}
//__________________________________________________________________________
Int_t AliITSRawStreamSPD::GetModuleNumber(UInt_t iDDL, UInt_t iModule) {
if (iDDL<20 && iModule<12) return fgkDDLModuleMap[iDDL][iModule];
else return 240;
}
//__________________________________________________________________________
+UInt_t AliITSRawStreamSPD::GetOfflineChipKeyFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip) {
+ // online->offline (chip key: 0-1199)
+ if (eqId<20 && hs<6 && chip<10) {
+ UInt_t module = GetOfflineModuleFromOnline(eqId,hs,chip);
+ UInt_t chipInModule = ( chip>4 ? chip-5 : chip );
+ if(eqId>9) chipInModule = 4 - chipInModule; // side C only
+ return (module*5 + chipInModule);
+ } else return 1200;
+}
+//__________________________________________________________________________
UInt_t AliITSRawStreamSPD::GetOfflineColFromOnline(UInt_t eqId, UInt_t hs, UInt_t chip, UInt_t col) {
// online->offline (col)
if (eqId>=20 || hs>=6 || chip>=10 || col>=32) return 160; // error
return 255-row;
}
-
-
-