ATLAS Offline Software
Loading...
Searching...
No Matches
InDet::TRT_SegmentsToTrack Class Reference

#include <TRT_SegmentsToTrack.h>

Inheritance diagram for InDet::TRT_SegmentsToTrack:

Public Member Functions

 TRT_SegmentsToTrack (const std::string &name, ISvcLocator *pSvcLocator)
 ~TRT_SegmentsToTrack ()
StatusCode initialize ()
StatusCode execute ()
StatusCode finalize ()
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

int getNumberReal (const InDet::TRT_DriftCircle *, const EventContext &ctx) const
 Get the number of truth particles associated with this hit.
double getRealFractionTRT (const Trk::Track *track, const EventContext &ctx) const
 Get the fraction of truth TRT hits on this Track.
double getNoiseProbability (const Trk::Track *track) const
 Get the fraction of noise TRT hits on this Track.
int nTRTHits (const Trk::Track *track) const
 Count number of TRT Hits on track.
int nHTHits (const Trk::Track *track) const
 Count number of TRT HT Hits on track.
void combineSegments (const EventContext &ctx) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

SG::ReadHandleKey< Trk::SegmentCollectionm_inputSegmentCollectionName {this,"InputSegmentsCollection","TrackSegments","RHK to retrieve input track collection"}
 Name of the TrackSegment Collection to read in.
SG::WriteHandleKey< TrackCollectionm_outputTrackCollectionName {this,"OutputTrackCollection","SegmentTracks","WHK to store output tracks"}
 Name of the TrackCollection to write out.
ToolHandle< Trk::ITrackFitterm_trackFitter {this,"TrackFitter","Trk::KalmanFitter/TrkKalmanFitter",""}
 The TrackFitter.
ToolHandle< Trk::IExtrapolatorm_extrapolator {this,"ExtrapolationTool","Trk::Extrapolator/InDetExtrapolator",""}
 The Extrapolator.
ToolHandle< Trk::IExtendedTrackSummaryToolm_trkSummaryTool {this, "SummaryTool","",""}
ToolHandle< Trk::IPRDtoTrackMapToolm_assoTool {this, "AssociationTool", "","" }
SG::WriteHandleKey< Trk::PRDtoTrackMapm_assoMapName {this,"AssociationMapName","",""}
 key for the PRDtoTrackMap to filled by the ambiguity score processor.
SG::ReadHandleKey< Trk::PRDtoTrackMapm_inputAssoMapName {this,"InputAssociationMapName","",""}
 key to be set to optionally store PRD to track association map
double m_noiseCut
 All tracks with a TRT Noise fraction larger than this variable will be thrown away.
int m_minTRTHits
 All tracks with less Hits (after the track fit) will be thrown away.
const AtlasDetectorIDm_idHelper
const TRT_IDm_trtid
SG::ReadHandleKey< PRD_MultiTruthCollectionm_multiTruthCollectionTRTName {this,"PRDTruthCollectionTRT","","RHK to retrieve TRT turth info"}
 Name of the TRT MultiTruthCollection.
int m_nTracksReal
 Counter for real reconstructed Tracks.
int m_nTracksFake
 Counter for fake reconstructed Track.
double m_noiseratio
 average percentage of noise in real tracks
std::atomic< int > m_events
 Event counter.
std::map< int, int > m_MapReal
 Map of hits and real tracks.
std::map< int, int > m_MapFake
 Map of hits and fake tracks.
bool m_materialEffects
 Flag to switch on Material Effects in the Fitter.
bool m_outlierRemoval
 Flag to switch on the outlier removal in the track fitter.
bool m_combineSegments
 Try to combine segments from Barrel and Endcap.
SG::ReadHandleKey< Trk::SegmentCollectionm_barrelSegments {this,"BarrelSegments","TRTBarrelSegments","RHK to retrieve barrel track segments"}
 Name of Barrel segment collection.
SG::ReadHandleKey< Trk::SegmentCollectionm_endcapSegments {this,"EndcapSegments","TRTEndcapSegments","RHK to retrieve endcap track segments"}
 Name of Endcap segment collection.
SG::WriteHandleKey< TrackCollectionm_BECCollectionName {this,"BarrelEndcapTracks","TRT_Barrel_EC","WHK to write tracks"}
 Name of the combined (TRT Barrel+EC) TrackCollection to write out.
std::atomic< int > m_n_combined_fit
DataObjIDColl m_extendedExtraObjects
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 53 of file TRT_SegmentsToTrack.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ TRT_SegmentsToTrack()

InDet::TRT_SegmentsToTrack::TRT_SegmentsToTrack ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 55 of file TRT_SegmentsToTrack.cxx.

55 :
56 AthAlgorithm(name, pSvcLocator),
57 m_idHelper(nullptr),
58 m_trtid(nullptr),
61 m_noiseratio(0.),
62 m_events(0),
64{
65 declareProperty("NoiseCut", m_noiseCut = -1.);
66 declareProperty("MinNHit", m_minTRTHits = 1);
67 declareProperty("MaterialEffects", m_materialEffects = false);
68 declareProperty("OutlierRemoval", m_outlierRemoval = false);
69 declareProperty("CombineSegments", m_combineSegments = false);
70}
AthAlgorithm()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
int m_nTracksReal
Counter for real reconstructed Tracks.
std::atomic< int > m_events
Event counter.
const AtlasDetectorID * m_idHelper
int m_minTRTHits
All tracks with less Hits (after the track fit) will be thrown away.
int m_nTracksFake
Counter for fake reconstructed Track.
std::atomic< int > m_n_combined_fit
bool m_outlierRemoval
Flag to switch on the outlier removal in the track fitter.
bool m_combineSegments
Try to combine segments from Barrel and Endcap.
double m_noiseCut
All tracks with a TRT Noise fraction larger than this variable will be thrown away.
bool m_materialEffects
Flag to switch on Material Effects in the Fitter.
double m_noiseratio
average percentage of noise in real tracks

◆ ~TRT_SegmentsToTrack()

InDet::TRT_SegmentsToTrack::~TRT_SegmentsToTrack ( )

Definition at line 72 of file TRT_SegmentsToTrack.cxx.

73{
74}

Member Function Documentation

◆ combineSegments()

void InDet::TRT_SegmentsToTrack::combineSegments ( const EventContext & ctx) const
private

Definition at line 573 of file TRT_SegmentsToTrack.cxx.

