diff --git a/RecoTracker/TrackProducer/interface/TrackProducerBase.icc b/RecoTracker/TrackProducer/interface/TrackProducerBase.icc index 3269dae3c81e7..2460acf12aa03 100644 --- a/RecoTracker/TrackProducer/interface/TrackProducerBase.icc +++ b/RecoTracker/TrackProducer/interface/TrackProducerBase.icc @@ -127,8 +127,8 @@ TrackProducerBase::getFromEvt(edm::Event& theEvent,edm::Handle void @@ -146,8 +146,8 @@ TrackProducerBase::getFromEvt(edm::Event& theEvent,edm::Handle @@ -185,15 +185,17 @@ TrackProducerBase::setSecondHitPattern(Trajectory* traj, T& track, //WARNING: we are assuming that the hits were originally sorted along momentum (and therefore oppositeToMomentum after smoothing) PropagationDirection dirForInnerLayers = oppositeToMomentum; PropagationDirection dirForOuterLayers = alongMomentum; - if(traj->direction() != oppositeToMomentum){ + auto outIn = traj->direction() != oppositeToMomentum; + if(outIn){ dirForInnerLayers = alongMomentum; dirForOuterLayers = oppositeToMomentum; - //throw cms::Exception("TrackProducer") - //<< "ERROR in setSecondHitPattern() logic. Trajectory direction (after smoothing) was not oppositeToMomentum. Bailing out.." << std::endl; + // std::cout << "Iin setSecondHitPattern() logic. Trajectory direction (after smoothing) was not oppositeToMomentum. .. algo= " << track.algo() << std::endl; } // ----------- this previous block of code is not very safe. It should rely less on the sorting of the trajectory measurements ----- + // Now all code looks as InOut in particular names + // we will take care of OutIn only where it matters (MISSING_INNER vs _OUTER) LogDebug("TrackProducer") << "calling inner compLayers()..."; auto innerCompLayers = (*theSchool).compatibleLayers(*innerLayer,*innerState,dirForInnerLayers); @@ -213,48 +215,48 @@ TrackProducerBase::setSecondHitPattern(Trajectory* traj, T& track, << "innerLayers: " << innerCompLayers.size() << "\n" << "outerLayers: " << outerCompLayers.size() << "\n"; - for(vector::const_iterator it=innerCompLayers.begin(); it!=innerCompLayers.end(); ++it){ - if ((*it)->basicComponents().empty()) { - //this should never happen. but better protect for it - edm::LogWarning("TrackProducer")<<"a detlayer with no components: I cannot figure out a DetId from this layer. please investigate."; - continue; - } - localProp->setPropagationDirection(oppositeToMomentum); - vector< GeometricSearchDet::DetWithState > detWithState = (*it)->compatibleDets(innerTSOS,*localProp,estimator); - if(!detWithState.size()) continue; - DetId id = detWithState.front().first->geographicalId(); - MeasurementDetWithData measDet = measTk->idToDet(id); - //if(measDet->isActive() && !measDet->hasBadComponents(detWithState.front().second)){ - if(measDet.isActive()){ - InvalidTrackingRecHit tmpHit(*detWithState.front().first, TrackingRecHit::missing_inner); - track.appendHitPattern(tmpHit); - //cout << "WARNING: this hit is marked as lost because the detector was marked as active" << endl; - }else{ - //cout << "WARNING: this hit is NOT marked as lost because the detector was marked as inactive" << endl; - } - }//end loop over layers - - for(vector::const_iterator it=outerCompLayers.begin(); it!=outerCompLayers.end(); ++it){ - if ((*it)->basicComponents().empty()){ - //this should never happen. but better protect for it - edm::LogWarning("TrackProducer")<<"a detlayer with no components: I cannot figure out a DetId from this layer. please investigate."; - continue; - } - - localProp->setPropagationDirection(alongMomentum); - vector< GeometricSearchDet::DetWithState > detWithState = (*it)->compatibleDets(outerTSOS,*localProp,estimator); - if(!detWithState.size()) continue; - DetId id = detWithState.front().first->geographicalId(); - MeasurementDetWithData measDet = measTk->idToDet(id); - //if(measDet->isActive() && !measDet->hasBadComponents(detWithState.front().second)){ - if(measDet.isActive()){ - InvalidTrackingRecHit tmpHit(*detWithState.front().first,TrackingRecHit::missing_outer); - track.appendHitPattern(tmpHit); - //cout << "WARNING: this hit is marked as lost because the detector was marked as active" << endl; - }else{ - //cout << "WARNING: this hit is NOT marked as lost because the detector was marked as inactive" << endl; - } - } + for(vector::const_iterator it=innerCompLayers.begin(); it!=innerCompLayers.end(); ++it){ + if ((*it)->basicComponents().empty()) { + //this should never happen. but better protect for it + edm::LogWarning("TrackProducer")<<"a detlayer with no components: I cannot figure out a DetId from this layer. please investigate."; + continue; + } + localProp->setPropagationDirection(oppositeToMomentum); + vector< GeometricSearchDet::DetWithState > detWithState = (*it)->compatibleDets(innerTSOS,*localProp,estimator); + if(!detWithState.size()) continue; + DetId id = detWithState.front().first->geographicalId(); + MeasurementDetWithData measDet = measTk->idToDet(id); + //if(measDet->isActive() && !measDet->hasBadComponents(detWithState.front().second)){ + if(measDet.isActive()){ + InvalidTrackingRecHit tmpHit(*detWithState.front().first, outIn ? TrackingRecHit::missing_outer : TrackingRecHit::missing_inner); + track.appendHitPattern(tmpHit); + //cout << "WARNING: this hit is marked as lost because the detector was marked as active" << endl; + }else{ + //cout << "WARNING: this hit is NOT marked as lost because the detector was marked as inactive" << endl; + } + }//end loop over layers + + for(vector::const_iterator it=outerCompLayers.begin(); it!=outerCompLayers.end(); ++it){ + if ((*it)->basicComponents().empty()){ + //this should never happen. but better protect for it + edm::LogWarning("TrackProducer")<<"a detlayer with no components: I cannot figure out a DetId from this layer. please investigate."; + continue; + } + + localProp->setPropagationDirection(alongMomentum); + vector< GeometricSearchDet::DetWithState > detWithState = (*it)->compatibleDets(outerTSOS,*localProp,estimator); + if(!detWithState.size()) continue; + DetId id = detWithState.front().first->geographicalId(); + MeasurementDetWithData measDet = measTk->idToDet(id); + //if(measDet->isActive() && !measDet->hasBadComponents(detWithState.front().second)){ + if(measDet.isActive()){ + InvalidTrackingRecHit tmpHit(*detWithState.front().first, outIn ? TrackingRecHit::missing_inner : TrackingRecHit::missing_outer); + track.appendHitPattern(tmpHit); + //cout << "WARNING: this hit is marked as lost because the detector was marked as active" << endl; + }else{ + //cout << "WARNING: this hit is NOT marked as lost because the detector was marked as inactive" << endl; + } + } }else{ cout << "inner or outer state was invalid" << endl; }