38 int numRow(
int numVertex) {
44 bool signFlipTreatment) {
46 int numbRow=numRow(numVertex);
54 dist=myPosition[numbRow];
56 dist=dist/fabs(dist)*300./
sin(
theta);
59 if (signFlipTreatment) {
75 m_linearizedFactory(
"Trk::FullLinearizedTrackFactory", this),
76 m_errphiJetAxis(0.07),
77 m_erretaJetAxis(0.065)
82 declareInterface< JetFitterInitializationHelper >(
this) ;
98 return StatusCode::FAILURE;
102 return StatusCode::SUCCESS;
124 std::vector<Trk::VxTrackAtVertex*>* setOfTracks=myJetCandidate->
vxTrackAtVertex();
126 std::vector<const Trk::ITrackLink*>::const_iterator vectorOfLinkBegin=vectorOfLink.begin();
127 std::vector<const Trk::ITrackLink*>::const_iterator vectorOfLinkEnd=vectorOfLink.end();
129 for (std::vector<const Trk::ITrackLink*>::const_iterator vectorOfLinkIter=vectorOfLinkBegin;
130 vectorOfLinkIter!=vectorOfLinkEnd;++vectorOfLinkIter)
132 std::vector<Trk::VxTrackAtVertex*> temp_vector_tracksAtVertex;
134 temp_vector_tracksAtVertex.push_back(newVxTrack);
135 setOfTracks->push_back(newVxTrack);
147 const RecVertex* primaryVertex,
155 VxJetCandidate* myJetCandidate=
new VxJetCandidate(vectorOfTP);
185 if (primaryVertex==
nullptr) {
186 std::cout <<
"ERROR. No valid primary vertex pointer provided to the JetFitterInitializationHelper." << std::endl;
187 throw std::runtime_error (
"No valid primary vertex pointer provided to the JetFitterInitializationHelper.");
194 if (jetdirection!=
nullptr) {
198 std::cout <<
"JetFitterInitializationHelper: Error! no starting jet direction provided. Using (0,0)" << std::endl;
219 AmgSymMatrix(3) primaryCovariance(primaryVertex->covariancePosition().block<3,3>(0,0));
220 AmgSymMatrix(5) startCovariance; startCovariance.setZero();
221 startCovariance.block<3,3>(0,0) = primaryCovariance;
226 RecVertexPositions startRecVertexPositions(startPosition,
231 myJetCandidate->setRecVertexPositions(startRecVertexPositions);
232 myJetCandidate->setConstraintVertexPositions(startRecVertexPositions);
234 VertexPositions linVertexPositions;
235 if (linearizationjetdirection!=
nullptr) {
238 linPosition[
Trk::jet_phi]=linearizationjetdirection->phi();
239 linVertexPositions=VertexPositions(linPosition);
241 linVertexPositions=startRecVertexPositions;
250 const VxVertexOnJetAxis* primaryVertexJC(myJetCandidate->
getPrimaryVertex());
252 if (primaryVertexJC==
nullptr) {
255 VxVertexOnJetAxis newPrimaryVertex;
257 newPrimaryVertex.setNumVertex(-10);
266 return myJetCandidate;
272 const std::vector<VxVertexOnJetAxis*> & associatedVertices=myJetCandidate->getVerticesOnJetAxis();
274 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxBegin=associatedVertices.begin();
275 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxEnd=associatedVertices.end();
280 if (!associatedVertices.empty()) {
281 for (std::vector<VxVertexOnJetAxis*>::const_iterator VtxIter=VtxBegin;VtxIter!=VtxEnd;++VtxIter) {
282 VxVertexOnJetAxis* myVertex=(*VtxIter);
283 if (myVertex!=
nullptr) {
284 myVertex->setNumVertex(numTrack);
287 std::cout <<
"Warning in JetFitterInitializationHelper.Inconsistency found. Pointer to VxVertexOnJetAxis should be different from zero. Skipping track..." << std::endl;
288 throw std::runtime_error (
"Warning in JetFitterInitializationHelper.Inconsistency found. Pointer to VxVertexOnJetAxis should be different from zero. Skipping track...");
292 int sizeOfRecVertex=myJetCandidate->getRecVertexPositions().position().rows();
295 if (numRow(numTrack)>sizeOfRecVertex) {
298 myJetCandidate->setRecVertexPositions(myJetCandidate->getConstraintVertexPositions());
300 Amg::VectorX myPosition = myJetCandidate->getRecVertexPositions().position();
301 Amg::MatrixX myCovariance = myJetCandidate->getRecVertexPositions().covariancePosition();
302 Amg::VectorX newPosition(numRow(numTrack)); newPosition.setZero();
303 newPosition.segment(0,myPosition.rows()) = myPosition;
304 Amg::MatrixX newCovariance(numRow(numTrack),numRow(numTrack));
305 newCovariance.setZero();
306 newCovariance.block(0,0,myCovariance.rows(),myCovariance.cols()) = myCovariance;
307 for (
int i=sizeOfRecVertex;
i<numRow(numTrack);++
i) {
308 newCovariance(
i,
i)=500.*500.;
311 RecVertexPositions newRecVertexPositions(newPosition,
313 myJetCandidate->getRecVertexPositions().fitQuality().chiSquared(),
314 myJetCandidate->getRecVertexPositions().fitQuality().numberDoF());
317 Amg::VectorX myPositionLinearization = myJetCandidate->getLinearizationVertexPositions().position();
318 Amg::VectorX newPositionLinearization(numRow(numTrack));
319 newPositionLinearization.setZero();
320 newPositionLinearization.segment(0,myPositionLinearization.rows()) = myPositionLinearization;
322 myJetCandidate->setRecVertexPositions(newRecVertexPositions);
323 myJetCandidate->setConstraintVertexPositions(newRecVertexPositions);
324 myJetCandidate->setLinearizationVertexPositions(newPositionLinearization);
326 }
else if (numRow(numTrack)<sizeOfRecVertex) {
327 std::cout <<
"Strange: size of RecVertexPosition's position in JetFitterInitializationHelper is bigger than actual numTracks plus 5. CHECK..." << std::endl;
328 throw std::runtime_error (
"Strange: size of RecVertexPosition's position in JetFitterInitializationHelper is bigger than actual numTracks plus 5. CHECK...");
336 bool signFlipTreatment,
337 double maxdistance)
const {
339 const VertexPositions & myLinVertexPosition=myJetCandidate->getLinearizationVertexPositions();
340 const Amg::VectorX & myPosition=myLinVertexPosition.position();
342 const VxVertexOnJetAxis* myPrimary=myJetCandidate->getPrimaryVertex();
343 const std::vector<VxTrackAtVertex*> & primaryVectorTracks=myPrimary->getTracksAtVertex();
348 const std::vector<VxTrackAtVertex*>::const_iterator primaryVectorTracksBegin=primaryVectorTracks.begin();
349 const std::vector<VxTrackAtVertex*>::const_iterator primaryVectorTracksEnd=primaryVectorTracks.end();
351 for (std::vector<VxTrackAtVertex*>::const_iterator primaryVectorIter=primaryVectorTracksBegin;
352 primaryVectorIter!=primaryVectorTracksEnd;++primaryVectorIter) {
358 if (linTrack!=
nullptr) {
372 const std::vector<VxVertexOnJetAxis*> & associatedVertices=myJetCandidate->getVerticesOnJetAxis();
374 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxBegin=associatedVertices.begin();
375 const std::vector<VxVertexOnJetAxis*>::const_iterator VtxEnd=associatedVertices.end();
377 for (std::vector<VxVertexOnJetAxis*>::const_iterator VtxIter=VtxBegin;VtxIter!=VtxEnd;++VtxIter) {
379 int numVertex=(*VtxIter)->getNumVertex();
380 Amg::Vector3D secondaryVertexPos(getSingleVtxPositionWithSignFlip(myPosition,numVertex,signFlipTreatment));
384 const std::vector<VxTrackAtVertex*> & tracksAtVertex=(*VtxIter)->getTracksAtVertex();
386 const std::vector<VxTrackAtVertex*>::const_iterator TracksBegin=tracksAtVertex.begin();
387 const std::vector<VxTrackAtVertex*>::const_iterator TracksEnd=tracksAtVertex.end();
389 for (std::vector<VxTrackAtVertex*>::const_iterator TrackVectorIter=TracksBegin;
390 TrackVectorIter!=TracksEnd;++TrackVectorIter) {
394 if (linTrack!=
nullptr) {