CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcCalibAlg/MdcCalibAlg-00-09-02/share/distcalib/src/fun.cpp File Reference
#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]
 

Function Documentation

◆ fcnXT()

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

Definition at line 66 of file MdcCalibAlg/MdcCalibAlg-00-09-02/share/distcalib/src/fun.cpp.

66 {
67 unsigned int i;
68 int ord;
69 Double_t deta;
70 Double_t chisq = 0.0;
71 Double_t dfit;
72
73 for(i=0; i<TBINCEN.size(); i++){
74 dfit = 0;
75 for(ord=0; ord<=5; ord++){
76 dfit += par[ord] * pow(TBINCEN[i], ord);
77 }
78 deta = (dfit - XMEAS[i]) / ERR[i];
79 chisq += deta * deta;
80 }
81
82 f = chisq;
83}

Referenced by XtCalib::calib().

◆ fcnXtEdge()

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

Definition at line 85 of file MdcCalibAlg/MdcCalibAlg-00-09-02/share/distcalib/src/fun.cpp.

85 {
86 unsigned int i;
87 Double_t deta;
88 Double_t chisq = 0.0;
89 Double_t dfit;
90
91 for(i=0; i<TBINCENED.size(); i++){
92 dfit = par[0] * (TBINCENED[i] - Tmax) + Dmax;
93 deta = (dfit - XMEASED[i]) / ERRED[i];
94 chisq += deta * deta;
95 }
96
97 f = chisq;
98}

Referenced by XtCalib::calib().

◆ getHistList() [1/2]

vector< string > getHistList ( )

Definition at line 180 of file MdcCalibAlg/MdcCalibAlg-00-09-02/share/distcalib/src/fun.cpp.

181{
182 vector<string> fnames;
183
184 string command(
185 "JobOutputDir=`/bin/ls -dt1 joboutput-* 2>/dev/null | head -1`\n"
186 "if [ -d \"${JobOutputDir}\" ]; then\n"
187 " find ${JobOutputDir} -name hist.root\n"
188 "fi\n"
189 );
190
191 stringstream fnstream;
192
193 char* fnbuf = new char[1024];
194 FILE* fstream = popen(command.c_str(), "r");
195
196 while ( fgets(fnbuf, 1024, fstream) != NULL ) {
197 fnstream << fnbuf;
198 }
199
200 string fname;
201 while ( ! (fnstream>>fname).eof() ) {
202 fnames.push_back(fname);
203 }
204
205 pclose(fstream);
206 delete [] fnbuf;
207
208 if ( fnames.empty() ) {
209 cout << "WARNING: Failed to retrieve hist files in the current directory!" << endl;
210// exit(1);
211 }
212 return fnames;
213}

◆ getHistList() [2/2]

vector< string > getHistList ( string  path)

Definition at line 215 of file MdcCalibAlg/MdcCalibAlg-00-09-02/share/distcalib/src/fun.cpp.

216{
217 vector<string> fnames;
218 string newpath = path;
219 string::size_type strl = newpath.length();
220 if((strl>1) && ('/'==newpath[strl-1])) newpath.erase(strl-1);
221
222 char com1[500];
223 sprintf(com1, "JobOutputDir=`/bin/ls -dt1 %s/joboutput-* 2>/dev/null | head -1`\n", newpath.c_str());
224 string command1(com1);
225 string command2(
226 "if [ -d \"${JobOutputDir}\" ]; then\n"
227 " find ${JobOutputDir} -name hist.root\n"
228 "fi\n"
229 );
230 string command = command1 + command2;
231 stringstream fnstream;
232
233 char* fnbuf = new char[1024];
234 FILE* fstream = popen(command.c_str(), "r");
235
236 while ( fgets(fnbuf, 1024, fstream) != NULL ) {
237 fnstream << fnbuf;
238 }
239
240 string fname;
241 while ( ! (fnstream>>fname).eof() ) {
242 fnames.push_back(fname);
243 }
244
245 pclose(fstream);
246 delete [] fnbuf;
247
248 if ( fnames.empty() ) {
249 cout << "ERROR: Failed to retrieve hist files!" << endl;
250 exit(1);
251 }
252 return fnames;
253}

◆ writeConst()

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

Definition at line 113 of file MdcCalibAlg/MdcCalibAlg-00-09-02/share/distcalib/src/fun.cpp.

