Hi all, I have plotted a Y:X plot with colz and found the centre of the plot is well in agreement with the prediction. however, around the centre, I have got a few data points which don’t match the expected correlation. Thus want to investigate further by applying 2D gates there and that’s where my problem arises. Can’t apply 2-D gates in a systematic way that automatically captures the data outside the central region of the attached plot (circled in RED) and eventually store them in a file or something. Any suggestions will be appreciated. Thanks!

Hi @thegame ,

if I understand correctly you want to extract the coordinates of data points that satisfy some constraints?

Some of that might be covered by ROOT: TCutG Class Reference – you can also access the bin contents of the TH2 manually of course, e.g. to zero-out the contents of the central bin to leave just the outer ones filled, and then continue the analysis from there.

Cheers,

Enrico

You gates looks quite simple to program.According to your plot the middle part is enclose in a square defined by: `-20 < x <20`

and `-20 < y < 20`

. Therefore you can make a loop identifying the 8 squares surrounding the central one:

```
+---------------+---------------+---------------+
| | | |
| 1 | 2 | 3 |
| | | |
20 +---------------+---------------+---------------+
| | | |
| 4 | centre | 5 |
| | | |
-20 +---------------+---------------+---------------+
| | | |
| 6 | 7 | 8 |
| | | |
+---------------+---------------+---------------+
-20 20
```

Some (pseudo)code like the following one should be able to sort the various zones:

```
int bin;
double c, x,y;
for (int i=1; i<=nbinx, i++) {
for (int j=1; i<=nbiny, j++) {
bin = h->GetBin(i,j);
c = h->GetBinContent(bin);
if (c) {
x = h->GetXaxis()->GetBinCenter(bin);
y = h->GetYaxis()->GetBinCenter(bin);
if (x<-20 && y<-20) --> in zone 6
if (x>=-20 && x<=20 and && y<-20) --> in zone 7
if (x>20 && y<-20) --> in zone 8
if (x<-20 && y>=-20 && y<=20) --> in zone 4
if (x>=-20 && x <=20 && y>=-20 && y<=20) --> in center
if (x>20 and && y>=-20 && y<=20) --> in zone 5
if (x<-20 && y>20) --> in zone 1
if (x>=-20 && x<=20 and && y>20) --> in zone 2
if (x>20 && y>20) --> in zone 3
}
}
}
```

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.