15 #include "GaudiKernel/MsgStream.h"
17 #include "CLHEP/Vector/ThreeVector.h"
63 #include <string_view>
77 const double deltaR = getRadius(pPoint1) - getRadius(pPoint0);
89 (
const std::string&
t,
const std::string&
n,
const IInterface*
p)
91 m_fieldmode(
"MapSolenoid"),
92 m_roadmaker(
"InDet::SiDetElementsRoadMaker_xk"),
93 m_proptool(
"Trk::RungeKuttaPropagator/InDetPropagator"),
94 m_updatorTool(
"Trk::KalmanUpdator_xk/InDetPatternUpdator"),
95 m_tracksfinder(
"InDet::SiCombinatorialTrackFinder_xk", this),
97 m_errorScale {1., 1., 1., 1., 1.}
100 m_xi2maxNoAdd = 50. ;
101 m_xi2maxlink = 100. ;
107 m_bremCorrect = false ;
109 m_useassoTool = false ;
111 m_searchInCaloROI = false ;
115 declareInterface<ITRT_SeededTrackFinder>(
this);
181 return StatusCode::SUCCESS;
191 return StatusCode::SUCCESS;
210 auto paddedName=[](
const auto &
str)->std::string{
218 auto format = [](MsgStream&
m)->MsgStream&{
219 m<<std::setw(12)<<std::setprecision(5);
223 constexpr std::string_view fieldmode[9] ={
"NoField" ,
"ConstantField",
"SolenoidalField",
224 "ToroidalField" ,
"Grid3DField" ,
"RealisticField" ,
225 "UndefinedField",
"AthenaField" ,
"?????" };
228 if(mode<0 || mode>8 )
mode = 8;
230 constexpr
auto horizontalRule{
231 "|-----------------------------------------------------------------------------------------|\n"
234 constexpr
auto padding{
" |\n"};
236 out<<
"| Tool for propagation | "<<paddedName(
m_proptool.type());
241 out<<
"| Magnetic field mode | "<<paddedName(fieldmode[
mode]);
267 std::unique_ptr<InDet::ITRT_SeededTrackFinder::IEventData>
272 auto event_data_p = std::make_unique<InDet::TRT_SeededTrackFinder_ATL::EventData>(combinatorialData,
289 event_data_p->setCaloClusterROIEM(*calo_rois);
295 std::unique_ptr<InDet::ITRT_SeededTrackFinder::IEventData>
297 const std::vector<IdentifierHash>& listOfPixIds,
298 const std::vector<IdentifierHash>& listOfSCTIds)
const{
299 auto event_data_p = std::make_unique<InDet::TRT_SeededTrackFinder_ATL::EventData>(combinatorialData,
300 m_seedmaker->newRegion(listOfPixIds,listOfSCTIds));
333 std::list<Trk::Track*>
339 std::list<Trk::Track*> aSiTrack;
350 throw std::logic_error(
"Unhandled surface.");
356 std::unique_ptr<Trk::TrackParameters> newPerPar =
365 ATH_MSG_DEBUG(
"Initial Track Parameters created from TRT segment, ");
368 ATH_MSG_WARNING(
"Could not get initial TRT track parameters, rejected! " );
371 constexpr
auto horizontalRule{
"==============================================================\n"};
373 ATH_MSG_DEBUG(horizontalRule <<
"Start initial search with 3-4 SCT layer combinations ");
382 if (fieldCondObj ==
nullptr) {
387 fieldCondObj->getInitializedCache (fieldCache);
389 aSiTrack =
findTrack(ctx, fieldCache, event_data, *newPerPar, tS);
391 ATH_MSG_DEBUG(horizontalRule <<
"Could not create track states on surface for this track!Try to add brem correction.");
394 ATH_MSG_VERBOSE(
"Modified TRT Track Parameters for brem. \n"<<(*modTP));
395 aSiTrack =
findTrack(ctx, fieldCache, event_data, *modTP, tS);
396 if(aSiTrack.empty()){
397 ATH_MSG_DEBUG(
"Could not create track states on surface for this track after all!");
412 std::list<Trk::Track*>
418 std::list<Trk::Track*> associatedSiTrack;
419 constexpr
double pi2 = 2.*
M_PI;
423 std::list<std::pair<const Trk::SpacePoint*,const Trk::SpacePoint*> >
426 ATH_MSG_DEBUG(
"---------------> SP SEED LIST SIZE " << SpE.size() );
427 if(SpE.empty()){
return associatedSiTrack;}
434 std::vector<const Trk::SpacePoint*> SpVec{
nullptr,
nullptr};
436 std::list<std::pair<const Trk::SpacePoint*,const Trk::SpacePoint*> >
::iterator r,
re=SpE.end();
437 for(
r=SpE.begin();
r!=
re; ++
r){
438 std::list<Trk::Track*> aTracks ;
439 std::list<Trk::Track*> cTracks ;
447 std::pair<const Trk::SpacePoint*, const Trk::SpacePoint*>& pSP = *
r;
448 if (pSP.first != pSP.second){
449 ATH_MSG_DEBUG(
"----> Seed Pair: SP 1 " << (pSP.first)->r() <<
" SP 2 " << (pSP.second)->r() );
452 msg(
MSG::DEBUG) <<
"----> Seed Single: SP 1 " << (pSP.first)->
r() <<
"\n";
453 msg(
MSG::DEBUG) <<
" Will not process for the time being ! A special module is needed\n" ;
454 msg(
MSG::DEBUG) <<
" to deal with late conversion (no search and stablized input fit ).\n";
455 msg(
MSG::DEBUG) <<
" Current version is unstable in the SP updates and gets unpredictable results." <<
endmsg;
461 SpVec[0]=(pSP.second);
462 SpVec[1]=(pSP.first);
464 ATH_MSG_DEBUG(
"Seed SPs already used by a single track. Ignore..." );
467 if(!
newSeed(SpVec,event_data)) {
468 ATH_MSG_DEBUG(
"Seed SPs already used by other tracks. Ignore..." );
476 bool seedGood =
checkSeed(SpVec,tS,initTP);
478 ATH_MSG_DEBUG(
"Seed not consistent with TRT segment. Ignore..." );
486 ATH_MSG_DEBUG(
"Get better track parameters using the seed" );
487 double newTheta = thetaFromSpacePoints(SpVec[0], SpVec[1]);
488 const AmgVector(5)& iv = initTP.parameters();
489 double newPhi = iv[2];
491 if (newTheta >
pi) newTheta = fmod(newTheta+
pi,
pi2)-
pi;
492 else if(newTheta <-
pi) newTheta = fmod(newTheta-
pi,
pi2)+
pi;
493 if(newTheta<0.){ newTheta = -newTheta; newPhi+=
pi; }
494 if (newPhi >
pi) newPhi = fmod(newPhi+
pi,
pi2)-
pi;
495 else if(newPhi <-
pi) newPhi = fmod(newPhi-
pi,
pi2)+
pi;
513 std::unique_ptr<const Trk::TrackParameters> niTP =
515 iv[0], iv[1], newPhi, newTheta, iv[4], nvCM);
518 ATH_MSG_DEBUG(
"Initial Track Parameters created and scaled from TRT segment, ");
521 ATH_MSG_DEBUG(
"Could not get initial TRT track parameters! " );
533 std::unique_ptr<const Trk::TrackParameters> upTP =
getTP(fieldCache, pSP.first,*niTP,outl,event_data);
536 ATH_MSG_DEBUG(
"Extrapolation through seed failed!Seed bogus.Move to next seed" );
546 if (pSP.first != pSP.second) {
549 std::unique_ptr<const Trk::TrackParameters> newTP =
getTP(fieldCache, pSP.second,*upTP,outl,event_data);
552 ATH_MSG_DEBUG(
"Extrapolation through seed failed!Seed bogus.Move to next seed" );
561 upTP = std::move(newTP);
589 std::vector<const InDetDD::SiDetectorElement*> DE;
599 const AmgVector(5)& piv = upTP->parameters();
602 std::unique_ptr<const Trk::TrackParameters> mesTP{};
616 ATH_MSG_DEBUG(
"Initial Track Parameters at 1st SP created and scaled from TRT segment, " );
628 std::vector<Amg::Vector3D> Gp;
630 if(aTracks.empty()) {
631 ATH_MSG_DEBUG(
"No tracks found by the combinatorial track finder!");
643 while(
t!=cTracks.end()) {
649 associatedSiTrack.push_back((*
t++));
654 return associatedSiTrack;
661 std::unique_ptr<const Trk::TrackParameters>
666 std::unique_ptr<const Trk::TrackParameters> iTP{};
671 auto eTP =
m_proptool->propagate(Gaudi::Hive::currentContext(),
684 ATH_MSG_DEBUG(
"Updator returned no update, but a DitQuality object, a leak !");
718 std::unique_ptr<const Trk::TrackParameters>
721 const double covAzim=
noise.covarianceAzim();
722 const double covPola=
noise.covariancePola();
723 const double covIMom=
noise.covarianceIMom();
724 const double corIMom=
noise.correctionIMom();
726 const AmgVector(5)& Vp1 = P1.parameters();
727 double M[5]={Vp1[0],Vp1[1],Vp1[2],Vp1[3],Vp1[4]};
755 int nEC = 0;
double gz = 0.;
768 if(isB==2 || isB==-2) nEC++;
775 double tanTheta =
std::tan(thetaFromSpacePoints(vsp[0], vsp[1]));
777 double propR = getRadius(vsp[1]) + (gz-
getZ(vsp[1]))*tanTheta;
778 if(propR<620. || propR>1010.) isGood=
false;
779 double zIn = gz-propR/tanTheta;
780 if(zIn>300.) isGood =
false;
790 std::unique_ptr<const Trk::TrackParameters>
794 const AmgVector(5)& pV = TP.parameters();
795 double ip[5] = {pV[0], pV[1], pV[2], pV[3], pV[4]};
798 const double &
q =
ip[4];
799 const double covarianceIMom = 0.25*
q*
q;
806 nM(4,4) = 10.*(0.1*((*CM)(4,4))+covarianceIMom);
809 nM(4,4)+=covarianceIMom;
850 if(prd) event_data.
clusterTrack().insert(std::make_pair(prd,Tr));
864 std::multimap<const Trk::PrepRawData*,const Trk::Track*>::const_iterator
866 std::vector<const Trk::SpacePoint*>::const_iterator
s=Sp.begin(),
se=Sp.end();
871 if((*s)->clusterList().first ) {
872 prd[
n] = (*s)->clusterList().first;
874 if(
t[
n]==te)
return true;
877 if((*s)->clusterList().second) {
878 prd[
n] = (*s)->clusterList().second;
880 if(
t[
n]==te)
return true;
890 for(; pTracks!=te; ++pTracks) {
891 if (
m==30)
return false;
892 if( (*pTracks).first != prd[0] )
break;
893 trk[0][
m++] = (*pTracks).second;
899 for(
int i=1;
i!=
n; ++
i) {
901 auto & pTheseTracks=
t[
i];
902 for(; pTheseTracks!=te; ++pTheseTracks) {
903 if( (*pTheseTracks).first != prd[
i] )
break;
904 for(
int j=0; j!=
m; ++j) {
905 if((*pTheseTracks).second == trk[in][j]) {trk[ou][
l++]= trk[in][j];
910 if(
l==0)
return true;
932 std::multimap<const Trk::PrepRawData*,const Trk::Track*>::const_iterator
935 std::vector<const Trk::SpacePoint*>::const_iterator
s=Sp.begin(),
se=Sp.end();
939 if((*s)->clusterList().first ) {
940 prd[
n] = (*s)->clusterList().first;
943 if((*s)->clusterList().second) {
944 prd[
n] = (*s)->clusterList().second;
953 if( (*tt).first != prd[0] )
break;
954 trk[0][
m++] = (*tt).second;
961 if( (*tt).first != prd[
i] )
break;
962 for(
int j=0; j!=
m; ++j) {
963 if((*tt).second == trk[in][j]) {
964 trk[ou][
l++]= trk[in][j];
979 if(
i==
n)
return false;
985 for(
int i=0;
i!=
n; ++
i) {
987 if( (*tt).first != prd[
i] )
break;
988 if((*tt).second->trackStateOnSurfaces()->size() >= 10) {
1006 std::multimap<const Trk::PrepRawData*,const Trk::Track*>::const_iterator
1018 if(
t[
n]==te)
return true;
1025 for(
int i=0;
i!=
n; ++
i) {
1027 for(ti=
t[
i]; ti!=te; ++ti) {
1028 if( (*ti).first != prd[
i] )
break;
1029 int ncl = (*ti).second->trackStateOnSurfaces()->size();
1030 if(ncl > nclmax) nclmax = ncl;
1032 if(nclt > nclmax)
return true;
1041 std::list<Trk::Track*>
1043 std::list<Trk::Track*> cleanSiTrack;
1044 std::list<Trk::Track*>::const_iterator
it = lTrk.begin();
1045 std::list<Trk::Track*>::const_iterator itEnd = lTrk.end();
1046 for (;
it != itEnd ; ++
it){
1053 if(!newtsos)
continue;
1060 if(RawDataClus==
nullptr){
1077 if(nPixHits==1 && (sctR-pixR)>200.){
1078 auto cltsos = std::make_unique<Trk::TrackStates>();
1079 auto fq = (*it)->fitQuality()->uniqueClone();
1082 for(p_tsos=newtsos->
begin()+nPixHits;p_tsos!=newtsos->
end();++p_tsos){
1083 cltsos->push_back( (*p_tsos)->clone() );
1089 cleanSiTrack.push_back(nTrack);
1092 cleanSiTrack.push_back((*
it));
1096 return cleanSiTrack;
1107 const AmgVector(5)& Vp = Tp.parameters();
1108 const double F = Vp[2];