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"
36 ClassImp( AliCaloRawAnalyzerNN )
38 AliCaloRawAnalyzerNN::AliCaloRawAnalyzerNN() : AliCaloRawAnalyzer("Neural Network"), fNeuralNet(0)
42 fNeuralNet = new AliCaloNeuralFit();
44 for(int i=0; i < 5 ; i++)
52 AliCaloRawAnalyzerNN::~AliCaloRawAnalyzerNN()
59 AliCaloRawAnalyzerNN::Evaluate( const vector<AliCaloBunchInfo> &bunchvector,
60 const UInt_t altrocfg1, const UInt_t altrocfg2 )
62 // The eveluation of Peak position and amplitude using the Neural Network
63 if( bunchvector.size() <= 0 )
65 return AliCaloFitResults(9999, 9999, 9999, 9999 , 9999, 9999, 9999 );
71 int bindex = SelectBunch( bunchvector, &maxindex , &maxamp ) ;
75 return AliCaloFitResults(9999, 9999, 9999, 9999 , 9999, 9999, 9999 );
81 Float_t ped = ReverseAndSubtractPed( &(bunchvector.at( bindex ) ) , altrocfg1, altrocfg2, fReversed );
83 // SelectSubarray ( fReversed, bunchvector.at(bindex).GetLength(), &first, &last );
85 short maxrev = maxindex - bunchvector.at(bindex).GetStartBin();
88 SelectSubarray( fReversed, bunchvector.at(bindex).GetLength(), maxrev , &first, &last);
90 // cout << __FILE__ << __LINE__ << ":" << fName << ", maxindex = " << maxindex << ", first = " << first << ", last = " << last << endl;
91 // cout << __FILE__ << __LINE__ << ":" << fName << ", maxindex = " << maxrev << ", first = " << first << ", last = " << last << endl;
95 if ( ( maxrev - first) < 2 && (last - maxrev ) < 2)
97 return AliCaloFitResults(9999, 9999, 9999, 9999 , 9999, 9999, 9999 );
102 cout << __FILE__ << __LINE__ << "!!!!!!!!:\t" << fReversed[maxrev -2 ]<< "\t" <<
103 fReversed[ maxrev -1 ] << "\t" << fReversed[maxrev ] << "\t" <<
104 fReversed[ maxrev +1 ] << "\t" << fReversed[maxrev +2] << endl;
107 for(int i=0; i < 5 ; i++)
109 fNNInput[i] = fReversed[maxrev-2 +i]/(maxamp -ped);
114 // double amp = fNeuralNet->Value( 0, fReversed[maxrev-2], fReversed[maxrev -1], fReversed[maxrev], fReversed[maxrev+1], fReversed[maxrev+2]);
115 // double tof = fNeuralNet->Value( 1, fReversed[maxrev-2], fReversed[maxrev -1], fReversed[maxrev], fReversed[maxrev+1], fReversed[maxrev+2]);
117 // double amp = fNeuralNet->Value( 0, fReversed[maxrev+2]/maxamp, fReversed[maxrev +1]/maxamp, fReversed[maxrev]/maxamp, fReversed[maxrev-1]/maxamp, fReversed[maxrev-2]/maxamp);
118 // double tof = fNeuralNet->Value( 1, fReversed[maxrev+2]/maxamp, fReversed[maxrev +1]/maxamp, fReversed[maxrev]/maxamp, fReversed[maxrev-1]/maxamp, fReversed[maxrev-2]/maxamp);
120 // double amp = maxamp*fNeuralNet->Value( 0, fReversed[maxrev-2]/(maxamp -ped), fReversed[maxrev -1]/(maxamp -ped), fReversed[maxrev]/(maxamp-ped), fReversed[maxrev+1]/(maxamp -ped), fReversed[maxrev+2]/(maxamp-ped));
121 // double tof = fNeuralNet->Value( 1, fReversed[maxrev-2]/maxamp, fReversed[maxrev -1]/maxamp, fReversed[maxrev]/maxamp, fReversed[maxrev+1]/maxamp, fReversed[maxrev+2]/maxamp);
124 // double amp = maxamp*fNeuralNet->Value( 0, fNNInput[0], fNNInput[1], fNNInput[2], fNNInput[3], fNNInput[4]);
125 // double tof = (fNeuralNet->Value( 1, fNNInput[0], fNNInput[1], fNNInput[2], fNNInput[3], fNNInput[4]) + maxrev )*256 ;
127 double amp = (maxamp - ped)*fNeuralNet->Value( 0, fNNInput[0], fNNInput[1], fNNInput[2], fNNInput[3], fNNInput[4]);
128 double tof = (fNeuralNet->Value( 1, fNNInput[0], fNNInput[1], fNNInput[2], fNNInput[3], fNNInput[4]) + maxrev )*256 ;
131 // double tof = fNeuralNet->Value( 1, fReversed[maxrev-2]/maxamp, fReversed[maxrev -1]/maxamp, fReversed[maxrev]/maxamp, fReversed[maxrev+1]/maxamp, fReversed[maxrev+2]/maxamp);
133 return AliCaloFitResults( maxamp, ped , -1, amp , tof, -2, -3 );
137 return AliCaloFitResults(9999, 9999, 9999, 9999 , 9999, 9999, 9999 );
140 //amp = exportNN.Value(0,input[0],input[1],input[2],input[3],input[4])*(globMaxSig - pedEstimate);
141 //time = (exportNN.Value(1,input[0],input[1],input[2],input[3],input[4])+globMaxId) * fgTimeBins;
145 //SelectSubarray( fReversed, bunchvector.at(index).GetLength(), maxampindex - bunchvector.at(index).GetStartBin(), &first, &last);
150 AliCaloRawAnalyzerNN::SelectSubarray( const Double_t *fData, const int length, const short maxindex, int *const first, int *const last ) const