1 /**************************************************************************
2 * This file is property of and copyright by the Experimental Nuclear *
3 * Physics Group, Dep. of Physics *
4 * University of Oslo, Norway, 2007 *
6 * Author: Per Thomas Hille <perthomas.hille@yale.edu> *
7 * for the ALICE HLT Project. *
8 * Contributors are mentioned in the code where appropriate. *
9 * Please report bugs to perthi@fys.uio.no *
11 * Permission to use, copy, modify and distribute this software and its *
12 * documentation strictly for non-commercial purposes is hereby granted *
13 * without fee, provided that the above copyright notice appears in all *
14 * copies and that both the copyright notice and this permission notice *
15 * appear in the supporting documentation. The authors make no claims *
16 * about the suitability of this software for any purpose. It is *
17 * provided "as is" without express or implied warranty. *
18 **************************************************************************/
20 // Evaluation of peak position
21 // and amplitude using Neural Networks (NN)
27 #include "AliCaloRawAnalyzerNN.h"
28 #include "AliCaloNeuralFit.h"
29 #include "AliCaloFitResults.h"
30 #include "AliCaloBunchInfo.h"
34 #include "AliCaloConstants.h"
36 ClassImp( AliCaloRawAnalyzerNN )
38 AliCaloRawAnalyzerNN::AliCaloRawAnalyzerNN() : AliCaloRawAnalyzer("Neural Network", "NN"), fNeuralNet(0)
41 fAlgo=Algo::kNeuralNet;
43 fNeuralNet = new AliCaloNeuralFit();
45 for(int i=0; i < 5 ; i++)
53 AliCaloRawAnalyzerNN::~AliCaloRawAnalyzerNN()
60 AliCaloRawAnalyzerNN::Evaluate( const vector<AliCaloBunchInfo> &bunchvector,
61 const UInt_t altrocfg1, const UInt_t altrocfg2 )
63 // The eveluation of Peak position and amplitude using the Neural Network
64 if( bunchvector.size() <= 0 )
66 // cout << __FILE__ << __LINE__<< " INVALID "<< endl;
68 return AliCaloFitResults( Ret::kInvalid, Ret::kInvalid);
74 int index = SelectBunch( bunchvector, &maxampindex , &maxamp ) ;
78 // cout << __FILE__ << __LINE__<< "INVALID !!!!!!" << endl;
79 return AliCaloFitResults( Ret::kInvalid, Ret::kInvalid);
82 Float_t ped = ReverseAndSubtractPed( &(bunchvector.at( index ) ) , altrocfg1, altrocfg2, fReversed );
83 short timebinOffset = maxampindex - (bunchvector.at(index).GetLength()-1);
84 double maxf = maxamp - ped;
86 if( maxf < fAmpCut || ( maxamp - ped) > fOverflowCut ) // (maxamp - ped) > fOverflowCut = Close to saturation (use low gain then)
88 // cout << __FILE__ << __LINE__<< ": timebinOffset = " << timebinOffset << " maxf "<< maxf << endl;
89 return AliCaloFitResults( maxamp, ped, Ret::kCrude, maxf, timebinOffset);
94 short maxrev = maxampindex - bunchvector.at(index).GetStartBin();
95 SelectSubarray( fReversed, bunchvector.at(index).GetLength(), maxrev , &first, &last, fFitArrayCut );
101 if ( ( maxrev - first) < 2 && (last - maxrev ) < 2)
103 chi2 = CalculateChi2(maxf, maxrev, first, last);
104 ndf = last - first - 1; // nsamples - 2
105 // cout << __FILE__ << __LINE__<< ": timebinOffset = " << timebinOffset << " maxf\t"<< maxf <<endl;
106 return AliCaloFitResults( maxamp, ped, Ret::kCrude, maxf, timebinOffset,
107 timebinOffset, chi2, ndf, Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) );
112 for(int i=0; i < 5 ; i++)
114 fNNInput[i] = fReversed[maxrev-2 +i]/(maxamp -ped);
118 double amp = (maxamp - ped)*fNeuralNet->Value( 0, fNNInput[0], fNNInput[1], fNNInput[2], fNNInput[3], fNNInput[4]);
119 double tof = (fNeuralNet->Value( 1, fNNInput[0], fNNInput[1], fNNInput[2], fNNInput[3], fNNInput[4]) + timebinOffset ) ;
121 // use local-array time for chi2 estimate
122 chi2 = CalculateChi2(amp, tof-timebinOffset+maxrev, first, last);
123 ndf = last - first - 1; // nsamples - 2
124 //cout << __FILE__ << __LINE__<< ": tof = " << tof << " amp" << amp <<endl;
125 return AliCaloFitResults( maxamp, ped , Ret::kFitPar, amp , tof, timebinOffset, chi2, ndf,
126 Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) );
130 chi2 = CalculateChi2(maxf, maxrev, first, last);
131 ndf = last - first - 1; // nsamples - 2
133 // cout << __FILE__ << __LINE__<< ": timebinOffset = " << timebinOffset << " maxf ="<< maxf << endl;
134 return AliCaloFitResults( maxamp, ped, Ret::kCrude, maxf, timebinOffset,
135 timebinOffset, chi2, ndf, Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) );