741 {
742
743
744 if (hitlist.empty())
745 return true;
746
747
748 static double unknown = -1.0e99;
749 double mom(unknown),
time(unknown);
750 if (p) {
752 if (v) {
753 mom =
p->momentum().length();
754 time =
v->position().t()/CLHEP::c_light;
755
756 }
757 }
758
759
760
761
762
763 bool sawhitwithoutmominfo(false);
764 bool sawhitwithmominfo(mom!=unknown);
765 SimHitList::iterator
it(hitlist.begin()), itE(hitlist.end());
766 for (;
it!=itE;++
it) {
767 const bool hasinfo =
it->second->momentum()>=0.0;
768 if (hasinfo)
769 sawhitwithmominfo = true;
770 else
771 sawhitwithoutmominfo = true;
772 if (sawhitwithoutmominfo&&sawhitwithmominfo)
773 break;
774 }
775
776 if (!sawhitwithoutmominfo) {
777
778 return true;
779 }
780 if (!sawhitwithmominfo) {
781
782 theclass->messageDebug(
"Discarding hitlist." );
783 SimHitList::iterator
it(hitlist.begin()), itE(hitlist.end());
786 hitlist.clear();
787 return false;
788 }
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804 if (mom==unknown) {
805 if (hitlist.at(0).second->momentum()<0.0) {
806 SimHitList::iterator
it(hitlist.begin()), itE(hitlist.end());
807 for (;
it!=itE;++
it) {
808 if (
it->second->momentum()>=0.0) {
809 hitlist.at(0).second->setFakeMomentum(
it->second->momentum()*1.00001);
810 break;
811 }
812 }
813 if (hitlist.at(0).second->momentum()<0.0) {
814 theclass->messageDebug(
"fixMomentumInfoInSimHits ERROR: Should not happen! (1)" );
815
816 return false;
817 }
818 }
819 mom = hitlist.at(0).second->momentum();
820 time = hitlist.at(0).second->hitTime();
821 }
822
823
824
825
826
827
828 unsigned ilast = hitlist.size()-1;
829 if (hitlist.at(ilast).second->momentum()<0.0) {
830 for (int iLastWithMom = ilast-1;iLastWithMom>=0;--iLastWithMom) {
831 if (hitlist.at(iLastWithMom).second->momentum()>0.0) {
832 hitlist.at(ilast).second->setFakeMomentum(hitlist.at(iLastWithMom).second->momentum()*0.99999);
833 break;
834 }
835 }
836 if (hitlist.at(ilast).second->momentum()<0.0) {
837
838 if (mom==unknown) {
839 theclass->messageDebug(
"fixMomentumInfoInSimHits ERROR: Should not happen! (2)" );
840
841 return false;
842 }
843 hitlist.at(ilast).second->setFakeMomentum(mom*0.99999);
844 }
845 }
846
847
848 if (mom==unknown||time==unknown) {
849
850 mom = hitlist.at(0).second->momentum();
851 time = hitlist.at(0).second->hitTime();
852 }
853
854 unsigned iNextWithMom(0);
855 for (
unsigned i = 0;
i < hitlist.size(); ++
i) {
856 if (hitlist.at(i).second->momentum()>=0.0) {
857 mom = hitlist.at(i).second->momentum();
858 time = hitlist.at(i).second->hitTime();
859 continue;
860 }
861 if (iNextWithMom<=i) {
862 for (
unsigned j = i+1;
j<hitlist.size();++
j) {
863 if (hitlist.at(j).second->momentum()>=0.0) {
865 break;
866 }
867 }
868 if (iNextWithMom<=i) {
869 theclass->messageDebug(
"fixMomentumInfoInSimHits ERROR: Should not happen! (3)" );
870
871 return false;
872 }
873 }
874
875 double time2 = hitlist.at(iNextWithMom).second->hitTime();
876 double mom2 = hitlist.at(iNextWithMom).second->momentum();
877 double t = hitlist.at(i).second->hitTime();
878
879
880 if (t<=time||t>=time2||time2<=time)
881 theclass->message(
"SUSPICIOUS TIME");
882 if (mom2>=mom)
883 theclass->message(
"SUSPICIOUS MOM mom="+
str(mom)+
", mom2="+
str(mom2));
886 hitlist.at(i).second->setFakeMomentum(mom);
887 }
888
889
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 return true;
944
945}
time(flags, cells_name, *args, **kw)
HepMC3::ConstGenVertexPtr ConstGenVertexPtr
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)