Belle II Software  release-05-01-25
XTCalibration.cc
1 #include <cdc/calibration/XT.h>
2 #include <cdc/calibration/XTCalibration.h>
3 
4 #include <cdc/dbobjects/CDCXtRelations.h>
5 
6 #include <TError.h>
7 #include <TROOT.h>
8 #include <TH1D.h>
9 #include <TProfile.h>
10 #include <TF1.h>
11 #include <TFile.h>
12 #include <TChain.h>
13 #include <TSystem.h>
14 #include <iostream>
15 #include <iomanip>
16 
17 #include <framework/database/DBObjPtr.h>
18 #include <framework/logging/Logger.h>
19 #include <framework/utilities/FileSystem.h>
20 #include <cdc/calibration/CDCDatabaseImporter.h>
21 
22 #include <boost/iostreams/filtering_stream.hpp>
23 #include <boost/iostreams/device/file.hpp>
24 #include <boost/iostreams/filter/gzip.hpp>
25 
26 using namespace std;
27 using namespace Belle2;
28 using namespace CDC;
29 typedef std::array<float, 3> array3;
30 XTCalibration::XTCalibration():
31  m_firstExperiment(0), m_firstRun(0),
32  m_lastExperiment(-1), m_lastRun(-1)
33 {
34  /*
35  setDescription(
36  " -------------------------- Test Calibration Algoritm -------------------------\n"
37  " \n"
38  " Testing algorithm which just gets mean of a test histogram collected by \n"
39  0 " CaTest module and provides a DB object with another histogram with one \n"
40  " entry at calibrated value. \n"
41  " ------------------------------------------------------------------------------\n"
42  );
43  */
44 }
45 
47 {
48  readXT();
49  readProfile();
50  /* read data from tree, make histo for fit*/
51  TChain* tree = new TChain("tree");
52  tree->Add(m_inputRootFileNames.c_str());
53  B2INFO("Open Files: " << m_inputRootFileNames);
54  if (!tree->GetBranch("ndf")) {
55  cout << "input data do not exits, please check!" << endl;
56  B2FATAL("echo rootfile do not exits or something wrong");
57  gSystem->Exec("echo rootfile do not exits or something wrong >> error");
58  return;
59  }
60  int lay;
61  double dt;
62  double dx;
63  double Pval, alpha, theta;
64  double ndf;
65 
66  tree->SetBranchAddress("lay", &lay);
67  tree->SetBranchAddress("t", &dt);
68  tree->SetBranchAddress("x_u", &dx);
69  tree->SetBranchAddress("alpha", &alpha);
70  tree->SetBranchAddress("theta", &theta);
71  tree->SetBranchAddress("Pval", &Pval);
72  tree->SetBranchAddress("ndf", &ndf);
73 
74  /* Disable unused branch */
75  std::vector<TString> list_vars = {"lay", "t", "x_u", "alpha", "theta", "Pval", "ndf"};
76  tree->SetBranchStatus("*", 0);
77 
78  for (TString brname : list_vars) {
79  tree->SetBranchStatus(brname, 1);
80  }
81 
82 
83  /*Create histogram*/
84  for (int i = 0; i < 56; ++i) {
85  for (int lr = 0; lr < 2; ++lr) {
86  for (int al = 0; al < m_nalpha; ++al) {
87  for (int th = 0; th < m_ntheta; ++th) {
88  hprof[i][lr][al][th] = new TProfile(Form("hprof%d_%d_%d_%d", i, lr, al, th),
89  Form("(L=%d)-(lr=%d)-(#alpha=%3.0f)-(#theta=%3.0f); Drift time (ns);Drift Length (cm)",
90  i, lr, ialpha[al], itheta[th]), 210, -20, 600, 0, 1.2, "i");
91  hist2d[i][lr][al][th] = new TH2D(Form("h%d_%d_%d_%d", i, lr, al, th),
92  Form("(L=%d)-(lr=%d)-(#alpha=%3.0f)-(#theta=%3.0f); Drift time (ns);Drift Length (cm)",
93  i, lr, ialpha[al], itheta[th]), 210, -20, 600, 110, 0, 1.2);
94  if (lr == 1)
95  hist2d_draw[i][al][th] = new TH2D(Form("h_draw%d_%d_%d", i, al, th),
96  Form("(L=%d)-(#alpha=%3.0f)-(#theta=%3.0f); Drift time (ns);Drift Length (cm)",
97  i, ialpha[al], itheta[th]), 210, -20, 600, 2200, -1.2, 1.2);
98  }
99  }
100  }
101  }
102 
103  /*Now read data and make histo*/
104  int al = 0;
105  int th = 0;
106  int lr = 0;
107  Long64_t nbytes = 0;
108  int nEntries = tree->GetEntries();
109  cout << "Number of Hit: " << nEntries << endl;
110 
111  for (int i = 0; i < nEntries; ++i) {
112  nbytes += tree->GetEntry(i);
113  /* protect in case |alpha|>90*/
114  if (fabs(alpha > 90)) {
115  if (alpha < 0) alpha += 180;
116  if (alpha > 0) alpha -= 180;
117  }
118 
119  if (Pval < m_Pvalmin) continue;
120  if (ndf < m_ndfmin) continue;
121 
122  for (int k = 0; k < m_nalpha; ++k) {
123  if (alpha < u_alpha[k]) {al = k; break;}
124  }
125  for (int j = 0; j < m_ntheta; ++j) {
126  if (theta < u_theta[j]) {th = j; break;}
127  }
128  if (dx > 0)
129  lr = 1;
130  else
131  lr = 0;
132  if (m_LRseparate) {
133  hprof[lay][lr][al][th]->Fill(dt, abs(dx));
134  hist2d[lay][lr][al][th]->Fill(dt, abs(dx));
135  } else {
136  hprof[lay][0][al][th]->Fill(dt, abs(dx));
137  hist2d[lay][0][al][th]->Fill(dt, abs(dx));
138  hprof[lay][1][al][th]->Fill(dt, abs(dx));
139  hist2d[lay][1][al][th]->Fill(dt, abs(dx));
140  }
141  hist2d_draw[lay][al][th]->Fill(dt, dx);
142  }
143 }
145 {
146  /*Read profile for xt*/
148  B2INFO("use XT bining from input XT");
151  B2INFO("Nalpha: " << m_nalpha << "\n Ntheta: " << m_ntheta);
152  for (int i = 0; i < m_nalpha; ++i) {
153  l_alpha[i] = l_alpha_old[i];
154  u_alpha[i] = u_alpha_old[i];
155  ialpha[i] = ialpha_old[i];
156  B2INFO("-" << l_alpha[i] << " " << u_alpha[i] << " " << ialpha[i]);
157  }
158  for (int i = 0; i < m_ntheta; ++i) {
159  l_theta[i] = l_theta_old[i];
160  u_theta[i] = u_theta_old[i];
161  itheta[i] = itheta_old[i];
162  B2INFO("-" << l_theta[i] << " " << u_theta[i] << " " << itheta[i]);
163  }
164  } else {
165  B2INFO("use XT bining from profile file");
166  ifstream proxt(m_profileFileName.c_str());
167  if (!proxt) {
168  B2FATAL("file not found: " << m_profileFileName);
169  }
170  double dumy1, dumy2, dumy3;
171  proxt >> m_nalpha;
172  B2DEBUG(99, "Number of alpha bin" << m_nalpha);
173  if (m_nalpha > m_MAXalpha) {
174  B2FATAL("number of alpha bin excess limit; please increse uplimit: " << m_nalpha << " > " << m_MAXalpha);
175  }
176  for (int i = 0; i < m_nalpha; ++i) {
177  proxt >> dumy1 >> dumy2 >> dumy3;
178  l_alpha[i] = dumy1;
179  u_alpha[i] = dumy2;
180  ialpha[i] = dumy3;
181  }
182  proxt >> m_ntheta;
183  B2DEBUG(99, "Number of theta bin" << m_nalpha);
184  if (m_ntheta > m_MAXtheta) {B2FATAL("number of theta bin excess limit; please increse uplimit: " << m_ntheta << " > " << m_MAXtheta);}
185  for (int i = 0; i < m_ntheta; ++i) {
186  proxt >> dumy1 >> dumy2 >> dumy3;
187  l_theta[i] = dumy1;
188  u_theta[i] = dumy2;
189  itheta[i] = dumy3;
190  }
191  }
192  B2INFO("Finish asssign XT bining");
193 }
194 
196 {
197  gROOT->SetBatch(1);
198  gErrorIgnoreLevel = 3001;
199 
200  CreateHisto();
201  B2INFO("Start Fitting");
202  for (int l = 0; l < 56; ++l) {
203  for (int lr = 0; lr < 2; ++lr) {
204  for (int al = 0; al < m_nalpha; ++al) {
205  for (int th = 0; th < m_ntheta; ++th) {
206 
207  if (hist2d[l][lr][al][th]->GetEntries() < m_smallestEntryRequire) {
208  fitflag[l][lr][al][th] = -1;
209  continue;
210  }
211  double p0, p1, tmin;
212  TF1* fpol1;
213  if (m_useSliceFit) {
214  hist2d[l][lr][al][th]->FitSlicesY(0, 0, -1, 5);
215  hist2d_1[l][lr][al][th] = (TH1D*)gDirectory->Get(Form("h%d_%d_%d_%d_1", l, lr, al, th));
216  if (!hist2d_1[l][lr][al][th]) {
217  fitflag[l][lr][al][th] = -1;
218  B2WARNING("error, not found results of slices fit");
219  continue;
220  }
221  hist2d_1[l][lr][al][th]->Fit("pol1", "Q", "", 30, 60);
222  fpol1 = (TF1*)hprof[l][lr][al][th]->GetFunction("pol1");
223  } else {
224  /*Set Error for low statistic bin*/
225  for (int n = 0; n < hprof[l][lr][al][th]->GetNbinsX(); ++n) {
226  if (hprof[l][lr][al][th]->GetBinEntries(n) < 5 && hprof[l][lr][al][th]->GetBinEntries(n) > 1) {
227  hprof[l][lr][al][th]->SetBinError(n, 0.3 / hprof[l][lr][al][th]->GetBinEntries(n));
228  }
229  }
230  hprof[l][lr][al][th]->Fit("pol1", "Q", "", 30, 60);
231  fpol1 = (TF1*)hprof[l][lr][al][th]->GetFunction("pol1");
232  }
233  if (fpol1) {
234  //determine tmin in fitting
235  p0 = fpol1->GetParameter(0);
236  p1 = fpol1->GetParameter(1);
237  tmin = -1 * p0 / p1 + 15;
238  } else {
239  p0 = 0; p1 = 0.005;
240  tmin = 12;
241  }
242  XT* xt;
243  if (m_useSliceFit) {
244  xt = new XT(hist2d_1[l][lr][al][th], m_xtmode);
245  } else {
246  xt = new XT(hprof[l][lr][al][th], m_xtmode);
247  }
248  // xt->setSmallestEntryRequired(m_smallestEntryRequire);
249  if (m_BField) {
250  int ial_old = 0;
251  int ith_old = 0;
252  for (int k = 0; k < nalpha_old; ++k) {
253  if (ialpha[al] < u_alpha_old[k]) {ial_old = k; break;}
254  }
255  for (int j = 0; j < ntheta_old; ++j) {
256  if (itheta[th] < u_theta_old[j]) {ith_old = j; break;}
257  }
258  double p6 = xtold[l][lr][ial_old][ith_old][6];
259  if (p6 > 400)
260  p6 = 400;
261  if (m_xtmode == xtmode_old) {
262  xt->setXTParams(xtold[l][lr][ial_old][ith_old]);
263  xt->setP6(p6);
264  } else {
265  xt->setXTParams(p0, p1, 0., 0., 0., 0., p6, xtold[l][lr][ial_old][ith_old][7]);
266  }
267  xt->setFitRange(tmin, p6 + 100);
268  } else {
269  xt->setXTParams(p0, p1, 0., 0., 0., 0., m_par6[l], 0.0001);
270  xt->setFitRange(tmin, m_par6[l] + 100);
271  }
272  xt->setDebug(m_debug);
273  xt->BField(m_BField);
274  xt->FitXT(m_xtmode);
275  /*get result*/
276  fitflag[l][lr][al][th] = xt->getFitStatus();
277  xtf5r[l][lr][al][th] = (TF1*)xt->getXTFunction();
278  if (m_useSliceFit) {
279  hist2d_1[l][lr][al][th] = (TH1D*)xt->getFittedHisto();
280  } else {
281  hprof[l][lr][al][th] = (TProfile*)xt->getFittedHisto();
282  }
283  }
284  }
285  }
286  }
287  Write();
288  storeHisto();
289  return true;
290 }
292 {
293  /*Set parameter for layer that fit do not success*/
294  /* and then write output file*/
295  double par[8];
296  ofstream xtout(m_OutputXTFileName.c_str());
297  xtout << m_nalpha << endl;
298  for (int i = 0; i < m_nalpha; ++i) {
299  xtout << std::setprecision(3) << l_alpha[i] << " "
300  << std::setprecision(3) << u_alpha[i] << " "
301  << std::setprecision(3) << ialpha[i] << endl;
302  }
303  xtout << m_ntheta << endl;
304  for (int i = 0; i < m_ntheta; ++i) {
305  xtout << std::setprecision(3) << l_theta[i] << " "
306  << std::setprecision(3) << u_theta[i] << " "
307  << std::setprecision(3) << itheta[i] << endl;
308  }
309  xtout << m_xtmode << " " << 8 << endl;
310 
311  int nfitted = 0;
312  int nfailure = 0;
313 
314  for (int th = 0; th < m_ntheta; ++th) {
315  for (int al = 0; al < m_nalpha; ++al) {
316  for (int l = 0; l < 56; ++l) {
317  for (int lr = 0; lr < 2; ++lr) {
318  /*Set Parameter for bad fit*/
319  if (fitflag[l][lr][al][th] != 1) {
320  nfailure += 1;
321  printf("fit failure status = %d \n", fitflag[l][lr][al][th]);
322  printf("layer %d, r %d, alpha %3.1f, theta %3.1f \n", l, lr, ialpha[al], itheta[th]);
323  printf("number of event: %3.2f", hprof[l][lr][al][th]->GetEntries());
324  if (fitflag[l][lr][al][th] != -1) {
325  printf("Probability of fit: %3.4f", xtf5r[l][lr][al][th]->GetProb());
326  }
327  if (m_xtmode == xtmode_old) {
328  int ial_old = 0;
329  int ith_old = 0;
330  for (int k = 0; k < nalpha_old; ++k) {
331  if (ialpha[al] < u_alpha_old[k]) {ial_old = k; break;}
332  }
333  for (int j = 0; j < ntheta_old; ++j) {
334  if (itheta[th] < u_theta_old[j]) {ith_old = j; break;}
335  }
336  for (int p = 0; p < 8; ++p) {
337  par[p] = xtold[l][lr][ial_old][ith_old][p];
338  }
339  } else {
340  //if mode of input xt is different from output, simple xt is used.
341  par[0] = 0; par[1] = 0.004; par[2] = 0; par[3] = 0; par[4] = 0; par[5] = 0; par[6] = m_par6[l]; par[7] = 0.00001;
342  }
343  } else {
344  xtf5r[l][lr][al][th]->GetParameters(par);
345  nfitted += 1;
346  }
347  /*Write params*/
348  xtout << l << std::setw(5) << itheta[th] << std::setw(5) << ialpha[al] << std::setw(5) << "0.0" << std::setw(4) << lr << std::setw(
349  15);
350  for (int p = 0; p < 8; ++p) {
351  if (p != 7) { xtout << std::setprecision(7) << par[p] << std::setw(15);}
352  if (p == 7) { xtout << std::setprecision(7) << par[p] << std::endl;}
353  }
354  }//lr
355  }//th
356  }//al
357  }//lay
358  xtout.close();
359  B2RESULT(" Total number of xt fit: " << m_nalpha * m_ntheta * 2 * 56);
360  B2RESULT(" Successfully Fitted: " << nfitted);
361  B2RESULT(" Failure Fit: " << nfailure);
362  B2RESULT("Finish export xt to text file");
363  if (m_useDB) {
364  CDCDatabaseImporter import(0, 0, -1, -1);
365  import.importXT(m_OutputXTFileName.c_str());
366  }
367 }
368 
370 {
371  B2INFO("start store histogram");
372  TFile* fout = new TFile("XTFIT.root", "RECREATE");
373  TDirectory* top = gDirectory;
374  TDirectory* Direct[56];
375  int nhisto = 0;
376  for (int l = 0; l < 56; ++l) {
377  top->cd();
378  Direct[l] = gDirectory->mkdir(Form("lay_%d", l));
379  Direct[l]->cd();
380  for (int th = 0; th < m_ntheta; ++th) {
381  for (int al = 0; al < m_nalpha; ++al) {
382  hist2d_draw[l][al][th]->Write();
383  for (int lr = 0; lr < 2; ++lr) {
384  hist2d[l][lr][al][th]->Write();
385  if (fitflag[l][lr][al][th] != 1) continue;
386  if (m_useSliceFit) {
387  if (hist2d_1[l][lr][al][th]) {
388  hist2d_1[l][lr][al][th]->Write();
389  nhisto += 1;
390  }
391  } else {
392  hprof[l][lr][al][th]->Write();
393  nhisto += 1;
394  }
395  }
396  }
397  }
398  }
399  fout->Close();
400  B2RESULT(" " << nhisto << " histograms was stored.");
401 }
402 
404 {
405  if (m_useDB) {
406  B2INFO("reading xt from DB");
407 
408  /*
409  ReadXT:readXTFromDB(&xtold,dbXT_old,
410  &nalpha_old,l_alpha_old,u_alpha_old,ialpha_old,
411  &ntheta_old,l_theta_old,u_theta_old, itheta_old);
412  */
413  readXTFromDB();
414  B2INFO("Number of theta bin from xt: " << ntheta_old);
415  B2INFO("Theta 0: " << itheta_old[0]);
416  // if(!a){
418  } else {
419  B2INFO("Read Xt from text");
420  /*
421  ReadXT::readXTFromText(xtold,m_xtfile,
422  nalpha_old,l_alpha_old,u_alpha_old,ialpha_old,
423  ntheta_old,l_theta_old,u_theta_old, itheta_old);
424  */
425  readXTFromText();
426  B2INFO("nalpha: " << nalpha_old);
427  // if(!a)
428  // {B2FATAL("Error reading xt from text");return;}
429  }
430 }
431 
433 {
434  std::string fileName1 = "/data/cdc" + m_xtfile;
435  std::string fileName = FileSystem::findFile(fileName1);
436  boost::iostreams::filtering_istream ifs;
437  if (fileName == "") {
438  fileName = FileSystem::findFile(m_xtfile);
439  }
440  if (fileName == "") {
441  B2FATAL("CDCGeometryPar: " << fileName1 << " not exist!");
442  } else {
443  B2INFO("CDCGeometryPar: open " << fileName1);
444  if ((fileName.rfind(".gz") != string::npos) && (fileName.length() - fileName.rfind(".gz") == 3)) {
445  ifs.push(boost::iostreams::gzip_decompressor());
446  }
447  ifs.push(boost::iostreams::file_source(fileName));
448  if (!ifs) B2FATAL("CDCGeometryPar: cannot open " << fileName1 << " !");
449 
450 
451  }
452  int npar = 8;
453  //read alpha bin info.
454  // unsigned short nAlphaBins = 0;
455  ifs >> nalpha_old;
456 
457  for (unsigned short i = 0; i < nalpha_old; ++i) {
458  ifs >> l_alpha_old[i] >> u_alpha_old[i] >> ialpha_old[i];
459  // ifs >> alpha0 >> alpha1 >> alpha2;
460  //m_alphaPoints[i] = alpha2;
461  }
462 
463  //read theta bin info.
464  // unsigned short nThetaBins = 0;
465  ifs >> ntheta_old;
466 
467  for (unsigned short i = 0; i < ntheta_old; ++i) {
468  ifs >> l_theta_old[i] >> u_theta_old[i] >> itheta_old[i];
469  //ifs >> theta0 >> theta1 >> theta2;
470  //m_thetaPoints[i] = theta2;
471  }
472 
473  B2INFO("number of alpha - theta bin" << nalpha_old << " - " << ntheta_old);
474  short np = 0;
475  unsigned short iCL, iLR;
476  // const unsigned short npx = nXTParams - 1;
477  double xtc[npar];
478  double theta, alpha, dummy1;
479  unsigned nRead = 0;
480  // unsigned m_xtParamMode_old;
481  ifs >> xtmode_old >> np;
482 
483  const double epsi = 0.1;
484 
485  while (ifs >> iCL) {
486  ifs >> theta >> alpha >> dummy1 >> iLR;
487  for (int i = 0; i < np; ++i) {
488  ifs >> xtc[i];
489  }
490  ++nRead;
491 
492  int ith = -99;
493  for (unsigned short i = 0; i < ntheta_old; ++i) {
494  if (fabs(theta - itheta_old[i]) < epsi) {
495  ith = i;
496  break;
497  }
498  }
499  if (ith < 0) {
500  gSystem->Exec("echo xt_theta error binning>> error");
501  return;
502  }
503 
504  int ial = -99;
505  for (unsigned short i = 0; i < nalpha_old; ++i) {
506  if (fabs(alpha - ialpha_old[i]) < epsi) {
507  ial = i;
508  break;
509  }
510  }
511  if (ial < 0) {
512  gSystem->Exec("echo xt_alpha error binning>> error");
513  return;
514  }
515 
516  for (int i = 0; i < np; ++i) {
517  xtold[iCL][iLR][ial][ith][i] = xtc[i];
518  }
519 
520  } //end of while loop
521 
522  //convert unit
523  /*
524  const double degrad = M_PI / 180.;
525  for (unsigned i = 0; i < nAlphaBins; ++i) {
526  m_alphaPoints[i] *= degrad;
527  }
528  for (unsigned i = 0; i < nThetaBins; ++i) {
529  m_thetaPoints[i] *= degrad;
530  }
531  */
532  // return true;
533 }
535 {
536  DBObjPtr<CDCXtRelations> dbXT_old;
537  nalpha_old = dbXT_old->getNoOfAlphaBins();
538  B2INFO("Number of alpha" << nalpha_old);
539  double rad2deg = 180 / M_PI;
540  for (unsigned short i = 0; i < nalpha_old; ++i) {
541  array3 alpha = dbXT_old->getAlphaBin(i);
542  l_alpha_old[i] = alpha[0] * rad2deg;
543  u_alpha_old[i] = alpha[1] * rad2deg;
544  ialpha_old[i] = alpha[2] * rad2deg;
545  // std::cout << m_alphaPoints[i]*180./M_PI << std::endl;
546  }
547 
548  ntheta_old = dbXT_old->getNoOfThetaBins();
549  B2INFO("Ntheta: " << ntheta_old);
550  for (unsigned short i = 0; i < ntheta_old; ++i) {
551  // m_thetaPoints[i] = (*dbXT_old).getThetaPoint(i);
552  array3 theta = dbXT_old->getThetaBin(i);
553  l_theta_old[i] = theta[0] * rad2deg;
554  u_theta_old[i] = theta[1] * rad2deg;
555  itheta_old[i] = theta[2] * rad2deg;
556 
557 
558  // std::cout << m_thetaPoints[i]*180./M_PI << std::endl;
559  }
560 
561  xtmode_old = dbXT_old->getXtParamMode();
562 
563  for (unsigned short iCL = 0; iCL < 56; ++iCL) {
564  for (unsigned short iLR = 0; iLR < 2; ++iLR) {
565  for (unsigned short iA = 0; iA < nalpha_old; ++iA) {
566  for (unsigned short iT = 0; iT < ntheta_old; ++iT) {
567  const std::vector<float> params = dbXT_old->getXtParams(iCL, iLR, iA, iT);
568  unsigned short np = params.size();
569  // std::cout <<"np4xt= " << np << std::endl;
570  for (unsigned short i = 0; i < np; ++i) {
571  xtold[iCL][iLR][iA][iT][i] = params[i];
572  }
573  }
574  }
575  }
576  }
577  // return true;
578 }
XT::getFittedHisto
TProfile * getFittedHisto()
Get histogram.
Definition: XT.h:188
Belle2::CDC::XTCalibration::u_alpha
double u_alpha[18]
Upper boundays of alpha bins.
Definition: XTCalibration.h:116
Belle2::CDC::XTCalibration::m_MAXtheta
int m_MAXtheta
max theta bin
Definition: XTCalibration.h:133
Belle2::CDC::XTCalibration::m_LRseparate
bool m_LRseparate
Separate LR in calibration or mix.
Definition: XTCalibration.h:77
Belle2::CDC::XTCalibration::hist2d_draw
TH2D * hist2d_draw[56][20][10]
2d histo for draw
Definition: XTCalibration.h:88
Belle2::CDC::XTCalibration::CreateHisto
virtual void CreateHisto()
Create histogram for calibration.
Definition: XTCalibration.cc:46
Belle2::CDC::XTCalibration::xtmode_old
unsigned short xtmode_old
XT mode old, 0-polynomial, 1 Cheb.
Definition: XTCalibration.h:131
Belle2::CDC::XTCalibration::xtf5r
TF1 * xtf5r[56][2][20][10]
XTFunction.
Definition: XTCalibration.h:84
Belle2::CDC::XTCalibration::u_theta
double u_theta[7]
Upper boundays of theta bins.
Definition: XTCalibration.h:119
Belle2::CDC::XTCalibration::nalpha_old
int nalpha_old
number of alpha bins from input
Definition: XTCalibration.h:122
Belle2::CDC::XTCalibration::storeHisto
virtual void storeHisto()
Store histogram to file.
Definition: XTCalibration.cc:369
XT::setP6
void setP6(double p6)
Set Parameter 6 for polynomia fit.
Definition: XT.h:86
Belle2::CDC::XTCalibration::m_ndfmin
double m_ndfmin
minimum ndf required
Definition: XTCalibration.h:71
Belle2::CDC::XTCalibration::hist2d
TH2D * hist2d[56][2][20][10]
2D histo of xt
Definition: XTCalibration.h:87
Belle2::CDC::XTCalibration::readProfile
virtual void readProfile()
Read profile xt file.
Definition: XTCalibration.cc:144
XT::setXTParams
void setXTParams(double p[8])
Set Paramerters for fit.
Definition: XT.h:108
Belle2::CDC::XTCalibration::l_theta
double l_theta[7]
Lower boundays of theta bins.
Definition: XTCalibration.h:118
Belle2::CDC::XTCalibration::m_profileFileName
std::string m_profileFileName
profile file name
Definition: XTCalibration.h:101
Belle2::CDC::XTCalibration::itheta
double itheta[7]
represented alphas of theta bins.
Definition: XTCalibration.h:120
Belle2::CDCDatabaseImporter::importXT
void importXT(std::string fileName)
Import xt table to the database.
Belle2::CDC::XTCalibration::calibrate
virtual bool calibrate()
Run algo on data.
Definition: XTCalibration.cc:195
XT::FitXT
void FitXT()
Do fitting.
Definition: XT.h:193
Belle2::CDC::XTCalibration::m_xtfile
std::string m_xtfile
Input xt file name, incase text mode.
Definition: XTCalibration.h:102
Belle2::CDC::XTCalibration::itheta_old
double itheta_old[7]
represented alphas of theta bins from input.
Definition: XTCalibration.h:129
Belle2::CDC::XTCalibration::m_BField
bool m_BField
with b field or none
Definition: XTCalibration.h:79
XT::BField
void BField(bool bfield)
set to use BField
Definition: XT.h:103
XT
Class to perform fitting for each xt function.
Definition: XT.h:53
Belle2::CDC::XTCalibration::xtold
double xtold[56][2][18][7][8]
Old paremeter.
Definition: XTCalibration.h:82
Belle2::CDC::XTCalibration::m_Pvalmin
double m_Pvalmin
minimum pvalue required
Definition: XTCalibration.h:72
Belle2::CDC::XTCalibration::m_smallestEntryRequire
int m_smallestEntryRequire
minimum number of hit per hitosgram.
Definition: XTCalibration.h:135
Belle2::DBObjPtr
Class for accessing objects in the database.
Definition: DBObjPtr.h:31
Belle2::CDC::XTCalibration::fitflag
int fitflag[56][2][20][10]
Fit flag.
Definition: XTCalibration.h:83
Belle2::CDC::XTCalibration::m_OutputXTFileName
std::string m_OutputXTFileName
Out put xt filename.
Definition: XTCalibration.h:99
Belle2::CDC::XTCalibration::m_xtmode
unsigned short m_xtmode
Mode of xt; 0 is polynomial;1 is Chebyshev.
Definition: XTCalibration.h:134
Belle2::CDC::XTCalibration::ialpha
double ialpha[18]
represented alphas of alpha bins.
Definition: XTCalibration.h:117
Belle2::CDC::XTCalibration::m_useDB
bool m_useDB
Use Database or text mode.
Definition: XTCalibration.h:75
Belle2::CDC::XTCalibration::hist2d_1
TH1D * hist2d_1[56][2][20][10]
1D xt histo, results of slice fit
Definition: XTCalibration.h:89
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::CDC::XTCalibration::readXT
virtual void readXT()
read xt paramter (wrap text mode and database mode)
Definition: XTCalibration.cc:403
Belle2::CDC::XTCalibration::l_theta_old
double l_theta_old[7]
Lower boundays of theta bins from input.
Definition: XTCalibration.h:127
Belle2::CDC::XTCalibration::m_inputRootFileNames
std::string m_inputRootFileNames
input root filename
Definition: XTCalibration.h:100
Belle2::CDC::XTCalibration::Write
virtual void Write()
Store calibrated constand.
Definition: XTCalibration.cc:291
Belle2::CDC::XTCalibration::ntheta_old
int ntheta_old
number of theta bins from input
Definition: XTCalibration.h:123
XT::getFitStatus
int getFitStatus()
get fitted flag.
Definition: XT.h:150
XT::setDebug
void setDebug(bool debug)
Set Debug.
Definition: XT.h:143
Belle2::CDC::XTCalibration::m_debug
bool m_debug
run in debug or silent
Definition: XTCalibration.h:73
Belle2::CDC::XTCalibration::readXTFromDB
virtual void readXTFromDB()
Read old xt parameter from database.
Definition: XTCalibration.cc:534
Belle2::CDC::XTCalibration::hprof
TProfile * hprof[56][2][20][10]
Profile xt histo.
Definition: XTCalibration.h:86
Belle2::CDC::XTCalibration::u_theta_old
double u_theta_old[7]
Upper boundays of theta bins from input.
Definition: XTCalibration.h:128
Belle2::CDC::XTCalibration::readXTFromText
virtual void readXTFromText()
Read old xt parameter from text file, incase text mode is used.
Definition: XTCalibration.cc:432
Belle2::CDC::XTCalibration::m_nalpha
int m_nalpha
number of alpha bins
Definition: XTCalibration.h:113
Belle2::CDC::XTCalibration::u_alpha_old
double u_alpha_old[18]
Upper boundays of alpha bins from input.
Definition: XTCalibration.h:125
Belle2::CDC::XTCalibration::ialpha_old
double ialpha_old[18]
represented alphas of alpha bins from input.
Definition: XTCalibration.h:126
Belle2::CDC::XTCalibration::m_useSliceFit
bool m_useSliceFit
Use slice fit or profile.
Definition: XTCalibration.h:78
Belle2::CDC::XTCalibration::m_ntheta
int m_ntheta
number of theta bins
Definition: XTCalibration.h:114
XT::getXTFunction
TF1 * getXTFunction(int mode)
Get XT function.
Definition: XT.h:172
Belle2::CDC::XTCalibration::m_par6
double m_par6[56]
boundary parameter for fitting, semi-experiment number
Definition: XTCalibration.h:137
Belle2::CDC::XTCalibration::l_alpha
double l_alpha[18]
Lower boundays of alpha bins.
Definition: XTCalibration.h:115
Belle2::FileSystem::findFile
static std::string findFile(const std::string &path, bool silent=false)
Search for given file or directory in local or central release directory, and return absolute path if...
Definition: FileSystem.cc:147
Belle2::CDC::XTCalibration::l_alpha_old
double l_alpha_old[18]
Lower boundays of alpha bins from input.
Definition: XTCalibration.h:124
Belle2::CDCDatabaseImporter
CDC database importer.
Definition: CDCDatabaseImporter.h:32
XT::setFitRange
void setFitRange(double tmin, double tmax)
Set Fit range.
Definition: XT.h:128
Belle2::CDC::XTCalibration::m_useProfileXTFromInputXT
bool m_useProfileXTFromInputXT
use profile from text file or default in input xt
Definition: XTCalibration.h:76
Belle2::CDC::XTCalibration::m_MAXalpha
int m_MAXalpha
max alpha bin
Definition: XTCalibration.h:132