THSTack does not stack when one histogram is scaled

I have a problem when I create THStack. I have multiple histograms that I want to add together and I need to multiply one of them by a constant. It works just fine without multiplying, but when I try to add the histograms, the scaled one is drawn behind (on in front of) the others. I cannot get it to be added on top of the others.
This is how the program looks like:

#include "TCanvas.h"
#include "TROOT.h"
#include <iostream>
#include <TH2.h>
#include "TFile.h"
void hstack(){
  THStack *a =new THStack("a","something");

  TFile *foo = TFile::Open("foo.root");
  TH1D *h = (TH1D*)foo->Get("something");

  TFile *bar = TFile::Open("bar");
  TH1D *g = (TH1D*)bar->Get("something");
TCanvas *C = new TCanvas("C", "something", 1000, 800);
return C;

I suppose I am using wrong method or using it in a wrong place or something like that, but I just cannot find a different way.
Thank you very much in advance for your help!

“h” and “g” are both TH1D …
I do not see any reason why it does not work.
Can you provide a small script we can run reproducing the problem ?

The real data that I am working with are way too big to send, but I will try to find another way to make a small script.

Yes if you can make a small reproducer with fake data it will be useful .
Just looking at the pseudo-code you sent I do not see any reason why it should not work.

Ok, I think I solved the problem, and I guess it is the most stupid thing someone has ever posted here. The problem was that one of the histograms has, after scaling, far larger values than the other - so when I first stack the large one, and then the smaller one, with logarithmic axis I cannot see the smaller one, and it appears not to be there…
Thank you for trying to help me and sorry for bothering you with such stupidity.

Ok no problem. Often posting a problem helps to resolve it. :slight_smile: