/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Mdc/MdcCalibAlg/MdcCalibAlg-00-09-02/share/distcalib/src/include/fun.h File Reference

#include <string>
#include <cstring>
#include <vector>
#include "TROOT.h"
#include "TObjArray.h"
#include "MdcCalibConst.h"

Go to the source code of this file.

Functions

double xtFun (double t, double xtpar[])
void fcnXT (Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
void fcnXtEdge (Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
Double_t xtFitFun (Double_t *x, Double_t par[])
Double_t xtFitEdge (Double_t *x, Double_t par[])
void writeConst (MdcCalibConst *calconst, TObjArray *newXtList, TObjArray *r2tList)
std::vector< std::stringgetHistList ()
std::vector< std::stringgetHistList (std::string path)

Variables

const int NLAYER = 43
const int NWIRE = 6796
const int NLR = 3
const int NXTBIN = 50
const int NXTPAR = 8
const int NENTRXT = 18
const int NENTRSD = 6
const int NSDBIN = 24
const int gfixXtC0 = 1
const double gTbinw = 10.0
std::vector< double > XMEAS
std::vector< double > TBINCEN
std::vector< double > ERR
double Tmax
double Dmax
std::vector< double > XMEASED
std::vector< double > TBINCENED
std::vector< double > ERRED
int gNEntr [43]
double gTimeShift
double gTesMin
double gTesMax
int gFgIniCalConst
bool gPreT0SetTm
double gInitT0
double gT0Shift
double gTminFitChindf
double gTmaxFitChindf
int gResiType
int gCalSigma
int gFixXtC0
int gFgCalib [NLAYER]
double gTminFitRange [NLAYER][2]
double gTmaxFitRange [NLAYER][2]
double gInitTm [NLAYER]
double gQmin [NLAYER]
double gQmax [NLAYER]


Function Documentation

void fcnXT ( Int_t &  npar,
Double_t *  gin,
Double_t &  f,
Double_t *  par,
Int_t  iflag 
)

Definition at line 66 of file fun.cpp.

References ERR, genRecEmupikp::i, TBINCEN, and XMEAS.

Referenced by XtCalib::calib().

00066                                                                                {
00067      unsigned int i;
00068      int ord;
00069      Double_t deta;
00070      Double_t chisq = 0.0;
00071      Double_t dfit;
00072 
00073      for(i=0; i<TBINCEN.size(); i++){
00074           dfit = 0;
00075           for(ord=0; ord<=5; ord++){
00076                dfit += par[ord] * pow(TBINCEN[i], ord);
00077           }
00078           deta = (dfit - XMEAS[i]) / ERR[i];
00079           chisq += deta * deta;
00080      }
00081 
00082      f = chisq;
00083 }

void fcnXtEdge ( Int_t &  npar,
Double_t *  gin,
Double_t &  f,
Double_t *  par,
Int_t  iflag 
)

Definition at line 85 of file fun.cpp.

References Dmax, ERRED, genRecEmupikp::i, TBINCENED, Tmax, and XMEASED.

Referenced by XtCalib::calib().

00085                                                                                    {
00086      unsigned int i;
00087      Double_t deta;
00088      Double_t chisq = 0.0;
00089      Double_t dfit;
00090 
00091      for(i=0; i<TBINCENED.size(); i++){
00092           dfit = par[0] * (TBINCENED[i] - Tmax) + Dmax;
00093           deta = (dfit - XMEASED[i]) / ERRED[i];
00094           chisq += deta * deta;
00095      }
00096 
00097      f = chisq;
00098 }

std::vector<std::string> getHistList ( std::string  path  ) 

std::vector<std::string> getHistList (  ) 

Definition at line 14 of file fun.cpp.

References fname, and deljobs::string.

00015 {
00016    vector<string> fnames;
00017 
00018    string command(
00019          "JobOutputDir=`/bin/ls -dt1 joboutput-* 2>/dev/null | head -1`\n"
00020          "if [ -d \"${JobOutputDir}\" ]; then\n"
00021          "  find ${JobOutputDir} -name hist.root\n"
00022          "fi\n"
00023          );
00024 
00025    stringstream fnstream;
00026 
00027    char* fnbuf   = new char[1024];
00028    FILE* fstream = popen(command.c_str(), "r");
00029 
00030    while ( fgets(fnbuf, 1024, fstream) != NULL ) {
00031       fnstream << fnbuf;
00032    }
00033 
00034    string fname;
00035    while ( ! (fnstream>>fname).eof() ) {
00036       fnames.push_back(fname);
00037    }
00038 
00039    pclose(fstream);
00040    delete [] fnbuf;
00041 
00042    if ( fnames.empty() ) {
00043       cout << "WARNING: Failed to retrieve hist files in the current directory!" << endl;
00044 //       exit(1);
00045    }
00046    return fnames;
00047 }

void writeConst ( MdcCalibConst calconst,
TObjArray *  newXtList,
TObjArray *  r2tList 
)

Definition at line 113 of file fun.cpp.

References bin, MdcCalibConst::getDelT0(), MdcCalibConst::getQtpar0(), MdcCalibConst::getQtpar1(), MdcCalibConst::getSdKey(), MdcCalibConst::getSdpar(), MdcCalibConst::getT0(), MdcCalibConst::getXtKey(), MdcCalibConst::getXtpar(), and key.

Referenced by main().

00113                                                                                   {
00114      TFile fout("MdcCalibConst_new.root", "recreate");
00115 
00116      int key;
00117      double xtpar;
00118      TTree *xttree = new TTree("XtTree", "XtTree");
00119      xttree -> Branch("xtkey", &key, "key/I");
00120      xttree -> Branch("xtpar", &xtpar, "xtpar/D");
00121      for(int lay=0; lay<43; lay++){
00122           for(int entr=0; entr<18; entr++){
00123                for(int lr=0; lr<3; lr++){
00124                     for(int ord=0; ord<8; ord++){
00125                          key = calconst->getXtKey(lay, entr, lr, ord);
00126                          xtpar = calconst->getXtpar(lay, entr, lr, ord);
00127                          xttree -> Fill();
00128                     }
00129                }
00130           }
00131      }
00132 
00133      double t0;
00134      double delt0;
00135      TTree *t0tree = new TTree("T0Tree", "T0Tree");
00136      t0tree -> Branch("t0", &t0, "t0/D");
00137      t0tree -> Branch("delt0", &delt0, "delt0/D");
00138      for(int wid=0; wid<6796; wid++){
00139           t0 = calconst->getT0(wid);
00140           delt0 = calconst->getDelT0(wid);
00141           t0tree -> Fill();
00142      }
00143 
00144      double qtval[2];
00145      TTree *qttree = new TTree("QtTree", "QtTree");
00146      qttree -> Branch("qtpar0", &(qtval[0]), "qtpar0/D");
00147      qttree -> Branch("qtpar1", &(qtval[1]), "qtpar1/D");
00148      for(int lay=0; lay<43; lay++){
00149           qtval[0] = calconst->getQtpar0(lay);
00150           qtval[1] = calconst->getQtpar1(lay);
00151           qttree -> Fill();
00152      }
00153 
00154      double sdpar;
00155      TTree *sdtree = new TTree("SdTree", "SdTree");
00156      sdtree -> Branch("sdkey", &key, "key/I");
00157      sdtree -> Branch("sdpar", &sdpar, "sdpar/D");
00158      for(int lay=0; lay<43; lay++){
00159           for(int entr=0; entr<6; entr++){
00160                for(int lr=0; lr<2; lr++){
00161                     for(int bin=0; bin<24; bin++){
00162                          key = calconst->getSdKey(lay, entr, lr, bin);
00163                          sdpar = calconst->getSdpar(lay, entr, lr, bin);
00164                          sdtree -> Fill();
00165                     }
00166                }
00167           }
00168      }
00169 
00170      fout.cd();
00171      xttree -> Write();
00172      t0tree -> Write();
00173      qttree -> Write();
00174      sdtree -> Write();
00175      if((newXtList->GetEntries()) > 0) newXtList -> Write();
00176      if((r2tList->GetEntries()) > 0) r2tList -> Write();
00177      fout.Close();
00178 }

Double_t xtFitEdge ( Double_t *  x,
Double_t  par[] 
)

Definition at line 108 of file fun.cpp.

References Dmax, and Tmax.

Referenced by GrXtCalib::calib().

00108                                                {
00109      double val = Dmax + (x[0] - Tmax) * par[0];
00110      return val;
00111 }

Double_t xtFitFun ( Double_t *  x,
Double_t  par[] 
)

Definition at line 100 of file fun.cpp.

Referenced by GrXtCalib::calib().

00100                                               {
00101      Double_t val = 0.0;
00102      for(Int_t ord=0; ord<6; ord++){
00103           val += par[ord] * pow(x[0], ord);
00104      }
00105      return val;
00106 }

double xtFun ( double  t,
double  xtpar[] 
)

Definition at line 47 of file fun.cpp.

References check_raw_filter::dist.

Referenced by XtCalib::calib().

00047                                       {
00048      int ord;
00049      double dist = 0.0;
00050      double tm = xtpar[6];
00051 
00052      if(t < tm ){
00053           for(ord=0; ord<=5; ord++){
00054                dist += xtpar[ord] * pow(t, ord);
00055           }
00056      }else{
00057           for(ord=0; ord<=5; ord++){
00058                dist += xtpar[ord] * pow(tm, ord);
00059           }
00060           dist += xtpar[7] * (t - tm);
00061      }
00062 
00063      return dist;
00064 }


Variable Documentation

double Dmax

Definition at line 20 of file fun.cpp.

Referenced by GrXtCalib::calib(), XtCalib::calib(), fcnXtEdge(), and xtFitEdge().

std::vector<double> ERR

Definition at line 18 of file fun.cpp.

Referenced by XtCalib::calib(), and fcnXT().

std::vector<double> ERRED

Definition at line 23 of file fun.cpp.

Referenced by XtCalib::calib(), and fcnXtEdge().

int gCalSigma

Definition at line 38 of file fun.cpp.

Referenced by CalibBase::calib(), and main().

int gFgCalib[NLAYER]

Definition at line 40 of file fun.cpp.

Referenced by CalibBase::calib(), GrXtCalib::calib(), IniCalib::calib(), PreT0Calib::calib(), PreXtCalib::calib(), QtCalib::calib(), XtCalib::calib(), XtInteCalib::calib(), and main().

int gFgIniCalConst

Definition at line 31 of file fun.cpp.

Referenced by IniCalib::calib(), and main().

int gFixXtC0

Definition at line 39 of file fun.cpp.

Referenced by main().

const int gfixXtC0 = 1

Definition at line 22 of file fun.h.

Referenced by XtCalib::calib(), and GrXtCalib::calib().

double gInitT0

Definition at line 33 of file fun.cpp.

Referenced by IniCalib::calib(), PreT0Calib::calib(), and main().

double gInitTm[NLAYER]

Definition at line 43 of file fun.cpp.

Referenced by IniCalib::calib(), PreT0Calib::calib(), and main().

int gNEntr[43]

Definition at line 25 of file fun.cpp.

Referenced by CalibBase::calib(), XtCalib::calib(), CalibBase::init(), XtCalib::init(), main(), CalibBase::mergeHist(), XtCalib::mergeHist(), CalibBase::renameHist(), and XtCalib::renameHist().

bool gPreT0SetTm

Definition at line 32 of file fun.cpp.

Referenced by PreT0Calib::calib(), and main().

double gQmax[NLAYER]

Definition at line 45 of file fun.cpp.

Referenced by QtCalib::init(), and main().

double gQmin[NLAYER]

Definition at line 44 of file fun.cpp.

Referenced by QtCalib::init(), and main().

int gResiType

Definition at line 37 of file fun.cpp.

Referenced by CalibBase::calib(), and main().

double gT0Shift

Definition at line 34 of file fun.cpp.

Referenced by IniCalib::calib(), PreT0Calib::calib(), and main().

const double gTbinw = 10.0

Definition at line 23 of file fun.h.

Referenced by XtCalib::calib().

double gTesMax

Definition at line 30 of file fun.cpp.

Referenced by main().

double gTesMin

Definition at line 29 of file fun.cpp.

Referenced by main().

double gTimeShift

Definition at line 28 of file fun.cpp.

Referenced by IniCalib::calib(), PreT0Calib::calib(), and main().

double gTmaxFitChindf

Definition at line 36 of file fun.cpp.

Referenced by IniCalib::calib(), PreT0Calib::calib(), and main().

double gTmaxFitRange[NLAYER][2]

Definition at line 42 of file fun.cpp.

Referenced by IniCalib::calib(), PreT0Calib::calib(), and main().

double gTminFitChindf

Definition at line 35 of file fun.cpp.

Referenced by IniCalib::calib(), PreT0Calib::calib(), and main().

double gTminFitRange[NLAYER][2]

Definition at line 41 of file fun.cpp.

Referenced by IniCalib::calib(), PreT0Calib::calib(), and main().

const int NENTRSD = 6

Definition at line 19 of file fun.h.

Referenced by IniCalib::calib().

const int NENTRXT = 18

Definition at line 18 of file fun.h.

Referenced by XtInteCalib::calib(), PreXtCalib::calib(), PreT0Calib::calib(), IniCalib::calib(), GrXtCalib::calib(), CalibBase::calib(), XtInteCalib::init(), GrXtCalib::init(), XtInteCalib::mergeHist(), GrXtCalib::mergeHist(), XtInteCalib::renameHist(), GrXtCalib::renameHist(), and XtInteCalib::saveOldXt().

const int NLAYER = 43

Definition at line 13 of file fun.h.

Referenced by XtInteCalib::calib(), QtCalib::calib(), PreXtCalib::calib(), PreT0Calib::calib(), IniCalib::calib(), GrXtCalib::calib(), CalibBase::calib(), GrXtCalib::GrXtCalib(), XtInteCalib::init(), QtCalib::init(), PreXtCalib::init(), PreT0Calib::init(), IniCalib::init(), GrXtCalib::init(), CalibBase::init(), main(), XtInteCalib::mergeHist(), QtCalib::mergeHist(), PreXtCalib::mergeHist(), PreT0Calib::mergeHist(), IniCalib::mergeHist(), GrXtCalib::mergeHist(), CalibBase::mergeHist(), XtInteCalib::renameHist(), QtCalib::renameHist(), PreXtCalib::renameHist(), PreT0Calib::renameHist(), IniCalib::renameHist(), GrXtCalib::renameHist(), CalibBase::renameHist(), XtInteCalib::saveOldXt(), and XtInteCalib::XtInteCalib().

const int NLR = 3

Definition at line 15 of file fun.h.

Referenced by XtCalib::calib(), PreXtCalib::calib(), PreT0Calib::calib(), IniCalib::calib(), GrXtCalib::calib(), XtCalib::init(), PreT0Calib::init(), GrXtCalib::init(), XtCalib::mergeHist(), PreT0Calib::mergeHist(), GrXtCalib::mergeHist(), XtCalib::renameHist(), PreT0Calib::renameHist(), and GrXtCalib::renameHist().

const int NSDBIN = 24

Definition at line 20 of file fun.h.

Referenced by IniCalib::calib(), CalibBase::calib(), CalibBase::init(), CalibBase::mergeHist(), and CalibBase::renameHist().

const int NWIRE = 6796

Definition at line 14 of file fun.h.

Referenced by T0Calib::calib(), PreT0Calib::calib(), T0Calib::init(), IniCalib::init(), T0Calib::mergeHist(), IniCalib::mergeHist(), T0Calib::renameHist(), and IniCalib::renameHist().

const int NXTBIN = 50

Definition at line 16 of file fun.h.

Referenced by XtCalib::calib(), XtCalib::init(), XtCalib::mergeHist(), and XtCalib::renameHist().

const int NXTPAR = 8

Definition at line 17 of file fun.h.

Referenced by XtCalib::calib(), and IniCalib::calib().

std::vector<double> TBINCEN

Definition at line 17 of file fun.cpp.

Referenced by XtCalib::calib(), and fcnXT().

std::vector<double> TBINCENED

Definition at line 22 of file fun.cpp.

Referenced by XtCalib::calib(), and fcnXtEdge().

double Tmax

Definition at line 19 of file fun.cpp.

Referenced by GrXtCalib::calib(), XtCalib::calib(), fcnXtEdge(), and xtFitEdge().

std::vector<double> XMEAS

Definition at line 16 of file fun.cpp.

Referenced by XtCalib::calib(), and fcnXT().

std::vector<double> XMEASED

Definition at line 21 of file fun.cpp.

Referenced by XtCalib::calib(), and fcnXtEdge().


Generated on Tue Nov 29 23:16:44 2016 for BOSS_7.0.2 by  doxygen 1.4.7