]>
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$ |
655e379f | 18 | Revision 1.11 2006/08/10 14:46:54 decaro |
19 | TOF raw data format: updated version | |
20 | ||
d0eb8f39 | 21 | Revision 1.10.1 2006/06/28 A.De Caro |
22 | Update TOF raw data format | |
23 | according to the final version | |
24 | (see ALICE internal note in preparation | |
25 | 'ALICE TOF raw data format') | |
26 | ||
571dda3d | 27 | Revision 0.02 2005/7/25 A.De Caro |
28 | Update number of bits allocated for time-of-flight | |
29 | and 'charge' measurements | |
30 | ||
7e6dce66 | 31 | Revision 0.01 2004/6/11 A.De Caro, S.B.Sellitto, R.Silvestri |
32 | First implementation: global methods RawDataTOF | |
33 | GetDigits | |
7e6dce66 | 34 | */ |
571dda3d | 35 | |
d0eb8f39 | 36 | //////////////////////////////////////////////////////////////////// |
37 | // // | |
38 | // This class contains the methods to create the Raw Data files // | |
39 | // for the TOF detector starting from the Digits. // | |
40 | // In this implementation, we defined the structure // | |
41 | // of the ALICE-TOF raw data (according to the // | |
42 | // ALICE technical note, in preparation) // | |
43 | // starting from the TOF digit format. // | |
44 | // // | |
45 | //////////////////////////////////////////////////////////////////// | |
7e6dce66 | 46 | |
0e46b9ae | 47 | #include "Riostream.h" |
48 | ||
49 | #include "TBranch.h" | |
50 | #include "TClonesArray.h" | |
51 | #include "TMath.h" | |
d0eb8f39 | 52 | #include "TRandom.h" |
43f77f2d | 53 | |
571dda3d | 54 | #include "AliBitPacking.h" |
d0eb8f39 | 55 | #include "AliDAQ.h" |
0e46b9ae | 56 | #include "AliLog.h" |
d0eb8f39 | 57 | //#include "AliRawDataHeader.h" |
58 | #include "AliRawDataHeaderSim.h" | |
571dda3d | 59 | |
0e46b9ae | 60 | #include "AliTOFDDLRawData.h" |
d0eb8f39 | 61 | #include "AliTOFDigitMap.h" |
7e6dce66 | 62 | #include "AliTOFdigit.h" |
0e46b9ae | 63 | #include "AliTOFGeometry.h" |
571dda3d | 64 | #include "AliTOFRawStream.h" |
d0eb8f39 | 65 | |
66 | extern TRandom *gRandom; | |
7e6dce66 | 67 | |
68 | ClassImp(AliTOFDDLRawData) | |
69 | ||
d0eb8f39 | 70 | //--------------------------------------------------------------------------- |
655e379f | 71 | AliTOFDDLRawData::AliTOFDDLRawData(): |
72 | fVerbose(0), | |
73 | fIndex(-1), | |
74 | fTOFgeometry(0), | |
75 | fTOFdigitMap(new AliTOFDigitMap()), | |
76 | fTOFdigitArray(0x0), | |
77 | fTOFrawStream(new AliTOFRawStream()) | |
7e6dce66 | 78 | { |
79 | //Default constructor | |
d3c7bfac | 80 | } |
81 | ||
d0eb8f39 | 82 | //---------------------------------------------------------------------------- |
655e379f | 83 | AliTOFDDLRawData::AliTOFDDLRawData(AliTOFGeometry *tofGeom): |
84 | fVerbose(0), | |
85 | fIndex(-1), | |
86 | fTOFgeometry(tofGeom), | |
87 | fTOFdigitMap(new AliTOFDigitMap()), | |
88 | fTOFdigitArray(0x0), | |
89 | fTOFrawStream(new AliTOFRawStream()) | |
d3c7bfac | 90 | { |
91 | //Constructor | |
7e6dce66 | 92 | |
d0eb8f39 | 93 | } |
7e6dce66 | 94 | |
d0eb8f39 | 95 | //---------------------------------------------------------------------------- |
96 | AliTOFDDLRawData::AliTOFDDLRawData(const AliTOFDDLRawData &source) : | |
655e379f | 97 | TObject(source), |
98 | fVerbose(0), | |
99 | fIndex(-1), | |
100 | fTOFgeometry(0), | |
101 | fTOFdigitMap(new AliTOFDigitMap()), | |
102 | fTOFdigitArray(0x0), | |
103 | fTOFrawStream(new AliTOFRawStream()) | |
104 | { | |
7e6dce66 | 105 | //Copy Constructor |
106 | this->fIndex=source.fIndex; | |
107 | this->fVerbose=source.fVerbose; | |
d3c7bfac | 108 | this->fTOFgeometry=source.fTOFgeometry; |
d0eb8f39 | 109 | this->fTOFdigitMap=source.fTOFdigitMap; |
110 | this->fTOFdigitArray=source.fTOFdigitArray; | |
111 | this->fTOFrawStream=source.fTOFrawStream; | |
7e6dce66 | 112 | return; |
113 | } | |
114 | ||
d0eb8f39 | 115 | //---------------------------------------------------------------------------- |
116 | AliTOFDDLRawData& AliTOFDDLRawData::operator=(const AliTOFDDLRawData &source) { | |
7e6dce66 | 117 | //Assigment operator |
118 | this->fIndex=source.fIndex; | |
119 | this->fVerbose=source.fVerbose; | |
d3c7bfac | 120 | this->fTOFgeometry=source.fTOFgeometry; |
d0eb8f39 | 121 | this->fTOFdigitMap=source.fTOFdigitMap; |
122 | this->fTOFdigitArray=source.fTOFdigitArray; | |
123 | this->fTOFrawStream=source.fTOFrawStream; | |
7e6dce66 | 124 | return *this; |
125 | } | |
126 | ||
d0eb8f39 | 127 | //---------------------------------------------------------------------------- |
128 | Int_t AliTOFDDLRawData::RawDataTOF(TBranch* branch) | |
7e6dce66 | 129 | { |
571dda3d | 130 | // |
131 | // This method creates the Raw data files for TOF detector | |
132 | // | |
133 | ||
134 | const Int_t kSize = 5000; //max number of digits per DDL file times 2 | |
135 | ||
7e6dce66 | 136 | UInt_t buf[kSize]; |
7e6dce66 | 137 | |
d0eb8f39 | 138 | fIndex = -1; |
139 | ||
140 | fTOFdigitArray = * (TClonesArray**) branch->GetAddress(); | |
7e6dce66 | 141 | |
7e6dce66 | 142 | char fileName[15]; |
143 | ofstream outfile; // logical name of the output file | |
d0eb8f39 | 144 | |
145 | //AliRawDataHeader header; | |
146 | AliRawDataHeaderSim header; | |
147 | ||
571dda3d | 148 | UInt_t sizeRawData = 0; |
7e6dce66 | 149 | |
d0eb8f39 | 150 | branch->GetEvent(); |
151 | ||
152 | GetDigits(); | |
153 | ||
154 | Int_t jj = -1; | |
155 | Int_t iDDL = -1; | |
156 | Int_t nDDL = -1; | |
157 | Int_t nTRM = 0; | |
158 | Int_t iChain = -1; | |
159 | ||
160 | UInt_t nWordsPerTRM = 0; | |
161 | ||
7e6dce66 | 162 | //loop over TOF DDL files |
d0eb8f39 | 163 | for (nDDL=0; nDDL<AliDAQ::NumberOfDdls("TOF"); nDDL++) { |
571dda3d | 164 | |
d0eb8f39 | 165 | strcpy(fileName,AliDAQ::DdlFileName("TOF",nDDL)); //The name of the output file |
7e6dce66 | 166 | #ifndef __DECCXX |
167 | outfile.open(fileName,ios::binary); | |
168 | #else | |
169 | outfile.open(fileName); | |
170 | #endif | |
571dda3d | 171 | |
d0eb8f39 | 172 | iDDL = fTOFrawStream->GetDDLnumberPerSector(nDDL); |
173 | ||
174 | // write Dummy DATA HEADER | |
175 | UInt_t dataHeaderPosition = outfile.tellp(); | |
7e6dce66 | 176 | outfile.write((char*)(&header),sizeof(header)); |
177 | ||
d0eb8f39 | 178 | // DRM section: trailer |
179 | MakeDRMtrailer(buf); | |
7e6dce66 | 180 | |
d0eb8f39 | 181 | // LTM section |
7e6dce66 | 182 | fIndex++; |
d0eb8f39 | 183 | buf[fIndex] = MakeFiller(); |
184 | MakeLTMtrailer(buf); | |
185 | MakeLTMdata(buf); | |
186 | MakeLTMheader(buf); | |
187 | ||
188 | // loop on TRM number per DRM | |
189 | for (nTRM=AliTOFGeometry::NTRM(); nTRM>=3; nTRM--) { | |
190 | ||
191 | nWordsPerTRM = 0; | |
192 | ||
193 | // the slot number 3 of the even DRM (i.e. right) doesn't contain TDC digit data | |
194 | if (iDDL%2==0 && nTRM==3) continue; | |
195 | ||
196 | // TRM global trailer | |
197 | MakeTRMtrailer(buf); | |
198 | ||
199 | // loop on TRM chain number per TRM | |
200 | for (iChain=AliTOFGeometry::NChain()-1; iChain>=0; iChain--) { | |
201 | ||
202 | // TRM chain trailer | |
203 | MakeTRMchainTrailer(iChain, buf); | |
204 | nWordsPerTRM++; | |
205 | ||
206 | // TRM TDC digits | |
207 | MakeTDCdigits(nDDL, nTRM, iChain, buf, nWordsPerTRM); | |
208 | ||
209 | // TRM chain header | |
210 | MakeTRMchainHeader(nTRM, iChain, buf); | |
211 | nWordsPerTRM++; | |
212 | ||
213 | } // end loop on iChain | |
7e6dce66 | 214 | |
d0eb8f39 | 215 | // TRM global header |
216 | MakeTRMheader(nTRM, buf); | |
217 | ||
218 | // TRM filler in case where TRM data number is odd | |
219 | if (nWordsPerTRM%2!=0) MakeTRMfiller(buf, nWordsPerTRM); | |
220 | ||
221 | } // end loop on nTRM | |
222 | ||
223 | // DRM section: in | |
224 | MakeDRMheader(nDDL, buf); | |
225 | ||
226 | ReverseArray(buf, fIndex+1); | |
7e6dce66 | 227 | |
7e6dce66 | 228 | outfile.write((char *)buf,((fIndex+1)*sizeof(UInt_t))); |
229 | ||
d0eb8f39 | 230 | for (jj=0; jj<(fIndex+1); jj++) buf[jj]=0; |
231 | fIndex = -1; | |
7e6dce66 | 232 | |
233 | //Write REAL DATA HEADER | |
d0eb8f39 | 234 | UInt_t currentFilePosition = outfile.tellp(); |
571dda3d | 235 | sizeRawData = currentFilePosition - dataHeaderPosition - sizeof(header); |
d0eb8f39 | 236 | header.fSize = currentFilePosition - dataHeaderPosition; |
7e6dce66 | 237 | header.SetAttribute(0); // valid data |
571dda3d | 238 | outfile.seekp(dataHeaderPosition); |
7e6dce66 | 239 | outfile.write((char*)(&header),sizeof(header)); |
571dda3d | 240 | outfile.seekp(currentFilePosition); |
241 | ||
7e6dce66 | 242 | outfile.close(); |
243 | ||
d0eb8f39 | 244 | } //end loop on DDL file number |
245 | ||
246 | return 0; | |
247 | ||
248 | } | |
249 | ||
250 | //---------------------------------------------------------------------------- | |
251 | void AliTOFDDLRawData::GetDigits() | |
252 | { | |
253 | // | |
254 | // Fill the TOF volumes' map with the TOF digit indices | |
255 | // | |
256 | ||
257 | Int_t vol[5] = {-1,-1,-1,-1,-1}; | |
258 | ||
259 | Int_t digit = -1; | |
260 | Int_t ndigits = fTOFdigitArray->GetEntries(); | |
261 | ||
262 | AliTOFdigit *digs; | |
263 | ||
264 | // loop on TOF digits | |
265 | for (digit=0; digit<ndigits; digit++) { | |
266 | digs = (AliTOFdigit*)fTOFdigitArray->UncheckedAt(digit); | |
267 | ||
268 | vol[0] = digs->GetSector(); // Sector Number (0-17) | |
269 | vol[1] = digs->GetPlate(); // Plate Number (0-4) | |
270 | vol[2] = digs->GetStrip(); // Strip Number (0-14/18) | |
271 | vol[3] = digs->GetPadx(); // Pad Number in x direction (0-47) | |
272 | vol[4] = digs->GetPadz(); // Pad Number in z direction (0-1) | |
273 | ||
274 | fTOFdigitMap->AddDigit(vol, digit); | |
275 | ||
276 | } // close loop on digit del TOF | |
277 | ||
278 | } | |
279 | ||
280 | //---------------------------------------------------------------------------- | |
281 | void AliTOFDDLRawData::MakeDRMheader(Int_t nDDL, UInt_t *buf) | |
282 | { | |
283 | // | |
284 | // DRM global header | |
285 | // | |
286 | ||
287 | Int_t iDDL = fTOFrawStream->GetDDLnumberPerSector(nDDL); | |
288 | ||
289 | Int_t iSector = fTOFrawStream->GetSectorNumber(nDDL); | |
290 | ||
291 | UInt_t baseWord=0; | |
292 | UInt_t word; | |
293 | ||
294 | // DRM event CRC | |
295 | baseWord=0; | |
296 | word = 1; // 0001 -> DRM data are coming from the VME slot number 1 | |
297 | AliBitPacking::PackWord(word,baseWord, 0, 3); | |
298 | word = 0; // event CRC | |
299 | AliBitPacking::PackWord(word,baseWord, 4,19); | |
300 | word = 0; // reserved for future use | |
301 | AliBitPacking::PackWord(word,baseWord,20,27); | |
302 | word = 4; // 0100 -> DRM header ID | |
303 | AliBitPacking::PackWord(word,baseWord,28,31); | |
304 | fIndex++; | |
305 | buf[fIndex]=baseWord; | |
306 | ||
307 | // DRM status header 3 | |
308 | baseWord=0; | |
309 | word = 1; // 0001 -> DRM data are coming from the VME slot number 1 | |
310 | AliBitPacking::PackWord(word,baseWord, 0, 3); | |
311 | word = 0; // TTC event counter | |
312 | AliBitPacking::PackWord(word,baseWord, 4,27); | |
313 | word = 4; // 0100 -> DRM header ID | |
314 | AliBitPacking::PackWord(word,baseWord,28,31); | |
315 | fIndex++; | |
316 | buf[fIndex]=baseWord; | |
317 | ||
318 | // DRM status header 2 | |
319 | baseWord=0; | |
320 | word = 1; // 0001 -> DRM data are coming from the VME slot number 1 | |
321 | AliBitPacking::PackWord(word,baseWord, 0, 3); | |
322 | ||
323 | if (iDDL%2==1) { | |
324 | word = 2047; // enable ID: [00000000000;11111111111] for odd | |
325 | // (i.e. right) crates | |
326 | AliBitPacking::PackWord(word,baseWord, 4,14); | |
327 | } else { | |
328 | word = 2045; // enable ID: [00000000000;11111111101] for even | |
329 | // (i.e. left) crates | |
330 | AliBitPacking::PackWord(word,baseWord, 4,14); | |
331 | } | |
332 | ||
333 | word = 0; // | |
334 | AliBitPacking::PackWord(word,baseWord,15,15); | |
335 | word = 0; // fault ID | |
336 | AliBitPacking::PackWord(word,baseWord,16,27); | |
337 | word = 4; // 0100 -> DRM header ID | |
338 | AliBitPacking::PackWord(word,baseWord,28,31); | |
339 | fIndex++; | |
340 | buf[fIndex]=baseWord; | |
7e6dce66 | 341 | |
d0eb8f39 | 342 | // DRM status header 1 |
343 | baseWord=0; | |
344 | word = 1; // 0001 -> DRM data are coming from the VME slot number 1 | |
345 | AliBitPacking::PackWord(word,baseWord, 0, 3); | |
346 | ||
347 | if (iDDL%2==1) { | |
348 | word = 2047; // slot ID: [00000000000;11111111111] for odd | |
349 | // (i.e. right) crates | |
350 | AliBitPacking::PackWord(word,baseWord, 4,14); | |
351 | } else { | |
352 | word = 2045; // slot ID: [00000000000;11111111101] for even | |
353 | // (i.e. left) crates | |
354 | AliBitPacking::PackWord(word,baseWord, 4,14); | |
355 | } | |
356 | ||
357 | word = 1; // LHC clock status: 1/0 | |
358 | AliBitPacking::PackWord(word,baseWord,15,15); | |
359 | word = 0; // reserved for future use | |
360 | AliBitPacking::PackWord(word,baseWord,16,27); | |
361 | word = 4; // 0100 -> DRM header ID | |
362 | AliBitPacking::PackWord(word,baseWord,28,31); | |
363 | fIndex++; | |
364 | buf[fIndex]=baseWord; | |
365 | ||
366 | // DRM global header | |
367 | baseWord=0; | |
368 | word = 1; // 0001 -> DRM data are coming from the VME slot number 1 | |
369 | AliBitPacking::PackWord(word,baseWord, 0, 3); | |
370 | word = fIndex+1 + 1; // event words | |
371 | AliBitPacking::PackWord(word,baseWord, 4,20); | |
372 | word = iDDL; // crate ID [0;3] | |
373 | AliBitPacking::PackWord(word,baseWord,21,22); | |
374 | word = iSector; // sector ID [0;17] | |
375 | AliBitPacking::PackWord(word,baseWord,23,27); | |
376 | word = 4; // 0100 -> DRM header ID | |
377 | AliBitPacking::PackWord(word,baseWord,28,31); | |
378 | fIndex++; | |
379 | buf[fIndex]=baseWord; | |
380 | ||
7e6dce66 | 381 | } |
382 | ||
d0eb8f39 | 383 | //---------------------------------------------------------------------------- |
384 | void AliTOFDDLRawData::MakeDRMtrailer(UInt_t *buf) | |
385 | { | |
386 | // | |
387 | // DRM global trailer | |
388 | // | |
389 | ||
390 | UInt_t baseWord; | |
391 | UInt_t word; | |
392 | ||
393 | baseWord=0; | |
394 | word = 1; // 0001 -> DRM data are coming from the VME slot number 1 | |
395 | AliBitPacking::PackWord(word,baseWord, 0, 3); | |
396 | word = 0; // local event counter | |
397 | AliBitPacking::PackWord(word,baseWord, 4,15); | |
398 | word = 0; // reserved for future use | |
399 | AliBitPacking::PackWord(word,baseWord,16,27); | |
400 | word = 5; // 0101 -> DRM trailer ID | |
401 | AliBitPacking::PackWord(word,baseWord,28,31); | |
402 | fIndex++; | |
403 | buf[fIndex]=baseWord; | |
404 | ||
405 | } | |
406 | ||
407 | //---------------------------------------------------------------------------- | |
408 | void AliTOFDDLRawData::MakeLTMheader(UInt_t *buf) | |
409 | { | |
410 | // | |
411 | // LTM header | |
412 | // | |
413 | ||
414 | UInt_t baseWord; | |
415 | UInt_t word; | |
416 | ||
417 | baseWord=0; | |
418 | word = 2; // 0010 -> LTM data are coming from the VME slot number 2 | |
419 | AliBitPacking::PackWord(word,baseWord, 0, 3); | |
420 | word = 35; // event words | |
421 | AliBitPacking::PackWord(word,baseWord, 4,16); | |
422 | word = 0; // crc error | |
423 | AliBitPacking::PackWord(word,baseWord,17,17); | |
424 | word = 0; // fault | |
425 | AliBitPacking::PackWord(word,baseWord,18,23); | |
426 | word = 0; | |
427 | AliBitPacking::PackWord(word,baseWord,24,27); | |
428 | word = 4; // 0100 -> LTM header ID | |
429 | AliBitPacking::PackWord(word,baseWord,28,31); | |
430 | fIndex++; | |
431 | buf[fIndex]=baseWord; | |
432 | ||
433 | } | |
434 | ||
435 | //---------------------------------------------------------------------------- | |
436 | void AliTOFDDLRawData::MakeLTMdata(UInt_t *buf) | |
437 | { | |
438 | // | |
439 | // LTM data | |
440 | // | |
441 | ||
442 | UInt_t baseWord; | |
443 | UInt_t word; | |
444 | ||
445 | baseWord=0; | |
446 | word = 100; // Local temperature in LTM5 -> 4 X 25 degree (environment temperature) | |
447 | AliBitPacking::PackWord(word,baseWord, 0, 9); | |
448 | word = 100; // Local temperature in LTM6 -> 4 X 25 degree (environment temperature) | |
449 | AliBitPacking::PackWord(word,baseWord,10,19); | |
450 | word = 100; // Local temperature in LTM7 -> 4 X 25 degree (environment temperature) | |
451 | AliBitPacking::PackWord(word,baseWord,20,29); | |
452 | word = 0; | |
453 | AliBitPacking::PackWord(word,baseWord,30,31); | |
454 | ||
455 | fIndex++; | |
456 | buf[fIndex]=baseWord; | |
457 | ||
458 | // Local temperature in LTM2, LMT3, LTM4 -> 4 X 25 degree (environment temperature) | |
459 | fIndex++; | |
460 | buf[fIndex]=baseWord; | |
461 | ||
462 | // Local temperature in FEAC7, FEAC8, LTM1 -> 4 X 25 degree (environment temperature) | |
463 | fIndex++; | |
464 | buf[fIndex]=baseWord; | |
465 | ||
466 | // Local temperature in FEAC4, FEAC5, FEAC6 -> 4 X 25 degree (environment temperature) | |
467 | fIndex++; | |
468 | buf[fIndex]=baseWord; | |
469 | ||
470 | // Local temperature in FEAC1, FEAC2, FEAC3 -> 4 X 25 degree (environment temperature) | |
471 | fIndex++; | |
472 | buf[fIndex]=baseWord; | |
473 | ||
474 | baseWord=0; | |
475 | word = 0; // GND-FEAC15 -> Voltage drop between GND and FEAC15 | |
476 | AliBitPacking::PackWord(word,baseWord, 0, 9); | |
477 | word = 0; // VTH16 -> Thereshould voltage for FEAC16 | |
478 | AliBitPacking::PackWord(word,baseWord,10,19); | |
479 | word = 0; // GND-FEAC16 -> Voltage drop between GND and FEAC16 | |
480 | AliBitPacking::PackWord(word,baseWord,20,29); | |
481 | word = 0; | |
482 | AliBitPacking::PackWord(word,baseWord,30,31); | |
483 | ||
484 | fIndex++; | |
485 | buf[fIndex]=baseWord; | |
486 | ||
487 | // VTH14 -> Thereshould voltage for FEAC14 | |
488 | // GND-FEAC14 -> Voltage drop between GND and FEAC14 | |
489 | // VTH15 -> Thereshould voltage for FEAC15 | |
490 | fIndex++; | |
491 | buf[fIndex]=baseWord; | |
492 | ||
493 | // GND-FEAC12 -> Voltage drop between GND and FEAC12 | |
494 | // VTH13 -> Thereshould voltage for FEAC13 | |
495 | // GND-FEAC13 -> Voltage drop between GND and FEAC13 | |
496 | fIndex++; | |
497 | buf[fIndex]=baseWord; | |
498 | ||
499 | // VTH11 -> Thereshould voltage for FEAC11 | |
500 | // GND-FEAC11 -> Voltage drop between GND and FEAC11 | |
501 | // VTH12 -> Thereshould voltage for FEAC12 | |
502 | fIndex++; | |
503 | buf[fIndex]=baseWord; | |
504 | ||
505 | // GND-FEAC9 -> Voltage drop between GND and FEAC9 | |
506 | // VTH10 -> Thereshould voltage for FEAC10 | |
507 | // GND-FEAC10 -> Voltage drop between GND and FEAC10 | |
508 | fIndex++; | |
509 | buf[fIndex]=baseWord; | |
510 | ||
511 | // VTH8 -> Thereshould voltage for FEAC8 | |
512 | // GND-FEAC8 -> Voltage drop between GND and FEAC8 | |
513 | // VTH9 -> Thereshould voltage for FEAC9 | |
514 | fIndex++; | |
515 | buf[fIndex]=baseWord; | |
516 | ||
517 | // GND-FEAC6 -> Voltage drop between GND and FEAC6 | |
518 | // VTH7 -> Thereshould voltage for FEAC7 | |
519 | // GND-FEAC7 -> Voltage drop between GND and FEAC7 | |
520 | fIndex++; | |
521 | buf[fIndex]=baseWord; | |
522 | ||
523 | // VTH5 -> Thereshould voltage for FEAC5 | |
524 | // GND-FEAC5 -> Voltage drop between GND and FEAC5 | |
525 | // VTH6 -> Thereshould voltage for FEAC6 | |
526 | fIndex++; | |
527 | buf[fIndex]=baseWord; | |
528 | ||
529 | // GND-FEAC3 -> Voltage drop between GND and FEAC3 | |
530 | // VTH4 -> Thereshould voltage for FEAC4 | |
531 | // GND-FEAC4 -> Voltage drop between GND and FEAC4 | |
532 | fIndex++; | |
533 | buf[fIndex]=baseWord; | |
534 | ||
535 | // VTH2 -> Thereshould voltage for FEAC2 | |
536 | // GND-FEAC2 -> Voltage drop between GND and FEAC2 | |
537 | // VTH3 -> Thereshould voltage for FEAC3 | |
538 | fIndex++; | |
539 | buf[fIndex]=baseWord; | |
540 | ||
541 | // LV16 -> Low Voltage measured by FEAC16 | |
542 | // GND-FEAC1 -> Voltage drop between GND and FEAC1 | |
543 | // VTH1 -> Thereshould voltage for FEAC1 | |
544 | fIndex++; | |
545 | buf[fIndex]=baseWord; | |
546 | ||
547 | // Low Voltage measured by FEAC13, FEAC14, FEAC15 | |
548 | fIndex++; | |
549 | buf[fIndex]=baseWord; | |
550 | ||
551 | // Low Voltage measured by FEAC10, FEAC11, FEAC12 | |
552 | fIndex++; | |
553 | buf[fIndex]=baseWord; | |
554 | ||
555 | // Low Voltage measured by FEAC7, FEAC8, FEAC9 | |
556 | fIndex++; | |
557 | buf[fIndex]=baseWord; | |
558 | ||
559 | // Low Voltage measured by FEAC4, FEAC5, FEAC6 | |
560 | fIndex++; | |
561 | buf[fIndex]=baseWord; | |
562 | ||
563 | // Low Voltage measured by FEAC1, FEAC2, FEAC3 | |
564 | fIndex++; | |
565 | buf[fIndex]=baseWord; | |
566 | ||
567 | ||
568 | baseWord=0; | |
569 | word = 0; // PDL45 -> Delay Line setting for PDL45 | |
570 | AliBitPacking::PackWord(word,baseWord, 0, 7); | |
571 | word = 0; // PDL46 -> Delay Line setting for PDL46 | |
572 | AliBitPacking::PackWord(word,baseWord, 8,15); | |
573 | word = 0; // PDL47 -> Delay Line setting for PDL47 | |
574 | AliBitPacking::PackWord(word,baseWord,16,23); | |
575 | word = 0; // PDL48 -> Delay Line setting for PDL48 | |
576 | AliBitPacking::PackWord(word,baseWord,24,31); | |
577 | fIndex++; | |
578 | buf[fIndex]=baseWord; | |
579 | ||
580 | // Delay Line setting for PDL41, PDL42, PDL43, PDL44 | |
581 | fIndex++; | |
582 | buf[fIndex]=baseWord; | |
583 | ||
584 | // Delay Line setting for PDL37, PDL38, PDL39, PDL40 | |
585 | fIndex++; | |
586 | buf[fIndex]=baseWord; | |
587 | ||
588 | // Delay Line setting for PDL33, PDL34, PDL35, PDL36 | |
589 | fIndex++; | |
590 | buf[fIndex]=baseWord; | |
591 | ||
592 | // Delay Line setting for PDL29, PDL30, PDL31, PDL32 | |
593 | fIndex++; | |
594 | buf[fIndex]=baseWord; | |
595 | ||
596 | // Delay Line setting for PDL25, PDL26, PDL27, PDL28 | |
597 | fIndex++; | |
598 | buf[fIndex]=baseWord; | |
599 | ||
600 | // Delay Line setting for PDL21, PDL22, PDL23, PDL24 | |
601 | fIndex++; | |
602 | buf[fIndex]=baseWord; | |
603 | ||
604 | // Delay Line setting for PDL17, PDL18, PDL19, PDL20 | |
605 | fIndex++; | |
606 | buf[fIndex]=baseWord; | |
607 | ||
608 | // Delay Line setting for PDL13, PDL14, PDL15, PDL16 | |
609 | fIndex++; | |
610 | buf[fIndex]=baseWord; | |
611 | ||
612 | // Delay Line setting for PDL9, PDL10, PDL11, PDL12 | |
613 | fIndex++; | |
614 | buf[fIndex]=baseWord; | |
615 | ||
616 | // Delay Line setting for PDL5, PDL6, PDL7, PDL8 | |
617 | fIndex++; | |
618 | buf[fIndex]=baseWord; | |
619 | ||
620 | // Delay Line setting for PDL1, PDL2, PDL3, PDL4 | |
621 | fIndex++; | |
622 | buf[fIndex]=baseWord; | |
623 | ||
624 | } | |
625 | ||
626 | //---------------------------------------------------------------------------- | |
627 | void AliTOFDDLRawData::MakeLTMtrailer(UInt_t *buf) | |
628 | { | |
629 | // | |
630 | // LTM trailer | |
631 | // | |
632 | ||
633 | UInt_t baseWord; | |
634 | UInt_t word; | |
635 | ||
636 | baseWord=0; | |
637 | word = 2; // 0010 -> LTM data are coming from the VME slot number 2 | |
638 | AliBitPacking::PackWord(word,baseWord, 0, 3); | |
639 | word = 0; // event crc | |
640 | AliBitPacking::PackWord(word,baseWord, 4,15); | |
641 | word = 0; // event number | |
642 | AliBitPacking::PackWord(word,baseWord,16,27); | |
643 | word = 5; // 0101 -> LTM trailer ID | |
644 | AliBitPacking::PackWord(word,baseWord,28,31); | |
645 | fIndex++; | |
646 | buf[fIndex]=baseWord; | |
647 | ||
648 | } | |
649 | ||
650 | //---------------------------------------------------------------------------- | |
651 | void AliTOFDDLRawData::MakeTRMheader(Int_t nTRM, UInt_t *buf) | |
652 | { | |
653 | // | |
654 | // TRM header for the TRM number nTRM [ 3;12] | |
655 | // | |
656 | ||
657 | if (nTRM<3 || nTRM>12) { | |
658 | AliWarning(Form(" TRM number is out of the right range [3;12] (nTRM = %3i",nTRM)); | |
659 | return; | |
660 | } | |
661 | ||
662 | UInt_t baseWord; | |
663 | UInt_t word; | |
664 | ||
665 | baseWord = 0; | |
666 | word = nTRM; // TRM data coming from the VME slot number nTRM | |
667 | AliBitPacking::PackWord(word,baseWord, 0, 3); | |
668 | word = 0; // event words | |
669 | AliBitPacking::PackWord(word,baseWord, 4,16); | |
670 | word = 0; // ACQuisition mode: [0;3] see document | |
671 | AliBitPacking::PackWord(word,baseWord,17,18); | |
672 | word = 0; // description of a SEU inside LUT tables for INL compensation; | |
673 | // the data are unaffected | |
674 | AliBitPacking::PackWord(word,baseWord,19,19); | |
675 | word = 0; // Must Be Zero (MBZ) | |
676 | AliBitPacking::PackWord(word,baseWord,20,27); | |
677 | word = 4; // 0100 -> TRM header ID | |
678 | AliBitPacking::PackWord(word,baseWord,28,31); | |
679 | fIndex++; | |
680 | buf[fIndex]=baseWord; | |
681 | ||
682 | } | |
683 | ||
684 | //---------------------------------------------------------------------------- | |
685 | void AliTOFDDLRawData::MakeTRMtrailer(UInt_t *buf) | |
686 | { | |
687 | // | |
688 | // TRM trailer | |
689 | // | |
690 | ||
691 | UInt_t baseWord; | |
692 | UInt_t word; | |
693 | ||
694 | baseWord=0; | |
695 | word = 15; // 1111 -> TRM trailer ID 1 | |
696 | AliBitPacking::PackWord(word,baseWord, 0, 3); | |
697 | word = 0; // event CRC | |
698 | AliBitPacking::PackWord(word,baseWord, 4,15); | |
699 | word = 0; // local event counter == DRM local event counter | |
700 | AliBitPacking::PackWord(word,baseWord,16,27); | |
701 | word = 5; // 0101 -> TRM trailer ID 2 | |
702 | AliBitPacking::PackWord(word,baseWord,28,31); | |
703 | fIndex++; | |
704 | buf[fIndex]=baseWord; | |
705 | ||
706 | } | |
707 | ||
708 | //---------------------------------------------------------------------------- | |
709 | void AliTOFDDLRawData::MakeTRMchainHeader(Int_t nTRM, Int_t iChain, | |
710 | UInt_t *buf) | |
711 | { | |
712 | // | |
713 | // TRM chain header | |
714 | // | |
715 | ||
716 | UInt_t baseWord; | |
717 | UInt_t word; | |
718 | ||
719 | if (nTRM<3 || nTRM>12) { | |
720 | AliWarning(Form(" TRM number is out of the right range [3;12] (nTRM = %3i", nTRM)); | |
721 | return; | |
722 | } | |
723 | ||
724 | if (iChain<0 || iChain>1) { | |
725 | AliWarning(Form(" Chain number is out of the right range [0;1] (iChain = %3i", iChain)); | |
726 | return; | |
727 | } | |
728 | ||
729 | baseWord=0; | |
730 | word = nTRM; // TRM data coming from the VME slot ID nTRM | |
731 | AliBitPacking::PackWord(word,baseWord, 0, 3); | |
732 | word = 0; // bunch ID | |
733 | AliBitPacking::PackWord(word,baseWord, 4,15); | |
734 | word = 100; // PB24 temperature -> 4 X 25 degree (environment temperature) | |
735 | AliBitPacking::PackWord(word,baseWord,16,23); | |
736 | word = (Int_t)(5 * gRandom->Rndm()); // PB24 ID [0;4] | |
737 | AliBitPacking::PackWord(word,baseWord,24,26); | |
738 | word = 0; // TS | |
739 | AliBitPacking::PackWord(word,baseWord,27,27); | |
740 | switch (iChain) { | |
741 | case 0: | |
742 | word = 0; // 0000 -> TRM chain 0 ID | |
743 | break; | |
744 | case 1: | |
745 | word = 2; // 0010 -> TRM chain 1 ID | |
746 | break; | |
747 | } | |
748 | AliBitPacking::PackWord(word,baseWord,28,31); | |
749 | fIndex++; | |
750 | buf[fIndex]=baseWord; | |
751 | ||
752 | } | |
753 | ||
754 | //---------------------------------------------------------------------------- | |
755 | void AliTOFDDLRawData::MakeTRMfiller(UInt_t *buf, UInt_t nWordsPerTRM) | |
756 | { | |
757 | // | |
758 | // TRM filler | |
759 | // | |
760 | ||
761 | Int_t jj = -1; | |
762 | ||
763 | fIndex++; | |
764 | for (jj=fIndex; jj>fIndex-(Int_t)nWordsPerTRM; jj--) { | |
765 | buf[jj] = buf[jj-1]; | |
766 | } | |
767 | ||
768 | buf[fIndex-nWordsPerTRM] = MakeFiller(); | |
769 | ||
770 | } | |
771 | ||
772 | //---------------------------------------------------------------------------- | |
773 | UInt_t AliTOFDDLRawData::MakeFiller() | |
774 | { | |
775 | // | |
776 | // Filler word definition: to make even the number of words per TRM/LTM | |
777 | // | |
778 | ||
779 | UInt_t baseWord; | |
780 | UInt_t word; | |
781 | ||
782 | baseWord=0; | |
783 | word = 0; // 0000 -> filler ID 1 | |
784 | AliBitPacking::PackWord(word,baseWord, 0, 3); | |
785 | word = 0; // MBZ | |
786 | AliBitPacking::PackWord(word,baseWord, 4,27); | |
787 | word = 7; // 0111 -> filler ID 2 | |
788 | AliBitPacking::PackWord(word,baseWord, 28,31); | |
789 | ||
790 | return baseWord; | |
791 | ||
792 | } | |
793 | ||
794 | //---------------------------------------------------------------------------- | |
795 | void AliTOFDDLRawData::MakeTRMchainTrailer(Int_t iChain, UInt_t *buf) | |
796 | { | |
797 | // | |
798 | // TRM chain trailer | |
799 | // | |
800 | ||
801 | if (iChain<0 || iChain>1) { | |
802 | AliWarning(Form(" Chain number is out of the right range [0;1] (iChain = %3i", iChain)); | |
803 | return; | |
804 | } | |
805 | ||
806 | UInt_t baseWord; | |
807 | UInt_t word; | |
808 | ||
809 | baseWord=0; | |
810 | word = 0; // status | |
811 | AliBitPacking::PackWord(word,baseWord, 0, 3); | |
812 | word = 0; // MBZ | |
813 | AliBitPacking::PackWord(word,baseWord, 4,15); | |
814 | word = 0; // event counter | |
815 | AliBitPacking::PackWord(word,baseWord,16,27); | |
816 | switch (iChain) { | |
817 | case 0: | |
818 | word = 1; // 0001 -> TRM chain 0 trailer ID | |
819 | break; | |
820 | case 1: | |
821 | word = 3; // 0011 -> TRM chain 1 trailer ID | |
822 | break; | |
823 | } | |
824 | AliBitPacking::PackWord(word,baseWord,28,31); | |
825 | fIndex++; | |
826 | buf[fIndex]=baseWord; | |
827 | ||
828 | } | |
829 | ||
830 | //---------------------------------------------------------------------------- | |
831 | void AliTOFDDLRawData::MakeTDCdigits(Int_t nDDL, Int_t nTRM, Int_t iChain, | |
832 | UInt_t *buf, UInt_t &nWordsPerTRM) | |
833 | { | |
834 | // | |
835 | // TRM TDC digit | |
836 | // | |
837 | ||
838 | if (nDDL<0 || nDDL>71) { | |
839 | AliWarning(Form(" DDL number is out of the right range [0;71] (nDDL = %3i", nDDL)); | |
840 | return; | |
841 | } | |
842 | ||
843 | if (nTRM<3 || nTRM>12) { | |
844 | AliWarning(Form(" TRM number is out of the right range [3;12] (nTRM = %3i", nTRM)); | |
845 | return; | |
846 | } | |
847 | ||
848 | if (iChain<0 || iChain>1) { | |
849 | AliWarning(Form(" Chain number is out of the right range [0;1] (iChain = %3i", iChain)); | |
850 | return; | |
851 | } | |
852 | ||
853 | Int_t iDDL = nDDL%AliTOFGeometry::NDDL(); | |
854 | ||
855 | Int_t volume[5] = {-1, -1, -1, -1, -1}; | |
856 | Int_t indexDigit[3] = {-1, -1, -1}; | |
857 | ||
858 | Int_t totCharge = -1; | |
859 | Int_t timeOfFlight = -1; | |
860 | ||
861 | AliTOFdigit *digs; | |
862 | ||
863 | UInt_t baseWord=0; | |
864 | UInt_t word=0; | |
865 | ||
866 | Int_t jj = -1; | |
867 | Int_t nTDC = -1; | |
868 | Int_t iCH = -1; | |
869 | ||
870 | ofstream ftxt; | |
871 | ||
872 | if (fVerbose==2) ftxt.open("TOFdigits.txt",ios::app); | |
873 | ||
874 | for (jj=0; jj<5; jj++) volume[jj] = -1; | |
875 | ||
876 | // loop on TDC number | |
877 | for (nTDC=AliTOFGeometry::NTdc()-1; nTDC>=0; nTDC--) { | |
878 | ||
879 | // the DRM odd (i.e. left) slot number 3 doesn't contain TDC digit data | |
880 | // for TDC numbers 3-14 | |
881 | if (iDDL%2==1 && nTRM==3 && (Int_t)(nTDC/3.)!=0) continue; | |
882 | ||
883 | // loop on TDC channel number | |
884 | for (iCH=AliTOFGeometry::NCh()-1; iCH>=0; iCH--) { | |
885 | ||
886 | fTOFrawStream->EquipmentId2VolumeId(nDDL, nTRM, iChain, nTDC, iCH, volume); | |
887 | ||
888 | if (volume[0]==-1 || volume[1]==-1 || volume[2]==-1 || | |
889 | volume[3]==-1 || volume[4]==-1) continue; | |
890 | //AliInfo(Form(" sector = %2i plate = %1i strip = %2i | |
891 | //padX = %2i padZ = %1i", volume[0], volume[1], volume[2], | |
892 | //volume[3], volume[4])); | |
893 | ||
894 | for (jj=0; jj<3; jj++) indexDigit[jj] = -1; | |
895 | ||
896 | fTOFdigitMap->GetDigitIndex(volume, indexDigit); | |
897 | ||
898 | for (jj=0; jj<3;jj++) { | |
899 | ||
900 | if (indexDigit[jj]<0) continue; | |
901 | digs = (AliTOFdigit*)fTOFdigitArray->UncheckedAt(indexDigit[jj]); | |
902 | ||
903 | if (digs->GetSector()!=volume[0] || | |
904 | digs->GetPlate() !=volume[1] || | |
905 | digs->GetStrip() !=volume[2] || | |
906 | digs->GetPadx() !=volume[3] || | |
907 | digs->GetPadz() !=volume[4]) AliWarning(" --- ERROR --- "); | |
908 | ||
909 | timeOfFlight = (Int_t)(digs->GetTdc())%8192; | |
910 | totCharge = (Int_t)(digs->GetToT());//digs->GetAdc(); | |
911 | // temporary control | |
912 | if (totCharge<0) totCharge = TMath::Abs(totCharge); | |
913 | if (totCharge>=256) totCharge = 255; | |
914 | ||
915 | if (fVerbose==2) { | |
916 | if (nDDL<10) ftxt << " " << nDDL; | |
917 | else ftxt << " " << nDDL; | |
918 | if (nTRM<10) ftxt << " " << nTRM; | |
919 | else ftxt << " " << nTRM; | |
920 | ftxt << " " << iChain; | |
921 | if (nTDC<10) ftxt << " " << nTDC; | |
922 | else ftxt << " " << nTDC; | |
923 | ftxt << " " << iCH; | |
924 | if (volume[0]<10) ftxt << " -> " << volume[0]; | |
925 | else ftxt << " -> " << volume[0]; | |
926 | ftxt << " " << volume[1]; | |
927 | if (volume[2]<10) ftxt << " " << volume[2]; | |
928 | else ftxt << " " << volume[2]; | |
929 | ftxt << " " << volume[4]; | |
930 | if (volume[3]<10) ftxt << " " << volume[3]; | |
931 | else ftxt << " " << volume[3]; | |
932 | if (totCharge<10) ftxt << " " << totCharge; | |
933 | else if (totCharge>=10 && totCharge<100) ftxt << " " << totCharge; | |
934 | else ftxt << " " << totCharge; | |
935 | if (timeOfFlight<10) ftxt << " " << timeOfFlight << endl; | |
936 | else if (timeOfFlight>=10 && timeOfFlight<100) ftxt << " " << timeOfFlight << endl; | |
937 | else if (timeOfFlight>=100 && timeOfFlight<1000) ftxt << " " << timeOfFlight << endl; | |
938 | else ftxt << " " << timeOfFlight << endl; | |
939 | } | |
940 | ||
941 | word = timeOfFlight; // time-of-fligth measurement | |
942 | AliBitPacking::PackWord(word,baseWord, 0,12); | |
943 | ||
944 | word = totCharge; // time-over-threshould measurement | |
945 | AliBitPacking::PackWord(word,baseWord,13,20); | |
946 | ||
947 | word = iCH; // TDC channel ID [0;7] | |
948 | AliBitPacking::PackWord(word,baseWord,21,23); | |
949 | word = nTDC; // TDC ID [0;14] | |
950 | AliBitPacking::PackWord(word,baseWord,24,27); | |
951 | word = 0; // error flag | |
952 | AliBitPacking::PackWord(word,baseWord,28,28); | |
953 | word = 0; // Packing Status [0;5] | |
954 | AliBitPacking::PackWord(word,baseWord,29,30); | |
955 | word = 1; // TRM TDC digit ID | |
956 | AliBitPacking::PackWord(word,baseWord,31,31); | |
957 | fIndex++; | |
958 | buf[fIndex]=baseWord; | |
959 | ||
960 | nWordsPerTRM++; | |
961 | baseWord=0; | |
962 | ||
963 | } //end loop on digits in the same volume | |
964 | ||
965 | } // end loop on TDC channel number | |
966 | ||
967 | } // end loop on TDC number | |
968 | ||
969 | ||
970 | if (fVerbose==2) ftxt.close(); | |
971 | ||
972 | } | |
973 | ||
974 | //---------------------------------------------------------------------------- | |
975 | void AliTOFDDLRawData::ReverseArray(UInt_t a[], Int_t n) const | |
976 | { | |
977 | // | |
978 | // Reverses the n elements of array a | |
979 | // | |
980 | ||
981 | Int_t ii, temp; | |
982 | ||
983 | for (ii=0; ii<n/2; ii++) { | |
984 | temp = a[ii]; | |
985 | a[ii] = a[n-ii-1]; | |
986 | a[n-ii-1] = temp; | |
987 | } | |
988 | ||
989 | return; | |
990 | ||
991 | } |