Draw command in histogram

Hello friends,
When I use Draw command I have a canvas without any histogram, but when I use DrawNormalized I have a histogram. What is the problem?
Thanks

Please read tips for efficient and successful posting and posting code

_ROOT Version: 6.10
Platform: linux
Compiler: Not Provided


I’m afraid it’s impossible to tell what’s wrong without knowing what you are doing in your code… Can you post a running piece of code showing the issue?

it want to reconstruct the the invariant mass of top quark by semileptonic channel here is part of my code:

TCanvas *cc1 = new TCanvas("cc1", "Top reconstruction", 1200, 800);
  //TCanvas *cc2 = new TCanvas("cc1", "Top reconstruction", 1200, 800);
  //TCanvas *cc3 = new TCanvas("cc1", "Top reconstruction", 1200, 800);
  
  
  //Draw Results
  // gStyle->SetOptStat(0);
  cc1->cd(1);
  //gPad->SetTickx(2);
  hh1->DrawNormalized();
  cc2->cd(2);
  //gPad->SetTickx(2);
  //gPad->SetTicky(2);
  hh2->DrawNormalized();
  cc3->cd(3);
  hh3->Draw Normalized();

however DrawCopy like DrawNormalized is working but Draw don’t work

Maybe because your histogram belongs to a file? or to another canvas? or is going out of scope, or…

but it works with DrawCopy and DrawNormalized!
is it possible to draw a histogram with DrawCopy but doesn’t draw with Draw command?

Yes, DrawCopy() creates a copy of the histogram in the current pad. It’s difficult to know exactly what’s happening by just looking at a tiny part of your code…

here is my code :


