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