-
Notifications
You must be signed in to change notification settings - Fork 1
/
functionmacro.C
73 lines (54 loc) · 1.87 KB
/
functionmacro.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
functionmacro.C : provide Higgs pT reweighting factor for the given mass and tan(beta)
Don't change ! (unless, you need your own defined function)
20 April 2016
*/
#include "TMath.h"
#include "TFile.h"
#include "TH1.h"
#include <iostream>
#include <vector>
#include "TROOT.h"
#include "TGraphErrors.h"
TGraphErrors* func[27][60];
std::vector<int> marray = {80, 90, 100, 110, 120, 130, 140, 160, 180, 200, 250, 300, 350, 400, 450, 500, 600, 700, 800, 900, 1000, 1200, 1400, 1500, 1600, 1800, 2000};
void ReadFile(){
TFile *file = new TFile("/afs/cern.ch/user/y/ytakahas/public/forHTT/Reweight.root");
const int num_of_tb = 60;
int imass = 0;
for(auto mass: marray){
for(int tanb=0; tanb < num_of_tb; tanb++){
TString wname = "weight_MSSM_";
wname += mass;
wname += "_tanb_";
wname += tanb + 1;
// std::cout << wname << " " << func[imass][tanb] << " " << func[imass][tanb]->GetBinContent(1) << std::endl;
func[imass][tanb] = (TGraphErrors*) gROOT->FindObject(wname);
}
imass++;
}
// delete file;
}
float returnNLOweight(Int_t mass, Int_t tanb, Double_t pt){
if(pt > 800){
// std::cout << "[INFO] pT = " << pt << " exceeds the range --> set it to 800." << std::endl;
pt = 800;
}
auto iter = std::find(marray.begin(), marray.end(), mass);
size_t index = std::distance(marray.begin(), iter);
if(index == marray.size()){
std::cout << "[WARNING] Invalid mass point ... " << mass << " -> return weight 1" << std::endl;
return 1;
}
if(tanb <1 || tanb > 60){
std::cout << "[WARNING] Invalid tan(beta) point ... " << tanb << " -> return weight 1" << std::endl;
return 1;
}
return func[index][tanb-1]->Eval(pt) ;
}
void functionmacro(){
std::cout << std::endl;
std::cout << "Initialize functionmacro.C ... " << std::endl;
std::cout << std::endl;
ReadFile();
}