Error in TTreeFormula::Compile

I am very new to both ROOT and C++, and I’m having a hard time with making the cuts I want. Here is my code:

#include <TF1.h>
#include
#include
#include
#include
#include
#include
using namespace std;

void proftest()
{
TFile *f = new TFile("/home/silicon/samples/2010_06_22_13_27_56_run/run.root");
TProfile *aaa = new TProfile(“aaa”,“sampleValue:kpixChannel profile”,512,0.0,512.0,“S”);
Double_t base_train = SampleTree->GetMinimum(“trainNum”);
Double_t base_offset =1.0;
base_train = base_train + base_offset;

cout<<base_train<<endl;

     SampleTree->Draw("sampleValue:kpixChannel>>aaa","kpixBucket==0 && trainNum>base_train");

}

The error I get is:
Error in TTreeFormula::Compile: Bad numerical expression : “base_train”

If I put a number in place of base_train, it works, but I don’t understand why it doesn’t know that base_train is a number, the cout works fine in the line before.

You should encode your variable into a string, eg

SampleTree->Draw("sampleValue:kpixChannel>>aaa",TString::Format("kpixBucket==0 && trainNum>%g",base_train));
Rene

Yes, that works! Thanks very much.