]>
Commit | Line | Data |
---|---|---|
e37e3c84 | 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 * | |
5 | * * | |
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 * | |
10 | * * | |
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 | **************************************************************************/ | |
19 | ||
20 | // Evaluation of peak position | |
21 | // and amplitude using Neural Networks (NN) | |
22 | // ------------------ | |
23 | // ------------------ | |
24 | // ------------------ | |
25 | ||
26 | ||
27 | #include "AliCaloRawAnalyzerNN.h" | |
28 | #include "AliCaloNeuralFit.h" | |
29 | #include "AliCaloFitResults.h" | |
30 | #include "AliCaloBunchInfo.h" | |
e37e3c84 | 31 | #include <iostream> |
e37e3c84 | 32 | using namespace std; |
33 | ||
168c7b3c | 34 | #include "AliCaloConstants.h" |
35 | ||
e37e3c84 | 36 | ClassImp( AliCaloRawAnalyzerNN ) |
37 | ||
48a2e3eb | 38 | AliCaloRawAnalyzerNN::AliCaloRawAnalyzerNN() : AliCaloRawAnalyzer("Neural Network", "NN"), fNeuralNet(0) |
e37e3c84 | 39 | { |
40 | // Comment | |
168c7b3c | 41 | fAlgo=Algo::kNeuralNet; |
e37e3c84 | 42 | |
43 | fNeuralNet = new AliCaloNeuralFit(); | |
44 | ||
45 | for(int i=0; i < 5 ; i++) | |
46 | { | |
47 | fNNInput[i] = 0; | |
48 | } | |
49 | ||
50 | } | |
51 | ||
52 | ||
53 | AliCaloRawAnalyzerNN::~AliCaloRawAnalyzerNN() | |
54 | { | |
55 | delete fNeuralNet; | |
56 | } | |
57 | ||
58 | ||
59 | AliCaloFitResults | |
60 | AliCaloRawAnalyzerNN::Evaluate( const vector<AliCaloBunchInfo> &bunchvector, | |
61 | const UInt_t altrocfg1, const UInt_t altrocfg2 ) | |
62 | { | |
63 | // The eveluation of Peak position and amplitude using the Neural Network | |
64 | if( bunchvector.size() <= 0 ) | |
65 | { | |
168c7b3c | 66 | return AliCaloFitResults( Ret::kInvalid, Ret::kInvalid); |
e37e3c84 | 67 | } |
68 | ||
f57baa2d | 69 | short maxampindex; |
e37e3c84 | 70 | short maxamp; |
71 | ||
f57baa2d | 72 | int index = SelectBunch( bunchvector, &maxampindex , &maxamp ) ; |
e37e3c84 | 73 | |
f57baa2d | 74 | if( index < 0 ) |
e37e3c84 | 75 | { |
168c7b3c | 76 | return AliCaloFitResults( Ret::kInvalid, Ret::kInvalid); |
e37e3c84 | 77 | } |
78 | ||
2cd0ffda | 79 | Float_t ped = ReverseAndSubtractPed( &(bunchvector.at( index ) ) , altrocfg1, altrocfg2, fReversed ); |
f57baa2d | 80 | short timebinOffset = maxampindex - (bunchvector.at(index).GetLength()-1); |
81 | double maxf = maxamp - ped; | |
82 | ||
2cd0ffda | 83 | if( maxf < fAmpCut || ( maxamp - ped) > fOverflowCut ) // (maxamp - ped) > fOverflowCut = Close to saturation (use low gain then) |
84 | { | |
168c7b3c | 85 | return AliCaloFitResults( maxamp, ped, Ret::kCrude, maxf, timebinOffset); |
2cd0ffda | 86 | } |
87 | ||
88 | int first = 0; | |
89 | int last = 0; | |
90 | short maxrev = maxampindex - bunchvector.at(index).GetStartBin(); | |
f57baa2d | 91 | SelectSubarray( fReversed, bunchvector.at(index).GetLength(), maxrev , &first, &last); |
e37e3c84 | 92 | |
2cd0ffda | 93 | Float_t chi2 = 0; |
94 | Int_t ndf = 0; | |
e37e3c84 | 95 | if(maxrev < 1000 ) |
96 | { | |
97 | if ( ( maxrev - first) < 2 && (last - maxrev ) < 2) | |
98 | { | |
2cd0ffda | 99 | chi2 = CalculateChi2(maxf, maxrev, first, last); |
100 | ndf = last - first - 1; // nsamples - 2 | |
168c7b3c | 101 | return AliCaloFitResults( maxamp, ped, Ret::kCrude, maxf, timebinOffset, |
102 | timebinOffset, chi2, ndf, Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) ); | |
e37e3c84 | 103 | } |
104 | else | |
105 | { | |
e37e3c84 | 106 | |
107 | for(int i=0; i < 5 ; i++) | |
108 | { | |
109 | fNNInput[i] = fReversed[maxrev-2 +i]/(maxamp -ped); | |
110 | } | |
111 | ||
3b8fd9fe | 112 | |
a9ebbc7a | 113 | double amp = (maxamp - ped)*fNeuralNet->Value( 0, fNNInput[0], fNNInput[1], fNNInput[2], fNNInput[3], fNNInput[4]); |
3b8fd9fe | 114 | double tof = (fNeuralNet->Value( 1, fNNInput[0], fNNInput[1], fNNInput[2], fNNInput[3], fNNInput[4]) + timebinOffset ) ; |
e37e3c84 | 115 | |
2cd0ffda | 116 | // use local-array time for chi2 estimate |
117 | chi2 = CalculateChi2(amp, tof-timebinOffset+maxrev, first, last); | |
118 | ndf = last - first - 1; // nsamples - 2 | |
168c7b3c | 119 | return AliCaloFitResults( maxamp, ped , Ret::kFitPar, amp , tof, timebinOffset, chi2, ndf, |
120 | Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) ); | |
e37e3c84 | 121 | |
122 | } | |
123 | } | |
2cd0ffda | 124 | chi2 = CalculateChi2(maxf, maxrev, first, last); |
125 | ndf = last - first - 1; // nsamples - 2 | |
168c7b3c | 126 | return AliCaloFitResults( maxamp, ped, Ret::kCrude, maxf, timebinOffset, |
127 | timebinOffset, chi2, ndf, Ret::kDummy, AliCaloFitSubarray(index, maxrev, first, last) ); | |
2cd0ffda | 128 | |
e37e3c84 | 129 | } |
130 | ||
e37e3c84 | 131 |