]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSSanityInspector.cxx
- changes to make the clusterisation work for EMCAL
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSSanityInspector.cxx
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 ClassImp(AliHLTPHOSSanityInspector);
35
36
37 AliHLTPHOSSanityInspector::AliHLTPHOSSanityInspector() : 
38   //  AliHLTPHOSBase(),
39   fMaxDifference(120)
40 {
41   //See header file for documentation
42 }
43
44
45 AliHLTPHOSSanityInspector::~AliHLTPHOSSanityInspector()
46 {
47   //See header file for documentation
48 }
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   for(Int_t i = 1; i < N; i++)
58     {
59       if((((Int_t)data[i] - (Int_t)data[i-1]) > fMaxDifference) || (((Int_t)data[i-1] - (Int_t)data[i]) > fMaxDifference))
60         return 1;
61     }
62   return 0;
63 }
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   if(N > 3)
88     {
89       if((((Short_t)data[0] - (Short_t)data[1]) > fMaxDifference) || (((Short_t)data[1] - (Short_t)data[0]) > fMaxDifference))
90         return -1;
91       if((((Short_t)data[1] - (Short_t)data[2]) > fMaxDifference) || (((Short_t)data[2] - (Short_t)data[1]) > fMaxDifference))
92         return -1;
93
94
95       for(Short_t i = 2; i < N - 3; i++)
96         {
97           if((((Short_t)data[i] - (Short_t)data[i+1]) > fMaxDifference) || (((Short_t)data[i+1] - (Short_t)data[i]) > fMaxDifference))
98             {
99               i++;
100               if((((Short_t)data[i] -(Short_t)data[i+1]) > fMaxDifference) || (((Short_t)data[i+1] - (Short_t)data[i]) > fMaxDifference))
101                 {
102                   i++;
103                   if((((Short_t)data[i] - (Short_t)data[i+1]) > fMaxDifference) || (((Short_t)data[i+1] - (Short_t)data[i]) > fMaxDifference))
104                     {
105                       return -2;  //Too crazy
106                     }
107                   data[i-1] = ((Short_t)data[i] + (Short_t)data[i-2])/2;
108                   crazyness++;
109                 }
110               else 
111                 return -3;    //Two spikes in a row? 
112             }
113         }
114       
115       
116       
117       if((((Short_t)data[N - 3] -(Short_t) data[N - 2]) > fMaxDifference) || 
118          (((Short_t)data[N - 2] - (Short_t)data[N - 3]) > fMaxDifference))
119         {
120           if((((Short_t)data[N - 2] - (Short_t)data[N - 1]) > fMaxDifference) || 
121              (((Short_t)data[N - 1] - (Short_t)data[N - 2]) > fMaxDifference))
122             {
123               data[N - 2] = ((Short_t)data[N - 3] +  (Short_t)data[N - 1])/2;
124               return crazyness++;
125             }
126           return -4;
127
128         }
129       
130       if((((Short_t)data[N - 2] - (Short_t)data[N - 1]) > fMaxDifference) || 
131          (((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           data[N - 1] = data[N - 2];
135           return crazyness++;
136         }
137       
138     }
139   
140   return crazyness;
141   
142 }