Int_t nWrite = fTree->Fill();
AliFMDDebug(1, ("Got a grand total of %d digits, wrote %d bytes to tree",
array->GetEntriesFast(), nWrite));
+ delete array;
}
//____________________________________________________________________
UInt_t ddl = input.GetDDLNumber();
AliFMDDebug(2, ("DDL number %d", ddl));
- // Get zero suppression flag
- fZeroSuppress[ddl] = input.GetZeroSupp();
+ /* Note, previously, the ALTROCFG1 register was interpreted as
+ *
+ * Bits Value Description
+ * 0- 3 0/1 1st Baseline filter, mode
+ * 4- 5 Over-1 2nd baseline filter, # of pre-samples
+ * 6- 9 factor 2nd baseline filter, # of post-samples
+ * 10- 0 2nd baseline filter, enable
+ * 11-12 00 Zero suppression, glitch filter mode
+ * 13-15 001 Zero suppression, # of post samples
+ * 16-17 01 Zero suppression, # of pre samples
+ * 18 0/1 Zero suppression, enable
+ *
+ * The interpretation used in AliAltroRawStreamerV3 - which
+ * corresponds directly to ALTRO DPCFG register - is
+ *
+ * Bits Value Description
+ * 0- 3 0/1 1st Baseline filter, mode
+ * 4 0 Polarity (if '1', then "1's inverse")
+ * 5- 6 01 Zero suppression, # of pre samples
+ * 7-10 0001 Zero suppression, # of post samples
+ * 11 0 2nd baseline filter, enable
+ * 12-13 00 Zero suppression, glitch filter mode
+ * 14-16 factor 2nd baseline filter, # of post-samples
+ * 17-18 01 2nd baseline filter, # of pre-samples
+ * 19 0/1 Zero suppression, enable
+ *
+ * Writing 'x' for variable values, that means we have the
+ * following patterns for the 2 cases
+ *
+ * bit # 20 16 12 8 4 0
+ * old |0x01|0010|00xx|xxxx|xxxx|
+ * new |x01x|xx00|0000|1010|xxxx|
+ *
+ * That means that we can check if bits 10-13 are '1000' or
+ * '0000', which will tell us if the value was written with the
+ * new or the old interpretation. That is, we can check that
+ *
+ * if (((altrocfg1 >> 10) & 0x8) == 0x8) {
+ * // old interpretation
+ * }
+ * else {
+ * // New interpretation
+ * }
+ *
+ * That means, that we should never
+ *
+ * - change the # of zero suppression post samples
+ * - Turn on 2nd baseline correction
+ * - Change the zero-suppression glitch filter mode
+ *
+ * This change as introduced in version 1.2 of Rcu++
+ */
+ UInt_t cfg1 = input.GetAltroCFG1();
+ if (((cfg1 >> 10) & 0x8) == 0x8) {
+ UInt_t cfg2 = input.GetAltroCFG2();
+ AliFMDDebug(3, ("We have data from older MiniConf 0x%x cfg2=0x%08x",
+ ((cfg1 >> 10) & 0x8), cfg2));
+ fZeroSuppress[ddl] = (cfg1 >> 0) & 0x1;
+ fNoiseFactor[ddl] = (cfg1 >> 6) & 0xF;
+ fSampleRate[ddl] = (cfg2 >> 20) & 0xF;
+ }
+ else {
+ AliFMDDebug(3, ("We have data from newer MiniConf 0x%x",
+ ((cfg1 >> 10) & 0x8)));
+ fZeroSuppress[ddl] = input.GetZeroSupp();
+ // WARNING: We store the noise factor in the 2nd baseline
+ // filters excluded post samples, since we'll never use that
+ // mode.
+ fNoiseFactor[ddl] = input.GetNPostsamples();
+ // WARNING: We store the sample rate in the number of pre-trigger
+ // samples, since we'll never use that mode.
+ fSampleRate[ddl] = input.GetNPretriggerSamples();
+ }
AliFMDDebug(3, ("RCU @ DDL %d zero suppression: %s",
ddl, (fZeroSuppress[ddl] ? "yes" : "no")));
-
- // WARNING: We store the noise factor in the 2nd baseline
- // filters excluded post samples, since we'll never use that
- // mode.
- fNoiseFactor[ddl] = input.GetNPostsamples();
- AliFMDDebug(3, ("RCU @ DDL %d noise factor: %d", ddl,fNoiseFactor[ddl]));
-
- // WARNING: We store the sample rate in the number of pre-trigger
- // samples, since we'll never use that mode.
- fSampleRate[ddl] = input.GetNPretriggerSamples();
+ AliFMDDebug(3, ("RCU @ DDL %d noise factor: %d", ddl,fNoiseFactor[ddl]));
AliFMDDebug(3, ("RCU @ DDL %d sample rate: %d", ddl,fSampleRate[ddl]));
+
// Get Errors seen
Int_t nChAddrMismatch = input.GetNChAddrMismatch();
Int_t nChLenMismatch = input.GetNChLengthMismatch();
"hardware address 0x%03x", ddl, hwaddr));
return -1;
}
- AliFMDDebug(3, ("Board: 0x%02x, Altro: 0x%x, Channel: 0x%x",
+ AliFMDDebug(4, ("Board: 0x%02x, Altro: 0x%x, Channel: 0x%x",
board, chip, channel));
// Get the 'conditions'
map->Timebin2Strip(sec, t, fPreSamp, fSampleRate[ddl], stroff, samp);
str = strbase + stroff;
- AliFMDDebug(20, ("0x%04x/0x%03x/%04d maps to strip %3d sample %d "
+ AliFMDDebug(20, ("0x%04x/0x%03x/%04d=%4d maps to strip %3d sample %d "
"(pre: %d, min: %d, max: %d, rate: %d)",
- ddl, hwa, t, str, samp, fPreSamp,
+ ddl, hwa, t, adc, str, samp, fPreSamp,
fMinStrip, fMaxStrip, fSampleRate[ddl]));
if (str < 0) {
AliFMDDebug(10, ("Got presamples at timebin %d", i));
AliFMDDebug(15, ("Checking if strip %d (%d) in range [%d,%d]",
lstrip, str, fMinStrip, fMaxStrip));
if (lstrip < fMinStrip || lstrip > fMaxStrip) {
- AliFMDDebug(20, ("Strip %03d-%d (%d,%d) from t=%d out of range (%3d->%3d)",
+ AliFMDDebug(10, ("Strip %03d-%d (%d,%d) from t=%d out of range (%3d->%3d)",
str, samp, lstrip, stroff, t, fMinStrip, fMaxStrip));
- return -1;
+ adc = -1;
}
// Possibly do pedestal subtraction of signal
if (adc > 1023)
det, ring, sec, str, samp, counts));
// Check the cache of indicies
Int_t idx = fSeen(det, ring, sec, str);
+ AliFMDDigit* digit = 0;
if (idx == kUShortMax) {
// We haven't seen this strip yet.
fSeen(det, ring, sec, str) = idx = array->GetEntriesFast();
AliFMDDebug(7,("making digit for FMD%d%c[%2d,%3d]-%d "
"from timebin %4d",
det, ring, sec, str, samp, t));
- new ((*array)[idx]) AliFMDDigit(det, ring, sec, str);
+ digit = new ((*array)[idx]) AliFMDDigit(det, ring, sec, str);
+ digit->SetDefaultCounts(fSampleRate[ddl]);
}
- AliFMDBaseDigit* digit =
- static_cast<AliFMDBaseDigit*>(array->At(idx));
+ else
+ digit = static_cast<AliFMDDigit*>(array->At(idx));
AliFMDDebug(10, ("Setting FMD%d%c[%2d,%3d]-%d "
"from timebin %4d=%4d (%4d)",
det, ring, sec, str, samp, t, counts, data[i]));
UInt_t strip_high[18];
UInt_t pulse_size[18];
UInt_t pulse_length[18];
+ for (size_t i = 0; i < 18; i++) {
+ shift_clk[i] = 0;
+ sample_clk[i] = 0;
+ strip_low[i] = 0;
+ strip_high[i] = 0;
+ pulse_size[i] = 0;
+ pulse_length[i] = 0;
+ }
AliFMDParameters* param = AliFMDParameters::Instance();
AliFMDAltroMapping* map = param->GetAltroMap();
- while(fReader->ReadNextData(fData)) {
-
- Int_t ddl = fReader->GetDDLID();
+ AliAltroRawStreamV3 streamer(fReader);
+ streamer.Reset();
+ streamer.SelectRawData("FMD");
+ //fReader->GetDDLID();
+ while (streamer.NextDDL()) {
+ Int_t ddl = streamer.GetDDLNumber();
Int_t detID = fReader->GetDetectorID();
if (detectors) detectors[map->DDL2Detector(ddl)-1] = kTRUE;
AliFMDDebug(0, (" From reader: DDL number is %d , det ID is %d",ddl,detID));
-
- fNbytes = fReader->GetDataSize();
-
- ULong_t nWords = GetNwords();
- UInt_t trailerLast = Get32bitWord(nWords);
- AliFMDDebug(20, (" # Bytes: %d, # Words: %d, Last word: 0x%08x",
- fNbytes, nWords, trailerLast));
- if ((trailerLast & 0xFFFF0000) != 0xAAAA0000) {
- AliWarning(Form("Last word 0x%08x does not match RCU II trailer",
- trailerLast));
- return kFALSE;
- }
-
- // 7 last bits is size of trailer
- ULong_t nTrailerWords = trailerLast & 0x7f;
- ULong_t nPayloadWords = Get32bitWord(nWords - nTrailerWords+1);
- AliFMDDebug(20, (" # trailer words: %d, # payload words: %d",
- nTrailerWords, nPayloadWords));
-
+ ULong_t nPayloadWords = streamer.GetRCUPayloadSizeInSOD();
+ UChar_t* payloadData = streamer.GetRCUPayloadInSOD();
+ UInt_t* payloadWords = reinterpret_cast<UInt_t*>(payloadData);
+ //UInt_t* payloadWords = streamer.GetRCUPayloadInSOD();
+
+ //std::cout<<nPayloadWords<<" "<<ddl<<std::endl;
+ for (ULong_t i = 1; i <= nPayloadWords ; i++, payloadWords++) {
+ UInt_t payloadWord = *payloadWords; // Get32bitWord(i);
- for (ULong_t i = 1; i <= nPayloadWords ; i++) {
- UInt_t payloadWord = Get32bitWord(i);
-
+ //std::cout<<i<<Form(" word: 0x%x",payloadWord)<<std::endl;
// address is only 24 bit
UInt_t address = (0xffffff & payloadWord);
UInt_t type = ((address >> 21) & 0xf);
readDataWord = kTRUE;
case 0x1: // Fec cmd
case 0x2: // Fec write
- i++;
+ i++;
+ payloadWords++;
break;
case 0x4: // Loop
case 0x5: // Wait
break;
case 0x6: // End sequence
case 0x7: // End Mem
- i = nPayloadWords + 1;
+ i = nPayloadWords + 1;
break;
default:
break;
//Don't read unless we have a FEC_RD
if(!readDataWord) continue;
- UInt_t dataWord = Get32bitWord(i);
+ UInt_t dataWord = *payloadWords;//Get32bitWord(i);
UInt_t data = (0xFFFFF & dataWord) ;
//UInt_t data = (0xFFFF & dataWord) ;
case 0x24: break; // FMD: L2 timeout
case 0x25: // FMD: Shift clk
shift_clk[board] = ((data >> 8 ) & 0xFF);
+ AliFMDDebug(30, ("Read shift_clk=%d for board 0x%02x",
+ shift_clk[board], board));
break;
case 0x26: // FMD: Strips
strip_low[board] = ((data >> 0 ) & 0xFF);
case 0x2A: break; // FMD: Preamp ref
case 0x2B: // FMD: Sample clk
sample_clk[board] = ((data >> 8 ) & 0xFF);
+ AliFMDDebug(30, ("Read sample_clk=%d for board 0x%02x",
+ sample_clk[board], board));
break;
case 0x2C: break; // FMD: Commands
case 0x4B: // FMD: Cal events
}
AliFMDDebug(50, ("instruction 0x%x, dataword 0x%x",
instruction,dataWord));
- }
+ } // End of loop over Result memory event
UShort_t det,sector;
Short_t strip;
det = map->DDL2Detector(ddl);
map->Channel2StripBase(boards[i], chip, channel, ring, sector, strip);
- UInt_t samplerate = 1;
+ UInt_t samplerate = 0;
+#if USE_VOTE
if(sample_clk[boards[i]] == 0) {
if(ddl == 0) {
Int_t sample1 = sample_clk[boards[0]];
strip_high[boards[i]] = strip_high[boards[idx]];
pulse_length[boards[i]] = pulse_length[boards[idx]];
pulse_size[boards[i]] = pulse_size[boards[idx]];
- AliFMDDebug(0, ("Vote taken for ddl %d, board 0x%x",
+ AliFMDDebug(3, ("Vote taken for ddl %d, board 0x%x",
ddl,boards[i]));
}
}
}
+#endif
if(sample_clk[boards[i]])
samplerate = shift_clk[boards[i]]/sample_clk[boards[i]];
+ AliFMDDebug(10, ("Sample rate for board 0x%02x is %d",
+ boards[i], samplerate));
sampleRate->Set(det,ring,sector,0,samplerate);
stripRange->Set(det,ring,sector,0,
strip_low[boards[i]],strip_high[boards[i]]);