744 {
745
746
747 if (hitlist.empty())
748 return true;
749
750
751 static double unknown = -1.0e99;
752 double mom(unknown),
time(unknown);
753 if (p) {
755 if (v) {
757 time =
v->position().t()/CLHEP::c_light;
758
759 }
760 }
761
762
763
764
765
766 bool sawhitwithoutmominfo(false);
767 bool sawhitwithmominfo(mom!=unknown);
768 SimHitList::iterator
it(hitlist.begin()), itE(hitlist.end());
769 for (;
it!=itE;++
it) {
770 const bool hasinfo =
it->second->momentum()>=0.0;
771 if (hasinfo)
772 sawhitwithmominfo = true;
773 else
774 sawhitwithoutmominfo = true;
775 if (sawhitwithoutmominfo&&sawhitwithmominfo)
776 break;
777 }
778
779 if (!sawhitwithoutmominfo) {
780
781 return true;
782 }
783 if (!sawhitwithmominfo) {
784
785 theclass->messageDebug(
"Discarding hitlist." );
786 SimHitList::iterator
it(hitlist.begin()), itE(hitlist.end());
789 hitlist.clear();
790 return false;
791 }
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807 if (mom==unknown) {
808 if (hitlist.at(0).second->momentum()<0.0) {
809 SimHitList::iterator
it(hitlist.begin()), itE(hitlist.end());
810 for (;
it!=itE;++
it) {
811 if (
it->second->momentum()>=0.0) {
812 hitlist.at(0).second->setFakeMomentum(
it->second->momentum()*1.00001);
813 break;
814 }
815 }
816 if (hitlist.at(0).second->momentum()<0.0) {
817 theclass->messageDebug(
"fixMomentumInfoInSimHits ERROR: Should not happen! (1)" );
818
819 return false;
820 }
821 }
822 mom = hitlist.at(0).second->momentum();
823 time = hitlist.at(0).second->hitTime();
824 }
825
826
827
828
829
830
831 unsigned ilast = hitlist.size()-1;
832 if (hitlist.at(ilast).second->momentum()<0.0) {
833 for (int iLastWithMom = ilast-1;iLastWithMom>=0;--iLastWithMom) {
834 if (hitlist.at(iLastWithMom).second->momentum()>0.0) {
835 hitlist.at(ilast).second->setFakeMomentum(hitlist.at(iLastWithMom).second->momentum()*0.99999);
836 break;
837 }
838 }
839 if (hitlist.at(ilast).second->momentum()<0.0) {
840
841 if (mom==unknown) {
842 theclass->messageDebug(
"fixMomentumInfoInSimHits ERROR: Should not happen! (2)" );
843
844 return false;
845 }
846 hitlist.at(ilast).second->setFakeMomentum(mom*0.99999);
847 }
848 }
849
850
851 if (mom==unknown||time==unknown) {
852
853 mom = hitlist.at(0).second->momentum();
854 time = hitlist.at(0).second->hitTime();
855 }
856
857 unsigned iNextWithMom(0);
858 for (
unsigned i = 0;
i < hitlist.size(); ++
i) {
859 if (hitlist.at(i).second->momentum()>=0.0) {
860 mom = hitlist.at(i).second->momentum();
861 time = hitlist.at(i).second->hitTime();
862 continue;
863 }
864 if (iNextWithMom<=i) {
865 for (
unsigned j = i+1;
j<hitlist.size();++
j) {
866 if (hitlist.at(j).second->momentum()>=0.0) {
868 break;
869 }
870 }
871 if (iNextWithMom<=i) {
872 theclass->messageDebug(
"fixMomentumInfoInSimHits ERROR: Should not happen! (3)" );
873
874 return false;
875 }
876 }
877
878 double time2 = hitlist.at(iNextWithMom).second->hitTime();
879 double mom2 = hitlist.at(iNextWithMom).second->momentum();
880 double t = hitlist.at(i).second->hitTime();
881
882
883 if (t<=time||t>=time2||time2<=time)
884 theclass->message(
"SUSPICIOUS TIME");
885 if (mom2>=mom)
886 theclass->message(
"SUSPICIOUS MOM mom="+
str(mom)+
", mom2="+
str(mom2));
889 hitlist.at(i).second->setFakeMomentum(mom);
890 }
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946 return true;
947
948}
Scalar mag() const
mag method
time(flags, cells_name, *args, **kw)
HepMC3::ConstGenVertexPtr ConstGenVertexPtr
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)