Hi, I am trying to draw two leafs (leaf1 vs leaf2) in a branch of tree. I managed to draw all entries together using:
f = new TFile("myfile.root");
if ((!f) || f->IsZombie()) {delete f; return;}
f->GetObject("mytree", t);
if (!t) {delete f; return;} // just a precaution
gROOT->cd();
TTree *gt = (TTree *) f->Get("mytree");
TH2D *h2 = new TH2D("h2", "tracks;x;z", 100, -100, 100, 100, -100, 100);
h2->Sumw2(kTRUE);
t->Project("h2", "leaf1:leaf2", "");
delete f;
h2->Draw("COL");
h2->SetStats(0); //hide stats
But what I see is all events (entries from both leafs drawn. How do I filter to see event by event?
couet
2
What do you mean exactly ? the Project
command will fill h2
with leaf1 and leaf2 along x and y axis… I am not sure "event by event"mean is that case.
Attached is what I get. They are 100 events. I would like to show only one event if possible.
For example:
I wanted to loop over all entries in my tree and draw only one by one but it didn’t work and it showed the same result:
//for (int i=0;i<events;i++){
// cout<<"Event "<<i<<endl;
// gt->GetEntry(i);
// TH2D *h2 = new TH2D("h2", " tracks;x;z", 100, -100, 100, 100, -100, 100);
// h2->Sumw2(kTRUE);
// t->Project("h2", "leaf1:leaf2", "");
couet
4
Have a look at the 2 last parameters of TTree::Project. The number of event and the last event. Use it to select on 1.
1 Like