#include "AliCaloNeuralFit.h"
#include "AliCaloFitResults.h"
#include "AliCaloBunchInfo.h"
-
#include <iostream>
-
using namespace std;
+#include "AliCaloConstants.h"
+
ClassImp( AliCaloRawAnalyzerNN )
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(AliCaloFitResults::kInvalid, AliCaloFitResults::kInvalid);
+ // cout << __FILE__ << __LINE__<< " INVALID "<< endl;
+
+ return AliCaloFitResults( Ret::kInvalid, Ret::kInvalid);
}
short maxampindex;
if( index < 0 )
{
- return AliCaloFitResults(AliCaloFitResults::kInvalid, AliCaloFitResults::kInvalid);
+ // cout << __FILE__ << __LINE__<< "INVALID !!!!!!" << endl;
+ return AliCaloFitResults( Ret::kInvalid, Ret::kInvalid);
}
- int first = 0;
- int last = 0;
-
- Float_t ped = ReverseAndSubtractPed( &(bunchvector.at( index ) ) , altrocfg1, altrocfg2, fReversed );
-
- short maxrev = maxampindex - bunchvector.at(index).GetStartBin();
+ Float_t ped = ReverseAndSubtractPed( &(bunchvector.at( index ) ) , altrocfg1, altrocfg2, fReversed );
short timebinOffset = maxampindex - (bunchvector.at(index).GetLength()-1);
double maxf = maxamp - ped;
- SelectSubarray( fReversed, bunchvector.at(index).GetLength(), maxrev , &first, &last);
+ 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;
+ 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( maxamp, ped, AliCaloFitResults::kCrude, maxf, timebinOffset);
+ 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 , AliCaloFitResults::kFitPar, amp , tof, timebinOffset, AliCaloFitResults::kDummy, AliCaloFitResults::kDummy,
- AliCaloFitResults::kDummy, AliCaloFitSubarray(index, maxrev, first, last) );
+ // 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( maxamp, ped, AliCaloFitResults::kCrude, maxf, timebinOffset);
+ 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) );
+
}