- // fRawAnalyzer setup
- fRawAnalyzer->SetAmpCut(fNoiseThreshold);
- fRawAnalyzer->SetFitArrayCut(fNoiseThreshold);
- fRawAnalyzer->SetIsZeroSuppressed(true); // TMP - should use stream->IsZeroSuppressed(), or altro cfg registers later
-
- // channel info parameters
- Int_t lowGain = 0;
- Int_t caloFlag = 0; // low, high gain, or TRU, or LED ref.
-
- // start loop over input stream
- while (in.NextDDL()) {
- while (in.NextChannel()) {
-
- //Check if the signal is high or low gain and then do the fit,
- //if it is from TRU or LEDMon do not fit
- caloFlag = in.GetCaloFlag();
- if (caloFlag != 0 && caloFlag != 1) continue;
-
- //Do not fit bad channels
- if(fRemoveBadChannels && pedbadmap->IsBadChannel(in.GetModule(),in.GetColumn(),in.GetRow())) {
- //printf("Tower from SM %d, column %d, row %d is BAD!!! Skip \n", in.GetModule(),in.GetColumn(),in.GetRow());
- continue;
- }
-
- vector<AliCaloBunchInfo> bunchlist;
- while (in.NextBunch()) {
- bunchlist.push_back( AliCaloBunchInfo(in.GetStartTimeBin(), in.GetBunchLength(), in.GetSignals() ) );
- } // loop over bunches
-
- Float_t time = 0;
- Float_t amp = 0;
-
- if (fFittingAlgorithm == kLMS || fFittingAlgorithm == kPeakFinder || fFittingAlgorithm == 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.GetTof();
- }
- 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 ampEstimate = 0;
- short maxADC = 0;
- short timeEstimate = 0;
- Float_t pedEstimate = 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;
- amp = ampEstimate;
-
- if ( nsamples > 1 ) { // possibly something to fit
- FitRaw(first, last, amp, time);
- }
-
- if ( amp>0 && time>0 ) { // brief sanity check of fit results
-
- // check fit results: should be consistent with initial estimates
- // more magic numbers, but very loose cuts, for now..
- // We have checked that amp and ampEstimate values are positive so division for assymmetry
- // calculation should be OK/safe
- Float_t ampAsymm = (amp - ampEstimate)/(amp + ampEstimate);
- if ( (TMath::Abs(ampAsymm) > 0.1) ) {
- AliDebug(2,Form("Fit results amp %f time %f not consistent with expectations ped %f max-ped %f time %d",
- amp, time, pedEstimate, ampEstimate, timeEstimate));
-
- // what should do we do then? skip this channel or assign the simple estimate?
- // for now just overwrite the fit results with the simple estimate
- amp = ampEstimate;
- time = timeEstimate;
- } // asymm check
- } // amp & time check
- } // ampEstimate check
- } // method selection
-
- if (amp > fNoiseThreshold) { // something to be stored
- 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?
-
- 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);
- // round off amplitude value to nearest integer
- AddDigit(digitsArr, id, lowGain, TMath::Nint(amp), time);
- }
-
- } // end while over channel
- } //end while over DDL's, of input stream
-
- return ;
-}
-
-//____________________________________________________________________________
-void AliEMCALRawUtils::AddDigit(TClonesArray *digitsArr, Int_t id, Int_t lowGain, Int_t amp, Float_t time) {
- //
- // Add a new digit.
- // This routine checks whether a digit exists already for this tower
- // and then decides whether to use the high or low gain info
- //
- // Called by Raw2Digits
-