]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCRawStream.cxx
Bug fix - T0 form AliRelKamna in microseconds
[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}
71
72//_____________________________________________________________________________
73AliTPCRawStream::AliTPCRawStream(const AliTPCRawStream& stream) :
041f6df4 74 AliAltroRawStream(stream),
e7bee78b 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)
b27ca38e 82{
e7bee78b 83 for(Int_t i = 0; i < 6; i++) fMapping[i] = stream.fMapping[i];
b27ca38e 84}
85
86//_____________________________________________________________________________
e7bee78b 87AliTPCRawStream& AliTPCRawStream::operator = (const AliTPCRawStream& stream)
b27ca38e 88{
e7bee78b 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
b27ca38e 103 return *this;
104}
105
106//_____________________________________________________________________________
107AliTPCRawStream::~AliTPCRawStream()
108{
109// destructor
110
e7bee78b 111 if (fIsMapOwner)
112 for(Int_t i = 0; i < 6; i++) delete fMapping[i];
b27ca38e 113}
114
115//_____________________________________________________________________________
116void AliTPCRawStream::Reset()
117{
118 // reset tpc raw stream params
119 AliAltroRawStream::Reset();
041f6df4 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;
b27ca38e 139}
140
141//_____________________________________________________________________________
142void AliTPCRawStream::ApplyAltroMapping()
143{
041f6df4 144 // Take the DDL index, load
b27ca38e 145 // the corresponding altro mapping
041f6df4 146 // object and fill the sector,row and pad indeces
147 Int_t ddlNumber = GetDDLNumber();
b27ca38e 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
041f6df4 158 Short_t hwAddress = GetHWAddress();
159 fRow = fMapping[patchIndex]->GetPadRow(hwAddress);
160 fPad = fMapping[patchIndex]->GetPad(hwAddress);
b27ca38e 161
481367a2 162 if ((fRow < 0) || (fPad < 0))
163 AddMappingErrorLog(Form("hw=%d",hwAddress));
b27ca38e 164}