Plot data from a branch versus other branch

Hello everyone

I have in the same tree two branches, one silicon detector data “Si1” and the time in “t1”. When I draw the data from Si1 it plots directly by channel or energy if I apply the calibration. The issue is that for the sake of my project I need to analyze the data of Si1 respect to the time t1, but I’m not able to do it.

I’ve tried doing something like:

TH2F *h = new TH2F(“h”,“histogram_time”,100,0,3,800,0,70000);

but the result is nothing like I was expecting (first of all, it plots a scatter plot and not a histogram). I would like to have the counts in the YAxis respect to the time in the XAxis.

Thank you!


TH2F *h = new TH2F("h","histogram_time",100,0,3,800,0,70000);
DataTree->Draw("Si1:t1>>h", " " , "COLZ");

It looks better for sure, but I was expecting something in the shape of a “normal” histogram, with solid lines. Also, I’m not entirely sure what the YAxis represents in this plot, because when I plot “SI1” I don’t get so many counts per channel.

What do you mean? a 1D histogram?
You are asking for a 2D …

Sorry, perhaps that’s the problem. I tried 2D histo because I had two variables, but yes, my intention would be to get a 1D histogram of Si1 but in the XAxis instead of having the channels I would like to have the time in t1.

So the histogram you want is:


Right ?

Correct, but setting t1 in the XAxis

DataTree->Draw("t1", "Si1");

1 Like

It looks better, but it is still plotting points instead of the solid histogram, and very weirdly is taking the counts as negative (the shape makes sense, but it should be flipped to positive). This is what I wrote
root [1] TH1F *h = new TH1F(“h”,“hist_time”,100,0,3);
root [2] DataTree->Draw(“t1>>h”,“Si1”);

When I try setting any options for Si1 (using “Si1>>h1”) I get an error like this

rror in TTreeFormula::Compile: Bad numerical expression : “h1”
Info in TSelectorDraw::AbortProcess: Variable compilation failed: {t1,Si1>>h1}

DataTree->Draw("t1", "Si1 * (Si1 >= 0) * (Si1 <= 70000)", "HIST");

1 Like

Works like a charm! Thank you