#define MyClass_cxx
#include "MyClass.h"
#include <iostream>
#include <math.h>
using namespace std;
void MyClass::Loop()
{

}
int main()
{

  MyClass LHEFIPM;
 
  // Event_lightquark_num & Event_lepton_num count the number of lightquark & lepton in the event
  int Event_lightquark_num, Event_lepton_num;
  
  // noulepton_pos, lepton_pos, b_pos, bbar_pos, q_pos ,and qbar_pos save the position (0-11) of particles in the event
  int noulepton_pos, lepton_pos, b_pos, bbar_pos, q_pos, qbar_pos;
  
  // numberofsemi counts total number of semileptonic Event in all events.
  int numberofsemi=0;
  
  //ax^2 + bx + c = 0, delta=b^2-4a*c, X1 and X2 are the answers of the equation, Pz_rec is reconstruction of noulepton Pz
  double_t equ_a = 1, equ_b, equ_c, delta, X1, X2, Pz_rec;
  
  //error_rec is error of Pz reconstruction
  double_t error_rec;
  
  //w_invar is constant, c_speed is constant
  double_t w_invar=80.379, c_speed= 1 ;
  
  // leptonic invariant mass of top quark
  double_t lep_topmass;
  
  // hadronic invariant mass of top quark
  double_t had_topmass;
  


  TH1F *hh1 = new TH1F("hh1", "Pz Reconstruction Error", 100, -3, 3);
  TH1F *hh2 = new TH1F("hh2", " leptonic invariant mass of top quark", 100, 100, 300);
  TH1F *hh3 = new TH1F("hh3", "hadronic invariant mass of top quark", 100, 100, 300);
  
  // loop over all Events
  for (Int_t i=0; i < LHEFIPM.EvGetEntries() ; i++)
    {
    
    LHEFIPM.GetEntry(i);
   
    // reset counter
    Event_lightquark_num = 0 ;
    Event_lepton_num = 0 ;
   
    
    // loop over the Event Particles   
    for(Int_t j=0; j < LHEFIPM.kMaxParticle ; j++)
      {
	
      // Check stable particle
      if(LHEFIPM.Particle_Status[j] == 1)
	{
	  
	// Check PID for q lightquark
	if(LHEFIPM.Particle_PID[j] == 1 || LHEFIPM.Particle_PID[j] == 2 ||  LHEFIPM.Particle_PID[j] == 3 )
	  {
	    
	  //count lightquark
	  Event_lightquark_num++;
	  
	  //save the position of q
	  q_pos = j;
	  
	  }
	
	// Check PID for qbar lightquark
	if( LHEFIPM.Particle_PID[j] == -1 ||LHEFIPM.Particle_PID[j] == -2 || LHEFIPM.Particle_PID[j] == -3)
	  {
	    
	  //count lightquark
	  Event_lightquark_num++;
	  
	  //save the position of qbar
	  qbar_pos = j;
	  }
	
	// Check PID for lepton
	if(LHEFIPM.Particle_PID[j] == 11 || LHEFIPM.Particle_PID[j] == -11 || LHEFIPM.Particle_PID[j] == 13 || LHEFIPM.Particle_PID[j] == -13 || LHEFIPM.Particle_PID[j] == 15 || LHEFIPM.Particle_PID[j] == -15 || LHEFIPM.Particle_PID[j] == 17 || LHEFIPM.Particle_PID[j] == -17 )
	  {
	    
	  //count lepton
	  Event_lepton_num++;
	  
	  //save the position of lepton , it just works for semileptonic and for fullleptonic needs lepton_pos array
	  lepton_pos = j;
	  
	  }
	// Check PID for noulepton
	if( LHEFIPM.Particle_PID[j] == 12 || LHEFIPM.Particle_PID[j] == -12 || LHEFIPM.Particle_PID[j] == 14 || LHEFIPM.Particle_PID[j] == -14 ||  LHEFIPM.Particle_PID[j] == 16 || LHEFIPM.Particle_PID[j] == -16 || LHEFIPM.Particle_PID[j] == 18 || LHEFIPM.Particle_PID[j] == -18)
	  {
	    
	  //count lepton
	  Event_lepton_num++;
	  
	  //save the position of noulepton , it just works for semileptonic and for fullleptonic needs noulepton_pos array
	  noulepton_pos = j;
	   
          }
	
	// Check PID for b
	if( LHEFIPM.Particle_PID[j] == 5)
	  {
	    
	  //save the position of noulepton
	  b_pos=j;
	  
	  }
	
	// Check PID for bbar
	if( LHEFIPM.Particle_PID[j] == -5)
	  
	  {
	    
	  //save the position of noulepton
	  bbar_pos=j;
	  
	  }
	
	} //End of Check stable particle
      
      }//End of loop over the Event Particles
    
      // Check semileptonic event
      if(Event_lightquark_num == 2 && Event_lepton_num == 2 )
	{
	//solve equation  
	equ_b = 2 * LHEFIPM.Particle_Pz[lepton_pos];
	equ_c = -pow((LHEFIPM.Particle_E[lepton_pos])/c_speed,2)+pow((LHEFIPM.Particle_Px[lepton_pos]),2)+pow((LHEFIPM.Particle_Py[lepton_pos]),2)+pow((LHEFIPM.Particle_Pz[lepton_pos]),2)-pow((LHEFIPM.Particle_E[noulepton_pos])/c_speed , 2)+pow((LHEFIPM.Particle_Px[noulepton_pos]), 2)+pow((LHEFIPM.Particle_Py[noulepton_pos]),2)+2*(-(LHEFIPM.Particle_E[lepton_pos]/c_speed)*(LHEFIPM.Particle_E[noulepton_pos]/c_speed)+LHEFIPM.Particle_Px[lepton_pos]*LHEFIPM.Particle_Px[noulepton_pos]+LHEFIPM.Particle_Py[lepton_pos]*LHEFIPM.Particle_Py[noulepton_pos])+(w_invar)*(w_invar);
        delta = pow((equ_b),2)-(4*equ_a*equ_c);

	//check delta and choose right answer
	if(delta>0)
	  {
	    X1=(-(equ_b)-sqrt(delta))/(2*(equ_a));
	    X2=(-(equ_b)+sqrt(delta))/(2*(equ_a));
	    if(abs(X1)<abs(X2))
	      {
		Pz_rec = X1;
	      }
	    else
	      {
		Pz_rec = X2;
	      }
	  }
	else
	  {	    
	    Pz_rec = (-(equ_b))/(2*(equ_a));
	  }
	// calculate error of reconstruction
	error_rec =((LHEFIPM.Particle_Pz[noulepton_pos])-(Pz_rec))/(LHEFIPM.Particle_Pz[noulepton_pos]);
	

	//fill hh1 with error of reconstruction
	hh1->Fill(error_rec);

	// calculate leptonic top quark mass
        lep_topmass= sqrt(pow((LHEFIPM.Particle_E[lepton_pos])/c_speed +(LHEFIPM.Particle_E[noulepton_pos])/c_speed + (LHEFIPM.Particle_E[b_pos])/c_speed,2)-pow( LHEFIPM.Particle_Px[lepton_pos] + LHEFIPM.Particle_Px[noulepton_pos] + LHEFIPM.Particle_Px[b_pos] ,2) - pow (LHEFIPM.Particle_Py[lepton_pos] + LHEFIPM.Particle_Py[noulepton_pos] + LHEFIPM.Particle_Py[b_pos] ,2)- pow( LHEFIPM.Particle_Pz[lepton_pos]+ Pz_rec + LHEFIPM.Particle_Pz[b_pos] ,2) );
	
	// fill hh2 with mass of leptonic top quark
        hh2->Fill(lep_topmass);

	// calculate hadronic top quark mass
	had_topmass = sqrt(pow((LHEFIPM.Particle_E[q_pos])/c_speed + (LHEFIPM.Particle_E[qbar_pos])/c_speed + (LHEFIPM.Particle_E[bbar_pos])/c_speed,2)-pow( LHEFIPM.Particle_Px[q_pos] + LHEFIPM.Particle_Px[qbar_pos] + LHEFIPM.Particle_Px[bbar_pos] ,2) - pow (LHEFIPM.Particle_Py[q_pos] + LHEFIPM.Particle_Py[qbar_pos] + LHEFIPM.Particle_Py[bbar_pos] ,2)- pow( LHEFIPM.Particle_Pz[q_pos]+ LHEFIPM.Particle_Pz[qbar_pos] + LHEFIPM.Particle_Pz[bbar_pos] ,2) );

	// fill hh3 with mass of hadronic top quark
        hh3->Fill(had_topmass);

	//count semileptonic
	numberofsemi++;

	}// End of Check semileptonic event
      
  }// End of loop over all Events

  TCanvas *cc1 = new TCanvas("cc1", "Top reconstruction", 1200, 800);
  //TCanvas *cc2 = new TCanvas("cc1", "Top reconstruction", 1200, 800);
  //TCanvas *cc3 = new TCanvas("cc1", "Top reconstruction", 1200, 800);
  
  
  //Draw Results
  // gStyle->SetOptStat(0);
  cc1->cd(1);
  //gPad->SetTickx(2);
  hh1->DrawNormalized();
  cc2->cd(2);
  //gPad->SetTickx(2);
  //gPad->SetTicky(2);
  hh2->DrawNormalized();
  cc3->cd(3);
  hh3->Draw Normalized();
  
  return numberofsemi;
}// End of main

