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"
33 const Int_t kPayLoadSize = 944;
36 ClassImp(AliEMCALTriggerSTURawStream)
38 //_____________________________________________________________________________
39 AliEMCALTriggerSTURawStream::AliEMCALTriggerSTURawStream() : TObject(),
43 fL0GammaPatchIndex(0x0),
44 fL1GammaPatchIndex(0x0),
45 fL1JetPatchIndex(0x0),
54 //_____________________________________________________________________________
55 AliEMCALTriggerSTURawStream::AliEMCALTriggerSTURawStream(AliRawReader* rawReader) : TObject(),
56 fRawReader(rawReader),
59 fL0GammaPatchIndex(0x0),
60 fL1GammaPatchIndex(0x0),
61 fL1JetPatchIndex(0x0),
69 fRawReader->Select("EMCAL",44);
72 //_____________________________________________________________________________
73 AliEMCALTriggerSTURawStream::~AliEMCALTriggerSTURawStream()
78 //_____________________________________________________________________________
79 void AliEMCALTriggerSTURawStream::Reset()
82 if (fRawReader) fRawReader->Reset();
85 //_____________________________________________________________________________
86 Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
88 // STU data decoder from Olivier Bourrion LPSC CNRS-IN2P3
89 // bourrion@lpsc.in2p3.fr
91 UInt_t word32[1772]; // 32b words
96 while (fRawReader->ReadNextInt(w32)) word32[iword++] = w32;
98 if (iword < kPayLoadSize)
100 AliError(Form("STU raw data size is too small: %d word32 only!", iword));
103 else if (iword > kPayLoadSize )
105 AliLog::Message(AliLog::kInfo, "TRU raw data in the STU payload enabled","EMCAL","AliEMCALTriggerSTURawStream","ReadPayLoad()","AliEMCALTriggerSTURawStream.cxx",104);
110 fL1JetThreshold = ((word32[0]>>16) & 0xFFF);
111 fL1GammaThreshold = (word32[0] & 0xFFF);
113 for (Int_t jet_row=0; jet_row<11; jet_row++)
115 UInt_t currentrow = word32[1+jet_row];
117 for (Int_t jet_col=0; jet_col<15; jet_col++)
119 if (currentrow & (1 << jet_col))
122 fL1JetPatchIndex = (UShort_t*)realloc(fL1JetPatchIndex, fNL1JetPatch * sizeof(UShort_t));
123 if (fL1JetPatchIndex == NULL) {AliError("Error (re)allocating L1 jet patch memory");}
125 fL1JetPatchIndex[fNL1JetPatch-1] = ((jet_row << 8) & 0xFF00) | (jet_col & 0xFF);
130 //////////////////////////////////////////////////////////
132 //////////////////////////////////////////////////////////
133 // FIXME: still not interpreted to be done with Jiri
135 unsigned short TRU_L0_indexes[32][6];
137 // extraction from stream
138 for (Int_t index=0;index<6;index++)
140 for (Int_t tru_num=0;tru_num<16;tru_num++)
142 TRU_L0_indexes[2*tru_num ][index] = ( word32[12+index*16+tru_num] & 0xFFFF);
143 TRU_L0_indexes[2*tru_num+1][index] = ((word32[12+index*16+tru_num]>>16) & 0xFFFF);
147 for (Int_t tru_num=0;tru_num<32;tru_num++)
149 for (Int_t index=0;index<6;index++)
151 for (Int_t bit_num=0;bit_num<12;bit_num++)
153 if ((TRU_L0_indexes[tru_num][index] & (1 << bit_num)))
157 Int_t idx = 12 * index + bit_num;
163 fL0GammaPatchIndex = (UShort_t*)realloc(fL0GammaPatchIndex, fNL0GammaPatch * sizeof(UShort_t));
165 if (fL0GammaPatchIndex == NULL) {AliError("Error (re)allocating L0 gamma patch memory");}
167 fL0GammaPatchIndex[fNL0GammaPatch-1] = (((row << 10) & 0xC00) | ((col << 5) & 0x3E0) | (tru_num & 0x1F));
173 //////////////////////////////////////////////////////////
174 // index des L1 gamma //
175 //////////////////////////////////////////////////////////
177 unsigned short TRU_L1_indexes[32][8];
179 // extraction from stream
180 for (Int_t index=0;index<8;index++)
182 for (Int_t tru_num=0;tru_num<16;tru_num++)
184 TRU_L1_indexes[2*tru_num ][index] = ( word32[108+index*16+tru_num] & 0xFFFF);
185 TRU_L1_indexes[2*tru_num+1][index] = ((word32[108+index*16+tru_num]>>16) & 0xFFFF);
193 for (Int_t tru_num=0;tru_num<32;tru_num++)
195 for (Int_t index=0;index<8;index++)
197 for (Int_t bit_num=0; bit_num<12; bit_num++)
199 if ((TRU_L1_indexes[tru_num][index] & (1<<bit_num)) != 0)
203 gammacolnum = (2*bit_num );
208 gammacolnum = (2*bit_num+1);
213 fL1GammaPatchIndex = (UShort_t*)realloc(fL1GammaPatchIndex, fNL1GammaPatch * sizeof(UShort_t));
215 if (fL1GammaPatchIndex == NULL) {AliError("Error (re)allocating L1 gamma patch memory");}
217 fL1GammaPatchIndex[fNL1GammaPatch-1] = (((indexcopy << 10) & 0xC00) | ((gammacolnum << 5) & 0x3E0) | (tru_num & 0x1F));
223 //////////////////////////////////////////////////////////
225 //////////////////////////////////////////////////////////
227 if ( iword <= kPayLoadSize ) return kFALSE;
229 // extraction from stream
230 for (Int_t index=0;index<96;index++)
232 for (Int_t tru_num=0;tru_num<16;tru_num++)
234 fADC[2*tru_num ][index] = ( word32[236+index*16+tru_num] & 0xFFFF);
235 fADC[2*tru_num+1][index] = ((word32[236+index*16+tru_num]>>16) & 0xFFFF);
239 for (Int_t tru_num=16;tru_num<32;tru_num++) // A side
241 for (Int_t index=0;index<96;index++)
243 fADC[tru_num][index] = fADC[tru_num][95-index];
250 //_____________________________________________________________________________
251 Bool_t AliEMCALTriggerSTURawStream::GetL0GammaPatch(const Int_t i, Int_t& tru, Int_t& col, Int_t& row) const
254 if (i > fNL0GammaPatch) return kFALSE;
256 tru = fL0GammaPatchIndex[i] & 0x1F;
257 col = (fL0GammaPatchIndex[i] & 0x3E0) >> 5;
258 row = (fL0GammaPatchIndex[i] & 0xC00) >> 10;
263 //_____________________________________________________________________________
264 Bool_t AliEMCALTriggerSTURawStream::GetL1GammaPatch(const Int_t i, Int_t& tru, Int_t& col, Int_t& row) const
267 if (i > fNL1GammaPatch) return kFALSE;
269 tru = fL1GammaPatchIndex[i] & 0x1F;
270 col = (fL1GammaPatchIndex[i] & 0x3E0) >> 5;
271 row = (fL1GammaPatchIndex[i] & 0xC00) >> 10;
276 //_____________________________________________________________________________
277 Bool_t AliEMCALTriggerSTURawStream::GetL1JetPatch(const Int_t i, Int_t& col, Int_t& row) const
280 if (i > fNL1JetPatch) return kFALSE;
282 col = fL1JetPatchIndex[i] & 0xFF;
283 row = (fL1JetPatchIndex[i] & 0xFF00) >> 8;
288 //_____________________________________________________________________________
289 void AliEMCALTriggerSTURawStream::GetADC(Int_t iTRU, UInt_t ADC[])
292 for (Int_t i=0; i<96; i++) ADC[i] = fADC[iTRU][i];
295 //_____________________________________________________________________________
296 void AliEMCALTriggerSTURawStream::Dump(const Option_t *option) const
301 cout << "Jet Threshold: " << fL1JetThreshold << " Gamma threshold: " << fL1GammaThreshold << endl;
303 Int_t itru, col, row;
307 if (op.Contains("L0") || op.Contains("ALL"))
309 for (Int_t i=0;i<fNL0GammaPatch;i++)
311 isOK = GetL0GammaPatch(i,itru,col,row);
312 if (isOK) cout << "> Found L0 gamma in TRU #" << setw(2) << itru
313 << " at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
317 if (op.Contains("L1") || op.Contains("ALL"))
319 for (Int_t i=0;i<fNL1GammaPatch;i++)
321 isOK = GetL1GammaPatch(i,itru,col,row);
322 if (isOK) cout << "> Found L1 gamma in TRU #" << setw(2) << itru
323 << " at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
326 for (Int_t i=0;i<fNL1JetPatch;i++)
328 isOK = GetL1JetPatch(i,col,row);
329 if (isOK) cout << "> Found L1 jet at: ( col: " << setw(2) << col << " , row: " << setw(2) << row << " )" << endl;
333 if (op.Contains("ADC") || op.Contains("ALL"))
335 for (Int_t i=0;i<32;i++)
337 cout << "--------\n";
338 cout << "TRU #" << setw(2) << i << ":";
339 for (Int_t j=0;j<96;j++)
341 TBits xadc(12); xadc.Set(12,&fADC[i][j]);
342 if ((j%4)==0) cout << endl;
343 //cout << setw(2) << j << ": " << xadc << " ";
344 printf("%2d: %3x / ",j,fADC[i][j]);