2 /**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
21 This class provides access to STU DDL raw data.
22 Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
25 #include "AliEMCALTriggerSTURawStream.h"
26 #include "AliRawReader.h"
29 #include "Riostream.h"
36 const Int_t kPayLoadSizeOld = 236;
37 const Int_t kPayLoadSizeNew = 245;
40 ClassImp(AliEMCALTriggerSTURawStream)
42 //_____________________________________________________________________________
43 AliEMCALTriggerSTURawStream::AliEMCALTriggerSTURawStream() : TObject(),
69 //_____________________________________________________________________________
70 AliEMCALTriggerSTURawStream::AliEMCALTriggerSTURawStream(AliRawReader* rawReader) : TObject(),
71 fRawReader(rawReader),
95 fRawReader->Select("EMCAL",44);
98 //_____________________________________________________________________________
99 AliEMCALTriggerSTURawStream::~AliEMCALTriggerSTURawStream()
104 //_____________________________________________________________________________
105 void AliEMCALTriggerSTURawStream::Reset()
109 if (fRawReader) fRawReader->Reset();
116 //_____________________________________________________________________________
117 Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
119 // STU data decoder from Olivier Bourrion LPSC CNRS-IN2P3
120 // bourrion_at_lpsc_dot_in2p3_dot_fr
122 UInt_t word32[kPayLoadSizeNew + 1536]; // 32b words
123 for (Int_t i = 0;i < kPayLoadSizeNew + 1536; i++) word32[i] = 0;
131 Int_t eqId = -1, eqSize = 0;
135 while (fRawReader->ReadNextInt(w32))
139 eqId = fRawReader->GetEquipmentId();
140 eqSize = fRawReader->GetEquipmentSize();
143 word32[iword++] = w32;
146 if (iword != kPayLoadSizeOld && iword != kPayLoadSizeNew && iword != (kPayLoadSizeOld + 1536) && iword != (kPayLoadSizeNew + 1536))
148 AliError(Form("STU payload (eqId: %d, eqSize: %d) doesn't match expected size! %d word32",
149 eqId, eqSize, iword));
155 AliInfo(Form("STU (eqId: %d, eqSize: %d) payload size: %d word32",
156 eqId, eqSize, iword));
163 case kPayLoadSizeOld:
164 case kPayLoadSizeOld + 1536:
166 fL1JetThreshold = ((word32[0]>>16) & 0xFFF);
167 fL1GammaThreshold = (word32[0] & 0xFFF);
171 case kPayLoadSizeNew:
172 case kPayLoadSizeNew + 1536:
174 fV0A = ((word32[0]>>16) & 0xFFF);
175 fV0C = (word32[0] & 0xFFF);
177 UInt_t sV0 = fV0A + fV0C;
185 fRegionEnable = word32[7];
186 fFrameReceived = word32[8];
187 fFwVersion = word32[9];
189 fL1JetThreshold = fJA * sV0 * sV0 + fJB * sV0 + fJC;
190 fL1GammaThreshold = fGA * sV0 * sV0 + fGB * sV0 + fGC;
202 for (Int_t jet_row = 0; jet_row < 11; jet_row++)
204 UInt_t currentrow = word32[offset + 1 + jet_row];
206 for (Int_t jet_col = 0; jet_col < 15; jet_col++)
208 if (currentrow & (1 << jet_col))
212 fL1JetPatchIndex[fNL1JetPatch-1] = ((jet_row << 8) & 0xFF00) | (jet_col & 0xFF);
218 //////////////////////////////////////////////////////////
220 //////////////////////////////////////////////////////////
221 // FIXME: sounds like not valid data
223 unsigned short truL0indexes[32][6];
225 // extraction from stream
226 for (Int_t index=0;index<6;index++)
228 for (Int_t tru_num=0;tru_num<16;tru_num++)
230 truL0indexes[2*tru_num ][index] = ( word32[offset + 12 + index * 16 + tru_num] & 0xFFFF);
231 truL0indexes[2*tru_num+1][index] = ((word32[offset + 12 + index * 16 + tru_num] >> 16) & 0xFFFF);
235 for (Int_t tru_num=0;tru_num<32;tru_num++)
237 for (Int_t index=0;index<6;index++)
239 for (Int_t bit_num=0;bit_num<12;bit_num++)
241 if ((truL0indexes[tru_num][index] & (1 << bit_num)))
243 Int_t idx = 12 * index + bit_num;
247 fL0GammaPatchIndex[fNL0GammaPatch-1] = (((idx << 5) & 0x7E0) | (tru_num & 0x1F));
253 //////////////////////////////////////////////////////////
254 // index des L1 gamma //
255 //////////////////////////////////////////////////////////
257 unsigned short truL1indexes[32][8];
259 // extraction from stream
260 for (Int_t index=0;index<8;index++)
262 for (Int_t tru_num=0;tru_num<16;tru_num++)
264 truL1indexes[2*tru_num ][index] = ( word32[offset + 108 + index * 16 + tru_num] & 0xFFFF);
265 truL1indexes[2*tru_num+1][index] = ((word32[offset + 108 + index * 16 + tru_num] >> 16) & 0xFFFF);
273 for (Int_t tru_num=0;tru_num<32;tru_num++)
275 for (Int_t index=0;index<8;index++)
277 for (Int_t bit_num=0; bit_num<12; bit_num++)
279 if ((truL1indexes[tru_num][index] & (1<<bit_num)) != 0)
283 gammacolnum = (2*bit_num );
288 gammacolnum = (2*bit_num+1);
294 fL1GammaPatchIndex[fNL1GammaPatch-1] = (((indexcopy << 10) & 0xC00) | ((gammacolnum << 5) & 0x3E0) | (tru_num & 0x1F));
300 //////////////////////////////////////////////////////////
302 //////////////////////////////////////////////////////////
304 if (iword == kPayLoadSizeOld || iword == kPayLoadSizeNew)
312 // extraction from stream
313 for (Int_t index=0;index<96;index++)
315 for (Int_t tru_num=0;tru_num<16;tru_num++)
317 fADC[2*tru_num ][index] = ( word32[offset + 236 + index * 16 + tru_num] & 0xFFFF);
318 fADC[2*tru_num+1][index] = ((word32[offset + 236 + index * 16 + tru_num] >> 16) & 0xFFFF);
322 for (Int_t tru_num=16;tru_num<32;tru_num++) // A side
325 for (Int_t index=0;index<96;index++) v[index] = fADC[tru_num][95-index];
327 for (Int_t index=0;index<96;index++) fADC[tru_num][index] = v[index];
333 //_____________________________________________________________________________
334 Bool_t AliEMCALTriggerSTURawStream::GetL0GammaPatch(const Int_t i, Int_t& tru, Int_t& idx) const
336 // L0 gamma patches sent to STU (original access to L0 patch indexes)
338 if (i > fNL0GammaPatch) return kFALSE;
340 tru = fL0GammaPatchIndex[i] & 0x1F;
341 idx = (fL0GammaPatchIndex[i] & 0x7E0) >> 5;
346 //_____________________________________________________________________________
347 Bool_t AliEMCALTriggerSTURawStream::GetL1GammaPatch(const Int_t i, Int_t& tru, Int_t& col, Int_t& row) const
349 // L1 gamma patch indexes
351 if (i > fNL1GammaPatch) return kFALSE;
353 tru = fL1GammaPatchIndex[i] & 0x1F;
354 col = (fL1GammaPatchIndex[i] & 0x3E0) >> 5;
355 row = (fL1GammaPatchIndex[i] & 0xC00) >> 10;
360 //_____________________________________________________________________________
361 Bool_t AliEMCALTriggerSTURawStream::GetL1JetPatch(const Int_t i, Int_t& col, Int_t& row) const
363 // L1 jet patch indexes
365 if (i > fNL1JetPatch) return kFALSE;
367 col = fL1JetPatchIndex[i] & 0xFF;
368 row = (fL1JetPatchIndex[i] & 0xFF00) >> 8;
373 //_____________________________________________________________________________
374 void AliEMCALTriggerSTURawStream::GetADC(Int_t iTRU, UInt_t ADC[])
378 for (Int_t i=0; i<96; i++) ADC[i] = fADC[iTRU][i];
381 //_____________________________________________________________________________
382 void AliEMCALTriggerSTURawStream::DumpPayLoad(const Option_t *option) const
388 printf("V0A: %d\n", fV0A);
389 printf("V0C: %d\n", fV0C);
390 printf("G_A: %d\n", fGA);
391 printf("G_B: %d\n", fGB);
392 printf("G_C: %d\n", fGC);
393 printf("Gamma threshold: %d\n", fL1GammaThreshold);
394 printf("J_A: %d\n", fJA);
395 printf("J_B: %d\n", fJB);
396 printf("J_C: %d\n", fJC);
397 printf("Jet Threshold: %d\n", fL1JetThreshold);
398 printf("RawData: %d\n", fGetRawData);
399 printf("RegionEnable: %8x\n", fRegionEnable);
400 printf("FrameReceived: %8x\n", fFrameReceived);
401 printf("FwVersion: %x\n", fFwVersion);
402 printf("Number of L0: %d\n", fNL0GammaPatch);
403 printf("Number of L1-g: %d\n", fNL1GammaPatch);
404 printf("Number of L1-j: %d\n", fNL1JetPatch);
406 Int_t itru, col, row;
408 if (op.Contains("L0") || op.Contains("ALL"))
410 for (Int_t i=0;i<fNL0GammaPatch;i++)
413 if (GetL0GammaPatch(i,itru,col))
414 cout << "> Found L0 gamma in TRU #" << setw(2) << itru << " at idx: " << setw(2) << col << endl;
418 if (op.Contains("L1") || op.Contains("ALL"))
420 for (Int_t i=0;i<fNL1GammaPatch;i++)
422 if (GetL1GammaPatch(i,itru,col,row))
423 cout << "> Found L1 gamma in TRU #" << setw(2) << itru << " at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
426 for (Int_t i=0;i<fNL1JetPatch;i++)
428 if (GetL1JetPatch(i,col,row)) cout << "> Found L1 jet at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
434 if ( (op.Contains("ADC") || op.Contains("ALL")) && fGetRawData )
436 for (Int_t i=0;i<32;i++)
438 cout << "--------\n";
439 cout << "TRU #" << setw(2) << i << ":";
440 for (Int_t j=0;j<96;j++)
442 TBits xadc(12); xadc.Set(12,&fADC[i][j]);
443 if ((j%4)==0) cout << endl;
444 //cout << setw(2) << j << ": " << xadc << " ";
445 printf("%2d: %3x / ",j,fADC[i][j]);