New version to recon the coming of the SOD event
[u/mrichter/AliRoot.git] / FMD / AliFMDRawReader.cxx
CommitLineData
e802be3e 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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 **************************************************************************/
e802be3e 15/* $Id$ */
c2fc1258 16/** @file AliFMDRawReader.cxx
17 @author Christian Holm Christensen <cholm@nbi.dk>
18 @date Mon Mar 27 12:45:23 2006
19 @brief Class to read raw data
02a27b50 20 @ingroup FMD_rec
c2fc1258 21*/
e802be3e 22//____________________________________________________________________
23//
24// Class to read ADC values from a AliRawReader object.
25//
7684b53c 26// This class uses the AliFMDRawStreamer class to read the ALTRO
27// formatted data.
28//
29// +-------+
30// | TTask |
31// +-------+
32// ^
33// |
34// +-----------------+ <<references>> +--------------+
35// | AliFMDRawReader |<>----------------| AliRawReader |
36// +-----------------+ +--------------+
37// | ^
38// | <<uses>> |
39// V |
40// +-----------------+ <<uses>> |
41// | AliFMDRawStream |------------------------+
42// +-----------------+
43// |
44// V
45// +----------------+
46// | AliAltroStream |
47// +----------------+
48//
f95a63c4 49// #include <AliLog.h> // ALILOG_H
50#include "AliFMDDebug.h" // Better debug macros
1a1fdef7 51#include "AliFMDParameters.h" // ALIFMDPARAMETERS_H
e802be3e 52#include "AliFMDDigit.h" // ALIFMDDIGIT_H
53#include "AliFMDRawStream.h" // ALIFMDRAWSTREAM_H
3effc6e7 54#include "AliRawReader.h" // ALIRAWREADER_H
e802be3e 55#include "AliFMDRawReader.h" // ALIFMDRAWREADER_H
3effc6e7 56#include "AliFMDDebug.h"
57#include "AliFMDCalibSampleRate.h"
58#include "AliFMDCalibStripRange.h"
c2fc1258 59// #include "AliFMDAltroIO.h" // ALIFMDALTROIO_H
3effc6e7 60#include <TArrayS.h> // ROOT_TArrayS
1a1fdef7 61#include <TTree.h> // ROOT_TTree
62#include <TClonesArray.h> // ROOT_TClonesArray
3effc6e7 63#include <TString.h>
02a27b50 64// #include <iostream>
65// #include <iomanip>
e802be3e 66
67//____________________________________________________________________
925e6570 68ClassImp(AliFMDRawReader)
1a1fdef7 69#if 0
70 ; // This is here to keep Emacs for indenting the next line
71#endif
e802be3e 72
73//____________________________________________________________________
1a1fdef7 74AliFMDRawReader::AliFMDRawReader(AliRawReader* reader, TTree* tree)
e802be3e 75 : TTask("FMDRawReader", "Reader of Raw ADC values from the FMD"),
1a1fdef7 76 fTree(tree),
77 fReader(reader),
3effc6e7 78 fSampleRate(1),
79 fData(0),
80 fNbytes(0)
e802be3e 81{
56b1929b 82 // Default CTOR
e802be3e 83}
84
e802be3e 85//____________________________________________________________________
c2fc1258 86void
87AliFMDRawReader::Exec(Option_t*)
88{
02a27b50 89 // Read the data
c2fc1258 90 TClonesArray* array = new TClonesArray("AliFMDDigit");
91 if (!fTree) {
92 AliError("No tree");
93 return;
94 }
95 fTree->Branch("FMD", &array);
3effc6e7 96
97
c2fc1258 98 ReadAdcs(array);
99 Int_t nWrite = fTree->Fill();
f95a63c4 100 AliFMDDebug(1, ("Got a grand total of %d digits, wrote %d bytes to tree",
bf37515f 101 array->GetEntriesFast(), nWrite));
c2fc1258 102}
103
104
105#if 1
106//____________________________________________________________________
107Bool_t
108AliFMDRawReader::ReadAdcs(TClonesArray* array)
109{
3effc6e7 110
c2fc1258 111 // Read raw data into the digits array, using AliFMDAltroReader.
112 if (!array) {
113 AliError("No TClonesArray passed");
114 return kFALSE;
115 }
d56f2b53 116 // if (!fReader->ReadHeader()) {
117 // AliError("Couldn't read header");
118 // return kFALSE;
119 // }
c2fc1258 120 // Get sample rate
121 AliFMDParameters* pars = AliFMDParameters::Instance();
122 AliFMDRawStream input(fReader);
9a090ccd 123 AliFMDDebug(5, ("Setting 7 word headers"));
625d7886 124 input.SetShortDataHeader(!pars->HasCompleteHeader());
c2fc1258 125
126 UShort_t stripMin = 0;
127 UShort_t stripMax = 127;
625d7886 128 UShort_t preSamp = 14+5;
c2fc1258 129
130 UInt_t ddl = 0;
131 UInt_t rate = 0;
132 UInt_t last = 0;
133 UInt_t hwaddr = 0;
134 // Data array is approx twice the size needed.
135 UShort_t data[2048];
2b893216 136
625d7886 137 Bool_t isGood = kTRUE;
138 while (isGood) {
139 isGood = input.ReadChannel(ddl, hwaddr, last, data);
7b4569a9 140 if (!isGood) break;
2b893216 141
f95a63c4 142 AliFMDDebug(5, ("Read channel 0x%x of size %d", hwaddr, last));
c2fc1258 143 UShort_t det, sec, str;
144 Char_t ring;
145 if (!pars->Hardware2Detector(ddl, hwaddr, det, ring, sec, str)) {
146 AliError(Form("Failed to get detector id from DDL %d "
147 "and hardware address 0x%x", ddl, hwaddr));
148 continue;
149 }
150 rate = pars->GetSampleRate(det, ring, sec, str);
151 stripMin = pars->GetMinStrip(det, ring, sec, str);
152 stripMax = pars->GetMaxStrip(det, ring, sec, str);
625d7886 153 preSamp = pars->GetPreSamples(det, ring, sec, str);
f95a63c4 154 AliFMDDebug(5, ("DDL 0x%04x, address 0x%03x maps to FMD%d%c[%2d,%3d]",
c2fc1258 155 ddl, hwaddr, det, ring, sec, str));
156
157 // Loop over the `timebins', and make the digits
158 for (size_t i = 0; i < last; i++) {
159 if (i < preSamp) continue;
b29d3b0b 160 Int_t n = array->GetEntriesFast();
625d7886 161 Short_t curStr = str + stripMin + (i-preSamp) / rate;
c2fc1258 162 if ((curStr-str) > stripMax) {
625d7886 163 // AliInfo(Form("timebin %4d -> (%3d+%3d+(%4d-%d)/%d) -> %d",
164 // i, str, stripMin, i, preSamp, rate, curStr));
165 // AliError(Form("Current strip is %3d (0x%04x,0x%03x,%4d) "
166 // "but DB says max is %3d (rate=%d)",
167 // curStr, ddl, hwaddr, i, str+stripMax, rate));
168 // Garbage timebins - ignore
169 continue;
c2fc1258 170 }
f95a63c4 171 AliFMDDebug(5, ("making digit for FMD%d%c[%2d,%3d] from sample %4d",
c2fc1258 172 det, ring, sec, curStr, i));
173 new ((*array)[n]) AliFMDDigit(det, ring, sec, curStr, data[i],
174 (rate >= 2 ? data[i+1] : 0),
2aeec17d 175 (rate >= 3 ? data[i+2] : 0),
176 (rate >= 4 ? data[i+3] : 0));
c2fc1258 177 if (rate >= 2) i++;
178 if (rate >= 3) i++;
2aeec17d 179 if (rate >= 4) i++;
c2fc1258 180 }
181 }
182 return kTRUE;
183}
184#else
185//____________________________________________________________________
d760ea03 186Bool_t
187AliFMDRawReader::ReadAdcs(TClonesArray* array)
e802be3e 188{
1e8f773e 189 // Read raw data into the digits array, using AliFMDAltroReader.
d760ea03 190 if (!array) {
191 AliError("No TClonesArray passed");
192 return kFALSE;
193 }
d56f2b53 194 // if (!fReader->ReadHeader()) {
195 // AliError("Couldn't read header");
196 // return kFALSE;
197 // }
1e8f773e 198 // Get sample rate
199 AliFMDParameters* pars = AliFMDParameters::Instance();
200
201 // Select FMD DDL's
362c9d61 202 fReader->Select("FMD");
1e8f773e 203
204 UShort_t stripMin = 0;
205 UShort_t stripMax = 127;
206 UShort_t preSamp = 0;
207
208 do {
209 UChar_t* cdata;
210 if (!fReader->ReadNextData(cdata)) break;
211 size_t nchar = fReader->GetDataSize();
362c9d61 212 UShort_t ddl = fReader->GetDDLID();
c2fc1258 213 UShort_t rate = 0;
f95a63c4 214 AliFMDDebug(1, ("Reading %d bytes (%d 10bit words) from %d",
1e8f773e 215 nchar, nchar * 8 / 10, ddl));
216 // Make a stream to read from
217 std::string str((char*)(cdata), nchar);
218 std::istringstream s(str);
219 // Prep the reader class.
220 AliFMDAltroReader r(s);
221 // Data array is approx twice the size needed.
222 UShort_t data[2048], hwaddr, last;
223 while (r.ReadChannel(hwaddr, last, data) > 0) {
f95a63c4 224 AliFMDDebug(5, ("Read channel 0x%x of size %d", hwaddr, last));
1e8f773e 225 UShort_t det, sec, str;
226 Char_t ring;
227 if (!pars->Hardware2Detector(ddl, hwaddr, det, ring, sec, str)) {
228 AliError(Form("Failed to detector id from DDL %d "
229 "and hardware address 0x%x", ddl, hwaddr));
230 continue;
231 }
c2fc1258 232 rate = pars->GetSampleRate(det, ring, sec, str);
233 stripMin = pars->GetMinStrip(det, ring, sec, str);
234 stripMax = pars->GetMaxStrip(det, ring, sec, str);
f95a63c4 235 AliFMDDebug(5, ("DDL 0x%04x, address 0x%03x maps to FMD%d%c[%2d,%3d]",
1e8f773e 236 ddl, hwaddr, det, ring, sec, str));
237
238 // Loop over the `timebins', and make the digits
239 for (size_t i = 0; i < last; i++) {
240 if (i < preSamp) continue;
d760ea03 241 Int_t n = array->GetEntries();
1e8f773e 242 UShort_t curStr = str + stripMin + i / rate;
243 if ((curStr-str) > stripMax) {
244 AliError(Form("Current strip is %d but DB says max is %d",
245 curStr, stripMax));
246 }
f95a63c4 247 AliFMDDebug(5, ("making digit for FMD%d%c[%2d,%3d] from sample %4d",
1e8f773e 248 det, ring, sec, curStr, i));
249 new ((*array)[n]) AliFMDDigit(det, ring, sec, curStr, data[i],
250 (rate >= 2 ? data[i+1] : 0),
251 (rate >= 3 ? data[i+2] : 0));
252 if (rate >= 2) i++;
253 if (rate >= 3) i++;
254 }
255 if (r.IsBof()) break;
256 }
257 } while (true);
d760ea03 258 return kTRUE;
259}
260
261
262
1e8f773e 263// This is the old method, for comparison. It's really ugly, and far
264// too convoluted.
265//____________________________________________________________________
266void
267AliFMDRawReader::Exec(Option_t*)
268{
56b1929b 269 // Read raw data into the digits array
d56f2b53 270 // if (!fReader->ReadHeader()) {
271 // Error("ReadAdcs", "Couldn't read header");
272 // return;
273 // }
e802be3e 274
1a1fdef7 275 Int_t n = 0;
276 TClonesArray* array = new TClonesArray("AliFMDDigit");
277 fTree->Branch("FMD", &array);
278
8f6ee336 279 // Get sample rate
280 AliFMDParameters* pars = AliFMDParameters::Instance();
362c9d61 281 fSampleRate = pars->GetSampleRate(0);
8f6ee336 282
e802be3e 283 // Use AliAltroRawStream to read the ALTRO format. No need to
284 // reinvent the wheel :-)
285 AliFMDRawStream input(fReader, fSampleRate);
286 // Select FMD DDL's
362c9d61 287 fReader->Select("FMD");
e802be3e 288
289 Int_t oldDDL = -1;
290 Int_t count = 0;
291 UShort_t detector = 1; // Must be one here
292 UShort_t oldDetector = 0;
293 Bool_t next = kTRUE;
294
295 // local Cache
296 TArrayI counts(10);
297 counts.Reset(-1);
298
299 // Loop over data in file
300 while (next) {
301 next = input.Next();
302
303 count++;
304 Int_t ddl = fReader->GetDDLID();
f95a63c4 305 AliFMDDebug(10, ("Current DDL is %d", ddl));
e802be3e 306 if (ddl != oldDDL || input.IsNewStrip() || !next) {
307 // Make a new digit, if we have some data (oldDetector == 0,
308 // means that we haven't really read anything yet - that is,
309 // it's the first time we get here).
310 if (oldDetector > 0) {
311 // Got a new strip.
f95a63c4 312 AliFMDDebug(10, ("Add a new strip: FMD%d%c[%2d,%3d] "
e802be3e 313 "(current: FMD%d%c[%2d,%3d])",
314 oldDetector, input.PrevRing(),
315 input.PrevSector() , input.PrevStrip(),
316 detector , input.Ring(), input.Sector(),
317 input.Strip()));
1a1fdef7 318 new ((*array)[n]) AliFMDDigit(oldDetector,
319 input.PrevRing(),
320 input.PrevSector(),
321 input.PrevStrip(),
322 counts[0], counts[1], counts[2]);
323 n++;
e802be3e 324#if 0
325 AliFMDDigit* digit =
326 static_cast<AliFMDDigit*>(fFMD->Digits()->
327 UncheckedAt(fFMD->GetNdigits()-1));
328#endif
329 }
330
331 if (!next) {
f95a63c4 332 AliFMDDebug(10, ("Read %d channels for FMD%d",
e802be3e 333 count + 1, detector));
334 break;
335 }
336
337
338 // If we got a new DDL, it means we have a new detector.
339 if (ddl != oldDDL) {
340 if (detector != 0)
f95a63c4 341 AliFMDDebug(10, ("Read %d channels for FMD%d", count + 1, detector));
e802be3e 342 // Reset counts, and update the DDL cache
343 count = 0;
344 oldDDL = ddl;
345 // Check that we're processing a FMD detector
346 Int_t detId = fReader->GetDetectorID();
362c9d61 347 if (detId != (AliDAQ::DetectorID("FMD"))) {
1e8f773e 348 AliError(Form("Detector ID %d != %d",
362c9d61 349 detId, (AliDAQ::DetectorID("FMD"))));
e802be3e 350 break;
351 }
352 // Figure out what detector we're deling with
353 oldDetector = detector;
354 switch (ddl) {
355 case 0: detector = 1; break;
356 case 1: detector = 2; break;
357 case 2: detector = 3; break;
358 default:
1e8f773e 359 AliError(Form("Unknown DDL 0x%x for FMD", ddl));
e802be3e 360 return;
361 }
f95a63c4 362 AliFMDDebug(10, ("Reading ADCs for 0x%x - That is FMD%d",
e802be3e 363 fReader->GetEquipmentId(), detector));
364 }
365 counts.Reset(-1);
366 }
367
368 counts[input.Sample()] = input.Count();
369
f95a63c4 370 AliFMDDebug(10, ("ADC of FMD%d%c[%2d,%3d] += %d",
e802be3e 371 detector, input.Ring(), input.Sector(),
372 input.Strip(), input.Count()));
373 oldDetector = detector;
374 }
1a1fdef7 375 fTree->Fill();
e802be3e 376 return;
377
378}
1e8f773e 379#endif
3effc6e7 380//____________________________________________________________________
381Bool_t AliFMDRawReader::ReadSODevent(AliFMDCalibSampleRate* sampleRate,
382 AliFMDCalibStripRange* stripRange,
383 TArrayS &pulseSize,
384 TArrayS &pulseLength) {
385
386 AliFMDDebug(0, ("Start of SOD/EOD"));
387
388 UInt_t shift_clk[18];
389 UInt_t sample_clk[18];
390 UInt_t strip_low[18];
391 UInt_t strip_high[18];
392 UInt_t pulse_size[18];
393 UInt_t pulse_length[18];
394
395 while(fReader->ReadNextData(fData)) {
396
397 Int_t ddl = fReader->GetDDLID();
398 Int_t detID = fReader->GetDetectorID();
399 AliFMDDebug(0, (" From reader: DDL number is %d , det ID is %d",ddl,detID));
400
401 fNbytes = fReader->GetDataSize();
402
403 ULong_t nWords = GetNwords();
404 UInt_t trailerLast = Get32bitWord(nWords);
405 AliFMDDebug(20, (" # Bytes: %d, # Words: %d, Last word: 0x%08x",
406 fNbytes, nWords, trailerLast));
407 if ((trailerLast & 0xFFFF0000) != 0xAAAA0000) {
408 AliWarning(Form("Last word 0x%08x does not match RCU II trailer",
409 trailerLast));
410 return kFALSE;
411 }
412
413 ULong_t nTrailerWords = trailerLast & 0x7f; // 7 last bits is size of trailer
414
415 ULong_t nPayloadWords = Get32bitWord(nWords - nTrailerWords+1);
416 AliFMDDebug(20, (" # trailer words: %d, # payload words: %d",
417 nTrailerWords, nPayloadWords));
418
419
420 for (ULong_t i = 1; i <= nPayloadWords ; i++) {
421 UInt_t payloadWord = Get32bitWord(i);
422 // if(!((i-CDH_length-1)%2)) {
423 // address is only 24 bit
424 UInt_t address = (0xffffff & payloadWord);
425 UInt_t type = ((address >> 21) & 0xf);
426 UInt_t error = ((address >> 20) & 0x1);
427 UInt_t bcast = ((address >> 18) & 0x1);
428 UInt_t bc_not_altro = ((address >> 17) & 0x1);
429 UInt_t board = ((address >> 12) & 0x1f);
430 UInt_t instruction = 0;
431 UInt_t chip = 0;
432 UInt_t channel = 0;
433 if(bc_not_altro)
434 instruction = address & 0xfff;
435 else {
436 chip = ((address >> 9) & 0x7);
437 channel = ((address >> 5) & 0x5);
438 instruction = (address & 0x1f);
439 }
440 if(error)
441 {
442 AliWarning(Form("error bit detected at Word 0x%06x; error % d, type %d, bc_not_altro %d, bcast %d, board 0x%02x, chip 0x%x, channel 0x%02x, instruction 0x%03x",address, error, type, bc_not_altro, bcast,board,chip,channel,instruction));
443 i++;
444 UInt_t errorWord = Get32bitWord(i);
445 //process error
446 continue;
447 }
448 Bool_t readDataWord = kFALSE;
449 switch(type) {
450 case 0x00: i++; readDataWord = kTRUE; break; //FEC_RD
451 case 0x01: i++; readDataWord = kFALSE; break; //FEC_CMD
452 case 0x10: i++; readDataWord = kFALSE; break; //FEC_WR
453 case 0x11: readDataWord = kFALSE; break; //IS: LOOP, WAIT, ENDSEQ, ENDMEM
454 default: i++; readDataWord = kFALSE; break;
455 }
456
457 if(!readDataWord) //Don't read unless we have a FEC_RD
458 continue;
459 UInt_t dataWord = Get32bitWord(i);
460 UInt_t data = (0xFFFFFF & dataWord) ;
461 //UInt_t data = (0xFFFF & dataWord) ;
462
463
464
465 switch(instruction) {
466
467 case 0x01: break; // First ADC T
468 case 0x02: break; // I 3.3 V
469 case 0x03: break; // I 2.5 V altro digital
470 case 0x04: break; // I 2.5 V altro analog
471 case 0x05: break; // I 2.5 V VA
472 case 0x06: break; // First ADC T
473 case 0x07: break; // I 3.3 V
474 case 0x08: break; // I 2.5 V altro digital
475 case 0x09: break; // I 2.5 V altro analog
476 case 0x0A: break; // I 2.5 V VA
477 case 0x2D: break; // Second ADC T
478 case 0x2E: break; // I 1.5 V VA
479 case 0x2F: break; // I -2.0 V
480 case 0x30: break; // I -2.0 V VA
481 case 0x31: break; // 2.5 V Digital driver
482 case 0x32: break; // Second ADC T
483 case 0x33: break; // I 1.5 V VA
484 case 0x34: break; // I -2.0 V
485 case 0x35: break; // I -2.0 V VA
486 case 0x36: break; // 2.5 V Digital driver
487 case 0x37: break; // Third ADC T
488 case 0x38: break; // Temperature sens. 1
489 case 0x39: break; // Temperature sens. 2
490 case 0x3A: break; // U 2.5 altro digital (m)
491 case 0x3B: break; // U 2.5 altro analog (m)
492 case 0x3C: break; // Third ADC T
493 case 0x3D: break; // Temperature sens. 1
494 case 0x3E: break; // Temperature sens. 2
495 case 0x3F: break; // U 2.5 altro digital (m)
496 case 0x40: break; // U 2.5 altro analog (m)
497 case 0x41: break; // Forth ADC T
498 case 0x42: break; // U 2.5 VA (m)
499 case 0x43: break; // U 1.5 VA (m)
500 case 0x44: break; // U -2.0 VA (m)
501 case 0x45: break; // U -2.0 (m)
502 case 0x46: break; // Forth ADC T
503 case 0x47: break; // U 2.5 VA (m)
504 case 0x48: break; // U 1.5 VA (m)
505 case 0x49: break; // U -2.0 VA (m)
506 case 0x4A: break; // U -2.0 (m)
507 // Counters
508 case 0x0B: break; // L1 trigger CouNTer
509 case 0x0C: break; // L2 trigger CouNTer
510 case 0x0D: break; // Sampling CLK CouNTer
511 case 0x0E: break; // DSTB CouNTer
512 // Test mode
513 case 0x0F: break; // Test mode word
514 case 0x10: break; // Undersampling ratio.
515 // Configuration and status
516 case 0x11: break; // Config/Status Register 0
517 case 0x12: break; // Config/Status Register 1
518 case 0x13: break; // Config/Status Register 2
519 case 0x14: break; // Config/Status Register 3
520 case 0x15: break; // Free
521 // Comands:
522 case 0x16: break; // Latch L1, L2, SCLK Counters
523 case 0x17: break; // Clear counters
524 case 0x18: break; // Clear CSR1
525 case 0x19: break; // rstb ALTROs
526 case 0x1A: break; // rstb BC
527 case 0x1B: break; // Start conversion
528 case 0x1C: break; // Scan event length
529 case 0x1D: break; // Read event length
530 case 0x1E: break; // Start test mode
531 case 0x1F: break; // Read acquisition memory
532 // FMD
533 case 0x20: break; // FMDD status
534 case 0x21: break; // L0 counters
535 case 0x22: break; // FMD: Wait to hold
536 case 0x23: break; // FMD: L1 timeout
537 case 0x24: break; // FMD: L2 timeout
538 case 0x25: // FMD: Shift clk
539 shift_clk[board] = ((data >> 8 ) & 0xFF);
540 break;
541 case 0x26: // FMD: Strips
542 strip_low[board] = ((data >> 0 ) & 0xFF);
543 strip_high[board] = ((data >> 8 ) & 0xFF);
544 break;
545 case 0x27: // FMD: Cal pulse
546 pulse_size[board] = ((data >> 8 ) & 0xFF);
547 break;
548 case 0x28: break; // FMD: Shape bias
549 case 0x29: break; // FMD: Shape ref
550 case 0x2A: break; // FMD: Preamp ref
551 case 0x2B: // FMD: Sample clk
552 sample_clk[board] = ((data >> 8 ) & 0xFF);
553 break;
554 case 0x2C: break; // FMD: Commands
555 case 0x4B: // FMD: Cal events
556 pulse_length[board] = ((data >> 8 ) & 0xFF);
557 break;
558 default: break;
559
560 }
561
562 }
563
564 UShort_t det,sector,strip;
565 Char_t ring;
566 UInt_t samplerate=1;
567 const UInt_t boards[4] = {0,1,16,17};
568 for(Int_t i=0;i<4;i++) {
569
570 UInt_t chip =0, channel=0;
571
572 AliFMDParameters::Instance()->Hardware2Detector(ddl,boards[i],chip,channel,det,ring,sector,strip);
573
574 if(sample_clk[boards[i]])
575 samplerate = shift_clk[boards[i]]/sample_clk[boards[i]];
576 sampleRate->Set(det,ring,sector,0,samplerate);
577 stripRange->Set(det,ring,sector,0,strip_low[boards[i]],strip_high[boards[i]]);
578 pulseSize.AddAt(pulse_size[boards[i]],GetHalfringIndex(det,ring,boards[i]%16));
579 pulseLength.AddAt(pulse_length[boards[i]],GetHalfringIndex(det,ring,boards[i]%16));
580
581 AliFMDDebug(20, ("board %d, strip_low %d, strip_high %d",boards[i],strip_low[i],strip_high[i]));
582 AliFMDDebug(20, ("board %d, shift_clk %d, sample_clk %d",boards[i],shift_clk[i],sample_clk[i]));
583
584 }
585
586 }
587
588 AliFMDParameters::Instance()->SetSampleRate(sampleRate);
589 AliFMDParameters::Instance()->SetStripRange(stripRange);
590
591 AliFMDDebug(0, ("End of SOD/EOD"));
592
593
594}
595//____________________________________________________________________
596
597UInt_t AliFMDRawReader::Get32bitWord(Int_t idx)
598{
599 // This method returns the 32 bit word at a given
600 // position inside the raw data payload.
601 // The 'index' points to the beginning of the next word.
602 // The method is supposed to be endian (platform)
603 // independent.
604 if (!fData) {
605 AliFatal("Raw data paylod buffer is not yet initialized !");
606 }
607
608 Int_t index = 4*idx;
609
610 if (index < 4) {
611 // fRawReader->AddFatalErrorLog(k32bitWordReadErr,Form("pos = %d",index));
612 // PrintDebug();
613 AliWarning(Form("Invalid raw data payload position (%d) !",index));
614 }
615
616 UInt_t word = 0;
617 //word = fData[--index] << 24;
618 // word |= fData[--index] << 16;
619 // word |= fData[--index] << 8;
620 //word |= fData[--index];
621
622 word = fData[--index] << 24;
623 word |= fData[--index] << 16;
624 word |= fData[--index] << 8;
625 word |= fData[--index] << 0 ;
e802be3e 626
3effc6e7 627 return word;
628}
629//_____________________________________________________________________
630Int_t AliFMDRawReader::GetHalfringIndex(UShort_t det, Char_t ring, UShort_t board) {
631
632 UShort_t iring = (ring == 'I' ? 1 : 0);
633
634 Int_t index = (((det-1) << 2) | (iring << 1) | (board << 0));
635
636 return index;
637
638}
e802be3e 639//____________________________________________________________________
640//
641// EOF
642//