#include "iostream" #include #include #include #include #include #include "TFile.h" #include "TTree.h" #include "TTreeReader.h" #include "TTreeReaderValue.h" #include "TTreeReaderArray.h" using namespace std; void tests(){ TFile *hfile = new TFile("unweighted.root","read"); TTree *LHEF=(TTree*)hfile->Get("LHEF"); auto nen = LHEF->GetEntries(); LHEF->Show(); TH1F *invm = new TH1F("H_invmass","GeV",100,0,150); TTreeReader reader("LHEF",hfile); TTreeReaderArray ParticleM(reader,"Particle.M"); long long e = 0; while (reader.Next()) { for (size_t j=0; j< ParticleM.GetSize() ;j++) { Double_t k = ParticleM.At(j); invm->Fill(k); } } invm->Draw(); } void mass() { TFile *hfile = new TFile("unweighted.root","read"); TTree *LHEF=(TTree*)hfile->Get("LHEF"); LHEF->SetBranchStatus("*",0); LHEF->SetBranchStatus("Particle.M",1); LHEF->SetBranchStatus("Event_size",1); Long64_t nentries = LHEF->GetEntries(); Int_t nParticle; Double_t Particle_M[9]; LHEF->SetMakeClass(true); LHEF->SetBranchAddress("Particle",&nParticle); LHEF->SetBranchAddress("Particle.M",&(Particle_M[0])); TH1F *invm = new TH1F("H_invmass","GeV",100,0,150); Double_t k; for (Int_t i=0; i< LHEF->GetEntries();i++) { LHEF->GetEntry(i); for (Int_t j=0; j< nParticle ;j++) { k = Particle_M[j]; cout<< Particle_M[j]<Fill(k); } cout<Draw(); }