BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
GrXtMdcCalib Class Reference

#include <GrXtMdcCalib.h>

+ Inheritance diagram for GrXtMdcCalib:

Public Member Functions

 GrXtMdcCalib ()
 
 ~GrXtMdcCalib ()
 
void initialize (TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)
 
void setParam (MdcCalParams &param)
 
int fillHist (MdcCalEvent *event)
 
int updateConst (MdcCalibConst *calconst)
 
void printCut () const
 
void clear ()
 
int findXtEntr (int lay, int iEntr, int lr) const
 
- Public Member Functions inherited from MdcCalib
 MdcCalib ()
 
virtual ~MdcCalib ()
 

Static Public Member Functions

static Double_t xtfun (Double_t *x, Double_t *par)
 
static Double_t xtedge (Double_t *x, Double_t *par)
 

Detailed Description

Definition at line 12 of file GrXtMdcCalib.h.

Constructor & Destructor Documentation

◆ GrXtMdcCalib()

GrXtMdcCalib::GrXtMdcCalib ( )

Definition at line 22 of file GrXtMdcCalib.cxx.

22 {
23 m_maxNhit = 5000;
24 m_fgIni = false;
25}

◆ ~GrXtMdcCalib()

GrXtMdcCalib::~GrXtMdcCalib ( )

Definition at line 27 of file GrXtMdcCalib.cxx.

27 {
28}

Member Function Documentation

◆ clear()

void GrXtMdcCalib::clear ( )
virtual

Implements MdcCalib.

Definition at line 30 of file GrXtMdcCalib.cxx.

30 {
31 cout << "~GrXtMdcCalib" << endl;
32 for(int lay=0; lay<MdcCalNLayer; lay++){
33 for(int iEntr=0; iEntr<MdcCalNENTRXT; iEntr++){
34 for(int iLR=0; iLR<MdcCalLR; iLR++){
35 delete m_grxt[lay][iEntr][iLR];
36 }
37 }
38 }
39 delete m_haxis;
40 delete m_fdXt;
41
43}
const int MdcCalNLayer
Definition MdcCalParams.h:6
const int MdcCalNENTRXT
const int MdcCalLR
virtual void clear()=0
Definition MdcCalib.cxx:80

◆ fillHist()

int GrXtMdcCalib::fillHist ( MdcCalEvent * event)
virtual

Implements MdcCalib.

Definition at line 87 of file GrXtMdcCalib.cxx.

