Is it possible to use a variable in TTree:Draw?

Hello, I would like to know iof there is a way to use a variable in the TTree::Draw expression. For example, if I have a TFile that contains a TTree, I can do

whete t is the TTree and “A” a leaf of the tree. However it does not work anymore if I do

int foo=10 t->Draw("A-foo")

In pratice, a TParameter is prezsent in the TFile and I would like to do something like that

root [1] int startTime = ((TParameter<int>*)_file0->Get("StartTime"))->GetVal(); root [2] t->Draw("Time-startTime") Error in <TTreeFormula::Compile>: Bad numerical expression : "tempsDebut" Info in <TSelectorDraw::AbortProcess>: Variable compilation failed: {Temps-tempsDebut,}

Do you have any key to do that?

Try:
t->Draw(TString::Format(“Time - (%d)”, startTime));

Indeed doing

I get what I want. Thanks

Better use: “Time - (%d)” -> it helps if “%d” returns a negative value.

Indeed, I note that :smiley: