#define MyClass_cxx
#include "MyClassChain.h"


//------------------------------------------------------------------------
// Loop is a method automatically created by MakeClass().
// It contains the loop to look at each event that is in the tree
// The Px for each event is plotted in a histogram.
//------------------------------------------------------------------------
void MyClass::Loop()
{
	if (fChain == 0) return;
	
	// create a histogram 
	TH1F *aHisto		= new TH1F("aHisto","fPx",100,-5,5);
	TH1F *smallHisto	= new TH1F("small","fPx 100",100,-5,5);	
	
	// create a pointer to a track
	Track *track = 0;
	Int_t nTracks = 0;

 	// the number of events
	Int_t nentries = Int_t(fChain->GetEntries());
	
 	// loop through the events 
	for (Int_t i = 0; i < nentries; i++) {

		// get the event
  		b_event->GetEntry(i);
		
		// get the number of tracks for this event		
		nTracks = event->GetNtrack();
		
		
		// loop through the tracks 
		for (Int_t j = 0; j < nTracks; j++){
			track = (Track*) event->GetTracks()->At(j);
			aHisto->Fill(track->GetPx());
			if (j < 100)
				smallHisto->Fill(track->GetPx());
		}
	}
 
	// draw the histogram
	aHisto->Draw();
	smallHisto->Draw("Same");}






	