574{
575 //Idea:
576 // - get from endcap segment z-phi dependence
577 // - get from barrel segment r-phi dependence and z dependence from endcap segment fit
578
579 int n_combined_fit=0;
580 SG::ReadHandle<Trk::SegmentCollection> BarrelSegments(m_barrelSegments,ctx);
581 SG::ReadHandle<Trk::SegmentCollection> EndcapSegments(m_endcapSegments,ctx);
582
584
585 SG::WriteHandle<TrackCollection> outputCombiCollection(m_BECCollectionName,ctx);
586 sc = outputCombiCollection.record(std::make_unique<TrackCollection>());
587 if (sc.isFailure()) return;
588
589 if (!BarrelSegments.isValid()){
590 ATH_MSG_FATAL("Could not open barrel segments collection : " << m_barrelSegments.key());
591 return;
592 }
593
594 if (!EndcapSegments.isValid()) {
595 ATH_MSG_FATAL("Could not open endcap segments collection : " << m_endcapSegments.key());
596 return;
597 }
598
599 ATH_MSG_VERBOSE("Got both barrel and endcap segment collections of size "<<BarrelSegments->size()<<" "<<EndcapSegments->size());
600
601 Trk::SegmentCollection::const_iterator iseg = BarrelSegments->begin();
602 Trk::SegmentCollection::const_iterator isegE = BarrelSegments->end();
603
604 int scount=0;
605 for(;iseg!=isegE;++iseg,scount++){
606 ATH_MSG_VERBOSE("Barrel Segment "<<scount<<" : phi="<<(*iseg)->localParameters()[Trk::phi]);
607 }
608
609 iseg = EndcapSegments->begin();
610 isegE = EndcapSegments->end();
611
612 scount=0;
613 for(;iseg!=isegE;++iseg,scount++){
614 ATH_MSG_VERBOSE("Endcap Segment "<<scount<<" : phi="<<(*iseg)->localParameters()[Trk::phi]);
615 }
616
617 if(BarrelSegments->size()==1 && EndcapSegments->size()==1){
618 ATH_MSG_VERBOSE("Here we go: one barrel segment and one endcap segment!");
619
620 Trk::SegmentCollection::const_iterator isegBarrel = BarrelSegments->begin();
621 Trk::SegmentCollection::const_iterator isegBarrelE = BarrelSegments->end();
622
623 Trk::SegmentCollection::const_iterator isegEndcap = EndcapSegments->begin();
624 Trk::SegmentCollection::const_iterator isegEndcapE = EndcapSegments->end();
625
626 //loop over all Barrel Segments
627 for(;isegBarrel!=isegBarrelE;++isegBarrel){
628 for(;isegEndcap!=isegEndcapE;++isegEndcap){
629
630 std::vector< Trk::PseudoMeasurementOnTrack*> tobedeleted;
631
632 ATH_MSG_VERBOSE("Barrel Segment : phi="<<(*isegBarrel)->localParameters()[Trk::phi]<<" with "<<(*isegBarrel)->numberOfMeasurementBases()<<" hits");
633 ATH_MSG_VERBOSE("Endcap Segment : phi="<<(*isegEndcap)->localParameters()[Trk::phi]<<" with "<<(*isegEndcap)->numberOfMeasurementBases()<<" hits");
634
635 int count=0;
636 Trk::MeasurementSet myset,myset2,echits=(*isegEndcap)->containedMeasurements();
637
638 bool barreldown=((*isegBarrel)->measurement((*isegBarrel)->numberOfMeasurementBases()/2)->globalPosition().y()<0);
639 double theta=0;
640 if((*isegEndcap)->localParameters().contains(Trk::theta)){
641 theta = (*isegEndcap)->localParameters()[Trk::theta];
642 }
643
644 //correct theta to point towards the barrel
645 if(( (*isegEndcap)->globalPosition().y()>0 && (*isegEndcap)->globalPosition().z()>0) ||
646 ((*isegEndcap)->globalPosition().y()<0 && (*isegEndcap)->globalPosition().z()<0)
647 ){
648 //endcap A top pointing to barrel A bottom or Barrel C top pointing to Endcap C bottom
649 //--> Theta between 90 and 180 degrees
650 if(theta<M_PI/2.) {
652 std::reverse(echits.begin(),echits.end());
653 }
654 }else{
655 //Theta between 0 and 90 degrees
656 if(theta>M_PI/2.) {
658 std::reverse(echits.begin(),echits.end());
659 }
660 }
661
662 //decide if barrel or endcap hits come first depending on global position of segments
663
664 if(!barreldown && (*isegEndcap)->globalPosition().y()>0){
665 ATH_MSG_VERBOSE("Both barrel and endcap segments in top sectors, won't fit");
666 continue;
667 }
668
669 if(barreldown && (*isegEndcap)->globalPosition().y()<0){
670 ATH_MSG_VERBOSE("Both barrel and endcap segments in lower sectors, won't fit");
671 continue;
672 }
673 int firstechit=0,lastechit=0;
674 if((*isegEndcap)->globalPosition().y()>0){
675 //first endcap then barrel
676 for(int i=0;i<(int)echits.size();++i){
677 const Trk::MeasurementBase *meas=echits[i];
678 const Amg::VectorX LocalParameters = meas->localParameters();
679 const Amg::MatrixX LocalErrorMatrix = meas->localCovariance();
680 double z=meas->globalPosition().z();
681 double phi=meas->globalPosition().phi();
682 double r=meas->globalPosition().perp();
683
684 const InDet::TRT_DriftCircleOnTrack* trtcirc = dynamic_cast<const InDet::TRT_DriftCircleOnTrack*>(meas);
685 if(trtcirc){
686 myset.push_back(meas);
687 ATH_MSG_VERBOSE("Endcap : (phi,r,z) = ( "<<phi<<" , "<<r<<" , "<<z<<" ) ");
688 count++;
689 }
690 }
691 firstechit=0;
692 lastechit=count-1;
693
694 for(unsigned int i=0;i<(*isegBarrel)->numberOfMeasurementBases();++i){
695 const Amg::VectorX LocalParameters = (*isegBarrel)->measurement(i)->localParameters();
696 const Amg::MatrixX LocalErrorMatrix = (*isegBarrel)->measurement(i)->localCovariance();
697 double z=(*isegBarrel)->measurement(i)->globalPosition().z();
698 double phi=(*isegBarrel)->measurement(i)->globalPosition().phi();
699 double r=(*isegBarrel)->measurement(i)->globalPosition().perp();
700
701 const Trk::MeasurementBase *mesb=(*isegBarrel)->measurement(i);
702 const InDet::TRT_DriftCircleOnTrack* trtcirc = dynamic_cast<const InDet::TRT_DriftCircleOnTrack*>(mesb);
703 if(trtcirc){
704 myset.push_back((*isegBarrel)->measurement(i));
705 ATH_MSG_VERBOSE("Barrel : (phi,r,z) = ( "<<phi<<" , "<<r<<" , "<<z<<" ) ");
706 count++;
707 }
708
709 }
710 }else{
711 //first barrel then endcap
712 for(unsigned int i=0;i<(*isegBarrel)->numberOfMeasurementBases();++i){
713 const Amg::VectorX LocalParameters = (*isegBarrel)->measurement(i)->localParameters();
714 const Amg::MatrixX LocalErrorMatrix = (*isegBarrel)->measurement(i)->localCovariance();
715 double z=(*isegBarrel)->measurement(i)->globalPosition().z();
716 double phi=(*isegBarrel)->measurement(i)->globalPosition().phi();
717 double r=(*isegBarrel)->measurement(i)->globalPosition().perp();
718
719 const Trk::MeasurementBase *mesb=(*isegBarrel)->measurement(i);
720 const InDet::TRT_DriftCircleOnTrack* trtcirc = dynamic_cast<const InDet::TRT_DriftCircleOnTrack*>(mesb);
721 if(trtcirc){
722 myset.push_back((*isegBarrel)->measurement(i));
723 ATH_MSG_VERBOSE("Barrel : (phi,r,z) = ( "<<phi<<" , "<<r<<" , "<<z<<" ) ");
724 count++;
725 }
726
727 }
728 firstechit=count;
729
730 for(int i=0;i<(int)echits.size();++i){
731 const Trk::MeasurementBase *meas=echits[i];
732 const Amg::VectorX LocalParameters = meas->localParameters();
733 const Amg::MatrixX LocalErrorMatrix = meas->localCovariance();
734 double z=meas->globalPosition().z();
735 double phi=meas->globalPosition().phi();
736 double r=meas->globalPosition().perp();
737
738 const InDet::TRT_DriftCircleOnTrack* trtcirc = dynamic_cast<const InDet::TRT_DriftCircleOnTrack*>(meas);
739 if(trtcirc){
740 myset.push_back(meas);
741 ATH_MSG_VERBOSE("Endcap : (phi,r,z) = ( "<<phi<<" , "<<r<<" , "<<z<<" ) ");
742 count++;
743 }
744
745 }
746 lastechit=count-1;
747 }
748
749
750
751 Amg::Vector3D inputMatchingPos((*isegBarrel)->globalPosition());
752
753 if((*isegEndcap)->globalPosition().y()>0)
754 inputMatchingPos=(*isegEndcap)->globalPosition();
755
756 Amg::Vector3D inputMatchingMom;
757 double p = 10e7;
758
759 if((*isegBarrel)->localParameters().contains(Trk::qOverP)){
760 p = ((*isegBarrel)->localParameters()[Trk::qOverP]!=0.) ? fabs(1./((*isegBarrel)->localParameters()[Trk::qOverP])) : 10e7;
761 }
762
763 double phi=0.;
764 if((*isegBarrel)->localParameters().contains(Trk::phi)){
765 phi = (*isegBarrel)->localParameters()[Trk::phi];
766 }
767
768
769 inputMatchingMom[Trk::px] = p * cos(phi) * sin(theta);
770 inputMatchingMom[Trk::py] = p * sin(phi) * sin(theta);
771 inputMatchingMom[Trk::pz] = p * cos(theta);
772
773
774 ATH_MSG_VERBOSE("Global position: "<<inputMatchingPos<<" Globalmomentum: "<<inputMatchingMom);
775
776
777
778 //add two pseudomeasurements at the beginning and at the end of the track
779 Trk::MeasurementSet::const_iterator mit;
780 Trk::MeasurementSet::const_iterator mitE=myset.end();
781
782 int count2=0;
783 for(mit=myset.begin();mit!=mitE;++mit){
784 myset2.push_back(*mit);
785 if(count2==firstechit || count2==lastechit){
786 const InDet::TRT_DriftCircleOnTrack* trtcirc = dynamic_cast<const InDet::TRT_DriftCircleOnTrack*>(*mit);
787 if(trtcirc){
788 const Trk::StraightLineSurface *line=dynamic_cast<const
789 Trk::StraightLineSurface*>(&trtcirc->associatedSurface());
790 if (line) {
791 //add pseudomeasurement
792 double locz=-200.;
793 if ((count2==firstechit && firstechit!=0) || (count2==lastechit && firstechit==0)) locz=200;
795 Trk::LocalParameters par(dp);
796
797 Amg::MatrixX cov(1,1);
798 cov(0,0) = 16./12. ; // take actual length of straw instead !!!!!
799
800 //create new surface
801 Amg::Vector3D C = line->transform().translation();
802
803 //decide on movement
804
805 const Amg::Vector3D& gpos=(*mit)->globalPosition();
806
807 if(fabs(gpos.z())>800){
808 if(theta>M_PI/2.){
809 C[2]-=1.;
810 }else{
811 C[2]+=1.;
812 }
813 }else{
814 C[1]-=1.;
815 }
816
817
819 T = line->transform().rotation();
820 T *= Amg::Translation3D(C.x(),C.y(),C.z());
821 Trk::StraightLineSurface* surface = new Trk::StraightLineSurface(T);
822
823 Trk::PseudoMeasurementOnTrack *pseudo=new Trk::PseudoMeasurementOnTrack( std::move(par),
824 std::move(cov),
825 *surface);
826
827 tobedeleted.push_back(pseudo);
828
829 delete surface;
830
831 myset2.push_back(pseudo);
832 }
833 }
834 }
835 count2++;
836 }
837
838
839
840 const Trk::StraightLineSurface* testSf;
841 if((*isegEndcap)->globalPosition().y()>0){
842 testSf= dynamic_cast<const Trk::StraightLineSurface*>(&((*isegEndcap)->associatedSurface()));
843 }else{
844 testSf= dynamic_cast<const Trk::StraightLineSurface*>(&((*isegBarrel)->associatedSurface()));
845 }
846
847 const Trk::AtaStraightLine* inputMatchLine = nullptr;
848 const Trk::Perigee* inputMatchPerigee = nullptr;
849
850 if(!testSf){
851 ATH_MSG_VERBOSE("No straightLineSurface !! Trying Perigee ...");
852
853 const Trk::PerigeeSurface *testPSf=dynamic_cast<const Trk::PerigeeSurface*>(&((*isegBarrel)->associatedSurface()));
854
855 if(!testPSf){
856 ATH_MSG_VERBOSE("Associated surface dynamic_cast into PerigeeSurface failed. "<<(*isegBarrel)->associatedSurface());
857 ATH_MSG_VERBOSE("Leaving input matching perigee as nullptr, will not get a fittedTrack");
858 }else{
859 ATH_MSG_VERBOSE("Ok, it seems to be a PerigeeSurface");
860 inputMatchPerigee = new Trk::Perigee(inputMatchingPos,inputMatchingMom, 1., *testPSf);
861 }
862
863 }else{
864 inputMatchLine = new Trk::AtaStraightLine(inputMatchingPos,inputMatchingMom, 1., *testSf);
865 ATH_MSG_VERBOSE("Created testSf : " << (*inputMatchLine));
866 }
867
868 Amg::Vector3D startMomentum( 0., 0., 1.);
869 std::unique_ptr<Trk::Track> fittedTrack;
871 if(inputMatchLine){
872 fittedTrack=m_trackFitter->fit(ctx,
873 myset2,
874 *inputMatchLine,
875 false,
877 );
878 }else if (inputMatchPerigee){
879 fittedTrack=m_trackFitter->fit(ctx,
880 myset2,
881 *inputMatchPerigee,
882 false,
884 );
885 }
886 }else{
887 if(inputMatchLine){
888 fittedTrack=m_trackFitter->fit(ctx,
889 myset2,
890 *inputMatchLine,
891 false,
893 );
894 }else if (inputMatchPerigee){
895 fittedTrack=m_trackFitter->fit(ctx,
896 myset2,
897 *inputMatchPerigee,
898 false,
900 );
901 }
902 }
903
904 if(fittedTrack){
905 n_combined_fit++;
906 ATH_MSG_DEBUG("Successful Barrel+Endcap fit of segment. ");
907 ATH_MSG_DEBUG("Quality of Track: "<<fittedTrack->fitQuality()->chiSquared()<<" / "<<fittedTrack->fitQuality()->numberDoF());
908 ATH_MSG_VERBOSE(*fittedTrack);
909 outputCombiCollection->push_back(std::move(fittedTrack));
910}
911
912 delete inputMatchPerigee;
913 delete inputMatchLine;
914
915 for(size_t i=0;i<tobedeleted.size();i++)
916 delete tobedeleted[i];
917 tobedeleted.clear();
918 }
919 }
920 }
921 m_n_combined_fit += n_combined_fit;
922
923 if (!outputCombiCollection.isValid()) {
924 ATH_MSG_ERROR("Could not write track Barrel+EC collection TRT_Barrel_EC");
925 }
926}
#define M_PI
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
bool const RAWDATA *ch2 const
#define z
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
virtual const Trk::Surface & associatedSurface() const override final
returns the surface for the local to global transformation
ToolHandle< Trk::ITrackFitter > m_trackFitter
The TrackFitter.
SG::ReadHandleKey< Trk::SegmentCollection > m_endcapSegments
Name of Endcap segment collection.
SG::WriteHandleKey< TrackCollection > m_BECCollectionName
Name of the combined (TRT Barrel+EC) TrackCollection to write out.
SG::ReadHandleKey< Trk::SegmentCollection > m_barrelSegments
Name of Barrel segment collection.
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
virtual const Amg::Vector3D & globalPosition() const =0
Interface method to get the global Position.
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
int r
Definition globals.cxx:22
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
struct color C
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Translation< double, 3 > Translation3D
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
::StatusCode StatusCode
StatusCode definition for legacy code.
unsigned long long T
std::vector< const MeasurementBase * > MeasurementSet
vector of fittable measurements
Definition FitterTypes.h:30
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
ParametersT< TrackParametersDim, Charged, StraightLineSurface > AtaStraightLine
@ pz
global momentum (cartesian)
Definition ParamDefs.h:61
@ theta
Definition ParamDefs.h:66
@ qOverP
perigee
Definition ParamDefs.h:67
@ phi
Definition ParamDefs.h:75
@ locZ
local cylindrical
Definition ParamDefs.h:42
@ px
Definition ParamDefs.h:59
@ py
Definition ParamDefs.h:60
std::pair< double, ParamDefs > DefinedParameter
Typedef to of a std::pair<double, ParamDefs> to identify a passed-through double as a specific type o...
void reverse(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of reverse for DataVector/List.

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode InDet::TRT_SegmentsToTrack::execute ( )

Definition at line 137 of file TRT_SegmentsToTrack.cxx.

138{
139 int segmentCounter=0;
140 const EventContext& ctx = Gaudi::Hive::currentContext();
141 m_events++;
142
143 ATH_MSG_DEBUG(name() << " execute() start");
144
145 StatusCode sc = StatusCode::SUCCESS;
146
147 //combine segments
149 combineSegments(ctx);
150
151 // input TrackSegment Collection
152
153 SG::ReadHandle<Trk::SegmentCollection> inputSegments(m_inputSegmentCollectionName,ctx);
154 if (!inputSegments.isValid()) {
155 ATH_MSG_ERROR("Could not open: " <<m_inputSegmentCollectionName.key());
156 sc = StatusCode::FAILURE;
157 return sc;
158 }
159
160
161 //output collections for fitted tracks
162
163 SG::WriteHandle<TrackCollection> final_outputTrackCollection(m_outputTrackCollectionName,ctx);
164 ATH_CHECK(final_outputTrackCollection.record(std::make_unique<TrackCollection>()));
165
166 std::vector<std::unique_ptr<Trk::Track> > output_track_collection;
167 //try to get truth information
168
169 if(not m_multiTruthCollectionTRTName.empty()){
170 SG::ReadHandle<PRD_MultiTruthCollection> truthCollectionTRT(m_multiTruthCollectionTRTName,ctx);
171
172 if (!truthCollectionTRT.isValid()){
173 ATH_MSG_FATAL("Could not open PRD_MultiTruthCollection : " << m_multiTruthCollectionTRTName.key());
174 return StatusCode::FAILURE;
175 }
176 }
177
178 Trk::SegmentCollection::const_iterator iseg = inputSegments->begin();
179 Trk::SegmentCollection::const_iterator isegEnd = inputSegments->end();
180
181
182
183 for(iseg=inputSegments->begin(); iseg != isegEnd; ++ iseg) {
184
185 segmentCounter++;
186
187
188 if((*iseg)->numberOfMeasurementBases()<10) continue; //only convert segments that are large enough
189
191 for(unsigned int i=0;i<(*iseg)->numberOfMeasurementBases();++i){
192 const Amg::VectorX& LocalParameters = (*iseg)->measurement(i)->localParameters();
193 const Amg::MatrixX& LocalErrorMatrix = (*iseg)->measurement(i)->localCovariance();
194 double z=(*iseg)->measurement(i)->globalPosition().z();
195 ATH_MSG_DEBUG("Segment "<<segmentCounter<<" rioOnTrack "<<i<<" (z="<<z<<") : "<<LocalParameters[0]
196 <<" ; "<<std::sqrt(LocalErrorMatrix(Trk::locR,Trk::locR)));
197 myset.push_back((*iseg)->measurement(i));
198 } //end of loop over measurements
199
200 if((*iseg)->numberOfMeasurementBases()>0){
201 ATH_MSG_DEBUG("numberOfContainedRots: " << (*iseg)->numberOfMeasurementBases());
202
203 const Trk::StraightLineSurface* testSf
204 = dynamic_cast<const Trk::StraightLineSurface*>(&((*iseg)->associatedSurface()));
205
206
207 const Trk::AtaStraightLine* inputMatchLine =nullptr;
208 const Trk::Perigee* inputMatchPerigee =nullptr;
209 const Amg::VectorX &p = dynamic_cast<const Amg::VectorX&>((**iseg).localParameters());
210
211 if(!testSf){
212 ATH_MSG_DEBUG("No straightLineSurface !! Trying Perigee ...");
213 const Trk::PerigeeSurface *testPSf=dynamic_cast<const Trk::PerigeeSurface*>(&((*iseg)->associatedSurface()));
214
215 if(!testPSf){
216 ATH_MSG_DEBUG("Associated surface dynamic_cast into PerigeeSurface failed: "<<(*iseg)->associatedSurface());
217 ATH_MSG_DEBUG("Leaving input matching perigee as nullptr, will not get a fittedTrack");
218 }else{
219 ATH_MSG_DEBUG("Ok, it seems to be a PerigeeSurface");
220 inputMatchPerigee = new Trk::Perigee(p(0),p(1),p(2),p(3),p(4), *testPSf);
221 }
222 }else{
223 inputMatchLine = new Trk::AtaStraightLine(p(0),p(1),p(2),p(3),p(4),*testSf);
224
225 ATH_MSG_DEBUG("Created testSf : " << (*inputMatchLine));
226 int nmeas=(*iseg)->numberOfMeasurementBases();
227 Amg::Vector3D surfpos(.5*((*iseg)->measurement(nmeas/2)->globalPosition()+(*iseg)->measurement(nmeas/2+1)->globalPosition()));
228 Trk::PerigeeSurface persurf(surfpos);
229 std::unique_ptr<const Trk::TrackParameters> tmp =
230 m_extrapolator->extrapolateDirectly(ctx, *inputMatchLine, persurf);
231 if (tmp && tmp->associatedSurface().type() == Trk::SurfaceType::Perigee) {
232 inputMatchPerigee = static_cast<const Trk::Perigee*>(tmp.release());
233 }
234 }
235 ATH_MSG_DEBUG("Created inputMatchLine");
236
237 std::unique_ptr<Trk::Track> fittedTrack;
238 const Trk::TrackParameters *inputpar=nullptr;
239 if (inputMatchPerigee) inputpar=inputMatchPerigee;
240 else if (inputMatchLine) inputpar=inputMatchLine;
241
242 if (inputpar) {
243 fittedTrack = m_trackFitter->fit(ctx,
244 myset,
245 *inputpar,
248 }
249 if(fittedTrack){
250 Trk::TrackStates::const_iterator itSet = fittedTrack->trackStateOnSurfaces()->begin();
251 Trk::TrackStates::const_iterator itSetEnd = fittedTrack->trackStateOnSurfaces()->end();
252 const Trk::TrackParameters *measpar=nullptr;
253 double mindist=9999;
254 for ( ; itSet!=itSetEnd; ++itSet) {
255 if ((**itSet).type(Trk::TrackStateOnSurface::Measurement) && (**itSet).trackParameters()->position().perp()<mindist) {
256 mindist=(**itSet).trackParameters()->position().perp();
257 measpar=(**itSet).trackParameters();
258 }
259 }
260 std::unique_ptr<Trk::TrackParameters> myper;
261 if (measpar){
262 myper = m_extrapolator->extrapolate(ctx,*measpar,Trk::PerigeeSurface(),Trk::anyDirection,false, m_materialEffects ? Trk::muon : Trk::nonInteracting);
263 }
264 if (!myper){
265 fittedTrack.reset();
266 }
267 else {
268 auto trajectory = std::make_unique<Trk::TrackStates>();
269 itSet = fittedTrack->trackStateOnSurfaces()->begin();
270 for ( ; itSet!=itSetEnd; ++itSet) {
271 if (!(**itSet).type(Trk::TrackStateOnSurface::Perigee)) {
272 auto trackpar=(**itSet).trackParameters() ? (**itSet).trackParameters()->uniqueClone() : nullptr;
273 auto measurement=(**itSet).measurementOnTrack() ? (**itSet).measurementOnTrack()->uniqueClone() : nullptr;
274 auto fitQual=(**itSet).fitQualityOnSurface() ;
275 auto mateff=(**itSet).materialEffectsOnTrack() ? (**itSet).materialEffectsOnTrack()->uniqueClone() : nullptr;
276 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern(0);
278 else if ((**itSet).type(Trk::TrackStateOnSurface::Outlier)) typePattern.set(Trk::TrackStateOnSurface::Outlier);
279 else if ((**itSet).type(Trk::TrackStateOnSurface::Scatterer)) typePattern.set(Trk::TrackStateOnSurface::Scatterer);
280 else if ((**itSet).type(Trk::TrackStateOnSurface::BremPoint)) typePattern.set(Trk::TrackStateOnSurface::BremPoint);
281 trajectory->push_back(
282 new Trk::TrackStateOnSurface(fitQual,
283 std::move(measurement),
284 std::move(trackpar),
285 std::move(mateff),
286 typePattern));
287 }
288 }
289 bool peradded=false;
290 itSet = trajectory->begin()+1;
291 itSetEnd = trajectory->end();
292 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern(0);
293 typePattern.set(Trk::TrackStateOnSurface::Perigee);
294 const auto myPosition {myper->position()};
295 const auto myMomentum {myper->momentum()};
296 const Trk::TrackStateOnSurface* pertsos =
297 new Trk::TrackStateOnSurface(nullptr,
298 std::move(myper),
299 nullptr,
300 typePattern);
301
302 int index=1;
303 for ( ; itSet!=itSetEnd; ++itSet) {
304 double inprod1=((**itSet).trackParameters()->position()-myPosition).dot(myMomentum);
305 --itSet;
306 double inprod2=((**itSet).trackParameters()->position()-myPosition).dot(myMomentum);
307 ++itSet;
308 if (inprod1>0 && inprod2<0) {
309 trajectory->insert(trajectory->begin()+index,pertsos);
310 peradded=true;
311 break;
312 }
313 index++;
314 }
315 if (!peradded){
316 itSet = trajectory->begin();
317 double inprod=((**itSet).trackParameters()->position()-myPosition).dot(myMomentum);
318 if (inprod>0) trajectory->insert(trajectory->begin(),pertsos);
319 else trajectory->push_back(pertsos);
320 }
321 std::unique_ptr<Trk::Track> track =
322 std::make_unique<Trk::Track>(fittedTrack->info(),
323 std::move(trajectory),
324 fittedTrack->fitQuality()->uniqueClone());
325 fittedTrack = std::move(track);
326 }
327 }
328 if(fittedTrack){
329
330 int nHT=nHTHits(fittedTrack.get());
331 ATH_MSG_DEBUG("Number of HT hits: "<<nHT);
332 ATH_MSG_DEBUG(" Successful fit of track.");
333 if ((*iseg)->fitQuality()) ATH_MSG_DEBUG("Quality of Segment: chi^2 /ndof "<<(*iseg)->fitQuality()->chiSquared()<<" / "<<(*iseg)->fitQuality()->numberDoF());
334 ATH_MSG_DEBUG("Quality of Track: chi^2 /ndof "<<fittedTrack->fitQuality()->chiSquared()<<" / "<<fittedTrack->fitQuality()->numberDoF());
335 ATH_MSG_DEBUG("Noise probability: "<<getNoiseProbability(fittedTrack.get()));
336 ATH_MSG_DEBUG((*fittedTrack));
337
338 if( nTRTHits(fittedTrack.get())>=m_minTRTHits){
339 if(getNoiseProbability(fittedTrack.get())>m_noiseCut){
340 double truefraction=getRealFractionTRT(fittedTrack.get(),ctx);
341
342 int nhits=(*iseg)->numberOfMeasurementBases();
343 ATH_MSG_DEBUG("Real/Noise : "<< truefraction << " chi2="<<fittedTrack->fitQuality()->chiSquared()/double(fittedTrack->fitQuality()->numberDoF()));
344 if(truefraction>0.5){
345 ATH_MSG_DEBUG("==> Real Track");
346
347 if(m_MapReal.find(nhits)==m_MapReal.end()){
348 m_MapReal[nhits]=1;
349 }else{
350 m_MapReal[nhits]++;
351 }
352
354 m_noiseratio+=(1-truefraction);
355 }else{
356 ATH_MSG_DEBUG(" ==> Fake Track");
357
358 if(m_MapFake.find(nhits)==m_MapFake.end()){
359 m_MapFake[nhits]=1;
360 }else{
361 m_MapFake[nhits]++;
362 }
363
365 }
366 }
367 output_track_collection.push_back(std::move(fittedTrack));
368 }else{
369 ATH_MSG_DEBUG("This tracks has only "<<nTRTHits(fittedTrack.get())<<" Hits! Will reject it!");
370 }
371
372 }else{
373 ATH_MSG_DEBUG("Fit did not converge!");
374 } //end of if(fittedTrack)
375
376 delete inputMatchLine;
377 delete inputMatchPerigee;
378
379 } //end of if: (*iseg)->numberOfMeasurementBases()>0
380 } //end of loop over segments
381
382 std::unique_ptr<Trk::PRDtoTrackMap> prd_to_track_map;
383 if (m_assoTool.isEnabled()) {
384 // create internal PRD-to-track map
385 prd_to_track_map = m_assoTool->createPRDtoTrackMap();
386 if (!m_inputAssoMapName.key().empty()) {
387 SG::ReadHandle<Trk::PRDtoTrackMap> input_asso_map(m_inputAssoMapName,ctx);
388 if (!input_asso_map.isValid()) {
389 ATH_MSG_FATAL("No valid input PRT-to-track map with key " << m_inputAssoMapName.key());
390 }
391 *prd_to_track_map = *input_asso_map;
392 ATH_MSG_INFO("PRD to track map input " << m_inputAssoMapName.key() );
393 }
394 for (const std::unique_ptr<Trk::Track> &track : output_track_collection) {
395 ATH_CHECK( m_assoTool->addPRDs(*prd_to_track_map, *track) );
396 }
397 }
398 // @TODO sort output track collection ?
399 final_outputTrackCollection->reserve(output_track_collection.size());
400 if (m_trkSummaryTool.isEnabled()) {
401 for (std::unique_ptr<Trk::Track> &track : output_track_collection) {
402 m_trkSummaryTool->computeAndReplaceTrackSummary(*track,prd_to_track_map.get());
403 final_outputTrackCollection->push_back(std::move(track));
404 }
405 }
406 else {
407 for (std::unique_ptr<Trk::Track> &track : output_track_collection) {
408 final_outputTrackCollection->push_back(std::move(track));
409 }
410 }
411 if (!m_assoMapName.key().empty()) {
412 ATH_CHECK(SG::WriteHandle<Trk::PRDtoTrackMap>(m_assoMapName,ctx).record(std::move(prd_to_track_map)));
413 }
414
415 if (!final_outputTrackCollection.isValid()) {
416 // @TODO never reached (?)
417 ATH_MSG_ERROR("Could not write track collection " << m_outputTrackCollectionName.key());
418 return StatusCode::FAILURE;
419 //return sc;
420 }
421
422 return sc;
423}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
double getNoiseProbability(const Trk::Track *track) const
Get the fraction of noise TRT hits on this Track.
int nHTHits(const Trk::Track *track) const
Count number of TRT HT Hits on track.
ToolHandle< Trk::IExtrapolator > m_extrapolator
The Extrapolator.
SG::ReadHandleKey< Trk::SegmentCollection > m_inputSegmentCollectionName
Name of the TrackSegment Collection to read in.
double getRealFractionTRT(const Trk::Track *track, const EventContext &ctx) const
Get the fraction of truth TRT hits on this Track.
ToolHandle< Trk::IPRDtoTrackMapTool > m_assoTool
void combineSegments(const EventContext &ctx) const
SG::ReadHandleKey< PRD_MultiTruthCollection > m_multiTruthCollectionTRTName
Name of the TRT MultiTruthCollection.
std::map< int, int > m_MapReal
Map of hits and real tracks.
std::map< int, int > m_MapFake
Map of hits and fake tracks.
ToolHandle< Trk::IExtendedTrackSummaryTool > m_trkSummaryTool
SG::ReadHandleKey< Trk::PRDtoTrackMap > m_inputAssoMapName
key to be set to optionally store PRD to track association map
SG::WriteHandleKey< TrackCollection > m_outputTrackCollectionName
Name of the TrackCollection to write out.
SG::WriteHandleKey< Trk::PRDtoTrackMap > m_assoMapName
key for the PRDtoTrackMap to filled by the ambiguity score processor.
int nTRTHits(const Trk::Track *track) const
Count number of TRT Hits on track.
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
@ Perigee
This represents a perigee, and so will contain a Perigee object only.
@ BremPoint
This represents a brem point on the track, and so will contain TrackParameters and MaterialEffectsBas...
@ Outlier
This TSoS contains an outlier, that is, it contains a MeasurementBase/RIO_OnTrack which was not used ...
@ Scatterer
This represents a scattering point on the track, and so will contain TrackParameters and MaterialEffe...
str index
Definition DeMoScan.py:362
@ anyDirection
@ locR
Definition ParamDefs.h:44
ParametersBase< TrackParametersDim, Charged > TrackParameters

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}
DataObjIDColl m_extendedExtraObjects

◆ finalize()

StatusCode InDet::TRT_SegmentsToTrack::finalize ( )

Definition at line 111 of file TRT_SegmentsToTrack.cxx.

112{
113 ATH_MSG_INFO("Summary of" << m_events << " Events");
114 ATH_MSG_INFO("Found Real Tracks : " << m_nTracksReal);
115 ATH_MSG_INFO("Found Fake Tracks : " << m_nTracksFake);
116
117 if(m_nTracksReal>0) {
118 ATH_MSG_INFO("Average noise percentage " << m_noiseratio/double(m_nTracksReal));
119 }
120
121 for (const auto& mitr : m_MapReal) {
122 ATH_MSG_INFO("Real tracks with " << mitr.first << " hits: " << mitr.second);
123 }
124 for (const auto& mitr : m_MapFake) {
125 ATH_MSG_INFO("Fake tracks with " << mitr.first << " hits: " << mitr.second);
126 }
127
129 ATH_MSG_INFO("Number of combined Barrel+Endcap tracks: "<<m_n_combined_fit);
130 }
131
132 ATH_MSG_DEBUG(name() << " finalize() successful ");
133
134 return StatusCode::SUCCESS;
135}

