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) {
59 int nPart =
R.Poisson(5);
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);
66 double eta =
R.Uniform(-3,3);
70 double E =
sqrt( vcyl.R()*vcyl.R() + M*M);
73 pTracks->push_back(
q);
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);
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;
153int mathcoreVectorCollection() {
156 double s1 = write(nEvents);
160 std::cout <<
"ERROR: Found difference in Vector when reading ( " <<
s1 <<
" != " << s2 <<
" diff = " <<
fabs(
s1-s2) <<
" ) " << std::endl;
167 return mathcoreVectorCollection();
#define R(a, b, c, d, e, f, g, h, i)
Class describing a generic displacement vector in 3 dimensions.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
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.
virtual void Draw(Option_t *option="")
Draw this histogram with options.
virtual Int_t Write(const char *name=0, 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.
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.
int main(int argc, char **argv)
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
constexpr Double_t E()
Base of natural log:
static long int sum(long int i)