#include <iostream>
#include <sstream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstdlib>
#include "TFile.h"
#include "TTree.h"
#include "include/MdcCalibConst.h"
#include "include/fun.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) |
vector< string > | getHistList () |
vector< string > | getHistList (string path) |
Variables | |
vector< double > | XMEAS |
vector< double > | TBINCEN |
vector< double > | ERR |
double | Tmax |
double | Dmax |
vector< double > | XMEASED |
vector< double > | TBINCENED |
vector< double > | ERRED |
int | gNEntr [43] |
double | gTimeShift = 0.0 |
double | gTesMin = 0.0 |
double | gTesMax = 9999.0 |
int | gFgIniCalConst = 2 |
bool | gPreT0SetTm = true |
double | gInitT0 = 50.0 |
double | gT0Shift = 0.0 |
double | gTminFitChindf = 20.0 |
double | gTmaxFitChindf = 20.0 |
int | gResiType = 0 |
int | gCalSigma = 1 |
int | gFixXtC0 = 0 |
int | gFgCalib [NLAYER] |
double | gTminFitRange [NLAYER][2] |
double | gTmaxFitRange [NLAYER][2] |
double | gInitTm [NLAYER] |
double | gQmin [NLAYER] |
double | gQmax [NLAYER] |
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 }
Definition at line 215 of file fun.cpp.
References fname, and deljobs::string.
00216 { 00217 vector<string> fnames; 00218 string newpath = path; 00219 string::size_type strl = newpath.length(); 00220 if((strl>1) && ('/'==newpath[strl-1])) newpath.erase(strl-1); 00221 00222 char com1[500]; 00223 sprintf(com1, "JobOutputDir=`/bin/ls -dt1 %s/joboutput-* 2>/dev/null | head -1`\n", newpath.c_str()); 00224 string command1(com1); 00225 string command2( 00226 "if [ -d \"${JobOutputDir}\" ]; then\n" 00227 " find ${JobOutputDir} -name hist.root\n" 00228 "fi\n" 00229 ); 00230 string command = command1 + command2; 00231 stringstream fnstream; 00232 00233 char* fnbuf = new char[1024]; 00234 FILE* fstream = popen(command.c_str(), "r"); 00235 00236 while ( fgets(fnbuf, 1024, fstream) != NULL ) { 00237 fnstream << fnbuf; 00238 } 00239 00240 string fname; 00241 while ( ! (fnstream>>fname).eof() ) { 00242 fnames.push_back(fname); 00243 } 00244 00245 pclose(fstream); 00246 delete [] fnbuf; 00247 00248 if ( fnames.empty() ) { 00249 cout << "ERROR: Failed to retrieve hist files!" << endl; 00250 exit(1); 00251 } 00252 return fnames; 00253 }
vector<string> getHistList | ( | ) |
Definition at line 180 of file fun.cpp.
References fname, and deljobs::string.
00181 { 00182 vector<string> fnames; 00183 00184 string command( 00185 "JobOutputDir=`/bin/ls -dt1 joboutput-* 2>/dev/null | head -1`\n" 00186 "if [ -d \"${JobOutputDir}\" ]; then\n" 00187 " find ${JobOutputDir} -name hist.root\n" 00188 "fi\n" 00189 ); 00190 00191 stringstream fnstream; 00192 00193 char* fnbuf = new char[1024]; 00194 FILE* fstream = popen(command.c_str(), "r"); 00195 00196 while ( fgets(fnbuf, 1024, fstream) != NULL ) { 00197 fnstream << fnbuf; 00198 } 00199 00200 string fname; 00201 while ( ! (fnstream>>fname).eof() ) { 00202 fnames.push_back(fname); 00203 } 00204 00205 pclose(fstream); 00206 delete [] fnbuf; 00207 00208 if ( fnames.empty() ) { 00209 cout << "WARNING: Failed to retrieve hist files in the current directory!" << endl; 00210 // exit(1); 00211 } 00212 return fnames; 00213 }
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[] | |||
) |
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 }
double Dmax |
Definition at line 20 of file fun.cpp.
Referenced by XtCalib::calib(), GrXtCalib::calib(), fcnXtEdge(), and xtFitEdge().
vector<double> ERR |
vector<double> ERRED |
int gCalSigma = 1 |
Definition at line 40 of file fun.cpp.
Referenced by XtInteCalib::calib(), XtCalib::calib(), QtCalib::calib(), PreXtCalib::calib(), PreT0Calib::calib(), IniCalib::calib(), GrXtCalib::calib(), CalibBase::calib(), and main().
int gFgIniCalConst = 2 |
double gInitT0 = 50.0 |
Definition at line 33 of file fun.cpp.
Referenced by PreT0Calib::calib(), IniCalib::calib(), and main().
Definition at line 43 of file fun.cpp.
Referenced by PreT0Calib::calib(), IniCalib::calib(), and main().
int gNEntr[43] |
Definition at line 25 of file fun.cpp.
Referenced by XtCalib::calib(), CalibBase::calib(), XtCalib::init(), CalibBase::init(), main(), XtCalib::mergeHist(), CalibBase::mergeHist(), XtCalib::renameHist(), and CalibBase::renameHist().
bool gPreT0SetTm = true |
int gResiType = 0 |
double gT0Shift = 0.0 |
Definition at line 34 of file fun.cpp.
Referenced by PreT0Calib::calib(), IniCalib::calib(), and main().
double gTimeShift = 0.0 |
Definition at line 28 of file fun.cpp.
Referenced by PreT0Calib::calib(), IniCalib::calib(), and main().
double gTmaxFitChindf = 20.0 |
Definition at line 36 of file fun.cpp.
Referenced by PreT0Calib::calib(), IniCalib::calib(), and main().
double gTmaxFitRange[NLAYER][2] |
Definition at line 42 of file fun.cpp.
Referenced by PreT0Calib::calib(), IniCalib::calib(), and main().
double gTminFitChindf = 20.0 |
Definition at line 35 of file fun.cpp.
Referenced by PreT0Calib::calib(), IniCalib::calib(), and main().
double gTminFitRange[NLAYER][2] |
Definition at line 41 of file fun.cpp.
Referenced by PreT0Calib::calib(), IniCalib::calib(), and main().
vector<double> TBINCEN |
vector<double> TBINCENED |
double Tmax |
Definition at line 19 of file fun.cpp.
Referenced by XtCalib::calib(), GrXtCalib::calib(), fcnXtEdge(), and xtFitEdge().
vector<double> XMEAS |
vector<double> XMEASED |