BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
fun.cpp File Reference
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <vector>
#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 65 of file MdcCalibAlg/share/distcalib/src/fun.cpp.

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

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 83 of file MdcCalibAlg/share/distcalib/src/fun.cpp.

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

Referenced by XtCalib::calib().

◆ getHistList() [1/2]

vector< string > getHistList ( )

Definition at line 187 of file MdcCalibAlg/share/distcalib/src/fun.cpp.

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

◆ getHistList() [2/2]

vector< string > getHistList ( string path)

Definition at line 216 of file MdcCalibAlg/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",
224 newpath.c_str() );
225 string command1( com1 );
226 string command2( "if [ -d \"${JobOutputDir}\" ]; then\n"
227 " find ${JobOutputDir} -name hist.root\n"
228 "fi\n" );
229 string command = command1 + command2;
230 stringstream fnstream;
231
232 char* fnbuf = new char[1024];
233 FILE* fstream = popen( command.c_str(), "r" );
234
235 while ( fgets( fnbuf, 1024, fstream ) != NULL ) { fnstream << fnbuf; }
236
237 string fname;
238 while ( !( fnstream >> fname ).eof() ) { fnames.push_back( fname ); }
239
240 pclose( fstream );
241 delete[] fnbuf;
242
243 if ( fnames.empty() )
244 {
245 cout << "ERROR: Failed to retrieve hist files!" << endl;
246 exit( 1 );
247 }
248 return fnames;
249}
sprintf(cut, "kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_" "pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)

◆ writeConst()

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

Definition at line 110 of file MdcCalibAlg/share/distcalib/src/fun.cpp.

110 {
111 TFile fout( "MdcCalibConst_new.root", "recreate" );
112
113 int key;
114 double xtpar;
115 TTree* xttree = new TTree( "XtTree", "XtTree" );
116 xttree->Branch( "xtkey", &key, "key/I" );
117 xttree->Branch( "xtpar", &xtpar, "xtpar/D" );
118 for ( int lay = 0; lay < 43; lay++ )
119 {
120 for ( int entr = 0; entr < 18; entr++ )
121 {
122 for ( int lr = 0; lr < 3; lr++ )
123 {
124 for ( int ord = 0; ord < 8; ord++ )
125 {
126 key = calconst->getXtKey( lay, entr, lr, ord );
127 xtpar = calconst->getXtpar( lay, entr, lr, ord );
128 xttree->Fill();
129 }
130 }
131 }
132 }
133
134 double t0;
135 double delt0;
136 TTree* t0tree = new TTree( "T0Tree", "T0Tree" );
137 t0tree->Branch( "t0", &t0, "t0/D" );
138 t0tree->Branch( "delt0", &delt0, "delt0/D" );
139 for ( int wid = 0; wid < 6796; wid++ )
140 {
141 t0 = calconst->getT0( wid );
142 delt0 = calconst->getDelT0( wid );
143 t0tree->Fill();
144 }
145
146 double qtval[2];
147 TTree* qttree = new TTree( "QtTree", "QtTree" );
148 qttree->Branch( "qtpar0", &( qtval[0] ), "qtpar0/D" );
149 qttree->Branch( "qtpar1", &( qtval[1] ), "qtpar1/D" );
150 for ( int lay = 0; lay < 43; lay++ )
151 {
152 qtval[0] = calconst->getQtpar0( lay );
153 qtval[1] = calconst->getQtpar1( lay );
154 qttree->Fill();
155 }
156
157 double sdpar;
158 TTree* sdtree = new TTree( "SdTree", "SdTree" );
159 sdtree->Branch( "sdkey", &key, "key/I" );
160 sdtree->Branch( "sdpar", &sdpar, "sdpar/D" );
161 for ( int lay = 0; lay < 43; lay++ )
162 {
163 for ( int entr = 0; entr < 6; entr++ )
164 {
165 for ( int lr = 0; lr < 2; lr++ )
166 {
167 for ( int bin = 0; bin < 24; bin++ )
168 {
169 key = calconst->getSdKey( lay, entr, lr, bin );
170 sdpar = calconst->getSdpar( lay, entr, lr, bin );
171 sdtree->Fill();
172 }
173 }
174 }
175 }
176
177 fout.cd();
178 xttree->Write();
179 t0tree->Write();
180 qttree->Write();
181 sdtree->Write();
182 if ( ( newXtList->GetEntries() ) > 0 ) newXtList->Write();
183 if ( ( r2tList->GetEntries() ) > 0 ) r2tList->Write();
184 fout.Close();
185}
*******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 105 of file MdcCalibAlg/share/distcalib/src/fun.cpp.

105 {
106 double val = Dmax + ( x[0] - Tmax ) * par[0];
107 return val;
108}

Referenced by GrXtCalib::calib().

◆ xtFitFun()

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

Definition at line 99 of file MdcCalibAlg/share/distcalib/src/fun.cpp.

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

Referenced by GrXtCalib::calib().

◆ xtFun()

double xtFun ( double t,
double xtpar[] )

Definition at line 47 of file MdcCalibAlg/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 {
54 for ( ord = 0; ord <= 5; ord++ ) { dist += xtpar[ord] * pow( t, ord ); }
55 }
56 else
57 {
58 for ( ord = 0; ord <= 5; ord++ ) { dist += xtpar[ord] * pow( tm, ord ); }
59 dist += xtpar[7] * ( t - tm );
60 }
61
62 return dist;
63}
int t()
Definition t.c:1

