# Positions of maximums with TSpectrum

**URL:** <https://root-forum.cern.ch/t/positions-of-maximums-with-tspectrum/21978>\
**Category:** ROOT\
**Created:** [October 3, 2016, 4:07pm UTC](https://root-forum.cern.ch/t/positions-of-maximums-with-tspectrum/21978 "2016-10-03T16:07:44Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [October 3, 2016, 4:21pm UTC](https://root-forum.cern.ch/t/positions-of-maximums-with-tspectrum/21978/2 "2016-10-03T16:21:51Z")

</div>

Which ROOT version?  
Note: [ROOT 6 returns “Double\_t” peaks’ positions](https://root.cern.ch/root/html/tutorials/spectrum/peaks.C.html), while [ROOT 5 returns “Float\_t” peaks’ positions](https://root.cern.ch/root/html534/tutorials/spectrum/peaks.C.html).  
Try something like this: ` // ...
#if ROOT_VERSION_CODE >= ROOT_VERSION(6,00,00)
  Double_t *xpeaks; // ROOT 6
#else
  Float_t *xpeaks; // ROOT 5
#endif
  xpeaks = s->GetPositionX();
  for (p = 0; p < nfound; p++) {
    Double_t xp = xpeaks[p]; // ROOT 6 or 5
    // ...
  }
  // ...` See also: [Illegal pointer to class object back 0x0 165](https://root-forum.cern.ch/t/illegal-pointer-to-class-object-back-0x0-165/21084/9)

---

_[View the full topic](https://root-forum.cern.ch/t/positions-of-maximums-with-tspectrum/21978)._
