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