]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
coding violation fixes
authorekman <ekman@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 29 May 2006 08:15:58 +0000 (08:15 +0000)
committerekman <ekman@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 29 May 2006 08:15:58 +0000 (08:15 +0000)
PWG0/CorrectionMatrix2D.cxx
PWG0/CorrectionMatrix2D.h

index cfeac34a47e928784761a1ba99b0feb186080547..69019b9972c6bf2c8e555eab3c5b312453d34d6a 100644 (file)
@@ -1,3 +1,11 @@
+// ------------------------------------------------------
+//
+// Class to handle 2d-corrections. 
+//
+// ------------------------------------------------------
+//
+
+
 /* $Id$ */
 
 #include "CorrectionMatrix2D.h"
 //____________________________________________________________________
 ClassImp(CorrectionMatrix2D)
 
+//____________________________________________________________________
+CorrectionMatrix2D::CorrectionMatrix2D(const CorrectionMatrix2D& c) 
+  : TNamed(c)
+{
+  // copy constructor
+  ((CorrectionMatrix2D &)c).Copy(*this);
+}
+
 //____________________________________________________________________
 CorrectionMatrix2D::CorrectionMatrix2D(Char_t* name, Char_t* title,
                                       Int_t nBinX, Float_t Xmin, Float_t Xmax,
                                       Int_t nBinY, Float_t Ymin, Float_t Ymax) 
   : TNamed(name, title)
 {
+  //
+  // constructor
+  //
+
 
-  fhMeas  = new TH2F(Form("meas_%s",name), Form("meas_%s",title),  nBinX, Xmin, Xmax, nBinY, Ymin, Ymax);
-  fhGene  = new TH2F(Form("gene_%s",name), Form("gene_%s",title),  nBinX, Xmin, Xmax, nBinY, Ymin, Ymax);
-  fhCorr  = new TH2F(Form("corr_%s",name), Form("corr_%s",title),  nBinX, Xmin, Xmax, nBinY, Ymin, Ymax);
-  fhRatio = new TH2F(Form("ratio_%s",name),Form("ratio_%s",title), nBinX, Xmin, Xmax, nBinY, Ymin, Ymax);
+  fhMeas  = new TH2F(Form("meas",name), Form("meas_%s",title),  nBinX, Xmin, Xmax, nBinY, Ymin, Ymax);
+  fhGene  = new TH2F(Form("gene",name), Form("gene_%s",title),  nBinX, Xmin, Xmax, nBinY, Ymin, Ymax);
+  fhCorr  = new TH2F(Form("corr",name), Form("corr_%s",title),  nBinX, Xmin, Xmax, nBinY, Ymin, Ymax);
+  fhRatio = new TH2F(Form("ratio",name),Form("ratio_%s",title), nBinX, Xmin, Xmax, nBinY, Ymin, Ymax);
 }
 
 //____________________________________________________________________
 CorrectionMatrix2D::CorrectionMatrix2D(Char_t* name,Char_t* title, 
                                       Int_t nBinX, Float_t *X, Int_t nBinY, Float_t *Y) 
-  : TNamed(name, title)
+  : TNamed(name, title) 
 {
-  fhMeas  = new TH2F(Form("meas_%s",name), Form("meas_%s",title),  nBinX, X, nBinY, Y);
-  fhGene  = new TH2F(Form("gene_%s",name), Form("gene_%s",title),  nBinX, X, nBinY, Y);
-  fhCorr  = new TH2F(Form("corr_%s",name), Form("corr_%s",title),  nBinX, X, nBinY, Y);
-  fhRatio = new TH2F(Form("ratio_%s",name),Form("ratio_%s",title), nBinX, X, nBinY, Y);
+  //
+  // constructor
+  //
+
+  fhMeas  = new TH2F(Form("meas",name), Form("meas_%s",title),  nBinX, X, nBinY, Y);
+  fhGene  = new TH2F(Form("gene",name), Form("gene_%s",title),  nBinX, X, nBinY, Y);
+  fhCorr  = new TH2F(Form("corr",name), Form("corr_%s",title),  nBinX, X, nBinY, Y);
+  fhRatio = new TH2F(Form("ratio",name),Form("ratio_%s",title), nBinX, X, nBinY, Y);
 }
 
 
 //____________________________________________________________________
 CorrectionMatrix2D::~CorrectionMatrix2D() {
-  // Destructor
+  //
+  // destructor
   //
   if (fhMeas)  delete fhMeas;
-  if (fhGene)  delete fhCorr;
-  if (fhRatio) delete fhRatio;
+  if (fhGene)  delete fhGene;
   if (fhCorr)  delete fhCorr;
+  if (fhRatio) delete fhRatio;
+}
+
+//____________________________________________________________________
+CorrectionMatrix2D &CorrectionMatrix2D::operator=(const CorrectionMatrix2D &c)
+{
+  // assigment operator
+
+  if (this != &c) 
+    ((CorrectionMatrix2D &) c).Copy(*this);
+
+  return *this;
+}
+
+//____________________________________________________________________
+void
+CorrectionMatrix2D::Copy(TObject& c) const 
+{
+  // copy function
+
+  CorrectionMatrix2D& target = (CorrectionMatrix2D &) c;
+
+  target.fhMeas  = fhMeas;
+  target.fhGene  = fhGene;
+  target.fhCorr  = fhCorr;
+  target.fhRatio = fhRatio;  
+
 }
 
 
 //________________________________________________________________________
 void CorrectionMatrix2D::SetAxisTitles(Char_t* titleX, Char_t* titleY) 
 { 
+  //
+  // method for setting the axis titles of the histograms
+  //
+
   fhMeas ->SetXTitle(titleX);  fhMeas ->SetYTitle(titleY);
   fhGene ->SetXTitle(titleX);  fhGene ->SetYTitle(titleY);
   fhCorr ->SetXTitle(titleX);  fhCorr ->SetYTitle(titleY);
@@ -53,38 +108,23 @@ void CorrectionMatrix2D::SetAxisTitles(Char_t* titleX, Char_t* titleY)
 
 //____________________________________________________________________
 void CorrectionMatrix2D::Finish() {  
+  //
+  // finish method
+  //
+  // divide the histograms
+  // 
 
-if (!fhMeas || !fhGene)  return;
+  if (!fhMeas || !fhGene)  return; 
 
   fhRatio->Divide(fhMeas, fhGene, 1,1,"B");
   fhCorr->Divide(fhGene, fhMeas, 1,1,"B");
-
-  Int_t nBinsVtx = fhCorr->GetNbinsX();
-  Int_t nBinsEta = fhCorr->GetNbinsY();
-
-  TH2F* tmp = (TH2F*)fhCorr->Clone("tmp");
-
-  // cut at 0.2
-  for (Int_t bx=0; bx<=nBinsVtx; bx++) {
-    for (Int_t by=0; by<=nBinsEta; by++) {
-      if (tmp->GetBinContent(bx,by)<0.2) {
-       fhCorr->SetBinContent(bx,by,0);
-       fhCorr->SetBinError(bx,by,0);
-       
-       tmp->SetBinContent(bx,by,0);
-      }
-      else 
-       tmp->SetBinContent(bx,by,1);
-    }
-  }
   
 }
 
 //____________________________________________________________________
 void
-CorrectionMatrix2D::RemoveEdges(Float_t cut, Int_t nBinsXedge, Int_t nBinsYedge) {
-
+CorrectionMatrix2D::RemoveEdges(Float_t cut, Int_t nBinsXedge, Int_t nBinsYedge) 
+{
   // remove edges of correction histogram by removing 
   // - bins with content less than cut
   // - bins next to bins with zero bin content
@@ -145,13 +185,15 @@ CorrectionMatrix2D::RemoveEdges(Float_t cut, Int_t nBinsXedge, Int_t nBinsYedge)
 
 //____________________________________________________________________
 Bool_t CorrectionMatrix2D::LoadHistograms(Char_t* fileName, Char_t* dir) {
-
+  //
+  // loads the histograms from a file
+  //
+  
   TFile* fin = TFile::Open(fileName);  
   
-  if(!fin) 
-  {
+  if(!fin) {
     //Info("LoadHistograms",Form(" %s file does not exist",fileName));
-  return kFALSE;
+    return kFALSE;
   }
   
   if(fhGene)  {delete fhGene;  fhGene=0;}
@@ -176,6 +218,9 @@ Bool_t CorrectionMatrix2D::LoadHistograms(Char_t* fileName, Char_t* dir) {
 //____________________________________________________________________
 void
 CorrectionMatrix2D::SaveHistograms() {
+  //
+  // saves the histograms 
+  //
 
   gDirectory->mkdir(fName.Data());
   gDirectory->cd(fName.Data());
@@ -195,6 +240,10 @@ CorrectionMatrix2D::SaveHistograms() {
 //____________________________________________________________________
 void CorrectionMatrix2D::DrawHistograms()
 {
+  //
+  // draws all the four histograms on one TCanvas
+  //
+
   TCanvas* canvas = new TCanvas("Correction", "Correction", 800, 800);
   canvas->Divide(2, 2);
 
index 28ea819b47edd8bf4bda111a730593d821f59bde..d01d7b40f303f847feebd554558fc7100e65070d 100644 (file)
@@ -1,13 +1,21 @@
+// ------------------------------------------------------
+//
+// Class to handle 2d-corrections. 
+//
+// ------------------------------------------------------
+//
+// TODO:
+//
+// - change the finish method (should not be called finish)
+// - add option in draw method
+// 
+//
+
 /* $Id$ */
 
 #ifndef CORRECTIONMATRIX2D_H
 #define CORRECTIONMATRIX2D_H
 
-// ------------------------------------------------------
-//
-// Class to handle 2d - corrections 
-//
-// ------------------------------------------------------
 
 #ifndef ROOT_TNamed
 #include "TNamed.h"
@@ -28,6 +36,7 @@
 class CorrectionMatrix2D : public TNamed 
 {
 public:
+  CorrectionMatrix2D(const CorrectionMatrix2D& c);
   CorrectionMatrix2D(Char_t* name="CorrectionMatrix", Char_t* title="",
                     Int_t nBinX=10, Float_t Xmin=0., Float_t Xmax=10.,
                     Int_t nBinY=10, Float_t Ymin=0., Float_t Ymax=10.);
@@ -37,11 +46,15 @@ public:
 
   virtual ~CorrectionMatrix2D(); 
 
+  CorrectionMatrix2D& operator=(const CorrectionMatrix2D& corrMatrix);
+
+  virtual void Copy(TObject& c) const;
+
   TH2F* GetGeneratedHistogram() { return fhGene; }
   TH2F* GetMeasuredHistogram()  { return fhMeas; }
 
   void SetGeneratedHistogram(TH2F* agene) { fhGene = agene; }
-  void SetMeasuredHistogram(TH2F* ameas)  { fhMeas  = ameas; }
+  void SetMeasuredHistogram(TH2F* ameas)  { fhMeas = ameas; }
 
   void FillMeas(Float_t ax, Float_t ay) {fhMeas->Fill(ax,ay);}
   void FillGene(Float_t ax, Float_t ay) {fhGene->Fill(ax,ay);}
@@ -62,11 +75,11 @@ public:
   
 protected:
   
-  TH2F*    fhMeas;
-  TH2F*    fhGene;
+  TH2F*    fhMeas;  // histogram of measured particles (or tracks)
+  TH2F*    fhGene;  // histogram of generated particles
 
-  TH2F*    fhCorr; 
-  TH2F*    fhRatio;
+  TH2F*    fhRatio; // ratio measured/generated 
+  TH2F*    fhCorr;  // ratio generated/measured
 
 
   ClassDef(CorrectionMatrix2D,0)