]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/PHOS/AliHLTPHOSSanityInspector.cxx
renaming function to avoid library conflict (discovered in test/generators/TUHKMgen)
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSSanityInspector.cxx
CommitLineData
1b41ab20 1// $Id$
2
3ed012c1 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
2374af72 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
3ed012c1 31#include "AliHLTPHOSSanityInspector.h"
3ed012c1 32#include "Rtypes.h"
33
34ClassImp(AliHLTPHOSSanityInspector);
35
36
37AliHLTPHOSSanityInspector::AliHLTPHOSSanityInspector() :
9f050726 38 // AliHLTPHOSBase(),
3ed012c1 39 fMaxDifference(120)
40{
2374af72 41 //See header file for documentation
3ed012c1 42}
43
44
45AliHLTPHOSSanityInspector::~AliHLTPHOSSanityInspector()
46{
2374af72 47 //See header file for documentation
3ed012c1 48}
49
50
939c67e7 51
e304ea31 52Int_t
a535ef8b 53AliHLTPHOSSanityInspector::CheckInsanity(const UShort_t* data, const Int_t N) const
3ed012c1 54{
2374af72 55 //See header file for documentation
56
3ed012c1 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
2374af72 65/*
66Int_t
67AliHLTPHOSSanityInspector::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*/
3ed012c1 78
79
80Int_t
a535ef8b 81AliHLTPHOSSanityInspector::CheckAndHealInsanity(UShort_t* data, Int_t N)
3ed012c1 82{
2374af72 83 //See header file for documentation
84
3ed012c1 85 Int_t crazyness = 0;
939c67e7 86
3ed012c1 87 if(N > 3)
88 {
a535ef8b 89 if((((Short_t)data[0] - (Short_t)data[1]) > fMaxDifference) || (((Short_t)data[1] - (Short_t)data[0]) > fMaxDifference))
3ed012c1 90 return -1;
a535ef8b 91 if((((Short_t)data[1] - (Short_t)data[2]) > fMaxDifference) || (((Short_t)data[2] - (Short_t)data[1]) > fMaxDifference))
3ed012c1 92 return -1;
939c67e7 93
94
a535ef8b 95 for(Short_t i = 2; i < N - 3; i++)
3ed012c1 96 {
a535ef8b 97 if((((Short_t)data[i] - (Short_t)data[i+1]) > fMaxDifference) || (((Short_t)data[i+1] - (Short_t)data[i]) > fMaxDifference))
3ed012c1 98 {
99 i++;
a535ef8b 100 if((((Short_t)data[i] -(Short_t)data[i+1]) > fMaxDifference) || (((Short_t)data[i+1] - (Short_t)data[i]) > fMaxDifference))
3ed012c1 101 {
102 i++;
a535ef8b 103 if((((Short_t)data[i] - (Short_t)data[i+1]) > fMaxDifference) || (((Short_t)data[i+1] - (Short_t)data[i]) > fMaxDifference))
3ed012c1 104 {
105 return -2; //Too crazy
106 }
a535ef8b 107 data[i-1] = ((Short_t)data[i] + (Short_t)data[i-2])/2;
3ed012c1 108 crazyness++;
109 }
110 else
111 return -3; //Two spikes in a row?
112 }
113 }
114
115
116
a535ef8b 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))
3ed012c1 119 {
a535ef8b 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))
3ed012c1 122 {
a535ef8b 123 data[N - 2] = ((Short_t)data[N - 3] + (Short_t)data[N - 1])/2;
3ed012c1 124 return crazyness++;
125 }
126 return -4;
127
128 }
129
a535ef8b 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))
3ed012c1 132 {
a535ef8b 133 // (Short_t)data[N - 3] = (Short_t)data[N - 4] -(Short_t) data[N - 5] + (Short_t)data[N-4];
939c67e7 134 data[N - 1] = data[N - 2];
135 return crazyness++;
136 }
3ed012c1 137
939c67e7 138 }
3ed012c1 139
140 return crazyness;
141
142}