Macro illustrating I/O with Lorentz Vectors of floats The dictionary for LorentzVector of float is not in the libMathCore, therefore is generated when parsed the file with CLING.
To run this macro you must do
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#include <iostream>
TFile f1(
"mathcoreVectorIO_F.root",
"RECREATE");
TTree t1(
"t1",
"Tree with new Float LorentzVector");
t1.Branch(
"LV branch",
"ROOT::Math::XYZTVectorF",&
v1);
for (
int i = 0; i <
n; ++i) {
double Px =
R.Gaus(0,10);
double Py =
R.Gaus(0,10);
double Pz =
R.Gaus(0,10);
double E =
R.Gaus(100,10);
v1->SetCoordinates(Px,Py,Pz,E);
}
std::cout <<
" Time for new Float Vector " <<
timer.RealTime() <<
" " <<
timer.CpuTime() << std::endl;
}
void read() {
TFile f1(
"mathcoreVectorIO_F.root");
t1->SetBranchAddress(
"LV branch",&
v1);
int n = (
int)
t1->GetEntries();
std::cout <<
" Tree Entries " <<
n << std::endl;
for (
int i = 0; i <
n; ++i) {
}
std::cout <<
" Time for new Float Vector " <<
timer.RealTime() <<
" " <<
timer.CpuTime() << std::endl;
}
#if defined(__CINT__) && !defined(__MAKECINT__)
cout << "This tutorial can run only using ACliC, you must run it by doing: " << endl;
cout << "\t .L tutorials/math/mathcoreVectorFloatIO.C+" << endl;
cout << "\t runIt()" << endl;
#endif
int nEvents = 100000;
write(nEvents);
read();
}
#if defined(__CINT__) && !defined(__MAKECINT__)
cout << "This tutorial can run only using ACliC, you must run it by doing: " << endl;
cout << "\t .L tutorials/math/mathcoreVectorFloatIO.C+" << endl;
cout << "\t runIt()" << endl;
#endif
}
#define R(a, b, c, d, e, f, g, h, i)
R__EXTERN TSystem * gSystem
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
This is the base class for the ROOT Random number generators.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
A TTree represents a columnar dataset.
- Author
- Lorenzo Moneta
Definition in file mathcoreVectorFloatIO.C.