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 kPayLoadSize = 944;
37 const Int_t kPayLoadSizeWithRawData = 1772;
40 ClassImp(AliEMCALTriggerSTURawStream)
42 //_____________________________________________________________________________
43 AliEMCALTriggerSTURawStream::AliEMCALTriggerSTURawStream() : TObject(),
58 //_____________________________________________________________________________
59 AliEMCALTriggerSTURawStream::AliEMCALTriggerSTURawStream(AliRawReader* rawReader) : TObject(),
60 fRawReader(rawReader),
73 fRawReader->Select("EMCAL",44);
76 //_____________________________________________________________________________
77 AliEMCALTriggerSTURawStream::~AliEMCALTriggerSTURawStream()
82 //_____________________________________________________________________________
83 void AliEMCALTriggerSTURawStream::Reset()
86 if (fRawReader) fRawReader->Reset();
93 //_____________________________________________________________________________
94 Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
96 // STU data decoder from Olivier Bourrion LPSC CNRS-IN2P3
97 // bourrion_at_lpsc_dot_in2p3_dot_fr
99 UInt_t word32[1772]; // 32b words
100 for (Int_t i=0;i<1772;i++) word32[i] = 0;
108 Int_t eqId = -1, eqSize = 0;
111 while (fRawReader->ReadNextInt(w32))
115 eqId = fRawReader->GetEquipmentId();
116 eqSize = fRawReader->GetEquipmentSize();
119 word32[iword++] = w32;
122 if (iword != kPayLoadSize && iword != kPayLoadSizeWithRawData)
124 AliError(Form("ERROR: STU payload (eqId: %d, eqSize: %d) doesn't match expected size! %d word32",
125 eqId, eqSize, iword));
128 else if (AliDebugLevel())
130 AliInfo(Form("STU (eqId: %d, eqSize: %d) payload size: %d word32",
131 eqId, eqSize, iword));
134 fL1JetThreshold = ((word32[0]>>16) & 0xFFF);
135 fL1GammaThreshold = (word32[0] & 0xFFF);
137 for (Int_t jet_row=0; jet_row<11; jet_row++)
139 UInt_t currentrow = word32[1+jet_row];
141 for (Int_t jet_col=0; jet_col<15; jet_col++)
143 if (currentrow & (1 << jet_col))
147 fL1JetPatchIndex[fNL1JetPatch-1] = ((jet_row << 8) & 0xFF00) | (jet_col & 0xFF);
152 //////////////////////////////////////////////////////////
154 //////////////////////////////////////////////////////////
155 // FIXME: still not interpreted to be done with Jiri
157 unsigned short TRU_L0_indexes[32][6];
159 // extraction from stream
160 for (Int_t index=0;index<6;index++)
162 for (Int_t tru_num=0;tru_num<16;tru_num++)
164 TRU_L0_indexes[2*tru_num ][index] = ( word32[12+index*16+tru_num] & 0xFFFF);
165 TRU_L0_indexes[2*tru_num+1][index] = ((word32[12+index*16+tru_num]>>16) & 0xFFFF);
169 for (Int_t tru_num=0;tru_num<32;tru_num++)
171 for (Int_t index=0;index<6;index++)
173 for (Int_t bit_num=0;bit_num<12;bit_num++)
175 if ((TRU_L0_indexes[tru_num][index] & (1 << bit_num)))
177 Int_t idx = 12 * index + bit_num;
181 fL0GammaPatchIndex[fNL0GammaPatch-1] = (((idx << 5) & 0x7E0) | (tru_num & 0x1F));
187 //////////////////////////////////////////////////////////
188 // index des L1 gamma //
189 //////////////////////////////////////////////////////////
191 unsigned short TRU_L1_indexes[32][8];
193 // extraction from stream
194 for (Int_t index=0;index<8;index++)
196 for (Int_t tru_num=0;tru_num<16;tru_num++)
198 TRU_L1_indexes[2*tru_num ][index] = ( word32[108+index*16+tru_num] & 0xFFFF);
199 TRU_L1_indexes[2*tru_num+1][index] = ((word32[108+index*16+tru_num]>>16) & 0xFFFF);
207 for (Int_t tru_num=0;tru_num<32;tru_num++)
209 for (Int_t index=0;index<8;index++)
211 for (Int_t bit_num=0; bit_num<12; bit_num++)
213 if ((TRU_L1_indexes[tru_num][index] & (1<<bit_num)) != 0)
217 gammacolnum = (2*bit_num );
222 gammacolnum = (2*bit_num+1);
228 fL1GammaPatchIndex[fNL1GammaPatch-1] = (((indexcopy << 10) & 0xC00) | ((gammacolnum << 5) & 0x3E0) | (tru_num & 0x1F));
234 //////////////////////////////////////////////////////////
236 //////////////////////////////////////////////////////////
238 if ( iword <= kPayLoadSize )
246 // extraction from stream
247 for (Int_t index=0;index<96;index++)
249 for (Int_t tru_num=0;tru_num<16;tru_num++)
251 fADC[2*tru_num ][index] = ( word32[236+index*16+tru_num] & 0xFFFF);
252 fADC[2*tru_num+1][index] = ((word32[236+index*16+tru_num]>>16) & 0xFFFF);
256 for (Int_t tru_num=16;tru_num<32;tru_num++) // A side
259 for (Int_t index=0;index<96;index++) v[index] = fADC[tru_num][95-index];
261 for (Int_t index=0;index<96;index++) fADC[tru_num][index] = v[index];
267 //_____________________________________________________________________________
268 Bool_t AliEMCALTriggerSTURawStream::GetL0GammaPatch(const Int_t i, Int_t& tru, Int_t& idx) const
271 if (i > fNL0GammaPatch) return kFALSE;
273 tru = fL0GammaPatchIndex[i] & 0x1F;
274 idx = (fL0GammaPatchIndex[i] & 0x7E0) >> 5;
279 //_____________________________________________________________________________
280 Bool_t AliEMCALTriggerSTURawStream::GetL1GammaPatch(const Int_t i, Int_t& tru, Int_t& col, Int_t& row) const
283 if (i > fNL1GammaPatch) return kFALSE;
285 tru = fL1GammaPatchIndex[i] & 0x1F;
286 col = (fL1GammaPatchIndex[i] & 0x3E0) >> 5;
287 row = (fL1GammaPatchIndex[i] & 0xC00) >> 10;
292 //_____________________________________________________________________________
293 Bool_t AliEMCALTriggerSTURawStream::GetL1JetPatch(const Int_t i, Int_t& col, Int_t& row) const
296 if (i > fNL1JetPatch) return kFALSE;
298 col = fL1JetPatchIndex[i] & 0xFF;
299 row = (fL1JetPatchIndex[i] & 0xFF00) >> 8;
304 //_____________________________________________________________________________
305 void AliEMCALTriggerSTURawStream::GetADC(Int_t iTRU, UInt_t ADC[])
308 for (Int_t i=0; i<96; i++) ADC[i] = fADC[iTRU][i];
311 //_____________________________________________________________________________
312 void AliEMCALTriggerSTURawStream::DumpPayLoad(const Option_t *option) const
317 cout << "Jet Threshold: " << fL1JetThreshold << " Gamma threshold: " << fL1GammaThreshold << endl;
318 cout << "Number of L0: " << fNL0GammaPatch << endl;
319 cout << "Number of L1-g: " << fNL1GammaPatch << endl;
320 cout << "Number of L1-j: " << fNL1JetPatch << endl;
322 Int_t itru, col, row;
324 if (op.Contains("L0") || op.Contains("ALL"))
326 for (Int_t i=0;i<fNL0GammaPatch;i++)
329 if (GetL0GammaPatch(i,itru,col))
330 cout << "> Found L0 gamma in TRU #" << setw(2) << itru << " at idx: " << setw(2) << col << endl;
334 if (op.Contains("L1") || op.Contains("ALL"))
336 for (Int_t i=0;i<fNL1GammaPatch;i++)
338 if (GetL1GammaPatch(i,itru,col,row))
339 cout << "> Found L1 gamma in TRU #" << setw(2) << itru << " at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
342 for (Int_t i=0;i<fNL1JetPatch;i++)
344 if (GetL1JetPatch(i,col,row)) cout << "> Found L1 jet at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
348 cout << "> RawData: " << fGetRawData << endl;
350 if ( (op.Contains("ADC") || op.Contains("ALL")) && fGetRawData )
352 for (Int_t i=0;i<32;i++)
354 cout << "--------\n";
355 cout << "TRU #" << setw(2) << i << ":";
356 for (Int_t j=0;j<96;j++)
358 TBits xadc(12); xadc.Set(12,&fADC[i][j]);
359 if ((j%4)==0) cout << endl;
360 //cout << setw(2) << j << ": " << xadc << " ";
361 printf("%2d: %3x / ",j,fADC[i][j]);