CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
PreXtCalib.cpp
Go to the documentation of this file.
2#include "include/fun.h"
3#include <math.h>
4
5#include "TF1.h"
6#include "TStyle.h"
7
9 cout << "Calibration type: PreXtCalib" << endl;
10}
11
14
15void PreXtCalib::init(TObjArray* hlist, MdcCosGeom* pGeom){
16 m_pGeom = pGeom;
17
18 double twid = 10.0; // ns
19 for(int bin=0; bin<NPreXtBin; bin++) m_tbin[bin] = (double)(bin+1) * twid;
20
21 m_fdPreXt = new TFolder("mPreXt", "PreXt");
22 hlist->Add(m_fdPreXt);
23
24 m_fdNhit = new TFolder("mXtNhit", "XtNhit");
25 hlist->Add(m_fdNhit);
26
27 m_haxis = new TH2F("maxis", "", 50, 0, 300, 50, 0, 9);
28 m_haxis -> SetStats(0);
29 m_fdPreXt -> Add(m_haxis);
30
31 m_nhitTot = new TH1F("mnhitTot", "", 43, -0.5, 42.5);
32 m_fdNhit -> Add(m_nhitTot);
33
34 char hname[200];
35 for(int lay=0; lay<NLAYER; lay++){
36 sprintf(hname, "mtrec%02d", lay);
37 m_htrec[lay] = new TH1F(hname, "", 310, -20, 600);
38 m_fdPreXt -> Add(m_htrec[lay]);
39
40 sprintf(hname, "mnhitBin%02d", lay);
41 m_nhitBin[lay] = new TH1F(hname, "", 40, 5.0, 405.0);
42 m_fdNhit -> Add(m_nhitBin[lay]);
43 }
44}
45
46void PreXtCalib::mergeHist(TFile* fhist){
47 TFolder* fdPreXt = (TFolder*)fhist->Get("PreXt");
48 TFolder* fdNhit = (TFolder*)fhist->Get("XtNhit");
49
50 char hname[200];
51 TH1F* hist;
52 for(int lay=0; lay<NLAYER; lay++){
53 sprintf(hname, "trec%02d", lay);
54 hist = (TH1F*)fdPreXt->FindObjectAny(hname);
55 m_htrec[lay]->Add(hist);
56
57 sprintf(hname, "nhitBin%02d", lay);
58 hist = (TH1F*)fdNhit->FindObjectAny(hname);
59 m_nhitBin[lay]->Add(hist);
60 }
61
62 hist = (TH1F*)fdNhit->FindObjectAny("nhitTot");
63 m_nhitTot->Add(hist);
64}
65
66void PreXtCalib::calib(MdcCalibConst* calconst, TObjArray* newXtList, TObjArray* r2tList){
67 double pi = 3.141592653;
68 double dist[NPreXtBin];
69 double xtpar[6];
70 char hname[200];
71
72 TF1* funXt = new TF1("funXt", xtfun, 0, 300, 6);
73 funXt -> FixParameter(0, 0.0);
74 funXt -> SetParameter(1, 0.03);
75 funXt -> SetParameter(2, 0.0);
76 funXt -> SetParameter(3, 0.0);
77 funXt -> SetParameter(4, 0.0);
78 funXt -> SetParameter(5, 0.0);
79
80 ofstream fxtlog("preXtpar.dat");
81 for(int lay=0; lay<NLAYER; lay++){
82 sprintf(hname, "mgrPreXt%02d", lay);
83 m_grXt[lay] = new TGraph();
84 m_grXt[lay] -> SetName(hname);
85 m_grXt[lay] -> SetMarkerStyle(20);
86 m_fdPreXt -> Add(m_grXt[lay]);
87
88 double layRad = m_pGeom -> getLayer(lay) -> getLayerRad();
89 int ncel = m_pGeom -> getLayer(lay) -> getNcell();
90 double dm = pi * layRad / (double)ncel;
91 Double_t nTot = m_nhitTot->GetBinContent(lay+1);
92 double tm = calconst->getXtpar(lay, 0, 0, 6);
93
94 fxtlog << "layer " << lay << endl;
95 for(int bin=0; bin<NPreXtBin; bin++){
96 Double_t nhitBin = m_nhitBin[lay]->GetBinContent(bin+1);
97 dist[bin] = dm * nhitBin / nTot;
98 m_grXt[lay] -> SetPoint(bin, m_tbin[bin], dist[bin]);
99 fxtlog << setw(4) << bin << setw(15) << m_tbin[bin]
100 << setw(15) << dist[bin] << setw(15) << dm
101 << setw(10) << nhitBin
102 << setw(10) << nTot << endl;
103
104 if(m_tbin[bin] >= tm) break;
105 }
106
107 if(1 == gFgCalib[lay]){
108 m_grXt[lay] -> Fit(funXt, "Q", "", 0.0, tm);
109 for(int ord=0; ord<6; ord++) xtpar[ord] = funXt -> GetParameter(ord);
110
111 for(int iEntr=0; iEntr<NENTRXT; iEntr++){
112 for(int iLR=0; iLR<NLR; iLR++){
113 for(int ord=0; ord<6; ord++){
114 calconst -> resetXtpar(lay, iEntr, iLR, ord, xtpar[ord]);
115 }
116 }
117 }
118 } else{
119 for(int ord=0; ord<6; ord++) xtpar[ord] = calconst->getXtpar(lay, 0, 0, ord);
120 }
121
122 for(int ord=0; ord<6; ord++) fxtlog << setw(14) << xtpar[ord];
123 fxtlog << setw(10) << tm << " 0" << endl;
124 } // end of layer loop
125 fxtlog.close();
126 cout << "preXt.dat was written." << endl;
127
128 renameHist();
129 delete funXt;
130}
131
132Double_t PreXtCalib::xtfun(Double_t *x, Double_t *par){
133 Double_t val = 0.0;
134 for(Int_t ord=0; ord<6; ord++){
135 val += par[ord] * pow(x[0], ord);
136 }
137 return val;
138}
139
140void PreXtCalib::renameHist(){
141 m_fdPreXt->SetName("PreXt");
142 m_fdNhit->SetName("XtNhit");
143 m_haxis->SetName("axis");
144 m_nhitTot->SetName("nhitTot");
145
146 char hname[200];
147 for(int lay=0; lay<NLAYER; lay++){
148 sprintf(hname, "trec%02d", lay);
149 m_htrec[lay]->SetName(hname);
150
151 sprintf(hname, "nhitBin%02d", lay);
152 m_nhitBin[lay]->SetName(hname);
153
154 sprintf(hname, "grPreXt%02d", lay);
155 m_grXt[lay] -> SetName(hname);
156 }
157}
gr SetMarkerStyle(21)
gr Fit("g1","R")
*******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 getXtpar(int lay, int entr, int lr, int order)
void calib(MdcCalibConst *calconst, TObjArray *newXtList, TObjArray *r2tList)
void init(TObjArray *hlist, MdcCosGeom *pGeom)
void mergeHist(TFile *fhist)
const float pi
Definition vector3.h:133