87 {
88 IMessageSvc* msgSvc;
89 Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
90 MsgStream log(msgSvc, "GrXtMdcCalib");
91 log << MSG::DEBUG << "GrXtMdcCalib::fillHist()" << endreq;
92
93 MdcCalib::fillHist(event);
94
95 // get EsTimeCol
96 bool esCutFg = event->getEsCutFlag();
97 if( ! esCutFg ) return -1;
98
99 int i;
100 int k;
101 int lay;
102 int iLR;
103 int iEntr;
104
105 double dr;
106 double dz;
107 double doca;
108 double tdr;
109 double resi;
110 double entrance;
111
112 int nhitlay;
113 bool fgHitLay[MdcCalNLayer];
114 bool fgTrk;
115
116 if(! m_fgIni){
117 for(lay=0; lay<MdcCalNLayer; lay++){
118 if(lay < 8) m_docaMax[lay] = m_param.maxDocaInner;
119 else m_docaMax[lay] = m_param.maxDocaOuter;
120 }
121 m_fgIni = true;
122 }
123
124 MdcCalRecTrk* rectrk;
125 MdcCalRecHit* rechit;
126
127 int nhit;
128 int ntrk = event -> getNTrk();
129 for(i=0; i<ntrk; i++){
130 fgTrk = true;
131 rectrk = event->getRecTrk(i);
132 nhit = rectrk -> getNHits();
133
134 // dr cut
135 dr = rectrk->getDr();
136 if(fabs(dr) > m_param.drCut) continue;
137
138 // dz cut
139 dz = rectrk->getDz();
140 if(fabs(dz) > m_param.dzCut) continue;
141
142 for(lay=0; lay<MdcCalNLayer; lay++){
143 fgHitLay[lay] = false;
144 }
145
146 for(k=0; k<nhit; k++){
147 rechit = rectrk -> getRecHit(k);
148 lay = rechit -> getLayid();
149 doca = rechit -> getDocaInc();
150 resi = rechit -> getResiInc();
151 fgHitLay[lay] = true;
152
153// if( (fabs(doca) > m_docaMax[lay]) ||
154// (fabs(resi) > m_param.resiCut[lay]) ){
155// fgTrk = false;
156// }
157 }
158 if(! fgTrk) continue;
159
160 nhitlay = 0;
161 for(lay=0; lay<MdcCalNLayer; lay++){
162 if(fgHitLay[lay]) nhitlay++;
163 }
164 if(nhitlay < m_param.nHitLayCut) continue;
165
166 for(k=0; k<nhit; k++){
167 rechit = rectrk -> getRecHit(k);
168 lay = rechit -> getLayid();
169 doca = rechit -> getDocaInc();
170 resi = rechit -> getResiInc();
171 iLR = rechit -> getLR();
172 entrance = rechit -> getEntra();
173 tdr = rechit -> getTdrift();
174
175 if( (fabs(doca) > m_docaMax[lay]) ||
176 (fabs(resi) > m_param.resiCut[lay]) ){
177 continue;
178 }
179
180 if(0 == lay){
181 if( ! fgHitLay[1] ) continue;
182 } else if(42 == lay){
183 if( ! fgHitLay[41] ) continue;
184 } else{
185 if( (!fgHitLay[lay-1]) && (!fgHitLay[lay+1]) ) continue;
186 }
187
188 iEntr = m_mdcFunSvc -> getXtEntrIndex(entrance);
189
190 if(iLR < 2){
191 if(m_nhit[lay][iEntr][iLR] < m_maxNhit){
192 m_grxt[lay][iEntr][iLR] -> SetPoint(m_nhit[lay][iEntr][iLR],
193 tdr, fabs(doca));
194 m_nhit[lay][iEntr][iLR]++;
195 }
196 }
197
198 if(m_nhit[lay][iEntr][2] < m_maxNhit){
199 m_grxt[lay][iEntr][2] -> SetPoint(m_nhit[lay][iEntr][2],
200 tdr, fabs(doca));
201 m_nhit[lay][iEntr][2]++;
202 }
203 } // hit loop
204 } // track loop
205 return 1;
206}
IMessageSvc * msgSvc()
double maxDocaOuter
double maxDocaInner
double resiCut[MdcCalNLayer]
double getDz() const
double getDr() const
virtual int fillHist(MdcCalEvent *event)=0
Definition MdcCalib.cxx:730

◆ findXtEntr()

int GrXtMdcCalib::findXtEntr ( int lay,
int iEntr,
int lr ) const

Definition at line 307 of file GrXtMdcCalib.cxx.

307 {
308 int id0 = 8;
309 int id1 = 9;
310 int idmax = 17;
311 int entrId = -1;
312 if(iEntr <= id0){
313 int id = -1;
314 for(int i=iEntr; i<=id0; i++){
315 if(m_fgFit[lay][i][lr]){
316 id = i;
317 break;
318 }
319 }
320 if(-1 != id) entrId = id;
321 else{
322 for(int i=iEntr; i>=0; i--){
323 if(m_fgFit[lay][i][lr]){
324 id = i;
325 break;
326 }
327 }
328 entrId = id;
329 }
330 } else{
331 int id = -1;
332 for(int i=iEntr; i>=id1; i--){
333 if(m_fgFit[lay][i][lr]){
334 id = i;
335 break;
336 }
337 }
338 if(-1 != id) entrId = id;
339 else{
340 for(int i=iEntr; i<idmax; i++){
341 if(m_fgFit[lay][i][lr]){
342 id = i;
343 break;
344 }
345 }
346 entrId = id;
347 }
348 }
349 if(-1 == entrId){
350 cout << "find EntrId error " << "layer " << lay << " iEntr " << iEntr << " lr " << lr << endl;
351 }
352
353 return entrId;
354}

Referenced by updateConst().

