12#include "TObjectTable.h"
23TTree*
t =
new TTree(
"t",
"tree to save original data");
30void f_opt(
double left,
double right,
int bins);
31double f_cals(
double left,
double right,
double step);
37TTree *
t_save =
new TTree(
"t_save",
"tree to save entropy");
43int main(
int argc,
char **argv){
45 if(argc<2){ cout <<
"please append config file, ex. binning.exe config.txt" << endl;
return 0;}
46 TFile *
f =
new TFile(
"pre_data.root");
47 t = (TTree*)
f->Get(
"n103");
48 ifstream config_file(argv[1]);
50 cout <<
"cannot read config file correctly!" << endl;
53 TFile *
f_group =
new TFile(
"group_points.root");
55 cout <<
"cannot read group points file correctly!" << endl;
58 TTree *t_group = (TTree*)
f_group->Get(
"t");
60 t_group->SetBranchAddress(
"x", &m_x_temp);
76 cout <<
"finial results for this time binning" << endl;
89 if(
m_debug) cout <<
"f_opt() is happily running!" << endl;
94 TTree *tree =
new TTree(
"tree",
"tree to save temp data");
98 tree->SetBranchAddress(
"nhits", &m_hits);
99 int m_num_total(tree->GetEntries());
100 for(
int k=0; k<m_num_total; k++){
107 double temp_s(0), temp_pos(0);
109 for(
unsigned int i=0; i<
vec_bg.size(); i++){
112 for(
double pos=
vec_bg[i]+pos_step; pos<
vec_bg[i+1]-0.00001; pos+=pos_step){
116 v.insert(
v.begin()+i+1, pos);
124 cout <<
"i:" << i <<
" pos:" << pos <<
" diff_s:" << diff_s <<
" temp_s:" << temp_s << endl;
125 cout <<
"temp_v: " << endl;
127 cout <<
"vec_bg: " << endl;
133 cout <<
"============== vec_bg =============" <<endl;
135 cout << endl << endl;
141void f_group(
double left,
double right,
int &
num,
int &index){
146 if(right<=
x_group[i]){
num = i - index;
break;}
157double f_cals(
double left,
double right,
double pos){
159 if(
m_debug) cout <<
"f_cal() is happyily running!" << endl;
160 for(
int i=0; i<
t_save->GetEntries(); i++){
164 double left_s(0), right_s(0), total_s(0);
165 double left_ratio(0), right_ratio(0);
166 TFile *
file =
new TFile(
"temp.root",
"recreate");
167 TTree *tree =
t->CopyTree(Form(
"bg>%f && bg<%f", left, right));
168 if(
m_debug){ cout <<
"after open temp.root" << endl; gDirectory->pwd(); gDirectory->ls(); }
169 double a_step(0.93*2/10);
170 for(
int i=0; i<2; i++){
174 int m_index_group(-1);
176 if(
m_debug) cout <<
"left " <<
m_left <<
" right " <<
m_right <<
" num of groups: " << m_num_group <<
" boundary index: " << m_index_group << endl;
177 for(
int j=0; j<10; j++){
178 TTree *temp_tree =
new TTree(
"tepm_tree",
"temp tree");
179 temp_tree = tree->CopyTree(Form(
"bg>%f && bg<%f && costheta>%f && costheta<%f",
m_left,
m_right, -0.93+j*a_step, -0.93+(j+1)*a_step));
183 temp_tree->SetBranchAddress(
"nhits", &
nhits);
184 temp_tree->SetBranchAddress(
"bg", &m_bg);
186 for(
int k=0; k<temp_tree->GetEntries(); k++){
187 temp_tree->GetEntry(k);
191 if(tot_nhits<2000){
file->Close();
return(100000.); }
193 for(
int n=0;
n<m_num_group;
n++){
197 if(p>1) cout <<
"m_index_group " << m_index_group <<
" n " <<
n <<
" hits_group[] " <<
hits_group[m_index_group+
n] <<
" tot_nhits " << tot_nhits << endl;
198 if(i==0) left_s += -p*TMath::Log2(p);
199 if(i==1) right_s += -p*TMath::Log2(p);
201 if(i==0) left_ratio += tot_nhits;
202 if(i==1) right_ratio += tot_nhits;
204 if(
m_debug) cout <<
"m_left:" <<
m_left <<
" m_right:" <<
m_right <<
" j:" << j <<
" left_s:" << left_s <<
" right_s:" << right_s << endl;
207 if(fabs(right-pos)<0.00001)
break;
211 left_ratio = left_ratio/(left_ratio+right_ratio);
212 right_ratio = 1-left_ratio;
213 total_s = left_ratio*left_s + right_ratio*right_s;
214 if(
m_debug) cout <<
"left_ratio: " << left_ratio <<
" right_ratio: " << right_ratio <<
" total_s: " << total_s << endl;
225 for(vdouble::iterator i=
v.begin(); i<
v.end(); i++) cout << *i <<
" " ;
230 cout <<
"vec[" <<
m_bins <<
"] = {" ;
231 for(vdouble::iterator i=
v.begin(); i<
v.end(); i++) cout << *i <<
", " ;
232 cout <<
"};" << endl;
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
void f_group(double left, double right, int &num, int &index)
std::vector< double > vdouble
void f_opt(double left, double right, int bins)
void print_vec_verso(vdouble v)
const double test_times(2)
double f_cals(double left, double right, double step)
void print_vec(vdouble v)