Referenced by XtCalib::calib().

Variable Documentation

◆ Dmax

double Dmax

◆ ERR

vector<double> ERR

Definition at line 18 of file MdcCalibAlg/share/distcalib/src/fun.cpp.

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

◆ ERRED

vector<double> ERRED

Definition at line 23 of file MdcCalibAlg/share/distcalib/src/fun.cpp.

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

◆ gCalSigma

int gCalSigma = 1

Definition at line 38 of file MdcCalibAlg/share/distcalib/src/fun.cpp.

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

◆ gFgCalib

◆ gFgIniCalConst

int gFgIniCalConst = 2

Definition at line 31 of file MdcCalibAlg/share/distcalib/src/fun.cpp.

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

◆ gFixXtC0

int gFixXtC0 = 0

Definition at line 39 of file MdcCalibAlg/share/distcalib/src/fun.cpp.

Referenced by main().

◆ gInitT0

double gInitT0 = 50.0

◆ gInitTm

double gInitTm[NLAYER]

◆ gNEntr

◆ gPreT0SetTm

bool gPreT0SetTm = true

Definition at line 32 of file MdcCalibAlg/share/distcalib/src/fun.cpp.

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

◆ gQmax

double gQmax[NLAYER]

Definition at line 45 of file MdcCalibAlg/share/distcalib/src/fun.cpp.

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

◆ gQmin

double gQmin[NLAYER]

Definition at line 44 of file MdcCalibAlg/share/distcalib/src/fun.cpp.

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

◆ gResiType

int gResiType = 0

Definition at line 37 of file MdcCalibAlg/share/distcalib/src/fun.cpp.

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

◆ gT0Shift

double gT0Shift = 0.0

◆ gTesMax

double gTesMax = 9999.0

Definition at line 30 of file MdcCalibAlg/share/distcalib/src/fun.cpp.

Referenced by main().

◆ gTesMin

double gTesMin = 0.0

Definition at line 29 of file MdcCalibAlg/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

Definition at line 17 of file MdcCalibAlg/share/distcalib/src/fun.cpp.

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

◆ TBINCENED

vector<double> TBINCENED

Definition at line 22 of file MdcCalibAlg/share/distcalib/src/fun.cpp.

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

◆ Tmax

double Tmax

◆ XMEAS

vector<double> XMEAS

Definition at line 16 of file MdcCalibAlg/share/distcalib/src/fun.cpp.

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

◆ XMEASED

vector<double> XMEASED

Definition at line 21 of file MdcCalibAlg/share/distcalib/src/fun.cpp.

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