113 {
114 TFile fout("MdcCalibConst_new.root", "recreate");
115
116 int key;
117 double xtpar;
118 TTree *xttree = new TTree("XtTree", "XtTree");
119 xttree -> Branch("xtkey", &key, "key/I");
120 xttree -> Branch("xtpar", &xtpar, "xtpar/D");
121 for(int lay=0; lay<43; lay++){
122 for(int entr=0; entr<18; entr++){
123 for(int lr=0; lr<3; lr++){
124 for(int ord=0; ord<8; ord++){
125 key = calconst->getXtKey(lay, entr, lr, ord);
126 xtpar = calconst->getXtpar(lay, entr, lr, ord);
127 xttree -> Fill();
128 }
129 }
130 }
131 }
132
133 double t0;
134 double delt0;
135 TTree *t0tree = new TTree("T0Tree", "T0Tree");
136 t0tree -> Branch("t0", &t0, "t0/D");
137 t0tree -> Branch("delt0", &delt0, "delt0/D");
138 for(int wid=0; wid<6796; wid++){
139 t0 = calconst->getT0(wid);
140 delt0 = calconst->getDelT0(wid);
141 t0tree -> Fill();
142 }
143
144 double qtval[2];
145 TTree *qttree = new TTree("QtTree", "QtTree");
146 qttree -> Branch("qtpar0", &(qtval[0]), "qtpar0/D");
147 qttree -> Branch("qtpar1", &(qtval[1]), "qtpar1/D");
148 for(int lay=0; lay<43; lay++){
149 qtval[0] = calconst->getQtpar0(lay);
150 qtval[1] = calconst->getQtpar1(lay);
151 qttree -> Fill();
152 }
153
154 double sdpar;
155 TTree *sdtree = new TTree("SdTree", "SdTree");
156 sdtree -> Branch("sdkey", &key, "key/I");
157 sdtree -> Branch("sdpar", &sdpar, "sdpar/D");
158 for(int lay=0; lay<43; lay++){
159 for(int entr=0; entr<6; entr++){
160 for(int lr=0; lr<2; lr++){
161 for(int bin=0; bin<24; bin++){
162 key = calconst->getSdKey(lay, entr, lr, bin);
163 sdpar = calconst->getSdpar(lay, entr, lr, bin);
164 sdtree -> Fill();
165 }
166 }
167 }
168 }
169
170 fout.cd();
171 xttree -> Write();
172 t0tree -> Write();
173 qttree -> Write();
174 sdtree -> Write();
175 if((newXtList->GetEntries()) > 0) newXtList -> Write();
176 if((r2tList->GetEntries()) > 0) r2tList -> Write();
177 fout.Close();
178}
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per bin
Definition: FoamA.h:85
*************DOUBLE PRECISION m_pi *DOUBLE PRECISION m_HvecTau2 DOUBLE PRECISION m_HvClone2 DOUBLE PRECISION m_gamma1 DOUBLE PRECISION m_gamma2 DOUBLE PRECISION m_thet1 DOUBLE PRECISION m_thet2 INTEGER m_IFPHOT *COMMON c_Taupair $ !Spin Polarimeter vector first Tau $ !Spin Polarimeter vector second Tau $ !Clone Spin Polarimeter vector first Tau $ !Clone Spin Polarimeter vector second Tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !phi of HvecTau1 $ !theta of HvecTau1 $ !phi of HvecTau2 $ !theta of HvecTau2 $ !super key
Definition: Taupair.h:42
int getXtKey(int lay, int entr, int lr, int order) const
double getT0(int wireid) const
double getXtpar(int lay, int entr, int lr, int order)
double getSdpar(int lay, int entr, int lr, int bin)
int getSdKey(int lay, int entr, int lr, int bin) const
double getDelT0(int wireid) const
double getQtpar1(int lay) const
double getQtpar0(int lay) const

Referenced by main().

◆ xtFitEdge()

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

Definition at line 108 of file MdcCalibAlg/MdcCalibAlg-00-09-02/share/distcalib/src/fun.cpp.

108 {
109 double val = Dmax + (x[0] - Tmax) * par[0];
110 return val;
111}
Double_t x[10]

Referenced by GrXtCalib::calib().

◆ xtFitFun()

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

Definition at line 100 of file MdcCalibAlg/MdcCalibAlg-00-09-02/share/distcalib/src/fun.cpp.

100 {
101 Double_t val = 0.0;
102 for(Int_t ord=0; ord<6; ord++){
103 val += par[ord] * pow(x[0], ord);
104 }
105 return val;
106}

Referenced by GrXtCalib::calib().

◆ xtFun()

double xtFun ( double  t,
double  xtpar[] 
)

Definition at line 47 of file MdcCalibAlg/MdcCalibAlg-00-09-02/share/distcalib/src/fun.cpp.

47 {
48 int ord;
49 double dist = 0.0;
50 double tm = xtpar[6];
51
52 if(t < tm ){
53 for(ord=0; ord<=5; ord++){
54 dist += xtpar[ord] * pow(t, ord);
55 }
56 }else{
57 for(ord=0; ord<=5; ord++){
58 dist += xtpar[ord] * pow(tm, ord);
59 }
60 dist += xtpar[7] * (t - tm);
61 }
62
63 return dist;
64}
int t()
Definition: t.c:1

Referenced by XtCalib::calib().

Variable Documentation

◆ Dmax

◆ ERR

vector<double> ERR

◆ ERRED

vector<double> ERRED

◆ gCalSigma

int gCalSigma = 1

◆ gFgCalib

◆ gFgIniCalConst

int gFgIniCalConst = 2

◆ gFixXtC0

int gFixXtC0 = 0

Definition at line 39 of file MdcCalibAlg/MdcCalibAlg-00-09-02/share/distcalib/src/fun.cpp.

Referenced by main().

◆ gInitT0

double gInitT0 = 50.0

◆ gInitTm

◆ gNEntr

◆ gPreT0SetTm

bool gPreT0SetTm = true

◆ gQmax

double gQmax[NLAYER]

◆ gQmin

double gQmin[NLAYER]

◆ gResiType

int gResiType = 0

◆ gT0Shift

double gT0Shift = 0.0

◆ gTesMax

double gTesMax = 9999.0

Definition at line 30 of file MdcCalibAlg/MdcCalibAlg-00-09-02/share/distcalib/src/fun.cpp.

Referenced by main().

◆ gTesMin

double gTesMin = 0.0

Definition at line 29 of file MdcCalibAlg/MdcCalibAlg-00-09-02/share/distcalib/src/fun.cpp.

Referenced by main().

◆ gTimeShift

double gTimeShift = 0.0

◆ gTmaxFitChindf

double gTmaxFitChindf = 20.0

◆ gTmaxFitRange

double gTmaxFitRange[NLAYER][2]

◆ gTminFitChindf

double gTminFitChindf = 20.0

◆ gTminFitRange

double gTminFitRange[NLAYER][2]

◆ TBINCEN

vector<double> TBINCEN

◆ TBINCENED

vector<double> TBINCENED

◆ Tmax

◆ XMEAS

vector<double> XMEAS

◆ XMEASED

vector<double> XMEASED