I have serie of values: x,y,z. I would like to create a TProfile2D, that for each trio of x,y,z is filled like Fill(x,y,z) was invoked - x,y are coordinates, z is the variable I want to histogram. Unfortunately, as far as I understand, TTree::Draw does not allow to do that even for TH2, for Draw(“x:y:z”) creates a TH3 (noth TH2). So I figured out a way to fill TH2 with values x,y,z (in my case they are called ccdx, ccdy and mean):
fin_res->Draw("ccdx:ccdy:mean", "", "");
TGraph2D *g = new TGraph2D(fin_res->GetSelectedRows(), fin_res->GetV1(), fin_res->GetV2(), fin_res->GetV3());
g->Draw("p0");
TH2D *h = g->Project("xy");
new TCanvas;
h->Draw("colz");
That works how it is supposed to work. However, I have no idea how to do a simillar thing, but to fill a TProfile2, not TH2. Could anyone help? Or maybe I even missed a simple way to directly create such TProfile2 and TH2 with TTree::Draw()?
fin_res->Draw("ccdx:ccdy:mean", "", "prof");should also do the trick. Note that if you suffix prof with either of the letter ‘s’,‘i’ or ‘g’, those are passed to the TProfile2D constructor.
It works for me:root [11] ntuple->Draw("px:py:pz","","prof");
root [12] htemp->IsA()->Print()
OBJ: TClass TProfile2D Profile2D histogram class. Which version of ROOT are you using?
Somehow I cannot explain what I mean properly Creating TProfile2D also works fine for me, but I don’t know the way to create exactly the same TH2 (as TProfile2D, but having sums in bins instead of means) from 3 variables…