Can you try to move the creation of the TCanvas before the creation of the TH1F? (and everything before opening the ROOT file, if any)?

in the first place I define TCanvas before the creation of TH1F but I saw a code that define it at the end of the code because of that I move it there but I will change it now again and try it

See also the ROOT Object Ownership chapter of the User’s guide

thanks I am reading it now moreover I move TCanvas before the definition of TH1F but it didn’t work unfortunately.

OK, that’s weird… I guess I cannot run your code, so I don’t know what more to advise…

I make a small changes in my code, would you please check it again whether it works in your or not?

#define MyClass_cxx
#include “MyClass.h”
#include
#include <math.h>
using namespace std;
void MyClass::Loop()
{

}
int main()
{

MyClass LHEFIPM;

// Event_lightquark_num & Event_lepton_num count the number of lightquark & lepton in the event
int Event_lightquark_num, Event_lepton_num;

// noulepton_pos, lepton_pos, b_pos, bbar_pos, q_pos ,and qbar_pos save the position (0-11) of particles in the event
int noulepton_pos, lepton_pos, b_pos, bbar_pos, q_pos, qbar_pos;

// numberofsemi counts total number of semileptonic Event in all events.
int numberofsemi=0;

//ax^2 + bx + c = 0, delta=b^2-4a*c, X1 and X2 are the answers of the equation, Pz_rec is reconstruction of noulepton Pz
double_t equ_a = 1, equ_b, equ_c, delta, X1, X2, Pz_rec;

//error_rec is error of Pz reconstruction
double_t error_rec;

//w_invar is constant, c_speed is constant
double_t w_invar=80.379, c_speed= 1 ;

// leptonic invariant mass of top quark
double_t lep_topmass;

// hadronic invariant mass of top quark
double_t had_topmass;

TCanvas *cc1 = new TCanvas(“cc1”, “Top reconstruction”, 1200, 800);
//TCanvas *cc2 = new TCanvas(“cc1”, “Top reconstruction”, 1200, 800);
//TCanvas *cc3 = new TCanvas(“cc1”, “Top reconstruction”, 1200, 800);

TH1F *hh1 = new TH1F(“hh1”, “Pz Reconstruction Error”, 100, -3, 3);
TH1F *hh2 = new TH1F(“hh2”, " leptonic invariant mass of top quark", 100, 100, 300);
TH1F *hh3 = new TH1F(“hh3”, “hadronic invariant mass of top quark”, 100, 100, 300);

// loop over all Events
for (Int_t i=0; i < LHEFIPM.EvGetEntries() ; i++)
{

LHEFIPM.GetEntry(i);

// reset counter
Event_lightquark_num = 0 ;
Event_lepton_num = 0 ;


// loop over the Event Particles   
for(Int_t j=0; j < LHEFIPM.kMaxParticle ; j++)
  {

  // Check stable particle
  if(LHEFIPM.Particle_Status[j] == 1)
{
  
// Check PID for q lightquark
if(LHEFIPM.Particle_PID[j] == 1 || LHEFIPM.Particle_PID[j] == 2 ||  LHEFIPM.Particle_PID[j] == 3 )
  {
    
  //count lightquark
  Event_lightquark_num++;
  
  //save the position of q
  q_pos = j;
  
  }

// Check PID for qbar lightquark
if( LHEFIPM.Particle_PID[j] == -1 ||LHEFIPM.Particle_PID[j] == -2 || LHEFIPM.Particle_PID[j] == -3)
  {
    
  //count lightquark
  Event_lightquark_num++;
  
  //save the position of qbar
  qbar_pos = j;
  }

// Check PID for lepton
if(LHEFIPM.Particle_PID[j] == 11 || LHEFIPM.Particle_PID[j] == -11 || LHEFIPM.Particle_PID[j] == 13 || LHEFIPM.Particle_PID[j] == -13 || LHEFIPM.Particle_PID[j] == 15 || LHEFIPM.Particle_PID[j] == -15 || LHEFIPM.Particle_PID[j] == 17 || LHEFIPM.Particle_PID[j] == -17 )
  {
    
  //count lepton
  Event_lepton_num++;
  
  //save the position of lepton , it just works for semileptonic and for fullleptonic needs lepton_pos array
  lepton_pos = j;
  
  }
// Check PID for noulepton
if( LHEFIPM.Particle_PID[j] == 12 || LHEFIPM.Particle_PID[j] == -12 || LHEFIPM.Particle_PID[j] == 14 || LHEFIPM.Particle_PID[j] == -14 ||  LHEFIPM.Particle_PID[j] == 16 || LHEFIPM.Particle_PID[j] == -16 || LHEFIPM.Particle_PID[j] == 18 || LHEFIPM.Particle_PID[j] == -18)
  {
    
  //count lepton
  Event_lepton_num++;
  
  //save the position of noulepton , it just works for semileptonic and for fullleptonic needs noulepton_pos array
  noulepton_pos = j;
   
      }

// Check PID for b
if( LHEFIPM.Particle_PID[j] == 5)
  {
    
  //save the position of noulepton
  b_pos=j;
  
  }

// Check PID for bbar
if( LHEFIPM.Particle_PID[j] == -5)
  
  {
    
  //save the position of noulepton
  bbar_pos=j;
  
  }

} //End of Check stable particle
  
  }//End of loop over the Event Particles

  // Check semileptonic event
  if(Event_lightquark_num == 2 && Event_lepton_num == 2 )
{
//solve equation  
equ_b = 2 * LHEFIPM.Particle_Pz[lepton_pos];
equ_c = -pow((LHEFIPM.Particle_E[lepton_pos])/c_speed,2)+pow((LHEFIPM.Particle_Px[lepton_pos]),2)+pow((LHEFIPM.Particle_Py[lepton_pos]),2)+pow((LHEFIPM.Particle_Pz[lepton_pos]),2)-pow((LHEFIPM.Particle_E[noulepton_pos])/c_speed , 2)+pow((LHEFIPM.Particle_Px[noulepton_pos]), 2)+pow((LHEFIPM.Particle_Py[noulepton_pos]),2)+2*(-(LHEFIPM.Particle_E[lepton_pos]/c_speed)*(LHEFIPM.Particle_E[noulepton_pos]/c_speed)+LHEFIPM.Particle_Px[lepton_pos]*LHEFIPM.Particle_Px[noulepton_pos]+LHEFIPM.Particle_Py[lepton_pos]*LHEFIPM.Particle_Py[noulepton_pos])+(w_invar)*(w_invar);
    delta = pow((equ_b),2)-(4*equ_a*equ_c);

//check delta and choose right answer
if(delta>0)
  {
    X1=(-(equ_b)-sqrt(delta))/(2*(equ_a));
    X2=(-(equ_b)+sqrt(delta))/(2*(equ_a));
    if(abs(X1)<abs(X2))
      {
	Pz_rec = X1;
      }
    else
      {
	Pz_rec = X2;
      }
  }
else
  {	    
    Pz_rec = (-(equ_b))/(2*(equ_a));
  }
// calculate error of reconstruction
error_rec =((LHEFIPM.Particle_Pz[noulepton_pos])-(Pz_rec))/(LHEFIPM.Particle_Pz[noulepton_pos]);


//fill hh1 with error of reconstruction
hh1->Fill(error_rec);

// calculate leptonic top quark mass
    lep_topmass= sqrt(pow((LHEFIPM.Particle_E[lepton_pos])/c_speed +(LHEFIPM.Particle_E[noulepton_pos])/c_speed + (LHEFIPM.Particle_E[b_pos])/c_speed,2)-pow( LHEFIPM.Particle_Px[lepton_pos] + LHEFIPM.Particle_Px[noulepton_pos] + LHEFIPM.Particle_Px[b_pos] ,2) - pow (LHEFIPM.Particle_Py[lepton_pos] + LHEFIPM.Particle_Py[noulepton_pos] + LHEFIPM.Particle_Py[b_pos] ,2)- pow( LHEFIPM.Particle_Pz[lepton_pos]+ Pz_rec + LHEFIPM.Particle_Pz[b_pos] ,2) );

// fill hh2 with mass of leptonic top quark
    hh2->Fill(lep_topmass);

// calculate hadronic top quark mass
had_topmass = sqrt(pow((LHEFIPM.Particle_E[q_pos])/c_speed + (LHEFIPM.Particle_E[qbar_pos])/c_speed + (LHEFIPM.Particle_E[bbar_pos])/c_speed,2)-pow( LHEFIPM.Particle_Px[q_pos] + LHEFIPM.Particle_Px[qbar_pos] + LHEFIPM.Particle_Px[bbar_pos] ,2) - pow (LHEFIPM.Particle_Py[q_pos] + LHEFIPM.Particle_Py[qbar_pos] + LHEFIPM.Particle_Py[bbar_pos] ,2)- pow( LHEFIPM.Particle_Pz[q_pos]+ LHEFIPM.Particle_Pz[qbar_pos] + LHEFIPM.Particle_Pz[bbar_pos] ,2) );

// fill hh3 with mass of hadronic top quark
    hh3->Fill(had_topmass);

//count semileptonic
numberofsemi++;

}// End of Check semileptonic event

}// End of loop over all Events

//Draw Results
// gStyle->SetOptStat(0);
cc1->cd(1);
//gPad->SetTickx(2);
hh1->DrawCopy();
//cc2->cd(2);
//gPad->SetTickx(2);
//gPad->SetTicky(2);
//hh2->DrawNormalized();
//cc3->cd(3);
// hh3->DrawNormalized();

return numberofsemi;
}// End of main

