BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
T0MdcCalib.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 <cstring>
10#include <iomanip>
11#include <iostream>
12
14 for ( int lay = 0; lay < MdcCalNLayer; lay++ )
15 {
16 if ( lay < 8 )
17 {
18 m_docaMin[lay] = 1.2; // mm
19 m_docaMax[lay] = 4.8; // mm
20 }
21 else
22 {
23 m_docaMin[lay] = 1.6; // mm
24 m_docaMax[lay] = 6.4; // mm
25 }
26 }
27}
28
30
32 for ( int i = 0; i < MdcCalTotCell; i++ )
33 {
34 delete m_hleft[i];
35 delete m_hright[i];
36 }
37 delete m_hLrResiSum;
38 delete m_hLrResiSub;
39 delete m_fdT0;
40 delete m_fdResiWire;
41
43}
44
45void T0MdcCalib::initialize( TObjArray* hlist, IMdcGeomSvc* mdcGeomSvc,
46 IMdcCalibFunSvc* mdcFunSvc, IMdcUtilitySvc* mdcUtilitySvc ) {
47 IMessageSvc* msgSvc;
48 Gaudi::svcLocator()->service( "MessageSvc", msgSvc );
49 MsgStream log( msgSvc, "T0MdcCalib" );
50 log << MSG::INFO << "T0MdcCalib::initialize()" << endmsg;
51
52 m_hlist = hlist;
53 m_mdcGeomSvc = mdcGeomSvc;
54 m_mdcFunSvc = mdcFunSvc;
55 m_mdcUtilitySvc = mdcUtilitySvc;
56
57 m_vdr = 0.03;
58
59 MdcCalib::initialize( m_hlist, m_mdcGeomSvc, m_mdcFunSvc, m_mdcUtilitySvc );
60
61 int i;
62 int nwire;
63 int lay;
64 int cel;
65 char hname[200];
66
67 m_fdT0 = new TFolder( "fdT0", "fdT0" );
68 m_hlist->Add( m_fdT0 );
69
70 m_fdResiWire = new TFolder( "ResiWire", "ResiWire" );
71 m_hlist->Add( m_fdResiWire );
72
73 nwire = m_mdcGeomSvc->getWireSize();
74 for ( i = 0; i < nwire; i++ )
75 {
76 lay = m_mdcGeomSvc->Wire( i )->Layer();
77 cel = m_mdcGeomSvc->Wire( i )->Cell();
78
79 sprintf( hname, "Resi%04d_Lay%02d_Cell%03d_L", i, lay, cel );
80 m_hleft[i] = new TH1F( hname, "", 400, -2.0, 2.0 );
81 m_fdT0->Add( m_hleft[i] );
82
83 sprintf( hname, "Resi%04d_Lay%02d_Cell%03d_R", i, lay, cel );
84 m_hright[i] = new TH1F( hname, "", 400, -2.0, 2.0 );
85 m_fdT0->Add( m_hright[i] );
86 }
87
88 m_hLrResiSum = new TH1F( "LrResiSum", "", 200, -0.5, 0.5 );
89 m_fdResiWire->Add( m_hLrResiSum );
90
91 m_hLrResiSub = new TH1F( "LrResiSub", "", 200, -0.5, 0.5 );
92 m_fdResiWire->Add( m_hLrResiSub );
93}
94
96 IMessageSvc* msgSvc;
97 Gaudi::svcLocator()->service( "MessageSvc", msgSvc );
98 MsgStream log( msgSvc, "T0MdcCalib" );
99 log << MSG::DEBUG << "T0MdcCalib::fillHist()" << endmsg;
100
101 MdcCalib::fillHist( event );
102
103 // get EsTimeCol
104 bool esCutFg = event->getEsCutFlag();
105 if ( !esCutFg ) return -1;
106
107 int i;
108 int k;
109 int ntrk;
110 int nhit;
111 int stat;
112
113 int lay;
114 int cel;
115 int wir;
116 int lr;
117 double dmeas;
118 double doca;
119 double resi;
120
121 bool fgHitLay[MdcCalNLayer];
122
123 MdcCalRecTrk* rectrk;
124 MdcCalRecHit* rechit;
125
126 ntrk = event->getNTrk();
127 if ( ( ntrk < m_param.nTrkCut[0] ) || ( ntrk > m_param.nTrkCut[1] ) ) return -1;
128
129 for ( i = 0; i < ntrk; i++ )
130 {
131 rectrk = event->getRecTrk( i );
132 nhit = rectrk->getNHits();
133
134 // dr cut
135 double dr = rectrk->getDr();
136 if ( fabs( dr ) > m_param.drCut ) continue;
137
138 // dz cut
139 double dz = rectrk->getDz();
140 if ( fabs( dz ) > m_param.dzCut ) continue;
141
142 // momentum cut
143 double p = rectrk->getP();
144 if ( ( fabs( p ) < m_param.pCut[0] ) || ( fabs( p ) > m_param.pCut[1] ) ) continue;
145
146 for ( lay = 0; lay < MdcCalNLayer; lay++ ) fgHitLay[lay] = false;
147 for ( k = 0; k < nhit; k++ )
148 {
149 rechit = rectrk->getRecHit( k );
150 lay = rechit->getLayid();
151 fgHitLay[lay] = true;
152 }
153
154 int nhitlay = 0;
155 for ( lay = 0; lay < MdcCalNLayer; lay++ )
156 if ( fgHitLay[lay] ) nhitlay++;
157 if ( nhitlay < m_param.nHitLayCut ) continue;
158
159 bool fgNoise = rectrk->getFgNoiseRatio();
160 if ( m_param.noiseCut && ( !fgNoise ) ) continue;
161
162 // log << MSG::DEBUG << "nhits: " << nhit << endmsg;
163 for ( k = 0; k < nhit; k++ )
164 {
165 rechit = rectrk->getRecHit( k );
166 lay = rechit->getLayid();
167 cel = rechit->getCellid();
168 wir = m_mdcGeomSvc->Wire( lay, cel )->Id();
169 lr = rechit->getLR();
170 doca = rechit->getDocaExc();
171 dmeas = rechit->getDmeas();
172 resi = rechit->getResiExc();
173 stat = rechit->getStat();
174
175 if ( 1 != stat ) continue;
176
177 if ( ( fabs( doca ) < m_docaMin[lay] ) || ( fabs( doca ) > m_docaMax[lay] ) ||
178 ( fabs( resi ) > m_param.resiCut[lay] ) )
179 { continue; }
180
181 if ( 0 == lay )
182 {
183 if ( !fgHitLay[1] ) continue;
184 }
185 else if ( 42 == lay )
186 {
187 if ( !fgHitLay[41] ) continue;
188 }
189 else
190 {
191 if ( ( !fgHitLay[lay - 1] ) && ( !fgHitLay[lay + 1] ) ) continue;
192 }
193
194 if ( wir < ( m_mdcGeomSvc->getWireSize() ) )
195 {
196 if ( 0 == lr ) { m_hleft[wir]->Fill( resi ); }
197 else if ( 1 == lr ) { m_hright[wir]->Fill( resi ); }
198 }
199 else { std::cout << "wireid: " << wir << std::endl; }
200 }
201 }
202 return 1;
203}
204
206
208 IMessageSvc* msgSvc;
209 Gaudi::svcLocator()->service( "MessageSvc", msgSvc );
210 MsgStream log( msgSvc, "T0MdcCalib" );
211 log << MSG::INFO << "T0MdcCalib::updateConst()" << endmsg;
212
213 MdcCalib::updateConst( calconst );
214
215 int i;
216 int lay;
217 int nwire;
218 double t0;
219 double delt0;
220 double resiLrSum;
221 double resiLrSub;
222
223 Stat_t entry_l;
224 double mean_l;
225 // double gmean_l; // mean of fit with the gaussian distribution
226 // double sigma_l;
227 // double rms_l;
228
229 Stat_t entry_r;
230 double mean_r;
231 // double gmean_r;
232 // double sigma_r;
233 // double rms_r;
234
235 nwire = m_mdcGeomSvc->getWireSize();
236 std::cout << "totwire: " << nwire << std::endl;
237 for ( i = 0; i < nwire; i++ )
238 {
239 lay = m_mdcGeomSvc->Wire( i )->Layer();
240
241 if ( 1 == m_param.fgCalib[lay] )
242 {
243 entry_l = m_hleft[i]->GetEntries();
244 mean_l = m_hleft[i]->GetMean();
245 // m_hleft[i] -> Fit("gaus", "Q");
246 // gmean_l = m_hleft[i] -> GetFunction("gaus") -> GetParameter(1);
247
248 entry_r = m_hright[i]->GetEntries();
249 mean_r = m_hright[i]->GetMean();
250 // m_hright[i] -> Fit("gaus", "Q");
251 // gmean_r = m_hright[i] -> GetFunction("gaus") -> GetParameter(1);
252
253 delt0 = 0.5 * ( mean_l + mean_r ) / m_vdr;
254 }
255 else { delt0 = 0.0; }
256 if ( 0 == m_param.fgWireCal[i] ) delt0 = 0.0;
257
258 resiLrSum = 0.5 * ( mean_l + mean_r );
259 resiLrSub = 0.5 * ( mean_l - mean_r );
260 m_hLrResiSum->Fill( resiLrSum );
261 m_hLrResiSub->Fill( resiLrSub );
262
263 t0 = calconst->getT0( i );
264 t0 += delt0;
265
266 calconst->resetT0( i, t0 );
267 calconst->resetDelT0( i, delt0 );
268 }
269 return 1;
270}
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
const int MdcCalTotCell
Definition MdcCalParams.h:9
IMessageSvc * msgSvc()
double getDocaExc() const
double getDmeas() const
int getCellid() const
int getLayid() const
double getResiExc() const
int getLR() const
int getStat() const
MdcCalRecHit * getRecHit(int index) const
double getP() const
double getDz() const
int getNHits() const
bool getFgNoiseRatio() const
double getDr() const
double getT0(int wireid) const
void resetDelT0(int wireid, double val)
void resetT0(int wireid, double val)
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
int fillHist(MdcCalEvent *event)
void clear()
void initialize(TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)
int updateConst(MdcCalibConst *calconst)
void printCut() const