BOSS 7.0.2
BESIII Offline Software System
Loading...
Searching...
No Matches
XtInteMdcCalib.cxx
Go to the documentation of this file.
1#include "MdcCalibAlg/XtInteMdcCalib.h"
2
3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/IMessageSvc.h"
5#include "GaudiKernel/StatusCode.h"
6#include "GaudiKernel/ISvcLocator.h"
7#include "GaudiKernel/Bootstrap.h"
8
9#include <iostream>
10#include <fstream>
11#include <iomanip>
12#include <cstring>
13#include <cmath>
14
15#include "TF1.h"
16
17using namespace std;
18
20 m_fgIni = false;
21 m_nMaxGrPoint = 5000;
22 for(int lay=0; lay<MdcCalNLayer; lay++){
23 m_tbinWid[lay][0] = 5.0;
24 m_tbinWid[lay][1] = 10.0;
25 m_tbinWid[lay][2] = 20.0;
26
27 m_tbinLim[lay][0] = -10.0;
28 m_tbinLim[lay][1] = 30.0;
29 if(lay < 8) m_tbinLim[lay][2] = 210.0;
30 else m_tbinLim[lay][2] = 350.0;
31 m_tbinLim[lay][3] = 990.0;
32 }
33}
34
36}
37
39 for(int lay=0; lay<MdcCalNLayer; lay++){
40 for(int iEntr=0; iEntr<NENTR; iEntr++){
41 for(int lr=0; lr<2; lr++){
42 delete m_pfNear[lay][iEntr][lr];
43 delete m_pfMid[lay][iEntr][lr];
44 delete m_pfFar[lay][iEntr][lr];
45 delete m_grXt[lay][iEntr][lr];
46 }
47 }
48 }
49 delete m_fdPf;
51}
52
53void XtInteMdcCalib::initialize(TObjArray* hlist, IMdcGeomSvc* mdcGeomSvc,
54 IMdcCalibFunSvc* mdcFunSvc, IMdcUtilitySvc* mdcUtilitySvc) {
55 IMessageSvc* msgSvc;
56 Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
57 MsgStream log(msgSvc, "XtInteMdcCalib");
58 log << MSG::INFO << "XtInteMdcCalib::initialize()" << endreq;
59
60 m_hlist = hlist;
61 m_mdcGeomSvc = mdcGeomSvc;
62 m_mdcFunSvc = mdcFunSvc;
63 m_mdcUtilitySvc = mdcUtilitySvc;
64
65 MdcCalib::initialize(m_hlist, m_mdcGeomSvc, m_mdcFunSvc, m_mdcUtilitySvc);
66
67 m_fdPf = new TFolder("fdProfile", "fdProfile");
68 m_hlist -> Add(m_fdPf);
69
70 char hname[200];
71 for(int lay=0; lay<MdcCalNLayer; lay++){
72 for(int iEntr=0; iEntr<NENTR; iEntr++){
73 for(int lr=0; lr<2; lr++){
74 sprintf(hname, "xt%02d_%02d_%d_gr", lay, iEntr, lr);
75 m_grXt[lay][iEntr][lr] = new TGraph();
76 m_grXt[lay][iEntr][lr]->SetName(hname);
77 m_fdPf->Add(m_grXt[lay][iEntr][lr]);
78
79 int xbinN = (int)((m_tbinLim[lay][1] - m_tbinLim[lay][0])/m_tbinWid[lay][0] + 0.5);
80 sprintf(hname, "xt%02d_%02d_%d_near", lay, iEntr, lr);
81 m_pfNear[lay][iEntr][lr] = new TProfile(hname, hname, xbinN, m_tbinLim[lay][0], m_tbinLim[lay][1]);
82 m_fdPf->Add(m_pfNear[lay][iEntr][lr]);
83
84 int xbinM = (int)((m_tbinLim[lay][2] - m_tbinLim[lay][1])/m_tbinWid[lay][1] + 0.5);
85 sprintf(hname, "xt%02d_%02d_%d_mid", lay, iEntr, lr);
86 m_pfMid[lay][iEntr][lr] = new TProfile(hname, hname, xbinM, m_tbinLim[lay][1], m_tbinLim[lay][2]);
87 m_fdPf->Add(m_pfMid[lay][iEntr][lr]);
88
89 int xbinF = (int)((m_tbinLim[lay][3] - m_tbinLim[lay][2])/m_tbinWid[lay][2] + 0.5);
90 sprintf(hname, "xt%02d_%02d_%d_far", lay, iEntr, lr);
91 m_pfFar[lay][iEntr][lr] = new TProfile(hname, hname, xbinF, m_tbinLim[lay][2], m_tbinLim[lay][3]);
92 m_fdPf->Add(m_pfFar[lay][iEntr][lr]);
93
94// if((0==iEntr)&&(0==lr))
95// cout << setw(5) << lay
96// << setw(5) << xbinN << setw(10) << m_tbinLim[lay][0] << setw(10) << m_tbinLim[lay][1]
97// << setw(5) << xbinM << setw(10) << m_tbinLim[lay][1] << setw(10) << m_tbinLim[lay][2]
98// << setw(5) << xbinF << setw(10) << m_tbinLim[lay][2] << setw(10) << m_tbinLim[lay][3] << endl;
99 }
100 }
101 }
102}
103
105 IMessageSvc* msgSvc;
106 Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
107 MsgStream log(msgSvc, "XtInteMdcCalib");
108 log << MSG::DEBUG << "XtInteMdcCalib::fillHist()" << endreq;
109
110 MdcCalib::fillHist(event);
111
112 // get EsTimeCol
113 bool esCutFg = event->getEsCutFlag();
114 if( ! esCutFg ) return -1;
115
116 int i;
117 int k;
118 int lay;
119 int iLR;
120 int iEntr;
121
122 double dr;
123 double dz;
124 double doca;
125 double tdr;
126 double resi;
127 double entrance;
128
129 int nhitlay;
130 bool fgHitLay[MdcCalNLayer];
131 bool fgTrk;
132
133 if(! m_fgIni){
134 for(lay=0; lay<MdcCalNLayer; lay++){
135 if(lay < 8) m_docaMax[lay] = m_param.maxDocaInner;
136 else m_docaMax[lay] = m_param.maxDocaOuter;
137 }
138 m_fgIni = true;
139 }
140
141 MdcCalRecTrk* rectrk;
142 MdcCalRecHit* rechit;
143
144 int nhit;
145 int ntrk = event -> getNTrk();
146 for(i=0; i<ntrk; i++){
147 fgTrk = true;
148 rectrk = event->getRecTrk(i);
149 nhit = rectrk -> getNHits();
150
151 // dr cut
152 dr = rectrk->getDr();
153 if(fabs(dr) > m_param.drCut) continue;
154
155 // dz cut
156 dz = rectrk->getDz();
157 if(fabs(dz) > m_param.dzCut) continue;
158
159 for(lay=0; lay<MdcCalNLayer; lay++){
160 fgHitLay[lay] = false;
161 }
162
163 for(k=0; k<nhit; k++){
164 rechit = rectrk -> getRecHit(k);
165 lay = rechit -> getLayid();
166 doca = rechit -> getDocaInc();
167 resi = rechit -> getResiInc();
168 fgHitLay[lay] = true;
169
170// if( (fabs(doca) > m_docaMax[lay]) ||
171// (fabs(resi) > m_param.resiCut[lay]) ){
172// fgTrk = false;
173// }
174 }
175 if(! fgTrk) continue;
176
177 nhitlay = 0;
178 for(lay=0; lay<MdcCalNLayer; lay++){
179 if(fgHitLay[lay]) nhitlay++;
180 }
181 if(nhitlay < m_param.nHitLayCut) continue;
182
183 for(k=0; k<nhit; k++){
184 rechit = rectrk -> getRecHit(k);
185 lay = rechit -> getLayid();
186 doca = rechit -> getDocaInc();
187 resi = rechit -> getResiInc();
188 iLR = rechit -> getLR();
189 entrance = rechit -> getEntra();
190 tdr = rechit -> getTdrift();
191
192 if( (fabs(doca) > m_docaMax[lay]) ||
193 (fabs(resi) > m_param.resiCut[lay]) ){
194 continue;
195 }
196
197 if(0 == lay){
198 if( ! fgHitLay[1] ) continue;
199 } else if(42 == lay){
200 if( ! fgHitLay[41] ) continue;
201 } else{
202 if( (!fgHitLay[lay-1]) && (!fgHitLay[lay+1]) ) continue;
203 }
204
205 iEntr = m_mdcFunSvc -> getXtEntrIndex(entrance);
206 int npoint = m_grXt[lay][iEntr][iLR]->GetN();
207 if(npoint < m_nMaxGrPoint) m_grXt[lay][iEntr][iLR]->SetPoint(npoint, tdr, fabs(doca));
208
209 if(tdr<m_tbinLim[lay][0]) continue;
210 else if(tdr<m_tbinLim[lay][1]) m_pfNear[lay][iEntr][iLR]->Fill(tdr, fabs(doca));
211 else if(tdr<m_tbinLim[lay][2]) m_pfMid[lay][iEntr][iLR]->Fill(tdr, fabs(doca));
212 else if(tdr<m_tbinLim[lay][3]) m_pfFar[lay][iEntr][iLR]->Fill(tdr, fabs(doca));
213 } // hit loop
214 } // track loop
215 return 1;
216}
217
219 IMessageSvc* msgSvc;
220 Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
221 MsgStream log(msgSvc, "XtInteMdcCalib");
222 log << MSG::INFO << "XtInteMdcCalib::updateConst()" << endreq;
223
224 MdcCalib::updateConst(calconst);
225}
226
virtual void clear()=0
Definition: MdcCalib.cxx:76
virtual void initialize(TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)=0
Definition: MdcCalib.cxx:202
virtual int updateConst(MdcCalibConst *calconst)=0
Definition: MdcCalib.cxx:1322
virtual int fillHist(MdcCalEvent *event)=0
Definition: MdcCalib.cxx:692
void initialize(TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)
int updateConst(MdcCalibConst *calconst)
int fillHist(MdcCalEvent *event)