573{
574
575
576
577
578 int n_combined_fit=0;
579 SG::ReadHandle<Trk::SegmentCollection> BarrelSegments(
m_barrelSegments,ctx);
580 SG::ReadHandle<Trk::SegmentCollection> EndcapSegments(
m_endcapSegments,ctx);
581
583
585 sc = outputCombiCollection.record(std::make_unique<TrackCollection>());
586 if (
sc.isFailure())
return;
587
588 if (!BarrelSegments.isValid()){
590 return;
591 }
592
593 if (!EndcapSegments.isValid()) {
595 return;
596 }
597
598 ATH_MSG_VERBOSE(
"Got both barrel and endcap segment collections of size "<<BarrelSegments->size()<<
" "<<EndcapSegments->size());
599
602
604 for(;iseg!=isegE;++iseg,
scount++){
606 }
607
608 iseg = EndcapSegments->begin();
609 isegE = EndcapSegments->end();
610
612 for(;iseg!=isegE;++iseg,
scount++){
614 }
615
616 if(BarrelSegments->size()==1 && EndcapSegments->size()==1){
617 ATH_MSG_VERBOSE(
"Here we go: one barrel segment and one endcap segment!");
618
621
624
625
626 for(;isegBarrel!=isegBarrelE;++isegBarrel){
627 for(;isegEndcap!=isegEndcapE;++isegEndcap){
628
629 std::vector< Trk::PseudoMeasurementOnTrack*> tobedeleted;
630
631 ATH_MSG_VERBOSE(
"Barrel Segment : phi="<<(*isegBarrel)->localParameters()[
Trk::phi]<<
" with "<<(*isegBarrel)->numberOfMeasurementBases()<<
" hits");
632 ATH_MSG_VERBOSE(
"Endcap Segment : phi="<<(*isegEndcap)->localParameters()[
Trk::phi]<<
" with "<<(*isegEndcap)->numberOfMeasurementBases()<<
" hits");
633
636
637 bool barreldown=((*isegBarrel)->measurement((*isegBarrel)->numberOfMeasurementBases()/2)->globalPosition().y()<0);
639 if((*isegEndcap)->localParameters().contains(
Trk::theta)){
641 }
642
643
644 if(( (*isegEndcap)->globalPosition().y()>0 && (*isegEndcap)->globalPosition().z()>0) ||
645 ((*isegEndcap)->globalPosition().y()<0 && (*isegEndcap)->globalPosition().z()<0)
646 ){
647
648
652 }
653 }else{
654
658 }
659 }
660
661
662
663 if(!barreldown && (*isegEndcap)->globalPosition().y()>0){
664 ATH_MSG_VERBOSE(
"Both barrel and endcap segments in top sectors, won't fit");
665 continue;
666 }
667
668 if(barreldown && (*isegEndcap)->globalPosition().y()<0){
669 ATH_MSG_VERBOSE(
"Both barrel and endcap segments in lower sectors, won't fit");
670 continue;
671 }
672 int firstechit=0,lastechit=0;
673 if((*isegEndcap)->globalPosition().y()>0){
674
675 for(
int i=0;
i<(
int)echits.size();++
i){
676 const Trk::MeasurementBase *meas=echits[
i];
682
683 const InDet::TRT_DriftCircleOnTrack* trtcirc = dynamic_cast<const InDet::TRT_DriftCircleOnTrack*>(meas);
684 if(trtcirc){
685 myset.push_back(meas);
688 }
689 }
690 firstechit=0;
692
693 for(
unsigned int i=0;
i<(*isegBarrel)->numberOfMeasurementBases();++
i){
694 const Amg::VectorX LocalParameters = (*isegBarrel)->measurement(i)->localParameters();
695 const Amg::MatrixX LocalErrorMatrix = (*isegBarrel)->measurement(i)->localCovariance();
696 double z=(*isegBarrel)->measurement(i)->globalPosition().z();
697 double phi=(*isegBarrel)->measurement(i)->globalPosition().phi();
698 double r=(*isegBarrel)->measurement(i)->globalPosition().perp();
699
700 const Trk::MeasurementBase *mesb=(*isegBarrel)->measurement(i);
701 const InDet::TRT_DriftCircleOnTrack* trtcirc = dynamic_cast<const InDet::TRT_DriftCircleOnTrack*>(mesb);
702 if(trtcirc){
703 myset.push_back((*isegBarrel)->measurement(i));
706 }
707
708 }
709 }else{
710
711 for(
unsigned int i=0;
i<(*isegBarrel)->numberOfMeasurementBases();++
i){
712 const Amg::VectorX LocalParameters = (*isegBarrel)->measurement(i)->localParameters();
713 const Amg::MatrixX LocalErrorMatrix = (*isegBarrel)->measurement(i)->localCovariance();
714 double z=(*isegBarrel)->measurement(i)->globalPosition().z();
715 double phi=(*isegBarrel)->measurement(i)->globalPosition().phi();
716 double r=(*isegBarrel)->measurement(i)->globalPosition().perp();
717
718 const Trk::MeasurementBase *mesb=(*isegBarrel)->measurement(i);
719 const InDet::TRT_DriftCircleOnTrack* trtcirc = dynamic_cast<const InDet::TRT_DriftCircleOnTrack*>(mesb);
720 if(trtcirc){
721 myset.push_back((*isegBarrel)->measurement(i));
724 }
725
726 }
728
729 for(
int i=0;
i<(
int)echits.size();++
i){
730 const Trk::MeasurementBase *meas=echits[
i];
736
737 const InDet::TRT_DriftCircleOnTrack* trtcirc = dynamic_cast<const InDet::TRT_DriftCircleOnTrack*>(meas);
738 if(trtcirc){
739 myset.push_back(meas);
742 }
743
744 }
746 }
747
748
749
750 Amg::Vector3D inputMatchingPos((*isegBarrel)->globalPosition());
751
752 if((*isegEndcap)->globalPosition().y()>0)
753 inputMatchingPos=(*isegEndcap)->globalPosition();
754
757
758 if((*isegBarrel)->localParameters().contains(
Trk::qOverP)){
759 p = ((*isegBarrel)->localParameters()[
Trk::qOverP]!=0.) ? fabs(1./((*isegBarrel)->localParameters()[
Trk::qOverP])) : 10e7;
760 }
761
763 if((*isegBarrel)->localParameters().contains(
Trk::phi)){
765 }
766
767
771
772
773 ATH_MSG_VERBOSE(
"Global position: "<<inputMatchingPos<<
" Globalmomentum: "<<inputMatchingMom);
774
775
776
777
778 Trk::MeasurementSet::const_iterator mit;
779 Trk::MeasurementSet::const_iterator mitE=myset.end();
780
781 int count2=0;
782 for(mit=myset.begin();mit!=mitE;++mit){
783 myset2.push_back(*mit);
784 if(count2==firstechit || count2==lastechit){
785 const InDet::TRT_DriftCircleOnTrack* trtcirc = dynamic_cast<const InDet::TRT_DriftCircleOnTrack*>(*mit);
786 if(trtcirc){
787 const Trk::StraightLineSurface *
line=
dynamic_cast<const
789 if (line) {
790
791 double locz=-200.;
792 if ((count2==firstechit && firstechit!=0) || (count2==lastechit && firstechit==0)) locz=200;
794 Trk::LocalParameters
par(dp);
795
798
799
801
802
803
805
806 if(fabs(gpos.z())>800){
809 }else{
811 }
812 }else{
814 }
815
816
818 T =
line->transform().rotation();
820 Trk::StraightLineSurface* surface = new Trk::StraightLineSurface(T);
821
822 Trk::PseudoMeasurementOnTrack *pseudo=new Trk::PseudoMeasurementOnTrack( std::move(par),
823 std::move(cov),
824 *surface);
825
826 tobedeleted.push_back(pseudo);
827
828 delete surface;
829
830 myset2.push_back(pseudo);
831 }
832 }
833 }
834 count2++;
835 }
836
837
838
839 const Trk::StraightLineSurface* testSf;
840 if((*isegEndcap)->globalPosition().y()>0){
841 testSf= dynamic_cast<const Trk::StraightLineSurface*>(&((*isegEndcap)->associatedSurface()));
842 }else{
843 testSf= dynamic_cast<const Trk::StraightLineSurface*>(&((*isegBarrel)->associatedSurface()));
844 }
845
848
849 if(!testSf){
851
852 const Trk::PerigeeSurface *testPSf=dynamic_cast<const Trk::PerigeeSurface*>(&((*isegBarrel)->associatedSurface()));
853
854 if(!testPSf){
855 ATH_MSG_VERBOSE(
"Associated surface dynamic_cast into PerigeeSurface failed. "<<(*isegBarrel)->associatedSurface());
856 ATH_MSG_VERBOSE(
"Leaving input matching perigee as nullptr, will not get a fittedTrack");
857 }else{
859 inputMatchPerigee =
new Trk::Perigee(inputMatchingPos,inputMatchingMom, 1., *testPSf);
860 }
861
862 }else{
865 }
866
868 std::unique_ptr<Trk::Track> fittedTrack;
870 if(inputMatchLine){
872 myset2,
873 *inputMatchLine,
874 false,
876 );
877 }else if (inputMatchPerigee){
879 myset2,
880 *inputMatchPerigee,
881 false,
883 );
884 }
885 }else{
886 if(inputMatchLine){
888 myset2,
889 *inputMatchLine,
890 false,
892 );
893 }else if (inputMatchPerigee){
895 myset2,
896 *inputMatchPerigee,
897 false,
899 );
900 }
901 }
902
903 if(fittedTrack){
904 n_combined_fit++;
906 ATH_MSG_DEBUG(
"Quality of Track: "<<fittedTrack->fitQuality()->chiSquared()<<
" / "<<fittedTrack->fitQuality()->numberDoF());
908 outputCombiCollection->push_back(std::move(fittedTrack));
909}
910
911 delete inputMatchPerigee;
912 delete inputMatchLine;
913
914 for(
size_t i=0;
i<tobedeleted.size();
i++)
915 delete tobedeleted[i];
916 tobedeleted.clear();
917 }
918 }
919 }
921
922 if (!outputCombiCollection.isValid()) {
923 ATH_MSG_ERROR(
"Could not write track Barrel+EC collection TRT_Barrel_EC");
924 }
925}
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_MSG_VERBOSE(x)
DataModel_detail::const_iterator< DataVector > const_iterator
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 count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
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.
const
helper method to get the collection index (into m_inputCollectionsName) and tuple index (into m_tuple...
::StatusCode StatusCode
StatusCode definition for legacy code.
std::vector< const MeasurementBase * > MeasurementSet
vector of fittable measurements
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
ParametersT< TrackParametersDim, Charged, StraightLineSurface > AtaStraightLine
@ pz
global momentum (cartesian)
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.