{ // Load shared libraries gSystem->Load("$ROOTSYS/lib/libPhysics.so"); gSystem->Load("libExRootAnalysisReader"); // Create chain of root trees TChain chain("Analysis"); chain.Add("test_1.root"); // Create object of class ExRootTree ExRootTree *tree = new ExRootTree(&chain); Long64_t numberOfEntries = tree->GetEntries(); // Get pointers to branches used in this analysis TClonesArray *branchVtx = tree->UseBranch("VtxPVF", "TRootVertex"); TClonesArray *branchJet = tree->UseBranch("JetIC5A", "TRootJet"); // Book histograms TH1 *histVtxZ = new TH1F("histVtxZ", "vertex position", 50, -50.0, 50.0); TH1 *histJetPz = new TH1F("histJetPz", "jet pz", 50, -50.0, 50.0); // Loop over all events for(Int_t entry = 0; entry < numberOfEntries; ++entry) { // Load selected branches with data from specified event tree->ReadEntry(entry); // If event contains at least 1 vertex if(branchVtx->GetEntries() > 0) { // Take first vertex TRootVertex *vtx = (TRootVertex*) branchVtx->At(0); // Plot vertex Z co-ordinate histVtxZ->Fill(vtx->Z); cout << vtx->Z << endl; } if(branchJet->GetEntries() > 0) { // Take first jet TRootJet *jet = (TRootJet*) branchJet->At(0); // Plot jet Z momentum histJetPz->Fill(jet->Pz); cout << jet->Pz << endl; } } // Show resulting histogram histVtxZ->Draw(); histJetPz->Draw(); }