15#include "GaudiKernel/MsgStream.h"
17#include "CLHEP/Vector/ThreeVector.h"
65 const double deltaR = getRadius(pPoint1) - getRadius(pPoint0);
66 const double deltaZ = getZ(pPoint1) - getZ(pPoint0);
67 return std::atan2(
deltaR,deltaZ);
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{
153 const auto n = 62-std::size(
str);
154 std::string
result(n,
' ');
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());
179 out<<
"| Tool for updator | "<<paddedName(
m_updatorTool.type());
180 out<<
"| Tool for road maker | "<<paddedName(
m_roadmaker.type());
181 out<<
"| Tool for seed maker | "<<paddedName(
m_seedmaker.type());
182 out<<
"| Tool for track finding | "<<paddedName(
m_tracksfinder.type());
183 out<<
"| Magnetic field mode | "<<paddedName(fieldmode[mode]);
184 out<<
"| Min pT of track (MeV) | "<<format<<
m_pTmin<<padding;
185 out<<
"| Max Xi2 for cluster | "<<format<<
m_xi2max<<padding;
186 out<<
"| Max Xi2 for outlayer | "<<format<<
m_xi2maxNoAdd<<padding;
187 out<<
"| Max Xi2 for link | "<<format<<
m_xi2maxlink<<padding;
188 out<<
"| Min number of clusters | "<<std::setw(12)<<
m_nclusmin<<padding;
189 out<<
"| Max number holes | "<<std::setw(12)<<
m_nholesmax<<padding;
190 out<<
"| Max holes gap | "<<std::setw(12)<<
m_dholesmax<<padding;
209std::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);
237std::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));
275std::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) {
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!");
354std::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);
507 if(upTP->momentum().perp()<
m_pTmin){
525 if(
msgLvl(MSG::VERBOSE)) {
526 msg(MSG::VERBOSE) <<
"Perigee after SP updates at same surface" <<
endmsg;
531 std::vector<const InDetDD::SiDetectorElement*> DE;
541 const AmgVector(5)& piv = upTP->parameters();
544 std::unique_ptr<const Trk::TrackParameters> mesTP{};
556 mesTP = upTP->associatedSurface().createUniqueTrackParameters(piv[0],piv[1],piv[2],piv[3],piv[4],pnvCM);
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!");
584 std::list<Trk::Track*>::iterator t = cTracks.begin();
585 while(t!=cTracks.end()) {
591 associatedSiTrack.push_back((*t++));
596 return associatedSiTrack;
603std::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 !");
637 if(!fieldCache.
solenoidOn()) outlierCut = 1000000.;
660std::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.;
701 if(std::abs(std::log(std::tan(pTS[3]/2.)))>0.8){
709 int isB =
m_trtId->barrel_ec(
id);
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;
732std::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;
883 t [n] = event_data.
clusterTrack().find(prd[n]);
if(t[n]!=te) ++nc; ++n;
885 if((*s)->clusterList().second) {
886 prd[n] = (*s)->clusterList().second;
887 t [n] = event_data.
clusterTrack().find(prd[n]);
if(t[n]!=te) ++nc; ++n;
894 for(tt=t[0]; tt!=te; ++tt) {
895 if( (*tt).first != prd[0] )
break;
896 trk[0][m++] = (*tt).second;
902 for(tt=t[i]; t[i]!=te; ++tt) {
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) {
928 for(tt=t[i]; t[i]!=te; ++tt) {
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;
983std::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;
997 for(itp=newtsos->
begin(); itp!=itpe; ++itp){
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;
1050 const double F = Vp[2];
const boost::regex re(r_e)
Scalar deltaR(const MatrixBase< Derived > &vec) const
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define AmgSymMatrix(dim)
Handle class for reading from StoreGate.
This is an Identifier helper class for the TRT subdetector.
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
Header file for AthHistogramAlgorithm.
void getInitializedCache(MagField::AtlasFieldCache &cache) const
get B field cache for evaluation as a function of 2-d or 3-d position.
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
virtual Identifier identify() const override final
identifier of this detector element:
RIO_OnTrack base class for Silicon detector in the InnerDetector.
const Amg::Vector3D & globalPosition() const
return global position reference
virtual const InDetDD::SiDetectorElement * detectorElement() const override final
return the detector element corresponding to this PRD The pointer will be zero if the det el is not d...
InDet::SiCombinatorialTrackFinderData_xk holds event dependent data used by SiCombinatorialTrackFinde...
void production(int direction, int model, const Trk::TrackParameters &tp)
Represents 'corrected' measurements from the TRT (for example, corrected for wire sag).
virtual const InDetDD::TRT_BaseElement * detectorElement() const override final
returns the detector element, assoicated with the PRD of this class
virtual const Amg::Vector3D & globalPosition() const override final
return the global position of this RIO_OnTrack
InDet::SiNoise_bt & noise()
const ROIPhiRZContainer * caloClusterROIEM() const
virtual InDet::SiCombinatorialTrackFinderData_xk & combinatorialData() override
InDet::SiDetElementRoadMakerData_xk & roadMakerData()
InDet::ITRT_SeededSpacePointFinder::IEventData & spacePointFinderEventData()
std::multimap< const Trk::PrepRawData *, const Trk::Track * > & clusterTrack()
ToolHandle< InDet::ITRT_SeededSpacePointFinder > m_seedmaker
const TRT_ID * m_trtId
ID TRT helper.
DoubleProperty m_xi2maxNoAdd
MsgStream & dumpconditions(MsgStream &out) const
virtual ~TRT_SeededTrackFinder_ATL()
ToolHandle< Trk::IUpdator > m_updatorTool
SG::ReadCondHandleKey< AtlasFieldCacheCondObj > m_fieldCondObjInputKey
bool checkSeed(std::vector< const Trk::SpacePoint * > &, const Trk::TrackSegment &, const Trk::TrackParameters &) const
Check consistency of seed and TRT track segment.
BooleanProperty m_bremCorrect
std::unique_ptr< const Trk::TrackParameters > addNoise(const SiNoise_bt &, const Trk::TrackParameters &, int) const
Add material effects.
static void clusterTrackMap(Trk::Track *, InDet::TRT_SeededTrackFinder_ATL::EventData &event_data)
Map PRDs-tracks.
virtual StatusCode initialize() override
std::list< Trk::Track * > findTrack(const EventContext &ctx, MagField::AtlasFieldCache &fieldCache, InDet::TRT_SeededTrackFinder_ATL::EventData &event_data, const Trk::TrackParameters &, const Trk::TrackSegment &) const
Find the corresponding list of Si tracks.
DoubleProperty m_outlierCut
void magneticFieldInit()
Private Methods.
DoubleProperty m_phiWidth
IntegerProperty m_dholesmax
ToolHandle< Trk::IPropagator > m_proptool
DoubleArrayProperty m_errorScale
virtual std::unique_ptr< InDet::ITRT_SeededTrackFinder::IEventData > newRegion(const EventContext &ctx, SiCombinatorialTrackFinderData_xk &combinatorialData, const std::vector< IdentifierHash > &, const std::vector< IdentifierHash > &) const override
New region intialization.
IntegerProperty m_nwclusmin
MsgStream & dump(MsgStream &out) const override
Print internal tool parameters and status.
bool isCaloCompatible(const Trk::TrackParameters &, const InDet::TRT_SeededTrackFinder_ATL::EventData &event_data) const
Only propagate to the Si if the TRT segment is compatible with a calo measurement.
ToolHandle< InDet::ISiDetElementsRoadMaker > m_roadmaker
Magnetic field properties.
virtual std::list< Trk::Track * > getTrack(const EventContext &ctx, InDet::ITRT_SeededTrackFinder::IEventData &event_data, const Trk::TrackSegment &) const override
Main methods for local track finding.
virtual std::unique_ptr< InDet::ITRT_SeededTrackFinder::IEventData > newEvent(const EventContext &ctx, SiCombinatorialTrackFinderData_xk &combinatorialData) const override
New event initialization.
ToolHandle< InDet::ISiCombinatorialTrackFinder > m_tracksfinder
BooleanProperty m_searchInCaloROI
SG::ReadHandleKey< ROIPhiRZContainer > m_caloClusterROIKey
static bool newClusters(const std::vector< const Trk::SpacePoint * > &, InDet::TRT_SeededTrackFinder_ATL::EventData &event_data)
Seed used by another track?
TRT_SeededTrackFinder_ATL(const std::string &, const std::string &, const IInterface *)
Standard tool methods.
static std::unique_ptr< const Trk::TrackParameters > modifyTrackParameters(const Trk::TrackParameters &, int)
Modify track parameters if brem correction.
BooleanProperty m_useassoTool
InDet::TrackQualityCuts m_trackquality
void setTrackQualityCuts()
Set the track quality cuts for combinatorial track finding.
Trk::MagneticFieldProperties m_fieldprop
static bool newSeed(const std::vector< const Trk::SpacePoint * > &, InDet::TRT_SeededTrackFinder_ATL::EventData &event_data)
Seed SPs used by other high quality tracks?
DoubleProperty m_xi2max
Track quality cuts to be passed to the combinatorial track finder.
StringProperty m_fieldmode
Protected Data.
virtual void endEvent(InDet::ITRT_SeededTrackFinder::IEventData &event_data) const override
End of event tasks.
IntegerProperty m_nholesmax
static bool isNewTrack(Trk::Track *, InDet::TRT_SeededTrackFinder_ATL::EventData &event_data)
Clean-up duplicate tracks.
std::unique_ptr< const Trk::TrackParameters > getTP(MagField::AtlasFieldCache &fieldCache, const Trk::SpacePoint *, const Trk::TrackParameters &, bool &, InDet::TRT_SeededTrackFinder_ATL::EventData &event_data) const
Update track parameters through space point propagation.
std::list< Trk::Track * > cleanTrack(std::list< Trk::Track * >) const
Eliminate spurious Pixel clusters in track.
DoubleProperty m_xi2maxlink
IntegerProperty m_nclusmin
virtual StatusCode finalize() override
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h)
bool solenoidOn() const
status of the magnets
const_iterator lowerPhiBound(float phi, float roi_phi_width) const
virtual bool isValid() override final
Can the handle be successfully dereferenced?
static EventData & getPrivateEventData(InDet::ITRT_SeededTrackFinder::IEventData &virt_event_data)
double chiSquared() const
returns the of the overall track fit
int parameterKey() const
Identifier key for matrix expansion/reduction.
double get(ParamDefs par) const
Retrieve specified parameter (const version).
magnetic field properties to steer the behavior of the extrapolation
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
virtual const Surface & associatedSurface() const override=0
Access to the Surface associated to the Parameters.
Class describing the Line to which the Perigee refers to.
Class to handle pseudo-measurements in fitters and on track objects.
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
virtual const Trk::PrepRawData * prepRawData() const =0
returns the PrepRawData (also known as RIO) object to which this RIO_OnTrack is associated.
const MeasurementBase * measurement(unsigned int) const
returns the Trk::MeasurementBase objects depending on the integer
unsigned int numberOfMeasurementBases() const
Return the number of contained Trk::MeasurementBase (s)
virtual const Amg::Vector3D & globalPosition() const override final
Interface method to get the global Position.
virtual const Surface & associatedSurface() const override final
Interface method to get the associated Surface.
Abstract Base Class for tracking surfaces.
virtual ChargedTrackParametersUniquePtr createUniqueTrackParameters(double l1, double l2, double phi, double theat, double qop, std::optional< AmgSymMatrix(5)> cov=std::nullopt) const =0
Use the Surface as a ParametersBase constructor, from local parameters - charged.
virtual constexpr SurfaceType type() const =0
Returns the Surface type to avoid dynamic casts.
Contains information about the 'fitter' of this track.
Class for a generic track segment that holdes polymorphic Trk::MeasurementBase objects,...
const Surface & associatedSurface() const override final
returns the surface for the local to global transformation
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
const DataVector< const MeasurementBase > * measurementsOnTrack() const
return a pointer to a vector of MeasurementBase (NOT including any that come from outliers).
Eigen::Matrix< double, 3, 1 > Vector3D
PropDirection
PropDirection, enum for direction of the propagation.
DataVector< const Trk::TrackStateOnSurface > TrackStates
@ FastField
call the fast field access method of the FieldSvc
@ NoField
Field is set to 0., 0., 0.,.
@ FullField
Field is set to be realistic, but within a given Volume.
@ loc2
generic first and second local coordinate
ParticleHypothesis
Enumeration for Particle hypothesis respecting the interaction with material.
ParametersBase< TrackParametersDim, Charged > TrackParameters