@@ -533,6 +533,7 @@ public Pair<Double, Double> getIsoAndT0(MeasurementSite ms){
533533 List <Measurement > allHits =sensor .hits ;
534534 if (allHits .size ()>2 && ms .hitID >-1 ){
535535 Measurement hitOnTrack = allHits .get (ms .hitID );
536+ double hitTime =hitOnTrack .time ;
536537 double [] hpsSensorPos =KalmanInterface .localKalToHps (sensor .p .X ());
537538 // keep track of sensor position & orientation
538539 // use the sign of the global plane position (vertical = z)
@@ -546,11 +547,17 @@ public Pair<Double, Double> getIsoAndT0(MeasurementSite ms){
546547 //sort the hits on the module by increasing v
547548 Collections .sort (allHits ,Measurement .MeasurementComparatorUp );
548549 // now get the position of nearest hit _away_ from beam
549- // the hits on the SiModule are sorted by v
550- int isoID =ms .hitID +awayFromBeam *1 ;
551- if (isoID <allHits .size () &&isoID >-1 ){
552- iso =Math .abs (allHits .get (isoID ).v -allHits .get (ms .hitID ).v );
553- isot0 =allHits .get (isoID ).time ;
550+ // within 40ns of original hit
551+ int nSteps =1 ;
552+ int isoID =ms .hitID +awayFromBeam *nSteps ;
553+ while (isoID <allHits .size () && isoID >-1 ){
554+ if (Math .abs (allHits .get (isoID ).time -hitTime )<40.0 ){
555+ iso =Math .abs (allHits .get (isoID ).v -hitOnTrack .v );
556+ isot0 =allHits .get (isoID ).time ;
557+ break ;
558+ }//otherwise step to the next one
559+ nSteps ++;
560+ isoID =ms .hitID +awayFromBeam *nSteps ;
554561 }
555562 return new Pair <Double , Double >(iso , isot0 );
556563 }else {
0 commit comments