Belle II Software development
MuidProb Class Reference

Class computes probability density for Muid calculation. More...

#include <B2BIIFixMdstModule.h>

MuidProb methods:

static const int kRange = 16
 Array size of range.
 
static const int kRchisq = 50
 Array size of reduced chi-squared.
 
static const int kEEcl = 100
 Array size of ECL energy.
 
static const int kPTrk = 50
 Array size of CDC momentum.
 
static const double kRchisqMax = 10.0
 Overflow value of reduced chi-squared.
 
static const double kEEclMax = 1.0
 Overflow value of ECL energy.
 
static const double kPTrkMax = 5.0
 Overflow value of CDC momentum.
 
double fRange [2][4][15][kRange]
 Range pdf.
 
double fRchisq [2][4][kRchisq+1]
 Reduced chi-squared pdf.
 
double fRchisqN [2][4][15]
 Non-overflow normalization.
 
double fRchisqD1 [2][4][kRchisq+1] = {{{0.0}}}
 First derivatives of Reduced chi-squared pdf.
 
double fRchisqD2 [2][4][kRchisq+1] = {{{0.0}}}
 Second derivatives of Reduced chi-squared pdf.
 
double fRchisqD3 [2][4][kRchisq+1] = {{{0.0}}}
 Third derivatives of Reduced chi-squared pdf.
 
double fEEcl [kPTrk][kEEcl+1]
 ECL energy pdf.
 
double fEEclD1 [kPTrk][kEEcl+1] = {{0.0}}
 First derivatives of ECL energy pdf.
 
double fEEclD2 [kPTrk][kEEcl+1] = {{0.0}}
 Second derivatives of ECL energy pdf.
 
double fEEclD3 [kPTrk][kEEcl+1] = {{0.0}}
 Third derivatives of ECL energy pdf.
 
 MuidProb (const char *, int &)
 Constructor.
 
 ~MuidProb ()
 Destructor.
 
double prob (int, int, int, int, double) const
 Compute probability density.
 
double probRange (int, int, int, int) const
 Compute probability density for range.
 
double probRchisq (int, int, int, double) const
 Compute probability density for reduced chi-squared.
 
double probECL (double, double) const
 Compute probability density for ECL energy deposit.
 
void readDB (const char *, int &)
 Read in probability density functions from database.
 

Detailed Description

Class computes probability density for Muid calculation.

Definition at line 282 of file B2BIIFixMdstModule.h.

Constructor & Destructor Documentation

◆ MuidProb()

MuidProb ( const char *  dbtemplate,
int &  expNo 
)

Constructor.

Definition at line 287 of file B2BIIFixMdstModule_muid.cc.

288{
289
290 readDB(dbtemplate, expNo);
291
292}
void readDB(const char *, int &)
Read in probability density functions from database.

◆ ~MuidProb()

~MuidProb ( )
inline

Destructor.

Definition at line 291 of file B2BIIFixMdstModule.h.

291{};

Member Function Documentation

◆ prob()

double prob ( int  ECMaxLyr,
int  outcome,
int  lyr_ext,
int  lyr_dif,
double  chi2_red 
) const

Compute probability density.

Definition at line 376 of file B2BIIFixMdstModule_muid.cc.

378{
379
380 // ECMaxLyr: 0 if Endcap_MX_layer == 13; 1 if Endcap_MX_layer == 11
381 // outcome: 0=??, 1=Barrel Stop, 2=Endcap Stop, 3=Barrel Exit, 4=Endcap Exit
382 // lyr_ext: last layer that Ext track touched
383 // lyr_dif: difference between last Ext layer and last hit layer
384 // chi2_red: reduced chi**2 of the transverse deviations of all associated
385 // hits from the corresponding Ext track crossings
386
387 return probRange(ECMaxLyr, outcome, lyr_ext, lyr_dif) *
388 probRchisq(ECMaxLyr, outcome, lyr_ext, chi2_red);
389
390}
double probRange(int, int, int, int) const
Compute probability density for range.
double probRchisq(int, int, int, double) const
Compute probability density for reduced chi-squared.

◆ probECL()

