How to add histograms

Multiply only y axis contents, not x!

see TH1::Scale

Rene

Is it possible to assign resulting histogram to another object without changing any of adding histograms? This, of course, does not work:

TH1F* diff = new TH1F( "diff", "diff", 100, 0, 100 );
diff = h1->Add( h2, -1 );
diff->Add( h1, h2, 1., -1. );

There are overloaded arithmetic operators https://root.cern.ch/doc/master/classTH1F.html#friends

auto diff = *h1 - *h2;

I am trying to use
void TH1::Add(const TH1 *M_LQ1, const TH1 *M_LQ2, Double_t c1, Double_t c2)

and I get:

./upload.Cxx: line 1: syntax blunders close to surprising token (’ ./upload.Cxx: line 1:void TH1::Add(const TH1 *M_LQ1, const TH1 *M_LQ2, Double_t c1, Double_t c2)’

upload.Cxx is my record, it’s miles in my ~/public, if you may check:
/afs/cern.Ch/person/e/evgenia/public
Thanks.

Is there a way to continuously add histograms to each other? For example: create an empty histogram and then use a for loop that keeps adding histograms to this empty histogram?

You can call TH1::Add as many times as you want.
You can draw the “updated” histogram(s) like in these tutorials:
${ROOTSYS}/tutorials/hist/hsum.C
${ROOTSYS}/tutorials/hist/hsumTimer.C