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