Problem with number of entries shown in histogram

Hello Rooters,

I have an admittedly simple query, it’s something that should be clear to me by now. However, much to my embarrassment, the following still puzzles me. I am simply trying to plot the entries of a branch in a TTree using a histogram, with given range

void M()
    TFile *fin = new TFile("outfile_2CEP.root");
    TTree *t1 = (TTree*)fin->Get("t1");
    //Float_t M;
   // t1->SetBranchAddress("M",&M);
    TH1F *h1   = new TH1F("h1","M distribution",1000, 2500, 4000);

The resulting histogram seems OK, but the number of entries quoted is the number of entries in the tree (I checked, t1->GetEntries();) and not the number of events binned in the mass range specified. Can someone help me understand this behaviour please?



Which is expected … t1->Draw("M>>h1"); loops over all the M values in the tree and for each of them does h1->Fill(M) . Each Fill counting for one entry …

Try: std::cout << h1->Integral() << std::endl; and/or: t1->Draw("M>>h1", "M>=2500 && M<4000");

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.