RE: [ROOT] TTree::Draw and "or"ed TCuts failing.

From: Philippe Canal (pcanal@fnal.gov)
Date: Tue Mar 04 2003 - 21:15:29 MET


Hi Brett,

This is an interesting case. The problem is that the formula (your cut) is
evaluated in 2 phases.  First it is calculated the number of times (per
event) it can be evaluated.  For example if the formula is simply trk.ds,
this number is the size of the TClonesArray.  And then, and only then, it
starts a loop over the whole expression to calculate it the proper number of
times.

In essence your "evthdr.ntrack==0||(evthdr.ntrack==1&&trk[0].ds<1.0)" turns
into

	if ((trk.GetLast()+1)>=0/*from trk[0]*/)
	   weight = evthdr.ntrack==0||(evthdr.ntrack==1&&trk[0].ds<1.0);
	}

Changing the design so that it would instead do something:

	weight = evthdr.ntrack==0;
	sub_weight = evthdr.ntrack==1
	if ((trk.GetLast()+1)>=0/*from trk[0]*/)
	   sub_weight = sub_weight && trk[0].ds<1.0;
	}
      weight = weight || sub_weight

would require substential work.

In summary, currently TTree::Draw, evaluate an expression to not exist
(hence be skipped and/or be considered false) if ANY of its elements can not
be evaluated.

Cheers,
Philippe.

-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Brett Viren
Sent: Tuesday, March 04, 2003 1:56 PM
To: ROOT-TALK ML
Subject: [ROOT] TTree::Draw and "or"ed TCuts failing.


Hi,

I am finding that when doing a TTree::Draw() an "or"ed cut is failing
to act as I expect it should, leading to bogus results.


Our top level tree object is like:

class TTreeSR : public TObject {
public:
	...
	EventSRHeader evthdr; // contains "hdr.ntrack" holding # of tracks
	TClonesArray* trk;    // TrackSRTTree
	...
};
class TrackSRTTree : public TObject {
public:
	...
	Float_t ds;
	...
};

I am trying to plot the number of tracks (A UShort_t in
"evthdr.ntrack") for all events which either have 0 tracks or have >0
tracks but have a certain value, ds<1.0.  This "ds" is held as a
Float_t in a data member of the "TrackSRTTree" elements of the "trk"
TClonesArray.

The two commands I use are:

 1) tree->Draw("evthdr.ntrack");

 2) tree->Draw("evthdr.ntrack","evthdr.ntrack==0||trk[0].ds<1.0");

or more explicitly:

 2')
tree->Draw("evthdr.ntrack","evthdr.ntrack==0||(evthdr.ntrack==1&&trk[0].ds<1
.0)")

In the first case the data populates the ntrack==0 and 1 bins.  In
both of the second cases, only bin ntracks==1 is populated.


There is a test file (14.4 MB):

http://minos.phy.bnl.gov/~bviren/minos/mc/gminos/test.root

Using it, this session should reproduce the problem:

root [1] TFile f("test.root")
root [2] TTree* t = (TTree*)f.Get("reco")
root [3] t->Draw("evthdr.ntrack")
root [4] t->Draw("evthdr.ntrack","evthdr.ntrack==0||trk[0].ds<1.0")
root [5]
t->Draw("evthdr.ntrack","evthdr.ntrack==0||(evthdr.ntrack==1&&trk[0].ds<1.0)
")


This is with today's CVS on x86, GCC 3.2.
-Brett.



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:09 MET