Helpful snippets when dealing with ROOT
TTree.Draw()
The following two produce the same histogram:
1 # long version
2 for t in metree:
3 if metree.leppt[0] > metree.leppt[1]:
4 h.Fill(metree.leppt[0])
5 elif metree.leppt[1] > metree.leppt[0]:
6 h.Fill(metree.leppt[1])
7 else:
8 print "Aah!"
9
10 # and the short version
11 metree.Draw("leppt[0]*(leppt[0]>leppt[1]) + leppt[1]*(leppt[1]>leppt[0])>>lead_pt(100,0,250)")
The short version will fill the histogram "lead_pt" with the value leppt[0] if it is bigger than leppt[1], otherwise it will will with leppt[1]. Here we take advantage of the fact that the boolean expression (leppt[0]>leppt[1]) is zero if it is false.