here is MyClass.h class:

#ifndef MyClass_h
#define MyClass_h

#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>

// Header file for the classes stored in the TTree if any.
#include "TClonesArray.h"
#include "TObject.h"

class MyClass {
public :
   TTree*          fChain;   //!pointer to the analyzed TTree or TChain
   Int_t           fCurrent; //!current Tree number in a TChain

// Fixed size dimensions of array or collections stored in the TTree if any.
   static constexpr Int_t kMaxEvent = 1;
   static constexpr Int_t kMaxRwgt = 1;
   static constexpr Int_t kMaxParticle = 12;

   // Declaration of leaf types
   Int_t           Event_;
   UInt_t          Event_fUniqueID[kMaxEvent];   //[Event_]
   UInt_t          Event_fBits[kMaxEvent];   //[Event_]
   Long64_t        Event_Number[kMaxEvent];   //[Event_]
   Int_t           Event_Nparticles[kMaxEvent];   //[Event_]
   Int_t           Event_ProcessID[kMaxEvent];   //[Event_]
   Double_t        Event_Weight[kMaxEvent];   //[Event_]
   Double_t        Event_ScalePDF[kMaxEvent];   //[Event_]
   Double_t        Event_CouplingQED[kMaxEvent];   //[Event_]
   Double_t        Event_CouplingQCD[kMaxEvent];   //[Event_]
   Int_t           Event_size;
   Int_t           Rwgt_;
   UInt_t          Rwgt_fUniqueID[kMaxRwgt];   //[Rwgt_]
   UInt_t          Rwgt_fBits[kMaxRwgt];   //[Rwgt_]
   Double_t        Rwgt_Weight[kMaxRwgt];   //[Rwgt_]
   Int_t           Rwgt_size;
   Int_t           Particle_;
   UInt_t          Particle_fUniqueID[kMaxParticle];   //[Particle_]
   UInt_t          Particle_fBits[kMaxParticle];   //[Particle_]
   Int_t           Particle_PID[kMaxParticle];   //[Particle_]
   Int_t           Particle_Status[kMaxParticle];   //[Particle_]
   Int_t           Particle_Mother1[kMaxParticle];   //[Particle_]
   Int_t           Particle_Mother2[kMaxParticle];   //[Particle_]
   Int_t           Particle_ColorLine1[kMaxParticle];   //[Particle_]
   Int_t           Particle_ColorLine2[kMaxParticle];   //[Particle_]
   Double_t        Particle_Px[kMaxParticle];   //[Particle_]
   Double_t        Particle_Py[kMaxParticle];   //[Particle_]
   Double_t        Particle_Pz[kMaxParticle];   //[Particle_]
   Double_t        Particle_E[kMaxParticle];   //[Particle_]
   Double_t        Particle_M[kMaxParticle];   //[Particle_]
   Double_t        Particle_PT[kMaxParticle];   //[Particle_]
   Double_t        Particle_Eta[kMaxParticle];   //[Particle_]
   Double_t        Particle_Phi[kMaxParticle];   //[Particle_]
   Double_t        Particle_Rapidity[kMaxParticle];   //[Particle_]
   Double_t        Particle_LifeTime[kMaxParticle];   //[Particle_]
   Double_t        Particle_Spin[kMaxParticle];   //[Particle_]
   Int_t           Particle_size;

