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 :
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");
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…
// 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.
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).
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 ?