ALIROOT-5559 - reducing Memory jump in the AliTPCcalibAlign::Streamer
authormivanov <marian.ivanov@cern.ch>
Mon, 11 Aug 2014 10:49:17 +0000 (12:49 +0200)
committermivanov <marian.ivanov@cern.ch>
Mon, 11 Aug 2014 10:49:17 +0000 (12:49 +0200)
Missing - back comaptibility - in old data THn and THnSparse not read

AliTPCcalibAlign.h    - make THn non streamable (streamed as separate object)
AliTPCcalibAlign.cxx  - custom stremaer to Read/Write separatelly THn and THnSparse
test/UnitTest.C       - extend UnitTest for the AliTPCcalibAlign

TPC/Calib/AliTPCcalibAlign.cxx
TPC/Calib/AliTPCcalibAlign.h
TPC/Calib/test/UnitTest.C

index 49f232a..d0770f2 100644 (file)
@@ -1615,11 +1615,7 @@ void AliTPCcalibAlign::MakeResidualHistos(){
   // 4 - local   kz
   // 
   axisName[0]="delta";   axisTitle[0]="#Delta (cm)"; 
-  if (TMath::Abs(AliTracker::GetBz())<0.01){
-    binsTrack[0]=60;       xminTrack[0]=-1.2;        xmaxTrack[0]=1.2; 
-  }else{
-    binsTrack[0]=60;       xminTrack[0]=-0.6;        xmaxTrack[0]=0.6; 
-  }
+  binsTrack[0]=60;       xminTrack[0]=-0.6;        xmaxTrack[0]=0.6; 
   //
   axisName[1]="sector";   axisTitle[1]="Sector Number"; 
   binsTrack[1]=180;       xminTrack[1]=0;        xmaxTrack[1]=18; 
@@ -3818,123 +3814,131 @@ void AliTPCcalibAlign::MakeReportDyPhi(TFile */*output*/){
 }
 
 
+void AliTPCcalibAlign::Streamer(TBuffer &R__b)
+{
+  // Stream an object of class AliTPCcalibAlign.
+  Bool_t isDebug=AliLog::GetDebugLevel("","AliTPCcalibAlign")>0;
+  if (isDebug) AliSysInfo::SetVerbose(kTRUE);
+  
+  if (R__b.IsReading()) {
+    R__b.ReadClassBuffer(AliTPCcalibAlign::Class(),this);    
+    if (gDirectory){
+      for (Int_t i=0; i<2; ++i){
+       TString hisName=TString::Format("AliTPCcalibAlign.%s.fClusterDelta_%d",GetName(),i);
+       if (gDirectory->Get(hisName.Data())){
+         fClusterDelta[i] = dynamic_cast<THn*>(gDirectory->Get((hisName).Data()));
+       }
+      }
+    
+      for (Int_t i=0; i<4; ++i){
+       TString hisName=TString::Format("AliTPCcalibAlign.%s.fTrackletDelta_%d",GetName(),i);
+       if (gDirectory->Get(hisName.Data())){
+         fTrackletDelta[i] = dynamic_cast<THnSparse*>(gDirectory->Get((hisName).Data()));
+       }
+      }
+    }
+  } else {    
+    if (isDebug) AliSysInfo::AddStamp("aliengStreamer::Start");
+    R__b.WriteClassBuffer(AliTPCcalibAlign::Class(),this);    
+    if (isDebug) AliSysInfo::AddStamp("alignStreamer::DefaultStreamer");
+    //
+    for (Int_t i=0; i<2; ++i){
+      if (fClusterDelta[i]) fClusterDelta[i]->Write(TString::Format("AliTPCcalibAlign.%s.fClusterDelta_%d",GetName(),i).Data());
+    }
+    if (isDebug) AliSysInfo::AddStamp("alignStreamer::fClusterDelta");
+    //
+    for (Int_t i=0; i<4; ++i){
+      if (fTrackletDelta[i]) fTrackletDelta[i]->Write(TString::Format("AliTPCcalibAlign.%s.fTrackletDelta_%d",GetName(),i).Data());
+    }
+    if (isDebug) AliSysInfo::AddStamp("alignStreamer::fTrackletDelta");
+    //
+  }
+}
+
+
+
+// //______________________________________________________________________________
 // void AliTPCcalibAlign::Streamer(TBuffer &R__b)
 // {
 //   // Stream an object of class AliTPCcalibAlign.
+
 //   Bool_t isDebug=AliLog::GetDebugLevel("","AliTPCcalibAlign")>0;
 //   if (isDebug) AliSysInfo::SetVerbose(kTRUE);
-  
 //   if (R__b.IsReading()) {
+//     // Read the class using the automatic streamer. Might be wrong
+//     R__b.ReadClassBuffer(AliTPCcalibAlign::Class(),this);
 //     for (Int_t i=0; i<2; ++i){
 //       if (gDirectory){
-//     TString hisName=TString::Format("AliTPCcalibAlign.fClusterDelta[%d]",i);
+//     TString hisName=TString::Format("fClusterDelta[%d]",i);
 //     if (gDirectory->Get(hisName.Data())){
 //       fClusterDelta[i] = dynamic_cast<THn*>(gDirectory->Get((hisName).Data()));
 //     }
 //       }
 //     }
-//     R__b.ReadClassBuffer(AliTPCcalibAlign::Class(),this);
-//   } else {    
-//     if (isDebug) AliSysInfo::AddStamp("AliTPCcalibAlign::Streame::Start");
-//     //
+//   } else {
+//     // R__b.WriteClassBuffer(AliTPCcalibAlign::Class(),this);
+//     if (isDebug) AliSysInfo::AddStamp("Start");
+//     R__b.WriteVersion(AliTPCcalibAlign::IsA());
+//     if (isDebug) AliSysInfo::AddStamp("Version");
+//     AliTPCcalibBase::Streamer(R__b); // Stream the base class
+//     if (isDebug) AliSysInfo::AddStamp("BaseClass");
+    
+//     //    for (Int_t i=0; i<2; ++i)
+//     //  R__b << fClusterDelta[i];
 //     for (Int_t i=0; i<2; ++i){
-//       if (fClusterDelta[i]) fClusterDelta[i]->Write(TString::Format("fClusterDelta_%d",i).Data());
-//     }
-//     if (isDebug) AliSysInfo::AddStamp("AliTPCcalibAlign::Streamer::fClusterDelta");
-//     //
-//     for (Int_t i=0; i<4; ++i){
-//       if (fTrackletDelta[i]) fTrackletDelta[i]->Write(TString::Format("fTrackletDelta_%d",i).Data());
+//       if (fClusterDelta[i]) fClusterDelta[i]->Write(TString::Format("fClusterDelta[%d]",i).Data());
 //     }
-//     if (isDebug) AliSysInfo::AddStamp("AliTPCcalibAlign::Streamer::fTrackletDelta");
-//     //
-//     R__b.WriteClassBuffer(AliTPCcalibAlign::Class(),this);    
-//   }
-// }
-
-
-
-//______________________________________________________________________________
-void AliTPCcalibAlign::Streamer(TBuffer &R__b)
-{
-  // Stream an object of class AliTPCcalibAlign.
-
-  Bool_t isDebug=AliLog::GetDebugLevel("","AliTPCcalibAlign")>0;
-  if (isDebug) AliSysInfo::SetVerbose(kTRUE);
-  if (R__b.IsReading()) {
-    // Read the class using the automatic streamer. Might be wrong
-    R__b.ReadClassBuffer(AliTPCcalibAlign::Class(),this);
-    for (Int_t i=0; i<2; ++i){
-      if (gDirectory){
-       TString hisName=TString::Format("fClusterDelta[%d]",i);
-       if (gDirectory->Get(hisName.Data())){
-         fClusterDelta[i] = dynamic_cast<THn*>(gDirectory->Get((hisName).Data()));
-       }
-      }
-    }
-  } else {
-    // R__b.WriteClassBuffer(AliTPCcalibAlign::Class(),this);
-    if (isDebug) AliSysInfo::AddStamp("Start");
-    R__b.WriteVersion(AliTPCcalibAlign::IsA());
-    if (isDebug) AliSysInfo::AddStamp("Version");
-    AliTPCcalibBase::Streamer(R__b); // Stream the base class
-    if (isDebug) AliSysInfo::AddStamp("BaseClass");
     
-    //    for (Int_t i=0; i<2; ++i)
-    //  R__b << fClusterDelta[i];
-    for (Int_t i=0; i<2; ++i){
-      if (fClusterDelta[i]) fClusterDelta[i]->Write(TString::Format("fClusterDelta[%d]",i).Data());
-    }
+//     if (isDebug) AliSysInfo::AddStamp("THn");
     
-    if (isDebug) AliSysInfo::AddStamp("THn");
+//     for (Int_t i=0; i<4; ++i)
+//       R__b << fTrackletDelta[i];
+//     if (isDebug) AliSysInfo::AddStamp("THnSparse");
     
-    for (Int_t i=0; i<4; ++i)
-      R__b << fTrackletDelta[i];
-    if (isDebug) AliSysInfo::AddStamp("THnSparse");
-    
-    fDphiHistArray.Streamer(R__b);
-    fDthetaHistArray.Streamer(R__b);
-    fDyHistArray.Streamer(R__b);
-    fDzHistArray.Streamer(R__b);
+//     fDphiHistArray.Streamer(R__b);
+//     fDthetaHistArray.Streamer(R__b);
+//     fDyHistArray.Streamer(R__b);
+//     fDzHistArray.Streamer(R__b);
 
-    fDyPhiHistArray.Streamer(R__b);
-    fDzThetaHistArray.Streamer(R__b);
+//     fDyPhiHistArray.Streamer(R__b);
+//     fDzThetaHistArray.Streamer(R__b);
     
-    fDphiZHistArray.Streamer(R__b);
-    fDthetaZHistArray.Streamer(R__b);
-    fDyZHistArray.Streamer(R__b);
-    fDzZHistArray.Streamer(R__b);
+//     fDphiZHistArray.Streamer(R__b);
+//     fDthetaZHistArray.Streamer(R__b);
+//     fDyZHistArray.Streamer(R__b);
+//     fDzZHistArray.Streamer(R__b);
     
-    fFitterArray12.Streamer(R__b);
-    fFitterArray9.Streamer(R__b);
-    fFitterArray6.Streamer(R__b);
+//     fFitterArray12.Streamer(R__b);
+//     fFitterArray9.Streamer(R__b);
+//     fFitterArray6.Streamer(R__b);
     
-    fMatrixArray12.Streamer(R__b);
-    fMatrixArray9.Streamer(R__b);
-    fMatrixArray6.Streamer(R__b);
+//     fMatrixArray12.Streamer(R__b);
+//     fMatrixArray9.Streamer(R__b);
+//     fMatrixArray6.Streamer(R__b);
     
-    fCombinedMatrixArray6.Streamer(R__b);
-    if (isDebug) AliSysInfo::AddStamp("ObjArrays1");
+//     fCombinedMatrixArray6.Streamer(R__b);
+//     if (isDebug) AliSysInfo::AddStamp("ObjArrays1");
     
-    R__b.WriteFastArray(fPoints,72*72);
-    if (isDebug) AliSysInfo::AddStamp("Points");
-    R__b << fNoField;
-    R__b << fXIO;
-    R__b << fXmiddle;
-    R__b << fXquadrant;
-    if (isDebug) AliSysInfo::AddStamp("Floats");
+//     R__b.WriteFastArray(fPoints,72*72);
+//     if (isDebug) AliSysInfo::AddStamp("Points");
+//     R__b << fNoField;
+//     R__b << fXIO;
+//     R__b << fXmiddle;
+//     R__b << fXquadrant;
+//     if (isDebug) AliSysInfo::AddStamp("Floats");
     
-    fArraySectorIntParam.Streamer(R__b);
-    fArraySectorIntCovar.Streamer(R__b);
-    if (isDebug) AliSysInfo::AddStamp("ObjArrays2");
+//     fArraySectorIntParam.Streamer(R__b);
+//     fArraySectorIntCovar.Streamer(R__b);
+//     if (isDebug) AliSysInfo::AddStamp("ObjArrays2");
     
-    R__b << fSectorParamA;
-    R__b << fSectorCovarA;
-    R__b << fSectorParamC;
-    R__b << fSectorCovarC;
-    if (isDebug) AliSysInfo::AddStamp("TMatrixD");
+//     R__b << fSectorParamA;
+//     R__b << fSectorCovarA;
+//     R__b << fSectorParamC;
+//     R__b << fSectorCovarC;
+//     if (isDebug) AliSysInfo::AddStamp("TMatrixD");
     
-    R__b << fUseInnerOuter;
-    R__b << fgkMergeEntriesCut; // Should we write the static member?
-    if (isDebug) AliSysInfo::AddStamp("End");
-  }
-}
+//     R__b << fUseInnerOuter;
+//     R__b << fgkMergeEntriesCut; // Should we write the static member?
+//     if (isDebug) AliSysInfo::AddStamp("End");
+//   }
+// }
index 9cf738c..9eeeb5d 100644 (file)
@@ -147,8 +147,8 @@ public:
 
   static void SetMergeEntriesCut(Double_t entriesCut){fgkMergeEntriesCut = entriesCut;}
 protected:
-  THn     *fClusterDelta[2];  //clusters residuals
-  THnSparse     *fTrackletDelta[4]; //track residuals
+  THn     *fClusterDelta[2];  // !clusters residuals
+  THnSparse     *fTrackletDelta[4]; //!track residuals
 
   TObjArray fDphiHistArray;    // array of residual histograms  phi      -kPhi
   TObjArray fDthetaHistArray;  // array of residual histograms  theta    -kTheta
@@ -206,7 +206,7 @@ protected:
 private:
   AliTPCcalibAlign&  operator=(const AliTPCcalibAlign&);// not implemented
 
-  ClassDef(AliTPCcalibAlign,6)
+  ClassDef(AliTPCcalibAlign,7)
 };
 
 