   // List of branches
   TBranch        *b_Event_;   //!
   TBranch        *b_Event_fUniqueID;   //!
   TBranch        *b_Event_fBits;   //!
   TBranch        *b_Event_Number;   //!
   TBranch        *b_Event_Nparticles;   //!
   TBranch        *b_Event_ProcessID;   //!
   TBranch        *b_Event_Weight;   //!
   TBranch        *b_Event_ScalePDF;   //!
   TBranch        *b_Event_CouplingQED;   //!
   TBranch        *b_Event_CouplingQCD;   //!
   TBranch        *b_Event_size;   //!
   TBranch        *b_Rwgt_;   //!
   TBranch        *b_Rwgt_fUniqueID;   //!
   TBranch        *b_Rwgt_fBits;   //!
   TBranch        *b_Rwgt_Weight;   //!
   TBranch        *b_Rwgt_size;   //!
   TBranch        *b_Particle_;   //!
   TBranch        *b_Particle_fUniqueID;   //!
   TBranch        *b_Particle_fBits;   //!
   TBranch        *b_Particle_PID;   //!
   TBranch        *b_Particle_Status;   //!
   TBranch        *b_Particle_Mother1;   //!
   TBranch        *b_Particle_Mother2;   //!
   TBranch        *b_Particle_ColorLine1;   //!
   TBranch        *b_Particle_ColorLine2;   //!
   TBranch        *b_Particle_Px;   //!
   TBranch        *b_Particle_Py;   //!
   TBranch        *b_Particle_Pz;   //!
   TBranch        *b_Particle_E;   //!
   TBranch        *b_Particle_M;   //!
   TBranch        *b_Particle_PT;   //!
   TBranch        *b_Particle_Eta;   //!
   TBranch        *b_Particle_Phi;   //!
   TBranch        *b_Particle_Rapidity;   //!
   TBranch        *b_Particle_LifeTime;   //!
   TBranch        *b_Particle_Spin;   //!
   TBranch        *b_Particle_size;   //!

