- // if (!fReader->ReadHeader()) {
- // AliError("Couldn't read header");
- // return kFALSE;
- // }
- // Get sample rate
- AliFMDParameters* pars = AliFMDParameters::Instance();
-
- // Select FMD DDL's
- fReader->Select("FMD");
-
- UShort_t stripMin = 0;
- UShort_t stripMax = 127;
- UShort_t preSamp = 0;
-
- do {
- UChar_t* cdata;
- if (!fReader->ReadNextData(cdata)) break;
- size_t nchar = fReader->GetDataSize();
- UShort_t ddl = fReader->GetDDLID();
- UShort_t rate = 0;
- AliFMDDebug(1, ("Reading %d bytes (%d 10bit words) from %d",
- nchar, nchar * 8 / 10, ddl));
- // Make a stream to read from
- std::string str((char*)(cdata), nchar);
- std::istringstream s(str);
- // Prep the reader class.
- AliFMDAltroReader r(s);
- // Data array is approx twice the size needed.
- UShort_t data[2048], hwaddr, last;
- while (r.ReadChannel(hwaddr, last, data) > 0) {
- AliFMDDebug(5, ("Read channel 0x%x of size %d", hwaddr, last));
- UShort_t det, sec, str;
- Char_t ring;
- if (!pars->Hardware2Detector(ddl, hwaddr, det, ring, sec, str)) {
- AliError(Form("Failed to detector id from DDL %d "
- "and hardware address 0x%x", ddl, hwaddr));
- continue;
- }
- rate = pars->GetSampleRate(det, ring, sec, str);
- stripMin = pars->GetMinStrip(det, ring, sec, str);
- stripMax = pars->GetMaxStrip(det, ring, sec, str);
- AliFMDDebug(5, ("DDL 0x%04x, address 0x%03x maps to FMD%d%c[%2d,%3d]",
- ddl, hwaddr, det, ring, sec, str));
-
- // Loop over the `timebins', and make the digits
- for (size_t i = 0; i < last; i++) {
- if (i < preSamp) continue;
- Int_t n = array->GetEntries();
- UShort_t curStr = str + stripMin + i / rate;
- if ((curStr-str) > stripMax) {
- AliError(Form("Current strip is %d but DB says max is %d",
- curStr, stripMax));
- }
- AliFMDDebug(5, ("making digit for FMD%d%c[%2d,%3d] from sample %4d",
- det, ring, sec, curStr, i));
- new ((*array)[n]) AliFMDDigit(det, ring, sec, curStr, data[i],
- (rate >= 2 ? data[i+1] : 0),
- (rate >= 3 ? data[i+2] : 0));
- if (rate >= 2) i++;
- if (rate >= 3) i++;