Hi I have a Class Structure for my tree defined as:
class DaqMonitor : public TObject {
public:
int MNum; // Monitor Number
int TrigRate;
unsigned long Data[24][40]; // 2 *12 layers:: 40 strips //unsigned integer
TTimeStamp t;
public:
DaqMonitor(){}
virtual ~DaqMonitor(){}
ClassDef(DaqMonitor,2) //Event structure
};
and now I am trying to plot the TrigRate as a function of time using the values returned from the TTimestamp variable “t”.
When I try to draw using tree->Draw(“TrigRate:t.fSec”)
it is successful, however when I try to draw something like: (similar to the one quoted in TTree documentation)
tree->Draw(“TrigRate:t.AsDouble”)
I get an error saying
Error in TTreeFormula::Compile: Bad numerical expression : "t.AsDouble()"
What is the reason for this ?
Thanks,
dsmcc
I can not reproduce the problem. Both:tree->Draw("TrigRate:t");ortree->Draw("TrigRate:t.AsDouble()");"work when I use your class.
Cheers,
Philippe.
PS. There is an ‘inconsistency’ in your report with states both “TrigRate:t.AsDouble” without the parathentesis and expression : “t.AsDouble()” with the parenthesis ; I assume that this is a copy/paste error but it could also be the original problem.
Hi Philippe,
Yes that was a copy paste error. It does not work even with the brackets. I dont use cint, but to demonstrate this error, I have attached a sample data file and here are the commands I used:
TFile *f = new TFile(“INORUN_20100408_2349.root”)
TTree *t = f->Get(“MON”);
t->Draw(“TrigRate:t.fSec”)// this works
t->Draw(“TrigRate:t.AsDouble()”) // this fails
Error in TTreeFormula::Compile: Bad numerical expression : “t.AsDouble()”
I dont understand why this is happening.
Thanks and Regards,
dsmcc INORUN_20100408_2349.root (738 KB)
To work around the issue, when writing the TTree replace tree->Branch("InoMonitor",...with[tree->Branch(“InoMonitor.”,…[/code](i.e. add a trailing dot) and uset->Draw("TrigRate:InoMonitor.t.AsDouble()".