ATO-98 AliTPCBoundaryVoltError::AddCorrectionCompact implemented and test included
authormivanov <marian.ivanov@cern.ch>
Sun, 14 Dec 2014 13:01:23 +0000 (14:01 +0100)
committermivanov <marian.ivanov@cern.ch>
Sun, 14 Dec 2014 13:01:23 +0000 (14:01 +0100)
TPC/Base/AliTPCBoundaryVoltError.cxx
TPC/Base/AliTPCBoundaryVoltError.h
TPC/Base/test/UnitTest.C

index 4ec62a7..dfa621d 100644 (file)
@@ -103,6 +103,37 @@ AliTPCBoundaryVoltError::~AliTPCBoundaryVoltError() {
 
 
 
+
+Bool_t AliTPCBoundaryVoltError::AddCorrectionCompact(AliTPCCorrection* corr, Double_t weight){
+  //
+  // Add correction  and make them compact
+  // Assumptions:
+  //  - origin of distortion/correction are additive
+  //  - only correction ot the same type supported ()
+  if (corr==NULL) {
+    AliError("Zerro pointer - correction");
+    return kFALSE;
+  }  
+  AliTPCBoundaryVoltError* corrC = dynamic_cast<AliTPCBoundaryVoltError *>(corr);
+  if (corrC == NULL) {
+    AliError(TString::Format("Inconsistent class types: %s\%s",IsA()->GetName(),corr->IsA()->GetName()).Data());
+    return kFALSE;
+  }
+  if (fROCdisplacement!=corrC->fROCdisplacement){
+    AliError(TString::Format("Inconsistent fROCdisplacement : %s\%s",IsA()->GetName(),corr->IsA()->GetName()).Data());
+    return kFALSE;    
+  }
+  for (Int_t i=0;i <8; i++){
+    fBoundariesA[i]+= corrC->fBoundariesA[i]*weight;
+    fBoundariesC[i]+= corrC->fBoundariesC[i]*weight;
+  }
+  //
+  return kTRUE;
+}
+
+
+
+
 void AliTPCBoundaryVoltError::Init() {
   //
   // Initialization funtion
index 595c0be..b1bf6d3 100644 (file)
@@ -17,7 +17,7 @@ class AliTPCBoundaryVoltError : public AliTPCCorrection {
 public:
   AliTPCBoundaryVoltError();
   virtual ~AliTPCBoundaryVoltError();
-
+  virtual Bool_t AddCorrectionCompact(AliTPCCorrection* corr, Double_t weight);
   // initialization and update functions
   virtual void Init();
   virtual void Update(const TTimeStamp &timeStamp);
index de020b8..2c6ffc8 100644 (file)
@@ -8,6 +8,7 @@
   TestCorrection_AliTPCExBTwistAddCorrectionCompact();
   TestCorrection_AliTPCFCVoltError3DAddCorrectionCompact();
   TestCorrection_AliTPCRocVoltError3DAddCorrectionCompact();
+  TestCorrection_AliTPCBoundaryVoltErrorAddCorrectionCompact();
 
 */
 
@@ -28,8 +29,8 @@
 #include "AliTPCExBTwist.h"
 #include "AliTPCFCVoltError3D.h"
 #include "AliTPCROCVoltError3D.h"
-//#include "AliTPCBoundaryVoltError.h"
-
+#include "AliTPCBoundaryVoltError.h"
 //
 // PARAMETERS to set from outside:
 //
@@ -285,3 +286,68 @@ Bool_t  TestCorrection_AliTPCRocVoltError3DAddCorrectionCompact(){
   }    
   return res;
 } 
+
+
+
+
+
+Bool_t  TestCorrection_AliTPCBoundaryVoltErrorAddCorrectionCompact(){
+  //
+  // AliTPCBoundaryVoltErrorAddCorrectionCompact
+  //
+  const Float_t kEpsilon=0.00000001;
+  Bool_t isOK[10]={kTRUE,kTRUE,kTRUE,kTRUE,kTRUE,kTRUE};
+  AliTPCComposedCorrection *compCorrBoundaryVoltError = new AliTPCComposedCorrection();
+  AliTPCBoundaryVoltError  *corr0    = new  AliTPCBoundaryVoltError;
+  AliTPCBoundaryVoltError  *corr1    = new  AliTPCBoundaryVoltError;
+  Float_t boundaries[8];
+  for (Int_t ibound=0; ibound<8; ibound++){ 
+    boundaries[ibound]=gRandom->Rndm()-0.5;
+  }
+  corr0->SetBoundariesA(boundaries);
+  corr1->SetBoundariesA(boundaries);  
+  //
+  isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr0,1);
+  isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr1,1);
+  isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr1,-1);
+  isOK[0]&=compCorrBoundaryVoltError->AddCorrectionCompact(corr0,-1);
+  isOK[1]=compCorrBoundaryVoltError->GetCorrections()->GetEntries()==1;
+  AliTPCBoundaryVoltError  *corrRes=0;
+  if (isOK[1]==kFALSE){
+    isOK[2]=kFALSE;
+    isOK[3]=kFALSE;
+    isOK[4]=kFALSE;
+  }else{
+    corrRes=  dynamic_cast<AliTPCBoundaryVoltError *>(compCorrBoundaryVoltError->GetSubCorrection(0));
+    if (corrRes==NULL){
+      isOK[2]=kFALSE;
+      isOK[3]=kFALSE;
+      isOK[4]=kFALSE;
+    }else{
+      for (Int_t ibound=0; ibound<8; ibound++){ 
+       isOK[3]&=TMath::Abs(corrRes->GetBoundariesA(ibound))<kEpsilon;
+       isOK[3]&=TMath::Abs(corrRes->GetBoundariesC(ibound))<kEpsilon;
+      }
+    }
+  }
+  Bool_t res=kTRUE;
+  for (Int_t i=0; i<5; i++) res&=isOK[i];
+  {
+    if (isOK[0]==kFALSE){
+      ::Error("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError -ADD FAILED");
+    }else{
+      ::Info("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError -ADD OK");
+    }
+    if (isOK[1]==kFALSE){
+      ::Error("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError - wrong entries  FAILED");
+    }else{
+      ::Info("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError - entries  OK");
+    }
+    if (isOK[2]==kFALSE || isOK[3]==kFALSE ||isOK[4]==kFALSE ){
+      ::Error("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError - inconsitent entries  FAILED");    
+    }else{
+      ::Info("TestCorrection_AddCorrectionCompact","AliTPCBoundaryVoltError - consistent entries  OK");    
+    }
+  }    
+  return res;
+}