]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSMapSDD.cxx
Cleaning up memory in destructor
[u/mrichter/AliRoot.git] / ITS / AliITSMapSDD.cxx
index 6e19e6c2bb840eeca8721876b2a12a02c99594d7..70c8eb6b62c55ed3a7431a00cd4a5581d316a487 100644 (file)
@@ -25,6 +25,7 @@
 #include "TH1F.h"
 #include "TH2F.h"
 #include "AliITSMapSDD.h"
+#include "AliITSCorrMap1DSDD.h"
 
 ClassImp(AliITSMapSDD)
 //______________________________________________________________________
@@ -54,19 +55,34 @@ void AliITSMapSDD::SetMap(TH2F* hmap){
   // with anodes on x axis and drift dist. on y axis
   for(Int_t iAn=0;iAn<fgkNAnodPts; iAn++){
     for(Int_t iDr=0;iDr<fgkNDrifPts; iDr++){
-      fMap[iAn][iDr]=hmap->GetBinContent(iAn+1,iDr+1);
+      SetCellContent(iAn,iDr,hmap->GetBinContent(iAn+1,iDr+1));
     }
   }
 }
 //______________________________________________________________________
+Float_t AliITSMapSDD::GetCorrection(Float_t z, Float_t x, AliITSsegmentationSDD *seg){
+  // returns correction in cm starting from local coordinates on the module
+  const Double_t kMicronTocm = 1.0e-4; 
+  Int_t nAnodes=seg->Npz();
+  Int_t nAnodesHybrid=seg->NpzHalf();
+  Int_t bina =(Int_t) seg->GetAnodeFromLocal(x,z);
+  if(bina>nAnodes)  AliError("Wrong anode anumber!");
+  if(bina>=nAnodesHybrid) bina-=nAnodesHybrid;
+  Float_t stept = seg->Dx()*kMicronTocm/(Float_t)fgkNDrifPts;
+  Int_t bint = TMath::Abs((Int_t)(x/stept));
+  if(bint==fgkNDrifPts) bint-=1;
+  if(bint>=fgkNDrifPts) AliError("Wrong bin number along drift direction!");
+  return kMicronTocm*GetCellContent(bina,bint);
+}
+//______________________________________________________________________
 TH2F* AliITSMapSDD::GetMapHisto() const{
   // Returns a TH2F histogram with map of residuals
-  Char_t hname[50];
-  sprintf(hname,"h%s",GetName());
-  TH2F* hmap=new TH2F(hname,"",fgkNAnodPts,-0.5,255.5,fgkNDrifPts,0.,35.);
+  TString hname;
+  hname.Form("h%s",GetName());
+  TH2F* hmap=new TH2F(hname.Data(),"",fgkNAnodPts,-0.5,255.5,fgkNDrifPts,0.,35.);
   for(Int_t iAn=0;iAn<fgkNAnodPts; iAn++){
     for(Int_t iDr=0;iDr<fgkNDrifPts; iDr++){
-      hmap->SetBinContent(iAn+1,iDr+1,fMap[iAn][iDr]);
+      hmap->SetBinContent(iAn+1,iDr+1,GetCellContent(iAn,iDr));
     }
   }
   return hmap;
@@ -74,13 +90,24 @@ TH2F* AliITSMapSDD::GetMapHisto() const{
 //______________________________________________________________________
 TH1F* AliITSMapSDD::GetResidualDistr(Float_t dmin, Float_t dmax) const{
   // Returns a TH1F histogram with distribution of residual
-  Char_t hname[50];
-  sprintf(hname,"hd%s",GetName());
-  TH1F* hd=new TH1F(hname,"",100,dmin,dmax);
+  TString hname;
+  hname.Form("hd%s",GetName());
+  TH1F* hd=new TH1F(hname.Data(),"",100,dmin,dmax);
   for(Int_t iAn=0;iAn<fgkNAnodPts; iAn++){
     for(Int_t iDr=0;iDr<fgkNDrifPts; iDr++){
-      hd->Fill(fMap[iAn][iDr]);
+      hd->Fill(GetCellContent(iAn,iDr));
     }
   }
   return hd;
 }
+//______________________________________________________________________
+AliITSCorrMapSDD* AliITSMapSDD::ConvertToNewFormat() const{
+  // convert correction map to new format  
+  Char_t* name=(Char_t*)GetName();
+  AliITSCorrMapSDD* newmap=new AliITSCorrMap1DSDD(name,fgkNDrifPts);
+  for(Int_t i=0; i<fgkNDrifPts; i++){
+    newmap->SetCellContent(0,i,GetCellContent(0,i));
+  }
+  return newmap;
+}
+