Commit 430f6be7 authored by Jérémie Dudouet's avatar Jérémie Dudouet
Browse files

Correct a bug for asymetric projections

parent ec03e511
......@@ -132,7 +132,7 @@ CXTH1Proj *CXHist2DPlayer::GetProj(){
return dynamic_cast<CXTH1Proj*>(hist);
}
else{
cout<<"No Projection for GxG found in the current pad"<<endl;
WARN_MESS << "No Projection for GxG found in the current pad"<< ENDL;
return nullptr;
}
}
......@@ -205,7 +205,11 @@ void CXHist2DPlayer::UpdateProjection()
else
fAxisProj = 1;
GetProj()->UpdateProjection(fAxisProj);
CXTH1Proj *proj = GetProj();
if(proj == nullptr) return;
proj->UpdateProjection(fAxisProj);
Project();
}
......
......@@ -61,18 +61,20 @@ void CXTH1Proj::UpdateProjection(Int_t Axis)
{
if(fGGHist->GetXaxis()->GetNbins() != fGGHist->GetYaxis()->GetNbins()) {
WARN_MESS << "X and Y axis needs to have the same number of bins for GG projections" << ENDL;
return;
// return;
}
if(Axis == 0) {
GetXaxis()->SetTitle("Energy (kev) [X axis]");
TH1 *projtmp = fGGHist->ProjectionX();
SetBins(fGGHist->GetXaxis()->GetNbins(),fGGHist->GetXaxis()->GetXmin(),fGGHist->GetXaxis()->GetXmax());
for(int i=0 ; i<projtmp->GetNbinsX()+2 ; i++)
SetBinContent(i,projtmp->GetBinContent(i));
delete projtmp;
}
else if(Axis == 1) {
GetXaxis()->SetTitle("Energy (kev) [Y axis]");
SetBins(fGGHist->GetYaxis()->GetNbins(),fGGHist->GetYaxis()->GetXmin(),fGGHist->GetYaxis()->GetXmax());
TH1 *projtmp = fGGHist->ProjectionY();
for(int i=0 ; i<projtmp->GetNbinsX()+2 ; i++)
SetBinContent(i,projtmp->GetBinContent(i));
......@@ -159,8 +161,7 @@ void CXTH1Proj::Project(Bool_t FixRange){
TString NameGates = "";
TString NameBGD = "";
for(int i=0 ; i<fListOfGates->GetEntries() ; i++)
{
for(int i=0 ; i<fListOfGates->GetEntries() ; i++) {
auto* box = dynamic_cast<CXGateBox*>(fListOfGates->At(i));
if(box->IsBGD()){
......@@ -182,7 +183,10 @@ void CXTH1Proj::Project(Bool_t FixRange){
delete gROOT->FindObject(ProjName.Data());
gErrorIgnoreLevel = kError;
TH1D *FinalProj = fGGHist->ProjectionX("tempproj");
TH1D *FinalProj = nullptr;
if(fProjectionAxis==0) FinalProj = fGGHist->ProjectionY("tempproj");
else FinalProj = fGGHist->ProjectionX("tempproj");
FinalProj->SetStats();
FinalProj->Reset();
FinalProj->SetName(ProjName.Data());
......@@ -208,17 +212,22 @@ void CXTH1Proj::Project(Bool_t FixRange){
FinalProj->GetYaxis()->SetTitleFont(GetYaxis()->GetTitleFont());
FinalProj->GetYaxis()->SetLabelFont(GetYaxis()->GetLabelFont());
for(int i=0 ; i<fListOfGates->GetEntries() ; i++)
{
for(int i=0 ; i<fListOfGates->GetEntries() ; i++) {
auto* box = dynamic_cast<CXGateBox*>(fListOfGates->At(i));
auto X1 = box->GetX1();
auto X2 = box->GetX2();
auto BinX1 = fGGHist->GetXaxis()->FindBin(X1);
auto BinX2 = fGGHist->GetXaxis()->FindBin(X2);
int BinX1, BinX2;
// cout<<"add_gate("<<X1<<","<<X2<<"): ilo="<<BinX1<<" ; ihi="<<BinX2<<endl;
if(fProjectionAxis==0) {
BinX1 = fGGHist->GetXaxis()->FindBin(X1);
BinX2 = fGGHist->GetXaxis()->FindBin(X2);
}
else {
BinX1 = fGGHist->GetYaxis()->FindBin(X1);
BinX2 = fGGHist->GetYaxis()->FindBin(X2);
}
Float_t Weight = 1.;
if(box->IsBGD())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment