-
- if (nsamples > 0) { // this check is needed for when we have zero-supp. on, but not sparse readout
-
- id = fGeom->GetAbsCellIdFromCellIndexes(in.GetModule(), in.GetRow(), in.GetColumn()) ;
- caloFlag = in.GetCaloFlag();
- lowGain = in.IsLowGain();
-
- gSig->Set(maxTime+1);
- FitRaw(gSig, signalF, amp, time) ;
-
- if (caloFlag == 0 || caloFlag == 1) { // low gain or high gain
- if (amp > 0 && amp < 2000) { //check both high and low end of
- //result, 2000 is somewhat arbitrary - not nice with magic numbers in the code..
- AliDebug(2,Form("id %d lowGain %d amp %g", id, lowGain, amp));
-
- AddDigit(digitsArr, id, lowGain, (Int_t)amp, time);
- }
-
- }
-
- // Reset graph
- for (Int_t index = 0; index < gSig->GetN(); index++) {
- gSig->SetPoint(index, index, 0) ;
- }
- // Reset starting parameters for fit function
- signalF->SetParameters(10.,0.,fTau,fOrder,5.); //reset all defaults just to be safe
-
- } // nsamples>0 check, some data found for this channel; not only trailer/header
- } // end while over channel
+
+ if ( caloFlag < 2 )
+ { // ALTRO
+ Float_t time = 0;
+ Float_t amp = 0;
+ short timeEstimate = 0;
+ Float_t ampEstimate = 0;
+ Bool_t fitDone = kFALSE;
+ Float_t chi2 = 0;
+ Int_t ndf = 0;
+
+ if ( fFittingAlgorithm == Algo::kFastFit || fFittingAlgorithm == Algo::kNeuralNet ||
+ fFittingAlgorithm == Algo::kLMS || fFittingAlgorithm == Algo::kPeakFinder ||
+ fFittingAlgorithm == Algo::kCrude) {
+ // all functionality to determine amp and time etc is encapsulated inside the Evaluate call for these methods
+ AliCaloFitResults fitResults = fRawAnalyzer->Evaluate( bunchlist, in.GetAltroCFG1(), in.GetAltroCFG2());
+
+ amp = fitResults.GetAmp();
+ time = fitResults.GetTime();
+ timeEstimate = fitResults.GetMaxTimebin();
+ ampEstimate = fitResults.GetMaxSig();
+ chi2 = fitResults.GetChi2();
+ ndf = fitResults.GetNdf();
+ if (fitResults.GetStatus() == Ret::kFitPar) {
+ fitDone = kTRUE;
+ }
+ }
+ else { // for the other methods we for now use the functionality of
+ // AliCaloRawAnalyzer as well, to select samples and prepare for fits,
+ // if it looks like there is something to fit
+
+ // parameters init.
+ Float_t pedEstimate = 0;
+ short maxADC = 0;
+ Int_t first = 0;
+ Int_t last = 0;
+ Int_t bunchIndex = 0;
+ //
+ // The PreFitEvaluateSamples + later call to FitRaw will hopefully
+ // be replaced by a single Evaluate call or so soon, like for the other
+ // methods, but this should be good enough for evaluation of
+ // the methods for now (Jan. 2010)
+ //
+ int nsamples = fRawAnalyzer->PreFitEvaluateSamples( bunchlist, in.GetAltroCFG1(), in.GetAltroCFG2(), bunchIndex, ampEstimate, maxADC, timeEstimate, pedEstimate, first, last);
+
+ if (ampEstimate >= fNoiseThreshold) { // something worth looking at
+
+ time = timeEstimate; // maxrev in AliCaloRawAnalyzer speak; comes with an offset w.r.t. real timebin
+ Int_t timebinOffset = bunchlist.at(bunchIndex).GetStartBin() - (bunchlist.at(bunchIndex).GetLength()-1);
+ amp = ampEstimate;
+
+ if ( nsamples > 1 && maxADC<fgkOverflowCut ) { // possibly something to fit
+ FitRaw(first, last, amp, time, chi2, fitDone);
+ time += timebinOffset;
+ timeEstimate += timebinOffset;
+ ndf = nsamples - 2;
+ }
+
+ } // ampEstimate check
+ } // method selection
+
+ if ( fitDone ) { // brief sanity check of fit results
+ Float_t ampAsymm = (amp - ampEstimate)/(amp + ampEstimate);
+ Float_t timeDiff = time - timeEstimate;
+ if ( (TMath::Abs(ampAsymm) > 0.1) || (TMath::Abs(timeDiff) > 2) ) {
+ // AliDebug(2,Form("Fit results amp %f time %f not consistent with expectations amp %f time %d", amp, time, ampEstimate, timeEstimate));
+
+ // for now just overwrite the fit results with the simple/initial estimate
+ amp = ampEstimate;
+ time = timeEstimate;
+ fitDone = kFALSE;
+ }
+ } // fitDone
+
+ if (amp >= fNoiseThreshold) { // something to be stored
+ if ( ! fitDone) { // smear ADC with +- 0.5 uniform (avoid discrete effects)
+ amp += (0.5 - gRandom->Rndm()); // Rndm generates a number in ]0,1]
+ }
+
+ Int_t id = fGeom->GetAbsCellIdFromCellIndexes(in.GetModule(), in.GetRow(), in.GetColumn()) ;
+ lowGain = in.IsLowGain();
+
+ // go from time-bin units to physical time fgtimetrigger
+ time = time * GetRawFormatTimeBinWidth(); // skip subtraction of fgTimeTrigger?
+ // subtract RCU L1 phase (L1Phase is in seconds) w.r.t. L0:
+ time -= in.GetL1Phase();
+
+ AliDebug(2,Form("id %d lowGain %d amp %g", id, lowGain, amp));
+ // printf("Added tower: SM %d, row %d, column %d, amp %3.2f\n",in.GetModule(), in.GetRow(), in.GetColumn(),amp);
+
+ AddDigit(digitsArr, id, lowGain, amp, time, chi2, ndf);
+ }
+
+ }//ALTRO
+ else if(fUseFALTRO)
+ {// Fake ALTRO
+ fTriggerRawDigitMaker->Add( bunchlist );
+ }//Fake ALTRO
+ } // end while over channel