Constructin my own variable

Hi All,
I’m really new to Root and I have been stuck the last days on (I think) a very simple issue.

I have generated a root file with MadGraph, and in the picture in the link (http://img837.imageshack.us/img837/3301/5lf.png) you can see the structure of the file that is called tag_1_pythia_lhe_events.root.

My goal is to try to construct (and plot of course) my own variable, so I was trying to build the transvers momenta from Px and Py and to compared with the distribution PT.

Following a guide that I found online I have opened root and I have typed the following lines

TFile myFile(“tag_1_pythia_lhe_events.root”)
LHEF->MakeClass(“Analyze”)

And now I got a file Analyze.H and Analyze.C that I shoul edit
In the file Analyze.C (below the message) I have put at line 33 the following line

Double_t pt = TMath::Sqrt(Px*Px + Py*Py);

I have saved an inside root I have typed
.L Analyze.C
Analyze a
a.Loop

but I get

root [4] aaa.Loop()
Error: Symbol px is not defined in current scope Analyze.C:33:
Error: Symbol px is not defined in current scope Analyze.C:33:
Error: Symbol py is not defined in current scope Analyze.C:33:
Error: Symbol py is not defined in current scope Analyze.C:33:
*** Interpreter error recovered ***

So looks like I’m not taking correctly the variables Px and Px to construct my Pt.

I tryed to understand on my own, but I’m a bit stuck, does any body can help me?

Thanks in advance!


Analyze.c

#define Analyze_cxx
#include “Analyze.h”
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>

void Analyze::Loop()
{
// In a ROOT session, you can do:
// Root > .L Analyze.C
// Root > Analyze t
// Root > t.GetEntry(12); // Fill t data members with entry number 12
// Root > t.Show(); // Show values of entry 12
// Root > t.Show(16); // Read and show values of entry 16
// Root > t.Loop(); // Loop on all entries
//

// This is the loop skeleton where:
// jentry is the global entry number in the chain
// ientry is the entry number in the current Tree
// Note that the argument to GetEntry must be:
// jentry for TChain::GetEntry
// ientry for TTree::GetEntry and TBranch::GetEntry
//
// To read only selected branches, Insert statements like:
// METHOD1:
// fChain->SetBranchStatus("*",0); // disable all branches
// fChain->SetBranchStatus(“branchname”,1); // activate branchname
// METHOD2: replace line
// fChain->GetEntry(jentry); //read all branches
//by b_branchname->GetEntry(ientry); //read only this branch
if (fChain == 0) return;

Long64_t nentries = fChain->GetEntriesFast();

Long64_t nbytes = 0, nb = 0;
for (Long64_t jentry=0; jentry<nentries;jentry++) {
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
nb = fChain->GetEntry(jentry); nbytes += nb;
// if (Cut(ientry) < 0) continue;
}
}

Hi,
I’m could you send Analyze.h and Analyze.C file? This variable should be here. Btw. it’s quite strange that rootcint can’t see px variable if you use Px variable;

Hi, thanks!
Yes of course, here in attach.
In Analyze.C I only add line 34, where I tried to define pt in this way

Double_t pt = TMath::Sqrt(Px*Px + Py*Py);

Thanks a lot for your help
Analyze.h (9.15 KB)
Analyze.C (1.46 KB)

Hi,
I’m think this is because there are no such variable as Px, there is only Particle_Px and this is an array.

Thanks! And do you know how I can construct my pt variable?
I tried writing Particle_Px instead than Px, but it doesn’t work.

Would be of help if I attach also the .root file?
Or in case do you know a manual where I can learn hot to do these things?
Thanks!

Yes, please send root file.

Thanks a lot!
tag_1_pythia_lhe_events.root (438 KB)

Hi again,
I increased kMaxEvent and kMaxParticle to 2000 (to be sure that my event/particle array will not go outside of array size). Later in Loop I modify loop by adding code

for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; /* new code */ for(int i=0;i<Particle_size;i++){ cout<<Particle_Px[i]<<endl; Double_t Px = Particle_Px[i]; Double_t Py = Particle_Py[i]; Double_t Pt = TMath::Sqrt(Px*Px+Py*Py); pt->Fill(Pt);//histo to hold data } /* end of new code */ // if (Cut(ientry) < 0) continue; }