]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Data quality monitoring (Oystein)
authorphille <phille@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 15 Oct 2007 15:56:39 +0000 (15:56 +0000)
committerphille <phille@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 15 Oct 2007 15:56:39 +0000 (15:56 +0000)
HLT/PHOS/AliHLTPHOSSanityInspector.cxx [new file with mode: 0644]
HLT/PHOS/AliHLTPHOSSanityInspector.h [new file with mode: 0644]

diff --git a/HLT/PHOS/AliHLTPHOSSanityInspector.cxx b/HLT/PHOS/AliHLTPHOSSanityInspector.cxx
new file mode 100644 (file)
index 0000000..6214e28
--- /dev/null
@@ -0,0 +1,247 @@
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * All rights reserved.                                                   *
+ *                                                                        *
+ * Primary Authors: Oystein Djuvsland                                     *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          * 
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+#include "AliHLTPHOSSanityInspector.h"
+#include "AliHLTAltroData.h"
+#include "Rtypes.h"
+
+ClassImp(AliHLTPHOSSanityInspector);
+
+
+AliHLTPHOSSanityInspector::AliHLTPHOSSanityInspector() : 
+  AliHLTPHOSBase(),
+  fMaxDifference(120)
+{
+}
+
+
+AliHLTPHOSSanityInspector::~AliHLTPHOSSanityInspector()
+{
+}
+
+
+Int_t  
+AliHLTPHOSSanityInspector::CheckInsanity(UInt_t* data, Int_t N)
+{
+  for(Int_t i = 1; i < N; i++)
+    {
+      if((((Int_t)data[i] - (Int_t)data[i-1]) > fMaxDifference) || (((Int_t)data[i-1] - (Int_t)data[i]) > fMaxDifference))
+       return 1;
+    }
+  return 0;
+}
+
+Int_t
+AliHLTPHOSSanityInspector::CheckInsanity(Int_t* data, Int_t N)
+{
+  for(Int_t i = 1; i < N; i++)
+  {
+    if((((Int_t)data[i] - (Int_t)data[i-1]) > fMaxDifference) || (((Int_t)data[i-1] - (Int_t)data[i]) > fMaxDifference))
+      return 1;
+  }
+  return 0;
+}
+
+
+Int_t 
+AliHLTPHOSSanityInspector::CheckAndHealInsanity(UInt_t* data, Int_t N)
+//
+{
+  Int_t crazyness = 0;
+  
+  /*  if(((data[0] - data[1]) > fMaxDifference) || ((data[1] - data[0]) > fMaxDifference))
+    {
+      if(((data[1] - data[2]) > fMaxDifference) || ((data[2] - data[1]) > fMaxDifference))
+       {
+         if(((data[2] - data[3]) > fMaxDifference) || ((data[3] - data[2]) > fMaxDifference))
+           {
+             return false;   //To much crazyness!
+           }
+         data[1] = (data[2] + data[0])/2;
+         crazyness++;
+       }
+    }
+  */
+  if(N > 3)
+    {
+      //Require a stable start 
+      if((((Int_t)data[0] - (Int_t)data[1]) > fMaxDifference) || (((Int_t)data[1] - (Int_t)data[0]) > fMaxDifference))
+       return -1;
+      if((((Int_t)data[1] - (Int_t)data[2]) > fMaxDifference) || (((Int_t)data[2] - (Int_t)data[1]) > fMaxDifference))
+       return -1;
+      /*
+       for(Int_t i = 2; i < altroData->fDataSize - 3; i++)
+       {
+       if(((data[i] - data[i+1]) > fMaxDifference) || ((data[i+1] - data[i]) > fMaxDifference))
+       {
+       if(((data[i+1] - data[i+2]) > fMaxDifference) || ((data[i+2] - data[i+1]) > fMaxDifference))
+       {
+       if(((data[i+2] - data[i+3]) > fMaxDifference) || ((data[i+3] - data[i+2]) > fMaxDifference))
+       {
+       return false;  //To0 crazy
+       }
+       data[i+1] = (data[i+2] + data[i])/2;
+       crazyness++;
+       }
+       else 
+       return false;   
+       }
+       }
+      */
+      for(Int_t i = 2; i < N - 3; i++)
+       {
+         if((((Int_t)data[i] - (Int_t)data[i+1]) > fMaxDifference) || (((Int_t)data[i+1] - (Int_t)data[i]) > fMaxDifference))
+           {
+             i++;
+             if((((Int_t)data[i] -(Int_t)data[i+1]) > fMaxDifference) || (((Int_t)data[i+1] - (Int_t)data[i]) > fMaxDifference))
+               {
+                 i++;
+                 if((((Int_t)data[i] - (Int_t)data[i+1]) > fMaxDifference) || (((Int_t)data[i+1] - (Int_t)data[i]) > fMaxDifference))
+                   {
+                     return -2;  //Too crazy
+                   }
+                 data[i-1] = ((Int_t)data[i] + (Int_t)data[i-2])/2;
+                 crazyness++;
+               }
+             else 
+               return -3;    //Two spikes in a row? 
+           }
+       }
+      
+      
+      
+      if((((Int_t)data[N - 3] -(Int_t) data[N - 2]) > fMaxDifference) || 
+        (((Int_t)data[N - 2] - (Int_t)data[N - 3]) > fMaxDifference))
+       {
+         if((((Int_t)data[N - 2] - (Int_t)data[N - 1]) > fMaxDifference) || 
+            (((Int_t)data[N - 1] - (Int_t)data[N - 2]) > fMaxDifference))
+           {
+             data[N - 2] = ((Int_t)data[N - 3] +  (Int_t)data[N - 1])/2;
+             return crazyness++;
+           }
+         return -4;
+
+       }
+      
+      if((((Int_t)data[N - 2] - (Int_t)data[N - 1]) > fMaxDifference) || 
+        (((Int_t)data[N - 1] - (Int_t)data[N - 2]) > fMaxDifference))
+       {
+         //      (Int_t)data[N - 3] = (Int_t)data[N - 4] -(Int_t) data[N - 5] + (Int_t)data[N-4];
+         data[N - 1] = data[N - 2];
+         return crazyness++;
+       }
+      
+    }
+  
+  return crazyness;
+  
+}
+Int_t 
+    AliHLTPHOSSanityInspector::CheckAndHealInsanity(Int_t* data, Int_t N)
+    //
+{
+  Int_t crazyness = 0;
+  
+  /*  if(((data[0] - data[1]) > fMaxDifference) || ((data[1] - data[0]) > fMaxDifference))
+  {
+  if(((data[1] - data[2]) > fMaxDifference) || ((data[2] - data[1]) > fMaxDifference))
+  {
+  if(((data[2] - data[3]) > fMaxDifference) || ((data[3] - data[2]) > fMaxDifference))
+  {
+  return false;   //To much crazyness!
+}
+  data[1] = (data[2] + data[0])/2;
+  crazyness++;
+}
+}
+  */
+  if(N > 3)
+  {
+      //Require a stable start 
+    if((((Int_t)data[0] - (Int_t)data[1]) > fMaxDifference) || (((Int_t)data[1] - (Int_t)data[0]) > fMaxDifference))
+      return -1;
+    if((((Int_t)data[1] - (Int_t)data[2]) > fMaxDifference) || (((Int_t)data[2] - (Int_t)data[1]) > fMaxDifference))
+      return -1;
+      /*
+    for(Int_t i = 2; i < altroData->fDataSize - 3; i++)
+    {
+    if(((data[i] - data[i+1]) > fMaxDifference) || ((data[i+1] - data[i]) > fMaxDifference))
+    {
+    if(((data[i+1] - data[i+2]) > fMaxDifference) || ((data[i+2] - data[i+1]) > fMaxDifference))
+    {
+    if(((data[i+2] - data[i+3]) > fMaxDifference) || ((data[i+3] - data[i+2]) > fMaxDifference))
+    {
+    return false;  //To0 crazy
+  }
+    data[i+1] = (data[i+2] + data[i])/2;
+    crazyness++;
+  }
+    else 
+    return false;   
+  }
+  }
+      */
+    for(Int_t i = 2; i < N - 3; i++)
+    {
+      if((((Int_t)data[i] - (Int_t)data[i+1]) > fMaxDifference) || (((Int_t)data[i+1] - (Int_t)data[i]) > fMaxDifference))
+      {
+       i++;
+       if((((Int_t)data[i] -(Int_t)data[i+1]) > fMaxDifference) || (((Int_t)data[i+1] - (Int_t)data[i]) > fMaxDifference))
+       {
+         i++;
+         if((((Int_t)data[i] - (Int_t)data[i+1]) > fMaxDifference) || (((Int_t)data[i+1] - (Int_t)data[i]) > fMaxDifference))
+         {
+           return -2;  //Too crazy
+         }
+         data[i-1] = ((Int_t)data[i] + (Int_t)data[i-2])/2;
+         crazyness++;
+       }
+       else 
+         return -3;    //Two spikes in a row? 
+      }
+    }
+      
+      
+      
+    if((((Int_t)data[N - 3] -(Int_t) data[N - 2]) > fMaxDifference) || 
+         (((Int_t)data[N - 2] - (Int_t)data[N - 3]) > fMaxDifference))
+    {
+      if((((Int_t)data[N - 2] - (Int_t)data[N - 1]) > fMaxDifference) || 
+           (((Int_t)data[N - 1] - (Int_t)data[N - 2]) > fMaxDifference))
+      {
+       data[N - 2] = ((Int_t)data[N - 3] +  (Int_t)data[N - 1])/2;
+       return crazyness++;
+      }
+      return -4;
+
+    }
+      
+    if((((Int_t)data[N - 2] - (Int_t)data[N - 1]) > fMaxDifference) || 
+         (((Int_t)data[N - 1] - (Int_t)data[N - 2]) > fMaxDifference))
+    {
+         //      (Int_t)data[N - 3] = (Int_t)data[N - 4] -(Int_t) data[N - 5] + (Int_t)data[N-4];
+      data[N - 1] = data[N - 2];
+      return crazyness++;
+    }
+      
+  }
+  
+  return crazyness;
+  
+}
diff --git a/HLT/PHOS/AliHLTPHOSSanityInspector.h b/HLT/PHOS/AliHLTPHOSSanityInspector.h
new file mode 100644 (file)
index 0000000..6ad29a5
--- /dev/null
@@ -0,0 +1,45 @@
+/**************************************************************************
+ * This file is property of and copyright by the ALICE HLT Project        * 
+ * All rights reserved.                                                   *
+ *                                                                        *
+ * Primary Authors: Oystein Djuvsland                                     *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          * 
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+#ifndef ALIHLTPHOSSANITYINSPECTOR_H
+#define ALIHLTPHOSSANITYINSPECTOR_H
+
+#include "AliHLTPHOSBase.h"
+#include "AliHLTAltroData.h"
+#include "Rtypes.h"
+
+class AliHLTPHOSSanityInspector : public AliHLTPHOSBase
+{
+  
+public:
+  AliHLTPHOSSanityInspector();
+  
+  virtual ~AliHLTPHOSSanityInspector();
+   
+  Int_t CheckInsanity(UInt_t*, Int_t);
+  Int_t CheckInsanity(Int_t*, Int_t);
+  
+  Int_t CheckAndHealInsanity(UInt_t*, Int_t);  //Not completely reliable
+  Int_t CheckAndHealInsanity(Int_t*, Int_t);  //Not completely reliable
+
+  void SetMaxDifference(Int_t maxDiff) { fMaxDifference = maxDiff; }
+    
+private:
+  Int_t fMaxDifference;
+  ClassDef(AliHLTPHOSSanityInspector, 1);
+};
+
+#endif