Bad numerical expression?

hello all ,
i have this error (Error in TTreeFormula::Compile: Bad numerical expression : “i”)
when i write the for loop :

for(int i=97;i<=192;i++){
mc8 = new TCanvas(“mc8 “,“2D”,1,55,964,491);
ch1.Draw(”((trt.tracks.tdctc)+(trt.tracks.tdcbc))/2:sqrt((trt.tracks.adcbc)*(trt.tracks.adctc))”,“slatc==i”);
}

who can help me please ??

thank you

Try (note: no “for” loop at all):
mc8 = new TCanvas(“mc8 “,“2D”,1,55,964,491);
ch1.Draw(”((trt.tracks.tdctc)+(trt.tracks.tdcbc))/2:sqrt((trt.tracks.adcbc)*(trt.tracks.adctc))” , “slatc>=97 && slatc<=192”);

thank you so much .
but i want to draw each slat individually .

You can try to replace:
"slatc==i"
with:
(TString(“slatc==”) + ((Long_t)i)).Data()
or:
(TString::Format(“slatc==%i”, i)).Data()

Are you really trying to create 96 (= 192 - 97 +1) canvases?
If yes, each of them should have a different “name” (the “title” doesn’t matter).
You can try to replace (btw. no “spaces” in object’s “name”):
"mc8 "
with:
(TString(“mc8_”) + ((Long_t)i)).Data()
or:
(TString::Format(“mc8_%i”, i)).Data()

it works thank you ,
but the canvas is disappearing when the other creates ,
so maybe if i write other “for loop” inside the first one to make a loop over canvases like this :

m=new TCanvas (“m”,“slatc”,1,55,1364,691);
m->Divide(8,12);

for(i=97;i<=192;i++){
for(j=1;j<=96;j++){
m_j->cd(); // here is the problem again
ch1.Draw("((trt.tracks.tdctc)+(trt.tracks.tdcbc))/2:sqrt((trt.tracks.adcbc)*(trt.tracks.adctc))",(TString::Format(“slatc==%i”, i)).Data());
}}

any suggestion ?

m=new TCanvas ("m","slatc",1,55,1364,691); m->Divide(8,12); for(i=97;i<=192;i++){ m->cd(i-96); ch1.Draw("((trt.tracks.tdctc)+(trt.tracks.tdcbc))/2:sqrt((trt.tracks.adcbc)*(trt.tracks.adctc))", (TString::Format("slatc==%i", i)).Data()); // m->Modified(); m->Update(); } m->cd(0);

thank you ,
i really appreciate your help .