# Setting scale and Merging two histograms

**URL:** <https://root-forum.cern.ch/t/setting-scale-and-merging-two-histograms/41051>\
**Category:** Newbie\
**Created:** [August 19, 2020, 7:14am UTC](https://root-forum.cern.ch/t/setting-scale-and-merging-two-histograms/41051 "2020-08-19T07:14:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Afzaal786](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/afzaal786/32/20527_2.png) [@Afzaal786](https://root-forum.cern.ch/u/Afzaal786)\
**Post date:** [August 19, 2020, 7:14am UTC](https://root-forum.cern.ch/t/setting-scale-and-merging-two-histograms/41051/1 "2020-08-19T07:14:36Z")

</div>

Hi, I wanna merge two histograms produced by single root file. But when i merged h10 and h20 then no effects occured after merging(may be due to empty h20). How one can adjust the scale and how it could be resolved?  
Macro file used

# macro file for TestEm5.cc

/control/verbose 2  
/run/verbose 2

/testem/det/setAbsMat G4\_GLASS\_PLATE  
/testem/det/setAbsThick 2 mm  
/testem/det/setAbsYZ 2 mm

/run/initialize

/testem/gun/setDefault  
/gun/particle gamma  
/gun/energy 511 keV

/analysis/setFileName acosta.root  
/analysis/h1/set 1 100 0 511 keV  
/analysis/h1/set 2 100 0 511 keV  
/analysis/h1/set 3 100 0 511 keV  
/analysis/h1/set 10 100 0 511 keV  
/analysis/h1/set 13 100 0 511 keV  
/analysis/h1/set 20 100 0 511 keV  
/analysis/h1/set 30 100 0 511 keV  
/analysis/h1/set 40 100 0 511 keV

/run/setCut 1 um

/run/printProgress 10000

/run/beamOn 100000

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [August 19, 2020, 9:26am UTC](https://root-forum.cern.ch/t/setting-scale-and-merging-two-histograms/41051/2 "2020-08-19T09:26:13Z")

</div>

Can you provide code of your ROOT macro?

---

<div class="post-metadata">

**Author:** ![Afzaal786](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/afzaal786/32/20527_2.png) [@Afzaal786](https://root-forum.cern.ch/u/Afzaal786)\
**Post date:** [August 19, 2020, 9:38am UTC](https://root-forum.cern.ch/t/setting-scale-and-merging-two-histograms/41051/3 "2020-08-19T09:38:18Z")

</div>

Code?

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [August 19, 2020, 10:33am UTC](https://root-forum.cern.ch/t/setting-scale-and-merging-two-histograms/41051/4 "2020-08-19T10:33:12Z")

</div>

Hi,

You need ROOT macro which opens your file, read histograms and merge them together, using [TH1::Add](https://root.cern/doc/v622/classTH1.html#a6da1513d03e7352438bd8356f5038e37) method.  
You also can try to use `hadd` executable, but typically it used to merge together several ROOT files with similar content structure inside.

Regards,  
Sergey

---

<div class="post-metadata">

**Author:** ![Afzaal786](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/afzaal786/32/20527_2.png) [@Afzaal786](https://root-forum.cern.ch/u/Afzaal786)\
**Post date:** [August 19, 2020, 2:23pm UTC](https://root-forum.cern.ch/t/setting-scale-and-merging-two-histograms/41051/5 "2020-08-19T14:23:20Z")

</div>

How to set scale of histogram? So that an empty pad get fill with histogram?

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [August 19, 2020, 2:25pm UTC](https://root-forum.cern.ch/t/setting-scale-and-merging-two-histograms/41051/6 "2020-08-19T14:25:51Z")

</div>

> [@Afzaal786](#):
>
> How to set scale of histogram?

There is method [TH1::Scale](https://root.cern/doc/v622/classTH1.html#add929909dcb3745f6a52e9ae0860bfbd). Just do:

```auto
h1->Scale(1000);

```

To multiply all bins by 1000
