-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCountEvents.C
More file actions
85 lines (44 loc) · 932 Bytes
/
CountEvents.C
File metadata and controls
85 lines (44 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#ifndef __CINT__
#include "TROOT.h"
#include "TH1.h"
#include "TTree.h"
#include "TH2.h"
#include "TF1.h"
#include "TFile.h"
#include "TMath.h"
#include "TSystem.h"
#include "TVector2.h"
#include "TLorentzVector.h"
#include "TVector3.h"
#include "TRandom.h"
#include <iostream>
#include <fstream>
using namespace std;
using std::cout;
using std::endl;
#endif
void CountEvents() {
int N = 1500;
char inputfile[512];
int num;
int sum = 0;
for(int i=0; i < N; i++){
sprintf(inputfile,"skim_HiForest_%d.root",i);
ifstream ifile(inputfile);
if(ifile){
TFile *fin = new TFile(inputfile);
TTree *t = (TTree *)fin->Get("ntHlt");
t->Draw("Event>>h1");
num = h1->GetEntries();
sum = sum + num;
cout << num << endl;
}
if (!ifile) {
i = i + 1;
cout << "File " << i << "does not exist" << endl;
}
cout << sum << endl;
//cout << "index = " << i << endl;
}
cout << "Totalevents = " << sum << endl;
}