Set Range of a TTree->Draw("histogram2:histogram1")

Hi,
I’m working on a detector simulation and I want to study the influence of the detectors positions. I can draw it pretty easily from the simulation’s output root files like that:

 SimuTree->Draw("DetectorEvents.Position.Z:DetectorEvents.Position.X")

which work perfectly if I want to check my sensitives volumes geometry but I’d like to set the range of the Y axis (Position.Z) so I can visualise the different height where I put my detectors. I tried to retrieve the 2D histogram like that TH2F h2 = (TH2F)gPad->GetPrimitive(“htemp”); (to then use SetUserRange) but it appears it is empty.
Too be clear I want 3 figures for my 3 different detector heigh with the same Y axis range.

Thanks in advance,
Maël.

TTree::Draw

BTW. You need something like: tree->Draw("y:x", "y > some_min && y < some_max");

Welcome to the ROOT forum.

The second parameter od TTree::Draw allows to define conditions on the variable. Something like:

 SimuTree->Draw("DetectorEvents.Position.Z:DetectorEvents.Position.X","DetectorEvents.Position.Z>a && DetectorEvents.Position.Z<b")

I have tried, it does not allow me to set the range. With your proposition I have a figures ranged between 1004 and 1014 mm (let’s call it configuration 1, 10 mm is the height of may detectors) which is not exactly what I want. I’d like to draw something between 1000 mm and 1100 mm so I can see that my detectors volumes are low and if I set the center of my detector to 1050 (let’s call it configuration 2) I will clearly see that with configuration 2 my detectors are placed upper than with configuration 1.

  • this bias the shape of my detectors which appears to look like columns (bc the Y axis range is equal to the heigh of the detectors) while it look like a puck in reality.
TCanvas *c = new TCanvas("c", "c");
c->DrawFrame(some_x_min, 1000., some_x_max, 1100., "Black Magic;X [mm];Z [mm]");
SimuTree->Draw("DetectorEvents.Position.Z:DetectorEvents.Position.X", "DetectorEvents.Position.Z > 1004. && DetectorEvents.Position.Z < 1014.", "SAME")

It worked !

thank you,
Maël.