15 #include "GaudiKernel/MsgStream.h"
17 #include "CLHEP/Vector/ThreeVector.h"
51 #include <string_view>
65 const double deltaR = getRadius(pPoint1) - getRadius(pPoint0);
66 const double deltaZ = getZ(pPoint1) - getZ(pPoint0);
77 (
const std::string&
t,
const std::string&
n,
const IInterface*
p)
80 declareInterface<ITRT_SeededTrackFinder>(
this);
123 return StatusCode::SUCCESS;
133 return StatusCode::SUCCESS;
152 auto paddedName=[](
const auto &
str)->std::string{
160 auto format = [](MsgStream&
m)->MsgStream&{
161 m<<std::setw(12)<<std::setprecision(5);
165 constexpr std::string_view fieldmode[9] ={
"NoField" ,
"ConstantField",
"SolenoidalField",
166 "ToroidalField" ,
"Grid3DField" ,
"RealisticField" ,
167 "UndefinedField",
"AthenaField" ,
"?????" };
170 if(mode<0 || mode>8 )
mode = 8;
172 constexpr
auto horizontalRule{
173 "|-----------------------------------------------------------------------------------------|\n"
176 constexpr
auto padding{
" |\n"};
178 out<<
"| Tool for propagation | "<<paddedName(
m_proptool.type());
183 out<<
"| Magnetic field mode | "<<paddedName(fieldmode[
mode]);
209 std::unique_ptr<InDet::ITRT_SeededTrackFinder::IEventData>
214 auto event_data_p = std::make_unique<InDet::TRT_SeededTrackFinder_ATL::EventData>(combinatorialData,
231 event_data_p->setCaloClusterROIEM(*calo_rois);
237 std::unique_ptr<InDet::ITRT_SeededTrackFinder::IEventData>
239 const std::vector<IdentifierHash>& listOfPixIds,
240 const std::vector<IdentifierHash>& listOfSCTIds)
const{
241 auto event_data_p = std::make_unique<InDet::TRT_SeededTrackFinder_ATL::EventData>(combinatorialData,
242 m_seedmaker->newRegion(listOfPixIds,listOfSCTIds));
275 std::list<Trk::Track*>
281 std::list<Trk::Track*> aSiTrack;
292 throw std::logic_error(
"Unhandled surface.");
298 std::unique_ptr<Trk::TrackParameters> newPerPar =
307 ATH_MSG_DEBUG(
"Initial Track Parameters created from TRT segment, ");
310 ATH_MSG_WARNING(
"Could not get initial TRT track parameters, rejected! " );
313 constexpr
auto horizontalRule{
"==============================================================\n"};
315 ATH_MSG_DEBUG(horizontalRule <<
"Start initial search with 3-4 SCT layer combinations ");
324 if (fieldCondObj ==
nullptr) {
329 fieldCondObj->getInitializedCache (fieldCache);
331 aSiTrack =
findTrack(ctx, fieldCache, event_data, *newPerPar, tS);
333 ATH_MSG_DEBUG(horizontalRule <<
"Could not create track states on surface for this track!Try to add brem correction.");
336 ATH_MSG_VERBOSE(
"Modified TRT Track Parameters for brem. \n"<<(*modTP));
337 aSiTrack =
findTrack(ctx, fieldCache, event_data, *modTP, tS);
338 if(aSiTrack.empty()){
339 ATH_MSG_DEBUG(
"Could not create track states on surface for this track after all!");
354 std::list<Trk::Track*>
360 std::list<Trk::Track*> associatedSiTrack;
361 constexpr
double pi2 = 2.*
M_PI;
365 std::list<std::pair<const Trk::SpacePoint*,const Trk::SpacePoint*> >
368 ATH_MSG_DEBUG(
"---------------> SP SEED LIST SIZE " << SpE.size() );
369 if(SpE.empty()){
return associatedSiTrack;}
376 std::vector<const Trk::SpacePoint*> SpVec{
nullptr,
nullptr};
378 std::list<std::pair<const Trk::SpacePoint*,const Trk::SpacePoint*> >
::iterator r,
re=SpE.end();
379 for(
r=SpE.begin();
r!=
re; ++
r){
380 std::list<Trk::Track*> aTracks ;
381 std::list<Trk::Track*> cTracks ;
389 std::pair<const Trk::SpacePoint*, const Trk::SpacePoint*>& pSP = *
r;
390 if (pSP.first != pSP.second){
391 ATH_MSG_DEBUG(
"----> Seed Pair: SP 1 " << (pSP.first)->r() <<
" SP 2 " << (pSP.second)->r() );
394 msg(
MSG::DEBUG) <<
"----> Seed Single: SP 1 " << (pSP.first)->
r() <<
"\n";
395 msg(
MSG::DEBUG) <<
" Will not process for the time being ! A special module is needed\n" ;
396 msg(
MSG::DEBUG) <<
" to deal with late conversion (no search and stablized input fit ).\n";
397 msg(
MSG::DEBUG) <<
" Current version is unstable in the SP updates and gets unpredictable results." <<
endmsg;
403 SpVec[0]=(pSP.second);
404 SpVec[1]=(pSP.first);
406 ATH_MSG_DEBUG(
"Seed SPs already used by a single track. Ignore..." );
409 if(!
newSeed(SpVec,event_data)) {
410 ATH_MSG_DEBUG(
"Seed SPs already used by other tracks. Ignore..." );
418 bool seedGood =
checkSeed(SpVec,tS,initTP);
420 ATH_MSG_DEBUG(
"Seed not consistent with TRT segment. Ignore..." );
428 ATH_MSG_DEBUG(
"Get better track parameters using the seed" );
429 double newTheta = thetaFromSpacePoints(SpVec[0], SpVec[1]);
430 const AmgVector(5)& iv = initTP.parameters();
431 double newPhi = iv[2];
433 if (newTheta >
pi) newTheta = fmod(newTheta+
pi,
pi2)-
pi;
434 else if(newTheta <-
pi) newTheta = fmod(newTheta-
pi,
pi2)+
pi;
435 if(newTheta<0.){ newTheta = -newTheta; newPhi+=
pi; }
436 if (newPhi >
pi) newPhi = fmod(newPhi+
pi,
pi2)-
pi;
437 else if(newPhi <-
pi) newPhi = fmod(newPhi-
pi,
pi2)+
pi;
455 std::unique_ptr<const Trk::TrackParameters> niTP =
457 iv[0], iv[1], newPhi, newTheta, iv[4], nvCM);
460 ATH_MSG_DEBUG(
"Initial Track Parameters created and scaled from TRT segment, ");
463 ATH_MSG_DEBUG(
"Could not get initial TRT track parameters! " );
475 std::unique_ptr<const Trk::TrackParameters> upTP =
getTP(fieldCache, pSP.first,*niTP,outl,event_data);
478 ATH_MSG_DEBUG(
"Extrapolation through seed failed!Seed bogus.Move to next seed" );
488 if (pSP.first != pSP.second) {
491 std::unique_ptr<const Trk::TrackParameters> newTP =
getTP(fieldCache, pSP.second,*upTP,outl,event_data);
494 ATH_MSG_DEBUG(
"Extrapolation through seed failed!Seed bogus.Move to next seed" );
503 upTP = std::move(newTP);
531 std::vector<const InDetDD::SiDetectorElement*> DE;
541 const AmgVector(5)& piv = upTP->parameters();
544 std::unique_ptr<const Trk::TrackParameters> mesTP{};
558 ATH_MSG_DEBUG(
"Initial Track Parameters at 1st SP created and scaled from TRT segment, " );
570 std::vector<Amg::Vector3D> Gp;
572 if(aTracks.empty()) {
573 ATH_MSG_DEBUG(
"No tracks found by the combinatorial track finder!");
585 while(
t!=cTracks.end()) {
591 associatedSiTrack.push_back((*
t++));
596 return associatedSiTrack;
603 std::unique_ptr<const Trk::TrackParameters>
608 std::unique_ptr<const Trk::TrackParameters> iTP{};
613 auto eTP =
m_proptool->propagate(Gaudi::Hive::currentContext(),
626 ATH_MSG_DEBUG(
"Updator returned no update, but a DitQuality object, a leak !");
660 std::unique_ptr<const Trk::TrackParameters>
663 const double covAzim=
noise.covarianceAzim();
664 const double covPola=
noise.covariancePola();
665 const double covIMom=
noise.covarianceIMom();
666 const double corIMom=
noise.correctionIMom();
668 const AmgVector(5)& Vp1 = P1.parameters();
669 double M[5]={Vp1[0],Vp1[1],Vp1[2],Vp1[3],Vp1[4]};
697 int nEC = 0;
double gz = 0.;
710 if(isB==2 || isB==-2) nEC++;
717 double tanTheta =
std::tan(thetaFromSpacePoints(vsp[0], vsp[1]));
719 double propR = getRadius(vsp[1]) + (gz-getZ(vsp[1]))*tanTheta;
720 if(propR<620. || propR>1010.) isGood=
false;
721 double zIn = gz-propR/tanTheta;
722 if(zIn>300.) isGood =
false;
732 std::unique_ptr<const Trk::TrackParameters>
736 const AmgVector(5)& pV = TP.parameters();
737 double ip[5] = {pV[0], pV[1], pV[2], pV[3], pV[4]};
740 const double &
q =
ip[4];
741 const double covarianceIMom = 0.25*
q*
q;
748 nM(4,4) = 10.*(0.1*((*CM)(4,4))+covarianceIMom);
751 nM(4,4)+=covarianceIMom;
792 if(prd) event_data.
clusterTrack().insert(std::make_pair(prd,Tr));
806 std::multimap<const Trk::PrepRawData*,const Trk::Track*>::const_iterator
808 std::vector<const Trk::SpacePoint*>::const_iterator
s=Sp.begin(),
se=Sp.end();
813 if((*s)->clusterList().first ) {
814 prd[
n] = (*s)->clusterList().first;
816 if(
t[
n]==te)
return true;
819 if((*s)->clusterList().second) {
820 prd[
n] = (*s)->clusterList().second;
822 if(
t[
n]==te)
return true;
832 for(; pTracks!=te; ++pTracks) {
833 if (
m==30)
return false;
834 if( (*pTracks).first != prd[0] )
break;
835 trk[0][
m++] = (*pTracks).second;
841 for(
int i=1;
i!=
n; ++
i) {
843 auto & pTheseTracks=
t[
i];
844 for(; pTheseTracks!=te; ++pTheseTracks) {
845 if( (*pTheseTracks).first != prd[
i] )
break;
846 for(
int j=0; j!=
m; ++j) {
847 if((*pTheseTracks).second == trk[in][j]) {trk[ou][
l++]= trk[in][j];
852 if(
l==0)
return true;
874 std::multimap<const Trk::PrepRawData*,const Trk::Track*>::const_iterator
877 std::vector<const Trk::SpacePoint*>::const_iterator
s=Sp.begin(),
se=Sp.end();
881 if((*s)->clusterList().first ) {
882 prd[
n] = (*s)->clusterList().first;
885 if((*s)->clusterList().second) {
886 prd[
n] = (*s)->clusterList().second;
895 if( (*tt).first != prd[0] )
break;
896 trk[0][
m++] = (*tt).second;
903 if( (*tt).first != prd[
i] )
break;
904 for(
int j=0; j!=
m; ++j) {
905 if((*tt).second == trk[in][j]) {
906 trk[ou][
l++]= trk[in][j];
921 if(
i==
n)
return false;
927 for(
int i=0;
i!=
n; ++
i) {
929 if( (*tt).first != prd[
i] )
break;
930 if((*tt).second->trackStateOnSurfaces()->size() >= 10) {
948 std::multimap<const Trk::PrepRawData*,const Trk::Track*>::const_iterator
960 if(
t[
n]==te)
return true;
967 for(
int i=0;
i!=
n; ++
i) {
969 for(ti=
t[
i]; ti!=te; ++ti) {
970 if( (*ti).first != prd[
i] )
break;
971 int ncl = (*ti).second->trackStateOnSurfaces()->size();
972 if(ncl > nclmax) nclmax = ncl;
974 if(nclt > nclmax)
return true;
983 std::list<Trk::Track*>
985 std::list<Trk::Track*> cleanSiTrack;
986 std::list<Trk::Track*>::const_iterator
it = lTrk.begin();
987 std::list<Trk::Track*>::const_iterator itEnd = lTrk.end();
988 for (;
it != itEnd ; ++
it){
995 if(!newtsos)
continue;
1002 if(RawDataClus==
nullptr){
1019 if(nPixHits==1 && (sctR-pixR)>200.){
1020 auto cltsos = std::make_unique<Trk::TrackStates>();
1021 auto fq = (*it)->fitQuality()->uniqueClone();
1024 for(p_tsos=newtsos->
begin()+nPixHits;p_tsos!=newtsos->
end();++p_tsos){
1025 cltsos->push_back( (*p_tsos)->clone() );
1031 cleanSiTrack.push_back(nTrack);
1034 cleanSiTrack.push_back((*
it));
1038 return cleanSiTrack;
1049 const AmgVector(5)& Vp = Tp.parameters();
1050 const double F = Vp[2];