How to write TRotation data in a Tree to read them later?
A TRotation object is not different from other objects. Here is an introduction to writing data into trees: Trees - ROOT
Thank you for your reply, but I still need an example with TRotation.
Here you go, writing one entry with the identity rotation:
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
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