# Converting TMatrix to TH2F/TH2D

**URL:** <https://root-forum.cern.ch/t/converting-tmatrix-to-th2f-th2d/45626>\
**Category:** Newbie\
**Tags:** root\
**Created:** [July 1, 2021, 2:36pm UTC](https://root-forum.cern.ch/t/converting-tmatrix-to-th2f-th2d/45626 "2021-07-01T14:36:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karl007](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/8491ac/32.png) [@Karl007](https://root-forum.cern.ch/u/Karl007)\
**Post date:** [July 1, 2021, 2:36pm UTC](https://root-forum.cern.ch/t/converting-tmatrix-to-th2f-th2d/45626/1 "2021-07-01T14:36:54Z")

</div>

Hi, I am using the following code for converting TMatrix to TH2F/TH2D:

```auto
  TH2D *h = new TH2D(matrix1);
  h->SetNameTitle("h", "matrix;x axis;y axis;z axis");
  h->Draw("COLZ");

```

But I am getting this errror:

```auto
 no known conversion from 'TMatrixD *' (aka
      'TMatrixT<double> *') to 'const TMatrixDBase' (aka 'const
      TMatrixTBase<double>') for 1st argument; dereference the argument with *
   TH2D(const TMatrixDBase &m);

```

Any idea what I am doing wrong?

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [July 1, 2021, 2:41pm UTC](https://root-forum.cern.ch/t/converting-tmatrix-to-th2f-th2d/45626/2 "2021-07-01T14:41:05Z")

</div>

Try:

```auto
TH2D *h = new TH2D(*matrix1);

```

---

<div class="post-metadata">

**Author:** ![Karl007](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/k/8491ac/32.png) [@Karl007](https://root-forum.cern.ch/u/Karl007)\
**Post date:** [July 1, 2021, 3:21pm UTC](https://root-forum.cern.ch/t/converting-tmatrix-to-th2f-th2d/45626/3 "2021-07-01T15:21:27Z")

</div>

Thank you. It is solved. 🙂
