]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCRawStream.cxx
- The default value of useFastDecoder in ctor changed to kFALSE,
[u/mrichter/AliRoot.git] / TPC / AliTPCRawStream.cxx
CommitLineData
b27ca38e 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/* $Id$ */
17
18///////////////////////////////////////////////////////////////////////////////
19///
20/// This class provides access to TPC digits in raw data.
21///
22/// It loops over all TPC 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.
26///
27///////////////////////////////////////////////////////////////////////////////
28
29#include <TSystem.h>
30
31#include "AliTPCRawStream.h"
32#include "AliRawReader.h"
33#include "AliLog.h"
34#include "AliTPCAltroMapping.h"
35
36ClassImp(AliTPCRawStream)
37
38//_____________________________________________________________________________
4cdab760 39AliTPCRawStream::AliTPCRawStream(AliRawReader* rawReader, AliAltroMapping **mapping) :
041f6df4 40 AliAltroRawStream(rawReader),
41 fSector(-1),
42 fPrevSector(-1),
43 fRow(-1),
44 fPrevRow(-1),
45 fPad(-1),
e7bee78b 46 fPrevPad(-1),
4cdab760 47 fIsMapOwner(kFALSE)
b27ca38e 48{
49 // create an object to read TPC raw digits
50
362c9d61 51 SelectRawData("TPC");
b27ca38e 52
01317cf9 53 if (mapping == NULL) {
4cdab760 54 TString path = gSystem->Getenv("ALICE_ROOT");
55 path += "/TPC/mapping/Patch";
56 TString path2;
57 for(Int_t i = 0; i < 6; i++) {
58 path2 = path;
59 path2 += i;
60 path2 += ".data";
61 fMapping[i] = new AliTPCAltroMapping(path2.Data());
62 }
63 fIsMapOwner = kTRUE;
b27ca38e 64 }
4cdab760 65 else {
66 for(Int_t i = 0; i < 6; i++)
67 fMapping[i] = mapping[i];
68 }
69
b27ca38e 70 fNoAltroMapping = kFALSE;
71}
72
73//_____________________________________________________________________________
74AliTPCRawStream::AliTPCRawStream(const AliTPCRawStream& stream) :
041f6df4 75 AliAltroRawStream(stream),
e7bee78b 76 fSector(stream.fSector),
77 fPrevSector(stream.fPrevSector),
78 fRow(stream.fRow),
79 fPrevRow(stream.fPrevRow),
80 fPad(stream.fPad),
81 fPrevPad(stream.fPrevPad),
82 fIsMapOwner(kFALSE)
b27ca38e 83{
e7bee78b 84 for(Int_t i = 0; i < 6; i++) fMapping[i] = stream.fMapping[i];
b27ca38e 85}
86
87//_____________________________________________________________________________
e7bee78b 88AliTPCRawStream& AliTPCRawStream::operator = (const AliTPCRawStream& stream)
b27ca38e 89{
e7bee78b 90 if(&stream == this) return *this;
91
92 ((AliAltroRawStream *)this)->operator=(stream);
93
94 fSector = stream.fSector;
95 fPrevSector = stream.fPrevSector;
96 fRow = stream.fRow;
97 fPrevRow = stream.fPrevRow;
98 fPad = stream.fPad;
99 fPrevPad = stream.fPrevPad;
100 fIsMapOwner = kFALSE;
101
102 for(Int_t i = 0; i < 6; i++) fMapping[i] = stream.fMapping[i];
103
b27ca38e 104 return *this;
105}
106
107//_____________________________________________________________________________
108AliTPCRawStream::~AliTPCRawStream()
109{
110// destructor
111
e7bee78b 112 if (fIsMapOwner)
113 for(Int_t i = 0; i < 6; i++) delete fMapping[i];
b27ca38e 114}
115
116//_____________________________________________________________________________
117void AliTPCRawStream::Reset()
118{
119 // reset tpc raw stream params
120 AliAltroRawStream::Reset();
041f6df4 121 fSector = fPrevSector = fRow = fPrevRow = fPad = fPrevPad = -1;
122}
123
124//_____________________________________________________________________________
125Bool_t AliTPCRawStream::Next()
126{
127 // Read next TPC signal
128 // Apply the TPC altro mapping to get
129 // the sector,pad-row and pad indeces
130 fPrevSector = fSector;
131 fPrevRow = fRow;
132 fPrevPad = fPad;
133 if (AliAltroRawStream::Next()) {
134 if (IsNewHWAddress())
135 ApplyAltroMapping();
136 return kTRUE;
137 }
138 else
139 return kFALSE;
b27ca38e 140}
141
142//_____________________________________________________________________________
143void AliTPCRawStream::ApplyAltroMapping()
144{
041f6df4 145 // Take the DDL index, load
b27ca38e 146 // the corresponding altro mapping
041f6df4 147 // object and fill the sector,row and pad indeces
148 Int_t ddlNumber = GetDDLNumber();
b27ca38e 149 Int_t patchIndex;
150 if (ddlNumber < 72) {
151 fSector = ddlNumber / 2;
152 patchIndex = ddlNumber % 2;
153 }
154 else {
155 fSector = (ddlNumber - 72) / 4 + 36;
156 patchIndex = (ddlNumber - 72) % 4 + 2;
157 }
158
041f6df4 159 Short_t hwAddress = GetHWAddress();
160 fRow = fMapping[patchIndex]->GetPadRow(hwAddress);
161 fPad = fMapping[patchIndex]->GetPad(hwAddress);
b27ca38e 162
481367a2 163 if ((fRow < 0) || (fPad < 0))
164 AddMappingErrorLog(Form("hw=%d",hwAddress));
b27ca38e 165}