Problem in Draw with cuts

Hi all,

I think my question is probably trivial, but I cannot figure out what is wrong with my code. I’m trying to plot some variables from a tree with a cut. I get what I want, except for the cut which doesn’t seems to work…
Here is the code, fChain stand for the tree :

 TCanvas *c1 = new TCanvas("c1");
   gStyle->SetPalette(1);
gPad->SetLogz();

TCut* cut1 = "BR_mu_to_eGamma < 1e-7"

   fChain->Draw("mEL12 : TE21","BR_mu_to_eGamma"*cut1, "colz");

Thanks for your help,
Best,
Jordan

Hi Jordan,

perhaps using a complementary approach could help, for example TDataFrame:

// Palette and log axis left aside, focussing on the core part
ROOT::Experimental::TDataFrame d("myTree","myWildcardForFiles*.root");
auto h = d.Filter("BR_mu_to_eGamma < 1e-7").Histo2D("mEL12", "TE21");
h->Draw("colz");

Cheers,
D

Hi, and thank you for your help.

I just modify the code to this :

TCanvas *c1 = new TCanvas(“c1”);
gStyle->SetPalette(1);
gPad->SetLogz();

ROOT::Experimental::TDataFrame d(“ScanTree”, “Tree_scan_SU5.root”);
auto h = d.Filter(“BR_mu_to_eGamma < 1e-7”).Histo2D(“mEL12”, “TE21”);
h->Draw(“colz”);

but I get the following error :

error: no matching member function for call to ‘Histo2D’
auto h = d.Filter(“BR_mu_to_eGamma < 1e-7”).Histo2D(“mEL12”, “TE21”);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
I’m not really familiar with root, obviously I did something wrong…

Cheers,
Jordan

Hi Jordan,

what ROOT release is this?

Cheers,
D

Hi,

I’m using the following version : root_v6.10.08

Cheers,
Jordan

Jordan, my bad.
The code should look like:

// Palette and log axis left aside, focussing on the core part
ROOT::Experimental::TDataFrame d("myTree","myWildcardForFiles*.root");
auto h = d.Filter("BR_mu_to_eGamma < 1e-7").Histo2D({"myHist","myTitle",64,-1,1,64,-1,1},"mEL12", "TE21");
h->Draw("colz");

Where this {“myHist”,“myTitle”,64,-1,1,64,-1,1} is the set of parameters to be passed to the TH2F (for 6.10) constructor.

Cheers,
Danilo

Hi,

I get a blank histogram with following error

“Warning in TClass::Init: no dictionary for class ROOT::TIOFeatures is available”

But don’t worry, I found an other (not beautiful) way by creating an other tree with a filter :wink:

Thanks very much for your help,
Jordan

Thanks for the feedback!

Could you share the file with us so that I can debug your issue? I’d like to make sure this is not an issue in the forthcoming ROOT 6.14…

Cheers,
D

Try:

TCut *cut1 = new TCut("BR_mu_to_eGamma < 1.e-7");
fChain->Draw("mEL12 : TE21", (*cut1) * "BR_mu_to_eGamma", "colz");

and/or:

TCut cut1 = "BR_mu_to_eGamma < 1.e-7";
fChain->Draw("mEL12 : TE21", cut1 * "BR_mu_to_eGamma", "colz");

Warning: with the current ROOT 6.12/06 and 6.13/02, you may get mysterious errors in form “IncrementalExecutor::executeFunction: symbol '_ZmlPKcRK4TCut' unresolved while linking function '_GLOBAL__sub_I_cling_module_8'!”, if you try to reverse the cut multiplication order into, respectively, "BR_mu_to_eGamma" * (*cut1) and/or "BR_mu_to_eGamma" * cut1. I think this is a bug in ROOT 6 (as it works fine in ROOT 5). You can simply overcome it, if you #include "TCut.h" (or manually R__LOAD_LIBRARY the corresponding library).

Hi All,

Many thanks for your answer, it seems to work like this !

Actually, I just realized why I thought it wasn’t working before. I think I misunderstood how “colz” works. If I’m correct, you get a 2D histograms where each cells contribute to the value. So, if I want to plot something like: X, Y and Z with a color scale, the actual value I will read from the 2D histo for each cells will be something like the sum of the Z values over all the points in the cell ?

Is there a way to get the value of the cell been the average of the Z values inside the cell ? Or at least just getting a plot with singles points (not binned) with the correct Z value associated ?

Thanks again for your time,
Cheers,
Jordan

Try: tree->Draw("Y:X:Z", "", "col");

It’s perfect, many thanks !

Cheers,
Jordan

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