46 TFile f1(
"mathcoreLV.root",
"RECREATE");
49 TTree t1(
"t1",
"Tree with new LorentzVector");
51 std::vector<ROOT::Math::XYZTVector>
tracks;
52 std::vector<ROOT::Math::XYZTVector> * pTracks = &
tracks;
53 t1.Branch(
"tracks",
"std::vector<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > >",&pTracks);
59 for (
int i = 0; i <
n; ++i) {
60 int nPart =
R.Poisson(5);
62 pTracks->reserve(nPart);
63 for (
int j = 0; j < nPart; ++j) {
64 double px =
R.Gaus(0,10);
65 double py =
R.Gaus(0,10);
66 double pt =
sqrt(px*px +py*py);
67 double eta =
R.Uniform(-3,3);
71 double E =
sqrt( vcyl.R()*vcyl.R() + M*M);
74 pTracks->push_back(
q);
83 std::cout <<
" Time for new Vector " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
93 TH1D *
h1 =
new TH1D(
"h1",
"total event energy ",100,0,1000.);
94 TH1D * h2 =
new TH1D(
"h2",
"Number of track per event",21,-0.5,20.5);
95 TH1D * h3 =
new TH1D(
"h3",
"Track Energy",100,0,200);
96 TH1D * h4 =
new TH1D(
"h4",
"Track Pt",100,0,100);
97 TH1D * h5 =
new TH1D(
"h5",
"Track Eta",100,-5,5);
98 TH1D * h6 =
new TH1D(
"h6",
"Track Cos(theta)",100,-1,1);
105 std::vector<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > > * pTracks =
nullptr;
106 t1->SetBranchAddress(
"tracks",&pTracks);
109 int n = (
int)
t1->GetEntries();
110 std::cout <<
" Tree Entries " <<
n << std::endl;
112 for (
int i = 0; i <
n; ++i) {
114 int ntrk = pTracks->size();
117 for (
int j = 0; j < ntrk; ++j) {
124 sum +=
v.x() +
v.y() +
v.z() +
v.t();
131 std::cout <<
" Time for new Vector " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
154int mathcoreVectorCollection() {
157 double s1 = write(nEvents);
161 std::cout <<
"ERROR: Found difference in Vector when reading ( " <<
s1 <<
" != " << s2 <<
" diff = " <<
fabs(
s1-s2) <<
" ) " << std::endl;
168 return mathcoreVectorCollection();
#define R(a, b, c, d, e, f, g, h, i)
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
1-D histogram with a double per channel (see TH1 documentation)
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
void Draw(Option_t *option="") override
Draw this histogram with options.
This is the base class for the ROOT Random number generators.
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
void Stop()
Stop the stopwatch.
A TTree represents a columnar dataset.
RVec< PromoteType< T > > cos(const RVec< T > &v)
DisplacementVector3D< CylindricalEta3D< double >, DefaultCoordinateSystemTag > RhoEtaPhiVector
3D Vector based on the eta based cylindrical coordinates rho, eta, phi in double precision.
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
LorentzVector< PxPyPzE4D< double > > XYZTVector
LorentzVector based on x,y,z,t (or px,py,pz,E) coordinates in double precision with metric (-,...
constexpr Double_t E()
Base of natural log: .
static uint64_t sum(uint64_t i)