Commit 8b9082ad authored by Jérémie Dudouet's avatar Jérémie Dudouet
Browse files

Merge branch 'Cubix' into 'preprod'

Cubix - bug correction

See merge request !61
parents ec03e511 73480ac0
Pipeline #90461 passed with stages
in 5 minutes and 44 seconds
......@@ -106,7 +106,6 @@ void CXBgdFit::Update()
arr->SetLineColor(kBlue);
arr->SetFillColor(kBlue);
fBackgd.push_back(E);
cout<<E<<endl;
}
fPlayer->GetMainWindow()->RefreshPads();
......@@ -175,7 +174,10 @@ void CXBgdFit::Fit()
Int_t binmin = fHistogram->GetXaxis()->FindBin(fBackgd.at(i));
Int_t binmax = fHistogram->GetXaxis()->FindBin(fBackgd.at(i+1));
for(int ibin=binmin ; ibin<=binmax ; ibin++) HistoToFit->SetBinContent(ibin,fHistogram->GetBinContent(ibin));
for(int ibin=binmin ; ibin<=binmax ; ibin++) {
HistoToFit->SetBinContent(ibin,fHistogram->GetBinContent(ibin));
HistoToFit->SetBinError(ibin,fHistogram->GetBinError(ibin));
}
}
HistoToFit->GetXaxis()->SetRangeUser(fBackgd.front(), fBackgd.back());
......@@ -196,10 +198,15 @@ void CXBgdFit::Fit()
TString FitOpt = "R0S";
if(fPlayer->GetPrintLevel()>0) FitOpt +="V";
TFitResultPtr r = HistoToFit->Fit(fBackFunction,FitOpt.Data());
TFitResultPtr r = HistoToFit->Fit(fBackFunction,FitOpt.Data(),FitOpt.Data());
ostringstream text;
cout<<r<<endl;
if(r==-1) {
WARN_MESS << "Oups... Error in fitting histogram" << ENDL;
return;
}
text << "Fit results :";
cout<<text.str()<<endl;fPlayer->PrintInListBox(text.str(),kPrint);text.str("");
text << "Status: ";
......
......@@ -516,7 +516,6 @@ void CXHist1DPlayer::DoBgdFit()
{
fFitResultsBox->RemoveAll();
fListOfBgdFitObjects->ls();
for(int i=0 ; i<fListOfBgdFitObjects->GetEntries() ; i++) {
CXBgdFit *fit = (CXBgdFit*)fListOfBgdFitObjects->At(i);
fit->Fit();
......
......@@ -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();
}
......
......@@ -893,7 +893,6 @@ TH1 *CXMainWindow::GetHisto(TVirtualPad *pad, bool GetFirst)
obj = lnk->GetObject();
if (obj->InheritsFrom(TH1::Class()) && strcmp(obj->GetName() ,"hframe") != 0) {
hist = dynamic_cast<TH1*>(obj);
hist->Print();
if(GetFirst) return hist;
}
lnk = (TObjOptLink*)lnk->Next();
......
......@@ -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