+// ------------------------------------------------------
+//
+// 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);
//____________________________________________________________________
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
//____________________________________________________________________
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;}
//____________________________________________________________________
void
CorrectionMatrix2D::SaveHistograms() {
+ //
+ // saves the histograms
+ //
gDirectory->mkdir(fName.Data());
gDirectory->cd(fName.Data());
//____________________________________________________________________
void CorrectionMatrix2D::DrawHistograms()
{
+ //
+ // draws all the four histograms on one TCanvas
+ //
+
TCanvas* canvas = new TCanvas("Correction", "Correction", 800, 800);
canvas->Divide(2, 2);
+// ------------------------------------------------------
+//
+// 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"
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.);
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);}
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)