   MyClass(TTree *tree=0);
   virtual ~MyClass();
   virtual Int_t    Cut(Long64_t entry);
   virtual Int_t    GetEntry(Long64_t entry);
   virtual Long64_t LoadTree(Long64_t entry);
   virtual void     Init(TTree *tree);
   virtual void     Loop();
   virtual Bool_t   Notify();
   virtual void     Show(Long64_t entry = -1);
   virtual Int_t    EvGetEntries();
};

#endif
#ifdef MyClass_cxx
MyClass::MyClass(TTree *tree) : fChain(0) 
{
// if parameter tree is not specified (or zero), connect the file
// used to generate this class and read the Tree.
   if (tree == 0) {
      TFile *f = (TFile*)gROOT->GetListOfFiles()->FindObject("ttbar.root");
      if (!f || !f->IsOpen()) {
         f = new TFile("ttbar.root");
      }
      f->GetObject("LHEF",tree);

   }
   Init(tree);
}

MyClass::~MyClass()
{
   if (!fChain) return;
   delete fChain->GetCurrentFile();
}

Int_t MyClass::GetEntry(Long64_t entry)
{
// Read contents of entry.
   if (!fChain) return 0;
   return fChain->GetEntry(entry);
}
Long64_t MyClass::LoadTree(Long64_t entry)
{
// Set the environment to read one entry
   if (!fChain) return -5;
   Long64_t centry = fChain->LoadTree(entry);
   if (centry < 0) return centry;
   if (fChain->GetTreeNumber() != fCurrent) {
      fCurrent = fChain->GetTreeNumber();
      Notify();
   }
   return centry;
}

