Help using TClonesArray and TTree::Draw

Hi all. I’d like to be able to use the TTree::Draw function by making selections on data contained inside a TClonesArray.

I have the following Event class
class Event {
Int_t varA;
TClonesArray *detector; //an array of MyDetector records

class MyDetector {
Int_t fNumber; //my detector number
Int_t fAdc[2]; //two adc values per detector


I would like to make a histogram of fAdc[0] for all events on detector 1 (fNumber == 1) and where the value of fAdc[0] > -1 and fAdc[1] > -1 for detector 1. (-1 is my initialization value for those variables, so I check that they have a non-initialized value.)

Now, I tried
tree->Draw(“fAdc[0]” < “fNumber == 1 && fAdc[0] > -1 && fAdc[1] > -1”);

But I didn’t get what I expected. This selection will only select events where fNumber == 1 for one of the objects in the TClonesArray and fAdc[0 and 1] > -1 for ALL of the objects in the TClonesArray. For example, the following event does not pass the tree->Draw cut.

varA = 1234
detector.fNumber = 1, 3
detector.fAdc[2] = 12, 788,
-1, 10

But this event will pass and be added to the output histogram

varA = 1235
detector.fNumber = 1, 3
detector.fAdc[2] = 12, 788,
18, 10

How can I get the expected behavior that I want using TTree::Draw?



You meant:

See the User’s Guide chapter on TTree page 216 and up and the reference guide for TTree::Draw for more details.