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;