Hello,

I’m trying to find a way to get the final amount of entries for one of x scatter plots in the an array of scatter plots. I’m also trying to fill these scatter plots using the floor function. I used a similar method method that I posted before on this forum. I will provide the link below. When I use GetEntries() in a string output in my code, the terminal spits out the amount of entries as the code compiles, which cause multiple lines to print out and it’s too much to keep track of when the root files I’m using have 100 million events each. I just want my code to output one number which would be the total number of entries, and I’m not sure what I need to change in my code in order to do that. I’ll provide some parts of my code to show what I have so far. I hope to hear a response soon. Thanks in advance.

-Charlie Clark

Code:

Code that creates arrays of scatter plots.

```
for (Int_t i = 0; i < x; i++){
TString nameA1 = Form("hA%d",i);
TString nameA2 = Form("%dmrad<Angle<%dmrad Cut;X-Position [m];Y-Position [m]",i,i+1);
hA[i] = new TH2F(nameA1,nameA2,400,-0.07,0.07,400,-0.15,0.15);
hA[i]->SetMarkerStyle(3);
}
for (Int_t j = 0; j < x; j++){
TString nameAMol1 = Form("hAMol%d",j);
TString nameAMol2 = Form("Moller %dmrad<Angle<%dmrad Cut;X-Position [m];Y-Position [m]",j,j+1);
hAMol[j] = new TH2F(nameAMol1,nameAMol2,400,-0.07,0.07,400,-0.15,0.15);
hAMol[j]->SetMarkerStyle(3);
hAMol[j]->SetMarkerColor(kRed);
}
for (Int_t k = 0; k < x; k++){
TString nameAMot1 = Form("hAMot%d",k);
TString nameAMot2 = Form("Mott %dmrad<Angle<%dmrad Cut;X-Position [m];Y-Position [m]",k,k+1);
hAMot[k] = new TH2F(nameAMot1,nameAMot2,400,-0.07,0.07,400,-0.15,0.15);
hAMot[k]->SetMarkerStyle(3);
hAMot[k]->SetMarkerColor(kBlue);
}
```

Code that fills and gives amount of entries for each scatter plot.

```
for (Int_t j = 0; j < hitN; j++){
//Double_t hitxy = TMath::Sqrt(TMath::Sq(hitX[j])+TMath::Sq(hitLy[j]));
Double_t hitPxy = TMath::Sqrt(TMath::Sq(hitPx[j])+TMath::Sq(hitPy[j]));
//if (hitPxy >= 0 && hitPxy <= (.3*B_1*R_s1*TMath::Sin(0.05)) && hitPz[j] >= (.3*B_1*R_s1*TMath::Cos(0.05)) && hitPz[j] <= (.3*B_1*R_l1)) continue;
Double_t a = TMath::ATan(hitPxy/hitPz[j]);
//Double_t b = TMath::ATan(hitxy/hitZ[j]);
//Double_t b1 = TMath::Sqrt(2*m*(E-hitE[j])/(E*hitE[j]));
//Double_t b2 = TMath::Sqrt(2*m*hitE[j]/(E*(E+m)-E*hitE[j]));
//Double_t c = TMath::Sqrt(2*M*(E-hitE[j])/(E*hitE[j]));
//Double_t p = TMath::ATan(m/((E+m)*TMath::Tan(b/2)));
//if ( a < 0.0001 ) continue;
//Plotting Scattering Angle vs. Energy on 1st flux plane (entrance to 1st quadrupole)
Int_t i = floor(a*1000);
if (hitDet[j]==1 && i >= 0 && i < x) hA[i]->Fill ( hitX[j] , hitLy[j] );
if (hitDet[j]==1 && i >= 0 && i < x && hitE[j]>(E/(1+(E/m)*(1-TMath::Cos(i/1000)))) && hitE[j]<(E/(1+(E/m)*(1-TMath::Cos((i+1)/1000))))) {
hAMol[i]->Fill ( hitX[j] , hitLy[j] );
TString MolEn = Form("Moller Entries %dmrad<Angle<%dmrad: ",i,i+1);
std::cout << MolEn << hAMol[i]->GetEntries() <<"\n";
}
//TString MolEn = Form("Moller Entries %dmrad<Angle<%dmrad: ",i,i+1);
//std::cout << MolEn << hAMol[i]->GetEntries() <<"\n";
if (hitDet[j]==1 && i >= 0 && i < x && hitE[j]>(E/(1+(E/M)*(1-TMath::Cos(i)))) && hitE[j]<(E/(1+(E/M)*(1-TMath::Cos((i+1)/1000))))) {
hAMot[i]->Fill ( hitX[j] , hitLy[j] );
TString MotEn = Form("Mott Entries %dmrad<Angle<%dmrad: ",i,i+1);
std::cout << MotEn << hAMot[i]->GetEntries() << "\n";
}
```

ROOT Version: 6.26/06

Platform: Ubuntu 22

Compiler: from file root_v6.26.06.Linux-ubuntu22-x86_64-gcc11.2.tar.gz

Forum of using the floor function to fill histograms: