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