#include #include #include "TH1.h" #include "TCanvas.h" using namespace std; void test(){ // Book histogram for distribution TH1 *hist_costh = new TH1F("costh", "cosTheta", 20, -1.0, 1.0); hist_costh->GetXaxis()->SetLimits(-1.0, 1.0); //hist_costh->GetXaxis()->SetRangeUser(-1.0, 1.0); // Load shared library gSystem->Load("/home/pramod/Packages/MG5_aMC_v2_7_3/ExRootAnalysis/libExRootAnalysis.so"); // Use your ExRootAnalysis path here gSystem->Load("libPhysics"); gSystem->Load("libMathCore"); // Create chain of root trees TChain chain("LHEF"); chain.Add("go-1.root"); // Create object of class ExRootTreeReader ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); Long64_t numberOfEntries = treeReader->GetEntries(); // Get pointers to branches used in this analysis TClonesArray *branchParticle = treeReader->UseBranch("Particle"); //print the number of Events in the file cout << "Number of evetns = " << numberOfEntries << endl; // Loop over all event for(Int_t entry = 0; entry ReadEntry(entry); // Create pointer to store the location of l- and l+ int e_pos; // Initialize the pointers e_pos=0; // Loop over all particle in a given event // Skip 1st two particles as they are incoming particles for(Int_t i = 2; i < branchParticle->GetEntries(); ++i) { // enlisting the index of generated particles // i'th particle of one event TRootLHEFParticle *p = (TRootLHEFParticle*) branchParticle->At(i); //electron if (p->PID == 11){ e_pos=i; } } // Acess final state particles with found positon TRootLHEFParticle *e1 = (TRootLHEFParticle*) branchParticle->At(e_pos); TLorentzVector vece; vece.SetPtEtaPhiM(e1->PT, e1->Eta, e1->Phi, e1->M); hist_costh->Fill(vece.CosTheta()); } hist_costh -> Draw(); } //main func ends here