# Integration of histogram

**URL:** <https://root-forum.cern.ch/t/integration-of-histogram/51418>\
**Category:** Newbie\
**Created:** [August 31, 2022, 8:32pm UTC](https://root-forum.cern.ch/t/integration-of-histogram/51418 "2022-08-31T20:32:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gurmukh\_dhindsa](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/gurmukh_dhindsa/32/30326_2.png) [@gurmukh\_dhindsa](https://root-forum.cern.ch/u/gurmukh_dhindsa)\
**Post date:** [August 31, 2022, 8:32pm UTC](https://root-forum.cern.ch/t/integration-of-histogram/51418/1 "2022-08-31T20:32:22Z")

</div>

* * *

I have a histogram and I wanted to do an integration of that. It will be a great help  
,if you can provide me a script. I am attaching root file  
[output3.root](https://root-forum.cern.ch/uploads/short-url/9pPI6oNiTyoMCMEzP1bUNHr75te.root) (123.7 KB)

_ROOT Version:_ Not Provided  
_Platform:_ Not Provided  
_Compiler:_ Not Provided

* * *

---

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [September 1, 2022, 12:50pm UTC](https://root-forum.cern.ch/t/integration-of-histogram/51418/2 "2022-09-01T12:50:41Z")

</div>

Hi!

You can use [TH2::Integral()](https://root.cern.ch/doc/master/classTH2.html#af15797d21d01bf7b0cf4ea5ade57c0b2) for that:

```c++
void testComputeIntegral() {

    auto file = TFile::Open("output3.root", "READ");

    auto h = file->Get<TH2F>("h");

    std::cout << h->Integral() << std::endl;

    delete file;
}

```

---

<div class="post-metadata">

**Author:** ![gurmukh\_dhindsa](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/gurmukh_dhindsa/32/30326_2.png) [@gurmukh\_dhindsa](https://root-forum.cern.ch/u/gurmukh_dhindsa)\
**Post date:** [September 1, 2022, 4:29pm UTC](https://root-forum.cern.ch/t/integration-of-histogram/51418/3 "2022-09-01T16:29:23Z")

</div>

Thankuu so much Jonas
