+
+ fGeom->RelToAbsNumbering(relId, absId);
+
+ fitter->SetNBunches(0);
+ Int_t sigStart =0 ;
+ Int_t sigLength=0 ;
+ while (fRawStream->NextBunch()) { //Take the first in time bunch
+ const UShort_t *sig = fRawStream->GetSignals();
+ sigStart = fRawStream->GetStartTimeBin();
+ sigLength = fRawStream->GetBunchLength();
+ fitter->Eval(sig,sigStart,sigLength);
+ if (caloFlag == AliCaloRawStreamV3::kLowGain) {
+ delete [] fADCValuesLG;
+ fADCValuesLG = new Int_t[sigLength];
+ for (Int_t i=0; i<sigLength; i++)
+ fADCValuesLG[sigLength-i-1] = sig[i];
+ }
+ else if (caloFlag == AliCaloRawStreamV3::kHighGain) {
+ delete [] fADCValuesHG;
+ fADCValuesHG = new Int_t[sigLength];
+ for (Int_t i=0; i<sigLength; i++)
+ fADCValuesHG[sigLength-i-1] = sig[i];
+ }
+ } // End of NextBunch()
+
+
+ Double_t energy = fitter->GetEnergy() ;
+ Double_t time = fitter->GetTime() ;
+ if(energy<=baseLine) //in ADC channels
+ continue ;
+
+ //remove digits with bad shape. Fitter should calculate quality so that
+ //in default case quality [0,1], while larger values of quality mean somehow
+ //corrupted samples, 999 means obviously corrupted sample.
+ //It is difficult to fit samples with overflow (even setting cut on overflow values)
+ //because too few points are left to fit. So we do not evaluate samples with overflow
+
+ if(fitter->GetSignalQuality() > fSampleQualityCut && !(fitter->IsOverflow()))
+ continue ;
+
+ energy = CalibrateE(energy,relId,!caloFlag) ;
+
+ //convert time from sample bin units to s
+ time*=fSampleToSec ;
+//CalibrateT moved to Clusterizer
+// time = CalibrateT(time,relId,!caloFlag) ;
+ // subtract RCU L1 phase (L1Phase is in seconds) w.r.t. L0:
+ //Very strange behaviour of electronics, but cross-checkes several times...
+ if( fRawStream->GetL1Phase()<55.*1.e-9 ) //for phase=0,25,50
+ time -= fRawStream->GetL1Phase();
+ else //for phase 75
+ time += 25.*1.e-9 ;
+
+ if(energy <= 0.)
+ continue;
+
+ if (caloFlag == AliCaloRawStreamV3::kLowGain) {
+ new((*tmpDigLG)[ilgDigit]) AliPHOSDigit(-1,absId,(Float_t)energy,(Float_t)time);
+ if (sigLength>0 && fADCValuesLG!=0)
+ static_cast<AliPHOSDigit*>(tmpDigLG->At(ilgDigit))->SetALTROSamplesLG(sigLength,fADCValuesLG);
+ ilgDigit++ ;
+ }
+ else if (caloFlag == AliCaloRawStreamV3::kHighGain) {
+ if(fitter->IsOverflow()) //Keep this digit to replace it by Low Gain later.
+ //If there is no LogGain it wil be removed by cut on Min E
+ new((*digits)[iDigit]) AliPHOSDigit(-1,absId,-1.f,(Float_t)time);
+ else
+ new((*digits)[iDigit]) AliPHOSDigit(-1,absId,(Float_t)energy,(Float_t)time);
+ if (sigLength>0 && fADCValuesHG!=0)
+ static_cast<AliPHOSDigit*>(digits->At(iDigit))->SetALTROSamplesHG(sigLength,fADCValuesHG);
+ iDigit++;
+ }
+ } // End of NextChannel()
+
+ //Now scan created LG and HG digits and keep only those which appeared in both lists
+ //replace energy of HighGain digits only if there is overflow
+ //negative energy (overflow)
+ digits->Sort() ;
+ tmpDigLG->Sort() ;
+ Int_t iLG = 0;
+ Int_t nLG1 = tmpDigLG->GetEntriesFast()-1 ;
+
+ for(Int_t iDig=0 ; iDig < digits->GetEntriesFast() ; iDig++) {
+ AliPHOSDigit * digHG = dynamic_cast<AliPHOSDigit*>(digits->At(iDig)) ;
+ if (!digHG) continue;
+ AliPHOSDigit * digLG = dynamic_cast<AliPHOSDigit*>(tmpDigLG->At(iLG)) ;
+ while(digLG && iLG<nLG1 && digHG->GetId()> digLG->GetId()){
+ iLG++ ;
+ digLG = dynamic_cast<AliPHOSDigit*>(tmpDigLG->At(iLG)) ;
+ }
+ absId=digHG->GetId() ;