BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Wr2dMdcCalib Class Reference

#include <Wr2dMdcCalib.h>

Inheritance diagram for Wr2dMdcCalib:

Public Member Functions

 Wr2dMdcCalib ()
 ~Wr2dMdcCalib ()
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 ()
Public Member Functions inherited from MdcCalib
 MdcCalib ()
virtual ~MdcCalib ()

Static Public Member Functions

static void fcnWireParab (Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)

Static Public Attributes

static bool fgBIN [MdcCalWrNBin]
static double xBIN [MdcCalWrNBin]
static double yBIN [MdcCalWrNBin]
static double zBIN [MdcCalWrNBin]
static double zBINERR [MdcCalWrNBin]
static double zMIN
static double zMAX

Detailed Description

Definition at line 6 of file Wr2dMdcCalib.h.

Constructor & Destructor Documentation

◆ Wr2dMdcCalib()

Wr2dMdcCalib::Wr2dMdcCalib ( )

Definition at line 27 of file Wr2dMdcCalib.cxx.

27{}

◆ ~Wr2dMdcCalib()

Wr2dMdcCalib::~Wr2dMdcCalib ( )

Definition at line 29 of file Wr2dMdcCalib.cxx.

29{}

Member Function Documentation

◆ clear()

void Wr2dMdcCalib::clear ( )
virtual

Implements MdcCalib.

Definition at line 31 of file Wr2dMdcCalib.cxx.

31 {
32 int bin;
33 for ( int i = 0; i < MdcCalTotCell; i++ )
34 {
35 for ( bin = 0; bin < MdcCalWrNBin; bin++ )
36 {
37 delete m_hl[i][bin];
38 delete m_hr[i][bin];
39 }
40 }
41 delete m_fdWire;
42
44}
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per bin
Definition FoamA.h:85
const int MdcCalTotCell
Definition MdcCalParams.h:9
const int MdcCalWrNBin
virtual void clear()=0
Definition MdcCalib.cxx:83

◆ fcnWireParab()

void Wr2dMdcCalib::fcnWireParab ( Int_t & npar,
Double_t * gin,
Double_t & f,
Double_t * par,
Int_t iflag )
static

Definition at line 371 of file Wr2dMdcCalib.cxx.

372 {
373 Int_t bin;
374 Double_t xfit;
375 Double_t yfit;
376
377 double a = 9.47e-06 / ( 2 * par[4] );
378 double dx = par[0] - par[2];
379 double dy = par[1] - par[3];
380 double dz = zMAX - zMIN;
381 double length = sqrt( dx * dx + dz * dz );
382
383 Double_t chisq = 0.0;
384 Double_t deta;
385
386 for ( bin = 0; bin < MdcCalWrNBin; bin++ )
387 {
388 if ( fgBIN[bin] )
389 {
390 xfit = ( par[0] - par[2] ) * ( zBIN[bin] - zMIN ) / ( zMAX - zMIN ) + par[2];
391 yfit = a * zBIN[bin] * zBIN[bin] + ( par[1] - par[3] ) * zBIN[bin] / length +
392 0.5 * ( par[1] + par[3] ) - a * length * length / 4.0;
393
394 deta = ( ( xfit - xBIN[bin] ) * ( xfit - xBIN[bin] ) +
395 ( yfit - yBIN[bin] ) * ( yfit - yBIN[bin] ) ) /
396 ( zBINERR[bin] * zBINERR[bin] );
397 chisq += deta;
398 }
399 }
400 f = chisq;
401}
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
static double zBIN[MdcCalWrNBin]
static double xBIN[MdcCalWrNBin]
static double zBINERR[MdcCalWrNBin]
static bool fgBIN[MdcCalWrNBin]
static double yBIN[MdcCalWrNBin]
static double zMAX
static double zMIN

Referenced by updateConst().

◆ fillHist()

int Wr2dMdcCalib::fillHist ( MdcCalEvent * event)
virtual

Implements MdcCalib.

Definition at line 97 of file Wr2dMdcCalib.cxx.