Int_t MyClass::EvGetEntries()
{
	Int_t numberofevents = fChain->GetEntries();
	return numberofevents;
}

void MyClass::Init(TTree *tree)
{
   // The Init() function is called when the selector needs to initialize
   // a new tree or chain. Typically here the branch addresses and branch
   // pointers of the tree will be set.
   // It is normally not necessary to make changes to the generated
   // code, but the routine can be extended by the user if needed.
   // Init() will be called many times when running on PROOF
   // (once per file to be processed).

   // Set branch addresses and branch pointers
   if (!tree) return;
   fChain = tree;
   fCurrent = -1;
   fChain->SetMakeClass(1);

   fChain->SetBranchAddress("Event", &Event_, &b_Event_);
   fChain->SetBranchAddress("Event.fUniqueID", Event_fUniqueID, &b_Event_fUniqueID);
   fChain->SetBranchAddress("Event.fBits", Event_fBits, &b_Event_fBits);
   fChain->SetBranchAddress("Event.Number", Event_Number, &b_Event_Number);
   fChain->SetBranchAddress("Event.Nparticles", Event_Nparticles, &b_Event_Nparticles);
   fChain->SetBranchAddress("Event.ProcessID", Event_ProcessID, &b_Event_ProcessID);
   fChain->SetBranchAddress("Event.Weight", Event_Weight, &b_Event_Weight);
   fChain->SetBranchAddress("Event.ScalePDF", Event_ScalePDF, &b_Event_ScalePDF);
   fChain->SetBranchAddress("Event.CouplingQED", Event_CouplingQED, &b_Event_CouplingQED);
   fChain->SetBranchAddress("Event.CouplingQCD", Event_CouplingQCD, &b_Event_CouplingQCD);
   fChain->SetBranchAddress("Event_size", &Event_size, &b_Event_size);
   fChain->SetBranchAddress("Rwgt", &Rwgt_, &b_Rwgt_);
   fChain->SetBranchAddress("Rwgt.fUniqueID", &Rwgt_fUniqueID, &b_Rwgt_fUniqueID);
   fChain->SetBranchAddress("Rwgt.fBits", &Rwgt_fBits, &b_Rwgt_fBits);
   fChain->SetBranchAddress("Rwgt.Weight", &Rwgt_Weight, &b_Rwgt_Weight);
   fChain->SetBranchAddress("Rwgt_size", &Rwgt_size, &b_Rwgt_size);
   fChain->SetBranchAddress("Particle", &Particle_, &b_Particle_);
   fChain->SetBranchAddress("Particle.fUniqueID", Particle_fUniqueID, &b_Particle_fUniqueID);
   fChain->SetBranchAddress("Particle.fBits", Particle_fBits, &b_Particle_fBits);
   fChain->SetBranchAddress("Particle.PID", Particle_PID, &b_Particle_PID);
   fChain->SetBranchAddress("Particle.Status", Particle_Status, &b_Particle_Status);
   fChain->SetBranchAddress("Particle.Mother1", Particle_Mother1, &b_Particle_Mother1);
   fChain->SetBranchAddress("Particle.Mother2", Particle_Mother2, &b_Particle_Mother2);
   fChain->SetBranchAddress("Particle.ColorLine1", Particle_ColorLine1, &b_Particle_ColorLine1);
   fChain->SetBranchAddress("Particle.ColorLine2", Particle_ColorLine2, &b_Particle_ColorLine2);
   fChain->SetBranchAddress("Particle.Px", Particle_Px, &b_Particle_Px);
   fChain->SetBranchAddress("Particle.Py", Particle_Py, &b_Particle_Py);
   fChain->SetBranchAddress("Particle.Pz", Particle_Pz, &b_Particle_Pz);
   fChain->SetBranchAddress("Particle.E", Particle_E, &b_Particle_E);
   fChain->SetBranchAddress("Particle.M", Particle_M, &b_Particle_M);
   fChain->SetBranchAddress("Particle.PT", Particle_PT, &b_Particle_PT);
   fChain->SetBranchAddress("Particle.Eta", Particle_Eta, &b_Particle_Eta);
   fChain->SetBranchAddress("Particle.Phi", Particle_Phi, &b_Particle_Phi);
   fChain->SetBranchAddress("Particle.Rapidity", Particle_Rapidity, &b_Particle_Rapidity);
   fChain->SetBranchAddress("Particle.LifeTime", Particle_LifeTime, &b_Particle_LifeTime);
   fChain->SetBranchAddress("Particle.Spin", Particle_Spin, &b_Particle_Spin);
   fChain->SetBranchAddress("Particle_size", &Particle_size, &b_Particle_size);
   Notify();
}

Bool_t MyClass::Notify()
{
   // The Notify() function is called when a new file is opened. This
   // can be either for a new TTree in a TChain or when when a new TTree
   // is started when using PROOF. It is normally not necessary to make changes
   // to the generated code, but the routine can be extended by the
   // user if needed. The return value is currently not used.

   return kTRUE;
}

void MyClass::Show(Long64_t entry)
{
// Print contents of entry.
// If entry is not specified, print current entry
   if (!fChain) return;
   fChain->Show(entry,15);
}
Int_t MyClass::Cut(Long64_t entry)
{
// This function may be called from Loop.
// returns  1 if entry is accepted.
// returns -1 otherwise.
   return 1;
}
#endif // #ifdef MyClass_cxx

Well, thanks, but it doesn’t really help… And please read Posting code? Read this first!

thanks a lot.