◆ getNoiseProbability()

double InDet::TRT_SegmentsToTrack::getNoiseProbability ( const Trk::Track * track) const
private

Get the fraction of noise TRT hits on this Track.

Definition at line 534 of file TRT_SegmentsToTrack.cxx.

535{
536 double fraction=0.;
537 int nDriftReal=0;
538 int nDriftNoise=0;
539
540 //loop over the hits
541 for (const Trk::TrackStateOnSurface* tsos : *track->trackStateOnSurfaces()) {
542 const Trk::RIO_OnTrack* hitOnTrack = dynamic_cast <const Trk::RIO_OnTrack*>(tsos->measurementOnTrack());
543 if (hitOnTrack) {
544 const Identifier& surfaceID = hitOnTrack->identify();
545
546 //take only TRT hits
547 if(m_idHelper->is_trt(surfaceID)){
548
549 const InDet::TRT_DriftCircleOnTrack *dcot= dynamic_cast <const InDet::TRT_DriftCircleOnTrack*>(hitOnTrack);
550 if (dcot) {
551 const InDet::TRT_DriftCircle *dc=dcot->prepRawData();
552
553 if(dc){
554
555 if(dc->isNoise())
556 nDriftNoise++;
557 else
558 nDriftReal++;
559 }
560 }
561 }
562 }
563 }
564
565 if(nDriftReal>0)
566 fraction=double(nDriftReal)/double(nDriftNoise+nDriftReal);
567
568 return fraction;
569}
virtual const TRT_DriftCircle * prepRawData() const override final
returns the PrepRawData - is a TRT_DriftCircle in this scope
bool isNoise() const
returns true if the hit is caused by noise with a high probability.
Identifier identify() const
return the identifier -extends MeasurementBase

