2#include "include/fun.h"
12 for(
int lay=0; lay<
NLAYER; lay++){
13 if(lay<8) m_tEd[lay] = 200.0;
14 else m_tEd[lay] = 300.0;
16 cout <<
"Calibration type: GrXtCalib" << endl;
25 m_fdXt =
new TFolder(
"mfdxt",
"fdxt");
28 m_haxis =
new TH2F(
"axis",
"", 50, 0, 300, 50, 0, 9);
29 m_haxis -> SetStats(0);
30 m_fdXt ->
Add(m_haxis);
33 for(
int lay=0; lay<
NLAYER; lay++){
34 for(
int iEntr=0; iEntr<
NENTRXT; iEntr++){
35 for(
int lr=0; lr<
NLR; lr++){
36 m_nhitIn[lay][iEntr][lr] = 0;
37 m_nhitEd[lay][iEntr][lr] = 0;
39 sprintf(hname,
"mgrXt%02d_%02d_lr%01d", lay, iEntr, lr);
40 m_grxt[lay][iEntr][lr] =
new TGraph();
41 m_grxt[lay][iEntr][lr] -> SetName(hname);
44 m_fdXt ->
Add(m_grxt[lay][iEntr][lr]);
55 TFolder* fd = (TFolder*)fhist->Get(
"fdXtGr");
56 for(
int lay=0; lay<
NLAYER; lay++){
57 for(
int iEntr=0; iEntr<
NENTRXT; iEntr++){
58 for(
int lr=0; lr<
NLR; lr++){
59 if((m_nhitIn[lay][iEntr][lr] > m_maxNhit) && (m_nhitEd[lay][iEntr][lr] > m_nMaxEd))
continue;
61 sprintf(hname,
"grXt%02d_%02d_lr%01d", lay, iEntr, lr);
62 TGraph*
gr = (TGraph*)fd->FindObjectAny(hname);
63 int nPoint =
gr->GetN();
64 for(
int i=0; i<nPoint; i++){
65 gr->GetPoint(i, tdr, doca);
66 if((tdr < m_tEd[lay]) && (m_nhitIn[lay][iEntr][lr] <= m_maxNhit)){
67 int np = m_grxt[lay][iEntr][lr]->GetN();
68 m_grxt[lay][iEntr][lr]->SetPoint(np, tdr, doca);
69 m_nhitIn[lay][iEntr][lr]++;
70 }
else if((tdr >= m_tEd[lay]) && (m_nhitEd[lay][iEntr][lr] <= m_nMaxEd)){
71 int np = m_grxt[lay][iEntr][lr]->GetN();
72 m_grxt[lay][iEntr][lr]->SetPoint(np, tdr, doca);
73 m_nhitEd[lay][iEntr][lr]++;
86 TF1* fxtDr =
new TF1(
"fxtDr",
xtFitFun, 0, 300, 6);
87 TF1* fxtEd =
new TF1(
"fxtEd",
xtFitEdge, 150, 500, 1);
88 if(1 ==
gfixXtC0) fxtDr -> FixParameter(0, 0);
90 for(
int lay=0; lay<
NLAYER; lay++){
91 for(
int iEntr=0; iEntr<
NENTRXT; iEntr++){
92 for(
int lr=0; lr<
NLR; lr++){
93 m_fgFit[lay][iEntr][lr] =
false;
96 if(m_nhitIn[lay][iEntr][lr] > 1000){
97 Tmax = calconst -> getXtpar(lay, iEntr, lr, 6);
99 m_grxt[lay][iEntr][lr] ->
Fit(
"fxtDr",
"Q+",
"", 0,
Tmax);
100 for(ord=0; ord<6; ord++){
101 xtpar[lay][iEntr][lr][ord] = fxtDr->GetParameter(ord);
103 xtpar[lay][iEntr][lr][6] =
Tmax;
106 for(ord=0; ord<6; ord++)
Dmax += xtpar[lay][iEntr][lr][ord] * pow(
Tmax, ord);
108 if(m_nhitEd[lay][iEntr][lr] > 300){
109 m_grxt[lay][iEntr][lr] ->
Fit(
"fxtEd",
"Q+",
"",
Tmax,
Tmax+300);
110 xtpar[lay][iEntr][lr][7] = fxtEd->GetParameter(0);
111 if(xtpar[lay][iEntr][lr][7] < 0.0) xtpar[lay][iEntr][lr][7] = 0.0;
113 xtpar[lay][iEntr][lr][7] = 0.0;
116 m_fgFit[lay][iEntr][lr] =
true;
123 ofstream fxtlog(
"xtlog");
124 for(
int lay=0; lay<
NLAYER; lay++){
125 for(
int iEntr=0; iEntr<
NENTRXT; iEntr++){
126 for(
int lr=0; lr<
NLR; lr++){
127 fxtlog << setw(3) << lay << setw(3) << iEntr << setw(3) << lr;
130 if(m_fgFit[lay][iEntr][lr]){
132 for(ord=0; ord<8; ord++) calconst->
resetXtpar(lay, iEntr, lr, ord, xtpar[lay][iEntr][lr][ord]);
134 int iEntrNew = findXtEntr(lay, iEntr, lr);
137 for(ord=0; ord<8; ord++){
138 calconst->
resetXtpar(lay, iEntr, lr, ord, xtpar[lay][iEntrNew][lr][ord]);
142 fxtlog << setw(3) << fgUpdate;
143 for(ord=0; ord<8; ord++){
144 double par = calconst -> getXtpar(lay, iEntr, lr, ord);
145 if(6==ord) fxtlog << setw(9) << par;
146 else fxtlog << setw(14) << par;
154 cout <<
"Xt update finished. File xtlog was written." << endl;
161void GrXtCalib::renameHist(){
163 m_fdXt->SetName(
"fdXtGr");
164 for(
int lay=0; lay<
NLAYER; lay++){
165 for(
int iEntr=0; iEntr<
NENTRXT; iEntr++){
166 for(
int lr=0; lr<
NLR; lr++){
167 sprintf(hname,
"grXt%02d_%02d_lr%01d", lay, iEntr, lr);
168 m_grxt[lay][iEntr][lr] -> SetName(hname);
174int GrXtCalib::findXtEntr(
int lay,
int iEntr,
int lr)
const {
181 for(
int i=iEntr; i<=id0; i++){
182 if(m_fgFit[lay][i][lr]){
187 if(-1 !=
id) entrId = id;
189 for(
int i=iEntr; i>=0; i--){
190 if(m_fgFit[lay][i][lr]){
199 for(
int i=iEntr; i>=id1; i--){
200 if(m_fgFit[lay][i][lr]){
205 if(-1 !=
id) entrId = id;
207 for(
int i=iEntr; i<idmax; i++){
208 if(m_fgFit[lay][i][lr]){
217 cout <<
"find EntrId error " <<
"layer " << lay <<
" iEntr " << iEntr <<
" lr " << lr << endl;
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)
Double_t xtFitEdge(Double_t *x, Double_t par[])
Double_t xtFitFun(Double_t *x, Double_t par[])
virtual void init(TObjArray *hlist, MdcCosGeom *pGeom)=0
virtual void mergeHist(TFile *fhist)=0
virtual void calib(MdcCalibConst *calconst, TObjArray *newXtList, TObjArray *r2tList)=0
void calib(MdcCalibConst *calconst, TObjArray *newXtList, TObjArray *r2tList)
void init(TObjArray *hlist, MdcCosGeom *pGeom)
void mergeHist(TFile *fhist)
void resetXtpar(int lay, int entr, int lr, int order, double val)