Using TTree::Project for 2 variables

Hello everybody,

I try to add 2D histograms and, in order to do it, I try first to project 2 variables into a 2D histogram with a specific and given binning. The compilation part is ok, but, at the execution, I have the following message :

Warning in TSelectorDraw::Begin: Deleting old histogram with different dimensions
Error in TH2F::Add: Attempt to add histograms with different number of bins

which corresponds to these lines in my program :

TH2F *dummy=new TH2F(“dummy”,“dummy”,50,0.,10.,50,0.,10.);



I don’t know if I have the right to project 2 variables into a 2D histo directly, or if the “Add” step is definitively not correct.
Do someone have some idea about my problem ?
My code is attached to this message.

ana_basic_works.cxx (2.69 KB)


The argument of TTree::Project are as follow:Long64_t TTree::Project(const char* hname, const char* varexp, const char* selection, Option_t* option, Long64_t nentries, Long64_t firstentry).
whereas you seemed to have passed the ‘selection’ (cut) as the 4th parameter rather than the 3rd. The 2nd parameter shoudl contain the name of the variable separated by a colon ( : ).


PS. See the documentation for TTree::Draw for more details.