]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/Alieve/TPCData.cxx
Removed ';' from ClassImp pragmas.
[u/mrichter/AliRoot.git] / EVE / Alieve / TPCData.cxx
CommitLineData
915dabe1 1// $Header$
2
3#include "TPCData.h"
4
5#include <Alieve/TPCSectorData.h>
6
7#include <AliSimDigits.h>
8#include <AliTPCParam.h>
9#include <AliTPCRawStream.h>
10#include <AliTPCRawStreamOld.h>
11#include <TTree.h>
12
13using namespace Reve;
14using namespace Alieve;
15
16//______________________________________________________________________
17// TPCData
18//
19// A central manager for TPC data of an event. Can read digits (from
20// a tree: LoadDigits()) and raw-data (via AliRawReader: LoadRaw()).
21//
22// The sector data is stored in 36 TPCSectorData objects.
23// Sectors 0 - 17: +z side, 18 - 35: -z side.
24// No separation of inner/outer segments, use row numbers for addressing.
25//
26
2aef44c1 27ClassImp(TPCData)
915dabe1 28
29TPCData::TPCData() :
30 fSectors(36), fSectorBlockSize(65536),
31 fLoadThreshold(0)
32{
33 TPCSectorData::InitStatics();
34}
35
36TPCData::~TPCData()
37{
38 // !!!! delete sectors
39}
40
41/**************************************************************************/
42
43void TPCData::CreateSector(Int_t sector)
44{
45 if(fSectors[sector] == 0)
46 fSectors[sector] = new TPCSectorData(sector, fSectorBlockSize);
47}
48
49void TPCData::CreateAllSectors()
50{
51 for(Int_t s=0; s<36; ++s)
52 CreateSector(s);
53}
54
55/**************************************************************************/
56
57TPCSectorData* TPCData::GetSectorData(Int_t sector, Bool_t spawnSectors)
58{
59 if(sector < 0 || sector > 35) return 0;
60 if(fSectors[sector] == 0 && spawnSectors)
61 CreateSector(sector);
62 return fSectors[sector];
63}
64
65/**************************************************************************/
66
67void TPCData::LoadDigits(TTree* tree, Bool_t spawnSectors)
68{
69 // Load data from TTree of AliSimDigits.
70 // If spawnSectors is false only sectors that have been created previously
71 // via CreateSector() are loaded.
72 // If spawnSectors is true sectors are created if data for them is encountered.
73
74 AliSimDigits digit, *digitPtr = &digit;
75 tree->GetBranch("Segment")->SetAddress(&digitPtr);
76
77 Int_t sector, row, pad, curPad;
78 Short_t time, signal;
79 Bool_t inFill = kFALSE;
80 TPCSectorData* secData = 0;
81
82 Int_t numEnt = (Int_t) tree->GetEntries();
83 for (Int_t ent=0; ent<numEnt; ent++) {
84 tree->GetEntry(ent);
85 Alieve::TPCSectorData::GetParam().AdjustSectorRow(digit.GetID(), sector, row);
86 if(sector >= 36) {
87 sector -= 36;
88 row += TPCSectorData::GetInnSeg().GetNRows();
89 }
90 secData = GetSectorData(sector, spawnSectors);
91 if(secData == 0)
92 continue;
93
94 if(digit.First() == kFALSE)
95 continue;
96 curPad = -1;
97 do {
98 pad = digit.CurrentColumn();
99 time = digit.CurrentRow();
100 signal = digit.CurrentDigit();
101
102 if(pad != curPad) {
103 if(inFill)
104 secData->EndPad();
105 secData->BeginPad(row, pad, kFALSE);
106 curPad = pad;
107 inFill = kTRUE;
108 }
109 if(signal > fLoadThreshold)
110 secData->RegisterData(time, signal);
111
112 } while (digit.Next());
113 if(inFill) {
114 secData->EndPad();
115 inFill = kFALSE;
116 }
117 }
118}
119
120void TPCData::LoadRaw(AliTPCRawStream& input, Bool_t spawnSectors)
121{
122 // Load data from AliTPCRawStream.
123 // If spawnSectors is false only sectors that have been created previously
124 // via CreateSector() are loaded.
125 // If spawnSectors is true sectors are created if data for them is encountered.
126
127 Int_t sector = -1, row = -1, pad = -1, rowOffset = 0;
128 Bool_t inFill = kFALSE;
129 TPCSectorData* secData = 0;
130
131 while (input.Next()) {
132 if (input.IsNewSector()) {
133 if(inFill) {
134 secData->EndPad();
135 inFill = kFALSE;
136 }
137 sector = input.GetSector();
138 if(sector >= 36) {
139 sector -= 36;
140 rowOffset = TPCSectorData::GetInnSeg().GetNRows();
141 } else {
142 rowOffset = 0;
143 }
144 secData = GetSectorData(sector, spawnSectors);
145 }
146 if (secData == 0)
147 continue;
148
149 if (input.IsNewPad()) {
150 if(inFill) {
151 secData->EndPad();
152 inFill = kFALSE;
153 }
154 row = input.GetRow() + rowOffset;
155 pad = input.GetPad();
156
157 secData->BeginPad(row, pad, kTRUE);
158 inFill = kTRUE;
159 }
160
161 if(input.GetSignal() > fLoadThreshold)
162 secData->RegisterData(input.GetTime(), input.GetSignal());
163 }
164
165 if(inFill) {
166 secData->EndPad();
167 inFill = kFALSE;
168 }
169}
170
171void TPCData::LoadRaw(AliTPCRawStreamOld& input, Bool_t spawnSectors, Bool_t warn)
172{
173 // Load data from AliTPCRawStream.
174 // If spawnSectors is false only sectors that have been created previously
175 // via CreateSector() are loaded.
176 // If spawnSectors is true sectors are created if data for them is encountered.
177
178 static const Exc_t eH("TPCData::LoadRaw ");
179
180 Int_t sector = -1, row = -1, pad = -1, rowOffset = 0;
181 Bool_t inFill = kFALSE;
182 TPCSectorData* secData = 0;
183
184 while (input.Next()) {
185 if (input.IsNewSector()) {
186 if(inFill) {
187 secData->EndPad();
188 inFill = kFALSE;
189 }
190 sector = input.GetSector();
191 if(sector >= 36) {
192 sector -= 36;
193 rowOffset = TPCSectorData::GetInnSeg().GetNRows();
194 } else {
195 rowOffset = 0;
196 }
197 secData = GetSectorData(sector, spawnSectors);
198 }
199 if (secData == 0)
200 continue;
201
202 if (input.IsNewPad()) {
203 if(inFill) {
204 secData->EndPad();
205 inFill = kFALSE;
206 }
207 row = input.GetRow() + rowOffset;
208 pad = input.GetPad();
209
210 if(pad >= TPCSectorData::GetNPadsInRow(row)) {
211 if(warn) {
212 Warning(eH.Data(), "pad out of range (row=%d, pad=%d, maxpad=%d).",
213 row, pad, TPCSectorData::GetNPadsInRow(row));
214 }
215 continue;
216 }
217
218 secData->BeginPad(row, pad, kTRUE);
219 inFill = kTRUE;
220 }
221
222 if(input.GetSignal() > fLoadThreshold)
223 secData->RegisterData(input.GetTime(), input.GetSignal());
224 }
225
226 if(inFill) {
227 secData->EndPad();
228 inFill = kFALSE;
229 }
230}