38 using namespace ROOT::Math;
44 TFile
f1(
"mathcoreLV.root",
"RECREATE");
47 TTree t1(
"t1",
"Tree with new LorentzVector");
49 std::vector<ROOT::Math::XYZTVector> tracks;
50 std::vector<ROOT::Math::XYZTVector> * pTracks = &tracks;
51 t1.
Branch(
"tracks",
"std::vector<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > >",&pTracks);
57 for (
int i = 0; i <
n; ++i) {
60 pTracks->reserve(nPart);
61 for (
int j = 0; j < nPart; ++j) {
62 double px = R.
Gaus(0,10);
63 double py = R.
Gaus(0,10);
64 double pt =
sqrt(px*px +py*py);
69 double E =
sqrt( vcyl.R()*vcyl.R() + M*M);
72 pTracks->push_back(q);
74 sum += q.
x()+q.
y()+q.
z()+q.
t();
81 std::cout <<
" Time for new Vector " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
91 TH1D * h1 =
new TH1D(
"h1",
"total event energy ",100,0,1000.);
92 TH1D * h2 =
new TH1D(
"h2",
"Number of track per event",21,-0.5,20.5);
93 TH1D * h3 =
new TH1D(
"h3",
"Track Energy",100,0,200);
94 TH1D * h4 =
new TH1D(
"h4",
"Track Pt",100,0,100);
95 TH1D * h5 =
new TH1D(
"h5",
"Track Eta",100,-5,5);
96 TH1D * h6 =
new TH1D(
"h6",
"Track Cos(theta)",100,-1,1);
98 TFile
f1(
"mathcoreLV.root");
103 std::vector<ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > > * pTracks = 0;
108 std::cout <<
" Tree Entries " << n << std::endl;
110 for (
int i = 0; i <
n; ++i) {
112 int ntrk = pTracks->size();
115 for (
int j = 0; j < ntrk; ++j) {
122 sum += v.
x() + v.
y() + v.
z() + v.
t();
129 std::cout <<
" Time for new Vector " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
131 TCanvas *c1 =
new TCanvas(
"c1",
"demo of Trees",10,10,600,800);
152 int mathcoreVectorCollection() {
154 #if defined(__CINT__) && !defined(__MAKECINT__)
159 using namespace ROOT::Math;
161 cout <<
"This tutorial can run only using ACliC, compiling it by doing: " << endl;
162 cout <<
"\t .x tutorials/math/mathcoreVectorCollection.C+" << endl;
170 std::cout <<
"ERROR: Found difference in Vector when reading ( " <<
s1 <<
" != " <<
s2 <<
" diff = " <<
fabs(
s1-
s2) <<
" ) " << std::endl;
179 return mathcoreVectorCollection();
Scalar E() const
return 4-th component (time, or energy for a 4-momentum vector)
double read(const std::string &file_name)
reading
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.
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 write(int n, const std::string &file_name, const std::string &vector_type, int compress=0)
writing
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...
virtual Int_t Fill()
Fill all branches.
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
virtual void Print(Option_t *option="") const
Print a summary of the tree contents.
void Stop()
Stop the stopwatch.
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=0)
Change branch address, dealing with clone trees properly.
This is the base class for the ROOT Random number generators.
Scalar Eta() const
pseudorapidity
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)
R__EXTERN TSystem * gSystem
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Scalar Pt() const
return the transverse spatial component sqrt ( X**2 + Y**2 )
1-D histogram with a double per channel (see TH1 documentation)}
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
virtual Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="")
Create one branch for each element in the collection.
Scalar Theta() const
polar Angle
virtual Long64_t GetEntries() const
A TTree object has a header with a name and a title.
virtual Int_t Poisson(Double_t mean)
Generates a random integer N according to a Poisson law.