1 #/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // This class provides access to TRD digits in raw data. //
22 // It loops over all TRD digits in the raw data given by the AliRawReader. //
23 // The Next method goes to the next digit. If there are no digits left //
24 // it returns kFALSE. //
25 // Several getters provide information about the current digit. //
27 // Author: M. Ploskon (ploskon@ikf.uni-frankfurt.de) //
29 ///////////////////////////////////////////////////////////////////////////////
33 #include "TTreeStream.h"
35 #include "AliTRDrawStreamTB.h"
36 #include "AliTRDgeometry.h"
37 #include "AliTRDfeeParam.h"
38 #include "AliTRDdigitsManager.h"
39 #include "AliTRDdataArrayS.h"
40 #include "AliTRDdataArrayI.h"
41 #include "AliTRDdataArrayDigits.h"
42 #include "AliTRDSignalIndex.h"
43 // #include "AliTRDReconstructor.h"
44 #include "AliTRDrecoParam.h"
45 #include "AliTRDcalibDB.h"
46 #include "Cal/AliTRDCalPadStatus.h"
49 #include "AliRawReader.h"
51 #define END_OF_TRACKLET_MARKEROLD 0xaaaaaaaa
52 #define END_OF_TRACKLET_MARKERNEW 0x10001000
53 #define ENDOFRAWDATAMARKER 0x00000000
55 #define WORD_SIZE sizeof(UInt_t) // size of a word in bytes
56 #define EXTRA_LEAD_WORDS 24
59 #define IS_BIT_SET(w,b) ( ((w) >> (b)) & 0x1 ) // 1 if bit b is set in word w
60 #define GET_VALUE_AT(w,m,s) (( (w) >> (s)) & (m) ) // get value of word w rshifted by s and mask with m
62 // SM index word masks:
63 #define SM_HEADER_SIZE(w) GET_VALUE_AT(w,0xffff,16)
64 #define TRACKLETS_ENABLED(w) IS_BIT_SET(w,5)
65 #define STACK_MASK(w) ((w) & 0x1f)
68 #define STACK_HEADER_SIZE(w) GET_VALUE_AT(w,0xffff,16)
69 #define STACK_LINK_WORD(w) ((w) & 0xfff)
72 //#define HC_HEADER_MASK_ERR(w) ( ((w) & (0x80000003)) == (0x80000001) ? 0 : 1) // 0 if OK!!!
73 #define HC_HEADER_MASK_ERR(w) ( ((w) & (0x3)) == (0x1) ? 0 : 1) // 0 if OK!!!
76 #define HC_SPECIAL_RAW_VERSION(w) IS_BIT_SET(w,31)
77 #define HC_MAJOR_RAW_VERSION(w) GET_VALUE_AT(w,0x7f,24)
78 #define HC_MAJOR_RAW_VERSION_OPT(w) GET_VALUE_AT(w,0x7,24)
79 #define HC_MINOR_RAW_VERSION(w) GET_VALUE_AT(w,0x7f,17)
80 #define HC_EXTRA_WORDS(w) GET_VALUE_AT(w,0x7,14)
81 #define HC_DCS_BOARD(w) GET_VALUE_AT(w,0xfff<<20,20)
82 #define HC_SM_NUMBER(w) GET_VALUE_AT(w,0x1f,9)
83 #define HC_LAYER_NUMBER(w) GET_VALUE_AT(w,0x7,6)
84 #define HC_STACK_NUMBER(w) GET_VALUE_AT(w,0x7,3)
85 #define HC_SIDE_NUMBER(w) IS_BIT_SET(w,2)
88 #define HC_NTIMEBINS(w) GET_VALUE_AT(w,0x3f,26)
89 #define HC_BUNCH_CROSS_COUNTER(w) GET_VALUE_AT(w,0xffff,10)
90 #define HC_PRETRIGGER_COUNTER(w) GET_VALUE_AT(w,0xf,6)
91 #define HC_PRETRIGGER_PHASE(w) GET_VALUE_AT(w,0xf,6)
93 //--------------------------------------------------------
95 // MCM word and ADC mask
96 #define MCM_HEADER_MASK_ERR(w) ( ((w) & (0xf)) == (0xc) ? 0 : 1) // 0 if OK!!!
97 #define MCM_ADCMASK_MASK_ERR(w) ( ((w) & (0xf)) == (0xc) ? 0 : 1) // 0 if OK!!!
98 #define MCM_MCM_NUMBER(w) GET_VALUE_AT(w,0x0f,24)
99 #define MCM_ROB_NUMBER(w) GET_VALUE_AT(w,0x7,28)
100 #define MCM_EVENT_COUNTER(w) GET_VALUE_AT(w,0x00fffff,4)
101 #define MCM_ADCMASK_VAL(w) GET_VALUE_AT(w,0x1fffff,4)
102 #define MCM_ADCMASK_NADC(w) GET_VALUE_AT(w,0x1f,25)
104 #define MCM_DUMMY_ADCMASK_VAL 0x015fffffc // updated
105 //#define MCM_DUMMY_ADCMASK_VAL 0x001fffffc
106 #define ADCDATA_VAL1 0x2 // updated
107 #define ADCDATA_VAL2 0x3 // updated
109 //--------------------------------------------------------
111 #define MAX_TRACKLETS_PERHC 256 // max number of tracklets per HC - large number for now
113 //--------------------------------------------------------
114 #define ADC_WORD_MASK(w) ((w) & 0x3)
115 //--------------------------------------------------------
118 ClassImp(AliTRDrawStreamTB)
120 Bool_t AliTRDrawStreamTB::fgExtraSkip = kFALSE;
121 Bool_t AliTRDrawStreamTB::fgSkipCDH = kFALSE;
122 Bool_t AliTRDrawStreamTB::fgWarnError = kTRUE;
123 Bool_t AliTRDrawStreamTB::fgCleanDataOnly = kTRUE;
124 Bool_t AliTRDrawStreamTB::fgDebugFlag = kTRUE;
125 Bool_t AliTRDrawStreamTB::fgDebugStreamFlag = kFALSE;
126 Bool_t AliTRDrawStreamTB::fgStackNumberChecker = kTRUE;
127 Bool_t AliTRDrawStreamTB::fgStackLinkNumberChecker = kTRUE;
128 Bool_t AliTRDrawStreamTB::fgSkipData = kTRUE;
129 TTreeSRedirector *AliTRDrawStreamTB::fgDebugStreamer = 0;
130 UInt_t AliTRDrawStreamTB::fgStreamEventCounter = 0;
131 UInt_t AliTRDrawStreamTB::fgFirstEquipmentID = 0;
132 UInt_t AliTRDrawStreamTB::fgDumpHead = 0;
133 Int_t AliTRDrawStreamTB::fgCommonAdditive = 0;
134 Int_t AliTRDrawStreamTB::fgEmptySignals[] =
136 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
137 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
140 AliTRDrawStreamTB::AliTRDrawStreamTB()
141 : AliTRDrawStreamBase()
154 , fStackLinkNumber(-1)
157 , fLinkTrackletCounter(-1)
158 , fEndOfTrackletCount(-1)
163 , fLastEventCounter(0)
164 , fSharedPadsOn(kFALSE)
169 , fDebugStreamOwned(kFALSE)
172 // default constructor
175 if (Init() == kFALSE)
177 AliWarning("Unable to Init.");
181 //--------------------------------------------------------
182 AliTRDrawStreamTB::AliTRDrawStreamTB(AliRawReader *rawReader)
183 : AliTRDrawStreamBase(rawReader)
196 , fStackLinkNumber(-1)
199 , fLinkTrackletCounter(-1)
200 , fEndOfTrackletCount(-1)
205 , fLastEventCounter(0)
206 , fSharedPadsOn(kFALSE)
209 , fRawReader(rawReader)
211 , fDebugStreamOwned(kFALSE)
214 // default constructor
218 if (Init() == kFALSE)
220 AliWarning("Unable to Init. Try setting up the reader with SetReader or buffer with Init(void *, UInt_t )");
225 AliWarning("Unable to setup reader. Use SetReader(AliRawReader*).");
229 //------------------------------------------------------------
231 AliTRDrawStreamTB::AliTRDrawStreamTB(const AliTRDrawStreamTB& /*st*/)
232 : AliTRDrawStreamBase()
245 , fStackLinkNumber(-1)
248 , fLinkTrackletCounter(-1)
249 , fEndOfTrackletCount(-1)
254 , fLastEventCounter(0)
255 , fSharedPadsOn(kFALSE)
260 , fDebugStreamOwned(kFALSE)
265 AliError("Not implemeneted.");
268 //------------------------------------------------------------
269 Bool_t AliTRDrawStreamTB::SetRawVersion(Int_t fraw)
272 // function provided for backward compatibility
274 AliWarning("Raw data version is read from raw data stream! No point of setting it in here.");
275 fraw = 0; // avoid warnings
279 //------------------------------------------------------------
280 AliTRDrawStreamTB::~AliTRDrawStreamTB()
287 if (fDebugStreamOwned == kTRUE)
291 delete fgDebugStreamer;
297 //------------------------------------------------------------
300 AliTRDrawStreamTB::operator=(const AliTRDrawStreamTB &)
303 // we are not using this functionality
305 AliFatal("May not use.");
309 //------------------------------------------------------------
312 AliTRDrawStreamTB::EnableDebug(TTreeSRedirector *debugStream)
315 // replace the current debug streamer or create a new one if owned
318 if (debugStream == 0)
320 if (fDebugStreamOwned == kTRUE)
323 delete fgDebugStreamer;
326 fDebugStreamOwned = kTRUE;
327 fgDebugStreamer = new TTreeSRedirector("TRDrawDataDebug.root");
328 fgStreamEventCounter = 0;
333 if (fDebugStreamOwned == kTRUE)
336 delete fgDebugStreamer;
339 fgDebugStreamer = debugStream;
340 fDebugStreamOwned = kFALSE;
344 //___________________________________________________________
346 AliTRDrawStreamTB::SwapOnEndian()
349 // Check the endian and swap if needed
353 char* ptemp = (char*) &itemp;
357 if (fgDebugFlag) AliDebug(8, "Swapping.");
361 while (fpPos < fpEnd)
364 iutmp = (((*fpPos & 0x000000ffU) << 24) | ((*fpPos & 0x0000ff00U) << 8) |
365 ((*fpPos & 0x00ff0000U) >> 8) | ((*fpPos & 0xff000000U) >> 24));
366 // here we override the value in the buffer!
373 //------------------------------------------------------------
375 AliTRDrawStreamTB::DumpErrorCount()
378 // print the error statistics into the stdout
382 // AliInfo(Form("Error counts: HC0 %d HC1 %d MCM %d ADCmask %d ADC %d",
383 // fHC->fH0ErrorCounter, fHC->fH1ErrorCounter, fMCM->fErrorCounter, fMCM->fMaskErrorCounter, adc.fErrorCounter));
386 //------------------------------------------------------------
388 AliTRDrawStreamTB::DumpWords(UInt_t *px, UInt_t iw, UInt_t marker)
392 // note: can be made faster
395 TString tsreturn = Form("\n[ Dump Sequence at 0x%08x ] : ", px);
396 for (UInt_t i = 0; i < iw; i++)
398 if (px + iw >= fpEnd)
403 if (marker != 0 && marker == px[i])
404 tsreturn += Form(" *>0x%08x<* ", px[i]);
406 tsreturn += Form("0x%08x ", px[i]);
410 AliInfo(tsreturn.Data());
415 //------------------------------------------------------------
417 AliTRDrawStreamTB::SkipWords(UInt_t iw)
421 // note: can be made faster
424 if ( fpPos + iw < fpEnd )
431 if (fgWarnError) AliWarning(Form("Skip %d words failed. %d available", iw, fpEnd - fpPos - 1));
434 TTreeSRedirector &cstream = *fgDebugStreamer;
435 cstream << "SkipWords"
436 << "Event=" << fgStreamEventCounter
438 // << ".read=" << (Char_t*)(fpPos - fpBegin)
439 // << ".togo=" << (Char_t*)(fpEnd - fpPos)
440 // << ".length=" << (Char_t*)(fpEnd - fpBegin)
449 //------------------------------------------------------------
451 AliTRDrawStreamTB::SetReader(AliRawReader *reader)
466 AliWarning("Unable to setup reader.");
472 AliWarning("AliRawReader argument is 0.");
479 //------------------------------------------------------------
481 AliTRDrawStreamTB::NextBuffer()
484 // return -1 if no more buffers available
485 // return 0 DecodeSM failed (clean data required for example) but still maybe more data to come
486 // return 1 DecodeSM OK
493 Bool_t kBufferSet = fRawReader->ReadNextData(buffer);
494 if (kBufferSet == kTRUE)
496 if (fgDebugFlag) AliDebug(9, "Buffer is set.");
497 length = fRawReader->GetDataSize();
498 if (fgExtraSkip == kTRUE)
500 buffer += EXTRA_LEAD_WORDS * WORD_SIZE;
501 length -= EXTRA_LEAD_WORDS * WORD_SIZE;
504 if (fgSkipCDH == kTRUE)
506 buffer += CDH_WORDS * WORD_SIZE;
507 length -= CDH_WORDS * WORD_SIZE;
512 if (fgDebugFlag) AliDebug(9, Form("Buffer length : %d", length));
513 //return InitBuffer((void*)buffer, length);
514 if (DecodeSM((void*)buffer, length) == kTRUE)
529 //------------------------------------------------------------
531 AliTRDrawStreamTB::ResetCounters()
534 // reset some global counters
538 fStackLinkNumber = 0;
542 fSM.fActiveStacks = 0;
543 fSM.fNexpectedHalfChambers = 0;
545 fLinkTrackletCounter = 0;
547 fLastEventCounter = 0;
551 //------------------------------------------------------------
553 AliTRDrawStreamTB::ResetIterators()
556 // reset the data iterators used in the Next()
559 fStackLinkNumber = 0;
564 //------------------------------------------------------------
567 AliTRDrawStreamTB::Next()
570 // returns with true on next adc read
571 // returns false on errors and end of buffer
574 while (fStackNumber < 5 && fSM.fActiveStacks > 0)
576 if(fSM.fStackActive[fStackNumber] == kTRUE)
578 fStack = &fSM.fStacks[fStackNumber];
579 while (fStackLinkNumber < 12)
581 if (fStack->fLinksActive[fStackLinkNumber] == kTRUE)
583 fHC = &fStack->fHalfChambers[fStackLinkNumber];
586 AliError(Form("Super Strange. HC missing at stack %d link %d", fStackNumber, fStackLinkNumber));
589 if (fHC->fCorrupted == 0)
591 while (fhcMCMcounter < fHC->fMCMmax)
593 fMCM = &fHC->fMCMs[fhcMCMcounter];
596 AliError(Form("Super Strange. HC missing at stack %d link %d atMCMslot %d",
597 fStackNumber, fStackLinkNumber, fhcMCMcounter));
600 while(fmcmADCcounter < fMCM->fADCmax)
602 fADC = &fMCM->fADCs[fmcmADCcounter];
605 AliError(Form("Super Strange. ADC missing at stack %d link %d MCMslot %d ADCslot %d",
606 fStackNumber, fStackLinkNumber, fhcMCMcounter, fmcmADCcounter));
616 if (fADC->fIsShared == kFALSE)
621 // next MCM should go through all active ADCs
627 // next stack link (HC) should go through all active MCMs
632 // next stack should go through all links - start from 0
633 fStackLinkNumber = 0;
636 // in case rawreader manages the mem buffers
637 // lets go for the next buffer
640 Int_t nextBuff = NextBuffer();
641 while (nextBuff != -1)
645 nextBuff = NextBuffer();
652 //------------------------------------------------------------
655 AliTRDrawStreamTB::NextChamber(AliTRDdigitsManager *digitsManager)
658 // Fills single chamber digit array
659 // Return value is the detector number
662 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
663 AliTRDdataArrayDigits *digits = 0;
664 AliTRDdataArrayI *track0 = 0;
665 AliTRDdataArrayI *track1 = 0;
666 AliTRDdataArrayI *track2 = 0;
667 AliTRDSignalIndex *indexes = 0;
669 // Get the ADC baseline
670 Int_t adcBaseline = 0;
671 // if (!AliTRDReconstructor::RecoParam())
673 // AliError("RecoParam does not exist\n");
678 // adcBaseline = ((Int_t) AliTRDReconstructor::RecoParam()->GetADCbaseline());
681 static AliTRDrecoParam * par = AliTRDrecoParam::GetLowFluxParam();
682 adcBaseline = par->GetADCbaseline();
683 // Loop through the digits
686 // Int_t returnDet = -1;
694 // If new detector found
704 if (det < 0 || det >= AliTRDgeometry::kNdet)
706 if (fSM.fClean == kTRUE)
708 AliError(Form("Strange Det Number %d BUT event buffer seems to be clean.", det));
712 AliError(Form("Strange Det Number %d. Event buffer marked NOT clean!", det));
717 // Add a container for the digits of this detector
718 digits = (AliTRDdataArrayDigits *) digitsManager->GetDigits(det);
720 if (digitsManager->UsesDictionaries())
722 track0 = (AliTRDdataArrayI *) digitsManager->GetDictionary(det,0);
723 track1 = (AliTRDdataArrayI *) digitsManager->GetDictionary(det,1);
724 track2 = (AliTRDdataArrayI *) digitsManager->GetDictionary(det,2);
729 if (fSM.fClean == kTRUE)
731 AliError(Form("Unable to get digits for det %d BUT event buffer seems to be clean.", det));
735 AliError(Form("Unable to get digits for det %d. Event buffer is NOT clean!", det));
741 Int_t rowMax = GetRowMax();
742 Int_t colMax = GetColMax();
743 Int_t ntbins = GetNumberOfTimeBins();
745 // Allocate memory space for the digits buffer
746 if (digits->GetNtime() == 0)
748 digits->Allocate(rowMax, colMax, ntbins);
749 if (digitsManager->UsesDictionaries())
751 track0->Allocate(rowMax, colMax, ntbins);
752 track1->Allocate(rowMax, colMax, ntbins);
753 track2->Allocate(rowMax, colMax, ntbins);
757 indexes = digitsManager->GetIndexes(det);
758 indexes->SetSM(GetSM());
759 indexes->SetStack(GetStack());
760 indexes->SetLayer(GetLayer());
761 indexes->SetDetNumber(det);
762 if (indexes->IsAllocated() == kFALSE)
763 indexes->Allocate(rowMax, colMax, ntbins);
766 Char_t padStatus = cal->GetPadStatus(det, GetCol(), GetRow());
768 // ntimebins data are ready to read
769 for (it = 0; it < GetNumberOfTimeBins(); it++)
771 if ((GetSignals()[it] - adcBaseline) > 0)
773 digits->SetDataUnchecked(GetRow(), GetCol(), it, GetSignals()[it] - adcBaseline);
775 digits->SetPadStatus(GetRow(), GetCol(), it, padStatus);
777 indexes->AddIndexTBin(GetRow(), GetCol(), it);
778 if (digitsManager->UsesDictionaries())
780 track0->SetDataUnchecked(GetRow(), GetCol(), it, 0);
781 track1->SetDataUnchecked(GetRow(), GetCol(), it, 0);
782 track2->SetDataUnchecked(GetRow(), GetCol(), it, 0);
788 // what happens if the last HC is turned off?
793 //------------------------------------------------------------
795 AliTRDrawStreamTB::Init()
801 TDirectory *saveDir = gDirectory;
805 fGeometry = new AliTRDgeometry();
810 AliError("Geometry FAILED!");
814 fTRDfeeParam = AliTRDfeeParam::Instance();
817 AliError("AliTRDfeeParam FAILED!");
821 fMaxADCgeom = (Int_t)fGeometry->ADCmax();
823 // common additive is moved to be static for temp solution
824 // common additive should be delivered in the HC word 2 (3rd word)
825 //fCommonAdditive = 10;
829 if (fgDebugStreamFlag == kTRUE)
831 if (!fgDebugStreamer)
833 fgDebugStreamer = new TTreeSRedirector("TRDrawDataDebug.root");
834 fgStreamEventCounter = 0;
838 AliInfo(Form("Debug Streamer Initialized! Remember to delete! %s::DeleteDebugStream()", this->IsA()->GetName()));
839 //fDebugStreamOwned = kTRUE;
843 AliError("Unable to init debug stream");
848 // in case rawreader manages the mem buffers
849 // lets go for the next buffer
852 Int_t nextBuff = NextBuffer();
853 while (nextBuff != -1)
857 nextBuff = NextBuffer();
866 void AliTRDrawStreamTB::DeleteDebugStream()
869 // static helper function
874 delete fgDebugStreamer;
880 //------------------------------------------------------------
882 AliTRDrawStreamTB::InitBuffer(void *buffer, UInt_t length)
885 // init the class before reading from the buffer
886 // and read SM heading info:
887 // -- super module header
888 // -- stack headers + link status words
891 // not in the pre scan mode
893 if(fgStreamEventCounter == 0) fgFirstEquipmentID = fRawReader->GetEquipmentId();
894 fEquipmentID = fRawReader->GetEquipmentId();
895 //fgStreamEventCounter++;
896 if(fEquipmentID == fgFirstEquipmentID) fgStreamEventCounter++;
901 fpBegin = (UInt_t *)buffer;
905 AliFatal("Strange! Size of UInt_t == 0");
909 fWordLength = length/WORD_SIZE;
910 fpEnd = fpBegin + fWordLength;
913 if (fpBegin == 0 || length <= 0)
915 AliError(Form("This will not work! Pointer to the buffer is 0x%08x of size %d", fpBegin, length));
923 AliInfo("------------------------------------------------");
924 if (DumpWords(fpBegin, fgDumpHead) == kFALSE)
926 AliError("Dump failed. Not enough data.");
928 AliInfo("------------------------------------------------");
932 DecodeSMInfo(fpPos, &fSM);
934 if (fgDebugFlag) AliDebug(5, DumpSMInfo(&fSM));
939 if (SkipWords(fSM.fHeaderSize) == kTRUE)
942 //for (Int_t istack = 0; istack < fSM.fActiveStacks; istack++)
943 for (Int_t istack = 0; istack < 5; istack++)
945 if (fSM.fStackActive[istack] == kFALSE)
948 fStack = &fSM.fStacks[istack];
949 DecodeStackInfo(fpPos, fStack);
952 fSM.fNexpectedHalfChambers += fStack->fActiveLinks;
954 if (fgDebugFlag) AliDebug(5, DumpStackInfo(fStack));
956 if (SkipWords(fStack->fHeaderSize) == kFALSE)
958 if (fRawReader) fRawReader->AddMajorErrorLog(kDecodeStackInfo, "Stack head words missing");
970 if (fgWarnError) AliWarning("No Stack info present. Strange.");
971 if (fRawReader) fRawReader->AddMajorErrorLog(kDecodeStackInfo, "Stack info missing");
975 if (fgDebugFlag) AliDebug(5, Form("Expected half chambers : %d", fSM.fNexpectedHalfChambers));
980 if (fgDebugFlag) AliDebug(5, "Init OK.");
984 if (fgWarnError) AliWarning("No data just after init. Strange.");
985 if (fRawReader) fRawReader->AddMajorErrorLog(kMissingData, "Missing data");
992 //------------------------------------------------------------
994 AliTRDrawStreamTB::DecodeSM(void *buffer, UInt_t length)
997 // decode all sm at once
998 // still here for devel and debug
1001 //memset(&fSM, 0, sizeof(fSM));
1006 if (InitBuffer(buffer, length) == kTRUE)
1008 // no we are already set!
1013 if (fgWarnError) AliError("--- INIT failed. ---------------");
1014 fSM.fClean = kFALSE;
1020 for (Int_t istack = 0; istack < 5; istack++)
1022 fStackNumber = istack;
1023 if (fSM.fStackActive[istack] == kFALSE)
1026 fStack = &fSM.fStacks[istack];
1028 //fStack[istack].fActiveLinks // max is 12
1029 for (Int_t ilink = 0; ilink < 12; ilink++)
1031 fStackLinkNumber = ilink;
1032 if (fStack->fLinksActive[ilink] == kFALSE)
1037 if (fRawReader) fRawReader->AddMajorErrorLog(kLinkDataMissing, "Link data missing");
1038 fSM.fClean = kFALSE;
1042 fHC = &fStack->fHalfChambers[ilink];
1044 if (fgDebugStreamer)
1046 TTreeSRedirector &cstream = *fgDebugStreamer;
1047 cstream << "LINKDataStream"
1048 << "Event=" << fgStreamEventCounter
1049 << ".equipID=" << fEquipmentID
1050 << ".stack=" << fStackNumber
1051 << ".link=" << fStackLinkNumber
1056 if (fSM.fTrackletEnable == kTRUE)
1058 if (DecodeTracklets() == kFALSE)
1060 if (fgDebugStreamer)
1062 TTreeSRedirector &cstream = *fgDebugStreamer;
1063 cstream << "TrackletDecodeError"
1064 << "Event=" << fgStreamEventCounter
1065 << ".Stack=" << fStackNumber
1066 << ".Link=" << fStackLinkNumber
1067 << ".EndOfTrackletCount=" << fEndOfTrackletCount
1071 fSM.fClean = kFALSE;
1076 AliError(Form("Failed stack %d link %d", fStackNumber, fStackLinkNumber));
1077 AliError(Form("Debug Event Counter : %d", fgStreamEventCounter));
1086 if (fRawReader) fRawReader->AddMajorErrorLog(kHCdataMissing, "HC data missing");
1087 fSM.fClean = kFALSE;
1091 if (DecodeHC() == kFALSE)
1093 fSM.fClean = kFALSE;
1096 AliError(Form("Dumping Words for Debugging Purpose =========================>"));
1097 DumpWords(fpPos-8, 16);
1098 AliError(Form("Dumping Done!"));
1100 if (fHC->fCorrupted < 16) SeekEndOfData(); // In case that we meet END_OF_TRACKLET_MARKERNEW during ADC data decoding or MCM header decoding
1101 // we don't seek ENDOFRAWDATAMARKER
1105 AliError(Form("Failed HC : %s", DumpHCinfoH0(fHC)));
1106 AliError(Form("Failed HC : %s", DumpHCinfoH1(fHC)));
1107 AliError(Form("Debug Event Counter : %d\n\n\n", fgStreamEventCounter));
1115 SeekEndOfData(); // make sure that finish off with the end of data markers
1124 if (fSM.fClean == kTRUE)
1127 if (fgCleanDataOnly && (fSM.fClean == kFALSE))
1131 AliWarning("Buffer with errors. Returning FALSE.");
1132 AliWarning(Form("--- Failed SM : %s ---", DumpSMInfo(&fSM)));
1134 fSM.fActiveStacks = 0; // Next will not give data
1141 //------------------------------------------------------------
1143 AliTRDrawStreamTB::DecodeSM()
1146 // decode SM data in case AliRawReader is in use
1150 Int_t nextBuff = NextBuffer();
1151 while (nextBuff != -1)
1155 nextBuff = NextBuffer();
1161 AliWarning("AliRawReader not set.");
1166 //------------------------------------------------------------
1168 AliTRDrawStreamTB::DecodeSM(AliRawReader *reader)
1171 // decode SM with the AliRawReader
1175 fRawReader = reader;
1180 AliWarning("Argument AliRawReader is 0.");
1185 //------------------------------------------------------------
1187 AliTRDrawStreamTB::SeekEndOfData()
1190 // go to end of data marker
1192 Int_t fEndOfDataCount = 0;
1194 while ( *fpPos != ENDOFRAWDATAMARKER && fpPos < fpEnd )
1199 while (*fpPos == ENDOFRAWDATAMARKER && fpPos < fpEnd )
1205 // if (fEndOfDataCount == 0)
1207 // if (fgWarnError) AliWarning("End of buffer reached first. No end of data marker?");
1214 //------------------------------------------------------------
1216 AliTRDrawStreamTB::SeekNextMCMheader()
1222 // move back to the mcm pos
1223 fpPos = fMCM->fPos + 1;
1225 while ( *fpPos != ENDOFRAWDATAMARKER && fpPos < fpEnd )
1227 if (MCM_HEADER_MASK_ERR(*fpPos) == 0)
1229 if (fgWarnError) AliWarning(Form("^^^ Found : Pos 0x%08x : Val 0x%08x", fpPos, *fpPos));
1239 //------------------------------------------------------------
1242 AliTRDrawStreamTB::DecodeTracklets()
1248 fLinkTrackletCounter = 0;
1249 fEndOfTrackletCount = 0;
1251 if (fgDebugFlag) AliDebug(10, Form("Decode tracklets at 0x%08x : 0x%08x", fpPos, *fpPos));
1253 while ( *fpPos != END_OF_TRACKLET_MARKEROLD && *fpPos != END_OF_TRACKLET_MARKERNEW && fpPos < fpEnd )
1256 if (fgDebugFlag) AliDebug(10, Form("Tracklet found at 0x%08x : 0x%08x", fpPos, *fpPos));
1258 fLinkTrackletCounter++;
1260 if (fLinkTrackletCounter > MAX_TRACKLETS_PERHC)
1262 if (fgWarnError) AliWarning(Form("Max number of tracklets exceeded %d > %d. Something is wrong with the input data!",
1263 fLinkTrackletCounter, MAX_TRACKLETS_PERHC));
1267 AliError(Form("Dumping Words for Debugging Purpose =========================>"));
1268 DumpWords(fpPos-300, 320);
1269 AliError(Form("Dumping Done!"));
1273 if (fRawReader) fRawReader->AddMajorErrorLog(kTrackletOverflow,"Too many tracklets");
1277 if (fgDebugStreamer)
1293 row = (val >> 20) & 0xF;
1294 defl = (val >> 13) & 0x7F;
1295 defl = defl << 25 >> 25;
1296 ypos = val & 0x1FFF;
1297 ypos = ypos << 19 >> 19;
1299 deflm = defl * 140.0e-6; /* m */
1300 yposm = ypos * 160.0e-6; /* m */
1302 TTreeSRedirector &cstream = *fgDebugStreamer;
1303 cstream << "MCMtracklets"
1304 << "Event=" << fgStreamEventCounter
1305 << ".stack=" << fStackNumber
1306 << ".link=" << fStackLinkNumber
1311 << ".deflm=" << deflm
1312 << ".yposm=" << yposm
1318 while ( ( *fpPos == END_OF_TRACKLET_MARKEROLD || *fpPos == END_OF_TRACKLET_MARKERNEW ) && fpPos < fpEnd )
1320 if (fgDebugFlag) AliDebug(10, Form("EoTracklets found at 0x%08x : 0x%08x", fpPos, *fpPos));
1322 fEndOfTrackletCount++;
1326 if ( fEndOfTrackletCount < 2 )
1328 if (fRawReader) fRawReader->AddMajorErrorLog(kEOTrackeltsMissing, "End of tracklets word missing");
1335 //------------------------------------------------------------
1337 AliTRDrawStreamTB::IsRowValid()
1340 if ( (fHC->fStack == 2 && fMCM->fROW >= fGeometry->RowmaxC0()) ||
1341 (fHC->fStack != 2 && fMCM->fROW >= fGeometry->RowmaxC1()) || fMCM->fROW < 0 )
1343 if (fgWarnError) AliWarning(Form("SM%d L%dS%d: Wrong Padrow (%d) fROB=%d, fSIDE=%d, fMCM=%02d"
1344 , fHC->fSM, fHC->fLayer, fHC->fStack, fMCM->fROW, fMCM->fROB, fHC->fSide, fMCM->fMCM ));
1345 if (fRawReader) fRawReader->AddMajorErrorLog(kWrongPadrow, "Wrong Row");
1351 //------------------------------------------------------------
1353 AliTRDrawStreamTB::IsMCMheaderOK()
1356 // check the mcm header
1359 if ( fMCM->fCorrupted > 1 )
1361 if (fRawReader) fRawReader->AddMajorErrorLog(kMCMheaderCorrupted,"ADC mask Corrupted");
1362 if (fgWarnError) AliWarning(Form("Wrong ADC Mask word 0x%08x %s. Error : %d\n", *fMCM->fPos, DumpMCMadcMask(fMCM), fMCM->fCorrupted));
1366 if ( fMCM->fCorrupted > 0 )
1368 if (fRawReader) fRawReader->AddMajorErrorLog(kMCMheaderCorrupted,"Corrupted");
1369 if (fgWarnError) AliWarning(Form("Wrong MCM word 0x%08x %s. Error : %d\n", *fMCM->fPos, DumpMCMinfo(fMCM), fMCM->fCorrupted));
1373 if ( fMCM->fMCM < 0 || fMCM->fMCM > 15 || fMCM->fROB < 0 || fMCM->fROB > 7 )
1375 if (fRawReader) fRawReader->AddMajorErrorLog(kWrongMCMorROB,"Wrong ROB or MCM");
1376 if (fgWarnError) AliWarning(Form("Wrong fMCM or fROB. %s\n", DumpMCMinfo(fMCM)));
1380 if (IsRowValid() == kFALSE)
1386 //------------------------------------------------------------
1388 AliTRDrawStreamTB::IsMCMevCounterOK()
1391 // Check the MCM event counter
1394 if (fEventCounter == 0)
1396 fEventCounter = fMCM->fEvCounter;
1399 if (fEventCounter < fLastEventCounter)
1401 fMCM->fCorrupted += 2;
1402 if (fgWarnError) AliWarning(Form("Event from the past? Current %d Last %d %s. Error : %d\n", fEventCounter, fLastEventCounter, DumpMCMinfo(fMCM), fMCM->fCorrupted));
1403 if (fRawReader) fRawReader->AddMajorErrorLog(kMCMeventMissmatch, "Wrong MCM event counter ? Past-Future");
1407 if (fEventCounter != fMCM->fEvCounter)
1409 fMCM->fCorrupted += 2;
1410 if (fgWarnError) AliWarning(Form("Event missmatch? FirstMCMs %d ThisMCMs %d %s. Error : %d\n", fEventCounter, fMCM->fEvCounter, DumpMCMinfo(fMCM), fMCM->fCorrupted));
1411 if (fRawReader) fRawReader->AddMajorErrorLog(kMCMeventMissmatch, "Wrong MCM event counter ?");
1418 //------------------------------------------------------------
1420 AliTRDrawStreamTB::DecodeMCMheader()
1423 // decode the mcm header
1426 DecodeMCMheader(fpPos, fMCM);
1427 if (fHC->fCorrupted >= 16)
1433 fMCM->fROW = fTRDfeeParam->GetPadRowFromMCM(fMCM->fROB, fMCM->fMCM);
1435 if ((fHC->fRawVMajor > 2 && fHC->fRawVMajor <5) || (fHC->fRawVMajor > 31 && fHC->fRawVMajor < 64)) //cover old and new version definition of ZS data
1438 if ( fpPos < fpEnd )
1440 DecodeMask(fpPos, fMCM);
1441 if (fHC->fCorrupted >= 16)
1446 MCMADCwordsWithTbins(fHC->fTimeBins, fMCM);
1447 fMCM->fAdcDataPos = fpPos + 1;
1451 if (fgWarnError) AliWarning("Expected ADC mask word. Fail due to buffer END.");
1452 if (fRawReader) fRawReader->AddMajorErrorLog(kMCMADCMaskMissing,"Missing");
1458 UInt_t dummyMask = MCM_DUMMY_ADCMASK_VAL;
1459 DecodeMask(&dummyMask, fMCM);
1460 MCMADCwordsWithTbins(fHC->fTimeBins, fMCM);
1461 fMCM->fAdcDataPos = fpPos + 1;
1466 AliDebug(6, DumpMCMinfo(fMCM));
1467 AliDebug(7, DumpMCMadcMask(fMCM));
1470 if (IsMCMheaderOK() == kFALSE)
1473 if (IsMCMevCounterOK() == kFALSE)
1479 //------------------------------------------------------------
1481 AliTRDrawStreamTB::IsHCheaderOK()
1484 // check the half chamber header
1487 if (fHC->fCorrupted > 0)
1489 if (fgWarnError) AliWarning(Form("Wrong HC Header word. Word 0x%08x Error : %d", *fHC->fPos, fHC->fCorrupted));
1490 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderCorrupt, "Corrupted");
1495 if (fHC->fStack < 0 || fHC->fStack > 4)
1497 if (fgWarnError) AliWarning(Form("Wrong Stack %d", fHC->fStack));
1498 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongStack, "Wrong Stack");
1502 if (fgStackNumberChecker)
1504 if (fHC->fStack != fStackNumber)
1506 if (fgWarnError) AliWarning(Form("Missmatch: Stack in HC header %d HW-stack %d",
1507 fHC->fStack, fStackNumber));
1508 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongStack, "Stack-HWstack");
1514 if (fHC->fLayer < 0 || fHC->fLayer >= AliTRDgeometry::kNplan)
1516 if (fgWarnError) AliWarning(Form("Wrong plane(layer) %d", fHC->fLayer));
1517 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongLayer, "Wrong Plane");
1521 if (fgStackLinkNumberChecker)
1524 if ((fHC->fLayer * 2 != fStackLinkNumber) && (fHC->fLayer * 2 != fStackLinkNumber - 1))
1526 if (fgWarnError) AliWarning(Form("Missmatch: plane(layer) in HCheader %d HW-Link %d | %s",
1527 fHC->fLayer, fStackLinkNumber, DumpStackInfo(fStack)));
1528 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongLayer, "Plane-Link missmatch");
1529 fStackLinkNumber = -1;
1534 if (fHC->fSide < 0 || fHC->fSide > 1)
1536 if (fgWarnError) AliWarning(Form("Wrong Side %d", fHC->fSide));
1537 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongSide, "Wrong Side");
1542 fHC->fDET = fGeometry->GetDetector(fHC->fLayer, fHC->fStack, fHC->fSM);
1543 if (fHC->fDET < 0 || fHC->fDET >= AliTRDgeometry::kNdet)
1545 if (fgWarnError) AliWarning(Form("Wrong detector %d", fHC->fDET));
1546 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongDet, "Wrong Det");
1551 // this check fails - raw data inconsistent with geometry?
1552 if (fHC->fSM != fGeometry->GetSector(fHC->fDET)
1553 || fHC->fSM <0 || fHC->fSM >= AliTRDgeometry::kNsect)
1555 if (fgWarnError) AliWarning(Form("Wrong SM(sector) %d (Geometry says: %d) Stack=%d Layer=%d Det=%d",
1556 fHC->fSM, fGeometry->GetSector(fHC->fDET),
1557 fHC->fStack, fHC->fLayer, fHC->fDET));
1558 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongSM, "Wrong SM");
1564 fHC->fROC = fGeometry->GetDetectorSec(fHC->fLayer, fHC->fStack);
1567 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongROC, "Wrong ROC");
1571 fHC->fRowMax = fGeometry->GetRowMax(fHC->fLayer, fHC->fStack, fHC->fSM);
1572 if (fHC->fRowMax < 1)
1574 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongROC, "Wrong ROC Row Max");
1578 fHC->fColMax = fGeometry->GetColMax(fHC->fROC);
1579 if (fHC->fColMax < 1)
1581 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongROC, "Wrong ROC Col Max");
1584 // extra - not needed
1585 // if (fHC->fSM <0 || fHC->fSM >= AliTRDgeometry::kNsect)
1587 // if (fgWarnError) AliWarning(Form("Wrong SM(sector) %d (Geometry says: %d) Stack=%d Layer=%d",
1588 // fHC->fSM, fGeometry->GetDetectorSec(fHC->fLayer, fHC->fStack),
1589 // fHC->fStack, fHC->fLayer));
1596 //------------------------------------------------------------
1598 AliTRDrawStreamTB::DecodeHCheader()
1601 // decode the half chamber header
1604 DecodeHCwordH0(fpPos, fHC);
1606 if (fHC->fNExtraWords > 0)
1611 DecodeHCwordH1(fpPos, fHC);
1615 if (fgWarnError) AliWarning("Expected HC header word 1. Fail due to buffer END.");
1616 if (fRawReader) fRawReader->AddMajorErrorLog(kHCWordMissing,"Next HC word 1 (count from 0) missing");
1621 if (fgDebugFlag) AliDebug(5, DumpHCinfoH0(fHC));
1622 if (fgDebugFlag) AliDebug(5, DumpHCinfoH1(fHC));
1625 if (IsHCheaderOK() == kFALSE)
1627 if(fHC->fCorrupted < 1) fHC->fCorrupted +=4;
1634 //------------------------------------------------------------
1636 AliTRDrawStreamTB::DecodeHC()
1639 // decode the hc data
1640 // function for devel & debug
1643 if (DecodeHCheader() == kFALSE)
1645 if (fgDebugStreamer)
1647 TTreeSRedirector &cstream = *fgDebugStreamer;
1648 cstream << "HCDecodeError"
1649 << "Event=" << fgStreamEventCounter
1650 << ".stack=" << fStackNumber
1651 << ".link=" << fStackLinkNumber
1652 << ".hcCorrupted=" << fHC->fCorrupted
1653 << ".hcRVmajor=" << fHC->fRawVMajor
1654 << ".hcDCSboard=" << fHC->fDCSboard
1655 << ".hcSM=" << fHC->fSM
1656 << ".hcStack=" << fHC->fStack
1657 << ".hcLayer=" << fHC->fLayer
1658 << ".hcSide=" << fHC->fSide
1659 << ".hcTbins=" << fHC->fTimeBins
1660 << ".hcBunchCross=" << fHC->fBunchCrossCounter
1661 << ".hcPreTrig=" << fHC->fPreTriggerCounter
1662 << ".hcPreTrigPh=" << fHC->fPreTriggerPhase
1663 << ".hcDet=" << fHC->fDET
1664 << ".hcROC=" << fHC->fROC
1665 << ".hcRowMax=" << fHC->fRowMax
1666 << ".hcColMax=" << fHC->fColMax
1670 if (fgWarnError) AliWarning("Header decode failed.");
1678 if (fgWarnError) AliWarning("No MCM data? Not enough data in the buffer.");
1679 if (fRawReader) fRawReader->AddMajorErrorLog(kMCMdataMissing, "MCM data missing");
1685 while (*fpPos != ENDOFRAWDATAMARKER && fpPos < fpEnd)
1687 if (fHC->fMCMmax > TRD_MAX_MCM)
1689 if (fgWarnError) AliWarning("More mcm data than expected!");
1690 if (fRawReader) fRawReader->AddMajorErrorLog(kMCMoverflow, "Too many mcms found!");
1694 fMCM = &fHC->fMCMs[fHC->fMCMmax];
1696 if (DecodeMCMheader() == kFALSE)
1698 if (fgDebugStreamer)
1700 TTreeSRedirector &cstream = *fgDebugStreamer;
1701 cstream << "MCMDecodeError"
1702 << "Event=" << fgStreamEventCounter
1703 << ".stack=" << fStackNumber
1704 << ".link=" << fStackLinkNumber
1705 << ".hcDCSboard=" << fHC->fDCSboard
1706 << ".hcSM=" << fHC->fSM
1707 << ".hcStack=" << fHC->fStack
1708 << ".hcLayer=" << fHC->fLayer
1709 << ".hcSide=" << fHC->fSide
1710 << ".hcBunchCross=" << fHC->fBunchCrossCounter
1711 << ".hcPreTrig=" << fHC->fPreTriggerCounter
1712 << ".hcPreTrigPh=" << fHC->fPreTriggerPhase
1713 << ".hcDet=" << fHC->fDET
1715 << ".mcmCorrupted=" << fMCM->fCorrupted
1716 << ".mcmROB=" << fMCM->fROB
1717 << ".mcmMCM=" << fMCM->fMCM
1718 << ".mcmADCMaskWord=" << fMCM->fADCMaskWord
1719 << ".mcmEventCounter=" << fMCM->fEvCounter
1721 << ".fEventCounter=" << fEventCounter
1722 << ".fLastEventCounter=" << fLastEventCounter
1726 if (fgSkipData == kTRUE || fHC->fCorrupted >= 16)
1727 return kFALSE; //if(true), keep reading next words even previous words were corrupted - debugging purpose
1732 if (fMCM->fADCmax > 0)
1737 if (fgDebugFlag) AliDebug(9, Form("Buffer short of data. ADC data expected."));
1738 if (fRawReader) fRawReader->AddMajorErrorLog(kADCdataMissing, "ADC data missing");
1741 unsigned long randVal, iniVal, expectedVal;
1742 Int_t endbits = ENDBITS;
1744 for (Int_t iadc = 0; iadc < fMCM->fADCmax; iadc++)
1746 fADC = &fMCM->fADCs[iadc];
1747 fADC->fADCnumber = fMCM->fADCchannel[iadc];
1749 if (fgDebugFlag) AliDebug(9, Form("This is ADC %d of %d. ADC number is %d.",
1750 iadc+1, fMCM->fADCmax, fMCM->fADCchannel[iadc]));
1752 if (fpPos + fMCM->fSingleADCwords >= fpEnd)
1754 if (fgDebugStreamer)
1756 TTreeSRedirector &cstream = *fgDebugStreamer;
1758 cstream << "ADCDecodeError"
1759 << "Event=" << fgStreamEventCounter
1760 << ".hcSM=" << fHC->fSM
1761 << ".hcStack=" << fHC->fStack
1762 << ".hcLayer=" << fHC->fLayer
1763 << ".hcSide=" << fHC->fSide
1764 << ".hcDet=" << fHC->fDET
1765 << ".mcmROB=" << fMCM->fROB
1766 << ".mcmMCM=" << fMCM->fMCM
1767 << ".mcmADCMaskWord=" << fMCM->fADCMaskWord
1768 << ".adcErr=" << ierr
1769 << ".adcNumber=" << ierr
1773 if (fgWarnError) AliWarning(Form("This is ADC %d of %d. ADC number is %d.", iadc+1, fMCM->fADCmax, fMCM->fADCchannel[iadc]));
1774 if (fgWarnError) AliWarning("--> ADC (10 words) expected. Not enough data in the buffer.");
1775 if (fgWarnError) AliWarning(Form("--> ADC mask : %s", DumpMCMadcMask(fMCM)));
1777 if (fRawReader) fRawReader->AddMajorErrorLog(kADCdataMissing, "ADC data missing - less than expected");
1781 if (fHC->fRawVMajor < 64) // normal(real) ADC data
1783 if (DecodeADC() == kFALSE)
1785 // check if we are out of the det when the pad is shared
1786 if (fADC->fIsShared && fADC->fCorrupted == 4)
1789 fpPos = fADC->fPos + fMCM->fSingleADCwords;
1793 if (fgWarnError) AliWarning(Form("ADC decode failed."));
1795 if (fgDebugStreamer)
1797 TTreeSRedirector &cstream = *fgDebugStreamer;
1798 cstream << "ADCDecodeError"
1799 << "Event=" << fgStreamEventCounter
1800 << ".hcSM=" << fHC->fSM
1801 << ".hcStack=" << fHC->fStack
1802 << ".hcLayer=" << fHC->fLayer
1803 << ".hcSide=" << fHC->fSide
1804 << ".hcDet=" << fHC->fDET
1805 << ".mcmROB=" << fMCM->fROB
1806 << ".mcmMCM=" << fMCM->fMCM
1807 << ".mcmADCMaskWord=" << fMCM->fADCMaskWord
1808 << ".adcErr=" << fADC->fCorrupted
1809 << ".adcNumber=" << fADC->fADCnumber
1812 if (fHC->fCorrupted < 16)
1813 fpPos = fADC->fPos + fMCM->fSingleADCwords;
1815 if (fgSkipData == kTRUE || fHC->fCorrupted >= 16)
1816 return kFALSE; //if(true), keep reading next words even previous words were corrupted - debugging purpose
1820 else // test pattern data
1822 if (fHC->fRawVMajorOpt == 1) //test pattern 1
1824 Int_t iCpu = iadc/5;
1825 if(iadc==20) iCpu = 3;
1826 if(iadc%5==0 && iadc!=20) randVal = (1 << 9) | (fMCM->fROB << 6) | (fMCM->fMCM << 2) | iCpu;
1827 if (DecodeADCTP1(&randVal,&endbits) == kFALSE)
1829 if (fgWarnError) AliWarning(Form("Summary: Test Pattern ADC data are corrupted in channel %d %s\n", iadc, DumpMCMinfo(fMCM)));
1830 if (fgDebugStreamer)
1832 TTreeSRedirector &cstream = *fgDebugStreamer;
1833 cstream << "ADCDecodeError"
1834 << "Event=" << fgStreamEventCounter
1835 << ".hcSM=" << fHC->fSM
1836 << ".hcStack=" << fHC->fStack
1837 << ".hcLayer=" << fHC->fLayer
1838 << ".hcSide=" << fHC->fSide
1839 << ".hcDet=" << fHC->fDET
1840 << ".mcmROB=" << fMCM->fROB
1841 << ".mcmMCM=" << fMCM->fMCM
1842 << ".mcmADCMaskWord=" << fMCM->fADCMaskWord
1843 << ".adcErr=" << fADC->fCorrupted
1844 << ".adcNumber=" << fADC->fADCnumber
1847 if (fHC->fCorrupted < 16)
1848 fpPos = fADC->fPos + fMCM->fSingleADCwords;
1850 if (fgSkipData == kTRUE || fHC->fCorrupted >= 16)
1851 return kFALSE; //if(true), keep reading next words even previous words were corrupted - debugging purpose
1855 if (fHC->fRawVMajorOpt == 2 || fHC->fRawVMajorOpt == 3) //test pattern 2 or 3
1857 iniVal = (fHC->fSM << 6) | (fHC->fStack << 0) | (fHC->fLayer << 3);
1858 iniVal = iniVal + 0x49;
1859 iniVal = (iniVal << 9) | (fMCM->fROB << 6) | (fMCM->fMCM << 2) | (fMCM->fEvCounter << 20);
1860 Int_t iCpu = iadc/5;
1861 if (iadc==20) iCpu = 3;
1862 if (iadc%5==0 && iadc!=20)
1864 if (fHC->fRawVMajorOpt == 2) { expectedVal = ((iniVal | iCpu) << 6) + 1; };
1865 if (fHC->fRawVMajorOpt == 3) { expectedVal = iniVal | iCpu; };
1867 if (DecodeADCTP23(&expectedVal) == kFALSE)
1869 if (fgWarnError) AliWarning(Form("Summary: Test Pattern ADC data are corrupted in channel %d %s\n", iadc, DumpMCMinfo(fMCM)));
1870 if (fgDebugStreamer)
1872 TTreeSRedirector &cstream = *fgDebugStreamer;
1873 cstream << "ADCDecodeError"
1874 << "Event=" << fgStreamEventCounter
1875 << ".hcSM=" << fHC->fSM
1876 << ".hcStack=" << fHC->fStack
1877 << ".hcLayer=" << fHC->fLayer
1878 << ".hcSide=" << fHC->fSide
1879 << ".hcDet=" << fHC->fDET
1880 << ".mcmROB=" << fMCM->fROB
1881 << ".mcmMCM=" << fMCM->fMCM
1882 << ".mcmADCMaskWord=" << fMCM->fADCMaskWord
1883 << ".adcErr=" << fADC->fCorrupted
1884 << ".adcNumber=" << fADC->fADCnumber
1887 if (fHC->fCorrupted < 16)
1888 fpPos = fADC->fPos + fMCM->fSingleADCwords;
1890 if (fgSkipData == kTRUE || fHC->fCorrupted >= 16)
1891 return kFALSE; //if(true), keep reading next words even previous words were corrupted - debugging purpose
1905 if (fgWarnError) AliWarning("We are at the end of buffer. There should be one more word left.");
1911 //------------------------------------------------------------
1914 AliTRDrawStreamTB::DecodeADC()
1917 // decode single ADC channel
1920 fADC->fCorrupted = 0;
1921 //fMaskADCword = ADC_WORD_MASK(*fpPos);
1922 if(fADC->fADCnumber%2==1) fMaskADCword = ADC_WORD_MASK(ADCDATA_VAL1);
1923 if(fADC->fADCnumber%2==0) fMaskADCword = ADC_WORD_MASK(ADCDATA_VAL2);
1928 for (Int_t i = 0; i < TRD_MAX_TBINS; i++)
1929 fADC->fSignals[i] = 0;
1931 for (Int_t iw = 0; iw < fMCM->fSingleADCwords; iw++)
1933 if (HC_HEADER_MASK_ERR(*fpPos) == 0 || *fpPos == END_OF_TRACKLET_MARKERNEW)
1935 if (fgWarnError) AliError(Form("There should be ADC data. We meet HC header or END_OF_TRACKLET_MARKER 0x%08x",*fpPos));
1936 fADC->fCorrupted += 16;
1937 fHC->fCorrupted += 16;
1942 if (fMaskADCword != ADC_WORD_MASK(*fpPos))
1944 fADC->fCorrupted += 1;
1945 if (fgWarnError) AliWarning(Form("Wrong ADC data mask! ADC channel number: %02d [Expected mask: 0x%08x Current mask: 0x%08x] MCM= %s Error : %d",
1946 fADC->fADCnumber, fMaskADCword, ADC_WORD_MASK(*fpPos),DumpMCMinfo(fMCM),fADC->fCorrupted));
1947 //if (fgWarnError) AliWarning(Form("Mask Change in ADC data Previous word (%d) : 0x%08x Previous mask : 0x%08x Current word(%d) : 0x%08x Current mask : 0x%08x",
1948 // iw - 1, *(fpPos-1), fMaskADCword, iw, *fpPos, ADC_WORD_MASK(*fpPos)));
1949 if (fRawReader) fRawReader->AddMajorErrorLog(kADCmaskMissmatch, "Mask change inside single channel");
1953 // here we subtract the baseline ( == common additive)
1954 fADC->fSignals[fTbinADC + 0] = ((*fpPos & 0x00000ffc) >> 2) - fgCommonAdditive;
1955 fADC->fSignals[fTbinADC + 1] = ((*fpPos & 0x003ff000) >> 12) - fgCommonAdditive;
1956 fADC->fSignals[fTbinADC + 2] = ((*fpPos & 0xffc00000) >> 22) - fgCommonAdditive;
1962 if (fADC->fADCnumber <= 1 || fADC->fADCnumber == fMaxADCgeom - 1)
1964 fADC->fIsShared = kTRUE;
1968 fADC->fIsShared = kFALSE;
1971 if ( fADC->fADCnumber >= fMaxADCgeom - 1)
1973 // let us guess the Column
1974 // take the one before last ADC and shift by one column
1975 // later we check if we are inside the limits of the chamber
1976 fADC->fCOL = AliTRDfeeParam::Instance()->GetPadColFromADC(fMCM->fROB, fMCM->fMCM, fADC->fADCnumber - 1);
1981 fADC->fCOL = fTRDfeeParam->GetPadColFromADC(fMCM->fROB, fMCM->fMCM, fADC->fADCnumber);
1984 if (fADC->fCOL >= fHC->fColMax || fADC->fCOL < 0)
1986 if (fADC->fIsShared == kFALSE)
1988 fADC->fCorrupted += 2;
1989 if (fgWarnError) AliWarning(Form("Wrong column! ADCnumber %d MaxIs %d Col %d MaxIs %d MCM= %s",
1990 fADC->fADCnumber, fMaxADCgeom, fADC->fCOL, fHC->fColMax, DumpMCMinfo(fMCM)));
1991 if (fRawReader) fRawReader->AddMajorErrorLog(kWrongPadcolumn, "Wrong column");
1995 // flag it - we are out of the det when the pad is shared
1996 if (fgDebugFlag) AliDebug(10, Form("Column out of the detector! ADCnumber %d MaxIs %d Col %d MaxIs %d MCM= %s",
1997 fADC->fADCnumber, fMaxADCgeom, fADC->fCOL, fHC->fColMax, DumpMCMinfo(fMCM)));
1998 fADC->fCorrupted += 4;
2002 if (fADC->fCorrupted > 0)
2010 //------------------------------------------------------------
2013 AliTRDrawStreamTB::DecodeADCTP1(unsigned long *randVal, Int_t *endbits)
2016 // decode test pattern ADC channel
2019 unsigned long expected;
2021 fADC->fCorrupted = 0;
2025 for (Int_t i = 0; i < TRD_MAX_TBINS; i++)
2026 fADC->fSignals[i] = 0;
2028 for (Int_t iw = 0; iw < fMCM->fSingleADCwords; iw++)
2030 if (HC_HEADER_MASK_ERR(*fpPos) == 0 || *fpPos == END_OF_TRACKLET_MARKERNEW)
2032 if (fgWarnError) AliError(Form("There should be ADC data. We meet HC header or END_OF_TRACKLET_MARKER 0x%08x",*fpPos));
2033 fADC->fCorrupted += 16;
2034 fHC->fCorrupted += 16;
2039 expected = (AdvancePseudoRandom(randVal) << 2) | *endbits;
2040 expected |= AdvancePseudoRandom(randVal) << 12;
2041 expected |= AdvancePseudoRandom(randVal) << 22;
2042 if (*fpPos != expected)
2044 if (fgWarnError) AliError(Form("Error: fpPos=%d, size=%d, found=0x%08lx, expected=0x%08lx",iw, fMCM->fSingleADCwords, *fpPos, expected));
2045 fADC->fCorrupted += 32; //test pattern corrupted
2047 fADC->fSignals[fTbinADC + 0] = ((*fpPos & 0x00000ffc) >> 2);
2048 fADC->fSignals[fTbinADC + 1] = ((*fpPos & 0x003ff000) >> 12);
2049 fADC->fSignals[fTbinADC + 2] = ((*fpPos & 0xffc00000) >> 22);
2054 *endbits = *endbits ^ 0x01;
2056 if (fADC->fADCnumber <= 1 || fADC->fADCnumber == fMaxADCgeom - 1)
2058 fADC->fIsShared = kTRUE;
2062 fADC->fIsShared = kFALSE;
2065 if ( fADC->fADCnumber >= fMaxADCgeom - 1)
2067 fADC->fCOL = AliTRDfeeParam::Instance()->GetPadColFromADC(fMCM->fROB, fMCM->fMCM, fADC->fADCnumber - 1);
2072 fADC->fCOL = fTRDfeeParam->GetPadColFromADC(fMCM->fROB, fMCM->fMCM, fADC->fADCnumber);
2075 if (fADC->fCorrupted > 0)
2083 //--------------------------------------------------------
2086 AliTRDrawStreamTB::DecodeADCTP23(unsigned long *expected)
2089 // decode test pattern ADC channel
2092 fADC->fCorrupted = 0;
2096 for (Int_t i = 0; i < TRD_MAX_TBINS; i++)
2097 fADC->fSignals[i] = 0;
2099 for (Int_t iw = 0; iw < fMCM->fSingleADCwords; iw++)
2101 if (*fpPos == END_OF_TRACKLET_MARKERNEW)
2103 if (fgWarnError) AliError(Form("There should be ADC data. We meet END_OF_TRACKLET_MARKER 0x%08x",*fpPos));
2104 fADC->fCorrupted += 16;
2105 fHC->fCorrupted += 16;
2110 if (*fpPos != *expected)
2114 if (fHC->fRawVMajorOpt == 2)
2116 AliError(Form("Error: fpPos=%d, size=%d, found=0x%08lx, expected=0x%08lx",iw, fMCM->fSingleADCwords, *fpPos, *expected));
2117 AliError(Form("Found ev.cnt. %ld, expected %ld", (*fpPos >> 26), (*expected >> 26)));
2118 AliError(Form("Found sector %ld, expected %ld", (*fpPos >> 21) & 0x1f - 1, (*expected >> 21) & 0x1f - 1));
2119 AliError(Form("Found layer %ld, expected %ld", (*fpPos >> 18) & 0x07 - 1, (*expected >> 18) & 0x07 - 1));
2120 AliError(Form("Found chamber %ld, expected %ld", (*fpPos >> 15) & 0x07 - 1, (*expected >> 15) & 0x07 - 1));
2121 AliError(Form("Found ROB %ld, expected %ld", (*fpPos >> 12) & 0x07, (*expected >> 12) & 0x07));
2122 AliError(Form("Found MCM %ld, expected %ld", (*fpPos >> 8) & 0x0f, (*expected >> 8) & 0x0f));
2123 AliError(Form("Found CPU %ld, expected %ld", (*fpPos >> 6) & 0x03, (*expected >> 6) & 0x03));
2124 AliError(Form("Found counter %ld, expected %ld\n", (*fpPos >> 0) & 0x3f, (*expected >> 0) & 0xf));
2126 if (fHC->fRawVMajorOpt == 3)
2128 AliError(Form("Error: fpPos=%d, size=%d, found=0x%08lx, expected=0x%08lx",iw, fMCM->fSingleADCwords, *fpPos, *expected));
2129 AliError(Form("Found ev.cnt. %ld, expected %ld", (*fpPos >> 20), (*expected >> 20)));
2130 AliError(Form("Found sector %ld, expected %ld", (*fpPos >> 15) & 0x1f - 1, (*expected >> 15) & 0x1f - 1));
2131 AliError(Form("Found layer %ld, expected %ld", (*fpPos >> 12) & 0x07 - 1, (*expected >> 12) & 0x07 - 1));
2132 AliError(Form("Found chamber %ld, expected %ld", (*fpPos >> 9) & 0x07 - 1, (*expected >> 9) & 0x07 - 1));
2133 AliError(Form("Found ROB %ld, expected %ld", (*fpPos >> 6) & 0x07, (*expected >> 6) & 0x07));
2134 AliError(Form("Found MCM %ld, expected %ld", (*fpPos >> 2) & 0x0f, (*expected >> 2) & 0x0f));
2135 AliError(Form("Found CPU %ld, expected %ld\n", (*fpPos >> 0) & 0x03, (*expected >> 0) & 0x03));
2139 fADC->fCorrupted += 32; //test pattern corrupted
2141 fADC->fSignals[fTbinADC + 0] = ((*fpPos & 0x00000ffc) >> 2);
2142 fADC->fSignals[fTbinADC + 1] = ((*fpPos & 0x003ff000) >> 12);
2143 fADC->fSignals[fTbinADC + 2] = ((*fpPos & 0xffc00000) >> 22);
2147 if (fHC->fRawVMajorOpt == 2) (*expected)++;
2150 if (fADC->fADCnumber <= 1 || fADC->fADCnumber == fMaxADCgeom - 1)
2152 fADC->fIsShared = kTRUE;
2156 fADC->fIsShared = kFALSE;
2159 if ( fADC->fADCnumber >= fMaxADCgeom - 1)
2161 fADC->fCOL = AliTRDfeeParam::Instance()->GetPadColFromADC(fMCM->fROB, fMCM->fMCM, fADC->fADCnumber - 1);
2166 fADC->fCOL = fTRDfeeParam->GetPadColFromADC(fMCM->fROB, fMCM->fMCM, fADC->fADCnumber);
2169 if (fADC->fCorrupted > 0)
2177 //--------------------------------------------------------
2180 void AliTRDrawStreamTB::DecodeSMInfo(const UInt_t *word, struct AliTRDrawSM *sm) const
2183 // Decode the data *word into SM info structure
2186 sm->fPos = (UInt_t*)word;
2189 UInt_t vword = *word;
2190 sm->fHeaderSize = SM_HEADER_SIZE(vword);
2192 if (TRACKLETS_ENABLED(vword) > 0)
2193 sm->fTrackletEnable = kTRUE;
2195 sm->fTrackletEnable = kFALSE;
2197 UInt_t stackMask = STACK_MASK(vword);
2198 sm->fActiveStacks = 0;
2199 for (Int_t i = 0; i < 5; i++)
2201 //if ((stackMask >> i) & 0x1 > 0)
2202 if (IS_BIT_SET(stackMask,i) > 0)
2204 sm->fStackActive[i] = kTRUE;
2205 sm->fActiveStacks++;
2209 sm->fStackActive[i] = kFALSE;
2214 //--------------------------------------------------------
2215 const char *AliTRDrawStreamTB::DumpSMInfo(const struct AliTRDrawSM *sm)
2218 // Get SM structure into a const char
2221 return Form("[ SM Info 0x%08x] : Hsize %d TrackletEnable %d Stacks %d %d %d %d %d",
2223 sm->fHeaderSize, sm->fTrackletEnable,
2224 sm->fStackActive[0], sm->fStackActive[1], sm->fStackActive[2],
2225 sm->fStackActive[3], sm->fStackActive[4]);
2228 //--------------------------------------------------------
2229 void AliTRDrawStreamTB::DecodeStackInfo(const UInt_t *word, struct AliTRDrawStack *st) const
2232 // Decode stack info - active links
2235 st->fPos = (UInt_t*)word;
2238 UInt_t vword = *word;
2239 st->fHeaderSize = STACK_HEADER_SIZE(vword);
2241 UInt_t linkMask = STACK_LINK_WORD(vword);
2242 st->fActiveLinks = 0;
2243 for (Int_t i = 0; i < 12; i++)
2245 //if (linkMask & (0x1 << i) > 0)
2246 if (IS_BIT_SET(linkMask,i) > 0)
2248 st->fLinksActive[i] = kTRUE;
2249 st->fTrackletDecode[i] = kTRUE;
2250 st->fHCDecode[i] = kTRUE;
2255 st->fTrackletDecode[i] = kFALSE;
2256 st->fLinksActive[i] = kFALSE;
2257 st->fHCDecode[i] = kFALSE;
2262 //--------------------------------------------------------
2263 const char *AliTRDrawStreamTB::DumpStackInfo(const struct AliTRDrawStack *st)
2266 // format the string with the stack info
2268 return Form("[ Stack Info 0x%08x ] : Hsize %d Links Active %d %d %d %d %d %d %d %d %d %d %d %d",
2271 st->fLinksActive[0], st->fLinksActive[1], st->fLinksActive[2], st->fLinksActive[3],
2272 st->fLinksActive[4], st->fLinksActive[5], st->fLinksActive[6], st->fLinksActive[7],
2273 st->fLinksActive[8], st->fLinksActive[9], st->fLinksActive[10], st->fLinksActive[11]);
2276 //--------------------------------------------------------
2277 void AliTRDrawStreamTB::DecodeHCwordH0(const UInt_t *word, struct AliTRDrawHC *hc) const
2280 // decode the hc header word 0
2284 UInt_t vword = *word;
2286 hc->fCorrupted = HC_HEADER_MASK_ERR(vword);
2287 if (hc->fCorrupted > 0)
2289 hc->fH0ErrorCounter++;
2292 hc->fSpecialRawV = HC_SPECIAL_RAW_VERSION(vword);
2293 hc->fRawVMajor = HC_MAJOR_RAW_VERSION(vword);
2294 hc->fRawVMajorOpt = HC_MAJOR_RAW_VERSION_OPT(vword);
2295 hc->fRawVMinor = HC_MINOR_RAW_VERSION(vword);
2296 hc->fNExtraWords = HC_EXTRA_WORDS(vword);
2297 hc->fDCSboard = HC_DCS_BOARD(vword);
2298 hc->fSM = HC_SM_NUMBER(vword);
2299 hc->fStack = HC_STACK_NUMBER(vword);
2300 hc->fLayer = HC_LAYER_NUMBER(vword);
2301 hc->fSide = HC_SIDE_NUMBER(vword);
2303 hc->fPos[0] = (UInt_t*)word;
2307 //--------------------------------------------------------
2308 void AliTRDrawStreamTB::DecodeHCwordH1(const UInt_t *word, struct AliTRDrawHC *hc) const
2315 UInt_t vword = *word;
2317 hc->fCorrupted += 2 * HC_HEADER_MASK_ERR(vword);
2318 if (hc->fCorrupted >= 2)
2320 hc->fH1ErrorCounter++;
2323 hc->fTimeBins = HC_NTIMEBINS(vword);
2324 hc->fBunchCrossCounter = HC_BUNCH_CROSS_COUNTER(vword);
2325 hc->fPreTriggerCounter = HC_PRETRIGGER_COUNTER(vword);
2326 hc->fPreTriggerPhase = HC_PRETRIGGER_PHASE(vword);
2328 hc->fPos[1] = (UInt_t*)word;
2331 //--------------------------------------------------------
2332 const char *AliTRDrawStreamTB::DumpHCinfoH0(const struct AliTRDrawHC *hc)
2338 return Form("Unable to dump. Null received as parameter!?!");
2340 return Form("[ HC[0] at 0x%08x ] : 0x%08x Info is : RawV %d SM %d Stack %d Layer %d Side %d DCSboard %d",
2341 hc->fPos[0], *(hc->fPos[0]), hc->fRawVMajor, hc->fSM, hc->fStack, hc->fLayer, hc->fSide, hc->fDCSboard);
2344 //--------------------------------------------------------
2345 const char *AliTRDrawStreamTB::DumpHCinfoH1(const struct AliTRDrawHC *hc)
2351 return Form("Unable to dump. Null received as parameter!?!");
2353 return Form("[ HC[1] at 0x%08x ] : 0x%08x Info is : TBins %d BCcount %d PreTrigCount %d PreTrigPhase %d",
2354 hc->fPos[1], *(hc->fPos[1]), hc->fTimeBins, hc->fBunchCrossCounter, hc->fPreTriggerCounter, hc->fPreTriggerPhase);
2357 //--------------------------------------------------------
2358 void AliTRDrawStreamTB::DecodeMCMheader(const UInt_t *word, struct AliTRDrawMCM *mcm) const
2361 // decode the mcm header
2364 UInt_t vword = *word;
2366 if (vword == END_OF_TRACKLET_MARKERNEW)
2368 if (fgWarnError) AliError(Form("There should be MCM header. We meet END_OF_TRACKLET_MARKER 0x%08x",vword));
2369 mcm->fCorrupted += 16;
2370 fHC->fCorrupted += 16; //to finish data reading of this HC
2372 mcm->fCorrupted = MCM_HEADER_MASK_ERR(vword); //if MCM header mask has error, set mcm->fCorrupted = 1
2373 if (mcm->fCorrupted)
2374 mcm->fErrorCounter++;
2375 mcm->fROB = MCM_ROB_NUMBER(vword);
2376 mcm->fMCM = MCM_MCM_NUMBER(vword);
2377 mcm->fEvCounter = MCM_EVENT_COUNTER(vword);
2378 mcm->fPos = (UInt_t*)word;
2381 //--------------------------------------------------------
2382 UInt_t AliTRDrawStreamTB::GetMCMadcMask(const UInt_t *word, struct AliTRDrawMCM *mcm) const
2388 UInt_t vword = *word;
2394 mcm->fADCMaskWord = vword;
2396 if (vword == END_OF_TRACKLET_MARKERNEW)
2398 if (fgWarnError) AliError(Form("There should be MCMadcMask. We meet END_OF_TRACKLET_MARKER 0x%08x",vword));
2399 mcm->fCorrupted += 16;
2400 fHC->fCorrupted += 16; //to finish data reading of this HC
2403 if ( MCM_ADCMASK_MASK_ERR(vword) == 0 )
2405 mcm->fADCMask = MCM_ADCMASK_VAL(vword);
2406 mcm->fADCcount = MCM_ADCMASK_NADC(~vword);
2410 mcm->fADCMask = 0xffffffff;
2411 mcm->fCorrupted += 4;
2412 mcm->fMaskErrorCounter++;
2415 return mcm->fADCMask;
2418 //--------------------------------------------------------
2419 void AliTRDrawStreamTB::DecodeMask(const UInt_t *word, struct AliTRDrawMCM *mcm) const
2422 // decode the adc mask - adcs to be read out
2425 mcm->fMCMADCWords = 0;
2426 mcm->fSingleADCwords = 0;
2428 mcm->fADCMask = GetMCMadcMask(word, mcm);
2430 if (mcm->fADCMask > 0)
2432 for (Int_t i = 0; i < TRD_MAX_ADC; i++)
2434 mcm->fADCchannel[mcm->fADCmax] = 0;
2435 if( IS_BIT_SET(mcm->fADCMask,i) )
2437 mcm->fADCchannel[mcm->fADCmax] = i;
2442 if (mcm->fADCcount != mcm->fADCmax && fHC->fRawVMajor >= 32) // backward compatibility
2444 mcm->fCorrupted += 8;
2448 //--------------------------------------------------------
2449 void AliTRDrawStreamTB::MCMADCwordsWithTbins(UInt_t fTbins, struct AliTRDrawMCM *mcm) const
2452 // count the expected mcm words for a given tbins
2454 mcm->fMCMADCWords = ( mcm->fADCmax ) * ( fTbins / 3 );
2455 mcm->fSingleADCwords = 0;
2456 if (mcm->fADCmax > 0)
2458 mcm->fSingleADCwords = mcm->fMCMADCWords/mcm->fADCmax;
2462 //--------------------------------------------------------
2463 const unsigned long AliTRDrawStreamTB::AdvancePseudoRandom(unsigned long *val) const
2466 // pseudo random number generator for test pattern data
2468 unsigned long currentVal = *val;
2470 *val = ( (*val << 1) | (((*val >> 9) ^ (*val >> 6)) & 1) ) & 0x3FF;
2474 //--------------------------------------------------------
2475 const char *AliTRDrawStreamTB::DumpMCMinfo(const struct AliTRDrawMCM *mcm)
2478 // mcm info in a string
2481 return Form("Unable to dump. Null received as parameter!?!");
2483 return Form("[ MCM 0x%08x ] : ROB %d MCM %d EvCounter %d", *(mcm->fPos), mcm->fROB, mcm->fMCM, mcm->fEvCounter);
2486 //--------------------------------------------------------
2487 //TString DumpMCMadcMask(const struct AliTRDrawMCMInfo *mcm)
2488 const char *AliTRDrawStreamTB::DumpMCMadcMask(const struct AliTRDrawMCM *mcm)
2491 // mcm adc mask in a string
2494 return Form("Unable to dump. Null received as parameter!?!");
2496 TString tsreturn = Form("[Word] : 0x%08x => [Mask] : 0x%08x : ", mcm->fADCMaskWord, mcm->fADCMask);
2497 for (Int_t i = 0; i < 21; i++)
2499 tsreturn += Form("%d ", mcm->fADCchannel[i]);
2502 return tsreturn.Data();