tree->Draw options

Hi all,
I have a problem about options drawing an histogram.
I’m not an expert so I’m sorry if it’s a too simple problem.

I’m plotting an histogram of 12454 data (these data come from a function as written below), but I need to exclude data the are present in the histogram less than 10 times.

From command window I open the root file (it’s a tree) and then I use the command to plot:

tv__tree->Draw("(vtxZB-vtxZ)/vtxZ","","",12454,0);

If, for example, I want to plot only the data from -100 to 100 with 200 bins, I use the command:

tv__tree->Draw("(vtxZB-vtxZ)/vtxZ>>hvtx(200,-100,100)","","",12454,0);

and till this point it’s all ok.

But now I want to exlude all the data that are present less than 10 times in the histogram.

Could anyone help me doing this from command window?
Thank you in advance.

Hi @Dranix,
if I understood well what you want is a TCut to select only the events which belong to bins with more the ten counts in it. I think there is no easy way to do it.

But you can try two lines from the command window like the ones below

TCut moreThan10=""
for(i=1;i<hvtx->GetNbinsX();i++)if(hvtx->GetBinContent(i)<10){moreThan10= moreThan10 || Form("(vtxZB-vtxZ)/vtxZ < %lf || (vtxZB-vtxZ)/vtxZ>%lf",hvtx->GetBinLowEdge(i),hvtx->GetBinLowEdge(i+1))};

Cheers
Stefano

Thank you very much.
I’ll try it as soon as possibile.

I forgot one thing,
if you want retrieve the histogram from the temporary memory you have to do

TH1D *hvtx=(TH1D*)gDirectory->->FindObject("hvtx");

just after you used the TTree::Draw method.

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