96 {
98
99
100
102
104 m_tree=
new TTree(
"globalChi2Deriv",
"globalChi2Deriv");
116
131 }
132
133
134
135 bool fullVertex = false;
136 AlignVertex * ptrVertex = alignTrack->getVtx();
139 const std::vector<AlignModuleVertexDerivatives> * ptrX = nullptr;
141 if( ptrVertex ) {
142 fullVertex = true;
143 ptrPosition = ptrVertex->position();
144 ptrCovariance = ptrVertex->covariance();
145 ptrX = ptrVertex->derivatives();
146 vtxType = ptrVertex->type();
147
148
150 msg(MSG::ERROR)<<
"something missing from alignVertex!"<<
endmsg;
151 if (!ptrPosition)
msg(MSG::ERROR)<<
"no fitted position!"<<
endmsg;
152 if (!ptrCovariance)
msg(MSG::ERROR)<<
"no covariance!"<<
endmsg;
153 if (!ptrX)
msg(MSG::ERROR)<<
"no link to the X object!"<<
endmsg;
155 return false;
156 }
157 }
158
159
160
161
164
165
167 const Amg::SymMatrixX * ptrWeightsFD = alignTrack->weightMatrixFirstDeriv();
168 const Amg::VectorX * ptrResiduals = alignTrack->residualVector();
169 const std::vector<AlignModuleDerivatives> * ptrDerivs = alignTrack->derivatives();
170
171
172 if (!ptrWeights || !ptrWeightsFD || !ptrResiduals || !ptrDerivs) {
173 msg(MSG::ERROR)<<
"something missing from alignTrack!"<<
endmsg;
174 if (!ptrWeights)
msg(MSG::ERROR)<<
"no weights!"<<
endmsg;
175 if (!ptrWeightsFD)
msg(MSG::ERROR)<<
"no weights for first deriv!"<<
endmsg;
176 if (!ptrResiduals)
msg(MSG::ERROR)<<
"no residuals!"<<
endmsg;
177 if (!ptrDerivs)
msg(MSG::ERROR)<<
"no derivatives!"<<
endmsg;
178 return false;
179 }
180
181
186
187
189 std::vector<AlignModuleDerivatives> derivatives = *ptrDerivs;
190 const std::vector<AlignModuleDerivatives>* derivativeErr = alignTrack->derivativeErr();
191 const std::vector<std::pair<AlignModule*,std::vector<double> > >* secDerivs = alignTrack->actualSecondDerivatives();
192
193
194
195 std::vector<AlignPar*> allAlignPars;
196 std::vector<Amg::VectorX*> allDerivatives;
197 std::vector<const Amg::VectorX*> allDerivativeErr;
198 std::vector<double> allActualSecDeriv;
201 matrix_F.setZero();
202
203
204 msg(MSG::DEBUG) <<
"accumulate: The derivative vector size is " << derivatives.size() <<
endmsg;
205 std::vector<AlignModuleDerivatives>::iterator derivIt = derivatives.begin();
206 std::vector<AlignModuleDerivatives>::iterator derivIt_end = derivatives.end();
207
208 std::vector<AlignModuleDerivatives>::const_iterator derivErrIt;
209 std::vector<std::pair<AlignModule*,std::vector<double> > >::const_iterator secDerivIt;
210 if (derivativeErr) derivErrIt=derivativeErr->begin();
211 if (secDerivs) secDerivIt=secDerivs->begin();
212 for ( ; derivIt!=derivIt_end ; ++derivIt) {
213
214
215 AlignModule*
module=derivIt->first;
216
217
218 module->addTrack();
219 ATH_MSG_DEBUG(
"add track to module "<<
module->identify().get_identifier32().get_compact());
220 module->addNDoF(alignTrack->fitQuality()->numberDoF());
221 module->addTrackChi2(alignTrack->fitQuality()->chiSquared());
222
223
227 }
229
230
231 std::vector<Amg::VectorX>& deriv_vec = derivIt->second;
232 ATH_MSG_DEBUG(
"accumulate: The deriv_vec size is " << deriv_vec.size() );
234 int nModPars = alignPars->
size();
235 if (nModPars != (int)deriv_vec.size() && (nModPars+3) != (int)deriv_vec.size()) {
237 return false;
238 }
239 for (
int i=0;
i<3;
i++) {
240 for (
int j=0;
j<WSize;
j++) {
241 matrix_F(i,j) += deriv_vec[nModPars+
i][
j];
242 }
243 }
244
245
246 for (
int i=0;
i<nModPars;
i++) {
248 allAlignPars.push_back((*alignPars)[i]);
249 allDerivatives.push_back(&deriv_vec[i]);
250 if (derivativeErr)
251 allDerivativeErr.push_back(&(derivErrIt->second)[i]);
252 if (secDerivs)
253 allActualSecDeriv.push_back((secDerivIt->second)[i]);
254 }
255 if (derivativeErr) ++derivErrIt;
256 if (secDerivs) ++secDerivIt;
257 }
258
259
262 for (; iatsos != iatsos_last; ++iatsos)
263 if ((*iatsos)->module())
264 (*iatsos)->module()->addHit();
265
266
267 int nAllPars = allAlignPars.size();
269 for (int ipar=0;ipar<nAllPars;ipar++) {
270
271
272 Amg::MatrixX derivativesT = (*allDerivatives[ipar]).transpose();
273 ATH_MSG_DEBUG(
"derivativesT (size "<<derivativesT.cols()<<
"): "<<derivativesT);
274
277
278
279 int index1 = allAlignPars[ipar]->index();
280
283 if (firstderivM(0,0)==0.) {
284 ATH_MSG_DEBUG(
"firstderivM[0][0] is zero : "<<firstderivM(0,0));
285 continue;
286 }
287
288
289
290
295 ATH_MSG_DEBUG(
"alActualSecDeriv size: "<<allActualSecDeriv.size());
297 }
299 }
300
301
302 int imodule1 = allAlignPars[ipar]->alignModule()->identifyHash();
303
304
305 bool goodSecondDeriv = true;
306 for (int jpar=ipar;jpar<nAllPars;jpar++) {
307
308
309 int index2=allAlignPars[jpar]->index();
310
311
312 int imodule2 = allAlignPars[jpar]->alignModule()->identifyHash();
313
314
315
317 if (imodule1 != imodule2)
318 continue;
319
322
323
324
325 if (jpar==ipar && secondderivM(0,0)<0.) {
327 }
331 goodSecondDeriv = false;
332 break;
333 }
334
337
338
341 }
342
343
344
345 if (goodSecondDeriv) {
348 }
349 else
351 }
352
353
354
355
356 if( fullVertex ) {
357
358
359 ATH_MSG_DEBUG(
"accumulate: Contribution from the fullVTX will be added " );
360
361 Amg::MatrixX RHM = (*ptrCovariance) * (matrix_F) * (weightsFirstDeriv * residuals);
362
363 std::vector<AlignPar*> vtxAlignPars;
364 std::vector<const Amg::VectorX*> vtxDerivatives;
365
366
367 msg(MSG::DEBUG) <<
"accumulate: The Vertex derivative vector size is " << ptrX->size() <<
endmsg;
368 std::vector<AlignModuleVertexDerivatives>::const_iterator XIt = ptrX->begin();
369 std::vector<AlignModuleVertexDerivatives>::const_iterator XIt_end = ptrX->end();
370
371 for ( ; XIt!=XIt_end ; ++XIt) {
372
373
374 const AlignModule*
module=XIt->first;
375
376
377 const std::vector<Amg::VectorX>& X_vec = XIt->second;
378 msg(MSG::DEBUG) <<
"accumulate: The X_vec size is " << X_vec.size() <<
endmsg;
380 int nModPars = alignPars->
size();
381 if (nModPars != (int)X_vec.size()) {
383 return false;
384 }
385
386
387 for (
int i=0;
i<nModPars;
i++) {
389 vtxAlignPars.push_back((*alignPars)[i]);
390 vtxDerivatives.push_back(&X_vec[i]);
391 }
392
393 }
394
395
396 int ierr(0);
398 Qinv.setZero();
400 vtemp.setZero();
401 if( vtxType==AlignVertex::Refitted && ptrVertex->Constrained() && ptrVertex->Qmatrix()->determinant() > 1.0e-24 ) {
402
403 bool invertible;
404 double determinant;
405 ptrVertex->Qmatrix()->computeInverseAndDetWithCheck(Qinv,determinant,invertible);
406
407 if(!invertible) {
408 std::cout <<"accumulate: Q inversion failed. CLHEP status flag = "<<ierr<< std::endl;
409 return false;
410 }
411 vtemp(0) = -ptrVertex->originalPosition()->x()+(*(ptrVertex->Vvector()))(0);
412 vtemp(1) = -ptrVertex->originalPosition()->y()+(*(ptrVertex->Vvector()))(1);
413 vtemp(2) = -ptrVertex->originalPosition()->z()+(*(ptrVertex->Vvector()))(2);
414 }
415
416
417
418 int nvtxPars = vtxAlignPars.size();
419 for (int ipar=0;ipar<nvtxPars;ipar++) {
420
421
422 Amg::MatrixX derivativesT = (*vtxDerivatives[ipar]).transpose();
424
425
426 if( vtxType==
AlignVertex::Refitted && ptrVertex->Constrained() && ptrVertex->Qmatrix()->determinant() > 1.0e-24 ) {
427 firstderivM += 2.* derivativesT * ((*ptrCovariance) * Qinv) * vtemp;
428 }
429
430
431 int index1 = vtxAlignPars[ipar]->index();
432
434
435
437 ATH_MSG_DEBUG(
"accumulate: Filling second derivative for this vertex... ");
438 for (int jpar=0;jpar<nvtxPars;jpar++) {
439
440
441 Amg::MatrixX secondderivM = -1.* derivativesT * (*ptrCovariance) * (*vtxDerivatives[jpar]);
442
443
444 if( ptrVertex->Constrained() && ptrVertex->Qmatrix()->determinant() > 1.0e-24 ) {
445 secondderivM += 2.* derivativesT * ((*ptrCovariance) * Qinv * (*ptrCovariance)) * (*vtxDerivatives[jpar]);
446 }
447
448
449 int index2=vtxAlignPars[jpar]->index();
450
454 }
455
456 }
458 }
459
461
462 }
463
464 }
465
466
467
468
469
470
472
473
476 if (
sc==StatusCode::SUCCESS) {
479 }
480 else {
483 }
484
487
488 double pT=alignTrack->originalTrack()->perigeeParameters()->pT();
489 double eta=alignTrack->originalTrack()->perigeeParameters()->eta();
492 m_phi=alignTrack->originalTrack()->perigeeParameters()->momentum().phi();
493
494 Amg::Vector3D pos=alignTrack->originalTrack()->perigeeParameters()->position();
498
499 const TrackInfo
info=alignTrack->originalTrack()->info();
507
510 }
511
512
514 m_nmeas += alignTrack->nAlignTSOSMeas();
515 m_nhits += alignTrack->alignTSOSCollection()->size();
516 m_chi2 += alignTrack->fitQuality()->chiSquared();
517 m_nDoF += alignTrack->fitQuality()->numberDoF();
518
521
522 return true;
523 }
Scalar eta() const
pseudorapidity method
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define AmgSymMatrix(dim)
ServiceHandle< StoreGateSvc > & evtStore()
DataModel_detail::iterator< DataVector > iterator
size_type size() const noexcept
Returns the number of elements in the collection.
@ Refitted
normally refitted, without adding any pseudo-measurement
@ Accumulated
accumulated by the GX algorithm.
@ BremFit
A brem fit was performed on this track.
@ StraightTrack
A straight track.
@ HardScatterOrKink
A track with a kink or a hard scatter.
@ LowPtTrack
A LowPt track.
@ BremFitSuccessful
A brem fit was performed on this track and this fit was successful.
@ SlimmedTrack
A slimmed track.
uint32_t runNumber() const
The current event's run number.
uint64_t eventNumber() const
The current event's event number.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > SymMatrixX
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
::StatusCode StatusCode
StatusCode definition for legacy code.
const std::string weights
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
EventInfo_v1 EventInfo
Definition of the latest event info version.
const Identifier & identify(const UncalibratedMeasurement *meas)
Returns the associated identifier from the muon measurement.