Skip to content

Commit

Permalink
CalculateNorm replaced by CalculateRawRatio
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielWielanek committed Dec 3, 2024
1 parent 4e08a3a commit 0058b38
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
26 changes: 19 additions & 7 deletions features/hist/DividedHisto.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1446,19 +1446,22 @@ namespace Hal {

DividedHisto3D::DividedHisto3D(const DividedHisto3D& other) : DividedHisto2D(other) {}

Double_t DividedHisto1D::CalculateNorm(Double_t min, Double_t max) const {
Double_t DividedHisto1D::CalculateRawRatio(Double_t min, Double_t max, Bool_t skip_empty) const {
Int_t binA = fNum->GetXaxis()->FindBin(min);
Int_t binB = fNum->GetXaxis()->FindBin(max);
Double_t N = 0;
Double_t D = 0;
for (int i = binA; i <= binB; i++) {
if (skip_empty)
if (fNum->GetBinContent(i) == 0 || fDen->GetBinContent(i)) continue;
N += fNum->GetBinContent(i);
D += fDen->GetBinContent(i);
}
return D / N;
return N / D;
}

Double_t DividedHisto2D::CalculateNorm(Double_t minX, Double_t maxX, Double_t minY, Double_t maxY) const {
Double_t
DividedHisto2D::CalculateRawRatio(Double_t minX, Double_t maxX, Double_t minY, Double_t maxY, Bool_t skip_empty) const {
Int_t binXm = fNum->GetXaxis()->FindBin(minX);
Int_t binXM = fNum->GetXaxis()->FindBin(maxX);
Int_t binYm = fNum->GetYaxis()->FindBin(minY);
Expand All @@ -1467,15 +1470,22 @@ namespace Hal {
Double_t D = 0;
for (int i = binXm; i <= binXM; i++) {
for (int j = binYm; j <= binYM; j++) {
if (skip_empty)
if (fNum->GetBinContent(i, j) == 0 || fDen->GetBinContent(i, j)) continue;
N += fNum->GetBinContent(i, j);
D += fDen->GetBinContent(i, j);
}
}
return D / N;
return N / D;
}

Double_t
DividedHisto3D::CalculateNorm(Double_t minX, Double_t maxX, Double_t minY, Double_t maxY, Double_t minZ, Double_t maxZ) const {
Double_t DividedHisto3D::CalculateRawRatio(Double_t minX,
Double_t maxX,
Double_t minY,
Double_t maxY,
Double_t minZ,
Double_t maxZ,
Bool_t skip_empty) const {
Int_t binXm = fNum->GetXaxis()->FindBin(minX);
Int_t binXM = fNum->GetXaxis()->FindBin(maxX);
Int_t binYm = fNum->GetYaxis()->FindBin(minY);
Expand All @@ -1487,12 +1497,14 @@ namespace Hal {
for (int i = binXm; i <= binXM; i++) {
for (int j = binYm; j <= binYM; j++) {
for (int k = binZm; k <= binZM; k++) {
if (skip_empty)
if (fNum->GetBinContent(i, j, k) == 0 || fDen->GetBinContent(i, j, k)) continue;
N += fNum->GetBinContent(i, j, k);
D += fDen->GetBinContent(i, j, k);
}
}
}
return D / N;
return N / D;
}

TH1D* DividedHisto2D::Projection2DTo1D(Double_t min, Double_t max, Option_t* opt) const {
Expand Down
19 changes: 14 additions & 5 deletions features/hist/DividedHisto.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,13 @@ namespace Hal {
*/
Double_t GetScale() const;
/**
* calucalte denominator/numerator ratio at given range
* calculate numerator/denominator ratio at given range
* @param min lower norm range
* @param max upper norm range
* @param skip_empty - skip empty bins
* @return
*/
Double_t CalculateNorm(Double_t min, Double_t max) const;
Double_t CalculateRawRatio(Double_t min, Double_t max, Bool_t skip_emtpy = kFALSE) const;
/**
* used to merge similar objects
* @param collection
Expand Down Expand Up @@ -533,14 +534,15 @@ namespace Hal {
*/
TH1D* GetProjection1D(Double_t min, Double_t max, Option_t* opt) const { return Projection2DTo1D(min, max, opt); }
/**
* calucalte denominator/numerator ratio at given range
* calucaltes numerator/denominrator ratio at given range
* @param min lower norm range
* @param max upper norm range
* @param minY lower norm range
* @param maxY upper norm range
* @param skip_empty - skip empty bins
* @return
*/
Double_t CalculateNorm(Double_t minX, Double_t maxX, Double_t minY, Double_t maxY) const;
Double_t CalculateRawRatio(Double_t minX, Double_t maxX, Double_t minY, Double_t maxY, Bool_t skip_emtpy = kFALSE) const;
virtual void Browse(TBrowser* b);
/**
* operator =
Expand Down Expand Up @@ -703,9 +705,16 @@ namespace Hal {
* @param maxY upper norm range
* @param minZ lower norm range
* @param maxZ upper norm range
* @param skip_emty - ignore emtpy bins
* @return
*/
Double_t CalculateNorm(Double_t minX, Double_t maxX, Double_t minY, Double_t maxY, Double_t minZ, Double_t maxZ) const;
Double_t CalculateRawRatio(Double_t minX,
Double_t maxX,
Double_t minY,
Double_t maxY,
Double_t minZ,
Double_t maxZ,
Bool_t skip_emtpy = kFALSE) const;
/**
* operator =
* @param other
Expand Down

0 comments on commit 0058b38

Please sign in to comment.