5 #include <Alieve/TPCSectorData.h>
7 #include <AliSimDigits.h>
8 #include <AliTPCParam.h>
9 #include <AliTPCRawStream.h>
10 #include <AliTPCRawStreamOld.h>
14 using namespace Alieve;
16 //______________________________________________________________________
19 // A central manager for TPC data of an event. Can read digits (from
20 // a tree: LoadDigits()) and raw-data (via AliRawReader: LoadRaw()).
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.
30 fSectors(36), fSectorBlockSize(65536),
33 TPCSectorData::InitStatics();
38 // !!!! delete sectors
41 /**************************************************************************/
43 void TPCData::CreateSector(Int_t sector)
45 if(fSectors[sector] == 0)
46 fSectors[sector] = new TPCSectorData(sector, fSectorBlockSize);
49 void TPCData::CreateAllSectors()
51 for(Int_t s=0; s<36; ++s)
55 /**************************************************************************/
57 TPCSectorData* TPCData::GetSectorData(Int_t sector, Bool_t spawnSectors)
59 if(sector < 0 || sector > 35) return 0;
60 if(fSectors[sector] == 0 && spawnSectors)
62 return fSectors[sector];
65 /**************************************************************************/
67 void TPCData::LoadDigits(TTree* tree, Bool_t spawnSectors)
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.
74 AliSimDigits digit, *digitPtr = &digit;
75 tree->GetBranch("Segment")->SetAddress(&digitPtr);
77 Int_t sector, row, pad, curPad;
79 Bool_t inFill = kFALSE;
80 TPCSectorData* secData = 0;
82 Int_t numEnt = (Int_t) tree->GetEntries();
83 for (Int_t ent=0; ent<numEnt; ent++) {
85 Alieve::TPCSectorData::GetParam().AdjustSectorRow(digit.GetID(), sector, row);
88 row += TPCSectorData::GetInnSeg().GetNRows();
90 secData = GetSectorData(sector, spawnSectors);
94 if(digit.First() == kFALSE)
98 pad = digit.CurrentColumn();
99 time = digit.CurrentRow();
100 signal = digit.CurrentDigit();
105 secData->BeginPad(row, pad, kFALSE);
109 if(signal > fLoadThreshold)
110 secData->RegisterData(time, signal);
112 } while (digit.Next());
120 void TPCData::LoadRaw(AliTPCRawStream& input, Bool_t spawnSectors)
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.
127 Int_t sector = -1, row = -1, pad = -1, rowOffset = 0;
128 Bool_t inFill = kFALSE;
129 TPCSectorData* secData = 0;
131 while (input.Next()) {
132 if (input.IsNewSector()) {
137 sector = input.GetSector();
140 rowOffset = TPCSectorData::GetInnSeg().GetNRows();
144 secData = GetSectorData(sector, spawnSectors);
149 if (input.IsNewPad()) {
154 row = input.GetRow() + rowOffset;
155 pad = input.GetPad();
157 secData->BeginPad(row, pad, kTRUE);
161 if(input.GetSignal() > fLoadThreshold)
162 secData->RegisterData(input.GetTime(), input.GetSignal());
171 void TPCData::LoadRaw(AliTPCRawStreamOld& input, Bool_t spawnSectors, Bool_t warn)
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.
178 static const Exc_t eH("TPCData::LoadRaw ");
180 Int_t sector = -1, row = -1, pad = -1, rowOffset = 0;
181 Bool_t inFill = kFALSE;
182 TPCSectorData* secData = 0;
184 while (input.Next()) {
185 if (input.IsNewSector()) {
190 sector = input.GetSector();
193 rowOffset = TPCSectorData::GetInnSeg().GetNRows();
197 secData = GetSectorData(sector, spawnSectors);
202 if (input.IsNewPad()) {
207 row = input.GetRow() + rowOffset;
208 pad = input.GetPad();
210 if(pad >= TPCSectorData::GetNPadsInRow(row)) {
212 Warning(eH.Data(), "pad out of range (row=%d, pad=%d, maxpad=%d).",
213 row, pad, TPCSectorData::GetNPadsInRow(row));
218 secData->BeginPad(row, pad, kTRUE);
222 if(input.GetSignal() > fLoadThreshold)
223 secData->RegisterData(input.GetTime(), input.GetSignal());