double probECL ( double  eEcl,
double  p 
) const

Compute probability density for ECL energy deposit.

Definition at line 456 of file B2BIIFixMdstModule_muid.cc.

457{
458
459 // eEcl: ECL energy (GeV)
460 // p: CDC momentum (GeV/c)
461
462 double prob;
463 int jTrk = (p < kPTrkMax) ? (int)(p / (kPTrkMax / kPTrk)) : kPTrk - 1;
464 if (eEcl >= kEEclMax) {
465 prob = fEEcl[jTrk][kEEcl]; // overflow bin
466 } else {
467 int i = (int)(eEcl / (kEEclMax / kEEcl));
468 double dx = eEcl - i * (kEEclMax / kEEcl);
469 prob = fEEcl[jTrk][i] +
470 dx * (fEEclD1[jTrk][i] +
471 dx * (fEEclD2[jTrk][i] +
472 dx * fEEclD3[jTrk][i]));
473 if (prob < 0.0) { prob = 0.0; } // don't let spline fit go negative
474 }
475 return prob;
476
477}
double prob(int, int, int, int, double) const
Compute probability density.
static const double kEEclMax
Overflow value of ECL energy.
double fEEclD1[kPTrk][kEEcl+1]
First derivatives of ECL energy pdf.
double fEEclD2[kPTrk][kEEcl+1]
Second derivatives of ECL energy pdf.
static const double kPTrkMax
Overflow value of CDC momentum.
double fEEclD3[kPTrk][kEEcl+1]
Third derivatives of ECL energy pdf.
static const int kEEcl
Array size of ECL energy.
static const int kPTrk
Array size of CDC momentum.
double fEEcl[kPTrk][kEEcl+1]
ECL energy pdf.

◆ probRange()

double probRange ( int  ECMaxLyr,
int  outcome,
int  lyr_ext,
int  lyr_dif 
) const

Compute probability density for range.

Definition at line 394 of file B2BIIFixMdstModule_muid.cc.

396{
397
398
399 // ECMaxLyr: 0 if max endcap layer is 13; 1 if it's 11.
400 // outcome: 0=??, 1=Barrel Stop, 2=Endcap Stop, 3=Barrel Exit, 4=Endcap Exit
401 // lyr_ext: last layer that Ext track touched
402 // lyr_dif: difference between last Ext layer and last hit layer
403
404 if (outcome <= 0) { return 0.0; }
405 if (outcome > 4) { return 0.0; }
406 if (lyr_ext < 0) { return 0.0; }
407 if (lyr_ext > 14) { return 0.0; }
408 if (lyr_dif < 0) { return 0.0; }
409 if (lyr_dif >= kRange) { lyr_dif = kRange - 1; }
410
411 return fRange[ECMaxLyr][outcome - 1][lyr_ext][lyr_dif];
412
413}
static const int kRange
Array size of range.
double fRange[2][4][15][kRange]
Range pdf.

◆ probRchisq()

double probRchisq ( int  ECMaxLyr,
int  outcome,
int  lyr_ext,
double  chi2_red 
) const

Compute probability density for reduced chi-squared.

Definition at line 417 of file B2BIIFixMdstModule_muid.cc.

