LCOV - code coverage report
Current view: top level - EMCAL/EMCALraw - AliCaloRawAnalyzerNN.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 48 2.1 %
Date: 2016-06-14 17:26:59 Functions: 1 7 14.3 %

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

Generated by: LCOV version 1.11