#include "AliCaloNeuralFit.h"
#include "AliCaloFitResults.h"
#include "AliCaloBunchInfo.h"
-
#include <iostream>
-
using namespace std;
+#include "AliCaloConstants.h"
+
ClassImp( AliCaloRawAnalyzerNN )
-AliCaloRawAnalyzerNN::AliCaloRawAnalyzerNN() : AliCaloRawAnalyzer("Neural Network"), fNeuralNet(0)
+AliCaloRawAnalyzerNN::AliCaloRawAnalyzerNN() : AliCaloRawAnalyzer("Neural Network", "NN"), fNeuralNet(0)
{
// Comment
+ fAlgo=Algo::kNeuralNet;
fNeuralNet = new AliCaloNeuralFit();
// The eveluation of Peak position and amplitude using the Neural Network
if( bunchvector.size() <= 0 )
{
- return AliCaloFitResults(9999, 9999, 9999, 9999 , 9999, 9999, 9999 );
+ // cout << __FILE__ << __LINE__<< " INVALID "<< endl;
+
+ return AliCaloFitResults( Ret::kInvalid, Ret::kInvalid);
}
- short maxindex;
+ short maxampindex;
short maxamp;
- int bindex = SelectBunch( bunchvector, &maxindex , &maxamp ) ;
+ int index = SelectBunch( bunchvector, &maxampindex , &maxamp ) ;
- if( bindex < 0 )
+ if( index < 0 )
{
- return AliCaloFitResults(9999, 9999, 9999, 9999 , 9999, 9999, 9999 );
+ // cout << __FILE__ << __LINE__<< "INVALID !!!!!!" << endl;
+ return AliCaloFitResults( Ret::kInvalid, Ret::kInvalid);
}
+ Float_t ped = ReverseAndSubtractPed( &(bunchvector.at( index ) ) , altrocfg1, altrocfg2, fReversed );
+ short timebinOffset = maxampindex - (bunchvector.at(index).GetLength()-1);
+ double maxf = maxamp - ped;
+
+ if( maxf < fAmpCut || ( maxamp - ped) > fOverflowCut ) // (maxamp - ped) > fOverflowCut = Close to saturation (use low gain then)
+ {
+ // cout << __FILE__ << __LINE__<< ": timebinOffset = " << timebinOffset << " maxf "<< maxf << endl;
+ return AliCaloFitResults( maxamp, ped, Ret::kCrude, maxf, timebinOffset);
+ }
+
int first = 0;
- int last = 0;
-
- Float_t ped = ReverseAndSubtractPed( &(bunchvector.at( bindex ) ) , altrocfg1, altrocfg2, fReversed );
-
- short maxrev = maxindex - bunchvector.at(bindex).GetStartBin();
- short timebinOffset = maxindex - (bunchvector.at(bindex).GetLength()-1);
-
- SelectSubarray( fReversed, bunchvector.at(bindex).GetLength(), maxrev , &first, &last);
+ int last = 0;
+ short maxrev = maxampindex - bunchvector.at(index).GetStartBin();
+ SelectSubarray( fReversed, bunchvector.at(index).GetLength(), maxrev , &first, &last, fFitArrayCut );
+ Float_t chi2 = 0;
+ Int_t ndf = 0;
if(maxrev < 1000 )
{
if ( ( maxrev - first) < 2 && (last - maxrev ) < 2)
{
- return AliCaloFitResults(9999, 9999, 9999, 9999 , 9999, 9999, 9999 );
+ chi2 = CalculateChi2(maxf, maxrev, first, last);
+ ndf = last - first - 1; // nsamples - 2
+ // cout << __FILE__ << __LINE__<< ": timebinOffset = " << timebinOffset << " maxf\t"<< maxf <<endl;
+ return AliCaloFitResults( maxamp, ped, Ret::kCrude, maxf, timebinOffset,
+ timebinOffset, chi2, ndf, Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) );
}
else
{
double amp = (maxamp - ped)*fNeuralNet->Value( 0, fNNInput[0], fNNInput[1], fNNInput[2], fNNInput[3], fNNInput[4]);
double tof = (fNeuralNet->Value( 1, fNNInput[0], fNNInput[1], fNNInput[2], fNNInput[3], fNNInput[4]) + timebinOffset ) ;
- return AliCaloFitResults( maxamp, ped , -1, amp , tof, -2, -3 );
+ // use local-array time for chi2 estimate
+ chi2 = CalculateChi2(amp, tof-timebinOffset+maxrev, first, last);
+ ndf = last - first - 1; // nsamples - 2
+ //cout << __FILE__ << __LINE__<< ": tof = " << tof << " amp" << amp <<endl;
+ return AliCaloFitResults( maxamp, ped , Ret::kFitPar, amp , tof, timebinOffset, chi2, ndf,
+ Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) );
}
}
- return AliCaloFitResults(9999, 9999, 9999, 9999 , 9999, 9999, 9999 );
+ chi2 = CalculateChi2(maxf, maxrev, first, last);
+ ndf = last - first - 1; // nsamples - 2
+
+ // cout << __FILE__ << __LINE__<< ": timebinOffset = " << timebinOffset << " maxf ="<< maxf << endl;
+ return AliCaloFitResults( maxamp, ped, Ret::kCrude, maxf, timebinOffset,
+ timebinOffset, chi2, ndf, Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) );
+
}