97 {
98 IMessageSvc* msgSvc;
99 Gaudi::svcLocator()->service( "MessageSvc", msgSvc );
100 MsgStream log( msgSvc, "Wr2dMdcCalib" );
101 log << MSG::DEBUG << "Wr2dMdcCalib::fillHist()" << endmsg;
102
103 MdcCalib::fillHist( event );
104
105 // get EsTimeCol
106 bool esCutFg = event->getEsCutFlag();
107 if ( !esCutFg ) return -1;
108
109 int i;
110 int k;
111 int ntrk;
112 int nhit;
113
114 int bin;
115 int lay;
116 int cel;
117 int wir;
118 int lr;
119 double dmeas;
120 double doca;
121 double residual;
122 double zhit;
123
124 MdcCalRecTrk* rectrk;
125 MdcCalRecHit* rechit;
126
127 ntrk = event->getNTrk();
128 log << MSG::DEBUG << "number of tracks: " << ntrk << endmsg;
129
130 for ( i = 0; i < ntrk; i++ )
131 {
132 rectrk = event->getRecTrk( i );
133 nhit = rectrk->getNHits();
134
135 log << MSG::DEBUG << "number of hits: " << nhit << endmsg;
136 for ( k = 0; k < nhit; k++ )
137 {
138 rechit = rectrk->getRecHit( k );
139 lay = rechit->getLayid();
140 cel = rechit->getCellid();
141 wir = m_mdcGeomSvc->Wire( lay, cel )->Id();
142 lr = rechit->getLR();
143 doca = rechit->getDocaInc();
144 dmeas = rechit->getDmeas();
145 residual = rechit->getResiInc();
146 zhit = rechit->getZhit();
147
148 if ( ( wir < MdcCalTotCell ) && ( fabs( zhit ) < m_zeast[lay] ) )
149 {
150 bin = (int)( zhit / m_zwid[lay] );
151 if ( 0 == lr ) { m_hl[wir][bin]->Fill( residual ); }
152 else if ( 1 == lr ) { m_hr[wir][bin]->Fill( residual ); }
153 }
154 else { std::cout << "wir: " << wir << std::endl; }
155 }
156 }
157 return 1;
158}
IMessageSvc * msgSvc()
double getDmeas() const
double getDocaInc() const
int getCellid() const
int getLayid() const
double getZhit() const
double getResiInc() const
int getLR() const
MdcCalRecHit * getRecHit(int index) const
int getNHits() const
virtual int fillHist(MdcCalEvent *event)=0
Definition MdcCalib.cxx:767

◆ initialize()

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

Implements MdcCalib.

Definition at line 46 of file Wr2dMdcCalib.cxx.

47 {
48 IMessageSvc* msgSvc;
49 Gaudi::svcLocator()->service( "MessageSvc", msgSvc );
50 MsgStream log( msgSvc, "Wr2dMdcCalib" );
51 log << MSG::INFO << "Wr2dMdcCalib::initialize()" << endmsg;
52
53 m_hlist = hlist;
54 m_mdcGeomSvc = mdcGeomSvc;
55 m_mdcFunSvc = mdcFunSvc;
56 m_mdcUtilitySvc = mdcUtilitySvc;
57
58 MdcCalib::initialize( m_hlist, m_mdcGeomSvc, m_mdcFunSvc, m_mdcUtilitySvc );
59
60 int i;
61 int bin;
62 int lay;
63 int cel;
64 char hname[200];
65
66 m_fdWire = new TFolder( "WireCor", "WireCor" );
67 m_hlist->Add( m_fdWire );
68
69 for ( i = 0; i < MdcCalTotCell; i++ )
70 {
71 lay = m_mdcGeomSvc->Wire( i )->Layer();
72 cel = m_mdcGeomSvc->Wire( i )->Cell();
73
74 for ( bin = 0; bin < MdcCalWrNBin; bin++ )
75 {
76 sprintf( hname, "h%04d_L_%02d", i, bin );
77 m_hl[i][bin] = new TH1F( hname, "", 300, -1.5, 1.5 );
78 m_fdWire->Add( m_hl[i][bin] );
79
80 sprintf( hname, "h%04d_R_%02d", i, bin );
81 m_hr[i][bin] = new TH1F( hname, "", 300, -1.5, 1.5 );
82 m_fdWire->Add( m_hr[i][bin] );
83 }
84 }
85
86 for ( lay = 0; lay < MdcCalNLayer; lay++ )
87 {
88 m_zwest[lay] = m_mdcGeomSvc->Wire( lay, 0 )->Forward().z();
89 m_zeast[lay] = m_mdcGeomSvc->Wire( lay, 0 )->Backward().z();
90 m_zwid[lay] = ( m_zeast[lay] - m_zwest[lay] ) / (double)MdcCalWrNBin;
91
92 for ( bin = 0; bin < MdcCalWrNBin; bin++ )
93 { m_zbinCen[lay][bin] = ( (double)bin + 0.5 ) * m_zwid[lay] + m_zwest[lay]; }
94 }
95}
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
virtual void initialize(TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)=0
Definition MdcCalib.cxx:225

◆ printCut()

void Wr2dMdcCalib::printCut ( ) const
virtual

Implements MdcCalib.

Definition at line 160 of file Wr2dMdcCalib.cxx.

virtual void printCut() const =0

◆ setParam()

void Wr2dMdcCalib::setParam ( MdcCalParams & param)
inlinevirtual

Implements MdcCalib.

Definition at line 48 of file Wr2dMdcCalib.h.

48 {
49 MdcCalib::setParam( param );
50 m_param = param;
51}
virtual void setParam(MdcCalParams &param)=0
Definition MdcCalib.h:305

◆ updateConst()

int Wr2dMdcCalib::updateConst ( MdcCalibConst * calconst)
virtual

Implements MdcCalib.

Definition at line 162 of file Wr2dMdcCalib.cxx.

162 {
163 IMessageSvc* msgSvc;
164 Gaudi::svcLocator()->service( "MessageSvc", msgSvc );
165 MsgStream log( msgSvc, "Wr2dMdcCalib" );
166 log << MSG::INFO << "Wr2dMdcCalib::updateConst()" << endmsg;
167
168 int i;
169 int k;
170 int bin;
171 int lay;
172 int cel;
173 double dw;
174
175 // minuit for wires
176 Int_t ierflg;
177 Int_t istat;
178 Int_t nvpar;
179 Int_t nparx;
180 Double_t fmin;
181 Double_t edm;
182 Double_t errdef;
183 Double_t arglist[10];
184
185 TMinuit* gmtrw = new TMinuit( 5 );
186 gmtrw->SetPrintLevel( -1 );
187 gmtrw->SetFCN( fcnWireParab );
188 gmtrw->SetErrorDef( 1.0 );
189 gmtrw->mnparm( 0, "xf", 0.0, 0.01, 0, 0, ierflg );
190 gmtrw->mnparm( 1, "yf", 0.0, 0.01, 0, 0, ierflg );
191 gmtrw->mnparm( 2, "xb", 0.0, 0.01, 0, 0, ierflg );
192 gmtrw->mnparm( 3, "yb", 0.0, 0.01, 0, 0, ierflg );
193 gmtrw->mnparm( 4, "ten", 0.0, 0.1, 0, 0, ierflg );
194 arglist[0] = 0;
195 gmtrw->mnexcm( "Set NOW", arglist, 0, ierflg );
196
197 double a;
198 double dx;
199 double dy;
200 double dz;
201 double length;
202 double ten[] = { 15, 15, 15, 16, 16, 17, 17, 18, 14, 14, 19, 19, 24, 24, 31,
203 31, 37, 37, 45, 45, 46, 47, 47, 47, 47, 48, 48, 48, 48, 49,
204 49, 49, 49, 50, 50, 50, 51, 51, 51, 52, 52, 52, 52 };
205 double wpar[5];
206 double wparErr[5];
207 double sinphiw;
208 double cosphiw;
209 double deldw;
210 double delxw;
211 double delyw;
212
213 int nFit;
214 Stat_t entryL;
215 Stat_t entryR;
216 Double_t hcen;
217 Double_t cenL[MdcCalWrNBin];
218 Double_t errL[MdcCalWrNBin];
219 Double_t cenR[MdcCalWrNBin];
220 Double_t errR[MdcCalWrNBin];
221
222 ofstream fwlog( "logWireCor.txt" );
223 ofstream fwpc( "wireposCor.txt" );
224 ofstream fwpcErr( "wireposErr.txt" );
225
226 fwpc << setw( 5 ) << "wireId" << setw( 15 ) << "dx_East(mm)" << setw( 15 ) << "dy_East(mm)"
227 << setw( 15 ) << "dz_East(mm)" << setw( 15 ) << "dx_West(mm)" << setw( 15 )
228 << "dy_West(mm)" << setw( 15 ) << "dz_West(mm)" << endl;
229
230 for ( i = 0; i < MdcCalTotCell; i++ )
231 {
232 for ( k = 0; k < 5; k++ ) wparErr[k] = 999.0;
233 nFit = 0;
234 for ( bin = 0; bin < MdcCalWrNBin; bin++ )
235 {
236 entryL = m_hl[i][bin]->GetEntries();
237 entryR = m_hr[i][bin]->GetEntries();
238 if ( ( entryL < 100 ) && ( entryR < 100 ) )
239 {
240 fgBIN[bin] = false;
241 continue;
242 }
243 else { fgBIN[bin] = true; }
244 nFit++;
245
246 if ( 1 == m_param.fgCalib[lay] )
247 {
248 hcen = m_hl[i][bin]->GetMean();
249 if ( entryL > 500 )
250 {
251 m_hl[i][bin]->Fit( "gaus", "Q", "", hcen - 1.5, hcen + 1.5 );
252 cenL[bin] = m_hl[i][bin]->GetFunction( "gaus" )->GetParameter( 1 );
253 errL[bin] = m_hl[i][bin]->GetFunction( "gaus" )->GetParameter( 2 );
254 }
255 else
256 {
257 cenL[bin] = hcen;
258 errL[bin] = m_hl[i][bin]->GetRMS();
259 }
260
261 hcen = m_hr[i][bin]->GetMean();
262 if ( entryR > 500 )
263 {
264 m_hr[i][bin]->Fit( "gaus", "Q", "", hcen - 1.5, hcen + 1.5 );
265 cenR[bin] = m_hr[i][bin]->GetFunction( "gaus" )->GetParameter( 1 );
266 errR[bin] = m_hr[i][bin]->GetFunction( "gaus" )->GetParameter( 2 );
267 }
268 else
269 {
270 cenR[bin] = hcen;
271 errR[bin] = m_hr[i][bin]->GetRMS();
272 }
273 }
274 else
275 {
276 cenL[bin] = 0.0;
277 errL[bin] = 0.15;
278 cenR[bin] = 0.0;
279 errR[bin] = 0.15;
280 }
281 }
282 if ( nFit < 8 ) continue;
283
284 lay = m_mdcGeomSvc->Wire( i )->Layer();
285 cel = m_mdcGeomSvc->Wire( i )->Cell();
286 zMIN = m_zwest[lay];
287 zMAX = m_zeast[lay];
288 wpar[0] = m_mdcGeomSvc->Wire( lay, 0 )->Backward().x();
289 wpar[1] = m_mdcGeomSvc->Wire( lay, 0 )->Backward().y();
290 wpar[2] = m_mdcGeomSvc->Wire( lay, 0 )->Forward().x();
291 wpar[3] = m_mdcGeomSvc->Wire( lay, 0 )->Forward().y();
292 wpar[4] = ten[lay];
293
294 a = 9.47e-06 / ( 2 * wpar[4] );
295 dx = wpar[0] - wpar[2];
296 dy = wpar[1] - wpar[3];
297 dz = zMAX - zMIN;
298 length = sqrt( dx * dx + dz * dz );
299
300 for ( bin = 0; bin < MdcCalWrNBin; bin++ )
301 {
302 zBIN[bin] = m_zbinCen[lay][bin];
303 xBIN[bin] = ( wpar[0] - wpar[2] ) * ( zBIN[bin] - zMIN ) / ( zMAX - zMIN ) + wpar[2];
304 yBIN[bin] = a * zBIN[bin] * zBIN[bin] + ( wpar[1] - wpar[3] ) * zBIN[bin] / length +
305 0.5 * ( wpar[1] + wpar[3] ) - a * length * length / 4.0;
306
307 sinphiw = yBIN[bin] / sqrt( xBIN[bin] * xBIN[bin] + yBIN[bin] * yBIN[bin] );
308 cosphiw = xBIN[bin] / sqrt( xBIN[bin] * xBIN[bin] + yBIN[bin] * yBIN[bin] );
309
310 deldw = -( cenL[bin] - cenR[bin] ) / 2.0;
311 delxw = -deldw * sinphiw;
312 delyw = deldw * cosphiw;
313
314 fwlog << setw( 3 ) << lay << setw( 4 ) << cel << setw( 5 ) << i << setw( 4 ) << bin
315 << setw( 15 ) << zBIN[bin] << setw( 15 ) << deldw << setw( 15 ) << delxw
316 << setw( 15 ) << delyw << endl;
317
318 xBIN[bin] += delxw;
319 yBIN[bin] += delyw;
320
321 zBINERR[bin] = sqrt( ( errL[bin] * errL[bin] ) + ( errR[bin] * errR[bin] ) ) / 2.0;
322 }
323
324 arglist[0] = 1;
325 arglist[1] = wpar[0];
326 gmtrw->mnexcm( "SET PARameter", arglist, 2, ierflg );
327 arglist[0] = 2;
328 arglist[1] = wpar[1];
329 gmtrw->mnexcm( "SET PARameter", arglist, 2, ierflg );
330 arglist[0] = 3;
331 arglist[1] = wpar[2];
332 gmtrw->mnexcm( "SET PARameter", arglist, 2, ierflg );
333 arglist[0] = 4;
334 arglist[1] = wpar[3];
335 gmtrw->mnexcm( "SET PARameter", arglist, 2, ierflg );
336 arglist[0] = 5;
337 arglist[1] = wpar[4];
338 gmtrw->mnexcm( "SET PARameter", arglist, 2, ierflg );
339 gmtrw->mnexcm( "FIX", arglist, 1, ierflg );
340
341 arglist[0] = 2000;
342 arglist[1] = 0.1;
343 gmtrw->mnexcm( "MIGRAD", arglist, 2, ierflg );
344 gmtrw->mnstat( fmin, edm, errdef, nvpar, nparx, istat );
345
346 if ( ( 0 == ierflg ) && ( 3 == istat ) )
347 {
348 gmtrw->GetParameter( 0, wpar[0], wparErr[0] );
349 gmtrw->GetParameter( 1, wpar[1], wparErr[1] );
350 gmtrw->GetParameter( 2, wpar[2], wparErr[2] );
351 gmtrw->GetParameter( 3, wpar[3], wparErr[3] );
352 gmtrw->GetParameter( 4, wpar[4], wparErr[4] );
353 }
354 gmtrw->mnexcm( "RELease", arglist, 1, ierflg );
355
356 fwlog << setw( 5 ) << i << setw( 15 ) << wpar[0] << setw( 15 ) << wpar[1] << setw( 15 )
357 << wpar[2] << setw( 15 ) << wpar[3] << endl;
358 fwpc << setw( 5 ) << i << setw( 15 ) << wpar[0] << setw( 15 ) << wpar[1] << setw( 15 )
359 << "0" << setw( 15 ) << wpar[2] << setw( 15 ) << wpar[3] << setw( 15 ) << "0" << endl;
360 fwpcErr << setw( 5 ) << i << setw( 15 ) << wparErr[0] << setw( 15 ) << wparErr[1]
361 << setw( 15 ) << wparErr[2] << setw( 15 ) << wparErr[3] << endl;
362 }
363 fwlog.close();
364 fwpc.close();
365 fwpcErr.close();
366
367 delete gmtrw;
368 return 1;
369}
static void fcnWireParab(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)

Member Data Documentation

◆ fgBIN

bool Wr2dMdcCalib::fgBIN
static

Definition at line 22 of file Wr2dMdcCalib.h.

Referenced by fcnWireParab(), and updateConst().

◆ xBIN

double Wr2dMdcCalib::xBIN
static

Definition at line 23 of file Wr2dMdcCalib.h.

Referenced by fcnWireParab(), and updateConst().

◆ yBIN

double Wr2dMdcCalib::yBIN
static

Definition at line 24 of file Wr2dMdcCalib.h.

Referenced by fcnWireParab(), and updateConst().

◆ zBIN

double Wr2dMdcCalib::zBIN
static

Definition at line 25 of file Wr2dMdcCalib.h.

Referenced by fcnWireParab(), and updateConst().

◆ zBINERR

double Wr2dMdcCalib::zBINERR
static

Definition at line 26 of file Wr2dMdcCalib.h.

Referenced by fcnWireParab(), and updateConst().

◆ zMAX

double Wr2dMdcCalib::zMAX
static

Definition at line 28 of file Wr2dMdcCalib.h.

Referenced by fcnWireParab(), and updateConst().

◆ zMIN

double Wr2dMdcCalib::zMIN
static

Definition at line 27 of file Wr2dMdcCalib.h.

Referenced by fcnWireParab(), and updateConst().


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