◆ initialize()

void GrXtMdcCalib::initialize ( TObjArray * hlist,
IMdcGeomSvc * mdcGeomSvc,
IMdcCalibFunSvc * mdcFunSvc,
IMdcUtilitySvc * mdcUtilitySvc )
virtual

Implements MdcCalib.

Definition at line 45 of file GrXtMdcCalib.cxx.

46 {
47 IMessageSvc* msgSvc;
48 Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
49 MsgStream log(msgSvc, "GrXtMdcCalib");
50 log << MSG::INFO << "GrXtMdcCalib::initialize()" << endreq;
51
52 m_hlist = hlist;
53 m_mdcGeomSvc = mdcGeomSvc;
54 m_mdcFunSvc = mdcFunSvc;
55 m_mdcUtilitySvc = mdcUtilitySvc;
56
57 MdcCalib::initialize(m_hlist, m_mdcGeomSvc, m_mdcFunSvc, m_mdcUtilitySvc);
58
59 int lay;
60 int iLR;
61 int iEntr;
62 char hname[200];
63
64 m_fdXt = new TFolder("fdXtGr", "fdXtGr");
65 m_hlist -> Add(m_fdXt);
66
67 m_haxis = new TH2F("axis", "", 50, 0, 300, 50, 0, 9);
68 m_haxis -> SetStats(0);
69 m_fdXt -> Add(m_haxis);
70
71 for(lay=0; lay<MdcCalNLayer; lay++){
72 for(iEntr=0; iEntr<MdcCalNENTRXT; iEntr++){
73 for(iLR=0; iLR<MdcCalLR; iLR++){
74 m_nhit[lay][iEntr][iLR] = 0;
75
76 sprintf(hname, "grXt%02d_%02d_lr%01d", lay, iEntr, iLR);
77 m_grxt[lay][iEntr][iLR] = new TGraph();
78 m_grxt[lay][iEntr][iLR] -> SetName(hname);
79 m_grxt[lay][iEntr][iLR] -> SetMarkerStyle(10);
80 m_grxt[lay][iEntr][iLR] -> SetLineColor(10);
81 m_fdXt -> Add(m_grxt[lay][iEntr][iLR]);
82 }
83 }
84 }
85}
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)
gr1 SetLineColor(1)
gr1 SetMarkerStyle(8)
mg Add(gr3)
virtual void initialize(TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)=0
Definition MdcCalib.cxx:214

◆ printCut()

void GrXtMdcCalib::printCut ( ) const
virtual

Implements MdcCalib.

Definition at line 208 of file GrXtMdcCalib.cxx.

208 {
210}
virtual void printCut() const =0

◆ setParam()

void GrXtMdcCalib::setParam ( MdcCalParams & param)
inlinevirtual

Implements MdcCalib.

Definition at line 53 of file GrXtMdcCalib.h.

53 {
54 MdcCalib::setParam(param);
55 m_param = param;
56}
virtual void setParam(MdcCalParams &param)=0
Definition MdcCalib.h:306

◆ updateConst()

int GrXtMdcCalib::updateConst ( MdcCalibConst * calconst)
virtual

Implements MdcCalib.

Definition at line 212 of file GrXtMdcCalib.cxx.

