1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
20 This class provides access to STU DDL raw data.
21 Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
24 #include "AliEMCALTriggerSTURawStream.h"
25 #include "AliRawReader.h"
28 #include "Riostream.h"
35 const Int_t kPayLoadSize = 944;
36 const Int_t kPayLoadSizeWithRawData = 1772;
39 ClassImp(AliEMCALTriggerSTURawStream)
41 //_____________________________________________________________________________
42 AliEMCALTriggerSTURawStream::AliEMCALTriggerSTURawStream() : TObject(),
57 //_____________________________________________________________________________
58 AliEMCALTriggerSTURawStream::AliEMCALTriggerSTURawStream(AliRawReader* rawReader) : TObject(),
59 fRawReader(rawReader),
72 fRawReader->Select("EMCAL",44);
75 //_____________________________________________________________________________
76 AliEMCALTriggerSTURawStream::~AliEMCALTriggerSTURawStream()
81 //_____________________________________________________________________________
82 void AliEMCALTriggerSTURawStream::Reset()
85 if (fRawReader) fRawReader->Reset();
92 //_____________________________________________________________________________
93 Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
95 // STU data decoder from Olivier Bourrion LPSC CNRS-IN2P3
96 // bourrion@lpsc.in2p3.fr
98 UInt_t word32[1772]; // 32b words
99 for (Int_t i=0;i<1772;i++) word32[i] = 0;
107 Int_t eqId = -1, eqSize = 0;
110 while (fRawReader->ReadNextInt(w32))
114 eqId = fRawReader->GetEquipmentId();
115 eqSize = fRawReader->GetEquipmentSize();
118 word32[iword++] = w32;
121 if (iword != kPayLoadSize && iword != kPayLoadSizeWithRawData)
123 AliError(Form("ERROR: STU payload (eqId: %d, eqSize: %d) doesn't match expected size! %d word32",
124 eqId, eqSize, iword));
127 else if (AliDebugLevel())
129 AliInfo(Form("STU (eqId: %d, eqSize: %d) payload size: %d word32",
130 eqId, eqSize, iword));
133 fL1JetThreshold = ((word32[0]>>16) & 0xFFF);
134 fL1GammaThreshold = (word32[0] & 0xFFF);
136 for (Int_t jet_row=0; jet_row<11; jet_row++)
138 UInt_t currentrow = word32[1+jet_row];
140 for (Int_t jet_col=0; jet_col<15; jet_col++)
142 if (currentrow & (1 << jet_col))
146 fL1JetPatchIndex[fNL1JetPatch-1] = ((jet_row << 8) & 0xFF00) | (jet_col & 0xFF);
151 //////////////////////////////////////////////////////////
153 //////////////////////////////////////////////////////////
154 // FIXME: still not interpreted to be done with Jiri
156 unsigned short TRU_L0_indexes[32][6];
158 // extraction from stream
159 for (Int_t index=0;index<6;index++)
161 for (Int_t tru_num=0;tru_num<16;tru_num++)
163 TRU_L0_indexes[2*tru_num ][index] = ( word32[12+index*16+tru_num] & 0xFFFF);
164 TRU_L0_indexes[2*tru_num+1][index] = ((word32[12+index*16+tru_num]>>16) & 0xFFFF);
168 for (Int_t tru_num=0;tru_num<32;tru_num++)
170 for (Int_t index=0;index<6;index++)
172 for (Int_t bit_num=0;bit_num<12;bit_num++)
174 if ((TRU_L0_indexes[tru_num][index] & (1 << bit_num)))
176 Int_t idx = 12 * index + bit_num;
180 fL0GammaPatchIndex[fNL0GammaPatch-1] = (((idx << 5) & 0x7E0) | (tru_num & 0x1F));
186 //////////////////////////////////////////////////////////
187 // index des L1 gamma //
188 //////////////////////////////////////////////////////////
190 unsigned short TRU_L1_indexes[32][8];
192 // extraction from stream
193 for (Int_t index=0;index<8;index++)
195 for (Int_t tru_num=0;tru_num<16;tru_num++)
197 TRU_L1_indexes[2*tru_num ][index] = ( word32[108+index*16+tru_num] & 0xFFFF);
198 TRU_L1_indexes[2*tru_num+1][index] = ((word32[108+index*16+tru_num]>>16) & 0xFFFF);
206 for (Int_t tru_num=0;tru_num<32;tru_num++)
208 for (Int_t index=0;index<8;index++)
210 for (Int_t bit_num=0; bit_num<12; bit_num++)
212 if ((TRU_L1_indexes[tru_num][index] & (1<<bit_num)) != 0)
216 gammacolnum = (2*bit_num );
221 gammacolnum = (2*bit_num+1);
227 fL1GammaPatchIndex[fNL1GammaPatch-1] = (((indexcopy << 10) & 0xC00) | ((gammacolnum << 5) & 0x3E0) | (tru_num & 0x1F));
233 //////////////////////////////////////////////////////////
235 //////////////////////////////////////////////////////////
237 if ( iword <= kPayLoadSize )
245 // extraction from stream
246 for (Int_t index=0;index<96;index++)
248 for (Int_t tru_num=0;tru_num<16;tru_num++)
250 fADC[2*tru_num ][index] = ( word32[236+index*16+tru_num] & 0xFFFF);
251 fADC[2*tru_num+1][index] = ((word32[236+index*16+tru_num]>>16) & 0xFFFF);
255 for (Int_t tru_num=16;tru_num<32;tru_num++) // A side
258 for (Int_t index=0;index<96;index++) v[index] = fADC[tru_num][95-index];
260 for (Int_t index=0;index<96;index++) fADC[tru_num][index] = v[index];
266 //_____________________________________________________________________________
267 Bool_t AliEMCALTriggerSTURawStream::GetL0GammaPatch(const Int_t i, Int_t& tru, Int_t& idx) const
270 if (i > fNL0GammaPatch) return kFALSE;
272 tru = fL0GammaPatchIndex[i] & 0x1F;
273 idx = (fL0GammaPatchIndex[i] & 0x7E0) >> 5;
278 //_____________________________________________________________________________
279 Bool_t AliEMCALTriggerSTURawStream::GetL1GammaPatch(const Int_t i, Int_t& tru, Int_t& col, Int_t& row) const
282 if (i > fNL1GammaPatch) return kFALSE;
284 tru = fL1GammaPatchIndex[i] & 0x1F;
285 col = (fL1GammaPatchIndex[i] & 0x3E0) >> 5;
286 row = (fL1GammaPatchIndex[i] & 0xC00) >> 10;
291 //_____________________________________________________________________________
292 Bool_t AliEMCALTriggerSTURawStream::GetL1JetPatch(const Int_t i, Int_t& col, Int_t& row) const
295 if (i > fNL1JetPatch) return kFALSE;
297 col = fL1JetPatchIndex[i] & 0xFF;
298 row = (fL1JetPatchIndex[i] & 0xFF00) >> 8;
303 //_____________________________________________________________________________
304 void AliEMCALTriggerSTURawStream::GetADC(Int_t iTRU, UInt_t ADC[])
307 for (Int_t i=0; i<96; i++) ADC[i] = fADC[iTRU][i];
310 //_____________________________________________________________________________
311 void AliEMCALTriggerSTURawStream::DumpPayLoad(const Option_t *option) const
316 cout << "Jet Threshold: " << fL1JetThreshold << " Gamma threshold: " << fL1GammaThreshold << endl;
317 cout << "Number of L0: " << fNL0GammaPatch << endl;
318 cout << "Number of L1-g: " << fNL1GammaPatch << endl;
319 cout << "Number of L1-j: " << fNL1JetPatch << endl;
321 Int_t itru, col, row;
323 if (op.Contains("L0") || op.Contains("ALL"))
325 for (Int_t i=0;i<fNL0GammaPatch;i++)
328 if (GetL0GammaPatch(i,itru,col))
329 cout << "> Found L0 gamma in TRU #" << setw(2) << itru << " at idx: " << setw(2) << col << endl;
333 if (op.Contains("L1") || op.Contains("ALL"))
335 for (Int_t i=0;i<fNL1GammaPatch;i++)
337 if (GetL1GammaPatch(i,itru,col,row))
338 cout << "> Found L1 gamma in TRU #" << setw(2) << itru << " at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
341 for (Int_t i=0;i<fNL1JetPatch;i++)
343 if (GetL1JetPatch(i,col,row)) cout << "> Found L1 jet at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
347 cout << "> RawData: " << fGetRawData << endl;
349 if ( (op.Contains("ADC") || op.Contains("ALL")) && fGetRawData )
351 for (Int_t i=0;i<32;i++)
353 cout << "--------\n";
354 cout << "TRU #" << setw(2) << i << ":";
355 for (Int_t j=0;j<96;j++)
357 TBits xadc(12); xadc.Set(12,&fADC[i][j]);
358 if ((j%4)==0) cout << endl;
359 //cout << setw(2) << j << ": " << xadc << " ";
360 printf("%2d: %3x / ",j,fADC[i][j]);