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