◆ getNumberReal()

int InDet::TRT_SegmentsToTrack::getNumberReal ( const InDet::TRT_DriftCircle * driftcircle,
const EventContext & ctx ) const
private

Get the number of truth particles associated with this hit.

Definition at line 425 of file TRT_SegmentsToTrack.cxx.

426{
427 int numBarcodes = 0;
428 using iter = PRD_MultiTruthCollection::const_iterator;
429
430 if(m_multiTruthCollectionTRTName.empty()) return 0;
431
432 else{
433 SG::ReadHandle<PRD_MultiTruthCollection> truthCollectionTRT(m_multiTruthCollectionTRTName,ctx);
434 if(truthCollectionTRT.isValid()){
435 std::pair<iter,iter> range = truthCollectionTRT->equal_range(driftcircle->identify());
436 numBarcodes+=std::distance(range.first,range.second);
437 }
438 }
439 return numBarcodes;
440}
Identifier identify() const
return the identifier

◆ getRealFractionTRT()

double InDet::TRT_SegmentsToTrack::getRealFractionTRT ( const Trk::Track * track,
const EventContext & ctx ) const
private

Get the fraction of truth TRT hits on this Track.

Definition at line 444 of file TRT_SegmentsToTrack.cxx.

445{
446 double fraction=0.;
447 int nDriftReal=0;
448 int nDriftNoise=0;
449
450 //loop over the hits
451 for (const Trk::TrackStateOnSurface* tsos : *track->trackStateOnSurfaces()) {
452
453 const Trk::RIO_OnTrack* hitOnTrack = dynamic_cast <const Trk::RIO_OnTrack*>(tsos->measurementOnTrack());
454 if (hitOnTrack) {
455 const Identifier& surfaceID = hitOnTrack->identify();
456
457 //take only TRT hits
458 if(m_idHelper->is_trt(surfaceID)){
459
460 const InDet::TRT_DriftCircleOnTrack *dcot= dynamic_cast <const InDet::TRT_DriftCircleOnTrack*>(hitOnTrack);
461 if(dcot) {
462 const InDet::TRT_DriftCircle *dc=dcot->prepRawData();
463
464 if(dc){
465 int nreal=getNumberReal(dc,ctx);
466
467 if(nreal>0) nDriftReal++;
468 else nDriftNoise++;
469
470 }
471 }
472 }
473 }
474 }
475
476 if(nDriftReal>0)
477 fraction=double(nDriftReal)/double(nDriftNoise+nDriftReal);
478
479 return fraction;
480}
int getNumberReal(const InDet::TRT_DriftCircle *, const EventContext &ctx) const
Get the number of truth particles associated with this hit.

