45 TFile
f1(
"mathcoreLV.root",
"RECREATE");
48 TTree
t1(
"t1",
"Tree with new LorentzVector");
50 std::vector<ROOT::Math::XYZTVector> tracks;
51 std::vector<ROOT::Math::XYZTVector> * pTracks = &tracks;
52 t1.Branch(
"tracks",
"std::vector<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > >",&pTracks);
58 for (
int i = 0; i <
n; ++i) {
61 pTracks->reserve(nPart);
62 for (
int j = 0; j < nPart; ++j) {
63 double px = R.
Gaus(0,10);
64 double py = R.
Gaus(0,10);
65 double pt =
sqrt(px*px +py*py);
70 double E =
sqrt( vcyl.R()*vcyl.R() + M*M);
73 pTracks->push_back(
q);
75 sum +=
q.x()+
q.y()+
q.z()+
q.t();
82 std::cout <<
" Time for new Vector " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
92 TH1D *
h1 =
new TH1D(
"h1",
"total event energy ",100,0,1000.);
93 TH1D * h2 =
new TH1D(
"h2",
"Number of track per event",21,-0.5,20.5);
94 TH1D * h3 =
new TH1D(
"h3",
"Track Energy",100,0,200);
95 TH1D * h4 =
new TH1D(
"h4",
"Track Pt",100,0,100);
96 TH1D * h5 =
new TH1D(
"h5",
"Track Eta",100,-5,5);
97 TH1D * h6 =
new TH1D(
"h6",
"Track Cos(theta)",100,-1,1);
99 TFile
f1(
"mathcoreLV.root");
102 TTree *
t1 = (TTree*)
f1.Get(
"t1");
104 std::vector<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > > * pTracks = 0;
105 t1->SetBranchAddress(
"tracks",&pTracks);
108 int n = (int) t1->GetEntries();
109 std::cout <<
" Tree Entries " << n << std::endl;
111 for (
int i = 0; i <
n; ++i) {
113 int ntrk = pTracks->size();
116 for (
int j = 0; j < ntrk; ++j) {
123 sum += v.
x() + v.
y() + v.
z() + v.
t();
130 std::cout <<
" Time for new Vector " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
153 int mathcoreVectorCollection() {
156 double s1 = write(nEvents);
159 if (
fabs(s1-s2) > s1*1.E-15 ) {
160 std::cout <<
"ERROR: Found difference in Vector when reading ( " << s1 <<
" != " << s2 <<
" diff = " <<
fabs(s1-s2) <<
" ) " << std::endl;
167 return mathcoreVectorCollection();
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
Class describing a generic LorentzVector in the 4D space-time, using the specified coordinate system ...
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
static long int sum(long int i)
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.
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
Scalar Eta() const
pseudorapidity
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
Scalar Theta() const
polar Angle
#define R(a, b, c, d, e, f, g, h, i)
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
void Stop()
Stop the stopwatch.
This is the base class for the ROOT Random number generators.
int main(int argc, char **argv)
Scalar E() const
return 4-th component (time, or energy for a 4-momentum vector)
Class describing a generic displacement vector in 3 dimensions.
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
virtual void Draw(Option_t *option="")
Draw this histogram with options.
1-D histogram with a double per channel (see TH1 documentation)}
constexpr Double_t E()
Base of natural log: .
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
virtual void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)
Automatic pad generation by division.
THist< 1, double, THistStatContent, THistStatUncertainty > TH1D
virtual Int_t Poisson(Double_t mean)
Generates a random integer N according to a Poisson law.
Scalar Pt() const
return the transverse spatial component sqrt ( X**2 + Y**2 )