Thank you @jalopezg to ping @couet
Anyway, waiting for @couet or someone else (for example, probably @Wile_E_Coyote @bellenot or @moneta may know the answer), I was trying to start to write the code and this is the updated macro
simlemma.cpp (130.3 KB)
As I wrote in my first message, I make the plots in this way
TH2F *hemitxxpsp = new TH2F("hemitxxpsp", "", 500, 0., 0.,5000, 0.,0.);
TString varhemitxxpsp = TString::Format("SecondaryParticleAng.x : PositionDirection.x >> hemitxxpsp");
ts->Draw(varhemitxxpsp);
i.e. my TTree in the Root file is ts
and my branches are SecondaryParticleAng.x
and PositionDirection.x
(for the x-x’ plots).
So, to calculate <xx’> (look the formula in my first message), I started to write this
TBranch *b_PositionDirection.x; //!
TBranch *b_SecondaryParticleAng.x; //!
float x[3];
float xp[3];
float xm;
float xpm;
float xxpmN;
float xxpm;
Long64_t nentries = ts->GetEntriesFast();
xm= hemitxxpsp->GetXaxis()->GetRMS();
xpm=hemitxxpsp->GetYaxis()->GetRMS();
for(Long64_t jentry=0; jentry<nentries;jentry++) {
xxpmN+= (x[0]-xm)*(xp[0]-xpm);
}
xxpm=xxpmN/nentries;
i.e.
-
Long64_t nentries = ts->GetEntriesFast();
I want to read how many entries I’ve in ts
-
xm= hemitxxpsp->GetXaxis()->GetRMS();
xpm=hemitxxpsp->GetYaxis()->GetRMS();
I want to calculate the means < x > and <x’>
-
for(Long64_t jentry=0; jentry<nentries;jentry++) {
xxpmN+= (x[0]-xm)*(xp[0]-xpm);
}
xxpm=xxpmN/nentries;
I want to calculate <xx’>, but I don’t know how to say to root that x[0] must be the entries of PositionDirection.x
and xp[0] must be the entries of SecondaryParticleAng.x
Please, do someone know how to finish my code (and eventually fix it if there are some errors)?
Thank you