◆ initialize()

StatusCode InDet::TRT_SegmentsToTrack::initialize ( )

Definition at line 76 of file TRT_SegmentsToTrack.cxx.

77{
78
79 ATH_MSG_DEBUG("TrkSegmenttoTrack initialize()");
80
82
85 m_events=0;
86 m_noiseratio=0.;
87
88 // Initialize handle keys
94 ATH_CHECK(m_BECCollectionName.initialize());
95
96 //--------- Set up fitter -------------
97 CHECK( m_trackFitter.retrieve());
98
100
101 CHECK(detStore()->retrieve(m_idHelper, "AtlasID"));
102
103 CHECK(m_extrapolator.retrieve());
104 ATH_CHECK(m_trkSummaryTool.retrieve( DisableTool{ m_trkSummaryTool.empty() } ));
105 ATH_CHECK(m_assoTool.retrieve( DisableTool{ m_assoTool.empty() || (m_trkSummaryTool.empty() && m_assoMapName.empty()) } ));
106 ATH_CHECK(m_inputAssoMapName.initialize( !m_inputAssoMapName.empty() && m_assoTool.isEnabled()));
107 ATH_CHECK(m_assoMapName.initialize( !m_assoMapName.empty() && m_assoTool.isEnabled()));
108 return StatusCode::SUCCESS;
109}
#define CHECK(...)
Evaluate an expression and check for errors.
const ServiceHandle< StoreGateSvc > & detStore() const
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg()

