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