LCOV - code coverage report
Current view: top level - HLT/PHOS - AliHLTPHOSSanityInspector.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 40 2.5 %
Date: 2016-06-14 17:26:59 Functions: 1 8 12.5 %

          Line data    Source code
       1             : // $Id$
       2             : 
       3             : /**************************************************************************
       4             :  * This file is property of and copyright by the ALICE HLT Project        * 
       5             :  * All rights reserved.                                                   *
       6             :  *                                                                        *
       7             :  * Primary Authors: Oystein Djuvsland                                     *
       8             :  *                                                                        *
       9             :  * Permission to use, copy, modify and distribute this software and its   *
      10             :  * documentation strictly for non-commercial purposes is hereby granted   *
      11             :  * without fee, provided that the above copyright notice appears in all   *
      12             :  * copies and that both the copyright notice and this permission notice   *
      13             :  * appear in the supporting documentation. The authors make no claims     *
      14             :  * about the suitability of this software for any purpose. It is          * 
      15             :  * provided "as is" without express or implied warranty.                  *
      16             :  **************************************************************************/
      17             : 
      18             : /** 
      19             :  * @file   AliHLTPHOSSanityInspector.cxx
      20             :  * @author Oystein Djuvsland
      21             :  * @date 
      22             :  * @brief  Sanity inspector for PHOS HLT 
      23             :  */
      24             : 
      25             : // see header file for class documentation
      26             : // or
      27             : // refer to README to build package
      28             : // or
      29             : // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
      30             : 
      31             : #include "AliHLTPHOSSanityInspector.h"
      32             : #include "Rtypes.h"
      33             : 
      34           6 : ClassImp(AliHLTPHOSSanityInspector);
      35             : 
      36             : 
      37             : AliHLTPHOSSanityInspector::AliHLTPHOSSanityInspector() : 
      38             :   //  AliHLTPHOSBase(),
      39           0 :   fMaxDifference(120)
      40           0 : {
      41             :   //See header file for documentation
      42           0 : }
      43             : 
      44             : 
      45             : AliHLTPHOSSanityInspector::~AliHLTPHOSSanityInspector()
      46           0 : {
      47             :   //See header file for documentation
      48           0 : }
      49             : 
      50             : 
      51             : 
      52             : Int_t  
      53             : AliHLTPHOSSanityInspector::CheckInsanity(const UShort_t* data, const Int_t N) const
      54             : {
      55             :    //See header file for documentation
      56             : 
      57           0 :   for(Int_t i = 1; i < N; i++)
      58             :     {
      59           0 :       if((((Int_t)data[i] - (Int_t)data[i-1]) > fMaxDifference) || (((Int_t)data[i-1] - (Int_t)data[i]) > fMaxDifference))
      60           0 :         return 1;
      61             :     }
      62           0 :   return 0;
      63           0 : }
      64             : 
      65             : /*
      66             : Int_t
      67             : AliHLTPHOSSanityInspector::CheckInsanity(Int_t* data, Int_t N)
      68             : {
      69             :    //See header file for documentation
      70             :   for(Int_t i = 1; i < N; i++)
      71             :   {
      72             :     if((((Int_t)data[i] - (Int_t)data[i-1]) > fMaxDifference) || (((Int_t)data[i-1] - (Int_t)data[i]) > fMaxDifference))
      73             :       return 1;
      74             :   }
      75             :   return 0;
      76             : }
      77             : */
      78             : 
      79             : 
      80             : Int_t 
      81             : AliHLTPHOSSanityInspector::CheckAndHealInsanity(UShort_t* data, Int_t N)
      82             : {
      83             :    //See header file for documentation
      84             : 
      85             :   Int_t crazyness = 0;
      86             : 
      87           0 :   if(N > 3)
      88             :     {
      89           0 :       if((((Short_t)data[0] - (Short_t)data[1]) > fMaxDifference) || (((Short_t)data[1] - (Short_t)data[0]) > fMaxDifference))
      90           0 :         return -1;
      91           0 :       if((((Short_t)data[1] - (Short_t)data[2]) > fMaxDifference) || (((Short_t)data[2] - (Short_t)data[1]) > fMaxDifference))
      92           0 :         return -1;
      93             : 
      94             : 
      95           0 :       for(Short_t i = 2; i < N - 3; i++)
      96             :         {
      97           0 :           if((((Short_t)data[i] - (Short_t)data[i+1]) > fMaxDifference) || (((Short_t)data[i+1] - (Short_t)data[i]) > fMaxDifference))
      98             :             {
      99           0 :               i++;
     100           0 :               if((((Short_t)data[i] -(Short_t)data[i+1]) > fMaxDifference) || (((Short_t)data[i+1] - (Short_t)data[i]) > fMaxDifference))
     101             :                 {
     102           0 :                   i++;
     103           0 :                   if((((Short_t)data[i] - (Short_t)data[i+1]) > fMaxDifference) || (((Short_t)data[i+1] - (Short_t)data[i]) > fMaxDifference))
     104             :                     {
     105           0 :                       return -2;  //Too crazy
     106             :                     }
     107           0 :                   data[i-1] = ((Short_t)data[i] + (Short_t)data[i-2])/2;
     108           0 :                   crazyness++;
     109             :                 }
     110             :               else 
     111           0 :                 return -3;    //Two spikes in a row? 
     112           0 :             }
     113             :         }
     114             :       
     115             :       
     116             :       
     117           0 :       if((((Short_t)data[N - 3] -(Short_t) data[N - 2]) > fMaxDifference) || 
     118           0 :          (((Short_t)data[N - 2] - (Short_t)data[N - 3]) > fMaxDifference))
     119             :         {
     120           0 :           if((((Short_t)data[N - 2] - (Short_t)data[N - 1]) > fMaxDifference) || 
     121           0 :              (((Short_t)data[N - 1] - (Short_t)data[N - 2]) > fMaxDifference))
     122             :             {
     123           0 :               data[N - 2] = ((Short_t)data[N - 3] +  (Short_t)data[N - 1])/2;
     124           0 :               return crazyness++;
     125             :             }
     126           0 :           return -4;
     127             : 
     128             :         }
     129             :       
     130           0 :       if((((Short_t)data[N - 2] - (Short_t)data[N - 1]) > fMaxDifference) || 
     131           0 :          (((Short_t)data[N - 1] - (Short_t)data[N - 2]) > fMaxDifference))
     132             :         {
     133             :           //      (Short_t)data[N - 3] = (Short_t)data[N - 4] -(Short_t) data[N - 5] + (Short_t)data[N-4];
     134           0 :           data[N - 1] = data[N - 2];
     135           0 :           return crazyness++;
     136             :         }
     137             :       
     138             :     }
     139             :   
     140           0 :   return crazyness;
     141             :   
     142           0 : }

Generated by: LCOV version 1.11