From: cblume Date: Mon, 5 Oct 2009 09:34:22 +0000 (+0000) Subject: Move to THnSparse instead of TH2F to reduce memory size X-Git-Url: http://git.uio.no/git/?a=commitdiff_plain;h=ba94744acf3b2b1a1af2b247bc3c38cb356c4a91;p=u%2Fmrichter%2FAliRoot.git Move to THnSparse instead of TH2F to reduce memory size --- diff --git a/TRD/AliTRDCalibraVdriftLinearFit.cxx b/TRD/AliTRDCalibraVdriftLinearFit.cxx index 9f1d8bc9bfa..b872fe70b74 100644 --- a/TRD/AliTRDCalibraVdriftLinearFit.cxx +++ b/TRD/AliTRDCalibraVdriftLinearFit.cxx @@ -35,6 +35,8 @@ #include #include #include +#include + //header file #include "AliTRDCalibraVdriftLinearFit.h" @@ -49,9 +51,9 @@ AliTRDCalibraVdriftLinearFit::AliTRDCalibraVdriftLinearFit() : /*FOLD00*/ fLinearFitterPArray(540), fLinearFitterEArray(540) { - // - // default constructor - // + // + // default constructor + // } //_____________________________________________________________________ AliTRDCalibraVdriftLinearFit::AliTRDCalibraVdriftLinearFit(const AliTRDCalibraVdriftLinearFit &ped) : /*FOLD00*/ @@ -65,18 +67,18 @@ AliTRDCalibraVdriftLinearFit::AliTRDCalibraVdriftLinearFit(const AliTRDCalibraVd // copy constructor // for (Int_t idet = 0; idet < 540; idet++){ + const TVectorD *vectorE = (TVectorD*)ped.fLinearFitterEArray.UncheckedAt(idet); const TVectorD *vectorP = (TVectorD*)ped.fLinearFitterPArray.UncheckedAt(idet); - const TH2F *hped = (TH2F*)ped.fLinearFitterHistoArray.UncheckedAt(idet); + const THnSparseS *hped = (THnSparseS*)ped.fLinearFitterHistoArray.UncheckedAt(idet); if ( vectorE != 0x0 ) fLinearFitterEArray.AddAt(new TVectorD(*vectorE), idet); if ( vectorP != 0x0 ) fLinearFitterPArray.AddAt(new TVectorD(*vectorP), idet); if ( hped != 0x0 ){ - TH2F *hNew = new TH2F(*hped); - hNew->SetDirectory(0); + THnSparseS *hNew = (THnSparseS *)hped->Clone(); + //hNew->SetDirectory(0); fLinearFitterHistoArray.AddAt(hNew,idet); } - } } //_____________________________________________________________________ @@ -91,10 +93,10 @@ AliTRDCalibraVdriftLinearFit::AliTRDCalibraVdriftLinearFit(const TObjArray &obja // constructor from a TObjArray // for (Int_t idet = 0; idet < 540; idet++){ - const TH2F *hped = (TH2F*)obja.UncheckedAt(idet); + const THnSparseS *hped = (THnSparseS*)obja.UncheckedAt(idet); if ( hped != 0x0 ){ - TH2F *hNew = new TH2F(*hped); - hNew->SetDirectory(0); + THnSparseS *hNew = (THnSparseS *)hped->Clone(); + //hNew->SetDirectory(0); fLinearFitterHistoArray.AddAt(hNew,idet); } } @@ -133,13 +135,12 @@ void AliTRDCalibraVdriftLinearFit::Copy(TObject &c) const // Copy only the histos for (Int_t idet = 0; idet < 540; idet++){ if(fLinearFitterHistoArray.UncheckedAt(idet)){ - TH2F *hped1 = target.GetLinearFitterHisto(idet,kTRUE); - hped1->SetDirectory(0); - hped1->Add((const TH1F *)fLinearFitterHistoArray.UncheckedAt(idet)); + THnSparseS *hped1 = (THnSparseS *)target.GetLinearFitterHisto(idet,kTRUE); + //hped1->SetDirectory(0); + hped1->Add((const THnSparseS *)fLinearFitterHistoArray.UncheckedAt(idet)); } - } - + TObject::Copy(c); } @@ -160,22 +161,22 @@ Long64_t AliTRDCalibraVdriftLinearFit::Merge(const TCollection* list) // collection of generated histograms Int_t count=0; while((obj = iter->Next()) != 0) - { - AliTRDCalibraVdriftLinearFit* entry = dynamic_cast(obj); - if (entry == 0) continue; - - // Copy only the histos - for (Int_t idet = 0; idet < 540; idet++){ - if(entry->GetLinearFitterHisto(idet)){ - TH2F *hped1 = GetLinearFitterHisto(idet,kTRUE); - hped1->SetDirectory(0); - hped1->Add(entry->GetLinearFitterHisto(idet)); + { + AliTRDCalibraVdriftLinearFit* entry = dynamic_cast(obj); + if (entry == 0) continue; + + // Copy only the histos + for (Int_t idet = 0; idet < 540; idet++){ + if(entry->GetLinearFitterHisto(idet)){ + THnSparseS *hped1 = (THnSparseS *)GetLinearFitterHisto(idet,kTRUE); + Double_t entriesa = hped1->GetEntries(); + Double_t entriesb = ((THnSparseS *)entry->GetLinearFitterHisto(idet))->GetEntries(); + if((entriesa + entriesb) < 5*32767) hped1->Add(entry->GetLinearFitterHisto(idet)); + } } + count++; } - - count++; - } return count; } @@ -189,28 +190,26 @@ void AliTRDCalibraVdriftLinearFit::Add(AliTRDCalibraVdriftLinearFit *ped) fVersion++; for (Int_t idet = 0; idet < 540; idet++){ - const TH2F *hped = (TH2F*)ped->GetLinearFitterHisto(idet); + const THnSparseS *hped = (THnSparseS*)ped->GetLinearFitterHisto(idet); //printf("idet %d\n",idet); if ( hped != 0x0 ){ //printf("add\n"); - TH2F *hped1 = GetLinearFitterHisto(idet,kTRUE); - //printf("test2\n"); - hped1->SetDirectory(0); - //printf("test4\n"); - hped1->Add(hped); - //printf("test3\n"); + THnSparseS *hped1 = (THnSparseS *)GetLinearFitterHisto(idet,kTRUE); + Double_t entriesa = hped1->GetEntries(); + Double_t entriesb = hped->GetEntries(); + if((entriesa + entriesb) < 5*32767) hped1->Add(hped); } } } //______________________________________________________________________________________ -TH2F* AliTRDCalibraVdriftLinearFit::GetLinearFitterHisto(Int_t detector, Bool_t force) +THnSparse* AliTRDCalibraVdriftLinearFit::GetLinearFitterHisto(Int_t detector, Bool_t force) { // // return pointer to TH2F histo // if force is true create a new histo if it doesn't exist allready // if ( !force || fLinearFitterHistoArray.UncheckedAt(detector) ) - return (TH2F*)fLinearFitterHistoArray.UncheckedAt(detector); + return (THnSparse*)fLinearFitterHistoArray.UncheckedAt(detector); // if we are forced and TLinearFitter doesn't yes exist create it @@ -219,15 +218,36 @@ TH2F* AliTRDCalibraVdriftLinearFit::GetLinearFitterHisto(Int_t detector, Bool_t name += detector; name += "version"; name += fVersion; + + //create the map + Int_t thnDim[2]; + thnDim[0] = 36; + thnDim[1] = 48; + + //arrays for lower bounds : + Double_t* binEdges[2]; + for(Int_t ivar = 0; ivar < 2; ivar++) + binEdges[ivar] = new Double_t[thnDim[ivar] + 1]; + + //values for bin lower bounds + for(Int_t i=0; i<=thnDim[0]; i++) binEdges[0][i]= -0.9 + (2*0.9)/thnDim[0]*(Double_t)i; + for(Int_t i=0; i<=thnDim[1]; i++) binEdges[1][i]= -1.2 + (2*1.2)/thnDim[1]*(Double_t)i; + + THnSparseS *lfdv = new THnSparseS((const Char_t *)name,(const Char_t *) name,2,thnDim); + + for (int k=0; k<2; k++) { + lfdv->SetBinEdges(k,binEdges[k]); + } + lfdv->Sumw2(); - TH2F *lfdv = new TH2F((const Char_t *)name,(const Char_t *) name - ,18,-0.9,0.9,24 - ,-1.2,1.2); - lfdv->SetXTitle("tan(phi_{track})"); - lfdv->SetYTitle("dy/dt"); - lfdv->SetZTitle("Number of clusters"); - lfdv->SetStats(0); - lfdv->SetDirectory(0); + //TH2F *lfdv = new TH2F((const Char_t *)name,(const Char_t *) name + // ,18,-0.9,0.9,24 + // ,-1.2,1.2); + //lfdv->SetXTitle("tan(phi_{track})"); + //lfdv->SetYTitle("dy/dt"); + //lfdv->SetZTitle("Number of clusters"); + //lfdv->SetStats(0); + //lfdv->SetDirectory(0); fLinearFitterHistoArray.AddAt(lfdv,detector); return lfdv; @@ -272,8 +292,11 @@ void AliTRDCalibraVdriftLinearFit::Update(Int_t detector, Float_t tnp, Float_t p // // Fill the 2D histos for debugging // - - ((TH2F *) GetLinearFitterHisto(detector,kTRUE))->Fill(tnp,pars1); + Double_t entries[2] = {tnp,pars1}; + + THnSparseS *h = ((THnSparseS *) GetLinearFitterHisto(detector,kTRUE)); + Double_t nbentries = h->GetEntries(); + if(nbentries < 5*32767) h->Fill(&entries[0]); } //____________Functions fit Online CH2d________________________________________ @@ -291,10 +314,13 @@ void AliTRDCalibraVdriftLinearFit::FillPEArray() // Loop over histos for(Int_t cb = 0; cb < 540; cb++){ - const TH2F *linearfitterhisto = (TH2F*)fLinearFitterHistoArray.UncheckedAt(cb); + const THnSparseS *linearfitterh = (THnSparseS*)fLinearFitterHistoArray.UncheckedAt(cb); //printf("Processing the detector cb %d we find %d\n",cb, (Bool_t) linearfitterhisto); - if ( linearfitterhisto != 0 ){ + if ( linearfitterh != 0 ){ + + TH2D *linearfitterhisto = linearfitterh->Projection(1,0); + // Fill a linearfitter TAxis *xaxis = linearfitterhisto->GetXaxis(); @@ -332,7 +358,10 @@ void AliTRDCalibraVdriftLinearFit::FillPEArray() fLinearFitterEArray.AddAt(parE,cb); //par->Print(); //parE->Print(); - } + } + + delete linearfitterhisto; + }// if something } diff --git a/TRD/AliTRDCalibraVdriftLinearFit.h b/TRD/AliTRDCalibraVdriftLinearFit.h index bc0aaf2ec0c..9b5c7fc7f29 100644 --- a/TRD/AliTRDCalibraVdriftLinearFit.h +++ b/TRD/AliTRDCalibraVdriftLinearFit.h @@ -17,7 +17,7 @@ //class TVectorD; class TObjArray; -class TH2F; +class THnSparse; class TTreeSRedirector; class AliTRDCalibraVdriftLinearFit : public TObject { @@ -36,7 +36,7 @@ class AliTRDCalibraVdriftLinearFit : public TObject { void Update(Int_t detector, Float_t tnp, Float_t pars1); void FillPEArray(); void Add(AliTRDCalibraVdriftLinearFit *ped); - TH2F *GetLinearFitterHisto(Int_t detector, Bool_t force=kFALSE); + THnSparse *GetLinearFitterHisto(Int_t detector, Bool_t force=kFALSE); Bool_t GetParam(Int_t detector, TVectorD *param); Bool_t GetError(Int_t detector, TVectorD *error); @@ -52,6 +52,7 @@ class AliTRDCalibraVdriftLinearFit : public TObject { TObjArray fLinearFitterPArray; // Array of result parameters from linear fitters for the detectors TObjArray fLinearFitterEArray; // Array of result errors from linear fitters for the detectors + ClassDef(AliTRDCalibraVdriftLinearFit,1) // Online Vdrift calibration }; @@ -59,3 +60,4 @@ class AliTRDCalibraVdriftLinearFit : public TObject { #endif + diff --git a/TRD/qaRec/AliTRDcalibration.cxx b/TRD/qaRec/AliTRDcalibration.cxx index 91f90ee4858..7f5516ed014 100644 --- a/TRD/qaRec/AliTRDcalibration.cxx +++ b/TRD/qaRec/AliTRDcalibration.cxx @@ -41,6 +41,7 @@ #include "TStyle.h" #include "TLegend.h" #include "TGraphErrors.h" +#include "THnSparse.h" #include "AliTRDrecoTask.h" #include "AliAnalysisManager.h" @@ -615,13 +616,13 @@ case kCH2DVector:{ break; } AliTRDCalibraVdriftLinearFit *h = 0x0; - TH2F *hdetector = 0x0; + THnSparseS *hdetector = 0x0; if(!(h = (AliTRDCalibraVdriftLinearFit *)fContainer->FindObject("AliTRDCalibraVdriftLinearFit"))) break; Double_t entries[540]; for(Int_t k = 0; k < 540; k++){ entries[k] = 0.0; hdetector = 0x0; - if(!(hdetector = h->GetLinearFitterHisto(k,kFALSE))) continue; + if(!(hdetector = (THnSparseS *)h->GetLinearFitterHisto(k,kFALSE))) continue; entries[k] = hdetector->GetEntries(); } Double_t max = -10.0; @@ -634,7 +635,7 @@ case kCH2DVector:{ } hdetector = 0x0; if((max == 0.0) || (detectormax <0.0) || (detectormax >=540.0)) break; - if(!(hdetector = h->GetLinearFitterHisto((Int_t)detectormax,kFALSE))) break; + if(!(hdetector = (THnSparseS *)h->GetLinearFitterHisto((Int_t)detectormax,kFALSE))) break; AliInfo(Form("The detector with the maximum of entries is %d",detectormax)); hdetector->Draw(); return kTRUE;