Fixes for building of DA (Anshul)
[u/mrichter/AliRoot.git] / TPC / AliTPCRawStreamV3.cxx
CommitLineData
c3066940 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: AliTPCRawStreamV3.cxx 22777 2007-12-05 17:37:33Z marian $ */
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 NextChannel method loads the data for the next pad. If there is no pad left
24/// it returns kFALSE.
25///
26///////////////////////////////////////////////////////////////////////////////
27
28#include <TSystem.h>
29
30#include "AliTPCRawStreamV3.h"
31#include "AliRawReader.h"
32#include "AliLog.h"
33#include "AliTPCAltroMapping.h"
34
35ClassImp(AliTPCRawStreamV3)
36
37//_____________________________________________________________________________
38AliTPCRawStreamV3::AliTPCRawStreamV3(AliRawReader* rawReader, AliAltroMapping **mapping) :
39 AliAltroRawStreamV3(rawReader),
40 fSector(-1),
41 fPrevSector(-1),
42 fRow(-1),
43 fPrevRow(-1),
44 fPad(-1),
45 fPrevPad(-1),
46 fPatchIndex(-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 //fNoAltroMapping = kFALSE;
72}
73//_____________________________________________________________________________
74AliTPCRawStreamV3::~AliTPCRawStreamV3()
75{
76// destructor
77
78 if (fIsMapOwner)
79 for(Int_t i = 0; i < 6; i++) delete fMapping[i];
80}
81
82//_____________________________________________________________________________
83void AliTPCRawStreamV3::Reset()
84{
85 // reset tpc raw stream params
86 AliAltroRawStreamV3::Reset();
87 fSector = fPrevSector = fRow = fPrevRow = fPad = fPrevPad = fPatchIndex = -1;
88}
89
90//_____________________________________________________________________________
91Bool_t AliTPCRawStreamV3::NextChannel()
92{
93 // Read next TPC Channel
94 // Apply the TPC altro mapping to get
95 // the pad-row and pad indeces
96
97/*
98 fPrevSector = fSector;
99 fPrevRow = fRow;
100 fPrevPad = fPad;
101 if (AliAltroRawStreamV3::NextChannel()) {
102 // if (IsNewHWAddress())
103 if ( GetHWAddress() > -1 )
104 ApplyAltroMapping();
105 return kTRUE;
106 }
107 else
108 return kFALSE;
109 */
110
111 fPrevRow = fRow;
112 fPrevPad = fPad;
113 fRow = -1;
114 fPad = -1;
115 if (!AliAltroRawStreamV3::NextChannel()) return kFALSE;
116
117 Short_t hwAddress = GetHWAddress();
118 if (hwAddress>-1){
119 fRow = fMapping[fPatchIndex]->GetPadRow(hwAddress);
120 fPad = fMapping[fPatchIndex]->GetPad(hwAddress);
121 }
122 return kTRUE;
123}
124//_____________________________________________________________________________
125Bool_t AliTPCRawStreamV3::NextDDL()
126{
127 // Take the DDL index,
128 // calculate the patch number and
129 // set the sector number
130// return AliAltroRawStreamV3::NextDDL();
131 fPrevSector = fSector;
132 fSector = -1;
133 if (!AliAltroRawStreamV3::NextDDL()) return kFALSE;
134
135 Int_t ddlNumber = GetDDLNumber();
136 if (ddlNumber < 72) {
137 fSector = ddlNumber / 2;
138 fPatchIndex = ddlNumber % 2;
139 }
140 else {
141 fSector = (ddlNumber - 72) / 4 + 36;
142 fPatchIndex = (ddlNumber - 72) % 4 + 2;
143 }
144 return kTRUE;
145}
146//_____________________________________________________________________________
147void AliTPCRawStreamV3::ApplyAltroMapping()
148{
149 Int_t ddlNumber = GetDDLNumber();
150 Int_t patchIndex;
151 if (ddlNumber < 72) {
152 fSector = ddlNumber / 2;
153 patchIndex = ddlNumber % 2;
154 }
155 else {
156 fSector = (ddlNumber - 72) / 4 + 36;
157 patchIndex = (ddlNumber - 72) % 4 + 2;
158 }
159
160 Short_t hwAddress = GetHWAddress();
161 fRow = fMapping[patchIndex]->GetPadRow(hwAddress);
162 fPad = fMapping[patchIndex]->GetPad(hwAddress);
163
164
165// if ((fRow < 0) || (fPad < 0))
166// AddMappingErrorLog(Form("hw=%d",hwAddress));
167}