You can create, fill, and draw a 2-d histogram (TH2F). You will see its 40x40 grid of bins, drawn with the default “scatter plot” option.
gROOT->cd(); // newly created histograms should go here
delete gROOT->FindObjectAny("h"); // make sure it will be (re)created below
TString varexp = "NumGammaProduced:Edep";
TString selection = "";
#if 1 /* 0 or 1 */
tScint->Project("h", varexp, selection);
#else /* 0 or 1 */
tScint->Draw(varexp + " >> h", selection, "goff");
#endif /* 0 or 1 */
TH1 *h = (TH1*)gROOT->FindObjectAny("h");
if (h) {
h->SetTitle("Scintillation Yield;Energy Deposited [eV];# Gamma Produced");
h->SetStats(kTRUE);
h->Draw();
if (gPad) { gPad->Modified(); gPad->Update(); } // really (re)draw it
}
You can create, fill, and draw an unbinned 2-d scatter-plot (TGraph). You will see all individual TTree’s data points.
gROOT->cd(); // newly created histograms should go here
TString varexp = "NumGammaProduced:Edep";
TString selection = "";
tScint->Draw(varexp, selection); // an unbinned 2-d scatter-plot (TGraph)
TH2F *h = (TH2F*)gPad->GetPrimitive("htemp"); // empty, but provides axes
if (h) {
TDirectory *d = h->GetDirectory();
h->SetDirectory(gROOT); // needed for "Project" and / or "Draw" below
// h->Reset("M"); // make sure it's "clean"
#if 1 /* 0 or 1 */
tScint->Project("+htemp", varexp, selection);
#else /* 0 or 1 */
tScint->Draw(varexp + " >> +htemp", selection, "goff");
#endif /* 0 or 1 */
((TArrayF*)h)->Reset(); // "reset" histogram's bins' contents
h->SetName("h"); // empty, except for "statistics" (and axes, of course)
h->SetTitle("Scintillation Yield;Energy Deposited [eV];# Gamma Produced");
h->SetStats(kTRUE);
h->SetDirectory(d); // where it originally belonged to
gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn
TPaveText *t = (TPaveText*)gPad->GetPrimitive("title");
if (t) { // move the "title" to the middle
Double_t x1 = t->GetX1NDC();
Double_t x2 = t->GetX2NDC();
Double_t dx = (x1 + x2) / 2.0 - 0.5;
t->SetX1NDC(x1 - dx);
t->SetX2NDC(x2 - dx);
gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn
}
}
BTW. For "e1:e2:e3"
and / or "e1:e2:e3:e4"
draw expressions, which produce unbinned 3-d scatter-plots (TPolyMarker3D), there is this thread and that thread.