Add selection to data plots

Hi Axel, first, thanks for your reply.

  1. Root 5.34/38 Windows

  2. About the error see the attachment

  3. Yes, I want to write Calo_Time[a]-Calo_Time[b]> p1-3*p2 && Calo_Time[a]-Calo_Time[b] < p1+3*p2?, I used the call to Form because of I defined the variables a,b at the beginning of the macro so that I can modify them quickly (this because I also will study Calo_Time[10]-Calo_Time[15], etc. etc]. The Form function works fine in the row t->Draw(Form("Calo_Time[%d]-Calo_Time[%d]",a,b)); (cuet wrote me this code here Differences between arrays)

  4. I just saw that the error was given because of I forgot the Form here if ("Calo_Time[%d]-Calo_Time[%d]",a,b))> (p1-3*p2) && (Form("Calo_Time[%d]-Calo_Time[%d]",a,b)) < (p1+3*p2)

now, by replacing this line with

 if (Form("Calo_Time[%d]-Calo_Time[%d]",a,b))> (p1-3*p2) && (Form("Calo_Time[%d]-Calo_Time[%d]",a,b)) < (p1+3*p2)

I don’t get the error (In the attachment the macro after the bug fixed)
calo.cpp (6.2 KB)

  1. Even if I don’t get the error, I don’t get the right results, because of the total events are 6119 and I get 6119 also by using the cut selection (I should get a lower number of events because of I reject the events out of the range )