13 #define MONITORTUNES // UNcomment this line to get more output, unfortunately in an ugly way
17 #include "CLHEP/Matrix/SymMatrix.h"
18 #include "CLHEP/Matrix/Vector.h"
59 #include "GaudiKernel/ITHistSvc.h"
78 ATH_MSG_DEBUG(
" Number of input tracks before track selection: " << trackParticles->
size());
82 std::vector<Trk::ITrackLink*> selectedTracks;
93 vertexError.setZero();
94 null.setCovariancePosition(vertexError);
95 for (TrackParticleDataVecIter itr = trackParticles->
begin(); itr != trackParticles->
end(); ++itr) {
97 selectionPassed=
static_cast<bool>(
m_trkFilter->accept(**itr,&
null));
98 if ( selectionPassed ) selectionPassed =
static_cast<bool>(
m_SVtrkFilter->accept(**itr,&
null));
102 par[0] = 1.0*(*itr)->hitPattern() ;
110 selectedTracks.push_back(linkTT);
114 ATH_MSG_DEBUG(
"Of " << trackParticles->
size() <<
" tracks " << selectedTracks.size() <<
" survived the preselection.");
117 std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*> returnContainers
120 return returnContainers;
124 std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*>
132 std::vector<Trk::ITrackLink*> selectedTracks;
135 bool selectionPassed;
141 vertexError.setZero();
142 null.setCovariancePosition(vertexError);
143 std::vector<const xAOD::IParticle*>::const_iterator trk_iter;
148 selectionPassed=
static_cast<bool>(
m_trkFilter->accept( *
tmp, &
null));
149 if ( selectionPassed ) selectionPassed =
static_cast<bool>(
m_SVtrkFilter->accept(*
tmp,&
null));
154 par[0] = 1.0*
tmp->hitPattern() ;
162 selectedTracks.push_back(link);
167 std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*> returnContainers
170 return returnContainers;
175 std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*>
182 std::vector<Trk::ITrackLink*> origTracks=trackVector;
183 std::vector<Trk::ITrackLink*> seedTracks=trackVector;
191 theVertexContainer->setStore( theVertexAuxContainer );
192 const auto invalidResponse = std::make_pair(theVertexContainer, theVertexAuxContainer);
196 ATH_MSG_WARNING( trackVector.size() <<
" tracks - exceeds maximum (" <<
m_maxTracks <<
"), skipping vertexing and returning only dummy..." );
197 return std::make_pair(theVertexContainer, theVertexAuxContainer);
201 unsigned int seedtracknumber=seedTracks.size();
243 seedBegin=seedTracks.begin();
244 seedEnd=seedTracks.end();
246 if (seedtracknumber ==0)
248 ATH_MSG_DEBUG(
" New iteration. No tracks available after track selection for seeding. No finding done." );
257 std::vector<const Trk::TrackParameters*> perigeeList;
259 seedtrkAtVtxIter!=seedEnd;++seedtrkAtVtxIter) {
260 perigeeList.push_back( (*seedtrkAtVtxIter)->parameters() );
269 std::unique_ptr<Trk::IMode3dInfo>
info;
276 std::vector<float> FsmwX, FsmwY, FsmwZ, wght ;
279 double cXY = -9.9, cZ = -9.9 ;
280 info->getCorrelationDistance( cXY, cZ ) ;
287 m_seedX->push_back( seedVertex.x() ) ;
288 m_seedY->push_back( seedVertex.y() ) ;
289 m_seedZ->push_back( seedVertex.z() ) ;
297 looseConstraintCovariance.setIdentity();
298 looseConstraintCovariance = looseConstraintCovariance * 1
e+8;
307 " at y: " << seedVertex.y() <<
308 " at z: " << seedVertex.z() );
311 if ( seedVertex.z()==0. ) {
313 ATH_MSG_DEBUG(
"No seed found: no further vertices in event" );
314 ATH_MSG_DEBUG(
"Number of input tracks: " << perigeeList.size() <<
" but no seed returned." );
330 std::vector<const Trk::TrackParameters*> perigeesToFit;
331 std::vector<const Trk::TrackParameters*> perigeesToFitSplitVertex;
333 int numberOfTracks( perigeeList.size() );
335 std::vector<const Trk::TrackParameters*>::const_iterator perigeeListBegin=perigeeList.begin();
336 std::vector<const Trk::TrackParameters*>::const_iterator perigeeListEnd=perigeeList.end();
339 for (std::vector<const Trk::TrackParameters*>::const_iterator perigeeListIter=perigeeListBegin;
340 perigeeListIter!=perigeeListEnd;++perigeeListIter)
343 if (numberOfTracks<=2)
345 perigeesToFit.push_back(*perigeeListIter);
350 perigeesToFit.push_back(*perigeeListIter);
358 perigeesToFit.push_back(*perigeeListIter);
363 perigeesToFitSplitVertex.push_back(*perigeeListIter);
378 ATH_MSG_WARNING(
" ImpactPoint3dEstimator failed to find minimum distance between track and vertex seed: " <<
err.p );
389 double doe = 99999999.9 ;
392 if( myPerigee && myPerigee->covariance() )
414 perigeesToFit.push_back(*perigeeListIter);
419 perigeesToFitSplitVertex.push_back(*perigeeListIter);
430 ATH_MSG_VERBOSE(
" Considering n. " << perigeesToFit.size() <<
" tracks for the fit. " );
433 ATH_MSG_VERBOSE(
" and n. " << perigeesToFitSplitVertex.size() <<
" tracks for split vertex fit. " );
444 if (perigeesToFit.empty())
447 ATH_MSG_DEBUG(
" No good seed found. Exiting search for vertices..." );
451 theVertexContainer->
push_back( seededxAODVertex );
455 dummyCovariance.setIdentity();
457 seededxAODVertex->
vxTrackAtVertex() = std::vector<Trk::VxTrackAtVertex>();
461 mDecor_mass( *seededxAODVertex ) =
m_v0mass ;
462 mDecor_energy( *seededxAODVertex ) =
m_v0ee ;
463 mDecor_NumTrk( *seededxAODVertex ) =
m_ntracks ;
464 mDecor_HitsFilter( *seededxAODVertex ) =
m_hif ;
465 mDecor_direction( *seededxAODVertex ) =
m_dir ;
466 mDecor_intrk( *seededxAODVertex ) = numberOfTracks ;
481 if ( perigeesToFit.size()>1)
494 bool goodVertex = myxAODVertex !=
nullptr &&
m_ndf >0 &&
m_ntracks >=2 ;
497 ATH_MSG_DEBUG(
" xAOD::Vertex : " << ( myxAODVertex !=
nullptr ? 1 : 0 )
498 <<
", #dof = " <<
m_ndf <<
", #tracks (weight>0.01) = " <<
m_ntracks );
505 ATH_MSG_DEBUG(
" Going to new iteration with: " << seedTracks.size() <<
" seed tracks after BAD VERTEX. " );
514 theVertexContainer->
push_back( myxAODVertex );
515 mDecor_mass( *myxAODVertex ) =
m_v0mass ;
516 mDecor_energy( *myxAODVertex ) =
m_v0ee ;
517 mDecor_NumTrk( *myxAODVertex ) =
m_ntracks ;
518 mDecor_HitsFilter( *myxAODVertex ) =
m_hif ;
519 mDecor_direction( *myxAODVertex ) =
m_dir ;
520 mDecor_intrk( *myxAODVertex ) = numberOfTracks ;
531 theVertexContainer->
push_back( seededxAODVertex );
535 dummyCovariance.setIdentity();
537 seededxAODVertex->
vxTrackAtVertex() = std::vector<Trk::VxTrackAtVertex>();
541 mDecor_mass( *seededxAODVertex ) =
m_v0mass ;
542 mDecor_energy( *seededxAODVertex ) =
m_v0ee ;
543 mDecor_NumTrk( *seededxAODVertex ) =
m_ntracks ;
544 mDecor_HitsFilter( *seededxAODVertex ) =
m_hif ;
545 mDecor_direction( *seededxAODVertex ) =
m_dir ;
546 mDecor_intrk( *seededxAODVertex ) = numberOfTracks ;
556 mDecor_nrobbed( *myxAODVertex ) = 0 ;
561 ATH_MSG_VERBOSE(
" N tracks used for fit before reallocating: " << perigeesToFit.size() );
566 int numberOfAddedTracks=0;
567 const AmgSymMatrix(3) covariance = (&(*myxAODVertex))->covariancePosition() ;
568 const Amg::Vector3D position = (&(*myxAODVertex))->position() ;
581 std::vector<Trk::VxTrackAtVertex>* myVxTracksAtVtx=(&(*vxIter)->vxTrackAtVertex());
583 if ( ! myVxTracksAtVtx )
continue;
587 const AmgSymMatrix(3) oldcovariance = (*vxIter)->covariancePosition() ;
591 std::vector<Trk::VxTrackAtVertex>::const_iterator tracksBegin=myVxTracksAtVtx->begin();
592 std::vector<Trk::VxTrackAtVertex>::const_iterator tracksEnd=myVxTracksAtVtx->end();
595 ATH_MSG_VERBOSE(
" Iterating over new vertex to look for tracks to reallocate... " );
598 for (std::vector<Trk::VxTrackAtVertex>::const_iterator tracksIter=tracksBegin;
599 tracksIter!=tracksEnd;)
611 if (trackPerigee==
nullptr)
613 ATH_MSG_ERROR(
" Cast to perigee gives 0 pointer, cannot continue " );
614 return invalidResponse;
618 double chi2_newvtx=
compatibility(*trackPerigee, covariance, position );
619 double chi2_oldvtx=
compatibility(*trackPerigee, oldcovariance, oldposition );
621 double minDist =
VrtVrtDist( myxAODVertex, *vxIter ) ;
625 " to new vtx is: " << chi2_newvtx );
630 if ( chi2_newvtx < chi2_oldvtx
636 ATH_MSG_DEBUG(
" Found track of old vertex (chi2= " << chi2_oldvtx <<
637 ") more compatible to new one (chi2= " << chi2_newvtx <<
")" );
640 perigeesToFit.push_back(trackPerigee);
649 origIter!=origEnd;++origIter)
651 if ( (*origIter)->parameters()==trackPerigee )
654 ATH_MSG_VERBOSE(
" found the old perigee to be re-added to seedTracks in order to be deleted again!" );
657 seedTracks.push_back(*origIter);
664 ATH_MSG_WARNING(
" Cannot find old perigee to re-add back to seed tracks... " );
667 numberOfAddedTracks+=1;
677 tracksIter=myVxTracksAtVtx->erase(tracksIter);
678 tracksBegin=myVxTracksAtVtx->begin();
679 tracksEnd=myVxTracksAtVtx->end();
687 if ( nrobbed > 0 ) mDecor_nrobbed( *(*vxIter) ) ++;
692 ATH_MSG_VERBOSE(
" N tracks used for fit after reallocating: " << perigeesToFit.size() );
698 if ( numberOfAddedTracks > 0 )
701 ATH_MSG_DEBUG(
" refit with additional " << numberOfAddedTracks
702 <<
" from other vertices " );
707 myxAODVertex=
nullptr;
709 if ( perigeesToFit.size()>1)
712 mDecor_nrobbed( *myxAODVertex ) = 0 ;
717 goodVertex = myxAODVertex !=
nullptr &&
m_ndf >0 &&
m_ntracks >=2 ;
720 ATH_MSG_DEBUG(
" Refitted xAODVertex is pointer: " << myxAODVertex <<
721 " #dof = " <<
m_ndf <<
" #tracks (with weight>0.01) " <<
m_ntracks );
731 theVertexContainer->
push_back(myxAODVertex);
734 mDecor_mass( *myxAODVertex ) =
m_v0mass ;
735 mDecor_energy( *myxAODVertex ) =
m_v0ee ;
736 mDecor_HitsFilter( *myxAODVertex ) =
m_hif ;
737 mDecor_direction( *myxAODVertex ) =
m_dir ;
738 mDecor_NumTrk( *myxAODVertex ) =
m_ntracks ;
739 mDecor_intrk( *myxAODVertex ) = numberOfTracks ;
749 ATH_MSG_DEBUG(
" Adding tracks resulted in an invalid vertex. Should be rare... " );
750 ATH_MSG_DEBUG(
" Going to new iteration with " << seedTracks.size()
751 <<
" seed tracks after BAD VERTEX. " );
756 theVertexContainer->
push_back( seededxAODVertex );
759 seededxAODVertex->
vxTrackAtVertex() = std::vector<Trk::VxTrackAtVertex>();
763 mDecor_NumTrk( *seededxAODVertex ) =
m_ntracks ;
764 mDecor_mass( *seededxAODVertex ) =
m_v0mass ;
765 mDecor_energy( *seededxAODVertex ) =
m_v0ee ;
766 mDecor_HitsFilter( *seededxAODVertex ) =
m_hif ;
767 mDecor_direction( *seededxAODVertex ) =
m_dir ;
768 mDecor_intrk( *seededxAODVertex ) = numberOfTracks ;
790 mDecor_HitsFilter( *myxAODVertex ) =
m_hif ;
791 mDecor_direction( *myxAODVertex ) =
m_dir ;
792 mDecor_NumTrk( *myxAODVertex ) =
m_ntracks ;
806 mDecor_mass( *myxAODVertex ) =
m_v0mass ;
807 mDecor_energy( *myxAODVertex ) =
m_v0ee ;
808 mDecor_intrk( *myxAODVertex ) = numberOfTracks ;
821 * groomed = * myxAODVertex ;
832 delete myxAODVertex ;
840 bool goodgroom = false ;
842 if ( perigeesToFit.size() >= 2 )
849 goodgroom = ( groomed !=
nullptr &&
m_ndf > 0 && ngroom >= 2 ) ;
852 if ( perigeesToFit.size() < 2 || ! goodgroom )
855 theVertexContainer->
push_back(myxAODVertex);
857 if ( perigeesToFit.size() < 2 || ngroom < 1 )
862 mDecor_HitsFilter( *myxAODVertex ) =
m_hif ;
863 mDecor_NumTrk( *myxAODVertex ) =
m_ntracks ;
877 * myxAODVertex = * groomed ;
883 ATH_MSG_DEBUG(
" new vertex after grooming with reminded tracks : " << ngroom
904 mDecor_mass( *myxAODVertex ) =
m_v0mass ;
905 mDecor_energy( *myxAODVertex ) =
m_v0ee ;
906 mDecor_intrk( *myxAODVertex ) = numberOfTracks ;
908 mDecor_HitsFilter( *myxAODVertex ) =
m_hif ;
909 mDecor_direction( *myxAODVertex ) =
m_dir ;
910 mDecor_NumTrk( *myxAODVertex ) = ngroom ;
918 <<
" with VxType : " << myxAODVertex->
vertexType() );
922 mDecor_HitsFilter( *myxAODVertex ) =
m_hif ;
933 ATH_MSG_VERBOSE(
"Number of seeds after removal of outliers: " << seedTracks.size() );
938 theVertexContainer->
push_back(myxAODVertex);
967 std::vector<Trk::VxTrackAtVertex>* myVxTracksAtVtx = &((*vxIter)->vxTrackAtVertex());
968 if ( !myVxTracksAtVtx )
974 int nrobbed = mDecor_nrobbed (**vxIter);
981 std::vector<Trk::VxTrackAtVertex>::const_iterator tracksBegin=myVxTracksAtVtx->begin();
982 std::vector<Trk::VxTrackAtVertex>::const_iterator tracksEnd=myVxTracksAtVtx->end();
984 std::vector<const Trk::TrackParameters*> perigeesToFit ;
985 std::vector<Trk::ITrackLink*> nullseedTracks ;
987 for (std::vector<Trk::VxTrackAtVertex>::const_iterator tracksIter=tracksBegin;
988 tracksIter!=tracksEnd;++tracksIter)
990 for (std::vector<Trk::ITrackLink*>::const_iterator origtrkiter=origtrkbegin;
991 origtrkiter!=origtrkend;++origtrkiter)
993 if ((*origtrkiter)->parameters()==(*tracksIter).initialPerigee())
996 nullseedTracks.push_back( *origtrkiter ) ;
997 perigeesToFit.push_back( (*origtrkiter)->parameters() ) ;
1003 QxAODVertex =
m_iVertexFitter->fit( perigeesToFit, (*vxIter)->position() );
1004 if ( QxAODVertex ==
nullptr )
1012 float chi2dof1 = (*vxIter)->chiSquared()/(*vxIter)->numberDoF() ;
1017 oldhf = mDecor_HitsFilter (**vxIter);
1018 if ( chi2dof2 >= chi2dof1 )
1024 int nit = mDecor_intrk (**vxIter);
1025 *(*vxIter) = *QxAODVertex ;
1028 mDecor_mass( *(*vxIter) ) =
m_v0mass ;
1029 mDecor_energy( *(*vxIter) ) =
m_v0ee ;
1030 mDecor_intrk( *(*vxIter) ) = nit ;
1035 mDecor_HitsFilter( *(*vxIter) ) = oldhf ;
1036 mDecor_direction( *(*vxIter) ) =
m_dir ;
1037 mDecor_NumTrk( *(*vxIter) ) = ntrk ;
1043 vxIter = theVertexContainer->
erase( vxIter ) ;
1044 vxBegin=theVertexContainer->
begin();
1045 vxEnd=theVertexContainer->
end();
1052 delete QxAODVertex ;
1061 ATH_MSG_DEBUG(
" filled " << nv <<
" 'th vertex : x= " << (*vxIter)->position().x() <<
" , y= "
1062 << (*vxIter)->position().y() <<
" , z= " << (*vxIter)->position().z()
1063 <<
" vxType = " << (*vxIter)->vertexType() ) ;
1065 std::vector<float> trkWght ;
1067 std::vector<Trk::VxTrackAtVertex>* myVxTracksAtVtx = &((*vxIter)->vxTrackAtVertex());
1069 if ( ! myVxTracksAtVtx )
1072 mDecor_trkDOE( *(*vxIter) ) = trkWght ;
1073 mDecor_trkWght( *(*vxIter) ) = trkWght ;
1074 mDecor_sumPt2( *(*vxIter) ) = -99.9 ;
1075 mDecor_nrobbed( *(*vxIter) ) = 0 ;
1081 std::vector<float> xdoe ;
1087 tracksIter!=tracksEnd;++tracksIter)
1089 bool found = false ;
1091 trkWght.push_back( (*tracksIter).weight() ) ;
1095 origtrkiter!=origtrkend;++origtrkiter)
1098 if ((*origtrkiter)->parameters()==(*tracksIter).initialPerigee())
1111 pt2 +=
pt*
pt*0.000001 ;
1117 std::unique_ptr<Trk::PlaneSurface> mySurface=
1127 if( svperigee->covariance() )
1136 (*tracksIter).setOrigTrack (*origtrkiter );
1144 (*vxIter)->addTrackAtVertex(*linkToXAODTP, (*tracksIter).weight());
1148 origTracks.erase(origtrkiter);
1149 origtrkbegin=origTracks.begin();
1150 origtrkend=origTracks.end();
1157 ATH_MSG_ERROR(
" Cannot find vector element to fix links (step 4)! " );
1167 mDecor_trkWght( *vtx ) = trkWght ;
1168 mDecor_trkDOE( *vtx ) = xdoe ;
1171 mDecor_sumPt2( *vtx ) = pt2 ;
1175 ATH_MSG_DEBUG(
" #Vtx "<< theVertexContainer->
size() <<
" with track-vertex association fixed " );
1178 for (
unsigned int i = 0 ;
i < theVertexContainer->
size() ;
i++)
1182 " x= " << (*theVertexContainer)[
i]->position().
x() <<
1183 " y= " << (*theVertexContainer)[
i]->position().
y() <<
1184 " z= " << (*theVertexContainer)[
i]->position().
z() <<
1185 " ntracks= " << (*theVertexContainer)[
i]->vxTrackAtVertex().
size() <<
1186 " chi2= " << (*theVertexContainer)[
i]->
chiSquared() <<
1187 " #dof = " << (*theVertexContainer)[
i]->numberDoF() );
1191 origtrkiter!=origtrkend;++origtrkiter)
1193 if ((*origtrkiter)!=0) {
1194 delete *origtrkiter;
1203 return std::make_pair(theVertexContainer, theVertexAuxContainer);
1207 float &
mass,
float &modir )
const
1212 int ntrk = momenta.size() ;
1220 std::vector<double> Pv (ntrk);
1221 double vx = 0., vy = 0., vz = 0., eK0 = 0. ;
1222 double pi2 = 139.57018*139.57018 ;
1224 for (
int t = 0 ;
t < ntrk ;
t ++ )
1231 Pv[
t] = trk.x()*trk.x() + trk.y()*trk.y() + trk.z()*trk.z() ;
1232 eK0 += std::sqrt( Pv[
t] +
pi2 ) ;
1235 double mnt2 = vx*vx + vy*vy + vz*vz ;
1236 mass = eK0*eK0 - mnt2 ;
1242 modir = vmoment.dot( vdif )/std::sqrt( mnt2 ) ;
1245 double a0z = ( vdif + vmoment*vmoment.dot( vdif )/( mnt2 + 0.00001 ) ).z() ;
1246 double Rxy = vdif.perp() ;
1248 ATH_MSG_DEBUG(
" V0kine : a0z = " << a0z <<
" Rxy = " << Rxy <<
" direction "<< modir );
1256 if ( a0z > 15. || Rxy > 500. ) {
return false ; }
1261 double eGam = std::sqrt( Pv[0] + 0.511*0.511 ) + std::sqrt( Pv[1] + 0.511*0.511 ) ;
1262 double mGam = eGam*eGam - mnt2 ;
1264 double prtn2 = 938.27205*938.27205 ;
1265 double eLam = Pv[0] > Pv[1] ? std::sqrt( Pv[0] + prtn2 ) + std::sqrt( Pv[1] +
pi2 ) :
1266 sqrt( Pv[0] +
pi2 ) + std::sqrt( Pv[1] + prtn2 ) ;
1267 double mLam = eLam*eLam - mnt2 ;
1270 <<
" "<< ( mGam >= 0 ? std::sqrt( mGam ) : std::sqrt( -mGam ) )
1271 <<
" "<< ( mLam >= 0 ? std::sqrt( mLam ) : std::sqrt( -mLam ) ) );
1273 if ( ( std::abs(
mass - 497.614 ) < 100. )
1274 || ( mGam > 0 && sqrt( mGam ) < 40. )
1275 || ( mLam > 0 && std::abs( sqrt( mLam ) - 1115.683 ) < 200. )
1288 AmgSymMatrix(3) vErrs = v1->covariancePosition() +
v2->covariancePosition() ;
1290 vErrs = vErrs.inverse().eval();
1292 dist = vdif.dot( vErrs * vdif ) ;
1323 outsidePixelBarrel0_and_insidePixelBarrel1,
1326 outsidePixelBarrel1_and_insidePixelBarrel2,
1329 outsidePixelBarrel2_and_insidePixelBarrel3,
1332 outsidePixelBarrel3_and_insideSctBarrel0,
1335 outsideSctBarrel0_and_insideSctBarrel1,
1341 int vertex_pattern = 0;
1343 vertex_pattern = insideBeamPipe;
1344 }
else if(
rad < 31.0 && absz < 331.5 ) {
1345 vertex_pattern = insidePixelBarrel0;
1346 }
else if(
rad < 38.4 && absz < 331.5 ) {
1347 vertex_pattern = aroundPixelBarrel0;
1348 }
else if(
rad < 47.7 && absz < 400.5 ) {
1349 vertex_pattern = outsidePixelBarrel0_and_insidePixelBarrel1;
1350 }
else if(
rad < 54.4 && absz < 400.5 ) {
1351 vertex_pattern = aroundPixelBarrel1;
1352 }
else if(
rad < 85.5 && absz < 400.5 ) {
1353 vertex_pattern = outsidePixelBarrel1_and_insidePixelBarrel2;
1354 }
else if(
rad < 92.2 && absz < 400.5 ) {
1355 vertex_pattern = aroundPixelBarrel2;
1356 }
else if(
rad < 119.3 && absz < 400.5 ) {
1357 vertex_pattern = outsidePixelBarrel2_and_insidePixelBarrel3;
1358 }
else if(
rad < 126.1 && absz < 400.5 ) {
1359 vertex_pattern = aroundPixelBarrel3;
1360 }
else if(
rad < 290 && absz < 749.0 ) {
1361 vertex_pattern = outsidePixelBarrel3_and_insideSctBarrel0;
1362 }
else if(
rad < 315 && absz < 749.0 ) {
1363 vertex_pattern = aroundSctBarrel0;
1364 }
else if(
rad < 360 && absz < 749.0 ) {
1365 vertex_pattern = outsideSctBarrel0_and_insideSctBarrel1;
1366 }
else if(
rad < 390 && absz < 749.0 ) {
1367 vertex_pattern = aroundSctBarrel1;
1369 vertex_pattern = insideSilicon ;
1379 if ( tpperigee[4] != perigee->parameters()[
Trk::qOverP]
1380 || tpperigee[3] != perigee->parameters()[
Trk::theta]
1381 || tpperigee[2] != perigee->parameters()[
Trk::phi]
1382 || tpperigee[1] != perigee->parameters()[
Trk::z0]
1387 uint32_t HitPattern= tpperigee[0] ;
1397 if( vertex_pattern == insideBeamPipe ) {
1401 }
else if( vertex_pattern == insidePixelBarrel0 ) {
1406 else if( vertex_pattern == aroundPixelBarrel0 ) {
1411 else if( vertex_pattern == outsidePixelBarrel0_and_insidePixelBarrel1 ) {
1417 else if( vertex_pattern == aroundPixelBarrel1 ) {
1424 else if( vertex_pattern == outsidePixelBarrel1_and_insidePixelBarrel2 ) {
1431 else if( vertex_pattern == aroundPixelBarrel2 ) {
1439 else if( vertex_pattern == outsidePixelBarrel2_and_insidePixelBarrel3 ) {
1447 else if( vertex_pattern == aroundPixelBarrel3 ) {
1456 else if( vertex_pattern == outsidePixelBarrel3_and_insideSctBarrel0 ) {
1465 else if( vertex_pattern == aroundSctBarrel0 ) {
1475 else if( vertex_pattern == outsideSctBarrel0_and_insideSctBarrel1 ) {
1485 else if( vertex_pattern == aroundSctBarrel1 ) {
1526 SmartIF<ITHistSvc> hist_root{Gaudi::svcLocator()->service(
"THistSvc")};
1530 m_sdFsmwX =
new std::vector< std::vector < float > >() ;
1531 m_sdFsmwY =
new std::vector< std::vector < float > >() ;
1532 m_sdFsmwZ =
new std::vector< std::vector < float > >() ;
1533 m_sdcrsWght =
new std::vector< std::vector < float > >() ;
1536 m_seedX =
new std::vector < float >() ;
1537 m_seedY =
new std::vector < float >() ;
1538 m_seedZ =
new std::vector < float >() ;
1541 m_seedac =
new std::vector < int >() ;
1543 m_OTree =
new TTree(
"IncSecVtxUnder",
"TTree of underlying/upstream techinfo for InclusiveSecVtx" ) ;
1574 return StatusCode::SUCCESS;
1580 ATH_MSG_DEBUG(
" Number of input tracks before track selection: " << trackTES->
size() );
1582 std::vector<Trk::ITrackLink*> selectedTracks;
1586 bool selectionPassed;
1587 for (TrackDataVecIter itr = (*trackTES).begin(); itr != (*trackTES).end(); ++itr) {
1589 selectionPassed=
static_cast<bool>(
m_trkFilter->accept(**itr,&
null));
1590 if ( selectionPassed ) selectionPassed=
static_cast<bool>(
m_SVtrkFilter->accept(**itr,&
null));
1591 if (selectionPassed)
1597 selectedTracks.push_back(linkTT);
1602 << selectedTracks.size() <<
" survived the preselection." );
1605 std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*> returnContainers
1608 return returnContainers;
1614 ATH_MSG_DEBUG(
" Number of input tracks before track selection: " << trackTES->
size() );
1616 std::vector<Trk::ITrackLink*> selectedTracks;
1621 bool selectionPassed;
1622 for (TrackParticleDataVecIter itr = (*trackTES).begin(); itr != (*trackTES).end(); ++itr) {
1625 selectionPassed=
static_cast<bool>(
m_trkFilter->accept( *((*itr)->originalTrack()), &
null));
1626 if ( selectionPassed ) selectionPassed =
static_cast<bool>(
m_SVtrkFilter->accept( *((*itr)->originalTrack()), &
null));
1628 if (selectionPassed)
1634 selectedTracks.push_back(linkTT);
1639 << selectedTracks.size() <<
" survived the preselection." );
1641 std::pair<xAOD::VertexContainer*, xAOD::VertexAuxContainer*> returnContainers
1644 return returnContainers;
1682 return StatusCode::SUCCESS;
1687 ATH_MSG_DEBUG(
"InDetIterativeSecVtxFinderTool initialize(): Parametersettings " );
1699 double returnValue = 0. ;
1702 &measPerigee, position );
1706 AmgMatrix(2,2) weightReduced=myLinearizedTrack->expectedCovarianceAtPCA().block<2,2>(0,0);
1708 AmgMatrix(2,2) errorVertexReduced=(myLinearizedTrack->positionJacobian()*
1709 ( covariancePosition*myLinearizedTrack->positionJacobian().transpose())).block<2,2>(0,0);
1711 weightReduced+=errorVertexReduced;
1713 weightReduced = weightReduced.inverse().eval();
1714 Amg::Vector2D trackParameters2D = myLinearizedTrack->expectedParametersAtPCA().block<2,1>(0,0);
1715 returnValue += trackParameters2D.dot(weightReduced*trackParameters2D);
1717 delete myLinearizedTrack;
1718 myLinearizedTrack=
nullptr;
1724 std::vector<Trk::ITrackLink*> & seedTracks)
const
1735 perigeesToFitIter!=perigeesToFitEnd;++perigeesToFitIter)
1738 ATH_MSG_VERBOSE(
" Iterating on new track in original perigeesToFit list of BAD VERTEX..." );
1744 seedIter!=seedEnd;++seedIter)
1746 if ((*seedIter)->parameters()==*perigeesToFitIter)
1752 seedTracks.erase(seedIter);
1753 seedBegin=seedTracks.begin();
1754 seedEnd=seedTracks.end();
1761 ATH_MSG_ERROR(
" Cannot find vector element to delete when removing BAD vertex! " );
1769 float &
ndf,
int & ntrk)
const
1777 std::vector<Trk::VxTrackAtVertex> myVxTracksAtVtx = myxAODVertex->
vxTrackAtVertex();
1782 tracksIter!=tracksEnd;++tracksIter)
1794 std::vector<const Trk::TrackParameters*> & perigeesToFit )
const
1798 std::vector<Trk::VxTrackAtVertex>* tracksAtVertex= &(myxAODVertex->
vxTrackAtVertex());
1800 int tot = tracksAtVertex->size() ;
1801 ATH_MSG_DEBUG(
" removeTracksInBadSeed ... #Tracks associated at vertex : " << tot );
1803 if ( tot == 0 )
return 0. ;
1805 std::vector<Trk::VxTrackAtVertex>::const_iterator tracksBegin=tracksAtVertex->begin();
1806 std::vector<Trk::VxTrackAtVertex>::const_iterator tracksEnd=tracksAtVertex->end();
1814 float pt_tot = 0. , pt_hf = 0. ;
1816 std::vector<const Trk::TrackParameters*> perigees_deleted ;
1817 for (std::vector<Trk::VxTrackAtVertex>::const_iterator tracksAtVertexIter=tracksBegin;
1818 tracksAtVertexIter!=tracksEnd;++tracksAtVertexIter)
1820 if ( (*tracksAtVertexIter).weight() <=
m_minWghtAtVtx ) continue ;
1824 if ( measPerigee ==
nullptr ) continue ;
1827 bool hf =
passHitsFilter( measPerigee, position.perp(), std::abs( position.z() ) ) ;
1836 if ( hf ) continue ;
1838 ATH_MSG_DEBUG(
" found and will delete from perigeesToFit !" );
1840 auto found=
std::find(perigeesToFitBegin,perigeesToFitEnd,measPerigee);
1841 if(
found!=perigeesToFitEnd){
1842 perigees_deleted.push_back(*
found);
1843 perigeesToFit.erase(
found);
1844 perigeesToFitBegin=perigeesToFit.begin();
1845 perigeesToFitEnd=perigeesToFit.end();
1851 if ( tot == 0 || pt_tot == 0. )
return 0. ;
1855 perigeesToFitIter!=perigees_deleted.end();++perigeesToFitIter)
1857 for (std::vector<Trk::VxTrackAtVertex>::const_iterator tracksAtVertexIter=tracksBegin;
1858 tracksAtVertexIter!=tracksEnd;++tracksAtVertexIter)
1862 if (*perigeesToFitIter==measPerigee)
1864 tracksAtVertex->erase( tracksAtVertexIter );
1865 tracksBegin=tracksAtVertex->begin();
1866 tracksEnd=tracksAtVertex->end();
1874 ATH_MSG_DEBUG(
" Bad tracks removed from seed : " << removed );
1875 return 0.4*removed/( 1.0*tot ) + 0.6*pt_hf/pt_tot ;
1881 std::vector< Amg::Vector3D > TrkAtVtxMomenta ;
1883 std::vector<Trk::VxTrackAtVertex>* tracksAtVertex= &(myxAODVertex->
vxTrackAtVertex());
1885 ATH_MSG_DEBUG(
" getVertexMomenta ... #Tracks associated at vertex : " << tracksAtVertex->size() );
1887 std::vector<Trk::VxTrackAtVertex>::const_iterator tracksAtVertexBegin=tracksAtVertex->begin();
1888 std::vector<Trk::VxTrackAtVertex>::const_iterator tracksAtVertexEnd=tracksAtVertex->end();
1890 for (std::vector<Trk::VxTrackAtVertex>::const_iterator tracksAtVertexIter=tracksAtVertexBegin;
1891 tracksAtVertexIter!=tracksAtVertexEnd;++tracksAtVertexIter)
1893 if ((*tracksAtVertexIter).weight() <=
m_minWghtAtVtx ) continue ;
1897 double qp = 1/std::abs( sv_perigee->parameters()[
Trk::qOverP] ) ;
1898 double theta = sv_perigee->parameters()[
Trk::theta];
1899 double phi = sv_perigee->parameters()[
Trk::phi];
1911 std::vector<const Trk::TrackParameters*> & perigeesToFit,
1912 std::vector<Trk::ITrackLink*> & seedTracks)
const
1916 std::vector<Trk::VxTrackAtVertex>* tracksAtVertex= &(myxAODVertex->
vxTrackAtVertex());
1918 ATH_MSG_VERBOSE(
" removeCompatibleTracks ... #Tracks associated at vertex : " << tracksAtVertex->size() );
1920 std::vector<Trk::VxTrackAtVertex>::const_iterator tracksAtVertexBegin=tracksAtVertex->begin();
1921 std::vector<Trk::VxTrackAtVertex>::const_iterator tracksAtVertexEnd=tracksAtVertex->end();
1929 const AmgSymMatrix(3) covariance = myxAODVertex->covariancePosition() ;
1932 for (std::vector<Trk::VxTrackAtVertex>::const_iterator tracksAtVertexIter=tracksAtVertexBegin;
1933 tracksAtVertexIter!=tracksAtVertexEnd;++tracksAtVertexIter)
1943 seedIter!=seedEnd;++seedIter)
1945 if ((*seedIter)->parameters()==(*tracksAtVertexIter).initialPerigee() )
1953 seedTracks.erase(seedIter);
1954 seedBegin=seedTracks.begin();
1955 seedEnd=seedTracks.end();
1963 ATH_MSG_ERROR(
" Cannot find vector element to delete (step 1)! " );
1968 perigeesToFitIter!=perigeesToFitEnd;++perigeesToFitIter)
1970 if (*perigeesToFitIter==(*tracksAtVertexIter).initialPerigee())
1979 perigeesToFit.erase(perigeesToFitIter);
1980 perigeesToFitBegin=perigeesToFit.begin();
1981 perigeesToFitEnd=perigeesToFit.end();
1988 #ifndef MONITORTUNES
1991 ATH_MSG_WARNING(
" Cannot find vector element to delete (step 2)! " );
1998 ATH_MSG_DEBUG(
" Outliers still to be considered: " << perigeesToFit.size() );
2000 ATH_MSG_VERBOSE(
"Number of seedtracks after removal of inliers: " << seedTracks.size() );
2004 std::vector<Trk::VxTrackAtVertex>* myVxTracksAtVertex= &(myxAODVertex->
vxTrackAtVertex());
2010 perigeesToFitIter!=perigeesToFitEnd;++perigeesToFitIter)
2020 if (myPerigee==
nullptr)
2039 " to be removed from the seeds... " );
2044 seedIter!=seedEnd;++seedIter)
2046 if ((*seedIter)->parameters()==*perigeesToFitIter)
2052 seedTracks.erase(seedIter);
2053 seedBegin=seedTracks.begin();
2054 seedEnd=seedTracks.end();
2061 ATH_MSG_ERROR(
" Cannot find vector element to delete (step 3)! " );
2071 " to be further considered and thus to be removed from previous vertex if it was there... " );
2078 tracksIter!=tracksEnd;++tracksIter)
2080 if ((*tracksIter).initialPerigee()==*perigeesToFitIter)
2084 ATH_MSG_VERBOSE(
" OK, removing track with compatibility:" << (*tracksIter).trackQuality().chiSquared() <<
2085 " or vtx compatibility" << (*tracksIter).vtxCompatibility() <<
" which was found attached to the vertex... " );
2092 myVxTracksAtVertex->erase(tracksIter);
2093 tracksBegin=myVxTracksAtVertex->begin();
2094 tracksEnd=myVxTracksAtVertex->end();
2104 ATH_MSG_VERBOSE(
"Track not found: probably it was already not attached to the vertex" );
2110 ATH_MSG_VERBOSE(
" #CompatibleTracks associated at vertex : " << myVxTracksAtVertex->size() );