MsgStream & AthCommonMsg< Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ nHTHits()

int InDet::TRT_SegmentsToTrack::nHTHits ( const Trk::Track * track) const
private

Count number of TRT HT Hits on track.

Definition at line 483 of file TRT_SegmentsToTrack.cxx.

484{
485
486 int nHT=0;
487
488 //loop over the hits
489 for (const Trk::TrackStateOnSurface* tsos : *track->trackStateOnSurfaces()) {
490
491 const Trk::RIO_OnTrack* hitOnTrack = dynamic_cast <const Trk::RIO_OnTrack*>(tsos->measurementOnTrack());
492 if (hitOnTrack != nullptr) {
493 const Identifier& surfaceID = hitOnTrack->identify();
494
495 //take only TRT hits
496 if(m_idHelper->is_trt(surfaceID) && !tsos->type(Trk::TrackStateOnSurface::Outlier)){
497 const InDet::TRT_DriftCircleOnTrack* trtcirc = dynamic_cast<const InDet::TRT_DriftCircleOnTrack*>(hitOnTrack);
498 if(trtcirc) {
499 if(trtcirc->highLevel()){
500 nHT++;
501 }
502 }
503 }
504 }
505 }
506
507 return nHT;
508}
bool highLevel() const
returns true if the high level threshold was passed

