# Divide() canvas not working

**URL:** <https://root-forum.cern.ch/t/divide-canvas-not-working/41701>\
**Category:** Newbie\
**Created:** [October 4, 2020, 1:01am UTC](https://root-forum.cern.ch/t/divide-canvas-not-working/41701 "2020-10-04T01:01:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cepheides](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/bcef8e/32.png) [@Cepheides](https://root-forum.cern.ch/u/Cepheides)\
**Post date:** [October 4, 2020, 1:01am UTC](https://root-forum.cern.ch/t/divide-canvas-not-working/41701/1 "2020-10-04T01:01:29Z")

</div>

I am trying to follow [this worksheet](https://mhance.scipp.ucsc.edu/analysisintro.php) from Hance and recreate the invariant mass plot below from his root file. I have attached my code and the root file can be downloaded from the website.

Anyway, when I try to run my code, I get the following error:[HEP\_practiceV5.C](https://root-forum.cern.ch/uploads/short-url/syRyq7Dp0ssSE0wfNWGxUOy2x5s.C) (20.6 KB) \_\_\_

```auto
In file included from input_line_13:1:
/home/nick/PHY496/mhance/HEP_practiceV5.C:658:3: error: use of undeclared identifier 'c19_1'
                c19_1->cd();
                ^
/home/nick/PHY496/mhance/HEP_practiceV5.C:665:3: error: use of undeclared identifier 'c19_2'
                c19_2->cd();
                ^
/home/nick/PHY496/mhance/HEP_practiceV5.C:672:3: error: use of undeclared identifier 'c19_3'
                c19_3->cd();
                ^
/home/nick/PHY496/mhance/HEP_practiceV5.C:679:3: error: use of undeclared identifier 'c19_4'
                c19_4->cd();
                ^
/home/nick/PHY496/mhance/HEP_practiceV5.C:696:3: error: use of undeclared identifier 'c20_1'
                c20_1->cd();
                ^
/home/nick/PHY496/mhance/HEP_practiceV5.C:703:3: error: use of undeclared identifier 'c20_2'
                c20_2->cd();
                ^
/home/nick/PHY496/mhance/HEP_practiceV5.C:710:3: error: use of undeclared identifier 'c20_3'
                c20_3->cd();
                ^
/home/nick/PHY496/mhance/HEP_practiceV5.C:717:3: error: use of undeclared identifier 'c20_4'
                c20_4->cd();

```

Could someone explain why ‘Divide()’ is not working here?  
_ROOT Version:_ 6.22  
_Platform:_ Linux Ubuntu 18.04

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [October 4, 2020, 11:25am UTC](https://root-forum.cern.ch/t/divide-canvas-not-working/41701/2 "2020-10-04T11:25:23Z")

</div>

As the error messages tell you, c19\_1, etc. don’t exist. Anyway, if your canvas is c19, and is divided in 2x2, you need to use

```auto
 c19->cd(1); // and similar for 2, 3 and 4

```

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [October 5, 2020, 7:01am UTC](https://root-forum.cern.ch/t/divide-canvas-not-working/41701/3 "2020-10-05T07:01:29Z")

</div>

Note also you have wrong definition of `TH1F`:

```auto
	TH1F *histTotPx = new TH1F("histTotPx", "TotpX hist", xNChannels, xMin, xMax, yNChannels, yMin, yMax);
	TH1F *histTotPy = new TH1F("histTotPy", "TotpY hist", xNChannels, xMin, xMax, yNChannels, yMin, yMax);
	TH1F *histTotPz = new TH1F("histTotPz", "TotpZ hist", xNChannels, xMin, xMax, yNChannels, yMin, yMax);
	TH1F *histTotE = new TH1F("histTotE", "TotE hist", xNChannels, xMin, xMax, yNChannels, yMin, yMax);

```

These are `TH2F` constructors, not `TH1F`.
