Make calculations with Chain of root files

Hello Rooters,
I have a few root files, which containe trees with some values. I need to open the tree, apply for value inside formula and plot the result of this formula. I use th following code for it

sprintf(canvas11_name[detector],“Target_%d_TYPES”,detector);
ccxzoom = new TCanvas (canvas11_name[detector],canvas11_name[detector],1000,1000);
sprintf(tree1_name[detector],“treetype2_%d”,detector);
TChain ch1(tree1_name[detector]);
ch1.Add("/afs/cern.ch/exp/ntof/users/ag9/ppac/03/Files/Run4960_ppac_v1.root");
ch1.Add("/afs/cern.ch/exp/ntof/users/ag9/ppac/03/Files/Run4962_ppac_v1.root");
ch1.Add("/afs/cern.ch/exp/ntof/users/ag9/ppac/03/Files/Run4963_ppac_v1.root");
TH1F h1 = new TH1F(“h1”,“TYPE-2 Center”,nbbin,es,ef);
n1 = ch1->GetEntries();
ch1->Draw("log10(939.56
(sqrt(1/(1-pl*pl/0.0009/((t0+t1)/2-55900+6210)/((t0+t1)/2-55900+6210)))-1)*1000000)>>h1",G0&&G1&&A01&&PCT2,"",n1);
h1->SetXTitle(“Log(En, eV)”);


parameters t0 and t1 contained in root files, but pl is the variable discribed in code as float and has some value. G0&&G1&&A01&&PCT2 - are the cuts discribed before in code.
But in this case if I start code message hapens “unknown pl”.
Do you know how is it possible to make calculations (using external in respect to trees variable) with values in trees using Chain and plot result of it after?

If pl is a variable in your script (not in the tree), you can do

double pl = …;

char mycut[1000];
sprintf(mycut,“log10(939.56*(sqrt(1/(1-%f*%f/0.0009/((t0+t1)/2-55900+6210)/((t0+t1)/2-55900+6210)))-1)*1000000)>>h1”,pl,pl);
ch1->Draw(mycut,G0&&G1&&A01&&PCT2,"",n1);

Rene

Thank you Rene,
now it works. But could you discribe how is it possible to apply logical condition
if (mycut>…){}
for result of calculation (mycut in your script). The purpose is

  1. calculate formula (mycut)
  2. apply condition if() for result of calculations (mycut)
  3. make another calculations for value in tree and discribed in script.

I was showing an example with the variable(s) to be histogrammed.
You can use the same technique for the cuts.

Rene