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 // Loop through the digits
684 // Int_t returnDet = -1;
692 // If new detector found
702 if (det < 0 || det >= AliTRDgeometry::kNdet)
704 if (fSM.fClean == kTRUE)
706 AliError(Form("Strange Det Number %d BUT event buffer seems to be clean.", det));
710 AliError(Form("Strange Det Number %d. Event buffer marked NOT clean!", det));
715 // Add a container for the digits of this detector
716 digits = (AliTRDdataArrayDigits *) digitsManager->GetDigits(det);
718 if (digitsManager->UsesDictionaries())
720 track0 = (AliTRDdataArrayI *) digitsManager->GetDictionary(det,0);
721 track1 = (AliTRDdataArrayI *) digitsManager->GetDictionary(det,1);
722 track2 = (AliTRDdataArrayI *) digitsManager->GetDictionary(det,2);
727 if (fSM.fClean == kTRUE)
729 AliError(Form("Unable to get digits for det %d BUT event buffer seems to be clean.", det));
733 AliError(Form("Unable to get digits for det %d. Event buffer is NOT clean!", det));
739 Int_t rowMax = GetRowMax();
740 Int_t colMax = GetColMax();
741 Int_t ntbins = GetNumberOfTimeBins();
743 // Allocate memory space for the digits buffer
744 if (digits->GetNtime() == 0)
746 digits->Allocate(rowMax, colMax, ntbins);
747 if (digitsManager->UsesDictionaries())
749 track0->Allocate(rowMax, colMax, ntbins);
750 track1->Allocate(rowMax, colMax, ntbins);
751 track2->Allocate(rowMax, colMax, ntbins);
755 indexes = digitsManager->GetIndexes(det);
756 indexes->SetSM(GetSM());
757 indexes->SetStack(GetStack());
758 indexes->SetLayer(GetLayer());
759 indexes->SetDetNumber(det);
760 if (indexes->IsAllocated() == kFALSE)
761 indexes->Allocate(rowMax, colMax, ntbins);
764 Char_t padStatus = cal->GetPadStatus(det, GetCol(), GetRow());
766 // ntimebins data are ready to read
767 for (it = 0; it < GetNumberOfTimeBins(); it++)
769 if ((GetSignals()[it] - adcBaseline) > 0)
771 digits->SetDataUnchecked(GetRow(), GetCol(), it, GetSignals()[it] - adcBaseline);
773 digits->SetPadStatus(GetRow(), GetCol(), it, padStatus);
775 indexes->AddIndexTBin(GetRow(), GetCol(), it);
776 if (digitsManager->UsesDictionaries())
778 track0->SetDataUnchecked(GetRow(), GetCol(), it, 0);
779 track1->SetDataUnchecked(GetRow(), GetCol(), it, 0);
780 track2->SetDataUnchecked(GetRow(), GetCol(), it, 0);
786 // what happens if the last HC is turned off?
791 //------------------------------------------------------------
793 AliTRDrawStreamTB::Init()
799 TDirectory *saveDir = gDirectory;
803 fGeometry = new AliTRDgeometry();
808 AliError("Geometry FAILED!");
812 fTRDfeeParam = AliTRDfeeParam::Instance();
815 AliError("AliTRDfeeParam FAILED!");
819 fMaxADCgeom = (Int_t)fGeometry->ADCmax();
821 // common additive is moved to be static for temp solution
822 // common additive should be delivered in the HC word 2 (3rd word)
823 //fCommonAdditive = 10;
827 if (fgDebugStreamFlag == kTRUE)
829 if (!fgDebugStreamer)
831 fgDebugStreamer = new TTreeSRedirector("TRDrawDataDebug.root");
832 fgStreamEventCounter = 0;
836 AliInfo(Form("Debug Streamer Initialized! Remember to delete! %s::DeleteDebugStream()", this->IsA()->GetName()));
837 //fDebugStreamOwned = kTRUE;
841 AliError("Unable to init debug stream");
846 // in case rawreader manages the mem buffers
847 // lets go for the next buffer
850 Int_t nextBuff = NextBuffer();
851 while (nextBuff != -1)
855 nextBuff = NextBuffer();
864 void AliTRDrawStreamTB::DeleteDebugStream()
867 // static helper function
872 delete fgDebugStreamer;
878 //------------------------------------------------------------
880 AliTRDrawStreamTB::InitBuffer(void *buffer, UInt_t length)
883 // init the class before reading from the buffer
884 // and read SM heading info:
885 // -- super module header
886 // -- stack headers + link status words
889 // not in the pre scan mode
891 if(fgStreamEventCounter == 0) fgFirstEquipmentID = fRawReader->GetEquipmentId();
892 fEquipmentID = fRawReader->GetEquipmentId();
893 //fgStreamEventCounter++;
894 if(fEquipmentID == fgFirstEquipmentID) fgStreamEventCounter++;
899 fpBegin = (UInt_t *)buffer;
903 AliFatal("Strange! Size of UInt_t == 0");
907 fWordLength = length/WORD_SIZE;
908 fpEnd = fpBegin + fWordLength;
911 if (fpBegin == 0 || length <= 0)
913 AliError(Form("This will not work! Pointer to the buffer is 0x%08x of size %d", fpBegin, length));
921 AliInfo("------------------------------------------------");
922 if (DumpWords(fpBegin, fgDumpHead) == kFALSE)
924 AliError("Dump failed. Not enough data.");
926 AliInfo("------------------------------------------------");
930 DecodeSMInfo(fpPos, &fSM);
932 if (fgDebugFlag) AliDebug(5, DumpSMInfo(&fSM));
937 if (SkipWords(fSM.fHeaderSize) == kTRUE)
940 //for (Int_t istack = 0; istack < fSM.fActiveStacks; istack++)
941 for (Int_t istack = 0; istack < 5; istack++)
943 if (fSM.fStackActive[istack] == kFALSE)
946 fStack = &fSM.fStacks[istack];
947 DecodeStackInfo(fpPos, fStack);
950 fSM.fNexpectedHalfChambers += fStack->fActiveLinks;
952 if (fgDebugFlag) AliDebug(5, DumpStackInfo(fStack));
954 if (SkipWords(fStack->fHeaderSize) == kFALSE)
956 if (fRawReader) fRawReader->AddMajorErrorLog(kDecodeStackInfo, "Stack head words missing");
968 if (fgWarnError) AliWarning("No Stack info present. Strange.");
969 if (fRawReader) fRawReader->AddMajorErrorLog(kDecodeStackInfo, "Stack info missing");
973 if (fgDebugFlag) AliDebug(5, Form("Expected half chambers : %d", fSM.fNexpectedHalfChambers));
978 if (fgDebugFlag) AliDebug(5, "Init OK.");
982 if (fgWarnError) AliWarning("No data just after init. Strange.");
983 if (fRawReader) fRawReader->AddMajorErrorLog(kMissingData, "Missing data");
990 //------------------------------------------------------------
992 AliTRDrawStreamTB::DecodeSM(void *buffer, UInt_t length)
995 // decode all sm at once
996 // still here for devel and debug
999 //memset(&fSM, 0, sizeof(fSM));
1004 if (InitBuffer(buffer, length) == kTRUE)
1006 // no we are already set!
1011 if (fgWarnError) AliError("--- INIT failed. ---------------");
1012 fSM.fClean = kFALSE;
1018 for (Int_t istack = 0; istack < 5; istack++)
1020 fStackNumber = istack;
1021 if (fSM.fStackActive[istack] == kFALSE)
1024 fStack = &fSM.fStacks[istack];
1026 //fStack[istack].fActiveLinks // max is 12
1027 for (Int_t ilink = 0; ilink < 12; ilink++)
1029 fStackLinkNumber = ilink;
1030 if (fStack->fLinksActive[ilink] == kFALSE)
1035 if (fRawReader) fRawReader->AddMajorErrorLog(kLinkDataMissing, "Link data missing");
1036 fSM.fClean = kFALSE;
1040 fHC = &fStack->fHalfChambers[ilink];
1042 if (fgDebugStreamer)
1044 TTreeSRedirector &cstream = *fgDebugStreamer;
1045 cstream << "LINKDataStream"
1046 << "Event=" << fgStreamEventCounter
1047 << ".equipID=" << fEquipmentID
1048 << ".stack=" << fStackNumber
1049 << ".link=" << fStackLinkNumber
1054 if (fSM.fTrackletEnable == kTRUE)
1056 if (DecodeTracklets() == kFALSE)
1058 if (fgDebugStreamer)
1060 TTreeSRedirector &cstream = *fgDebugStreamer;
1061 cstream << "TrackletDecodeError"
1062 << "Event=" << fgStreamEventCounter
1063 << ".Stack=" << fStackNumber
1064 << ".Link=" << fStackLinkNumber
1065 << ".EndOfTrackletCount=" << fEndOfTrackletCount
1069 fSM.fClean = kFALSE;
1074 AliError(Form("Failed stack %d link %d", fStackNumber, fStackLinkNumber));
1075 AliError(Form("Debug Event Counter : %d", fgStreamEventCounter));
1084 if (fRawReader) fRawReader->AddMajorErrorLog(kHCdataMissing, "HC data missing");
1085 fSM.fClean = kFALSE;
1089 if (DecodeHC() == kFALSE)
1091 fSM.fClean = kFALSE;
1094 AliError(Form("Dumping Words for Debugging Purpose =========================>"));
1095 DumpWords(fpPos-8, 16);
1096 AliError(Form("Dumping Done!"));
1098 if (fHC->fCorrupted < 16) SeekEndOfData(); // In case that we meet END_OF_TRACKLET_MARKERNEW during ADC data decoding or MCM header decoding
1099 // we don't seek ENDOFRAWDATAMARKER
1103 AliError(Form("Failed HC : %s", DumpHCinfoH0(fHC)));
1104 AliError(Form("Failed HC : %s", DumpHCinfoH1(fHC)));
1105 AliError(Form("Debug Event Counter : %d\n\n\n", fgStreamEventCounter));
1113 SeekEndOfData(); // make sure that finish off with the end of data markers
1122 if (fSM.fClean == kTRUE)
1125 if (fgCleanDataOnly && (fSM.fClean == kFALSE))
1129 AliWarning("Buffer with errors. Returning FALSE.");
1130 AliWarning(Form("--- Failed SM : %s ---", DumpSMInfo(&fSM)));
1132 fSM.fActiveStacks = 0; // Next will not give data
1139 //------------------------------------------------------------
1141 AliTRDrawStreamTB::DecodeSM()
1144 // decode SM data in case AliRawReader is in use
1148 Int_t nextBuff = NextBuffer();
1149 while (nextBuff != -1)
1153 nextBuff = NextBuffer();
1159 AliWarning("AliRawReader not set.");
1164 //------------------------------------------------------------
1166 AliTRDrawStreamTB::DecodeSM(AliRawReader *reader)
1169 // decode SM with the AliRawReader
1173 fRawReader = reader;
1178 AliWarning("Argument AliRawReader is 0.");
1183 //------------------------------------------------------------
1185 AliTRDrawStreamTB::SeekEndOfData()
1188 // go to end of data marker
1190 Int_t fEndOfDataCount = 0;
1192 while ( *fpPos != ENDOFRAWDATAMARKER && fpPos < fpEnd )
1197 while (*fpPos == ENDOFRAWDATAMARKER && fpPos < fpEnd )
1203 // if (fEndOfDataCount == 0)
1205 // if (fgWarnError) AliWarning("End of buffer reached first. No end of data marker?");
1212 //------------------------------------------------------------
1214 AliTRDrawStreamTB::SeekNextMCMheader()
1220 // move back to the mcm pos
1221 fpPos = fMCM->fPos + 1;
1223 while ( *fpPos != ENDOFRAWDATAMARKER && fpPos < fpEnd )
1225 if (MCM_HEADER_MASK_ERR(*fpPos) == 0)
1227 if (fgWarnError) AliWarning(Form("^^^ Found : Pos 0x%08x : Val 0x%08x", fpPos, *fpPos));
1237 //------------------------------------------------------------
1240 AliTRDrawStreamTB::DecodeTracklets()
1246 fLinkTrackletCounter = 0;
1247 fEndOfTrackletCount = 0;
1249 if (fgDebugFlag) AliDebug(10, Form("Decode tracklets at 0x%08x : 0x%08x", fpPos, *fpPos));
1251 while ( *fpPos != END_OF_TRACKLET_MARKEROLD && *fpPos != END_OF_TRACKLET_MARKERNEW && fpPos < fpEnd )
1254 if (fgDebugFlag) AliDebug(10, Form("Tracklet found at 0x%08x : 0x%08x", fpPos, *fpPos));
1256 fLinkTrackletCounter++;
1258 if (fLinkTrackletCounter > MAX_TRACKLETS_PERHC)
1260 if (fgWarnError) AliWarning(Form("Max number of tracklets exceeded %d > %d. Something is wrong with the input data!",
1261 fLinkTrackletCounter, MAX_TRACKLETS_PERHC));
1265 AliError(Form("Dumping Words for Debugging Purpose =========================>"));
1266 DumpWords(fpPos-300, 320);
1267 AliError(Form("Dumping Done!"));
1271 if (fRawReader) fRawReader->AddMajorErrorLog(kTrackletOverflow,"Too many tracklets");
1275 if (fgDebugStreamer)
1291 row = (val >> 20) & 0xF;
1292 defl = (val >> 13) & 0x7F;
1293 defl = defl << 25 >> 25;
1294 ypos = val & 0x1FFF;
1295 ypos = ypos << 19 >> 19;
1297 deflm = defl * 140.0e-6; /* m */
1298 yposm = ypos * 160.0e-6; /* m */
1300 TTreeSRedirector &cstream = *fgDebugStreamer;
1301 cstream << "MCMtracklets"
1302 << "Event=" << fgStreamEventCounter
1303 << ".stack=" << fStackNumber
1304 << ".link=" << fStackLinkNumber
1309 << ".deflm=" << deflm
1310 << ".yposm=" << yposm
1316 while ( ( *fpPos == END_OF_TRACKLET_MARKEROLD || *fpPos == END_OF_TRACKLET_MARKERNEW ) && fpPos < fpEnd )
1318 if (fgDebugFlag) AliDebug(10, Form("EoTracklets found at 0x%08x : 0x%08x", fpPos, *fpPos));
1320 fEndOfTrackletCount++;
1324 if ( fEndOfTrackletCount < 2 )
1326 if (fRawReader) fRawReader->AddMajorErrorLog(kEOTrackeltsMissing, "End of tracklets word missing");
1333 //------------------------------------------------------------
1335 AliTRDrawStreamTB::IsRowValid()
1338 if ( (fHC->fStack == 2 && fMCM->fROW >= fGeometry->RowmaxC0()) ||
1339 (fHC->fStack != 2 && fMCM->fROW >= fGeometry->RowmaxC1()) || fMCM->fROW < 0 )
1341 if (fgWarnError) AliWarning(Form("SM%d L%dS%d: Wrong Padrow (%d) fROB=%d, fSIDE=%d, fMCM=%02d"
1342 , fHC->fSM, fHC->fLayer, fHC->fStack, fMCM->fROW, fMCM->fROB, fHC->fSide, fMCM->fMCM ));
1343 if (fRawReader) fRawReader->AddMajorErrorLog(kWrongPadrow, "Wrong Row");
1349 //------------------------------------------------------------
1351 AliTRDrawStreamTB::IsMCMheaderOK()
1354 // check the mcm header
1357 if ( fMCM->fCorrupted > 1 )
1359 if (fRawReader) fRawReader->AddMajorErrorLog(kMCMheaderCorrupted,"ADC mask Corrupted");
1360 if (fgWarnError) AliWarning(Form("Wrong ADC Mask word 0x%08x %s. Error : %d\n", *fMCM->fPos, DumpMCMadcMask(fMCM), fMCM->fCorrupted));
1364 if ( fMCM->fCorrupted > 0 )
1366 if (fRawReader) fRawReader->AddMajorErrorLog(kMCMheaderCorrupted,"Corrupted");
1367 if (fgWarnError) AliWarning(Form("Wrong MCM word 0x%08x %s. Error : %d\n", *fMCM->fPos, DumpMCMinfo(fMCM), fMCM->fCorrupted));
1371 if ( fMCM->fMCM < 0 || fMCM->fMCM > 15 || fMCM->fROB < 0 || fMCM->fROB > 7 )
1373 if (fRawReader) fRawReader->AddMajorErrorLog(kWrongMCMorROB,"Wrong ROB or MCM");
1374 if (fgWarnError) AliWarning(Form("Wrong fMCM or fROB. %s\n", DumpMCMinfo(fMCM)));
1378 if (IsRowValid() == kFALSE)
1384 //------------------------------------------------------------
1386 AliTRDrawStreamTB::IsMCMevCounterOK()
1389 // Check the MCM event counter
1392 if (fEventCounter == 0)
1394 fEventCounter = fMCM->fEvCounter;
1397 if (fEventCounter < fLastEventCounter)
1399 fMCM->fCorrupted += 2;
1400 if (fgWarnError) AliWarning(Form("Event from the past? Current %d Last %d %s. Error : %d\n", fEventCounter, fLastEventCounter, DumpMCMinfo(fMCM), fMCM->fCorrupted));
1401 if (fRawReader) fRawReader->AddMajorErrorLog(kMCMeventMissmatch, "Wrong MCM event counter ? Past-Future");
1405 if (fEventCounter != fMCM->fEvCounter)
1407 fMCM->fCorrupted += 2;
1408 if (fgWarnError) AliWarning(Form("Event missmatch? FirstMCMs %d ThisMCMs %d %s. Error : %d\n", fEventCounter, fMCM->fEvCounter, DumpMCMinfo(fMCM), fMCM->fCorrupted));
1409 if (fRawReader) fRawReader->AddMajorErrorLog(kMCMeventMissmatch, "Wrong MCM event counter ?");
1416 //------------------------------------------------------------
1418 AliTRDrawStreamTB::DecodeMCMheader()
1421 // decode the mcm header
1424 DecodeMCMheader(fpPos, fMCM);
1425 if (fHC->fCorrupted >= 16)
1431 fMCM->fROW = fTRDfeeParam->GetPadRowFromMCM(fMCM->fROB, fMCM->fMCM);
1433 if ((fHC->fRawVMajor > 2 && fHC->fRawVMajor <5) || (fHC->fRawVMajor > 31 && fHC->fRawVMajor < 64)) //cover old and new version definition of ZS data
1436 if ( fpPos < fpEnd )
1438 DecodeMask(fpPos, fMCM);
1439 if (fHC->fCorrupted >= 16)
1444 MCMADCwordsWithTbins(fHC->fTimeBins, fMCM);
1445 fMCM->fAdcDataPos = fpPos + 1;
1449 if (fgWarnError) AliWarning("Expected ADC mask word. Fail due to buffer END.");
1450 if (fRawReader) fRawReader->AddMajorErrorLog(kMCMADCMaskMissing,"Missing");
1456 UInt_t dummyMask = MCM_DUMMY_ADCMASK_VAL;
1457 DecodeMask(&dummyMask, fMCM);
1458 MCMADCwordsWithTbins(fHC->fTimeBins, fMCM);
1459 fMCM->fAdcDataPos = fpPos + 1;
1464 AliDebug(6, DumpMCMinfo(fMCM));
1465 AliDebug(7, DumpMCMadcMask(fMCM));
1468 if (IsMCMheaderOK() == kFALSE)
1471 if (IsMCMevCounterOK() == kFALSE)
1477 //------------------------------------------------------------
1479 AliTRDrawStreamTB::IsHCheaderOK()
1482 // check the half chamber header
1485 if (fHC->fCorrupted > 0)
1487 if (fgWarnError) AliWarning(Form("Wrong HC Header word. Word 0x%08x Error : %d", *fHC->fPos, fHC->fCorrupted));
1488 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderCorrupt, "Corrupted");
1493 if (fHC->fStack < 0 || fHC->fStack > 4)
1495 if (fgWarnError) AliWarning(Form("Wrong Stack %d", fHC->fStack));
1496 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongStack, "Wrong Stack");
1500 if (fgStackNumberChecker)
1502 if (fHC->fStack != fStackNumber)
1504 if (fgWarnError) AliWarning(Form("Missmatch: Stack in HC header %d HW-stack %d",
1505 fHC->fStack, fStackNumber));
1506 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongStack, "Stack-HWstack");
1512 if (fHC->fLayer < 0 || fHC->fLayer >= AliTRDgeometry::kNplan)
1514 if (fgWarnError) AliWarning(Form("Wrong plane(layer) %d", fHC->fLayer));
1515 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongLayer, "Wrong Plane");
1519 if (fgStackLinkNumberChecker)
1522 if ((fHC->fLayer * 2 != fStackLinkNumber) && (fHC->fLayer * 2 != fStackLinkNumber - 1))
1524 if (fgWarnError) AliWarning(Form("Missmatch: plane(layer) in HCheader %d HW-Link %d | %s",
1525 fHC->fLayer, fStackLinkNumber, DumpStackInfo(fStack)));
1526 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongLayer, "Plane-Link missmatch");
1527 fStackLinkNumber = -1;
1532 if (fHC->fSide < 0 || fHC->fSide > 1)
1534 if (fgWarnError) AliWarning(Form("Wrong Side %d", fHC->fSide));
1535 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongSide, "Wrong Side");
1540 fHC->fDET = fGeometry->GetDetector(fHC->fLayer, fHC->fStack, fHC->fSM);
1541 if (fHC->fDET < 0 || fHC->fDET >= AliTRDgeometry::kNdet)
1543 if (fgWarnError) AliWarning(Form("Wrong detector %d", fHC->fDET));
1544 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongDet, "Wrong Det");
1549 // this check fails - raw data inconsistent with geometry?
1550 if (fHC->fSM != fGeometry->GetSector(fHC->fDET)
1551 || fHC->fSM <0 || fHC->fSM >= AliTRDgeometry::kNsect)
1553 if (fgWarnError) AliWarning(Form("Wrong SM(sector) %d (Geometry says: %d) Stack=%d Layer=%d Det=%d",
1554 fHC->fSM, fGeometry->GetSector(fHC->fDET),
1555 fHC->fStack, fHC->fLayer, fHC->fDET));
1556 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongSM, "Wrong SM");
1562 fHC->fROC = fGeometry->GetDetectorSec(fHC->fLayer, fHC->fStack);
1565 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongROC, "Wrong ROC");
1569 fHC->fRowMax = fGeometry->GetRowMax(fHC->fLayer, fHC->fStack, fHC->fSM);
1570 if (fHC->fRowMax < 1)
1572 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongROC, "Wrong ROC Row Max");
1576 fHC->fColMax = fGeometry->GetColMax(fHC->fROC);
1577 if (fHC->fColMax < 1)
1579 if (fRawReader) fRawReader->AddMajorErrorLog(kHCHeaderWrongROC, "Wrong ROC Col Max");
1582 // extra - not needed
1583 // if (fHC->fSM <0 || fHC->fSM >= AliTRDgeometry::kNsect)
1585 // if (fgWarnError) AliWarning(Form("Wrong SM(sector) %d (Geometry says: %d) Stack=%d Layer=%d",
1586 // fHC->fSM, fGeometry->GetDetectorSec(fHC->fLayer, fHC->fStack),
1587 // fHC->fStack, fHC->fLayer));
1594 //------------------------------------------------------------
1596 AliTRDrawStreamTB::DecodeHCheader()
1599 // decode the half chamber header
1602 DecodeHCwordH0(fpPos, fHC);
1604 if (fHC->fNExtraWords > 0)
1609 DecodeHCwordH1(fpPos, fHC);
1613 if (fgWarnError) AliWarning("Expected HC header word 1. Fail due to buffer END.");
1614 if (fRawReader) fRawReader->AddMajorErrorLog(kHCWordMissing,"Next HC word 1 (count from 0) missing");
1619 if (fgDebugFlag) AliDebug(5, DumpHCinfoH0(fHC));
1620 if (fgDebugFlag) AliDebug(5, DumpHCinfoH1(fHC));
1623 if (IsHCheaderOK() == kFALSE)
1625 if(fHC->fCorrupted < 1) fHC->fCorrupted +=4;
1632 //------------------------------------------------------------
1634 AliTRDrawStreamTB::DecodeHC()
1637 // decode the hc data
1638 // function for devel & debug
1641 if (DecodeHCheader() == kFALSE)
1643 if (fgDebugStreamer)
1645 TTreeSRedirector &cstream = *fgDebugStreamer;
1646 cstream << "HCDecodeError"
1647 << "Event=" << fgStreamEventCounter
1648 << ".stack=" << fStackNumber
1649 << ".link=" << fStackLinkNumber
1650 << ".hcCorrupted=" << fHC->fCorrupted
1651 << ".hcRVmajor=" << fHC->fRawVMajor
1652 << ".hcDCSboard=" << fHC->fDCSboard
1653 << ".hcSM=" << fHC->fSM
1654 << ".hcStack=" << fHC->fStack
1655 << ".hcLayer=" << fHC->fLayer
1656 << ".hcSide=" << fHC->fSide
1657 << ".hcTbins=" << fHC->fTimeBins
1658 << ".hcBunchCross=" << fHC->fBunchCrossCounter
1659 << ".hcPreTrig=" << fHC->fPreTriggerCounter
1660 << ".hcPreTrigPh=" << fHC->fPreTriggerPhase
1661 << ".hcDet=" << fHC->fDET
1662 << ".hcROC=" << fHC->fROC
1663 << ".hcRowMax=" << fHC->fRowMax
1664 << ".hcColMax=" << fHC->fColMax
1668 if (fgWarnError) AliWarning("Header decode failed.");
1676 if (fgWarnError) AliWarning("No MCM data? Not enough data in the buffer.");
1677 if (fRawReader) fRawReader->AddMajorErrorLog(kMCMdataMissing, "MCM data missing");
1683 while (*fpPos != ENDOFRAWDATAMARKER && fpPos < fpEnd)
1685 if (fHC->fMCMmax > TRD_MAX_MCM)
1687 if (fgWarnError) AliWarning("More mcm data than expected!");
1688 if (fRawReader) fRawReader->AddMajorErrorLog(kMCMoverflow, "Too many mcms found!");
1692 fMCM = &fHC->fMCMs[fHC->fMCMmax];
1694 if (DecodeMCMheader() == kFALSE)
1696 if (fgDebugStreamer)
1698 TTreeSRedirector &cstream = *fgDebugStreamer;
1699 cstream << "MCMDecodeError"
1700 << "Event=" << fgStreamEventCounter
1701 << ".stack=" << fStackNumber
1702 << ".link=" << fStackLinkNumber
1703 << ".hcDCSboard=" << fHC->fDCSboard
1704 << ".hcSM=" << fHC->fSM
1705 << ".hcStack=" << fHC->fStack
1706 << ".hcLayer=" << fHC->fLayer
1707 << ".hcSide=" << fHC->fSide
1708 << ".hcBunchCross=" << fHC->fBunchCrossCounter
1709 << ".hcPreTrig=" << fHC->fPreTriggerCounter
1710 << ".hcPreTrigPh=" << fHC->fPreTriggerPhase
1711 << ".hcDet=" << fHC->fDET
1713 << ".mcmCorrupted=" << fMCM->fCorrupted
1714 << ".mcmROB=" << fMCM->fROB
1715 << ".mcmMCM=" << fMCM->fMCM
1716 << ".mcmADCMaskWord=" << fMCM->fADCMaskWord
1717 << ".mcmEventCounter=" << fMCM->fEvCounter
1719 << ".fEventCounter=" << fEventCounter
1720 << ".fLastEventCounter=" << fLastEventCounter
1724 if (fgSkipData == kTRUE || fHC->fCorrupted >= 16)
1725 return kFALSE; //if(true), keep reading next words even previous words were corrupted - debugging purpose
1730 if (fMCM->fADCmax > 0)
1735 if (fgDebugFlag) AliDebug(9, Form("Buffer short of data. ADC data expected."));
1736 if (fRawReader) fRawReader->AddMajorErrorLog(kADCdataMissing, "ADC data missing");
1739 unsigned long randVal, iniVal, expectedVal;
1740 Int_t endbits = ENDBITS;
1742 for (Int_t iadc = 0; iadc < fMCM->fADCmax; iadc++)
1744 fADC = &fMCM->fADCs[iadc];
1745 fADC->fADCnumber = fMCM->fADCchannel[iadc];
1747 if (fgDebugFlag) AliDebug(9, Form("This is ADC %d of %d. ADC number is %d.",
1748 iadc+1, fMCM->fADCmax, fMCM->fADCchannel[iadc]));
1750 if (fpPos + fMCM->fSingleADCwords >= fpEnd)
1752 if (fgDebugStreamer)
1754 TTreeSRedirector &cstream = *fgDebugStreamer;
1756 cstream << "ADCDecodeError"
1757 << "Event=" << fgStreamEventCounter
1758 << ".hcSM=" << fHC->fSM
1759 << ".hcStack=" << fHC->fStack
1760 << ".hcLayer=" << fHC->fLayer
1761 << ".hcSide=" << fHC->fSide
1762 << ".hcDet=" << fHC->fDET
1763 << ".mcmROB=" << fMCM->fROB
1764 << ".mcmMCM=" << fMCM->fMCM
1765 << ".mcmADCMaskWord=" << fMCM->fADCMaskWord
1766 << ".adcErr=" << ierr
1767 << ".adcNumber=" << ierr
1771 if (fgWarnError) AliWarning(Form("This is ADC %d of %d. ADC number is %d.", iadc+1, fMCM->fADCmax, fMCM->fADCchannel[iadc]));
1772 if (fgWarnError) AliWarning("--> ADC (10 words) expected. Not enough data in the buffer.");
1773 if (fgWarnError) AliWarning(Form("--> ADC mask : %s", DumpMCMadcMask(fMCM)));
1775 if (fRawReader) fRawReader->AddMajorErrorLog(kADCdataMissing, "ADC data missing - less than expected");
1779 if (fHC->fRawVMajor < 64) // normal(real) ADC data
1781 if (DecodeADC() == kFALSE)
1783 // check if we are out of the det when the pad is shared
1784 if (fADC->fIsShared && fADC->fCorrupted == 4)
1787 fpPos = fADC->fPos + fMCM->fSingleADCwords;
1791 if (fgWarnError) AliWarning(Form("ADC decode failed."));
1793 if (fgDebugStreamer)
1795 TTreeSRedirector &cstream = *fgDebugStreamer;
1796 cstream << "ADCDecodeError"
1797 << "Event=" << fgStreamEventCounter
1798 << ".hcSM=" << fHC->fSM
1799 << ".hcStack=" << fHC->fStack
1800 << ".hcLayer=" << fHC->fLayer
1801 << ".hcSide=" << fHC->fSide
1802 << ".hcDet=" << fHC->fDET
1803 << ".mcmROB=" << fMCM->fROB
1804 << ".mcmMCM=" << fMCM->fMCM
1805 << ".mcmADCMaskWord=" << fMCM->fADCMaskWord
1806 << ".adcErr=" << fADC->fCorrupted
1807 << ".adcNumber=" << fADC->fADCnumber
1810 if (fHC->fCorrupted < 16)
1811 fpPos = fADC->fPos + fMCM->fSingleADCwords;
1813 if (fgSkipData == kTRUE || fHC->fCorrupted >= 16)
1814 return kFALSE; //if(true), keep reading next words even previous words were corrupted - debugging purpose
1818 else // test pattern data
1820 if (fHC->fRawVMajorOpt == 1) //test pattern 1
1822 Int_t iCpu = iadc/5;
1823 if(iadc==20) iCpu = 3;
1824 if(iadc%5==0 && iadc!=20) randVal = (1 << 9) | (fMCM->fROB << 6) | (fMCM->fMCM << 2) | iCpu;
1825 if (DecodeADCTP1(&randVal,&endbits) == kFALSE)
1827 if (fgWarnError) AliWarning(Form("Summary: Test Pattern ADC data are corrupted in channel %d %s\n", iadc, DumpMCMinfo(fMCM)));
1828 if (fgDebugStreamer)
1830 TTreeSRedirector &cstream = *fgDebugStreamer;
1831 cstream << "ADCDecodeError"
1832 << "Event=" << fgStreamEventCounter
1833 << ".hcSM=" << fHC->fSM
1834 << ".hcStack=" << fHC->fStack
1835 << ".hcLayer=" << fHC->fLayer
1836 << ".hcSide=" << fHC->fSide
1837 << ".hcDet=" << fHC->fDET
1838 << ".mcmROB=" << fMCM->fROB
1839 << ".mcmMCM=" << fMCM->fMCM
1840 << ".mcmADCMaskWord=" << fMCM->fADCMaskWord
1841 << ".adcErr=" << fADC->fCorrupted
1842 << ".adcNumber=" << fADC->fADCnumber
1845 if (fHC->fCorrupted < 16)
1846 fpPos = fADC->fPos + fMCM->fSingleADCwords;
1848 if (fgSkipData == kTRUE || fHC->fCorrupted >= 16)
1849 return kFALSE; //if(true), keep reading next words even previous words were corrupted - debugging purpose
1853 if (fHC->fRawVMajorOpt == 2 || fHC->fRawVMajorOpt == 3) //test pattern 2 or 3
1855 iniVal = (fHC->fSM << 6) | (fHC->fStack << 0) | (fHC->fLayer << 3);
1856 iniVal = iniVal + 0x49;
1857 iniVal = (iniVal << 9) | (fMCM->fROB << 6) | (fMCM->fMCM << 2) | (fMCM->fEvCounter << 20);
1858 Int_t iCpu = iadc/5;
1859 if (iadc==20) iCpu = 3;
1860 if (iadc%5==0 && iadc!=20)
1862 if (fHC->fRawVMajorOpt == 2) { expectedVal = ((iniVal | iCpu) << 6) + 1; };
1863 if (fHC->fRawVMajorOpt == 3) { expectedVal = iniVal | iCpu; };
1865 if (DecodeADCTP23(&expectedVal) == kFALSE)
1867 if (fgWarnError) AliWarning(Form("Summary: Test Pattern ADC data are corrupted in channel %d %s\n", iadc, DumpMCMinfo(fMCM)));
1868 if (fgDebugStreamer)
1870 TTreeSRedirector &cstream = *fgDebugStreamer;
1871 cstream << "ADCDecodeError"
1872 << "Event=" << fgStreamEventCounter
1873 << ".hcSM=" << fHC->fSM
1874 << ".hcStack=" << fHC->fStack
1875 << ".hcLayer=" << fHC->fLayer
1876 << ".hcSide=" << fHC->fSide
1877 << ".hcDet=" << fHC->fDET
1878 << ".mcmROB=" << fMCM->fROB
1879 << ".mcmMCM=" << fMCM->fMCM
1880 << ".mcmADCMaskWord=" << fMCM->fADCMaskWord
1881 << ".adcErr=" << fADC->fCorrupted
1882 << ".adcNumber=" << fADC->fADCnumber
1885 if (fHC->fCorrupted < 16)
1886 fpPos = fADC->fPos + fMCM->fSingleADCwords;
1888 if (fgSkipData == kTRUE || fHC->fCorrupted >= 16)
1889 return kFALSE; //if(true), keep reading next words even previous words were corrupted - debugging purpose
1903 if (fgWarnError) AliWarning("We are at the end of buffer. There should be one more word left.");
1909 //------------------------------------------------------------
1912 AliTRDrawStreamTB::DecodeADC()
1915 // decode single ADC channel
1918 fADC->fCorrupted = 0;
1919 //fMaskADCword = ADC_WORD_MASK(*fpPos);
1920 if(fADC->fADCnumber%2==1) fMaskADCword = ADC_WORD_MASK(ADCDATA_VAL1);
1921 if(fADC->fADCnumber%2==0) fMaskADCword = ADC_WORD_MASK(ADCDATA_VAL2);
1926 for (Int_t i = 0; i < TRD_MAX_TBINS; i++)
1927 fADC->fSignals[i] = 0;
1929 for (Int_t iw = 0; iw < fMCM->fSingleADCwords; iw++)
1931 if (HC_HEADER_MASK_ERR(*fpPos) == 0 || *fpPos == END_OF_TRACKLET_MARKERNEW)
1933 if (fgWarnError) AliError(Form("There should be ADC data. We meet HC header or END_OF_TRACKLET_MARKER 0x%08x",*fpPos));
1934 fADC->fCorrupted += 16;
1935 fHC->fCorrupted += 16;
1940 if (fMaskADCword != ADC_WORD_MASK(*fpPos))
1942 fADC->fCorrupted += 1;
1943 if (fgWarnError) AliWarning(Form("Wrong ADC data mask! ADC channel number: %02d [Expected mask: 0x%08x Current mask: 0x%08x] MCM= %s Error : %d",
1944 fADC->fADCnumber, fMaskADCword, ADC_WORD_MASK(*fpPos),DumpMCMinfo(fMCM),fADC->fCorrupted));
1945 //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",
1946 // iw - 1, *(fpPos-1), fMaskADCword, iw, *fpPos, ADC_WORD_MASK(*fpPos)));
1947 if (fRawReader) fRawReader->AddMajorErrorLog(kADCmaskMissmatch, "Mask change inside single channel");
1951 // here we subtract the baseline ( == common additive)
1952 fADC->fSignals[fTbinADC + 0] = ((*fpPos & 0x00000ffc) >> 2) - fgCommonAdditive;
1953 fADC->fSignals[fTbinADC + 1] = ((*fpPos & 0x003ff000) >> 12) - fgCommonAdditive;
1954 fADC->fSignals[fTbinADC + 2] = ((*fpPos & 0xffc00000) >> 22) - fgCommonAdditive;
1960 if (fADC->fADCnumber <= 1 || fADC->fADCnumber == fMaxADCgeom - 1)
1962 fADC->fIsShared = kTRUE;
1966 fADC->fIsShared = kFALSE;
1969 if ( fADC->fADCnumber >= fMaxADCgeom - 1)
1971 // let us guess the Column
1972 // take the one before last ADC and shift by one column
1973 // later we check if we are inside the limits of the chamber
1974 fADC->fCOL = AliTRDfeeParam::Instance()->GetPadColFromADC(fMCM->fROB, fMCM->fMCM, fADC->fADCnumber - 1);
1979 fADC->fCOL = fTRDfeeParam->GetPadColFromADC(fMCM->fROB, fMCM->fMCM, fADC->fADCnumber);
1982 if (fADC->fCOL >= fHC->fColMax || fADC->fCOL < 0)
1984 if (fADC->fIsShared == kFALSE)
1986 fADC->fCorrupted += 2;
1987 if (fgWarnError) AliWarning(Form("Wrong column! ADCnumber %d MaxIs %d Col %d MaxIs %d MCM= %s",
1988 fADC->fADCnumber, fMaxADCgeom, fADC->fCOL, fHC->fColMax, DumpMCMinfo(fMCM)));
1989 if (fRawReader) fRawReader->AddMajorErrorLog(kWrongPadcolumn, "Wrong column");
1993 // flag it - we are out of the det when the pad is shared
1994 if (fgDebugFlag) AliDebug(10, Form("Column out of the detector! ADCnumber %d MaxIs %d Col %d MaxIs %d MCM= %s",
1995 fADC->fADCnumber, fMaxADCgeom, fADC->fCOL, fHC->fColMax, DumpMCMinfo(fMCM)));
1996 fADC->fCorrupted += 4;
2000 if (fADC->fCorrupted > 0)
2008 //------------------------------------------------------------
2011 AliTRDrawStreamTB::DecodeADCTP1(unsigned long *randVal, Int_t *endbits)
2014 // decode test pattern ADC channel
2017 unsigned long expected;
2019 fADC->fCorrupted = 0;
2023 for (Int_t i = 0; i < TRD_MAX_TBINS; i++)
2024 fADC->fSignals[i] = 0;
2026 for (Int_t iw = 0; iw < fMCM->fSingleADCwords; iw++)
2028 if (HC_HEADER_MASK_ERR(*fpPos) == 0 || *fpPos == END_OF_TRACKLET_MARKERNEW)
2030 if (fgWarnError) AliError(Form("There should be ADC data. We meet HC header or END_OF_TRACKLET_MARKER 0x%08x",*fpPos));
2031 fADC->fCorrupted += 16;
2032 fHC->fCorrupted += 16;
2037 expected = (AdvancePseudoRandom(randVal) << 2) | *endbits;
2038 expected |= AdvancePseudoRandom(randVal) << 12;
2039 expected |= AdvancePseudoRandom(randVal) << 22;
2040 if (*fpPos != expected)
2042 if (fgWarnError) AliError(Form("Error: fpPos=%d, size=%d, found=0x%08lx, expected=0x%08lx",iw, fMCM->fSingleADCwords, *fpPos, expected));
2043 fADC->fCorrupted += 32; //test pattern corrupted
2045 fADC->fSignals[fTbinADC + 0] = ((*fpPos & 0x00000ffc) >> 2);
2046 fADC->fSignals[fTbinADC + 1] = ((*fpPos & 0x003ff000) >> 12);
2047 fADC->fSignals[fTbinADC + 2] = ((*fpPos & 0xffc00000) >> 22);
2052 *endbits = *endbits ^ 0x01;
2054 if (fADC->fADCnumber <= 1 || fADC->fADCnumber == fMaxADCgeom - 1)
2056 fADC->fIsShared = kTRUE;
2060 fADC->fIsShared = kFALSE;
2063 if ( fADC->fADCnumber >= fMaxADCgeom - 1)
2065 fADC->fCOL = AliTRDfeeParam::Instance()->GetPadColFromADC(fMCM->fROB, fMCM->fMCM, fADC->fADCnumber - 1);
2070 fADC->fCOL = fTRDfeeParam->GetPadColFromADC(fMCM->fROB, fMCM->fMCM, fADC->fADCnumber);
2073 if (fADC->fCorrupted > 0)
2081 //--------------------------------------------------------
2084 AliTRDrawStreamTB::DecodeADCTP23(unsigned long *expected)
2087 // decode test pattern ADC channel
2090 fADC->fCorrupted = 0;
2094 for (Int_t i = 0; i < TRD_MAX_TBINS; i++)
2095 fADC->fSignals[i] = 0;
2097 for (Int_t iw = 0; iw < fMCM->fSingleADCwords; iw++)
2099 if (*fpPos == END_OF_TRACKLET_MARKERNEW)
2101 if (fgWarnError) AliError(Form("There should be ADC data. We meet END_OF_TRACKLET_MARKER 0x%08x",*fpPos));
2102 fADC->fCorrupted += 16;
2103 fHC->fCorrupted += 16;
2108 if (*fpPos != *expected)
2112 if (fHC->fRawVMajorOpt == 2)
2114 AliError(Form("Error: fpPos=%d, size=%d, found=0x%08lx, expected=0x%08lx",iw, fMCM->fSingleADCwords, *fpPos, *expected));
2115 AliError(Form("Found ev.cnt. %ld, expected %ld", (*fpPos >> 26), (*expected >> 26)));
2116 AliError(Form("Found sector %ld, expected %ld", (*fpPos >> 21) & 0x1f - 1, (*expected >> 21) & 0x1f - 1));
2117 AliError(Form("Found layer %ld, expected %ld", (*fpPos >> 18) & 0x07 - 1, (*expected >> 18) & 0x07 - 1));
2118 AliError(Form("Found chamber %ld, expected %ld", (*fpPos >> 15) & 0x07 - 1, (*expected >> 15) & 0x07 - 1));
2119 AliError(Form("Found ROB %ld, expected %ld", (*fpPos >> 12) & 0x07, (*expected >> 12) & 0x07));
2120 AliError(Form("Found MCM %ld, expected %ld", (*fpPos >> 8) & 0x0f, (*expected >> 8) & 0x0f));
2121 AliError(Form("Found CPU %ld, expected %ld", (*fpPos >> 6) & 0x03, (*expected >> 6) & 0x03));
2122 AliError(Form("Found counter %ld, expected %ld\n", (*fpPos >> 0) & 0x3f, (*expected >> 0) & 0xf));
2124 if (fHC->fRawVMajorOpt == 3)
2126 AliError(Form("Error: fpPos=%d, size=%d, found=0x%08lx, expected=0x%08lx",iw, fMCM->fSingleADCwords, *fpPos, *expected));
2127 AliError(Form("Found ev.cnt. %ld, expected %ld", (*fpPos >> 20), (*expected >> 20)));
2128 AliError(Form("Found sector %ld, expected %ld", (*fpPos >> 15) & 0x1f - 1, (*expected >> 15) & 0x1f - 1));
2129 AliError(Form("Found layer %ld, expected %ld", (*fpPos >> 12) & 0x07 - 1, (*expected >> 12) & 0x07 - 1));
2130 AliError(Form("Found chamber %ld, expected %ld", (*fpPos >> 9) & 0x07 - 1, (*expected >> 9) & 0x07 - 1));
2131 AliError(Form("Found ROB %ld, expected %ld", (*fpPos >> 6) & 0x07, (*expected >> 6) & 0x07));
2132 AliError(Form("Found MCM %ld, expected %ld", (*fpPos >> 2) & 0x0f, (*expected >> 2) & 0x0f));
2133 AliError(Form("Found CPU %ld, expected %ld\n", (*fpPos >> 0) & 0x03, (*expected >> 0) & 0x03));
2137 fADC->fCorrupted += 32; //test pattern corrupted
2139 fADC->fSignals[fTbinADC + 0] = ((*fpPos & 0x00000ffc) >> 2);
2140 fADC->fSignals[fTbinADC + 1] = ((*fpPos & 0x003ff000) >> 12);
2141 fADC->fSignals[fTbinADC + 2] = ((*fpPos & 0xffc00000) >> 22);
2145 if (fHC->fRawVMajorOpt == 2) (*expected)++;
2148 if (fADC->fADCnumber <= 1 || fADC->fADCnumber == fMaxADCgeom - 1)
2150 fADC->fIsShared = kTRUE;
2154 fADC->fIsShared = kFALSE;
2157 if ( fADC->fADCnumber >= fMaxADCgeom - 1)
2159 fADC->fCOL = AliTRDfeeParam::Instance()->GetPadColFromADC(fMCM->fROB, fMCM->fMCM, fADC->fADCnumber - 1);
2164 fADC->fCOL = fTRDfeeParam->GetPadColFromADC(fMCM->fROB, fMCM->fMCM, fADC->fADCnumber);
2167 if (fADC->fCorrupted > 0)
2175 //--------------------------------------------------------
2178 void AliTRDrawStreamTB::DecodeSMInfo(const UInt_t *word, struct AliTRDrawSM *sm) const
2181 // Decode the data *word into SM info structure
2184 sm->fPos = (UInt_t*)word;
2187 UInt_t vword = *word;
2188 sm->fHeaderSize = SM_HEADER_SIZE(vword);
2190 if (TRACKLETS_ENABLED(vword) > 0)
2191 sm->fTrackletEnable = kTRUE;
2193 sm->fTrackletEnable = kFALSE;
2195 UInt_t stackMask = STACK_MASK(vword);
2196 sm->fActiveStacks = 0;
2197 for (Int_t i = 0; i < 5; i++)
2199 //if ((stackMask >> i) & 0x1 > 0)
2200 if (IS_BIT_SET(stackMask,i) > 0)
2202 sm->fStackActive[i] = kTRUE;
2203 sm->fActiveStacks++;
2207 sm->fStackActive[i] = kFALSE;
2212 //--------------------------------------------------------
2213 const char *AliTRDrawStreamTB::DumpSMInfo(const struct AliTRDrawSM *sm)
2216 // Get SM structure into a const char
2219 return Form("[ SM Info 0x%08x] : Hsize %d TrackletEnable %d Stacks %d %d %d %d %d",
2221 sm->fHeaderSize, sm->fTrackletEnable,
2222 sm->fStackActive[0], sm->fStackActive[1], sm->fStackActive[2],
2223 sm->fStackActive[3], sm->fStackActive[4]);
2226 //--------------------------------------------------------
2227 void AliTRDrawStreamTB::DecodeStackInfo(const UInt_t *word, struct AliTRDrawStack *st) const
2230 // Decode stack info - active links
2233 st->fPos = (UInt_t*)word;
2236 UInt_t vword = *word;
2237 st->fHeaderSize = STACK_HEADER_SIZE(vword);
2239 UInt_t linkMask = STACK_LINK_WORD(vword);
2240 st->fActiveLinks = 0;
2241 for (Int_t i = 0; i < 12; i++)
2243 //if (linkMask & (0x1 << i) > 0)
2244 if (IS_BIT_SET(linkMask,i) > 0)
2246 st->fLinksActive[i] = kTRUE;
2247 st->fTrackletDecode[i] = kTRUE;
2248 st->fHCDecode[i] = kTRUE;
2253 st->fTrackletDecode[i] = kFALSE;
2254 st->fLinksActive[i] = kFALSE;
2255 st->fHCDecode[i] = kFALSE;
2260 //--------------------------------------------------------
2261 const char *AliTRDrawStreamTB::DumpStackInfo(const struct AliTRDrawStack *st)
2264 // format the string with the stack info
2266 return Form("[ Stack Info 0x%08x ] : Hsize %d Links Active %d %d %d %d %d %d %d %d %d %d %d %d",
2269 st->fLinksActive[0], st->fLinksActive[1], st->fLinksActive[2], st->fLinksActive[3],
2270 st->fLinksActive[4], st->fLinksActive[5], st->fLinksActive[6], st->fLinksActive[7],
2271 st->fLinksActive[8], st->fLinksActive[9], st->fLinksActive[10], st->fLinksActive[11]);
2274 //--------------------------------------------------------
2275 void AliTRDrawStreamTB::DecodeHCwordH0(const UInt_t *word, struct AliTRDrawHC *hc) const
2278 // decode the hc header word 0
2282 UInt_t vword = *word;
2284 hc->fCorrupted = HC_HEADER_MASK_ERR(vword);
2285 if (hc->fCorrupted > 0)
2287 hc->fH0ErrorCounter++;
2290 hc->fSpecialRawV = HC_SPECIAL_RAW_VERSION(vword);
2291 hc->fRawVMajor = HC_MAJOR_RAW_VERSION(vword);
2292 hc->fRawVMajorOpt = HC_MAJOR_RAW_VERSION_OPT(vword);
2293 hc->fRawVMinor = HC_MINOR_RAW_VERSION(vword);
2294 hc->fNExtraWords = HC_EXTRA_WORDS(vword);
2295 hc->fDCSboard = HC_DCS_BOARD(vword);
2296 hc->fSM = HC_SM_NUMBER(vword);
2297 hc->fStack = HC_STACK_NUMBER(vword);
2298 hc->fLayer = HC_LAYER_NUMBER(vword);
2299 hc->fSide = HC_SIDE_NUMBER(vword);
2301 hc->fPos[0] = (UInt_t*)word;
2305 //--------------------------------------------------------
2306 void AliTRDrawStreamTB::DecodeHCwordH1(const UInt_t *word, struct AliTRDrawHC *hc) const
2313 UInt_t vword = *word;
2315 hc->fCorrupted += 2 * HC_HEADER_MASK_ERR(vword);
2316 if (hc->fCorrupted >= 2)
2318 hc->fH1ErrorCounter++;
2321 hc->fTimeBins = HC_NTIMEBINS(vword);
2322 hc->fBunchCrossCounter = HC_BUNCH_CROSS_COUNTER(vword);
2323 hc->fPreTriggerCounter = HC_PRETRIGGER_COUNTER(vword);
2324 hc->fPreTriggerPhase = HC_PRETRIGGER_PHASE(vword);
2326 hc->fPos[1] = (UInt_t*)word;
2329 //--------------------------------------------------------
2330 const char *AliTRDrawStreamTB::DumpHCinfoH0(const struct AliTRDrawHC *hc)
2336 return Form("Unable to dump. Null received as parameter!?!");
2338 return Form("[ HC[0] at 0x%08x ] : 0x%08x Info is : RawV %d SM %d Stack %d Layer %d Side %d DCSboard %d",
2339 hc->fPos[0], *(hc->fPos[0]), hc->fRawVMajor, hc->fSM, hc->fStack, hc->fLayer, hc->fSide, hc->fDCSboard);
2342 //--------------------------------------------------------
2343 const char *AliTRDrawStreamTB::DumpHCinfoH1(const struct AliTRDrawHC *hc)
2349 return Form("Unable to dump. Null received as parameter!?!");
2351 return Form("[ HC[1] at 0x%08x ] : 0x%08x Info is : TBins %d BCcount %d PreTrigCount %d PreTrigPhase %d",
2352 hc->fPos[1], *(hc->fPos[1]), hc->fTimeBins, hc->fBunchCrossCounter, hc->fPreTriggerCounter, hc->fPreTriggerPhase);
2355 //--------------------------------------------------------
2356 void AliTRDrawStreamTB::DecodeMCMheader(const UInt_t *word, struct AliTRDrawMCM *mcm) const
2359 // decode the mcm header
2362 UInt_t vword = *word;
2364 if (vword == END_OF_TRACKLET_MARKERNEW)
2366 if (fgWarnError) AliError(Form("There should be MCM header. We meet END_OF_TRACKLET_MARKER 0x%08x",vword));
2367 mcm->fCorrupted += 16;
2368 fHC->fCorrupted += 16; //to finish data reading of this HC
2370 mcm->fCorrupted = MCM_HEADER_MASK_ERR(vword); //if MCM header mask has error, set mcm->fCorrupted = 1
2371 if (mcm->fCorrupted)
2372 mcm->fErrorCounter++;
2373 mcm->fROB = MCM_ROB_NUMBER(vword);
2374 mcm->fMCM = MCM_MCM_NUMBER(vword);
2375 mcm->fEvCounter = MCM_EVENT_COUNTER(vword);
2376 mcm->fPos = (UInt_t*)word;
2379 //--------------------------------------------------------
2380 UInt_t AliTRDrawStreamTB::GetMCMadcMask(const UInt_t *word, struct AliTRDrawMCM *mcm) const
2386 UInt_t vword = *word;
2392 mcm->fADCMaskWord = vword;
2394 if (vword == END_OF_TRACKLET_MARKERNEW)
2396 if (fgWarnError) AliError(Form("There should be MCMadcMask. We meet END_OF_TRACKLET_MARKER 0x%08x",vword));
2397 mcm->fCorrupted += 16;
2398 fHC->fCorrupted += 16; //to finish data reading of this HC
2401 if ( MCM_ADCMASK_MASK_ERR(vword) == 0 )
2403 mcm->fADCMask = MCM_ADCMASK_VAL(vword);
2404 mcm->fADCcount = MCM_ADCMASK_NADC(~vword);
2408 mcm->fADCMask = 0xffffffff;
2409 mcm->fCorrupted += 4;
2410 mcm->fMaskErrorCounter++;
2413 return mcm->fADCMask;
2416 //--------------------------------------------------------
2417 void AliTRDrawStreamTB::DecodeMask(const UInt_t *word, struct AliTRDrawMCM *mcm) const
2420 // decode the adc mask - adcs to be read out
2423 mcm->fMCMADCWords = 0;
2424 mcm->fSingleADCwords = 0;
2426 mcm->fADCMask = GetMCMadcMask(word, mcm);
2428 if (mcm->fADCMask > 0)
2430 for (Int_t i = 0; i < TRD_MAX_ADC; i++)
2432 mcm->fADCchannel[mcm->fADCmax] = 0;
2433 if( IS_BIT_SET(mcm->fADCMask,i) )
2435 mcm->fADCchannel[mcm->fADCmax] = i;
2440 if (mcm->fADCcount != mcm->fADCmax && fHC->fRawVMajor >= 32) // backward compatibility
2442 mcm->fCorrupted += 8;
2446 //--------------------------------------------------------
2447 void AliTRDrawStreamTB::MCMADCwordsWithTbins(UInt_t fTbins, struct AliTRDrawMCM *mcm) const
2450 // count the expected mcm words for a given tbins
2452 mcm->fMCMADCWords = ( mcm->fADCmax ) * ( fTbins / 3 );
2453 mcm->fSingleADCwords = 0;
2454 if (mcm->fADCmax > 0)
2456 mcm->fSingleADCwords = mcm->fMCMADCWords/mcm->fADCmax;
2460 //--------------------------------------------------------
2461 const unsigned long AliTRDrawStreamTB::AdvancePseudoRandom(unsigned long *val) const
2464 // pseudo random number generator for test pattern data
2466 unsigned long currentVal = *val;
2468 *val = ( (*val << 1) | (((*val >> 9) ^ (*val >> 6)) & 1) ) & 0x3FF;
2472 //--------------------------------------------------------
2473 const char *AliTRDrawStreamTB::DumpMCMinfo(const struct AliTRDrawMCM *mcm)
2476 // mcm info in a string
2479 return Form("Unable to dump. Null received as parameter!?!");
2481 return Form("[ MCM 0x%08x ] : ROB %d MCM %d EvCounter %d", *(mcm->fPos), mcm->fROB, mcm->fMCM, mcm->fEvCounter);
2484 //--------------------------------------------------------
2485 //TString DumpMCMadcMask(const struct AliTRDrawMCMInfo *mcm)
2486 const char *AliTRDrawStreamTB::DumpMCMadcMask(const struct AliTRDrawMCM *mcm)
2489 // mcm adc mask in a string
2492 return Form("Unable to dump. Null received as parameter!?!");
2494 TString tsreturn = Form("[Word] : 0x%08x => [Mask] : 0x%08x : ", mcm->fADCMaskWord, mcm->fADCMask);
2495 for (Int_t i = 0; i < 21; i++)
2497 tsreturn += Form("%d ", mcm->fADCchannel[i]);
2500 return tsreturn.Data();