]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDrawData.cxx
Store the total number of produced particles in the header.
[u/mrichter/AliRoot.git] / TRD / AliTRDrawData.cxx
CommitLineData
5990c064 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
88cb7938 16/* $Id$ */
5990c064 17
18///////////////////////////////////////////////////////////////////////////////
19// //
20// TRD raw data conversion class //
21// //
22///////////////////////////////////////////////////////////////////////////////
23
a2cb5b3d 24#include <Riostream.h>
090026bf 25#include <TMath.h>
5990c064 26
2745a409 27#include "AliDAQ.h"
28#include "AliRawDataHeader.h"
29#include "AliRawReader.h"
30#include "AliLog.h"
31
5990c064 32#include "AliTRDrawData.h"
33#include "AliTRDdigitsManager.h"
bd0f8685 34#include "AliTRDgeometry.h"
5990c064 35#include "AliTRDdataArrayI.h"
b864d801 36#include "AliTRDRawStream.h"
50378239 37
3551db50 38#include "AliTRDcalibDB.h"
08f92f14 39#include "AliFstream.h"
5990c064 40
ca21baaa 41#include "AliTRDSignalIndex.h"
dfd03fc3 42
43#include "AliTRDfeeParam.h"
44#include "AliTRDmcmSim.h"
45
5990c064 46ClassImp(AliTRDrawData)
47
48//_____________________________________________________________________________
2cb20be6 49AliTRDrawData::AliTRDrawData()
50 :TObject()
dfd03fc3 51 ,fGeo(NULL)
52 ,fFee(NULL)
8c703901 53 ,fNumberOfDDLs(0)
5990c064 54{
b864d801 55 //
56 // Default constructor
57 //
dfd03fc3 58 fFee = AliTRDfeeParam::Instance();
59 fNumberOfDDLs = AliDAQ::NumberOfDdls("TRD");
5990c064 60}
61
8c703901 62//_____________________________________________________________________________
63AliTRDrawData::AliTRDrawData(const AliTRDrawData &r)
64 :TObject(r)
dfd03fc3 65 ,fGeo(NULL)
66 ,fFee(NULL)
8c703901 67 ,fNumberOfDDLs(0)
68{
69 //
70 // Copy constructor
71 //
dfd03fc3 72 fFee = AliTRDfeeParam::Instance();
73 fNumberOfDDLs = AliDAQ::NumberOfDdls("TRD");
8c703901 74}
75
5990c064 76//_____________________________________________________________________________
77AliTRDrawData::~AliTRDrawData()
78{
79 //
80 // Destructor
81 //
8c703901 82}
83
84//_____________________________________________________________________________
85Bool_t AliTRDrawData::Digits2Raw(TTree *digitsTree, TTree *tracks )
86{
87 //
88 // Initialize necessary parameters and call one
89 // of the raw data simulator selected by SetRawVersion.
90 //
91 // Currently tracklet output is not spported yet and it
92 // will be supported in higher version simulator.
93 //
94
8c703901 95 AliTRDdigitsManager* digitsManager = new AliTRDdigitsManager();
96
97 if (!digitsManager->ReadDigits(digitsTree)) {
98 delete digitsManager;
99 return kFALSE;
100 }
101
102 if (tracks != NULL) {
103 delete digitsManager;
7925de54 104 AliError("Tracklet input is not supported yet.");
8c703901 105 return kFALSE;
106 }
107
108 fGeo = new AliTRDgeometry();
109
f162af62 110 if (!AliTRDcalibDB::Instance()) {
7925de54 111 AliError("Could not get calibration object");
8c703901 112 delete fGeo;
113 delete digitsManager;
114 return kFALSE;
115 }
116
117 Int_t retval = kTRUE;
dfd03fc3 118 Int_t rv = fFee->GetRAWversion();
8c703901 119
120 // Call appropriate Raw Simulator
dfd03fc3 121 if ( rv > 0 && rv <= 3 ) retval = Digits2Raw(digitsManager);
7925de54 122 else {
123 retval = kFALSE;
dfd03fc3 124 AliWarning(Form("Unsupported raw version (%d).", rv));
8c703901 125 }
126
127 // Cleanup
128 delete fGeo;
129 delete digitsManager;
130
131 return retval;
132
133}
134
135//_____________________________________________________________________________
50378239 136Bool_t AliTRDrawData::Digits2Raw(AliTRDdigitsManager *digitsManager)
8c703901 137{
138 //
7925de54 139 // Raw data simulator for all versions > 0. This is prepared for real data.
8c703901 140 // This version simulate only raw data with ADC data and not with tracklet.
8c703901 141 //
142
7925de54 143 const Int_t kMaxHcWords = (fGeo->TBmax()/3)*fGeo->ADCmax()*fGeo->MCMmax()*fGeo->ROBmaxC1()/2 + 100 + 20;
8c703901 144
145 // Buffer to temporary store half chamber data
146 UInt_t *hc_buffer = new UInt_t[kMaxHcWords];
147
148 // sect is same as iDDL, so I use only sect here.
149 for (Int_t sect = 0; sect < fGeo->Nsect(); sect++) {
150
151 char name[1024];
152 sprintf(name,"TRD_%d.ddl",sect + AliTRDRawStream::kDDLOffset);
153
08f92f14 154 AliFstream* of = new AliFstream(name);
8c703901 155
156 // Write a dummy data header
157 AliRawDataHeader header; // the event header
08f92f14 158 UInt_t hpos = of->Tellp();
159 of->WriteBuffer((char *) (& header), sizeof(header));
8c703901 160
161 // Reset payload byte size (payload does not include header).
162 Int_t npayloadbyte = 0;
163
7925de54 164 // GTU common data header (5x4 bytes per super module, shows link mask)
8c703901 165 for( Int_t cham = 0; cham < fGeo->Ncham(); cham++ ) {
777fe13b 166 UInt_t GtuCdh = (UInt_t)(0xe << 28);
7925de54 167 for( Int_t plan = 0; plan < fGeo->Nplan(); plan++) {
168 Int_t iDet = fGeo->GetDetector(plan, cham, sect);
169 // If chamber status is ok, we assume that the optical link is also OK.
170 // This is shown in the GTU link mask.
f162af62 171 if ( AliTRDcalibDB::Instance()->GetChamberStatus(iDet) )
7925de54 172 GtuCdh = GtuCdh | (3 << (2*plan));
173 }
08f92f14 174 of->WriteBuffer((char *) (& GtuCdh), sizeof(GtuCdh));
8c703901 175 npayloadbyte += 4;
176 }
177
178 // Prepare chamber data
179 for( Int_t cham = 0; cham < fGeo->Ncham(); cham++) {
180 for( Int_t plan = 0; plan < fGeo->Nplan(); plan++) {
181
182 Int_t iDet = fGeo->GetDetector(plan,cham,sect);
183
184 // Get the digits array
185 AliTRDdataArrayI *digits = digitsManager->GetDigits(iDet);
186 digits->Expand();
187
7925de54 188 Int_t hcwords = 0;
dfd03fc3 189 Int_t rv = fFee->GetRAWversion();
8c703901 190
191 // Process A side of the chamber
dfd03fc3 192 if ( rv >= 1 && rv <= 2 ) hcwords = ProduceHcDataV1andV2(digits,0,iDet,hc_buffer,kMaxHcWords);
193 if ( rv == 3 ) hcwords = ProduceHcDataV3 (digits,0,iDet,hc_buffer,kMaxHcWords);
194
08f92f14 195 of->WriteBuffer((char *) hc_buffer, hcwords*4);
8c703901 196 npayloadbyte += hcwords*4;
197
198 // Process B side of the chamber
dfd03fc3 199 if ( rv >= 1 && rv <= 2 ) hcwords = ProduceHcDataV1andV2(digits,1,iDet,hc_buffer,kMaxHcWords);
200 if ( rv >= 3 ) hcwords = ProduceHcDataV3 (digits,1,iDet,hc_buffer,kMaxHcWords);
201
08f92f14 202 of->WriteBuffer((char *) hc_buffer, hcwords*4);
8c703901 203 npayloadbyte += hcwords*4;
8c703901 204 }
205 }
206
207 // Complete header
08f92f14 208 header.fSize = UInt_t(of->Tellp()) - hpos;
8c703901 209 header.SetAttribute(0); // Valid data
08f92f14 210 of->Seekp(hpos); // Rewind to header position
211 of->WriteBuffer((char *) (& header), sizeof(header));
8c703901 212 delete of;
8c703901 213 }
214
e21c2d7d 215 delete [] hc_buffer;
8c703901 216 return kTRUE;
217
218}
219
220//_____________________________________________________________________________
7925de54 221Int_t AliTRDrawData::ProduceHcDataV1andV2(AliTRDdataArrayI *digits, Int_t side
222 , Int_t det, UInt_t *buf, Int_t maxSize)
8c703901 223{
7925de54 224 //
dfd03fc3 225 // This function simulates: 1) SM-I commissiong data Oct. 06 (Raw Version == 1).
226 // 2) Full Raw Production Version (Raw Version == 2)
8c703901 227 //
228 // Produce half chamber data (= an ORI data) for the given chamber (det) and side (side)
229 // where
7925de54 230 //
8c703901 231 // side=0 means A side with ROB positions 0, 2, 4, 6.
232 // side=1 means B side with ROB positions 1, 3, 5, 7.
233 //
234 // Chamber type (C0 orC1) is determined by "det" automatically.
235 // Appropriate size of buffer (*buf) must be prepared prior to calling this function.
236 // Pointer to the buffer and its size must be given to "buf" and "maxSize".
237 // Return value is the number of valid data filled in the buffer in unit of 32 bits
238 // UInt_t words.
239 // If buffer size if too small, the data is truncated with the buffer size however
240 // the function will finish without crash (this behaviour is similar to the MCM).
241 //
242
243 Int_t nw = 0; // Number of written words
244 Int_t of = 0; // Number of overflowed words
245 Int_t plan = fGeo->GetPlane( det ); // Plane
246 Int_t cham = fGeo->GetChamber( det ); // Chamber
247 Int_t sect = fGeo->GetSector( det ); // Sector (=iDDL)
f162af62 248 Int_t nRow = fGeo->GetRowMax( plan, cham, sect );
249 Int_t nCol = fGeo->GetColMax( plan );
250 const Int_t nTBin = AliTRDcalibDB::Instance()->GetNumberOfTimeBins();
8c703901 251 Int_t kCtype = 0; // Chamber type (0:C0, 1:C1)
252 Int_t iEv = 0xA; // Event ID. Now fixed to 10, how do I get event id?
253 UInt_t x = 0; // General used number
dfd03fc3 254 Int_t rv = fFee->GetRAWversion();
8c703901 255
256 // Check the nCol and nRow.
257 if ((nCol == 144) &&
258 (nRow == 16 || nRow == 12)) {
259 kCtype = (nRow-12) / 4;
260 }
261 else {
7925de54 262 AliError(Form("This type of chamber is not supported (nRow=%d, nCol=%d)."
8c703901 263 ,nRow,nCol));
264 return 0;
265 }
266
267 AliDebug(1,Form("Producing raw data for sect=%d plan=%d cham=%d side=%d"
268 ,sect,plan,cham,side));
269
270 // Tracklet should be processed here but not implemented yet
271
272 // Write end of tracklet marker
273 if (nw < maxSize) {
bd63bf88 274 buf[nw++] = kEndoftrackletmarker;
8c703901 275 }
276 else {
277 of++;
278 }
279
280 // Half Chamber header
dfd03fc3 281 if ( rv == 1 ) {
7925de54 282 // Now it is the same version as used in SM-I commissioning.
283 Int_t dcs = det+100; // DCS Serial (in simulation, it is meaningless
284 x = (dcs<<20) | (sect<<15) | (plan<<12) | (cham<<9) | (side<<8) | 1;
285 if (nw < maxSize) {
286 buf[nw++] = x;
287 }
288 else {
289 of++;
290 }
291 }
dfd03fc3 292 else if ( rv == 2 ) {
bd63bf88 293 // h[0] (there are 3 HC header)
7925de54 294 Int_t minorv = 0; // The minor version number
295 Int_t add = 1; // The number of additional header words to follow
dfd03fc3 296 x = (1<<31) | (rv<<24) | (minorv<<17) | (add<<14) | (sect<<9) | (plan<<6) | (cham<<3) | (side<<2) | 1;
7925de54 297 if (nw < maxSize) {
298 buf[nw++] = x;
299 }
300 else {
301 of++;
302 }
303 // h[1]
304 Int_t bc_ctr = 99; // bunch crossing counter. Here it is set to 99 always for no reason
305 Int_t pt_ctr = 15; // pretrigger counter. Here it is set to 15 always for no reason
306 Int_t pt_phase = 11; // pretrigger phase. Here it is set to 11 always for no reason
307 x = (bc_ctr<<16) | (pt_ctr<<12) | (pt_phase<<8) | ((nTBin-1)<<2) | 1;
308 if (nw < maxSize) {
309 buf[nw++] = x;
310 }
311 else {
312 of++;
313 }
bd63bf88 314 // h[2]
315 Int_t ped_setup = 1; // Pedestal filter setup (0:1). Here it is always 1 for no reason
316 Int_t gain_setup = 1; // Gain filter setup (0:1). Here it is always 1 for no reason
317 Int_t tail_setup = 1; // Tail filter setup (0:1). Here it is always 1 for no reason
318 Int_t xt_setup = 0; // Cross talk filter setup (0:1). Here it is always 0 for no reason
319 Int_t nonlin_setup = 0; // Nonlinearity filter setup (0:1). Here it is always 0 for no reason
320 Int_t bypass_setup = 0; // Filter bypass (for raw data) setup (0:1). Here it is always 0 for no reason
321 Int_t common_additive = 10; // Digital filter common additive (0:63). Here it is always 10 for no reason
322 x = (ped_setup<<31) | (gain_setup<<30) | (tail_setup<<29) | (xt_setup<<28) | (nonlin_setup<<27)
323 | (bypass_setup<<26) | (common_additive<<20) | 1;
324 if (nw < maxSize) {
325 buf[nw++] = x;
326 }
327 else {
328 of++;
329 }
8c703901 330 }
331
332 // Scan for ROB and MCM
333 for (Int_t iRobRow = 0; iRobRow < (kCtype + 3); iRobRow++ ) {
334 Int_t iRob = iRobRow * 2 + side;
7925de54 335 for (Int_t iMcm = 0; iMcm < fGeo->MCMmax(); iMcm++ ) {
8c703901 336 Int_t padrow = iRobRow * 4 + iMcm / 4;
337
338 // MCM header
7925de54 339 x = ((iRob * fGeo->MCMmax() + iMcm) << 24) | ((iEv % 0x100000) << 4) | 0xC;
8c703901 340 if (nw < maxSize) {
341 buf[nw++] = x;
342 }
343 else {
344 of++;
345 }
346
347 // ADC data
348 for (Int_t iAdc = 0; iAdc < 21; iAdc++ ) {
bd63bf88 349 Int_t padcol = fGeo->GetPadColFromADC(iRob, iMcm, iAdc);
7925de54 350 UInt_t aa = !(iAdc & 1) + 2;
8c703901 351 UInt_t *a = new UInt_t[nTBin+2];
352 // 3 timebins are packed into one 32 bits word
353 for (Int_t iT = 0; iT < nTBin; iT+=3) {
7925de54 354 if ((padcol >= 0) && (padcol < nCol)) {
355 a[iT ] = ((iT ) < nTBin ) ? digits->GetDataUnchecked(padrow,padcol,iT ) : 0;
356 a[iT+1] = ((iT + 1) < nTBin ) ? digits->GetDataUnchecked(padrow,padcol,iT + 1) : 0;
357 a[iT+2] = ((iT + 2) < nTBin ) ? digits->GetDataUnchecked(padrow,padcol,iT + 2) : 0;
358 }
359 else {
360 a[iT] = a[iT+1] = a[iT+2] = 0; // This happenes at the edge of chamber (should be pedestal! How?)
8c703901 361 }
7925de54 362 x = (a[iT+2] << 22) | (a[iT+1] << 12) | (a[iT] << 2) | aa;
363 if (nw < maxSize) {
364 buf[nw++] = x;
8c703901 365 }
7925de54 366 else {
367 of++;
8c703901 368 }
7925de54 369 }
8c703901 370 // Diagnostics
371 Float_t avg = 0;
372 Float_t rms = 0;
373 for (Int_t iT = 0; iT < nTBin; iT++) {
374 avg += (Float_t) (a[iT]);
375 }
376 avg /= (Float_t) nTBin;
377 for (Int_t iT = 0; iT < nTBin; iT++) {
378 rms += ((Float_t) (a[iT]) - avg) * ((Float_t) (a[iT]) - avg);
379 }
380 rms = TMath::Sqrt(rms / (Float_t) nTBin);
381 if (rms > 1.7) {
7925de54 382 AliDebug(2,Form("Large RMS (>1.7) (ROB,MCM,ADC)=(%02d,%02d,%02d), avg=%03.1f, rms=%03.1f"
383 ,iRob,iMcm,iAdc,avg,rms));
8c703901 384 }
e21c2d7d 385 delete [] a;
8c703901 386 }
387 }
388 }
389
390 // Write end of raw data marker
391 if (nw < maxSize) {
bd63bf88 392 buf[nw++] = kEndofrawdatamarker;
8c703901 393 }
394 else {
395 of++;
396 }
397 if (of != 0) {
398 AliWarning("Buffer overflow. Data is truncated. Please increase buffer size and recompile.");
399 }
400
401 return nw;
5990c064 402
403}
404
dfd03fc3 405
406//_____________________________________________________________________________
407Int_t AliTRDrawData::ProduceHcDataV3(AliTRDdataArrayI *digits, Int_t side
408 , Int_t det, UInt_t *buf, Int_t maxSize)
409{
410 //
411 // This function simulates: Raw Version == 3 (Zero Suppression Prototype)
412 //
413
414 Int_t nw = 0; // Number of written words
415 Int_t of = 0; // Number of overflowed words
416 Int_t plan = fGeo->GetPlane( det ); // Plane
417 Int_t cham = fGeo->GetChamber( det ); // Chamber
418 Int_t sect = fGeo->GetSector( det ); // Sector (=iDDL)
419 Int_t nRow = fGeo->GetRowMax( plan, cham, sect );
420 Int_t nCol = fGeo->GetColMax( plan );
421 const Int_t nTBin = AliTRDcalibDB::Instance()->GetNumberOfTimeBins();
422 Int_t kCtype = 0; // Chamber type (0:C0, 1:C1)
423 Int_t iEv = 0xA; // Event ID. Now fixed to 10, how do I get event id?
424 UInt_t x = 0; // General used number
425 Int_t rv = fFee->GetRAWversion();
426
427 // Check the nCol and nRow.
428 if ((nCol == 144) &&
429 (nRow == 16 || nRow == 12)) {
430 kCtype = (nRow-12) / 4;
431 }
432 else {
433 AliError(Form("This type of chamber is not supported (nRow=%d, nCol=%d)."
434 ,nRow,nCol));
435 return 0;
436 }
437
438 AliDebug(1,Form("Producing raw data for sect=%d plan=%d cham=%d side=%d"
439 ,sect,plan,cham,side));
440
441 // Tracklet should be processed here but not implemented yet
442
443 // Write end of tracklet marker
444 if (nw < maxSize) {
445 buf[nw++] = kEndoftrackletmarker;
446 }
447 else {
448 of++;
449 }
450
451 // Half Chamber header
452 // h[0] (there are 3 HC header)
453 Int_t minorv = 0; // The minor version number
454 Int_t add = 1; // The number of additional header words to follow
455 x = (1<<31) | (rv<<24) | (minorv<<17) | (add<<14) | (sect<<9) | (plan<<6) | (cham<<3) | (side<<2) | 1;
456 if (nw < maxSize) {
457 buf[nw++] = x;
458 }
459 else {
460 of++;
461 }
462 // h[1]
463 Int_t bc_ctr = 99; // bunch crossing counter. Here it is set to 99 always for no reason
464 Int_t pt_ctr = 15; // pretrigger counter. Here it is set to 15 always for no reason
465 Int_t pt_phase = 11; // pretrigger phase. Here it is set to 11 always for no reason
466 x = (bc_ctr<<16) | (pt_ctr<<12) | (pt_phase<<8) | ((nTBin-1)<<2) | 1;
467 if (nw < maxSize) {
468 buf[nw++] = x;
469 }
470 else {
471 of++;
472 }
473 // h[2]
474 Int_t ped_setup = 1; // Pedestal filter setup (0:1). Here it is always 1 for no reason
475 Int_t gain_setup = 1; // Gain filter setup (0:1). Here it is always 1 for no reason
476 Int_t tail_setup = 1; // Tail filter setup (0:1). Here it is always 1 for no reason
477 Int_t xt_setup = 0; // Cross talk filter setup (0:1). Here it is always 0 for no reason
478 Int_t nonlin_setup = 0; // Nonlinearity filter setup (0:1). Here it is always 0 for no reason
479 Int_t bypass_setup = 0; // Filter bypass (for raw data) setup (0:1). Here it is always 0 for no reason
480 Int_t common_additive = 10; // Digital filter common additive (0:63). Here it is always 10 for no reason
481 x = (ped_setup<<31) | (gain_setup<<30) | (tail_setup<<29) | (xt_setup<<28) | (nonlin_setup<<27)
482 | (bypass_setup<<26) | (common_additive<<20) | 1;
483 if (nw < maxSize) {
484 buf[nw++] = x;
485 }
486 else {
487 of++;
488 }
489
490 AliTRDmcmSim *mcm = new AliTRDmcmSim();
491
492 // Scan for ROB and MCM
493 for (Int_t iRobRow = 0; iRobRow < (kCtype + 3); iRobRow++ ) {
494 Int_t iRob = iRobRow * 2 + side;
495 for (Int_t iMcm = 0; iMcm < fGeo->MCMmax(); iMcm++ ) {
496
497 mcm->Init( det, iRob, iMcm );
498 Int_t padrow = mcm->GetRow();
499
500 // Copy ADC data to MCM simulator
501 for (Int_t iAdc = 0; iAdc < 21; iAdc++ ) {
502 Int_t padcol = mcm->GetCol( iAdc );
503 if ((padcol >= 0) && (padcol < nCol)) {
504 for (Int_t iT = 0; iT < nTBin; iT++) {
505 mcm->SetData( iAdc, iT, digits->GetDataUnchecked( padrow, padcol, iT) );
506 }
507 } else { // this means it is out of chamber, and masked ADC
508 mcm->SetDataPedestal( iAdc );
509 }
510 }
511 // Simulate process in MCM
512 mcm->Filter(); // Apply filter
513 mcm->ZSMapping(); // Calculate zero suppression mapping
514
515 // Write MCM data to buffer
516 Int_t temp_nw = mcm->ProduceRawStream( &buf[nw], maxSize - nw );
517 if( temp_nw < 0 ) {
518 of += temp_nw;
519 nw += maxSize - nw;
520 AliError(Form("Buffer overflow detected. Please increase the buffer size and recompile."));
521 } else {
522 nw += temp_nw;
523 }
524 }
525 }
526
527 // Write end of raw data marker
528 if (nw < maxSize) {
529 buf[nw++] = kEndofrawdatamarker;
530 }
531 else {
532 of++;
533 }
534 if (of != 0) {
535 AliWarning("Buffer overflow. Data is truncated. Please increase buffer size and recompile.");
536 }
537
538 return nw;
539
540}
541
5990c064 542//_____________________________________________________________________________
7925de54 543AliTRDdigitsManager *AliTRDrawData::Raw2Digits(AliRawReader *rawReader)
5990c064 544{
b864d801 545 //
50378239 546 // Vx of the raw data reading
b864d801 547 //
5990c064 548
2cb20be6 549 AliTRDdataArrayI *digits = 0;
550 AliTRDdataArrayI *track0 = 0;
551 AliTRDdataArrayI *track1 = 0;
552 AliTRDdataArrayI *track2 = 0;
5990c064 553
ca21baaa 554 AliTRDSignalIndex *indexes = 0;
5990c064 555 // Create the digits manager
b864d801 556 AliTRDdigitsManager* digitsManager = new AliTRDdigitsManager();
b864d801 557 digitsManager->CreateArrays();
5990c064 558
3551db50 559 AliTRDRawStream input(rawReader);
dfd03fc3 560 input.SetRawVersion( fFee->GetRAWversion() );
50378239 561 input.Init();
5990c064 562
b864d801 563 // Loop through the digits
50378239 564 Int_t lastdet = -1;
565 Int_t det = 0;
566 Int_t it = 0;
567 while (input.Next())
568 {
569
570 det = input.GetDet();
571
572 if (det != lastdet)
573 {
574
575 lastdet = det;
576
577 if (digits) digits->Compress(1,0);
578 if (track0) track0->Compress(1,0);
579 if (track1) track1->Compress(1,0);
580 if (track2) track2->Compress(1,0);
581
582 // Add a container for the digits of this detector
583 digits = digitsManager->GetDigits(det);
584 track0 = digitsManager->GetDictionary(det,0);
585 track1 = digitsManager->GetDictionary(det,1);
586 track2 = digitsManager->GetDictionary(det,2);
587
588 // Allocate memory space for the digits buffer
589 if (digits->GetNtime() == 0)
590 {
591 digits->Allocate(input.GetMaxRow(),input.GetMaxCol(), input.GetNumberOfTimeBins());
592 track0->Allocate(input.GetMaxRow(),input.GetMaxCol(), input.GetNumberOfTimeBins());
593 track1->Allocate(input.GetMaxRow(),input.GetMaxCol(), input.GetNumberOfTimeBins());
594 track2->Allocate(input.GetMaxRow(),input.GetMaxCol(), input.GetNumberOfTimeBins());
595 }
ca21baaa 596
597 indexes = digitsManager->GetIndexes(det);
598 indexes->SetSM(input.GetSM());
599 indexes->SetStack(input.GetStack());
600 indexes->SetLayer(input.GetLayer());
601 indexes->SetDetNumber(det);
602 if (indexes->IsAllocated() == kFALSE)
603 indexes->Allocate(input.GetMaxRow(), input.GetMaxCol(), input.GetNumberOfTimeBins());
50378239 604 }
605
606 for (it = 0; it < 3; it++)
607 {
608 if ( input.GetTimeBin() + it < input.GetNumberOfTimeBins() )
609 {
ca21baaa 610 if (input.GetSignals()[it] > 0)
611 {
612 digits->SetDataUnchecked(input.GetRow(), input.GetCol(),
613 input.GetTimeBin() + it, input.GetSignals()[it]);
614
615 indexes->AddIndexTBin(input.GetRow(), input.GetCol(),
616 input.GetTimeBin() + it);
617 track0->SetDataUnchecked(input.GetRow(), input.GetCol(),
618 input.GetTimeBin() + it, 0);
619 track1->SetDataUnchecked(input.GetRow(), input.GetCol(),
620 input.GetTimeBin() + it, 0);
621 track2->SetDataUnchecked(input.GetRow(), input.GetCol(),
622 input.GetTimeBin() + it, 0);
623 }
50378239 624 }
625 }
5990c064 626 }
627
b864d801 628 if (digits) digits->Compress(1,0);
928e9fae 629 if (track0) track0->Compress(1,0);
630 if (track1) track1->Compress(1,0);
631 if (track2) track2->Compress(1,0);
b864d801 632
7925de54 633 return digitsManager;
634
635}