# TParameter Units

**URL:** <https://root-forum.cern.ch/t/tparameter-units/24426>\
**Category:** Evolution Proposals, Apps & Ideas\
**Created:** [April 13, 2017, 10:37pm UTC](https://root-forum.cern.ch/t/tparameter-units/24426 "2017-04-13T22:37:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [April 13, 2017, 10:37pm UTC](https://root-forum.cern.ch/t/tparameter-units/24426/1 "2017-04-13T22:37:45Z")

</div>

Hi,

I believe many of us use TParameter to store values associate with the data we acquired. Often these values have units. It would be nice to be able to store the unit along with the value.

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [April 25, 2017, 7:40pm UTC](https://root-forum.cern.ch/t/tparameter-units/24426/2 "2017-04-25T19:40:12Z")

</div>

A TParameter has both a value and a string name. You can either embedded the unit inside the name.

Otherwise, what kind of field did you envision to hold the unit information?

Thanks,  
Philippe.

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [April 25, 2017, 8:13pm UTC](https://root-forum.cern.ch/t/tparameter-units/24426/3 "2017-04-25T20:13:39Z")

</div>

You are correct, that one could stick the units in the name, but this is sometimes cumbersome. For example, flux can have units of [m^-2 s^-1 sr^-1 J^-1], this would be a lot to place in a name. Instead it would be nice to have:

```auto
TParameter< double > flux("someFlux", 1000, "m^-2 s^-1 sr^-1 J^-1");
std::cout << flux.GetName() << " has a value of " <<
      flux.GetVal() << " " << flux.GetUnits() << "\n"

```

---

<div class="post-metadata">

**Author:** ![Axel](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/axel/32/11084_2.png) [@Axel](https://root-forum.cern.ch/u/Axel)\
**Post date:** [April 28, 2017, 12:05pm UTC](https://root-forum.cern.ch/t/tparameter-units/24426/4 "2017-04-28T12:05:34Z")

</div>

I don’t think this should be conflated into `TParameter`.

There have been several efforts in creating a C++ unit system, some are better than others.  
Nice examples from a web search:

> **[martinmoene/PhysUnits-CT-Cpp11](https://github.com/martinmoene/PhysUnits-CT-Cpp11)**
>
> A small C++11, C++14 header-only library for compile-time dimensional analysis and unit/quantity manipulation and conversion - martinmoene/PhysUnits-CT-Cpp11

  

> **[nholthaus/units](https://github.com/nholthaus/units)**
>
> a compile-time, header-only, dimensional analysis and unit conversion library built on c++14 with no dependencies. - nholthaus/units

and less recommended:  
[http://www.boost.org/doc/libs/1\_63\_0/doc/html/boost\_units/Quick\_Start.html](http://www.boost.org/doc/libs/1_63_0/doc/html/boost_units/Quick_Start.html)

And a discussion: [https://benjaminjurke.net/content/articles/2015/compile-time-numerical-unit-dimension-checking/](https://benjaminjurke.net/content/articles/2015/compile-time-numerical-unit-dimension-checking/)

Pick yours! 🙂

Axel.