index 97307cc..03bab3c 100644 (file)
@@ -15,6 +15,8 @@
 #include "TTree.h"
 #include "AliLog.h"
 #include "THn.h"
+#include "TRandom.h"
+
 
 const Double_t kAlmost0=1.e-13;
 
@@ -74,30 +76,72 @@ void UnitTestF1Plane(){
 
 void UnitTestAliTPCcalibAlignStreamer(const char *fname="/hera/alice/local/benchmark/vAN-20140518/000128503/cpass1/CalibObjects.root"){
   //
-  // 0.) ReadPart
-  // 
+  // test streamer of the AliTPCcalibAlign::Streamer
+  //   0.) Read old data part
+  //   1.) Fill part 
+  //   2.) Write part
+  //   3.) Read back - consistency check
+  //   4.) Destructor check
+  //   5.) Memory usage print
+  //
   AliLog::SetClassDebugLevel("AliTPCcalibAlign",1);
+  AliTPCcalibAlign * align=0;
+  Int_t nPoints=1000000;
+  //
+  //  0.) Read old data part
+  //
   TFile *fin= TFile::Open(fname);
-  AliSysInfo::AddStamp("LoadFile");
-  AliTPCcalibAlign * align = (AliTPCcalibAlign * )fin->Get("TPCAlign/alignTPC");
-  AliSysInfo::AddStamp("LoadAlign");
-  AliTPCcalibLaser * laser = (AliTPCcalibLaser * )fin->Get("TPCAlign/laserTPC");
-  AliSysInfo::AddStamp("LoadLaser");
-  TTree * tree =AliSysInfo::MakeTree("syswatch.log");
-  tree->Scan("sname:deltaVM:VM:pI.fMemResident","","colsize=30");
-  fin->Close();
-  delete fin;
-  //
-  // 1.) Write part
+  if (fin){
+    AliSysInfo::AddStamp("LoadFile");
+    align = (AliTPCcalibAlign * )fin->Get("TPCAlign/alignTPC");
+    AliSysInfo::AddStamp("LoadAlign");
+    fin->Close();
+    delete fin;
+    if (align->GetClusterDelta(0)==NULL){
+      ::Error("UnitTestAliTPCcalibAlignStreamer","Not back compatible class- GetClusterDelta");
+      align->MakeResidualHistos();    
+    }
+    if (align->GetTrackletDelta(0)==NULL){
+      ::Error("UnitTestAliTPCcalibAlignStreamer","Not back compatible class- GetTrackletDelta");
+      align->MakeResidualHistosTracklet();
+    }
+  }else{
+  }
+
+
+  //
+  // 1.) Fill part test
+  //
+  for (Int_t ipoint=0; ipoint<nPoints; ipoint++){
+    Double_t xxx[10]={0};
+    for (Int_t ihis=0; ihis<2; ihis++){
+      THn* his = align->GetClusterDelta(ihis);
+      for (Int_t iaxis=0; iaxis<his->GetNdimensions(); iaxis++) {
+       xxx[iaxis]=his->GetAxis(iaxis)->GetXmin()+gRandom->Rndm()*(his->GetAxis(iaxis)->GetXmax()-his->GetAxis(iaxis)->GetXmin());
+      }
+      his->Fill(xxx);
+    }
+    for (Int_t ihis=0; ihis<4; ihis++){
+      THnSparse* his = align->GetTrackletDelta(ihis);
+      for (Int_t iaxis=0; iaxis<his->GetNdimensions(); iaxis++) {
+       xxx[iaxis]=his->GetAxis(iaxis)->GetXmin()+gRandom->Rndm()*(his->GetAxis(iaxis)->GetXmax()-his->GetAxis(iaxis)->GetXmin());
+      }
+      his->Fill(xxx);
+    }
+  } 
+  AliSysInfo::AddStamp("FillTrees");
+  //
+  // 2.) Write part
   //
   TFile * fout=new TFile("testAliTPCcalibAlignStreamer.root","recreate");
+  AliSysInfo::AddStamp("WriteAlignStart");
   align->Write("alignTPC"); 
-  AliSysInfo::AddStamp("WriteAlign");
+  AliSysInfo::AddStamp("WriteAlignEnd");
   fout->ls();
   fout->Close();
   delete fout;
   //
-  // 2.) read back
+  // 3.) Read back - consistency check
   //
   fin=new TFile("testAliTPCcalibAlignStreamer.root");
   AliTPCcalibAlign * align2 = (AliTPCcalibAlign *)fin->Get("alignTPC");  
@@ -127,19 +171,17 @@ void UnitTestAliTPCcalibAlignStreamer(const char *fname="/hera/alice/local/bench
     ::Fatal("UnitTestAliTPCcalibAlignStreamer","histogram with different entries");
   }
   //
-  // 3.) delete 
+  // 4.) Destructor check
   //
   delete align2;
   AliSysInfo::AddStamp("deleteAlign2");
-  delete laser;
-  AliSysInfo::AddStamp("deleteLaser");
   delete align;
   AliSysInfo::AddStamp("deleteAlign");
   //
-  // 4.) Check memory
+  // 5.) Memory usage print
   //
-  tree =AliSysInfo::MakeTree("syswatch.log");
-  tree->Scan("sname:deltaVM:VM:pI.fMemResident","","colsize=25");
+  TTree * treeSys =AliSysInfo::MakeTree("syswatch.log");
+  treeSys->Scan("sname:deltaVM:VM:pI.fMemResident","","colsize=30:15:15:20");
 
 }