-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyzeChain.C
49 lines (39 loc) · 1.37 KB
/
analyzeChain.C
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
#include "analyzeChain.h"
using vec_d = std::vector<double>;
using vec_f = std::vector<float>;
std::vector<vec_d> getLuminosity(std::string dir, std::string file_name){
std::ifstream file(dir + file_name);
std::vector<vec_d> cols;
read(file, cols);
return cols;
}
void getExpected(vec_d section, std::vector<vec_d> luminosity, vec_f & counts){
for(int i = 0; i < counts.size(); i++){
counts[i] = section[i]*luminosity[i][2]*counts[i]/5e4;
}
}
void analyzeChain(Chain chain, vec_f &counts_fin, vec_f &counts_min, vec_f &counts_inter,
std::string dir, vec_d energy, std::vector<vec_d> luminosity){
TChain * inchain = chain.chain;
TObjArray *fileElements = inchain->GetListOfFiles();
TIter next(fileElements);
TChainElement *chainElement = 0;
vec_d section;
vec_d coeff;
while( ( chainElement = (TChainElement *)next() ) ){
TFile * f = new TFile( chainElement->GetTitle() );
int N_fin = 0;
int N_min = 0;
int N_inter = 0;
analyzeFile(f, N_fin, N_min, N_inter);
counts_fin.push_back(N_fin);
counts_min.push_back(N_min);
counts_inter.push_back(N_inter);
}
if(chain.section_file != " "){
section = getSection(energy, dir, chain.section_file);
getExpected(section, luminosity, counts_fin);
getExpected(section, luminosity, counts_min);
getExpected(section, luminosity, counts_inter);
}
}