+ if(!failZS) {
+ fitter.SubtractPedestals(kFALSE);
+ fitter.SetAmpOffset(offset);
+ fitter.SetAmpThreshold(threshold);
+ }
+
+ while (stream.NextDDL()) {
+ while (stream.NextChannel()) {
+
+ /* Retrieve ZS parameters from data*/
+ if(failZS) {
+ short value = stream.GetAltroCFG1();
+ bool ZeroSuppressionEnabled = (value >> 15) & 0x1;
+ bool AutomaticBaselineSubtraction = (value >> 14) & 0x1;
+ if(ZeroSuppressionEnabled) {
+ offset = (value >> 10) & 0xf;
+ threshold = value & 0x3ff;
+ fitter.SubtractPedestals(kFALSE);
+ fitter.SetAmpOffset(offset);
+ fitter.SetAmpThreshold(threshold);
+ }
+ }
+
+ cellX = stream.GetCellX();
+ cellZ = stream.GetCellZ();
+ caloFlag = stream.GetCaloFlag(); // 0=LG, 1=HG, 2=TRU
+
+ if(caloFlag!=0 && caloFlag!=1) continue; //TRU data!
+
+ // In case of oscillating signals with ZS,
+ //a channel can have several bunches.
+
+ nBunches = 0;
+ while (stream.NextBunch()) {
+ nBunches++;
+ if (nBunches > 1) continue;
+ sigStart = stream.GetStartTimeBin();
+ sigLength = stream.GetBunchLength();
+ fitter.SetChannelGeo(stream.GetModule(),cellX,cellZ,caloFlag);
+ fitter.Eval(stream.GetSignals(),sigStart,sigLength);
+ } // End of NextBunch()
+
+ if (nBunches != 1) continue;
+
+ e[cellX][cellZ][caloFlag] = fitter.GetEnergy();
+ t[cellX][cellZ][caloFlag] = fitter.GetTime();
+ }
+
+ if(stream.GetModule()<0 || stream.GetModule()>4) continue;