212 {
213 IMessageSvc* msgSvc;
214 Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
215 MsgStream log(msgSvc, "GrXtMdcCalib");
216 log << MSG::INFO << "GrXtMdcCalib::updateConst()" << endreq;
217
218 MdcCalib::updateConst(calconst);
219
220 int ord;
221 double xtpar[MdcCalNLayer][MdcCalNENTRXT][MdcCalLR][8];
222 TF1* fxtDr = new TF1("fxtDr", xtfun, 0, 300, 6);
223 TF1* fxtEd = new TF1("fxtEd", xtedge, 150, 500, 1);
224 if(1 == m_param.fixXtC0) fxtDr -> FixParameter(0, 0);
225
226 for(int lay=0; lay<MdcCalNLayer; lay++){
227 for(int iEntr=0; iEntr<MdcCalNENTRXT; iEntr++){
228 for(int lr=0; lr<MdcCalLR; lr++){
229 m_fgFit[lay][iEntr][lr] = false;
230 if(0 == m_param.fgCalib[lay]) continue;
231
232 if(m_nhit[lay][iEntr][lr] > 1000){
233 TMAX = calconst -> getXtpar(lay, iEntr, lr, 6);
234
235 m_grxt[lay][iEntr][lr] -> Fit("fxtDr", "Q+", "", 0, TMAX);
236
237 for(ord=0; ord<6; ord++){
238 xtpar[lay][iEntr][lr][ord] = fxtDr->GetParameter(ord);
239 }
240 xtpar[lay][iEntr][lr][6] = TMAX;
241
242 DMAX = 0.0;
243 for(ord=0; ord<6; ord++) DMAX += xtpar[lay][iEntr][lr][ord] * pow(TMAX, ord);
244
245 m_grxt[lay][iEntr][lr] -> Fit("fxtEd", "Q+", "", TMAX, TMAX+300);
246 xtpar[lay][iEntr][lr][7] = fxtEd->GetParameter(0);
247 if(xtpar[lay][iEntr][lr][7] < 0.0) xtpar[lay][iEntr][lr][7] = 0.0;
248 m_fgFit[lay][iEntr][lr] = true;
249
250// for(ord=0; ord<8; ord++){
251// calconst -> resetXtpar(lay, iEntr, lr, ord, xtpar[ord]);
252// }
253 }
254
255 } // end of lr loop
256 } // end of entrance angle loop
257 } // end of layer loop
258
259 ofstream fxtlog("xtlog");
260 for(int lay=0; lay<MdcCalNLayer; lay++){
261 for(int iEntr=0; iEntr<MdcCalNENTRXT; iEntr++){
262 for(int lr=0; lr<MdcCalLR; lr++){
263 fxtlog << setw(3) << lay << setw(3) << iEntr << setw(3) << lr;
264
265 int fgUpdate = -1;
266 if(m_fgFit[lay][iEntr][lr]){
267 fgUpdate = 1;
268 for(ord=0; ord<8; ord++) calconst->resetXtpar(lay, iEntr, lr, ord, xtpar[lay][iEntr][lr][ord]);
269 } else{
270 int iEntrNew = findXtEntr(lay, iEntr, lr);
271 if(-1 != iEntrNew){
272 fgUpdate = 2;
273 for(ord=0; ord<8; ord++){
274 calconst->resetXtpar(lay, iEntr, lr, ord, xtpar[lay][iEntrNew][lr][ord]);
275 }
276 }
277 }
278 fxtlog << setw(3) << fgUpdate;
279 for(ord=0; ord<8; ord++){
280 double par = calconst -> getXtpar(lay, iEntr, lr, ord);
281 fxtlog << setw(14) << par;
282 }
283 fxtlog << endl;
284 }
285 }
286 }
287 fxtlog.close();
288
289 cout << "Xt update finished. File xtlog was written." << endl;
290 delete fxtDr;
291 delete fxtEd;
292}
void Fit()
int findXtEntr(int lay, int iEntr, int lr) const
static Double_t xtedge(Double_t *x, Double_t *par)
static Double_t xtfun(Double_t *x, Double_t *par)
int fgCalib[MdcCalNLayer]
void resetXtpar(int lay, int entr, int lr, int order, double val)
virtual int updateConst(MdcCalibConst *calconst)=0

◆ xtedge()

Double_t GrXtMdcCalib::xtedge ( Double_t * x,
Double_t * par )
static

Definition at line 302 of file GrXtMdcCalib.cxx.

302 {
303 double val = DMAX + (x[0] - TMAX) * par[0];
304 return val;
305}
Double_t x[10]

Referenced by updateConst().

◆ xtfun()

Double_t GrXtMdcCalib::xtfun ( Double_t * x,
Double_t * par )
static

Definition at line 294 of file GrXtMdcCalib.cxx.

294 {
295 Double_t val = 0.0;
296 for(Int_t ord=0; ord<6; ord++){
297 val += par[ord] * pow(x[0], ord);
298 }
299 return val;
300}

Referenced by updateConst().


The documentation for this class was generated from the following files: