]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - TPC/AliTPCRawStream.cxx
make Init methods public
[u/mrichter/AliRoot.git] / TPC / AliTPCRawStream.cxx
... / ...
CommitLineData
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//_____________________________________________________________________________
39AliTPCRawStream::AliTPCRawStream(AliRawReader* rawReader, AliAltroMapping **mapping) :
40 AliAltroRawStream(rawReader),
41 fSector(-1),
42 fPrevSector(-1),
43 fRow(-1),
44 fPrevRow(-1),
45 fPad(-1),
46 fPrevPad(-1),
47 fIsMapOwner(kFALSE)
48{
49 // create an object to read TPC raw digits
50
51 SelectRawData("TPC");
52
53 if (mapping == NULL) {
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;
64 }
65 else {
66 for(Int_t i = 0; i < 6; i++)
67 fMapping[i] = mapping[i];
68 }
69
70}
71
72//_____________________________________________________________________________
73AliTPCRawStream::AliTPCRawStream(const AliTPCRawStream& stream) :
74 AliAltroRawStream(stream),
75 fSector(stream.fSector),
76 fPrevSector(stream.fPrevSector),
77 fRow(stream.fRow),
78 fPrevRow(stream.fPrevRow),
79 fPad(stream.fPad),
80 fPrevPad(stream.fPrevPad),
81 fIsMapOwner(kFALSE)
82{
83 for(Int_t i = 0; i < 6; i++) fMapping[i] = stream.fMapping[i];
84}
85
86//_____________________________________________________________________________
87AliTPCRawStream& AliTPCRawStream::operator = (const AliTPCRawStream& stream)
88{
89 if(&stream == this) return *this;
90
91 ((AliAltroRawStream *)this)->operator=(stream);
92
93 fSector = stream.fSector;
94 fPrevSector = stream.fPrevSector;
95 fRow = stream.fRow;
96 fPrevRow = stream.fPrevRow;
97 fPad = stream.fPad;
98 fPrevPad = stream.fPrevPad;
99 fIsMapOwner = kFALSE;
100
101 for(Int_t i = 0; i < 6; i++) fMapping[i] = stream.fMapping[i];
102
103 return *this;
104}
105
106//_____________________________________________________________________________
107AliTPCRawStream::~AliTPCRawStream()
108{
109// destructor
110
111 if (fIsMapOwner)
112 for(Int_t i = 0; i < 6; i++) delete fMapping[i];
113}
114
115//_____________________________________________________________________________
116void AliTPCRawStream::Reset()
117{
118 // reset tpc raw stream params
119 AliAltroRawStream::Reset();
120 fSector = fPrevSector = fRow = fPrevRow = fPad = fPrevPad = -1;
121}
122
123//_____________________________________________________________________________
124Bool_t AliTPCRawStream::Next()
125{
126 // Read next TPC signal
127 // Apply the TPC altro mapping to get
128 // the sector,pad-row and pad indeces
129 fPrevSector = fSector;
130 fPrevRow = fRow;
131 fPrevPad = fPad;
132 if (AliAltroRawStream::Next()) {
133 if (IsNewHWAddress())
134 ApplyAltroMapping();
135 return kTRUE;
136 }
137 else
138 return kFALSE;
139}
140
141//_____________________________________________________________________________
142void AliTPCRawStream::ApplyAltroMapping()
143{
144 // Take the DDL index, load
145 // the corresponding altro mapping
146 // object and fill the sector,row and pad indeces
147 Int_t ddlNumber = GetDDLNumber();
148 Int_t patchIndex;
149 if (ddlNumber < 72) {
150 fSector = ddlNumber / 2;
151 patchIndex = ddlNumber % 2;
152 }
153 else {
154 fSector = (ddlNumber - 72) / 4 + 36;
155 patchIndex = (ddlNumber - 72) % 4 + 2;
156 }
157
158 Short_t hwAddress = GetHWAddress();
159 fRow = fMapping[patchIndex]->GetPadRow(hwAddress);
160 fPad = fMapping[patchIndex]->GetPad(hwAddress);
161
162 if ((fRow < 0) || (fPad < 0))
163 AddMappingErrorLog(Form("hw=%d",hwAddress));
164}