# TRotation in a Tree

**URL:** <https://root-forum.cern.ch/t/trotation-in-a-tree/64819>\
**Category:** Newbie\
**Created:** [April 24, 2026, 3:14pm UTC](https://root-forum.cern.ch/t/trotation-in-a-tree/64819 "2026-04-24T15:14:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![valentin630](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/8c91f0/32.png) [@valentin630](https://root-forum.cern.ch/u/valentin630)\
**Post date:** [April 24, 2026, 3:14pm UTC](https://root-forum.cern.ch/t/trotation-in-a-tree/64819/1 "2026-04-24T15:14:10Z")

</div>

* * *

_How to write TRotation data in a Tree to read them later?_

---

<div class="post-metadata">

**Author:** ![jblomer](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@jblomer](https://root-forum.cern.ch/u/jblomer)\
**Post date:** [April 24, 2026, 7:50pm UTC](https://root-forum.cern.ch/t/trotation-in-a-tree/64819/2 "2026-04-24T19:50:03Z")

</div>

A `TRotation` object is not different from other objects. Here is an introduction to writing data into trees: [Trees - ROOT](https://root.cern/manual/trees/#writing-a-tree)

---

<div class="post-metadata">

**Author:** ![valentin630](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/8c91f0/32.png) [@valentin630](https://root-forum.cern.ch/u/valentin630)\
**Post date:** [April 25, 2026, 8:20am UTC](https://root-forum.cern.ch/t/trotation-in-a-tree/64819/3 "2026-04-25T08:20:47Z")

</div>

Thank you for your reply, but I still need an example with TRotation.

---

<div class="post-metadata">

**Author:** ![jblomer](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@jblomer](https://root-forum.cern.ch/u/jblomer)\
**Post date:** [April 25, 2026, 6:55pm UTC](https://root-forum.cern.ch/t/trotation-in-a-tree/64819/4 "2026-04-25T18:55:22Z")

</div>

Here you go, writing one entry with the identity rotation:

```cpp
std::unique_ptr<TFile> file(TFile::Open("file.root", "RECREATE"));
auto tree = std::make_unique<TTree>("tree", "");
TRotation r;
tree->Branch("rot", &r);
tree->Fill();
tree->Write();
file->Write();

```

Note the deprecation warning of `TRotation`: [ROOT: TRotation Class Reference](https://root.cern.ch/doc/master/classTRotation.html)

---

<div class="post-metadata">

**Author:** ![valentin630](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/v/8c91f0/32.png) [@valentin630](https://root-forum.cern.ch/u/valentin630)\
**Post date:** [April 26, 2026, 11:32am UTC](https://root-forum.cern.ch/t/trotation-in-a-tree/64819/5 "2026-04-26T11:32:34Z")

</div>

Thanks more once!  
My probllem was to read date. Now I know how to do it right:  
root [0] TRotation Tr;  
root [1] Tr.RotateZ(TMath::Pi());  
root [2] TFile \*file1 = new TFile(“file.root”,“READ”);  
root [3] TTree \*algnw = (TTree \*)file1-\>Get(“tree”);  
root [4] TRotation \*pTr = &Tr; // The problem!  
root [5] algnw-\>SetBranchAddress(“rot”, &pTr);  
root [6] algnw-\>GetEvent(0);  
root [7] Tr(0,0)  
(double) 1.0000000