◆ nTRTHits()

int InDet::TRT_SegmentsToTrack::nTRTHits ( const Trk::Track * track) const
private

Count number of TRT Hits on track.

Definition at line 512 of file TRT_SegmentsToTrack.cxx.

513{
514 int nhits=0;
515
516 //loop over the hits
517 for (const Trk::TrackStateOnSurface* tsos : *track->trackStateOnSurfaces()) {
518
519 const Trk::RIO_OnTrack* hitOnTrack = dynamic_cast <const Trk::RIO_OnTrack*>(tsos->measurementOnTrack());
520 if (hitOnTrack != nullptr) {
521 const Identifier& surfaceID = hitOnTrack->identify();
522
523 //take only TRT hits
524 if(m_idHelper->is_trt(surfaceID) && !tsos->type(Trk::TrackStateOnSurface::Outlier)){
525 nhits++;
526 }
527 }
528 }
529
530 return nhits;
531}

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
#define ATH_MSG_WARNING(x)
virtual StatusCode sysInitialize() override
Override sysInitialize.
AthCommonDataStore(const std::string &name, T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_assoMapName

SG::WriteHandleKey<Trk::PRDtoTrackMap> InDet::TRT_SegmentsToTrack::m_assoMapName {this,"AssociationMapName","",""}
private

key for the PRDtoTrackMap to filled by the ambiguity score processor.

key to be set to optionally store PRD to track association map

Definition at line 93 of file TRT_SegmentsToTrack.h.

94{this,"AssociationMapName","",""};

◆ m_assoTool

ToolHandle<Trk::IPRDtoTrackMapTool> InDet::TRT_SegmentsToTrack::m_assoTool {this, "AssociationTool", "","" }
private

Definition at line 90 of file TRT_SegmentsToTrack.h.

91{this, "AssociationTool", "","" };

◆ m_barrelSegments

SG::ReadHandleKey<Trk::SegmentCollection> InDet::TRT_SegmentsToTrack::m_barrelSegments {this,"BarrelSegments","TRTBarrelSegments","RHK to retrieve barrel track segments"}
private

Name of Barrel segment collection.

Definition at line 124 of file TRT_SegmentsToTrack.h.

124{this,"BarrelSegments","TRTBarrelSegments","RHK to retrieve barrel track segments"};

◆ m_BECCollectionName

SG::WriteHandleKey<TrackCollection> InDet::TRT_SegmentsToTrack::m_BECCollectionName {this,"BarrelEndcapTracks","TRT_Barrel_EC","WHK to write tracks"}
private

Name of the combined (TRT Barrel+EC) TrackCollection to write out.

Definition at line 127 of file TRT_SegmentsToTrack.h.

127{this,"BarrelEndcapTracks","TRT_Barrel_EC","WHK to write tracks"};

◆ m_combineSegments

bool InDet::TRT_SegmentsToTrack::m_combineSegments
private

Try to combine segments from Barrel and Endcap.

Definition at line 122 of file TRT_SegmentsToTrack.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_endcapSegments

SG::ReadHandleKey<Trk::SegmentCollection> InDet::TRT_SegmentsToTrack::m_endcapSegments {this,"EndcapSegments","TRTEndcapSegments","RHK to retrieve endcap track segments"}
private

Name of Endcap segment collection.

Definition at line 125 of file TRT_SegmentsToTrack.h.

125{this,"EndcapSegments","TRTEndcapSegments","RHK to retrieve endcap track segments"};

◆ m_events

std::atomic<int> InDet::TRT_SegmentsToTrack::m_events
mutableprivate

Event counter.

Definition at line 114 of file TRT_SegmentsToTrack.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_extrapolator

ToolHandle<Trk::IExtrapolator> InDet::TRT_SegmentsToTrack::m_extrapolator {this,"ExtrapolationTool","Trk::Extrapolator/InDetExtrapolator",""}
private

The Extrapolator.

Definition at line 85 of file TRT_SegmentsToTrack.h.

86{this,"ExtrapolationTool","Trk::Extrapolator/InDetExtrapolator",""};

◆ m_idHelper

const AtlasDetectorID* InDet::TRT_SegmentsToTrack::m_idHelper
private

Definition at line 102 of file TRT_SegmentsToTrack.h.

◆ m_inputAssoMapName

SG::ReadHandleKey<Trk::PRDtoTrackMap> InDet::TRT_SegmentsToTrack::m_inputAssoMapName {this,"InputAssociationMapName","",""}
private

key to be set to optionally store PRD to track association map

Definition at line 95 of file TRT_SegmentsToTrack.h.

96{this,"InputAssociationMapName","",""};

◆ m_inputSegmentCollectionName

SG::ReadHandleKey<Trk::SegmentCollection> InDet::TRT_SegmentsToTrack::m_inputSegmentCollectionName {this,"InputSegmentsCollection","TrackSegments","RHK to retrieve input track collection"}
private

Name of the TrackSegment Collection to read in.

Definition at line 78 of file TRT_SegmentsToTrack.h.

78{this,"InputSegmentsCollection","TrackSegments","RHK to retrieve input track collection"};

◆ m_MapFake

std::map<int,int> InDet::TRT_SegmentsToTrack::m_MapFake
private

Map of hits and fake tracks.

Definition at line 116 of file TRT_SegmentsToTrack.h.

◆ m_MapReal

std::map<int,int> InDet::TRT_SegmentsToTrack::m_MapReal
private

Map of hits and real tracks.

Definition at line 115 of file TRT_SegmentsToTrack.h.

◆ m_materialEffects

bool InDet::TRT_SegmentsToTrack::m_materialEffects
private

Flag to switch on Material Effects in the Fitter.

Definition at line 118 of file TRT_SegmentsToTrack.h.

◆ m_minTRTHits

int InDet::TRT_SegmentsToTrack::m_minTRTHits
private

All tracks with less Hits (after the track fit) will be thrown away.

Definition at line 100 of file TRT_SegmentsToTrack.h.

◆ m_multiTruthCollectionTRTName

SG::ReadHandleKey<PRD_MultiTruthCollection> InDet::TRT_SegmentsToTrack::m_multiTruthCollectionTRTName {this,"PRDTruthCollectionTRT","","RHK to retrieve TRT turth info"}
private

Name of the TRT MultiTruthCollection.

Definition at line 107 of file TRT_SegmentsToTrack.h.

107{this,"PRDTruthCollectionTRT","","RHK to retrieve TRT turth info"};

◆ m_n_combined_fit

std::atomic<int> InDet::TRT_SegmentsToTrack::m_n_combined_fit
mutableprivate

Definition at line 129 of file TRT_SegmentsToTrack.h.

◆ m_noiseCut

double InDet::TRT_SegmentsToTrack::m_noiseCut
private

All tracks with a TRT Noise fraction larger than this variable will be thrown away.

Definition at line 99 of file TRT_SegmentsToTrack.h.

◆ m_noiseratio

double InDet::TRT_SegmentsToTrack::m_noiseratio
private

average percentage of noise in real tracks

Definition at line 112 of file TRT_SegmentsToTrack.h.

◆ m_nTracksFake

int InDet::TRT_SegmentsToTrack::m_nTracksFake
private

Counter for fake reconstructed Track.

Definition at line 110 of file TRT_SegmentsToTrack.h.

◆ m_nTracksReal

int InDet::TRT_SegmentsToTrack::m_nTracksReal
private

Counter for real reconstructed Tracks.

Definition at line 109 of file TRT_SegmentsToTrack.h.

◆ m_outlierRemoval

bool InDet::TRT_SegmentsToTrack::m_outlierRemoval
private

Flag to switch on the outlier removal in the track fitter.

Definition at line 119 of file TRT_SegmentsToTrack.h.

◆ m_outputTrackCollectionName

SG::WriteHandleKey<TrackCollection> InDet::TRT_SegmentsToTrack::m_outputTrackCollectionName {this,"OutputTrackCollection","SegmentTracks","WHK to store output tracks"}
private

Name of the TrackCollection to write out.

Definition at line 80 of file TRT_SegmentsToTrack.h.

80{this,"OutputTrackCollection","SegmentTracks","WHK to store output tracks"};

◆ m_trackFitter

ToolHandle<Trk::ITrackFitter> InDet::TRT_SegmentsToTrack::m_trackFitter {this,"TrackFitter","Trk::KalmanFitter/TrkKalmanFitter",""}
private

The TrackFitter.

Definition at line 82 of file TRT_SegmentsToTrack.h.

83{this,"TrackFitter","Trk::KalmanFitter/TrkKalmanFitter",""};

◆ m_trkSummaryTool

ToolHandle<Trk::IExtendedTrackSummaryTool> InDet::TRT_SegmentsToTrack::m_trkSummaryTool {this, "SummaryTool","",""}
private

Definition at line 88 of file TRT_SegmentsToTrack.h.

89{this, "SummaryTool","",""};

◆ m_trtid

const TRT_ID* InDet::TRT_SegmentsToTrack::m_trtid
private

Definition at line 104 of file TRT_SegmentsToTrack.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: