BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
XtInteMdcCalib.cxx
Go to the documentation of this file.
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 // momentum cut
160 double p = rectrk -> getP();
161 if((fabs(p) < m_param.pCut[0]) || (fabs(p) > m_param.pCut[1])) continue;
162
163 // select cosmic track with y<0
164 double phi0 = rectrk -> getPhi0();
165 double phiTrk = phi0 + CLHEP::halfpi;
166 if(phiTrk > CLHEP::twopi) phiTrk -= CLHEP::twopi;
167 if(m_param.cosmicDwTrk && (phiTrk<CLHEP::pi)) continue;
168// cout << "cosmicDwTrk " << m_param.cosmicDwTrk << setw(15) << phiTrk*180./3.14 << endl;
169
170 for(lay=0; lay<MdcCalNLayer; lay++){
171 fgHitLay[lay] = false;
172 }
173
174 for(k=0; k<nhit; k++){
175 rechit = rectrk -> getRecHit(k);
176 lay = rechit -> getLayid();
177 doca = rechit -> getDocaInc();
178 resi = rechit -> getResiInc();
179 fgHitLay[lay] = true;
180
181// if( (fabs(doca) > m_docaMax[lay]) ||
182// (fabs(resi) > m_param.resiCut[lay]) ){
183// fgTrk = false;
184// }
185 }
186 if(! fgTrk) continue;
187
188 nhitlay = 0;
189 for(lay=0; lay<MdcCalNLayer; lay++){
190 if(fgHitLay[lay]) nhitlay++;
191 }
192 if(nhitlay < m_param.nHitLayCut) continue;
193
194 for(k=0; k<nhit; k++){
195 rechit = rectrk -> getRecHit(k);
196 lay = rechit -> getLayid();
197 doca = rechit -> getDocaInc();
198 resi = rechit -> getResiInc();
199 iLR = rechit -> getLR();
200 entrance = rechit -> getEntra();
201 tdr = rechit -> getTdrift();
202
203 if( (fabs(doca) > m_docaMax[lay]) ||
204 (fabs(resi) > m_param.resiCut[lay]) ){
205 continue;
206 }
207
208 if(0 == lay){
209 if( ! fgHitLay[1] ) continue;
210 } else if(42 == lay){
211 if( ! fgHitLay[41] ) continue;
212 } else{
213 if( (!fgHitLay[lay-1]) && (!fgHitLay[lay+1]) ) continue;
214 }
215
216 int nPM = 1;
217 if(m_param.fgCombinePlusMinue) nPM = 2;
218 for(int iPM=0; iPM<nPM; iPM++){
219 if(0==iPM) iEntr = m_mdcFunSvc -> getXtEntrIndex(entrance);
220 else iEntr = m_mdcFunSvc -> getXtEntrIndex(-1.0*entrance);
221
222 int npoint = m_grXt[lay][iEntr][iLR]->GetN();
223 if(npoint < m_nMaxGrPoint) m_grXt[lay][iEntr][iLR]->SetPoint(npoint, tdr, fabs(doca));
224
225 if(tdr<m_tbinLim[lay][0]) continue;
226 else if(tdr<m_tbinLim[lay][1]) m_pfNear[lay][iEntr][iLR]->Fill(tdr, fabs(doca));
227 else if(tdr<m_tbinLim[lay][2]) m_pfMid[lay][iEntr][iLR]->Fill(tdr, fabs(doca));
228 else if(tdr<m_tbinLim[lay][3]) m_pfFar[lay][iEntr][iLR]->Fill(tdr, fabs(doca));
229 }
230 } // hit loop
231 } // track loop
232 return 1;
233}
234
237}
238
240 IMessageSvc* msgSvc;
241 Gaudi::svcLocator() -> service("MessageSvc", msgSvc);
242 MsgStream log(msgSvc, "XtInteMdcCalib");
243 log << MSG::INFO << "XtInteMdcCalib::updateConst()" << endreq;
244
245 MdcCalib::updateConst(calconst);
246}
247
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)
mg Add(gr3)
const int MdcCalNLayer
Definition: MdcCalParams.h:6
IMessageSvc * msgSvc()
bool cosmicDwTrk
Definition: MdcCalParams.h:71
double maxDocaOuter
Definition: MdcCalParams.h:77
double pCut[2]
Definition: MdcCalParams.h:75
double maxDocaInner
Definition: MdcCalParams.h:76
bool fgCombinePlusMinue
Definition: MdcCalParams.h:61
double dzCut
Definition: MdcCalParams.h:74
double drCut
Definition: MdcCalParams.h:73
double resiCut[MdcCalNLayer]
Definition: MdcCalParams.h:84
double getDz() const
Definition: MdcCalRecTrk.h:33
double getDr() const
Definition: MdcCalRecTrk.h:30
virtual void printCut() const =0
Definition: MdcCalib.cxx:1407
virtual void clear()=0
Definition: MdcCalib.cxx:80
virtual void initialize(TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)=0
Definition: MdcCalib.cxx:214
virtual int updateConst(MdcCalibConst *calconst)=0
Definition: MdcCalib.cxx:1417
virtual int fillHist(MdcCalEvent *event)=0
Definition: MdcCalib.cxx:730
void printCut() const
void initialize(TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)
int updateConst(MdcCalibConst *calconst)
int fillHist(MdcCalEvent *event)