419{
420
421 // ECMaxLyr: 0 if max endcap layer is 13; 1 if it's 11.
422 // outcome: 0=??, 1=Barrel Stop, 2=Endcap Stop, 3=Barrel Exit, 4=Endcap Exit
423 // lyr_ext: last layer that Ext track touched
424 // chi2_red: reduced chi**2 of the transverse deviations of all associated
425 // hits from the corresponding Ext track crossings
426
427 // Extract the probability density for a particular value of reduced
428 // chi-squared by spline interpolation of the binned histogram values.
429 // This avoids binning artifacts that were seen when the histogram
430 // was sampled directly.
431
432 if (outcome <= 0) { return 0.0; }
433 if (outcome > 4) { return 0.0; }
434 if (lyr_ext < 0) { return 0.0; }
435 if (lyr_ext > 14) { return 0.0; }
436 if (chi2_red < 0.0) { return 0.0; }
437
438 double prob;
439 double area = fRchisqN[ECMaxLyr][outcome - 1][lyr_ext];
440 if (chi2_red >= kRchisqMax) {
441 prob = area * fRchisq[ECMaxLyr][outcome - 1][kRchisq - 1] + (1.0 - area);
442 } else {
443 int i = (int)(chi2_red / (kRchisqMax / kRchisq));
444 double dx = chi2_red - i * (kRchisqMax / kRchisq);
445 prob = fRchisq[ECMaxLyr][outcome - 1][i] +
446 dx * (fRchisqD1[ECMaxLyr][outcome - 1][i] +
447 dx * (fRchisqD2[ECMaxLyr][outcome - 1][i] +
448 dx * fRchisqD3[ECMaxLyr][outcome - 1][i]));
449 prob = (prob < 0.0) ? 0.0 : area * prob;
450 }
451 return prob;
452}
double fRchisq[2][4][kRchisq+1]
Reduced chi-squared pdf.
double fRchisqD2[2][4][kRchisq+1]
Second derivatives of Reduced chi-squared pdf.
double fRchisqD1[2][4][kRchisq+1]
First derivatives of Reduced chi-squared pdf.
static const int kRchisq
Array size of reduced chi-squared.
double fRchisqN[2][4][15]
Non-overflow normalization.
double fRchisqD3[2][4][kRchisq+1]
Third derivatives of Reduced chi-squared pdf.
static const double kRchisqMax
Overflow value of reduced chi-squared.

◆ readDB()

void readDB ( const char *  dbtemplate,
int &  expNo 
)

Read in probability density functions from database.

Definition at line 294 of file B2BIIFixMdstModule_muid.cc.

295{
296
297 double dx; // bin size
298
299 if (expNo == 0) return; // do nothing if pdf file was not found previously
300
301 if ((expNo < 5) || ((expNo & 1) == 0)) {
302 expNo = 5; // Runs 1-4 and all even-numbered runs map to Exp #5
303 }
304
305 char dbname[] = "muid_xxxx_e000000.dat";
306 std::string pathname = "";
307 bool tmp = Belle::set_belfnm_verbose(false);
308 while ((pathname == "") && (expNo >= 5)) {
309 std::sprintf(dbname, "%s%s%s%06d%s", "muid_", dbtemplate,
310 "_e", expNo, ".dat");
311 pathname = Belle::belfnm(dbname, 0, "share/belle_legacy/data-files/muid");
312 expNo -= 2;
313 }
314 (void)Belle::set_belfnm_verbose(tmp);
315 expNo += 2;
316 if (pathname == "") {
317 B2ERROR("%MuidProb: Failed to open database file."
318 << "Module B2BIIFixMdst muid will do nothing.");
319 expNo = 0;
320 return;
321 }
322
323 std::ifstream probDB;
324 char ident[90];
325 probDB.open(pathname.c_str());
326 probDB.get(ident, 80, '\n');
327 B2INFO("%MuidProb: Reading file " << pathname
328 << std::endl << "%MuidProb: " << ident
329 << std::endl << "%MuidProb: ");
330
331 for (int l = 0; l < 2; l++) {
332 B2INFO("range ");
333 for (int k = 0; k < 4; k++) {
334 for (int j = 0; j < 15; j++) {
335 for (int i = 0; i < kRange; i++) {
336 probDB >> fRange[l][k][j][i];
337 }
338 }
339 }
340 B2INFO("chi**2 ");
341 dx = kRchisqMax / kRchisq;
342 for (int k = 0; k < 4; k++) {
343 for (int i = 0; i < kRchisq; i++) {
344 probDB >> fRchisq[l][k][i];
345 }
346 Spline::muidSpline(kRchisq, dx, &fRchisq[l][k][0], &fRchisqD1[l][k][0],
347 &fRchisqD2[l][k][0], &fRchisqD3[l][k][0]);
348 }
349 for (int k = 0; k < 4; k++) {
350 for (int j = 0; j < 15; j++) {
351 probDB >> fRchisqN[l][k][j];
352 }
353 }
354 }
355 B2INFO("eEcl ");
356 dx = kEEclMax / kEEcl;
357 for (int k = 0; k < kPTrk; k++) {
358 double probSum = 0.0; // normalization denominator
359 for (int i = 0; i < kEEcl; i++) {
360 probDB >> fEEcl[k][i];
361 probSum += fEEcl[k][i];
362 }
363 fEEcl[k][kEEcl] = 1.0 - probSum; // overflow bin
364 if (fEEcl[k][kEEcl] < 0.0) { fEEcl[k][kEEcl] = 0.0; }
365 if (fEEcl[k][kEEcl] > 1.0) { fEEcl[k][kEEcl] = 1.0; }
366 Spline::muidSpline(kEEcl, dx, &fEEcl[k][0], &fEEclD1[k][0],
367 &fEEclD2[k][0], &fEEclD3[k][0]);
368 }
369
370 probDB.close();
371
372}

Member Data Documentation

◆ fEEcl

double fEEcl[kPTrk][kEEcl+1]
private

ECL energy pdf.

Definition at line 331 of file B2BIIFixMdstModule.h.

◆ fEEclD1

double fEEclD1[kPTrk][kEEcl+1] = {{0.0}}
private

First derivatives of ECL energy pdf.

Definition at line 332 of file B2BIIFixMdstModule.h.

◆ fEEclD2

double fEEclD2[kPTrk][kEEcl+1] = {{0.0}}
private

Second derivatives of ECL energy pdf.

Definition at line 333 of file B2BIIFixMdstModule.h.

◆ fEEclD3

double fEEclD3[kPTrk][kEEcl+1] = {{0.0}}
private

Third derivatives of ECL energy pdf.

Definition at line 334 of file B2BIIFixMdstModule.h.

◆ fRange

double fRange[2][4][15][kRange]
private

Range pdf.

Definition at line 325 of file B2BIIFixMdstModule.h.

◆ fRchisq

double fRchisq[2][4][kRchisq+1]
private

Reduced chi-squared pdf.

Definition at line 326 of file B2BIIFixMdstModule.h.

◆ fRchisqD1

double fRchisqD1[2][4][kRchisq+1] = {{{0.0}}}
private

First derivatives of Reduced chi-squared pdf.

Definition at line 328 of file B2BIIFixMdstModule.h.

◆ fRchisqD2

double fRchisqD2[2][4][kRchisq+1] = {{{0.0}}}
private

Second derivatives of Reduced chi-squared pdf.

Definition at line 329 of file B2BIIFixMdstModule.h.

◆ fRchisqD3

double fRchisqD3[2][4][kRchisq+1] = {{{0.0}}}
private

Third derivatives of Reduced chi-squared pdf.

Definition at line 330 of file B2BIIFixMdstModule.h.

◆ fRchisqN

double fRchisqN[2][4][15]
private

Non-overflow normalization.

Definition at line 327 of file B2BIIFixMdstModule.h.

◆ kEEcl

const int kEEcl = 100
staticprivate

Array size of ECL energy.

Definition at line 310 of file B2BIIFixMdstModule.h.

◆ kEEclMax

const double kEEclMax = 1.0
staticprivate

Overflow value of ECL energy.

Definition at line 316 of file B2BIIFixMdstModule.h.

◆ kPTrk

const int kPTrk = 50
staticprivate

Array size of CDC momentum.

Definition at line 311 of file B2BIIFixMdstModule.h.

◆ kPTrkMax

const double kPTrkMax = 5.0
staticprivate

Overflow value of CDC momentum.

Definition at line 317 of file B2BIIFixMdstModule.h.

◆ kRange

const int kRange = 16
staticprivate

Array size of range.

Definition at line 308 of file B2BIIFixMdstModule.h.

◆ kRchisq

const int kRchisq = 50
staticprivate

Array size of reduced chi-squared.

Definition at line 309 of file B2BIIFixMdstModule.h.

◆ kRchisqMax

const double kRchisqMax = 10.0
staticprivate

Overflow value of reduced chi-squared.

Definition at line 315 of file B2BIIFixMdstModule.h.


The documentation for this class was generated from the following files: