]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RAW/AliITSRawStreamSPD.cxx
Replacing rindex by strrchr
[u/mrichter/AliRoot.git] / RAW / AliITSRawStreamSPD.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 ///////////////////////////////////////////////////////////////////////////////
17 //
18 // This is a class for reading ITS SPD raw data files and providing
19 // information about digits
20 //
21 ///////////////////////////////////////////////////////////////////////////////
22
23 #include "AliITSRawStreamSPD.h"
24 #include "AliRawReader.h"
25
26 ClassImp(AliITSRawStreamSPD)
27
28
29 AliITSRawStreamSPD::AliITSRawStreamSPD(AliRawReader* rawReader) :
30   AliITSRawStream(rawReader)
31 {
32 // create an object to read ITS SPD raw digits
33
34   fRawReader->Select(1);
35 }
36
37
38 Bool_t AliITSRawStreamSPD::Next()
39 {
40 // read the next raw digit
41 // returns kFALSE if there is no digit left
42
43   fPrevModuleID = fModuleID;
44   while (fRawReader->ReadNextShort(fData)) {
45   
46     if ((fData & 0xE000) == 0x6000) {           // header
47       fHitCount = 0;
48       UShort_t halfStave = (fData >> 4) & 0x007F;
49       UShort_t chipAddr = fData & 0x000F;
50       fModuleID = 2 * halfStave;
51       if (chipAddr >= 5) fModuleID++;
52       fOffset = 32 * (chipAddr % 5);
53     } else if ((fData & 0xE000) == 0x0000) {    // trailer
54       UShort_t hitCount = fData & 0x1FFF;
55       if (hitCount != fHitCount) Error("Next", "wrong number of hits!");
56     } else if ((fData & 0xC000) == 0x8000) {    // pixel hit
57       fHitCount++;
58       fCoord1 = (fData & 0x001F) + fOffset;
59       fCoord2 = (fData >> 5) & 0x00FF;
60       return kTRUE;
61     } else {                                    // fill word
62       if (fData != 0xFEDC) Error("Next", "wrong fill word!");
63     }
64
65   }
66
67   return kFALSE;
68 }