]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOFDDLRawData.cxx
Remove a run from LHC10e wo AODs; added run list for the new PbPb MC LHC11a10b_bis
[u/mrichter/AliRoot.git] / TOF / AliTOFDDLRawData.cxx
CommitLineData
7e6dce66 1/**************************************************************************
2 * Copyright(c) 1998-2003, 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/*
d0eb8f39 17$Log$
96f01799 18Revision 1.19 2007/06/22 11:37:47 cvetan
19Fixes in order to write correct raw-data on big-endian platforms (Marco)
20
08f92f14 21Revision 1.18 2007/05/21 13:26:19 decaro
22Correction on matching_window control and bug fixing (R.Preghenella)
23
018d19cf 24Revision 1.17 2007/05/10 09:29:34 hristov
25Last moment fixes and changes from v4-05-Release (Silvia)
26
d321691a 27Revision 1.16 2007/05/03 09:07:22 decaro
28Double digit in the same TDC channel. Wrong sequence during the raw data writing in unpacked mode: solved
29
a403781d 30Revision 1.15 2007/04/23 16:51:39 decaro
31Digits-to-raw_data conversion: correction for a more real description (A.De Caro, R.Preghenella)
32
515faf5d 33Revision 1.14 2007/03/28 10:50:33 decaro
34Rounding off problem in rawData coding/decoding: solved
35
d11fc181 36Revision 1.13 2007/02/20 15:57:00 decaro
37Raw data update: to read the TOF raw data defined in UNPACKED mode
38
15ec34b9 39Revision 1.12 2006/08/22 13:29:42 arcelli
40removal of effective c++ warnings (C.Zampolli)
41
655e379f 42Revision 1.11 2006/08/10 14:46:54 decaro
43TOF raw data format: updated version
44
d0eb8f39 45Revision 1.10.1 2006/06/28 A.De Caro
46 Update TOF raw data format
47 according to the final version
48 (see ALICE internal note in preparation
49 'ALICE TOF raw data format')
50
571dda3d 51Revision 0.02 2005/7/25 A.De Caro
52 Update number of bits allocated for time-of-flight
53 and 'charge' measurements
54
7e6dce66 55Revision 0.01 2004/6/11 A.De Caro, S.B.Sellitto, R.Silvestri
56 First implementation: global methods RawDataTOF
57 GetDigits
7e6dce66 58*/
571dda3d 59
d0eb8f39 60////////////////////////////////////////////////////////////////////
61// //
62// This class contains the methods to create the Raw Data files //
63// for the TOF detector starting from the Digits. //
64// In this implementation, we defined the structure //
65// of the ALICE-TOF raw data (according to the //
66// ALICE technical note, in preparation) //
67// starting from the TOF digit format. //
68// //
69////////////////////////////////////////////////////////////////////
7e6dce66 70
0e46b9ae 71#include "Riostream.h"
72
73#include "TBranch.h"
74#include "TClonesArray.h"
75#include "TMath.h"
d0eb8f39 76#include "TRandom.h"
43f77f2d 77
571dda3d 78#include "AliBitPacking.h"
d0eb8f39 79#include "AliDAQ.h"
0e46b9ae 80#include "AliLog.h"
d0eb8f39 81//#include "AliRawDataHeader.h"
82#include "AliRawDataHeaderSim.h"
32ead898 83#include "AliFstream.h"
571dda3d 84
0e46b9ae 85#include "AliTOFDDLRawData.h"
d0eb8f39 86#include "AliTOFDigitMap.h"
7e6dce66 87#include "AliTOFdigit.h"
0e46b9ae 88#include "AliTOFGeometry.h"
571dda3d 89#include "AliTOFRawStream.h"
32ead898 90//#include "AliTOFCableLengthMap.h"
d0eb8f39 91
92extern TRandom *gRandom;
7e6dce66 93
94ClassImp(AliTOFDDLRawData)
95
d0eb8f39 96//---------------------------------------------------------------------------
655e379f 97AliTOFDDLRawData::AliTOFDDLRawData():
6e4ef37b 98 TObject(),
655e379f 99 fVerbose(0),
100 fIndex(-1),
32ead898 101 fPackedAcquisition(kFALSE),
515faf5d 102 fFakeOrphaneProduction(kFALSE),
103 fMatchingWindow(8192),
655e379f 104 fTOFdigitMap(new AliTOFDigitMap()),
c5cf594b 105 fTOFdigitArray(0x0),
106 fWordsPerDRM(0),
107 fWordsPerTRM(0),
108 fWordsPerChain(0)
7e6dce66 109{
110 //Default constructor
d3c7bfac 111}
d0eb8f39 112//----------------------------------------------------------------------------
113AliTOFDDLRawData::AliTOFDDLRawData(const AliTOFDDLRawData &source) :
655e379f 114 TObject(source),
8a190ba2 115 fVerbose(source.fVerbose),
116 fIndex(source.fIndex),
117 fPackedAcquisition(source.fPackedAcquisition),
118 fFakeOrphaneProduction(source.fFakeOrphaneProduction),
119 fMatchingWindow(source.fMatchingWindow),
120 fTOFdigitMap(source.fTOFdigitMap),
c5cf594b 121 fTOFdigitArray(source.fTOFdigitArray),
122 fWordsPerDRM(source.fWordsPerDRM),
123 fWordsPerTRM(source.fWordsPerTRM),
124 fWordsPerChain(source.fWordsPerChain)
655e379f 125 {
7e6dce66 126 //Copy Constructor
7e6dce66 127 return;
128}
129
d0eb8f39 130//----------------------------------------------------------------------------
131AliTOFDDLRawData& AliTOFDDLRawData::operator=(const AliTOFDDLRawData &source) {
7e6dce66 132 //Assigment operator
8a190ba2 133
134 if (this == &source)
135 return *this;
136
137 TObject::operator=(source);
138 fIndex=source.fIndex;
139 fVerbose=source.fVerbose;
140 fPackedAcquisition=source.fPackedAcquisition;
141 fFakeOrphaneProduction=source.fFakeOrphaneProduction;
142 fMatchingWindow=source.fMatchingWindow;
143 fTOFdigitMap=source.fTOFdigitMap;
144 fTOFdigitArray=source.fTOFdigitArray;
c5cf594b 145 fWordsPerDRM=source.fWordsPerDRM;
146 fWordsPerTRM=source.fWordsPerTRM;
147 fWordsPerChain=source.fWordsPerChain;
7e6dce66 148 return *this;
149}
150
d321691a 151//----------------------------------------------------------------------------
152AliTOFDDLRawData::~AliTOFDDLRawData()
153{
c5cf594b 154 // dtr
155
d321691a 156 delete fTOFdigitMap;
d321691a 157}
d0eb8f39 158//----------------------------------------------------------------------------
159Int_t AliTOFDDLRawData::RawDataTOF(TBranch* branch)
7e6dce66 160{
571dda3d 161 //
162 // This method creates the Raw data files for TOF detector
163 //
164
6e4ef37b 165 const Int_t kSize = 5000; // max number of digits per DDL file times 2
571dda3d 166
7e6dce66 167 UInt_t buf[kSize];
7e6dce66 168
6e4ef37b 169 // To clear the digit indices map for each event
170 fTOFdigitMap->Clear();
171
d0eb8f39 172 fIndex = -1;
173
174 fTOFdigitArray = * (TClonesArray**) branch->GetAddress();
7e6dce66 175
6e4ef37b 176 AliFstream* outfile; // logical name of the output file
d0eb8f39 177
d0eb8f39 178 AliRawDataHeaderSim header;
179
571dda3d 180 UInt_t sizeRawData = 0;
7e6dce66 181
d0eb8f39 182 branch->GetEvent();
183
184 GetDigits();
185
3e2f0097 186 //if (!fPackedAcquisition) fMatchingWindow = 2097152;//AdC
187
d0eb8f39 188 Int_t jj = -1;
189 Int_t iDDL = -1;
190 Int_t nDDL = -1;
191 Int_t nTRM = 0;
192 Int_t iChain = -1;
193
7e6dce66 194 //loop over TOF DDL files
d0eb8f39 195 for (nDDL=0; nDDL<AliDAQ::NumberOfDdls("TOF"); nDDL++) {
571dda3d 196
d6d4cfce 197 char fileName[256]="";
198 strncpy(fileName,AliDAQ::DdlFileName("TOF",nDDL),255); //The name of the output file
571dda3d 199
08f92f14 200 outfile = new AliFstream(fileName);
177b002e 201 iDDL = AliTOFRawStream::GetDDLnumberPerSector(nDDL);
d0eb8f39 202
203 // write Dummy DATA HEADER
08f92f14 204 UInt_t dataHeaderPosition = outfile->Tellp();
205 outfile->WriteBuffer((char*)(&header),sizeof(header));
7e6dce66 206
d0eb8f39 207 // DRM section: trailer
208 MakeDRMtrailer(buf);
7e6dce66 209
d0eb8f39 210 // loop on TRM number per DRM
211 for (nTRM=AliTOFGeometry::NTRM(); nTRM>=3; nTRM--) {
212
c5cf594b 213 fWordsPerTRM = 0;
d0eb8f39 214
215 // the slot number 3 of the even DRM (i.e. right) doesn't contain TDC digit data
216 if (iDDL%2==0 && nTRM==3) continue;
217
d0eb8f39 218 // loop on TRM chain number per TRM
219 for (iChain=AliTOFGeometry::NChain()-1; iChain>=0; iChain--) {
220
221 // TRM chain trailer
c5cf594b 222 MakeTRMchainTrailer(iChain, buf); fWordsPerTRM++;
d0eb8f39 223
224 // TRM TDC digits
c5cf594b 225 MakeTDCdigits(nDDL, nTRM, iChain, buf);
d0eb8f39 226
227 // TRM chain header
c5cf594b 228 MakeTRMchainHeader(nTRM, iChain, buf); fWordsPerTRM++;
d0eb8f39 229
230 } // end loop on iChain
7e6dce66 231
d0eb8f39 232 // TRM global header
c5cf594b 233 MakeTRMheader(nTRM, buf); fWordsPerTRM++;
d0eb8f39 234
235 // TRM filler in case where TRM data number is odd
c5cf594b 236 if ((fWordsPerTRM+1)%2!=0) {
237 MakeTRMfiller(buf); fWordsPerTRM++;
238 }
239
240 MakeTRMtrailer(buf); fWordsPerDRM++;
241
242 fWordsPerDRM += fWordsPerTRM;
d0eb8f39 243
244 } // end loop on nTRM
c5cf594b 245
246
247 // LTM section
248 //fIndex++;
249 //buf[fIndex] = MakeFiller(); fWordsPerDRM++; // valid till when LTM word number was 33
250 MakeLTMtrailer(buf); fWordsPerDRM++;
251 MakeLTMdata(buf); fWordsPerDRM+=48;
252 MakeLTMheader(buf); fWordsPerDRM++;
253
d0eb8f39 254 // DRM section: in
255 MakeDRMheader(nDDL, buf);
256
257 ReverseArray(buf, fIndex+1);
7e6dce66 258
08f92f14 259 outfile->WriteBuffer((char *)buf,((fIndex+1)*sizeof(UInt_t)));
7e6dce66 260
d0eb8f39 261 for (jj=0; jj<(fIndex+1); jj++) buf[jj]=0;
262 fIndex = -1;
7e6dce66 263
264 //Write REAL DATA HEADER
08f92f14 265 UInt_t currentFilePosition = outfile->Tellp();
571dda3d 266 sizeRawData = currentFilePosition - dataHeaderPosition - sizeof(header);
d0eb8f39 267 header.fSize = currentFilePosition - dataHeaderPosition;
7e6dce66 268 header.SetAttribute(0); // valid data
08f92f14 269 outfile->Seekp(dataHeaderPosition);
270 outfile->WriteBuffer((char*)(&header),sizeof(header));
271 outfile->Seekp(currentFilePosition);
571dda3d 272
08f92f14 273 delete outfile;
7e6dce66 274
d0eb8f39 275 } //end loop on DDL file number
276
277 return 0;
278
279}
280
281//----------------------------------------------------------------------------
282void AliTOFDDLRawData::GetDigits()
283{
284 //
285 // Fill the TOF volumes' map with the TOF digit indices
286 //
287
288 Int_t vol[5] = {-1,-1,-1,-1,-1};
289
290 Int_t digit = -1;
291 Int_t ndigits = fTOFdigitArray->GetEntries();
96b13296 292 AliDebug(2, Form(" Number of read digits = %d",ndigits));
d0eb8f39 293 AliTOFdigit *digs;
294
295 // loop on TOF digits
296 for (digit=0; digit<ndigits; digit++) {
297 digs = (AliTOFdigit*)fTOFdigitArray->UncheckedAt(digit);
298
299 vol[0] = digs->GetSector(); // Sector Number (0-17)
300 vol[1] = digs->GetPlate(); // Plate Number (0-4)
301 vol[2] = digs->GetStrip(); // Strip Number (0-14/18)
302 vol[3] = digs->GetPadx(); // Pad Number in x direction (0-47)
303 vol[4] = digs->GetPadz(); // Pad Number in z direction (0-1)
304
305 fTOFdigitMap->AddDigit(vol, digit);
306
307 } // close loop on digit del TOF
96b13296 308 AliDebug(2,Form(" Number of mapped digits = %d",fTOFdigitMap->GetFilledCellNumber()));
d0eb8f39 309}
310
311//----------------------------------------------------------------------------
312void AliTOFDDLRawData::MakeDRMheader(Int_t nDDL, UInt_t *buf)
313{
314 //
315 // DRM global header
316 //
317
177b002e 318 //Int_t iDDL = fTOFrawStream->GetDDLnumberPerSector(nDDL);
319 Int_t iDDL = AliTOFRawStream::GetDDLnumberPerSector(nDDL);
d0eb8f39 320
177b002e 321 //Int_t iSector = fTOFrawStream->GetSectorNumber(nDDL);
322 Int_t iSector = AliTOFRawStream::GetSectorNumber(nDDL);
d0eb8f39 323
324 UInt_t baseWord=0;
325 UInt_t word;
326
327 // DRM event CRC
328 baseWord=0;
329 word = 1; // 0001 -> DRM data are coming from the VME slot number 1
330 AliBitPacking::PackWord(word,baseWord, 0, 3);
c5cf594b 331 word = 0; // event CRC --> CHANGED
d0eb8f39 332 AliBitPacking::PackWord(word,baseWord, 4,19);
333 word = 0; // reserved for future use
334 AliBitPacking::PackWord(word,baseWord,20,27);
335 word = 4; // 0100 -> DRM header ID
336 AliBitPacking::PackWord(word,baseWord,28,31);
337 fIndex++;
338 buf[fIndex]=baseWord;
339
73620dbf 340 // DRM status header 4
341 baseWord=0;
342 word = 1; // 0001 -> DRM data are coming from the VME slot number 1
343 AliBitPacking::PackWord(word,baseWord, 0, 3);
344 word = 0; // temperature
345 AliBitPacking::PackWord(word,baseWord, 4,13);
346 word = 0; // zero
347 AliBitPacking::PackWord(word,baseWord, 14,14);
348 word = 0; // ACK
349 AliBitPacking::PackWord(word,baseWord, 15,15);
350 word = 0; // Sens AD
351 AliBitPacking::PackWord(word,baseWord, 16,18);
352 word = 0; // zero
353 AliBitPacking::PackWord(word,baseWord, 19,19);
354 word = 0; // reserved for future use
355 AliBitPacking::PackWord(word,baseWord, 20,27);
356 word = 4; // 0100 -> DRM header ID
357 AliBitPacking::PackWord(word,baseWord,28,31);
358 fIndex++;
359 buf[fIndex]=baseWord;
360
d0eb8f39 361 // DRM status header 3
362 baseWord=0;
363 word = 1; // 0001 -> DRM data are coming from the VME slot number 1
364 AliBitPacking::PackWord(word,baseWord, 0, 3);
73620dbf 365 word = 0; // L0 BCID
366 AliBitPacking::PackWord(word,baseWord, 4,15);
367 word = 0; // Run Time info
368 AliBitPacking::PackWord(word,baseWord, 16,27);
d0eb8f39 369 word = 4; // 0100 -> DRM header ID
370 AliBitPacking::PackWord(word,baseWord,28,31);
371 fIndex++;
372 buf[fIndex]=baseWord;
373
374 // DRM status header 2
375 baseWord=0;
376 word = 1; // 0001 -> DRM data are coming from the VME slot number 1
377 AliBitPacking::PackWord(word,baseWord, 0, 3);
378
379 if (iDDL%2==1) {
380 word = 2047; // enable ID: [00000000000;11111111111] for odd
381 // (i.e. right) crates
382 AliBitPacking::PackWord(word,baseWord, 4,14);
383 } else {
384 word = 2045; // enable ID: [00000000000;11111111101] for even
385 // (i.e. left) crates
386 AliBitPacking::PackWord(word,baseWord, 4,14);
387 }
388
389 word = 0; //
390 AliBitPacking::PackWord(word,baseWord,15,15);
391 word = 0; // fault ID
73620dbf 392 AliBitPacking::PackWord(word,baseWord,16,26);
393 word = 0; // RTO
394 AliBitPacking::PackWord(word,baseWord,27,27);
d0eb8f39 395 word = 4; // 0100 -> DRM header ID
396 AliBitPacking::PackWord(word,baseWord,28,31);
397 fIndex++;
398 buf[fIndex]=baseWord;
7e6dce66 399
d0eb8f39 400 // DRM status header 1
401 baseWord=0;
402 word = 1; // 0001 -> DRM data are coming from the VME slot number 1
403 AliBitPacking::PackWord(word,baseWord, 0, 3);
404
405 if (iDDL%2==1) {
406 word = 2047; // slot ID: [00000000000;11111111111] for odd
407 // (i.e. right) crates
408 AliBitPacking::PackWord(word,baseWord, 4,14);
409 } else {
410 word = 2045; // slot ID: [00000000000;11111111101] for even
411 // (i.e. left) crates
412 AliBitPacking::PackWord(word,baseWord, 4,14);
413 }
414
415 word = 1; // LHC clock status: 1/0
416 AliBitPacking::PackWord(word,baseWord,15,15);
73620dbf 417 word = 0; // Vers ID
418 AliBitPacking::PackWord(word,baseWord,16,20);
419 word = 0; // DRMH size
420 AliBitPacking::PackWord(word,baseWord,21,24);
d0eb8f39 421 word = 0; // reserved for future use
73620dbf 422 AliBitPacking::PackWord(word,baseWord,25,27);
d0eb8f39 423 word = 4; // 0100 -> DRM header ID
424 AliBitPacking::PackWord(word,baseWord,28,31);
425 fIndex++;
426 buf[fIndex]=baseWord;
427
428 // DRM global header
429 baseWord=0;
430 word = 1; // 0001 -> DRM data are coming from the VME slot number 1
431 AliBitPacking::PackWord(word,baseWord, 0, 3);
432 word = fIndex+1 + 1; // event words
433 AliBitPacking::PackWord(word,baseWord, 4,20);
434 word = iDDL; // crate ID [0;3]
435 AliBitPacking::PackWord(word,baseWord,21,22);
436 word = iSector; // sector ID [0;17]
437 AliBitPacking::PackWord(word,baseWord,23,27);
438 word = 4; // 0100 -> DRM header ID
439 AliBitPacking::PackWord(word,baseWord,28,31);
440 fIndex++;
441 buf[fIndex]=baseWord;
442
7e6dce66 443}
444
d0eb8f39 445//----------------------------------------------------------------------------
446void AliTOFDDLRawData::MakeDRMtrailer(UInt_t *buf)
447{
448 //
449 // DRM global trailer
450 //
451
452 UInt_t baseWord;
453 UInt_t word;
454
455 baseWord=0;
456 word = 1; // 0001 -> DRM data are coming from the VME slot number 1
457 AliBitPacking::PackWord(word,baseWord, 0, 3);
c5cf594b 458 word = 0; // local event counter --> TO BE CHANGED IN fWordsPerDRM+5
d0eb8f39 459 AliBitPacking::PackWord(word,baseWord, 4,15);
460 word = 0; // reserved for future use
461 AliBitPacking::PackWord(word,baseWord,16,27);
462 word = 5; // 0101 -> DRM trailer ID
463 AliBitPacking::PackWord(word,baseWord,28,31);
464 fIndex++;
465 buf[fIndex]=baseWord;
466
467}
468
469//----------------------------------------------------------------------------
470void AliTOFDDLRawData::MakeLTMheader(UInt_t *buf)
471{
472 //
473 // LTM header
474 //
475
476 UInt_t baseWord;
477 UInt_t word;
478
479 baseWord=0;
480 word = 2; // 0010 -> LTM data are coming from the VME slot number 2
481 AliBitPacking::PackWord(word,baseWord, 0, 3);
482 word = 35; // event words
483 AliBitPacking::PackWord(word,baseWord, 4,16);
484 word = 0; // crc error
485 AliBitPacking::PackWord(word,baseWord,17,17);
486 word = 0; // fault
487 AliBitPacking::PackWord(word,baseWord,18,23);
488 word = 0;
489 AliBitPacking::PackWord(word,baseWord,24,27);
490 word = 4; // 0100 -> LTM header ID
491 AliBitPacking::PackWord(word,baseWord,28,31);
492 fIndex++;
493 buf[fIndex]=baseWord;
494
495}
496
497//----------------------------------------------------------------------------
498void AliTOFDDLRawData::MakeLTMdata(UInt_t *buf)
499{
500 //
501 // LTM data
502 //
503
504 UInt_t baseWord;
505 UInt_t word;
96b13296 506
d0eb8f39 507 baseWord=0;
96b13296 508 word = 0;
509 AliBitPacking::PackWord(word,baseWord,0,9);
510 word = 0;
d0eb8f39 511 AliBitPacking::PackWord(word,baseWord,10,19);
96b13296 512 word = 0;
d0eb8f39 513 AliBitPacking::PackWord(word,baseWord,20,29);
514 word = 0;
96b13296 515 AliBitPacking::PackWord(word,baseWord,30,30);
516 word = 0;
517 AliBitPacking::PackWord(word,baseWord,31,31);
518
519
520 // OR45, OR46, OR47
521 fIndex++;
522 buf[fIndex]=baseWord;
523
524 // OR42, OR43, OR44
525 fIndex++;
526 buf[fIndex]=baseWord;
527
528 // OR39, OR40, OR41
529 fIndex++;
530 buf[fIndex]=baseWord;
531
532 // OR36, OR37, OR38
533 fIndex++;
534 buf[fIndex]=baseWord;
535
536 // OR33, OR34, OR35
537 fIndex++;
538 buf[fIndex]=baseWord;
539
540 // OR30, OR31, OR32
541 fIndex++;
542 buf[fIndex]=baseWord;
543
544 // OR27, OR28, OR29
545 fIndex++;
546 buf[fIndex]=baseWord;
547
548 // OR24, OR25, OR26
549 fIndex++;
550 buf[fIndex]=baseWord;
551
552 // OR21, OR22, OR23
553 fIndex++;
554 buf[fIndex]=baseWord;
555
556 // OR18, OR19, OR20
557 fIndex++;
558 buf[fIndex]=baseWord;
d0eb8f39 559
96b13296 560 // OR15, OR16, OR17
d0eb8f39 561 fIndex++;
562 buf[fIndex]=baseWord;
563
96b13296 564 // OR12, OR12, OR24
d0eb8f39 565 fIndex++;
566 buf[fIndex]=baseWord;
567
96b13296 568 // OR9, OR10, OR11
d0eb8f39 569 fIndex++;
570 buf[fIndex]=baseWord;
571
96b13296 572 // OR6, OR7, OR8
d0eb8f39 573 fIndex++;
574 buf[fIndex]=baseWord;
575
96b13296 576 // OR3, OR4, OR5
d0eb8f39 577 fIndex++;
578 buf[fIndex]=baseWord;
579
96b13296 580 // OR0, OR1, OR2
581 fIndex++;
582 buf[fIndex]=baseWord;
583
584
585
d0eb8f39 586 baseWord=0;
96b13296 587 word = 100; // Local temperature in LTM11 -> 4 X 25 degree (environment temperature)
d0eb8f39 588 AliBitPacking::PackWord(word,baseWord, 0, 9);
96b13296 589 word = 100; // Local temperature in LTM10 -> 4 X 25 degree (environment temperature)
d0eb8f39 590 AliBitPacking::PackWord(word,baseWord,10,19);
96b13296 591 word = 100; // Local temperature in LTM9 -> 4 X 25 degree (environment temperature)
d0eb8f39 592 AliBitPacking::PackWord(word,baseWord,20,29);
593 word = 0;
96b13296 594 AliBitPacking::PackWord(word,baseWord,30,30);
595 word = 0;
596 AliBitPacking::PackWord(word,baseWord,31,31);
597
598 fIndex++;
599 buf[fIndex]=baseWord;
600
601 // Local temperature in LTM8, LMT7, LTM6 -> 4 X 25 degree (environment temperature)
602 fIndex++;
603 buf[fIndex]=baseWord;
604
605 // Local temperature in LTM5, LMT4, LTM3 -> 4 X 25 degree (environment temperature)
606 fIndex++;
607 buf[fIndex]=baseWord;
608
609 // Local temperature in LTM2, LMT1, LTM0 -> 4 X 25 degree (environment temperature)
610 fIndex++;
611 buf[fIndex]=baseWord;
612
613
d0eb8f39 614
96b13296 615 // Local temperature in T7, T6, T5 -> 4 X 25 degree (environment temperature)
d0eb8f39 616 fIndex++;
617 buf[fIndex]=baseWord;
618
96b13296 619 // Local temperature in T4, T3, T2 -> 4 X 25 degree (environment temperature)
d0eb8f39 620 fIndex++;
621 buf[fIndex]=baseWord;
622
96b13296 623 // Local temperature in T1, T0 -> 4 X 25 degree (environment temperature)
624 // Local temperature in VTH15 -> Thereshould voltage for FEAC15
625 fIndex++;
626 buf[fIndex]=baseWord;
627
628 baseWord=0;
629 word = 0; // VTH13 -> Thereshould voltage for FEAC16
630 AliBitPacking::PackWord(word,baseWord, 0, 9);
631 word = 0; // VTH14 -> Thereshould voltage for FEAC14
632 AliBitPacking::PackWord(word,baseWord,10,19);
633 word = 0; // GND-FEAC7 -> Voltage drop between GND and FEAC7
634 AliBitPacking::PackWord(word,baseWord,20,29);
635 word = 0;
636 AliBitPacking::PackWord(word,baseWord,30,30);
637 word = 0;
638 AliBitPacking::PackWord(word,baseWord,31,31);
639
d0eb8f39 640 fIndex++;
641 buf[fIndex]=baseWord;
642
643 // VTH11 -> Thereshould voltage for FEAC11
d0eb8f39 644 // VTH12 -> Thereshould voltage for FEAC12
96b13296 645 // GND-FEAC6 -> Voltage drop between GND and FEAC6
d0eb8f39 646 fIndex++;
647 buf[fIndex]=baseWord;
648
96b13296 649 // VTH9 -> Thereshould voltage for FEAC11
650 // VTH10 -> Thereshould voltage for FEAC12
651 // GND-FEAC5 -> Voltage drop between GND and FEAC6
d0eb8f39 652 fIndex++;
653 buf[fIndex]=baseWord;
654
96b13296 655 // VTH7 -> Thereshould voltage for FEAC11
656 // VTH8 -> Thereshould voltage for FEAC12
657 // GND-FEAC4 -> Voltage drop between GND and FEAC6
d0eb8f39 658 fIndex++;
659 buf[fIndex]=baseWord;
660
96b13296 661 // VTH5 -> Thereshould voltage for FEAC11
662 // VTH6 -> Thereshould voltage for FEAC12
663 // GND-FEAC3 -> Voltage drop between GND and FEAC6
d0eb8f39 664 fIndex++;
665 buf[fIndex]=baseWord;
666
96b13296 667 // VTH3 -> Thereshould voltage for FEAC11
668 // VTH4 -> Thereshould voltage for FEAC12
669 // GND-FEAC2 -> Voltage drop between GND and FEAC6
d0eb8f39 670 fIndex++;
671 buf[fIndex]=baseWord;
672
96b13296 673 // VTH1 -> Thereshould voltage for FEAC11
674 // VTH2 -> Thereshould voltage for FEAC12
675 // GND-FEAC1 -> Voltage drop between GND and FEAC6
d0eb8f39 676 fIndex++;
677 buf[fIndex]=baseWord;
678
96b13296 679 // LV15
680 // VTH0 -> Thereshould voltage for FEAC12
681 // GND-FEAC0 -> Voltage drop between GND and FEAC6
d0eb8f39 682 fIndex++;
683 buf[fIndex]=baseWord;
684
96b13296 685 // LV15
686 // VTH0 -> Thereshould voltage for FEAC12
687 // GND-FEAC0 -> Voltage drop between GND and FEAC6
d0eb8f39 688 fIndex++;
689 buf[fIndex]=baseWord;
690
96b13296 691 // LV12
692 // LV13
693 // LV14
d0eb8f39 694 fIndex++;
695 buf[fIndex]=baseWord;
696
96b13296 697 // LV9
698 // LV10
699 // LV11
d0eb8f39 700 fIndex++;
701 buf[fIndex]=baseWord;
702
96b13296 703 // LV6
704 // LV7
705 // LV8
d0eb8f39 706 fIndex++;
707 buf[fIndex]=baseWord;
708
96b13296 709 // LV3
710 // LV4
711 // LV5
d0eb8f39 712 fIndex++;
713 buf[fIndex]=baseWord;
714
96b13296 715 // LV0
716 // LV1
717 // LV2
d0eb8f39 718 fIndex++;
719 buf[fIndex]=baseWord;
720
721
96b13296 722
d0eb8f39 723 baseWord=0;
96b13296 724 word = 0; // PDL45 -> Delay Line setting for PDL41
d0eb8f39 725 AliBitPacking::PackWord(word,baseWord, 0, 7);
96b13296 726 word = 0; // PDL46 -> Delay Line setting for PDL42
d0eb8f39 727 AliBitPacking::PackWord(word,baseWord, 8,15);
96b13296 728 word = 0; // PDL47 -> Delay Line setting for PDL43
d0eb8f39 729 AliBitPacking::PackWord(word,baseWord,16,23);
96b13296 730 word = 0; // PDL48 -> Delay Line setting for PDL44
d0eb8f39 731 AliBitPacking::PackWord(word,baseWord,24,31);
732 fIndex++;
733 buf[fIndex]=baseWord;
734
d0eb8f39 735 // Delay Line setting for PDL37, PDL38, PDL39, PDL40
736 fIndex++;
737 buf[fIndex]=baseWord;
738
739 // Delay Line setting for PDL33, PDL34, PDL35, PDL36
740 fIndex++;
741 buf[fIndex]=baseWord;
742
743 // Delay Line setting for PDL29, PDL30, PDL31, PDL32
744 fIndex++;
745 buf[fIndex]=baseWord;
746
747 // Delay Line setting for PDL25, PDL26, PDL27, PDL28
748 fIndex++;
749 buf[fIndex]=baseWord;
750
751 // Delay Line setting for PDL21, PDL22, PDL23, PDL24
752 fIndex++;
753 buf[fIndex]=baseWord;
754
755 // Delay Line setting for PDL17, PDL18, PDL19, PDL20
756 fIndex++;
757 buf[fIndex]=baseWord;
758
759 // Delay Line setting for PDL13, PDL14, PDL15, PDL16
760 fIndex++;
761 buf[fIndex]=baseWord;
762
763 // Delay Line setting for PDL9, PDL10, PDL11, PDL12
764 fIndex++;
765 buf[fIndex]=baseWord;
766
767 // Delay Line setting for PDL5, PDL6, PDL7, PDL8
768 fIndex++;
769 buf[fIndex]=baseWord;
770
771 // Delay Line setting for PDL1, PDL2, PDL3, PDL4
772 fIndex++;
773 buf[fIndex]=baseWord;
774
775}
776
777//----------------------------------------------------------------------------
778void AliTOFDDLRawData::MakeLTMtrailer(UInt_t *buf)
779{
780 //
781 // LTM trailer
782 //
783
784 UInt_t baseWord;
785 UInt_t word;
786
787 baseWord=0;
788 word = 2; // 0010 -> LTM data are coming from the VME slot number 2
789 AliBitPacking::PackWord(word,baseWord, 0, 3);
790 word = 0; // event crc
791 AliBitPacking::PackWord(word,baseWord, 4,15);
792 word = 0; // event number
793 AliBitPacking::PackWord(word,baseWord,16,27);
794 word = 5; // 0101 -> LTM trailer ID
795 AliBitPacking::PackWord(word,baseWord,28,31);
796 fIndex++;
797 buf[fIndex]=baseWord;
798
799}
800
801//----------------------------------------------------------------------------
802void AliTOFDDLRawData::MakeTRMheader(Int_t nTRM, UInt_t *buf)
803{
804 //
805 // TRM header for the TRM number nTRM [ 3;12]
806 //
807
808 if (nTRM<3 || nTRM>12) {
809 AliWarning(Form(" TRM number is out of the right range [3;12] (nTRM = %3i",nTRM));
810 return;
811 }
812
813 UInt_t baseWord;
814 UInt_t word;
815
816 baseWord = 0;
817 word = nTRM; // TRM data coming from the VME slot number nTRM
818 AliBitPacking::PackWord(word,baseWord, 0, 3);
819 word = 0; // event words
820 AliBitPacking::PackWord(word,baseWord, 4,16);
15ec34b9 821
822 if (fPackedAcquisition)
823 word = 0; // ACQuisition mode: [0;3] see document
824 else
825 word = 3; // ACQuisition mode: [0;3] see document
d0eb8f39 826 AliBitPacking::PackWord(word,baseWord,17,18);
827 word = 0; // description of a SEU inside LUT tables for INL compensation;
828 // the data are unaffected
829 AliBitPacking::PackWord(word,baseWord,19,19);
830 word = 0; // Must Be Zero (MBZ)
831 AliBitPacking::PackWord(word,baseWord,20,27);
832 word = 4; // 0100 -> TRM header ID
833 AliBitPacking::PackWord(word,baseWord,28,31);
834 fIndex++;
835 buf[fIndex]=baseWord;
836
837}
838
839//----------------------------------------------------------------------------
840void AliTOFDDLRawData::MakeTRMtrailer(UInt_t *buf)
841{
842 //
c5cf594b 843 // Set TRM Global Trailer
844 // with the calculated CRC
d0eb8f39 845 //
846
847 UInt_t baseWord;
848 UInt_t word;
849
850 baseWord=0;
851 word = 15; // 1111 -> TRM trailer ID 1
852 AliBitPacking::PackWord(word,baseWord, 0, 3);
c5cf594b 853
854 UInt_t trmCRC=0x0;
855 for (Int_t ii=fIndex-(fWordsPerTRM-1); ii<fIndex; ii++)
856 trmCRC ^= buf[ii];
b035d4ce 857 //PH printf(" A trmCRC=%d\n",trmCRC);
c5cf594b 858
859 word = 0x0;
860 word ^= ( (trmCRC & 0x00000fff) >> 0);
861 word ^= ( (trmCRC & 0x00fff000) >> 12);
862 word ^= ( (trmCRC & 0xff000000) >> 24);
863
b035d4ce 864 //PH printf(" B trmCRC=%d\n",word);
c5cf594b 865
866 AliBitPacking::PackWord(word,baseWord, 4,15); // event CRC --> CHANGED
867
868 word = 0; // local event counter == DRM local event counter --> TO BE CHANGED
d0eb8f39 869 AliBitPacking::PackWord(word,baseWord,16,27);
870 word = 5; // 0101 -> TRM trailer ID 2
871 AliBitPacking::PackWord(word,baseWord,28,31);
c5cf594b 872
d0eb8f39 873 fIndex++;
c5cf594b 874 for (Int_t ii=fIndex; ii>fIndex-fWordsPerTRM; ii--)
875 buf[ii]=buf[ii-1];
d0eb8f39 876
c5cf594b 877 buf[fIndex-fWordsPerTRM] = baseWord;
d0eb8f39 878
c5cf594b 879}
880
d0eb8f39 881//----------------------------------------------------------------------------
882void AliTOFDDLRawData::MakeTRMchainHeader(Int_t nTRM, Int_t iChain,
883 UInt_t *buf)
884{
885 //
886 // TRM chain header
887 //
888
889 UInt_t baseWord;
890 UInt_t word;
891
892 if (nTRM<3 || nTRM>12) {
893 AliWarning(Form(" TRM number is out of the right range [3;12] (nTRM = %3i", nTRM));
894 return;
895 }
896
897 if (iChain<0 || iChain>1) {
898 AliWarning(Form(" Chain number is out of the right range [0;1] (iChain = %3i", iChain));
899 return;
900 }
901
902 baseWord=0;
903 word = nTRM; // TRM data coming from the VME slot ID nTRM
904 AliBitPacking::PackWord(word,baseWord, 0, 3);
905 word = 0; // bunch ID
906 AliBitPacking::PackWord(word,baseWord, 4,15);
c5cf594b 907 word = 0;//100; // PB24 temperature -> 4 X 25 degree (environment temperature)
d0eb8f39 908 AliBitPacking::PackWord(word,baseWord,16,23);
c5cf594b 909 word = 0;//(Int_t)(5 * gRandom->Rndm()); // PB24 ID [0;4]
d0eb8f39 910 AliBitPacking::PackWord(word,baseWord,24,26);
911 word = 0; // TS
912 AliBitPacking::PackWord(word,baseWord,27,27);
913 switch (iChain) {
914 case 0:
915 word = 0; // 0000 -> TRM chain 0 ID
916 break;
917 case 1:
918 word = 2; // 0010 -> TRM chain 1 ID
919 break;
920 }
921 AliBitPacking::PackWord(word,baseWord,28,31);
922 fIndex++;
923 buf[fIndex]=baseWord;
924
925}
926
927//----------------------------------------------------------------------------
c5cf594b 928void AliTOFDDLRawData::MakeTRMfiller(UInt_t *buf)
d0eb8f39 929{
930 //
931 // TRM filler
932 //
933
934 Int_t jj = -1;
935
936 fIndex++;
c5cf594b 937 for (jj=fIndex; jj>fIndex-fWordsPerTRM; jj--)
d0eb8f39 938 buf[jj] = buf[jj-1];
d0eb8f39 939
c5cf594b 940 buf[fIndex-fWordsPerTRM] = MakeFiller();
d0eb8f39 941
942}
943
944//----------------------------------------------------------------------------
3407e19b 945UInt_t AliTOFDDLRawData::MakeFiller() const
d0eb8f39 946{
947 //
948 // Filler word definition: to make even the number of words per TRM/LTM
949 //
950
951 UInt_t baseWord;
952 UInt_t word;
953
954 baseWord=0;
955 word = 0; // 0000 -> filler ID 1
956 AliBitPacking::PackWord(word,baseWord, 0, 3);
957 word = 0; // MBZ
958 AliBitPacking::PackWord(word,baseWord, 4,27);
959 word = 7; // 0111 -> filler ID 2
960 AliBitPacking::PackWord(word,baseWord, 28,31);
961
962 return baseWord;
963
964}
965
966//----------------------------------------------------------------------------
967void AliTOFDDLRawData::MakeTRMchainTrailer(Int_t iChain, UInt_t *buf)
968{
969 //
970 // TRM chain trailer
971 //
972
973 if (iChain<0 || iChain>1) {
974 AliWarning(Form(" Chain number is out of the right range [0;1] (iChain = %3i", iChain));
975 return;
976 }
977
978 UInt_t baseWord;
979 UInt_t word;
980
981 baseWord=0;
982 word = 0; // status
983 AliBitPacking::PackWord(word,baseWord, 0, 3);
984 word = 0; // MBZ
985 AliBitPacking::PackWord(word,baseWord, 4,15);
c5cf594b 986 word = 0; // event counter --> TO BE CHANGED
d0eb8f39 987 AliBitPacking::PackWord(word,baseWord,16,27);
988 switch (iChain) {
989 case 0:
990 word = 1; // 0001 -> TRM chain 0 trailer ID
991 break;
992 case 1:
993 word = 3; // 0011 -> TRM chain 1 trailer ID
994 break;
995 }
996 AliBitPacking::PackWord(word,baseWord,28,31);
997 fIndex++;
998 buf[fIndex]=baseWord;
999
1000}
1001
1002//----------------------------------------------------------------------------
c5cf594b 1003void AliTOFDDLRawData::MakeTDCdigits(Int_t nDDL, Int_t nTRM, Int_t iChain, UInt_t *buf)
d0eb8f39 1004{
1005 //
1006 // TRM TDC digit
1007 //
1008
96f01799 1009 const Double_t kOneMoreFilledCell = 1./(AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors());
1010 Double_t percentFilledCells = Double_t(fTOFdigitMap->GetFilledCellNumber())/(AliTOFGeometry::NPadXSector()*AliTOFGeometry::NSectors());
15ec34b9 1011
d0eb8f39 1012 if (nDDL<0 || nDDL>71) {
1013 AliWarning(Form(" DDL number is out of the right range [0;71] (nDDL = %3i", nDDL));
1014 return;
1015 }
1016
1017 if (nTRM<3 || nTRM>12) {
1018 AliWarning(Form(" TRM number is out of the right range [3;12] (nTRM = %3i", nTRM));
1019 return;
1020 }
1021
1022 if (iChain<0 || iChain>1) {
1023 AliWarning(Form(" Chain number is out of the right range [0;1] (iChain = %3i", iChain));
1024 return;
1025 }
1026
15ec34b9 1027 Int_t psArray[1000];
1028 UInt_t localBuffer[1000];
1029 Int_t localIndex = -1;
1030
d0eb8f39 1031 Int_t iDDL = nDDL%AliTOFGeometry::NDDL();
1032
1033 Int_t volume[5] = {-1, -1, -1, -1, -1};
1034 Int_t indexDigit[3] = {-1, -1, -1};
1035
1036 Int_t totCharge = -1;
1037 Int_t timeOfFlight = -1;
1038
15ec34b9 1039 Int_t trailingSpurious = -1;
1040 Int_t leadingSpurious = -1;
1041
d0eb8f39 1042 AliTOFdigit *digs;
1043
1044 UInt_t baseWord=0;
1045 UInt_t word=0;
1046
1047 Int_t jj = -1;
1048 Int_t nTDC = -1;
1049 Int_t iCH = -1;
1050
a403781d 1051 //Int_t numberOfMeasuresPerChannel = 0;
1052 //Int_t maxMeasuresPerChannelInTDC = 0;
515faf5d 1053
1054 Bool_t outOut = HeadOrTail();
1055
d0eb8f39 1056 ofstream ftxt;
1057
1058 if (fVerbose==2) ftxt.open("TOFdigits.txt",ios::app);
1059
1060 for (jj=0; jj<5; jj++) volume[jj] = -1;
1061
1062 // loop on TDC number
1063 for (nTDC=AliTOFGeometry::NTdc()-1; nTDC>=0; nTDC--) {
1064
1065 // the DRM odd (i.e. left) slot number 3 doesn't contain TDC digit data
1066 // for TDC numbers 3-14
96b13296 1067 if (iDDL%2==1 && nTRM==3 && (Int_t)(nTDC/3)!=0) continue;
d0eb8f39 1068
1069 // loop on TDC channel number
1070 for (iCH=AliTOFGeometry::NCh()-1; iCH>=0; iCH--) {
1071
a403781d 1072 //numberOfMeasuresPerChannel = 0;
515faf5d 1073
96b13296 1074 for (Int_t aa=0; aa<5; aa++) volume[aa]=-1;
177b002e 1075 AliTOFRawStream::EquipmentId2VolumeId(nDDL, nTRM, iChain, nTDC, iCH, volume);
d0eb8f39 1076
96b13296 1077 AliDebug(3,Form(" volume -> %2d %1d %2d %2d %1d",volume[0],volume[1],volume[2],volume[3],volume[4]));
1078
d0eb8f39 1079 if (volume[0]==-1 || volume[1]==-1 || volume[2]==-1 ||
1080 volume[3]==-1 || volume[4]==-1) continue;
d0eb8f39 1081
96b13296 1082 AliDebug(3,Form(" ====== %2d %1d %2d %2d %1d",volume[0],volume[1],volume[2],volume[3],volume[4]));
1083
d0eb8f39 1084 for (jj=0; jj<3; jj++) indexDigit[jj] = -1;
1085
1086 fTOFdigitMap->GetDigitIndex(volume, indexDigit);
1087
15ec34b9 1088 if (indexDigit[0]<0) {
1089
515faf5d 1090 trailingSpurious = Int_t(2097152*gRandom->Rndm());
1091 leadingSpurious = Int_t(2097152*gRandom->Rndm());
15ec34b9 1092
515faf5d 1093 if ( fFakeOrphaneProduction &&
1094 ( ( fPackedAcquisition && percentFilledCells<0.12 && gRandom->Rndm()<(0.12-percentFilledCells) ) ||
1095 (!fPackedAcquisition && percentFilledCells<0.24 && gRandom->Rndm()<(0.24-percentFilledCells) ) ) ) {
15ec34b9 1096
1097 percentFilledCells+=kOneMoreFilledCell;
1098
1099 Int_t dummyPS = 0;
1100
515faf5d 1101 if (outOut) {
15ec34b9 1102 word = trailingSpurious; // trailing edge measurement
1103 dummyPS = 2;
1104 }
1105 else {
1106 word = leadingSpurious; // leading edge measurement
1107 dummyPS = 1;
1108 }
1109
1110 if (fVerbose==2) {
1111 if (nDDL<10) ftxt << " " << nDDL;
1112 else ftxt << " " << nDDL;
1113 if (nTRM<10) ftxt << " " << nTRM;
1114 else ftxt << " " << nTRM;
1115 ftxt << " " << iChain;
1116 if (nTDC<10) ftxt << " " << nTDC;
1117 else ftxt << " " << nTDC;
1118 ftxt << " " << iCH;
1119 if (volume[0]<10) ftxt << " -> " << volume[0];
1120 else ftxt << " -> " << volume[0];
1121 ftxt << " " << volume[1];
1122 if (volume[2]<10) ftxt << " " << volume[2];
1123 else ftxt << " " << volume[2];
1124 ftxt << " " << volume[4];
1125 if (volume[3]<10) ftxt << " " << volume[3];
1126 else ftxt << " " << volume[3];
515faf5d 1127 ftxt << " " << -1;
1128 if (word<10) ftxt << " " << word;
1129 else if (word>=10 && word<100) ftxt << " " << word;
1130 else if (word>=100 && word<1000) ftxt << " " << word;
1131 else if (word>=1000 && word<10000) ftxt << " " << word;
1132 else if (word>=10000 && word<100000) ftxt << " " << word;
1133 else if (word>=100000 && word<1000000) ftxt << " " << word;
1134 else ftxt << " " << word;
1135 ftxt << " " << dummyPS << endl;
15ec34b9 1136 }
1137
1138 AliBitPacking::PackWord(word,baseWord, 0,20);
1139 word = iCH; // TDC channel ID [0;7]
1140 AliBitPacking::PackWord(word,baseWord,21,23);
1141 word = nTDC; // TDC ID [0;14]
1142 AliBitPacking::PackWord(word,baseWord,24,27);
1143 word = 0; // error flag
1144 AliBitPacking::PackWord(word,baseWord,28,28);
1145 word = dummyPS; // Packing Status [0;3]
1146 AliBitPacking::PackWord(word,baseWord,29,30);
1147 word = 1; // TRM TDC digit ID
1148 AliBitPacking::PackWord(word,baseWord,31,31);
1149
c5cf594b 1150 localIndex++; fWordsPerTRM++;
15ec34b9 1151 localBuffer[localIndex]=baseWord;
1152 psArray[localIndex]=dummyPS;
1153
15ec34b9 1154 baseWord=0;
1155
515faf5d 1156 } // if ( fFakeOrphaneProduction && ( ( fPackedAcquisition && percentFilledCells<0.12 && gRandom->Rndm()<(0.12-percentFilledCells) ) or ... ) )
15ec34b9 1157 } // if (indexDigit[0]<0)
1158
d0eb8f39 1159 for (jj=0; jj<3;jj++) {
1160
1161 if (indexDigit[jj]<0) continue;
a403781d 1162
96b13296 1163 AliDebug(3,Form(" ====== %2d %1d %2d %2d %1d -> %1d %d",volume[0],volume[1],volume[2],volume[3],volume[4],jj,indexDigit[jj]));
1164
d0eb8f39 1165 digs = (AliTOFdigit*)fTOFdigitArray->UncheckedAt(indexDigit[jj]);
1166
1167 if (digs->GetSector()!=volume[0] ||
1168 digs->GetPlate() !=volume[1] ||
1169 digs->GetStrip() !=volume[2] ||
1170 digs->GetPadx() !=volume[3] ||
6e4ef37b 1171 digs->GetPadz() !=volume[4]) AliWarning(Form(" --- ERROR --- %2i (%2i) %1i (%1i) %2i (%2i) %2i (%2i) %1i (%1i)",
1172 digs->GetSector(), volume[0],
1173 digs->GetPlate(), volume[1],
1174 digs->GetStrip(), volume[2],
1175 digs->GetPadx(), volume[3],
1176 digs->GetPadz(), volume[4])
1177 );
d0eb8f39 1178
96b13296 1179 timeOfFlight = (Int_t)(digs->GetTdc());
1180 /*+
cfceaf15 1181 fTOFCableLengthMap->GetCableTimeShiftBin(nDDL, nTRM, iChain, nTDC)*/;
d11fc181 1182
cfceaf15 1183 //if (timeOfFlight>=fMatchingWindow+1000) continue; // adc
96b13296 1184 //if (timeOfFlight>=fMatchingWindow) continue; // adc
1185 if (digs->GetTdcND()>=fMatchingWindow) {
1186 AliDebug(2,"Out of matching window.");
1187 continue; // adc
1188 }
1189 else AliDebug(2,"In matching window");
515faf5d 1190
a403781d 1191 //numberOfMeasuresPerChannel++;
1192
515faf5d 1193 // totCharge = (Int_t)digs->GetAdc(); //Use realistic ToT, for Standard production with no miscalibration/Slewing it == fAdC in digit (see AliTOFDigitizer)
1194 totCharge = (Int_t)(digs->GetToT());
d0eb8f39 1195 // temporary control
d11fc181 1196 if (totCharge<0) totCharge = 0;//TMath::Abs(totCharge);
d0eb8f39 1197
15ec34b9 1198 if (fPackedAcquisition) {
1199
d0eb8f39 1200 if (fVerbose==2) {
1201 if (nDDL<10) ftxt << " " << nDDL;
1202 else ftxt << " " << nDDL;
1203 if (nTRM<10) ftxt << " " << nTRM;
1204 else ftxt << " " << nTRM;
1205 ftxt << " " << iChain;
1206 if (nTDC<10) ftxt << " " << nTDC;
1207 else ftxt << " " << nTDC;
1208 ftxt << " " << iCH;
1209 if (volume[0]<10) ftxt << " -> " << volume[0];
1210 else ftxt << " -> " << volume[0];
1211 ftxt << " " << volume[1];
1212 if (volume[2]<10) ftxt << " " << volume[2];
1213 else ftxt << " " << volume[2];
1214 ftxt << " " << volume[4];
1215 if (volume[3]<10) ftxt << " " << volume[3];
1216 else ftxt << " " << volume[3];
515faf5d 1217 if (totCharge<10) ftxt << " " << totCharge;
1218 else if (totCharge>=10 && totCharge<100) ftxt << " " << totCharge;
1219 else ftxt << " " << totCharge;
1220 if (timeOfFlight<10) ftxt << " " << timeOfFlight << endl;
1221 else if (timeOfFlight>=10 && timeOfFlight<100) ftxt << " " << timeOfFlight << endl;
1222 else if (timeOfFlight>=100 && timeOfFlight<1000) ftxt << " " << timeOfFlight << endl;
1223 else ftxt << " " << timeOfFlight << endl;
d0eb8f39 1224 }
1225
515faf5d 1226 word = timeOfFlight%8192; // time-of-fligth measurement
d0eb8f39 1227 AliBitPacking::PackWord(word,baseWord, 0,12);
1228
515faf5d 1229 if (totCharge>=256) totCharge = 255;
d0eb8f39 1230 word = totCharge; // time-over-threshould measurement
1231 AliBitPacking::PackWord(word,baseWord,13,20);
1232
1233 word = iCH; // TDC channel ID [0;7]
1234 AliBitPacking::PackWord(word,baseWord,21,23);
1235 word = nTDC; // TDC ID [0;14]
1236 AliBitPacking::PackWord(word,baseWord,24,27);
1237 word = 0; // error flag
1238 AliBitPacking::PackWord(word,baseWord,28,28);
15ec34b9 1239 word = 0; // Packing Status [0;3]
1240 AliBitPacking::PackWord(word,baseWord,29,30);
1241 word = 1; // TRM TDC digit ID
1242 AliBitPacking::PackWord(word,baseWord,31,31);
1243
c5cf594b 1244 localIndex++; fWordsPerTRM++;
15ec34b9 1245 localBuffer[localIndex]=baseWord;
1246
15ec34b9 1247 baseWord=0;
1248
515faf5d 1249 if ( fFakeOrphaneProduction &&
1250 percentFilledCells<0.12 && gRandom->Rndm()<(0.12-percentFilledCells) ) {
15ec34b9 1251
1252 percentFilledCells+=kOneMoreFilledCell;
1253
515faf5d 1254 trailingSpurious = Int_t(2097152*gRandom->Rndm());
1255 leadingSpurious = Int_t(2097152*gRandom->Rndm());
15ec34b9 1256
1257 Int_t dummyPS = 0;
1258
515faf5d 1259 if (outOut) {
15ec34b9 1260 word = trailingSpurious; // trailing edge measurement
1261 dummyPS = 2;
1262 }
1263 else {
1264 word = leadingSpurious; // leading edge measurement
1265 dummyPS = 1;
1266 }
1267
1268 if (fVerbose==2) {
1269 if (nDDL<10) ftxt << " " << nDDL;
1270 else ftxt << " " << nDDL;
1271 if (nTRM<10) ftxt << " " << nTRM;
1272 else ftxt << " " << nTRM;
1273 ftxt << " " << iChain;
1274 if (nTDC<10) ftxt << " " << nTDC;
1275 else ftxt << " " << nTDC;
1276 ftxt << " " << iCH;
1277 if (volume[0]<10) ftxt << " -> " << volume[0];
1278 else ftxt << " -> " << volume[0];
1279 ftxt << " " << volume[1];
1280 if (volume[2]<10) ftxt << " " << volume[2];
1281 else ftxt << " " << volume[2];
1282 ftxt << " " << volume[4];
1283 if (volume[3]<10) ftxt << " " << volume[3];
1284 else ftxt << " " << volume[3];
515faf5d 1285 ftxt << " " << -1;
1286 if (word<10) ftxt << " " << word;
1287 else if (word>=10 && word<100) ftxt << " " << word;
1288 else if (word>=100 && word<1000) ftxt << " " << word;
1289 else if (word>=1000 && word<10000) ftxt << " " << word;
1290 else if (word>=10000 && word<100000) ftxt << " " << word;
1291 else if (word>=100000 && word<1000000) ftxt << " " << word;
1292 else ftxt << " " << word;
1293 ftxt << " " << dummyPS << endl;
15ec34b9 1294 }
1295
1296 AliBitPacking::PackWord(word,baseWord, 0,20);
1297 word = iCH; // TDC channel ID [0;7]
1298 AliBitPacking::PackWord(word,baseWord,21,23);
1299 word = nTDC; // TDC ID [0;14]
1300 AliBitPacking::PackWord(word,baseWord,24,27);
1301 word = 0; // error flag
1302 AliBitPacking::PackWord(word,baseWord,28,28);
1303 word = dummyPS; // Packing Status [0;3]
1304 AliBitPacking::PackWord(word,baseWord,29,30);
1305 word = 1; // TRM TDC digit ID
1306 AliBitPacking::PackWord(word,baseWord,31,31);
1307
c5cf594b 1308 localIndex++; fWordsPerTRM++;
15ec34b9 1309 localBuffer[localIndex]=baseWord;
1310 psArray[localIndex]=dummyPS;
1311
15ec34b9 1312 baseWord=0;
1313
515faf5d 1314 } // if ( fFakeOrphaneProduction && percentFilledCells<0.12 && gRandom->Rndm()<(0.12-percentFilledCells) )
15ec34b9 1315
1316
1317 } // if (fPackedAcquisition)
1318 else { // if (!fPackedAcquisition)
1319
515faf5d 1320 if ( fFakeOrphaneProduction &&
1321 percentFilledCells<0.24 && gRandom->Rndm()<(0.24-percentFilledCells) && outOut ) {
15ec34b9 1322
1323 percentFilledCells+=kOneMoreFilledCell;
1324
515faf5d 1325 trailingSpurious = Int_t(2097152*gRandom->Rndm());
15ec34b9 1326 word = trailingSpurious;
1327 Int_t dummyPS = 2;
1328
1329 if (fVerbose==2) {
1330 if (nDDL<10) ftxt << " " << nDDL;
1331 else ftxt << " " << nDDL;
1332 if (nTRM<10) ftxt << " " << nTRM;
1333 else ftxt << " " << nTRM;
1334 ftxt << " " << iChain;
1335 if (nTDC<10) ftxt << " " << nTDC;
1336 else ftxt << " " << nTDC;
1337 ftxt << " " << iCH;
1338 if (volume[0]<10) ftxt << " -> " << volume[0];
1339 else ftxt << " -> " << volume[0];
1340 ftxt << " " << volume[1];
1341 if (volume[2]<10) ftxt << " " << volume[2];
1342 else ftxt << " " << volume[2];
1343 ftxt << " " << volume[4];
1344 if (volume[3]<10) ftxt << " " << volume[3];
1345 else ftxt << " " << volume[3];
515faf5d 1346 ftxt << " " << -1;
1347 if (word<10) ftxt << " " << word;
1348 else if (word>=10 && word<100) ftxt << " " << word;
1349 else if (word>=100 && word<1000) ftxt << " " << word;
1350 else if (word>=1000 && word<10000) ftxt << " " << word;
1351 else if (word>=10000 && word<100000) ftxt << " " << word;
1352 else if (word>=100000 && word<1000000) ftxt << " " << word;
1353 else ftxt << " " << word;
1354 ftxt << " " << dummyPS << endl;
15ec34b9 1355 }
1356
1357 AliBitPacking::PackWord(word,baseWord, 0,20);
1358 word = iCH; // TDC channel ID [0;7]
1359 AliBitPacking::PackWord(word,baseWord,21,23);
1360 word = nTDC; // TDC ID [0;14]
1361 AliBitPacking::PackWord(word,baseWord,24,27);
1362 word = 0; // error flag
1363 AliBitPacking::PackWord(word,baseWord,28,28);
1364 word = dummyPS; // Packing Status [0;3]
1365 AliBitPacking::PackWord(word,baseWord,29,30);
1366 word = 1; // TRM TDC digit ID
1367 AliBitPacking::PackWord(word,baseWord,31,31);
1368
c5cf594b 1369 localIndex++; fWordsPerTRM++;
15ec34b9 1370 localBuffer[localIndex]=baseWord;
1371 psArray[localIndex]=dummyPS;
1372
15ec34b9 1373 baseWord=0;
1374
515faf5d 1375 } // if ( fFakeOrphaneProduction && percentFilledCells<0.24 && gRandom->Rndm()<(0.24-percentFilledCells) && outOut )
15ec34b9 1376
1377
515faf5d 1378 word = (timeOfFlight + Int_t(totCharge*AliTOFGeometry::ToTBinWidth()/AliTOFGeometry::TdcBinWidth()))%2097152; // trailing edge measurement
15ec34b9 1379
1380 if (fVerbose==2) {
1381 if (nDDL<10) ftxt << " " << nDDL;
1382 else ftxt << " " << nDDL;
1383 if (nTRM<10) ftxt << " " << nTRM;
1384 else ftxt << " " << nTRM;
1385 ftxt << " " << iChain;
1386 if (nTDC<10) ftxt << " " << nTDC;
1387 else ftxt << " " << nTDC;
1388 ftxt << " " << iCH;
1389 if (volume[0]<10) ftxt << " -> " << volume[0];
1390 else ftxt << " -> " << volume[0];
1391 ftxt << " " << volume[1];
1392 if (volume[2]<10) ftxt << " " << volume[2];
1393 else ftxt << " " << volume[2];
1394 ftxt << " " << volume[4];
1395 if (volume[3]<10) ftxt << " " << volume[3];
1396 else ftxt << " " << volume[3];
515faf5d 1397 ftxt << " " << -1;
1398 if (word<10) ftxt << " " << word;
1399 else if (word>=10 && word<100) ftxt << " " << word;
1400 else if (word>=100 && word<1000) ftxt << " " << word;
1401 else if (word>=1000 && word<10000) ftxt << " " << word;
1402 else if (word>=10000 && word<100000) ftxt << " " << word;
1403 else if (word>=100000 && word<1000000) ftxt << " " << word;
1404 else ftxt << " " << word;
1405 ftxt << " " << 2 << endl;
15ec34b9 1406 }
1407
1408 AliBitPacking::PackWord(word,baseWord, 0,20);
1409
1410 word = iCH; // TDC channel ID [0;7]
1411 AliBitPacking::PackWord(word,baseWord,21,23);
1412 word = nTDC; // TDC ID [0;14]
1413 AliBitPacking::PackWord(word,baseWord,24,27);
1414 word = 0; // error flag
1415 AliBitPacking::PackWord(word,baseWord,28,28);
1416 word = 2; // Packing Status [0;3]
d0eb8f39 1417 AliBitPacking::PackWord(word,baseWord,29,30);
1418 word = 1; // TRM TDC digit ID
1419 AliBitPacking::PackWord(word,baseWord,31,31);
15ec34b9 1420
c5cf594b 1421 localIndex++; fWordsPerTRM++;
15ec34b9 1422 localBuffer[localIndex]=baseWord;
1423 psArray[localIndex]=2;
d0eb8f39 1424
d0eb8f39 1425 baseWord=0;
1426
515faf5d 1427 word = timeOfFlight%2097152; // leading edge measurement
15ec34b9 1428
1429 if (fVerbose==2) {
1430 if (nDDL<10) ftxt << " " << nDDL;
1431 else ftxt << " " << nDDL;
1432 if (nTRM<10) ftxt << " " << nTRM;
1433 else ftxt << " " << nTRM;
1434 ftxt << " " << iChain;
1435 if (nTDC<10) ftxt << " " << nTDC;
1436 else ftxt << " " << nTDC;
1437 ftxt << " " << iCH;
1438 if (volume[0]<10) ftxt << " -> " << volume[0];
1439 else ftxt << " -> " << volume[0];
1440 ftxt << " " << volume[1];
1441 if (volume[2]<10) ftxt << " " << volume[2];
1442 else ftxt << " " << volume[2];
1443 ftxt << " " << volume[4];
1444 if (volume[3]<10) ftxt << " " << volume[3];
1445 else ftxt << " " << volume[3];
515faf5d 1446 ftxt << " " << -1;
1447 if (word<10) ftxt << " " << word;
1448 else if (word>=10 && word<100) ftxt << " " << word;
1449 else if (word>=100 && word<1000) ftxt << " " << word;
1450 else if (word>=1000 && word<10000) ftxt << " " << word;
1451 else if (word>=10000 && word<100000) ftxt << " " << word;
1452 else if (word>=100000 && word<1000000) ftxt << " " << word;
1453 else ftxt << " " << word;
1454 ftxt << " " << 1 << endl;
15ec34b9 1455 }
1456
1457 AliBitPacking::PackWord(word,baseWord, 0,20);
1458
1459 word = iCH; // TDC channel ID [0;7]
1460 AliBitPacking::PackWord(word,baseWord,21,23);
1461 word = nTDC; // TDC ID [0;14]
1462 AliBitPacking::PackWord(word,baseWord,24,27);
1463 word = 0; // error flag
1464 AliBitPacking::PackWord(word,baseWord,28,28);
1465 word = 1; // Packing Status [0;3]
1466 AliBitPacking::PackWord(word,baseWord,29,30);
1467 word = 1; // TRM TDC digit ID
1468 AliBitPacking::PackWord(word,baseWord,31,31);
1469
c5cf594b 1470 localIndex++; fWordsPerTRM++;
15ec34b9 1471 localBuffer[localIndex]=baseWord;
1472 psArray[localIndex]=1;
1473
15ec34b9 1474 baseWord=0;
1475
1476
515faf5d 1477 if ( fFakeOrphaneProduction &&
1478 percentFilledCells<0.24 && gRandom->Rndm()<(0.24-percentFilledCells) && !outOut ) {
15ec34b9 1479
1480 percentFilledCells+=kOneMoreFilledCell;
1481
515faf5d 1482 leadingSpurious = Int_t(2097152*gRandom->Rndm());
15ec34b9 1483 word = leadingSpurious;
1484 Int_t dummyPS = 1;
1485
1486 if (fVerbose==2) {
1487 if (nDDL<10) ftxt << " " << nDDL;
1488 else ftxt << " " << nDDL;
1489 if (nTRM<10) ftxt << " " << nTRM;
1490 else ftxt << " " << nTRM;
1491 ftxt << " " << iChain;
1492 if (nTDC<10) ftxt << " " << nTDC;
1493 else ftxt << " " << nTDC;
1494 ftxt << " " << iCH;
1495 if (volume[0]<10) ftxt << " -> " << volume[0];
1496 else ftxt << " -> " << volume[0];
1497 ftxt << " " << volume[1];
1498 if (volume[2]<10) ftxt << " " << volume[2];
1499 else ftxt << " " << volume[2];
1500 ftxt << " " << volume[4];
1501 if (volume[3]<10) ftxt << " " << volume[3];
1502 else ftxt << " " << volume[3];
515faf5d 1503 ftxt << " " << -1;
1504 if (word<10) ftxt << " " << word;
1505 else if (word>=10 && word<100) ftxt << " " << word;
1506 else if (word>=100 && word<1000) ftxt << " " << word;
1507 else if (word>=1000 && word<10000) ftxt << " " << word;
1508 else if (word>=10000 && word<100000) ftxt << " " << word;
1509 else if (word>=100000 && word<1000000) ftxt << " " << word;
1510 else ftxt << " " << word;
1511 ftxt << " " << dummyPS << endl;
15ec34b9 1512 }
1513
1514 AliBitPacking::PackWord(word,baseWord, 0,20);
1515 word = iCH; // TDC channel ID [0;7]
1516 AliBitPacking::PackWord(word,baseWord,21,23);
1517 word = nTDC; // TDC ID [0;14]
1518 AliBitPacking::PackWord(word,baseWord,24,27);
1519 word = 0; // error flag
1520 AliBitPacking::PackWord(word,baseWord,28,28);
1521 word = dummyPS; // Packing Status [0;3]
1522 AliBitPacking::PackWord(word,baseWord,29,30);
1523 word = 1; // TRM TDC digit ID
1524 AliBitPacking::PackWord(word,baseWord,31,31);
1525
c5cf594b 1526 localIndex++; fWordsPerTRM++;
15ec34b9 1527 localBuffer[localIndex]=baseWord;
1528 psArray[localIndex]=dummyPS;
1529
15ec34b9 1530 baseWord=0;
1531
515faf5d 1532 } // if ( fFakeOrphaneProduction && percentFilledCells<0.24 && gRandom->Rndm()<(0.24-percentFilledCells) && !outOut )
15ec34b9 1533
1534
1535 } // if (!fPackedAcquisition)
1536
d0eb8f39 1537 } //end loop on digits in the same volume
1538
a403781d 1539 //if (numberOfMeasuresPerChannel>maxMeasuresPerChannelInTDC)
1540 //maxMeasuresPerChannelInTDC = numberOfMeasuresPerChannel;
1541
d0eb8f39 1542 } // end loop on TDC channel number
1543
e8285af5 1544 //AliDebug(3,Form(" TDC number %2i: numberOfMeasuresPerChannel = %2i --- maxMeasuresPerChannelInTDC = %2i ", nTDC, numberOfMeasuresPerChannel, maxMeasuresPerChannelInTDC));
a403781d 1545
515faf5d 1546 if (localIndex==-1) continue;
15ec34b9 1547
515faf5d 1548 if (fPackedAcquisition) {
15ec34b9 1549
3c609b5c 1550 for (jj=0; jj<=localIndex; jj++) {
15ec34b9 1551 fIndex++;
1552 buf[fIndex] = localBuffer[jj];
515faf5d 1553 localBuffer[jj] = 0;
1554 psArray[jj] = -1;
15ec34b9 1555 }
515faf5d 1556
15ec34b9 1557 }
515faf5d 1558 else {
a403781d 1559 /*
515faf5d 1560 if (maxMeasuresPerChannelInTDC = 1) {
1561
1562 for (Int_t jj=0; jj<=localIndex; jj++) {
1563 if (psArray[jj]==2) {
1564 fIndex++;
1565 buf[fIndex] = localBuffer[jj];
1566 localBuffer[jj] = 0;
1567 psArray[jj] = -1;
1568 }
1569 }
1570 for (Int_t jj=0; jj<=localIndex; jj++) {
1571 if (psArray[jj]==1) {
1572 fIndex++;
1573 buf[fIndex] = localBuffer[jj];
1574 localBuffer[jj] = 0;
1575 psArray[jj] = -1;
1576 }
1577 }
1578
1579 } // if (maxMeasuresPerChannelInTDC = 1)
1580 else if (maxMeasuresPerChannelInTDC>1) {
1581
96b13296 1582 AliDebug(3,Form(" In the TOF DDL %2i, TRM %2i, TDC %2i, chain %1i, the maximum number of t.o.f. good measurements per channel is %2i",
515faf5d 1583 nDDL, nTRM, iChain, nTDC, iCH, maxMeasuresPerChannelInTDC));
a403781d 1584 */
3c609b5c 1585 for (jj=0; jj<=localIndex; jj++) {
515faf5d 1586 fIndex++;
1587 buf[fIndex] = localBuffer[jj];
1588 localBuffer[jj] = 0;
1589 psArray[jj] = -1;
1590 }
1591
a403781d 1592 //} // else if (maxMeasuresPerChannelInTDC>1)
515faf5d 1593
1594 } // else (!fPackedAcquisition)
1595
1596 localIndex = -1;
1597
a403781d 1598 //maxMeasuresPerChannelInTDC = 0;
1599
515faf5d 1600 } // end loop on TDC number
15ec34b9 1601
d0eb8f39 1602
1603 if (fVerbose==2) ftxt.close();
1604
1605}
1606
1607//----------------------------------------------------------------------------
1608void AliTOFDDLRawData::ReverseArray(UInt_t a[], Int_t n) const
1609{
1610 //
1611 // Reverses the n elements of array a
1612 //
1613
1614 Int_t ii, temp;
1615
1616 for (ii=0; ii<n/2; ii++) {
1617 temp = a[ii];
1618 a[ii] = a[n-ii-1];
1619 a[n-ii-1] = temp;
1620 }
1621
1622 return;
1623
1624}
15ec34b9 1625
1626//----------------------------------------------------------------------------
1627Bool_t AliTOFDDLRawData::HeadOrTail() const
1628{
1629 //
1630 // Returns the result of a 'pitch and toss'
1631 //
1632
1633 Double_t dummy = gRandom->Rndm();
1634
1635 if (dummy<0.5) return kFALSE;
1636 else return kTRUE;
1637
1638}