Problems with reading gcut

I have a problem with different output that I get from T->Scan("…",“cut3_1 && cut2_3_1”) and
if(cut3_1->IsInside(…)). I made some analysis with T->Scan(…), which looks good,
so I am sure that the output from the T->Scan("…",“cut3_1 && cut2_3_1”) is the correct one.

My code is:

{

TCutG *cut3_1,
*cut2_3_1;

TFile f2 = new TFile(“e3_all_C_R80.root”);
cut3_1 = (TCutG
)f2->Get(“cut3_1”);

TFile f3 = new TFile(“e2_alpha_R50.root”);
cut2_3_1 = (TCutG
)f3->Get(“cut2_3_1”);

TFile *f = new TFile(“R86_0.root”,“read”);

TTree T = (TTree)f->Get(“T”);

Short_t ch001,…, ch288;
T->SetBranchAddress(“ch001”,&ch001);
.
.
.
.
T->SetBranchAddress(“ch288”,&ch288);

printf("%d \n",1);
T->Scan(“ch158:((ch161-17.0)*1.006+ch162-18.5):ch197:((ch214-11.0)*0.98+ch213-12.0)”,“cut3_1 && cut2_3_1”);

printf("%d \n",2);
Long64_t nentries = T->GetEntries();

for (Long64_t i = 0; i < nentries; i++){

T->GetEntry(i);

if(cut3_1->IsInside(ch158,((ch161-17.0)*1.006+ch162-18.5)) && cut2_3_1->IsInside(ch197,((ch214-11.0)*0.98+ch213-12.0))){
printf("%f %f %f %f\n",ch158,((ch161-17.0)*1.006+ch162-18.5),ch197,((ch214-11.0)*0.98+ch213-12.0));

}
}

The output is:

root [0] .x macro.C
1


  • Row * ch158 * ((ch161-1 * ch197 * ((ch214-1 *

  • 253722 * 1693 * 876.702 * 162 * 532.64 *
  • 858084 * 2447 * 313.988 * 181 * 391.22 *
  • 1012721 * 2402 * 325.748 * 292 * 88.1 *
  • 1277094 * 1495 * 1487.746 * 323 * 94.24 *
  • 1934526 * 2195 * 529.114 * 254 * 194.42 *
  • 1976560 * 2601 * 155.1 * 119 * 839.46 *
  • 1992150 * 2092 * 649.378 * 113 * 889.52 *
  • 2097508 * 1960 * 704.63 * 205 * 369.28 *
  • 4317167 * 1555 * 1470.406 * 154 * 414.46 *
  • 4978212 * 2276 * 218.872 * 170 * 465.14 *
  • 5638631 * 1944 * 874.412 * 162 * 474.3 *
  • 5739385 * 2370 * 296.226 * 205 * 296.56 *
  • 7747243 * 2580 * 94.746 * 245 * 191.94 *
  • 8271621 * 1496 * 1432.708 * 293 * 136.3 *

==> 14 selected entries
2
root [1]

I saved cuts also as a .C files, but the output is the same and I also checked if the first and the last point in cuts is the same, and it is.
I tried generating new tree with only these branches that I use, and also to make new branch to shorten expression ((ch161-17.0)*1.006+ch162-18.5), but with no results.
I tried reading only one cut in if statement but I get different number of events for Scan(…)(around 24000 events) and if(…)(around 11500 events), all events generated from if statement can be found in output from Scan(…). I use root version 5.24/00.
If you have any suggestions, please let me know.
Thank you very much!

After a lot of time that I spent on this code and with a help from my friend, I realized that I made a big mistake. When I define a cut I do it this way:

T->Draw(“ch001:ch002”,“ch001>0. && ch002>0.”);
TCutG cut1 = new TCutG();
c1->Update();
cut1 = (TCutG
) gPad->WaitPrimitive(“CUTG”);
cut1->SetName(“cut1”);

where ch001 represents branch on y-axis, and ch002 branch on x-axis. When you do the T->Scan(…) it seams that this function knows which is which axis, but if you do if(cut1->IsInside(ch001,ch002)), you won’t get anything, just like I didn’t :smiley: because function IsInside is defined as: Int_t IsInside(Double_t x, Double_t y) :blush: So the problem was that I switched the axes and that was it, nothing more, nothing else.
I hope that this can help someone, who just like me, never thought about actually reading a manual :smiley:
Best regards :wink: