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

#include <MilleAlign.h>

Inheritance diagram for MilleAlign:

Public Member Functions

 MilleAlign ()
 ~MilleAlign ()
void clear ()
void initialize (TObjArray *hlist, IMdcGeomSvc *mdcGeomSvc, IMdcCalibFunSvc *mdcFunSvc, IMdcUtilitySvc *mdcUtilitySvc)
void setParam (MdcAliParams &param)
bool fillHist (MdcAliEvent *event)
void updateConst (MdcAlignPar *alignPar)
Public Member Functions inherited from MdcAlign
 MdcAlign ()
virtual ~MdcAlign ()

Public Attributes

std::string fixMomLab
Public Attributes inherited from MdcAlign
std::string fixMomLab

Detailed Description

Definition at line 15 of file MilleAlign.h.

Constructor & Destructor Documentation

◆ MilleAlign()

MilleAlign::MilleAlign ( )

Definition at line 28 of file MilleAlign.cxx.

28 {
29 for ( int lay = 0; lay < LAYERNMAX; lay++ )
30 {
31 m_resiCut[lay] = 1.5;
32 if ( lay < 8 )
33 {
34 m_docaCut[lay][0] = 0.5;
35 m_docaCut[lay][1] = 5.5;
36 }
37 else
38 {
39 m_docaCut[lay][0] = 0.5;
40 m_docaCut[lay][1] = 7.5;
41 }
42 }
43}
const int LAYERNMAX
Definition Alignment.h:43

◆ ~MilleAlign()

MilleAlign::~MilleAlign ( )

Definition at line 45 of file MilleAlign.cxx.

45{}

Member Function Documentation

◆ clear()

void MilleAlign::clear ( )
virtual

Implements MdcAlign.

Definition at line 47 of file MilleAlign.cxx.

47 {
48 delete m_hresAll;
49 delete m_hresInn;
50 delete m_hresStp;
51 delete m_hresOut;
52 for ( int lay = 0; lay < LAYERNMAX; lay++ ) delete m_hresLay[lay];
53 delete m_hresAllRec;
54 for ( int lay = 0; lay < LAYERNMAX; lay++ ) delete m_hresLayRec[lay];
55 delete m_hddoca;
56 delete m_pMilleAlign;
57}

◆ fillHist()

bool MilleAlign::fillHist ( MdcAliEvent * event)
virtual

Implements MdcAlign.

Definition at line 199 of file MilleAlign.cxx.

199 {
200 IMessageSvc* msgSvc;
201 Gaudi::svcLocator()->service( "MessageSvc", msgSvc );
202 MsgStream log( msgSvc, "MilleAlign" );
203 log << MSG::DEBUG << "MilleAlign::fillTree()" << endmsg;
204
205 int recFlag;
206 int itrk;
207 int ihit;
208 int fgGetDoca;
209 int lr;
210 int lay;
211 int cel;
212 double doca;
213 double dmeas;
214 double zhit;
215 double resi;
216 double resiRec;
217 double deri;
218 double hitSigm;
219 double hitpos[3];
220 double wpos[7]; // wpos[6] is wire tension
221 const MdcGeoWire* pWire;
222
223 double trkpar[NTRKPAR];
224 double trkparms[NTRKPARALL]; // track parameters and errors
225
226 // numerical derivative
227 int ipar;
228 int iparGB;
229
230 MdcAliRecTrk* rectrk;
231 MdcAliRecHit* rechit;
232
233 int ntrk = event->getNTrk();
234 if ( ( ntrk < m_param.nTrkCut[0] ) || ( ntrk > m_param.nTrkCut[1] ) ) return false;
235
236 for ( itrk = 0; itrk < ntrk; itrk++ )
237 {
238 rectrk = event->getRecTrk( itrk );
239 recFlag = rectrk->getStat();
240
241 trkpar[0] = rectrk->getDr();
242 trkpar[1] = rectrk->getPhi0();
243 trkpar[2] = rectrk->getKappa();
244 trkpar[3] = rectrk->getDz();
245 trkpar[4] = rectrk->getTanLamda();
246
247 int nHit = rectrk->getNHits();
248 if ( nHit < m_param.nHitCut ) continue;
249 if ( fabs( trkpar[0] ) > m_param.drCut ) continue;
250 if ( fabs( trkpar[3] ) > m_param.dzCut ) continue;
251
252 HepVector rechelix = rectrk->getHelix();
253 HepVector helix = rectrk->getHelix();
254 HepSymMatrix helixErr = rectrk->getHelixErr();
255
256 int nHitUse = 0;
257 for ( ihit = 0; ihit < nHit; ihit++ )
258 {
259 rechit = rectrk->getRecHit( ihit );
260 lr = rechit->getLR();
261 lay = rechit->getLayid();
262 cel = rechit->getCellid();
263 pWire = m_mdcGeomSvc->Wire( lay, cel );
264 dmeas = rechit->getDmeas();
265 zhit = rechit->getZhit();
266 hitSigm = rechit->getErrDmeas();
267
268 wpos[0] = pWire->Backward().x(); // east end
269 wpos[1] = pWire->Backward().y();
270 wpos[2] = pWire->Backward().z();
271 wpos[3] = pWire->Forward().x(); // west end
272 wpos[4] = pWire->Forward().y();
273 wpos[5] = pWire->Forward().z();
274 wpos[6] = pWire->Tension();
275
276 double docaRec = rechit->getDocaInc();
277 double doca = ( m_mdcUtilitySvc->doca( lay, cel, helix, helixErr ) ) * 10.0;
278
279 resi = -1.0 * dmeas - doca;
280 if ( ( fabs( doca ) < m_docaCut[lay][0] ) || ( fabs( doca ) > m_docaCut[lay][1] ) ||
281 ( fabs( resi ) > m_resiCut[lay] ) )
282 continue;
283 nHitUse++;
284
285 resiRec = rechit->getResiIncLR();
286
287 double dd = fabs( doca ) - fabs( rechit->getDocaInc() );
288 m_hddoca->Fill( dd );
289 m_hddocaLay[lay]->Fill( dd );
290
291 // fill histograms
292 m_hresAll->Fill( resi );
293 if ( lay < 8 ) m_hresInn->Fill( resi );
294 else if ( lay < 20 ) m_hresStp->Fill( resi );
295 else m_hresOut->Fill( resi );
296 m_hresLay[lay]->Fill( resi );
297
298 m_hresAllRec->Fill( resiRec );
299 m_hresLayRec[lay]->Fill( resiRec );
300
301 // reset the derivatives arrays
302 m_pMilleAlign->ZerLoc( &m_derGB[0], &m_derLC[0], &m_derNonLin[0] );
303
304 // derivatives of local parameters
305 for ( ipar = 0; ipar < m_nloc; ipar++ )
306 {
307 if ( !getDeriLoc( ipar, lay, cel, rechelix, helixErr, deri ) )
308 {
309 cout << "getDeriLoc == false!" << setw( 12 ) << itrk << setw( 12 ) << ipar << endl;
310 return false;
311 }
312 m_derLC[ipar] = deri;
313 }
314 // derivatives of global parameters
315 // ipar 0 - 5: dx_east, dx_west, dy_east, dy_west, rz_east, rz_west
316 for ( ipar = 0; ipar < m_nGloHit; ipar++ )
317 {
318 iparGB = getAlignParId( lay, ipar );
319 if ( !getDeriGlo( ipar, iparGB, lay, cel, helix, helixErr, wpos, deri ) )
320 {
321 cout << "getDeriGlo == false!" << setw( 12 ) << itrk << setw( 12 ) << ipar << endl;
322 return false;
323 }
324 m_derGB[iparGB] = deri;
325 }
326 m_pMilleAlign->EquLoc( &m_derGB[0], &m_derLC[0], &m_derNonLin[0], resi, hitSigm );
327 } // loop of nhit
328
329 // local fit in Millepede
330 bool sc = m_pMilleAlign->FitLoc( m_pMilleAlign->GetTrackNumber(), trkparms, 0 );
331 if ( sc ) m_pMilleAlign->SetTrackNumber( m_pMilleAlign->GetTrackNumber() + 1 );
332 } // track loop
333 return true;
334}
IMessageSvc * msgSvc()
int getCellid() const
double getDmeas() const
int getLR() const
double getErrDmeas() const
int getLayid() const
double getZhit() const
double getResiIncLR() const
double getDocaInc() const
double getDz() const
double getDr() const
MdcAliRecHit * getRecHit(int index) const
double getKappa() const
int getStat() const
int getNHits() const
double getPhi0() const
HepSymMatrix getHelixErr() const
HepVector getHelix() const
double getTanLamda() const
const int NTRKPAR
Definition Alignment.h:47
const int NTRKPARALL
Definition Alignment.h:48

◆ initialize()

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

Implements MdcAlign.

Definition at line 59 of file MilleAlign.cxx.

60 {
61 IMessageSvc* msgSvc;
62 Gaudi::svcLocator()->service( "MessageSvc", msgSvc );
63 MsgStream log( msgSvc, "MilleAlign" );
64 log << MSG::INFO << "MilleAlign::initialize()" << endmsg;
65
66 m_hlist = hlist;
67 m_mdcGeomSvc = mdcGeomSvc;
68 m_mdcFunSvc = mdcFunSvc;
69 m_mdcUtilitySvc = mdcUtilitySvc;
70
71 // initialize hitograms
72 m_hresAll = new TH1F( "HResAllInc", "", 200, -1.0, 1.0 );
73 m_hlist->Add( m_hresAll );
74
75 m_hresInn = new TH1F( "HResInnInc", "", 200, -1.0, 1.0 );
76 m_hlist->Add( m_hresInn );
77
78 m_hresStp = new TH1F( "HResStpInc", "", 200, -1.0, 1.0 );
79 m_hlist->Add( m_hresStp );
80
81 m_hresOut = new TH1F( "HResOutInc", "", 200, -1.0, 1.0 );
82 m_hlist->Add( m_hresOut );
83
84 char hname[200];
85 for ( int lay = 0; lay < LAYERNMAX; lay++ )
86 {
87 sprintf( hname, "Res_Layer%02d", lay );
88 m_hresLay[lay] = new TH1F( hname, "", 200, -1.0, 1.0 );
89 m_hlist->Add( m_hresLay[lay] );
90 }
91
92 m_hresAllRec = new TH1F( "HResAllRecInc", "", 200, -1.0, 1.0 );
93 m_hlist->Add( m_hresAllRec );
94 for ( int lay = 0; lay < LAYERNMAX; lay++ )
95 {
96 sprintf( hname, "Res_LayerRec%02d", lay );
97 m_hresLayRec[lay] = new TH1F( hname, "", 200, -1.0, 1.0 );
98 m_hlist->Add( m_hresLayRec[lay] );
99 }
100
101 // for debug
102 m_hddoca = new TH1F( "delt_doca", "", 200, -1.0, 1.0 );
103 m_hlist->Add( m_hddoca );
104
105 for ( int lay = 0; lay < LAYERNMAX; lay++ )
106 {
107 sprintf( hname, "delt_docaLay%02d", lay );
108 m_hddocaLay[lay] = new TH1F( hname, "", 200, -1.0, 1.0 );
109 m_hlist->Add( m_hddocaLay[lay] );
110 }
111
112 // initialize millepede
113 m_nglo = NEP;
114 m_nloc = NTRKPAR;
115 m_nGloHit = 2 * NDOFALIGN;
116 m_npar = NDOFALIGN * m_nglo;
117
118 int i;
119 for ( i = 0; i < NDOFALIGN; i++ )
120 {
121 m_dofs[i] = g_dofs[i];
122 m_sigm[i] = g_Sigm[i];
123 }
124
125 m_pMilleAlign = new Millepede();
126 m_pMilleAlign->InitMille( &m_dofs[0], &m_sigm[0], m_nglo, m_nloc, g_start_chi_cut, 3,
128
129 m_derGB.resize( m_npar );
130 m_derNonLin.resize( m_npar );
131 m_par.resize( m_npar );
132 m_error.resize( m_npar );
133 m_pull.resize( m_npar );
134
135 m_derLC.resize( m_nloc );
136
137 // contraints
138 std::vector<double> constTX;
139 std::vector<double> constTY;
140 std::vector<double> constRZ;
141
142 std::vector<double> constTXE;
143 std::vector<double> constTXW;
144 std::vector<double> constTYE;
145 std::vector<double> constTYW;
146 std::vector<double> constRZE;
147 std::vector<double> constRZW;
148
149 constTX.resize( m_npar );
150 constTY.resize( m_npar );
151 constRZ.resize( m_npar );
152
153 constTXE.resize( m_npar );
154 constTXW.resize( m_npar );
155 constTYE.resize( m_npar );
156 constTYW.resize( m_npar );
157 constRZE.resize( m_npar );
158 constRZW.resize( m_npar );
159
160 for ( i = 0; i < m_npar; i++ )
161 {
162 constTX[i] = 0.0;
163 constTY[i] = 0.0;
164 constRZ[i] = 0.0;
165
166 constTXE[i] = 0.0;
167 constTXW[i] = 0.0;
168 constTYE[i] = 0.0;
169 constTYW[i] = 0.0;
170 constRZE[i] = 0.0;
171 constRZW[i] = 0.0;
172 }
173 constTX[7] = 1.0;
174 constTX[15] = 1.0;
175 constTY[23] = 1.0;
176 constTY[31] = 1.0;
177 constRZ[39] = 1.0;
178 constRZ[47] = 1.0;
179
180 constTXE[7] = 1.0;
181 constTXW[15] = 1.0;
182 constTYE[23] = 1.0;
183 constTYW[31] = 1.0;
184 constRZE[39] = 1.0;
185 constRZW[47] = 1.0;
186
187 // m_pMilleAlign -> ConstF(&constTX[0], 0.0);
188 // m_pMilleAlign -> ConstF(&constTY[0], 0.0);
189 // m_pMilleAlign -> ConstF(&constRZ[0], 0.0);
190
191 m_pMilleAlign->ConstF( &constTXE[0], 0.0 );
192 m_pMilleAlign->ConstF( &constTXW[0], 0.0 );
193 m_pMilleAlign->ConstF( &constTYE[0], 0.0 );
194 m_pMilleAlign->ConstF( &constTYW[0], 0.0 );
195 m_pMilleAlign->ConstF( &constRZE[0], 0.0 );
196 m_pMilleAlign->ConstF( &constRZW[0], 0.0 );
197}
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 double g_res_cut_init
Definition Alignment.h:84
const int NEP
Definition Alignment.h:46
const double g_res_cut
Definition Alignment.h:83
const int NDOFALIGN
Definition Alignment.h:60
const double g_Sigm[3]
Definition Alignment.h:77
const bool g_dofs[3]
Definition Alignment.h:69
const double g_start_chi_cut
Definition Alignment.h:85

◆ setParam()

void MilleAlign::setParam ( MdcAliParams & param)
inlinevirtual

Implements MdcAlign.

Definition at line 83 of file MilleAlign.h.

83 {
84 MdcAlign::setParam( param );
85 m_param = param;
86}
virtual void setParam(MdcAliParams &param)=0
Definition MdcAlign.h:37

◆ updateConst()

void MilleAlign::updateConst ( MdcAlignPar * alignPar)
virtual

Implements MdcAlign.

Definition at line 336 of file MilleAlign.cxx.

336 {
337 IMessageSvc* msgSvc;
338 Gaudi::svcLocator()->service( "MessageSvc", msgSvc );
339 MsgStream log( msgSvc, "MilleAlign" );
340 log << MSG::INFO << "MilleAlign::updateConst()" << endmsg;
341
342 m_pMilleAlign->MakeGlobalFit( &m_par[0], &m_error[0], &m_pull[0] );
343
344 int iEP;
345 int ipar;
346 double val;
347 double err;
348 for ( int i = 0; i < NDOFALIGN; i++ )
349 {
350 for ( iEP = 0; iEP < NEP; iEP++ )
351 {
352 ipar = i * NEP + iEP;
353 if ( m_dofs[i] )
354 {
355 val = m_par[ipar];
356 err = m_error[ipar];
357 }
358 else
359 {
360 val = 0.0;
361 err = 0.0;
362 }
363
364 if ( 0 == i )
365 {
366 alignPar->setDelDx( iEP, val );
367 alignPar->setErrDx( iEP, err );
368 }
369 else if ( 1 == i )
370 {
371 alignPar->setDelDy( iEP, val );
372 alignPar->setErrDy( iEP, err );
373 }
374 else if ( 2 == i )
375 {
376 alignPar->setDelRz( iEP, val / 1000.0 ); // mrad -> rad
377 alignPar->setErrRz( iEP, err / 1000.0 ); // mrad -> rad
378 }
379 }
380 }
381}
void setErrRz(int iEP, double val)
void setDelDy(int iEP, double val)
void setDelRz(int iEP, double val)
void setErrDx(int iEP, double val)
void setDelDx(int iEP, double val)
void setErrDy(int iEP, double val)

Member Data Documentation

◆ fixMomLab

std::string MilleAlign::fixMomLab

Definition at line 28 of file MilleAlign.h.


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