Hi,
I was recently trying to reduce the sizes of my ROOT files. Since the TLorentzVector class uses Doubles, it eats up lots of memory without actually needing it. To go for smaller classes, I looked at the GenVector package that allows to set the type of the fields by a template parameter. However, I noticed something I don’t really understand when I wrote these classes in trees:
This code reproduces the problem:
#include "TObject.h"
#include "TFile.h"
#include "TTree.h"
#include "TClonesArray.h"
#include "Math/LorentzVector.h"
typedef ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<Float16_t> > LorentzVectorF16;
void test() {
TFile* f = new TFile("test.root", "RECREATE");
TTree* t = new TTree("t", "Test Tree");
LorentzVectorF16* lv = new LorentzVectorF16();
t->Branch("lv", lv, 32000, 3);
t->Fill();
t->Print();
}
The output I get is:
******************************************************************************
*Tree :t : Test Tree *
*Entries : 1 : Total = 4631 bytes File Size = 0 *
* : : Tree compression factor = 1.00 *
******************************************************************************
*Branch :lv *
*Entries : 1 : BranchElement (see below) *
*............................................................................*
*Br 0 :fCoordinates : *
*Entries : 1 : Total Size= 3608 bytes One basket in memory *
*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
*Br 1 :fCoordinates.fX : Float_t *
*Entries : 1 : Total Size= 707 bytes One basket in memory *
*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
*Br 2 :fCoordinates.fY : Float_t *
*Entries : 1 : Total Size= 707 bytes One basket in memory *
*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
*Br 3 :fCoordinates.fZ : Float_t *
*Entries : 1 : Total Size= 707 bytes One basket in memory *
*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
*Br 4 :fCoordinates.fT : Float_t *
*Entries : 1 : Total Size= 707 bytes One basket in memory *
*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
As you can see the internal fields fX, fY , fZ and fT that should be Float16_t as declared in the template, are streamed just like regular Float_t and I would like to understand why this happens and whether there is a way to stream them correctly.
Thanks in advance and all the best,
Triple_S
ROOT Version: 6.12.06
Platform: Debian 8
Compiler: GCC 4.9.2