2023-02-13 14:50:36 +08:00
|
|
|
#include <TFile.h>
|
|
|
|
#include <TTree.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2023-05-14 15:08:17 +08:00
|
|
|
void integral(TString file) {
|
2023-02-13 14:50:36 +08:00
|
|
|
double e[24];
|
|
|
|
int id[24], N[1];
|
|
|
|
int sum1, sum2;
|
2023-05-14 15:08:17 +08:00
|
|
|
|
|
|
|
TFile f(file);
|
2023-02-13 14:50:36 +08:00
|
|
|
if (f.IsZombie()) {
|
|
|
|
printf("cannot open root file\n");
|
2023-05-14 15:08:17 +08:00
|
|
|
return;
|
2023-02-13 14:50:36 +08:00
|
|
|
}
|
|
|
|
TTree* t = (TTree*)f.Get("SimData1");
|
|
|
|
if (!t) {
|
|
|
|
printf("cannot find tree!\n");
|
2023-05-14 15:08:17 +08:00
|
|
|
return;
|
2023-02-13 14:50:36 +08:00
|
|
|
}
|
|
|
|
t->SetBranchAddress("detE", e);
|
|
|
|
t->SetBranchAddress("detId", id);
|
|
|
|
t->SetBranchAddress("Ndets", N);
|
|
|
|
int n = t->GetEntries();
|
|
|
|
// printf("n=%d\n", n);
|
|
|
|
int i, j;
|
|
|
|
sum1 = sum2 = 0;
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
t->GetEntry(i);
|
|
|
|
for (j = 0; j < N[0]; j++) {
|
|
|
|
if (e[j] > 0.18 && id[j] < 12) {
|
|
|
|
sum1++;
|
|
|
|
}
|
|
|
|
if (e[j] > 0.18 && id[j] > 11) {
|
|
|
|
sum2++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-05-14 15:08:17 +08:00
|
|
|
printf("%d,%d,%d,%f\n", sum1 + sum2, sum1, sum2, 1.0 * sum1 / sum2);
|
2023-02-13 14:50:36 +08:00
|
|
|
}
|