17 #include "GaudiKernel/MsgStream.h"
29 #include "GaudiKernel/ThreadLocalContext.h"
83 m_trkfitter(
"Trk::GlobalChi2Fitter/InDetTrackFitter")
86 declareInterface<IInDetTrackSplitterTool>(
this);
106 msg(MSG::WARNING) <<
"Problem retrieving TRTID helper" <<
endmsg;
107 return StatusCode::SUCCESS;
113 msg(MSG::WARNING) <<
"Problem retrieving SCT ID helper" <<
endmsg;
114 return StatusCode::SUCCESS;
121 return StatusCode::SUCCESS;
128 return StatusCode::SUCCESS;
136 return StatusCode::SUCCESS;
143 bool siliconHitsOnly)
const {
158 auto uppertraj = std::make_unique<Trk::TrackStates>();
159 auto lowertraj = std::make_unique<Trk::TrackStates>();
161 unsigned int totalNumberHits = 0;
163 unsigned int totalNumberPixelHits = 0;
164 unsigned int totalNumberSCTHits = 0;
165 unsigned int totalNumberTRTHits = 0;
167 unsigned int numberUpperPixelHits = 0;
168 unsigned int numberUpperSCTHits = 0;
169 unsigned int numberUpperTRTHits = 0;
170 unsigned int numberUpperPseudoMeas = 0;
172 unsigned int numberLowerPixelHits = 0;
173 unsigned int numberLowerSCTHits = 0;
174 unsigned int numberLowerTRTHits = 0;
175 unsigned int numberLowerPseudoMeas = 0;
183 bool perigeeseen=
false;
184 for(;tsosit != tsosEnd; ++tsosit){
186 if (originalPerigee==(**tsosit).trackParameters()){
188 uppertraj->push_back((**tsosit).clone());
189 lowertraj->push_back((**tsosit).clone());
198 uppertraj->push_back((**tsosit).clone());
200 lowertraj->push_back((**tsosit).clone());
215 ++totalNumberPixelHits;
217 ++totalNumberSCTHits;
219 ++totalNumberTRTHits;
225 ++numberUpperPixelHits;
227 ++numberUpperSCTHits;
229 ++numberUpperTRTHits;
233 uppertraj->push_back((**tsosit).clone());
240 ++numberLowerPixelHits;
242 ++numberLowerSCTHits;
244 ++numberLowerTRTHits;
249 lowertraj->push_back((**tsosit).clone());
260 if (!perigeeseen || totalNumberHits == totalNumberTRTHits) {
263 ++numberUpperPseudoMeas;
264 uppertraj->push_back((**tsosit).clone());
266 if (perigeeseen || totalNumberHits == totalNumberTRTHits) {
269 ++numberLowerPseudoMeas;
270 lowertraj->push_back((**tsosit).clone());
278 uppertraj->push_back((**tsosit).clone());
280 lowertraj->push_back((**tsosit).clone());
289 if(
isConstrained(numberUpperPixelHits,numberUpperSCTHits,numberUpperTRTHits,numberUpperPseudoMeas)){
293 upperTrack = (
m_trkfitter->fit(Gaudi::Hive::currentContext(),upperorigtrack,
false, hypo)).
release();
299 << numberUpperPixelHits <<
" upper Pixel hits, "
300 << numberUpperSCTHits <<
" upper SCT hits, "
301 << numberUpperTRTHits <<
"upper TRT hits"
302 << numberUpperPseudoMeas <<
"upper Pseudomeasurements"
306 << totalNumberPixelHits <<
" total Pixel hits, "
307 << totalNumberSCTHits <<
" total SCT hits, "
308 << totalNumberTRTHits <<
"total TRT hits"
316 << numberUpperPixelHits <<
" upper Pixel hits, "
317 << numberUpperSCTHits <<
" upper SCT hits, "
318 << numberUpperTRTHits <<
"upper TRT hits"
319 << numberUpperPseudoMeas <<
"upper Pseudomeasurements"
324 if(
isConstrained(numberLowerPixelHits,numberLowerSCTHits,numberLowerTRTHits,numberLowerPseudoMeas)){
327 lowerTrack = (
m_trkfitter->fit(Gaudi::Hive::currentContext(),lowerorigtrack,
false, hypo)).release();
333 << numberLowerPixelHits <<
" upper Pixel hits, "
334 << numberLowerSCTHits <<
" upper SCT hits, "
335 << numberLowerTRTHits <<
"upper TRT hits"
336 << numberLowerPseudoMeas <<
"upper Pseudomeasurements"
340 << totalNumberPixelHits <<
" total Pixel hits, "
341 << totalNumberSCTHits <<
" total SCT hits, "
342 << totalNumberTRTHits <<
"total TRT hits"
349 << numberLowerPixelHits <<
" upper Pixel hits, "
350 << numberLowerSCTHits <<
" upper SCT hits, "
351 << numberLowerTRTHits <<
"upper TRT hits"
352 << numberLowerPseudoMeas <<
"upper Pseudomeasurements"
357 return std::make_pair(upperTrack, lowerTrack);
363 bool removeSilicon,
bool applyConstraint )
const {
403 TRTHits.push_back(constraint);
405 unsigned int totalNumberTRTHits = 0;
409 for(;meas != measEnd; ++meas){
424 ++totalNumberTRTHits;
425 TRTHits.push_back(*meas);
434 outputTrack = (
m_trkfitter->fit(Gaudi::Hive::currentContext(),TRTHits, *originalPerigee,
true, hypo)).release();
440 << totalNumberTRTHits <<
"TRT hits"
467 bool addedConstraint =
false;
469 unsigned int totalNumberSiHits = 0;
473 for(;meas != measEnd; ++meas){
483 if(applyConstraint && !addedConstraint &&
m_trtid->
is_trt(surfaceid)){
491 ATH_MSG_DEBUG(
"Cast of rio associated surface to StraightLineSurface failed.");
498 SiHits.push_back(constraint);
501 addedConstraint =
true;
510 SiHits.push_back(*meas);
519 outputTrack = (
m_trkfitter->fit(Gaudi::Hive::currentContext(),SiHits, *originalPerigee,
false, hypo)).
release();
535 if( !perigee->covariance() )
return nullptr;
540 std::array<Trk::DefinedParameter,1> constraints = {inputPMeasurement};
548 std::move(constraintErrMatrix) ,*trtSurf);
558 if( !perigee->covariance() )
return nullptr;
564 std::array<Trk::DefinedParameter,2> constraints = {inputZ0Measurement, inputTheta0Measurement};
569 constraintErrMatrix(0,0) = (*perigee->covariance())(
Trk::z0,
Trk::z0);
582 std::move(constraintErrMatrix) ,
612 unsigned int totalNumberPixelHits = 0;
613 unsigned int totalNumberSCTHits = 0;
614 unsigned int totalNumberTRTHits = 0;
615 unsigned int totalNumberHits = 0;
617 unsigned int numberOddSCTHits = 0;
618 unsigned int numberOddPixelHits = 0;
619 unsigned int numberOddTRTHits = 0;
620 unsigned int numberOddPseudoMeas = 0;
622 unsigned int numberEvenPixelHits = 0;
623 unsigned int numberEvenSCTHits = 0;
624 unsigned int numberEvenTRTHits = 0;
625 unsigned int numberEvenPseudoMeas = 0;
628 std::vector<Trk::MeasurementBase const*> unusedSCTHits =
getSCTHits(
input);
632 for(;meas != measEnd; ++meas){
641 if( totalNumberHits % 2 == 1){
649 oddHits.push_back( *meas);
658 if(
result != unusedSCTHits.end()){
661 oddHits.push_back( *meas);
666 unusedSCTHits.erase(
result);
670 if(
result != unusedSCTHits.end()){
672 oddHits.push_back( *
result);
674 unusedSCTHits.erase(
result);
680 ++numberEvenPixelHits;
688 evenHits.push_back( *meas);
696 if(
result != unusedSCTHits.end()){
699 evenHits.push_back( *meas);
704 unusedSCTHits.erase(
result);
708 if(
result != unusedSCTHits.end()){
710 evenHits.push_back( *
result);
712 unusedSCTHits.erase(
result);
722 ++numberOddPseudoMeas;
723 oddHits.push_back( ps);
726 ++numberEvenPseudoMeas;
727 evenHits.push_back( ps);
738 if(
isConstrained(numberOddPixelHits,numberOddSCTHits,numberOddTRTHits,numberOddPseudoMeas)){
741 oddTrack = (
m_trkfitter->fit(Gaudi::Hive::currentContext(),oddHits, *originalPerigee,
false, hypo)).
release();
747 << numberOddPixelHits <<
" odd Pixel hits, "
748 << numberOddSCTHits <<
" odd SCT hits, "
749 << numberOddTRTHits <<
" odd TRT hits"
750 << numberOddPseudoMeas <<
"odd Pseudomeasurements"
754 << totalNumberPixelHits <<
" total Pixel hits, "
755 << totalNumberSCTHits <<
" total SCT hits, "
756 << totalNumberTRTHits <<
"total TRT hits"
764 if(
isConstrained(numberEvenPixelHits,numberEvenSCTHits,numberEvenTRTHits,numberEvenPseudoMeas)){
767 evenTrack = (
m_trkfitter->fit(Gaudi::Hive::currentContext(),evenHits, *originalPerigee,
false, hypo)).release();
773 << numberEvenTRTHits <<
"even TRT hits"<<
endmsg;
776 << totalNumberTRTHits <<
"total TRT hits"<<
endmsg;
783 return std::make_pair(oddTrack, evenTrack);
799 if ( upperTracks.
record( std::make_unique<TrackCollection>() ).isFailure() ) {
804 if ( lowerTracks.
record( std::make_unique<TrackCollection>() ).isFailure() ) {
853 msg(MSG::WARNING) <<
"Found track with invalid perigee parameters. Not splitting." <<
endmsg;
858 double const d0 = trackPerigee->parameters()[
Trk::d0];
879 std::vector<Trk::MeasurementBase const*> SCTHits;
883 for(;meas != measEnd; ++meas){
891 SCTHits.push_back(*meas);
919 std::vector<Trk::MeasurementBase const*>::const_iterator meas = listOfSCTHits.begin();
920 std::vector<Trk::MeasurementBase const*>::const_iterator measEnd = listOfSCTHits.end();
921 for(;meas != measEnd; ++meas){
927 result =
find(listOfSCTHits.begin(), listOfSCTHits.end(), *meas);
946 (nPseudomeasurements >= 1 &&
nTRTHits > 10)){