Skip to content

Commit

Permalink
Merge pull request #11096 from VinInn/FixOutIn75
Browse files Browse the repository at this point in the history
fix inner outer for OutIn in 75X
  • Loading branch information
cmsbuild committed Oct 12, 2015
2 parents e29a7b0 + a056dae commit c4d6c6d
Showing 1 changed file with 51 additions and 49 deletions.
100 changes: 51 additions & 49 deletions RecoTracker/TrackProducer/interface/TrackProducerBase.icc
Expand Up @@ -127,8 +127,8 @@ TrackProducerBase<T>::getFromEvt(edm::Event& theEvent,edm::Handle<TrackCandidate
theEvent.getByToken(bsSrc_,recoBeamSpotHandle);
if ( recoBeamSpotHandle.isValid() )
bs = *recoBeamSpotHandle;
else
edm::LogWarning("TrackProducerBase") << " BeamSpot is not valid";
else
edm::LogWarning("TrackProducerBase") << " BeamSpot is not valid";
}

template <class T> void
Expand All @@ -146,8 +146,8 @@ TrackProducerBase<T>::getFromEvt(edm::Event& theEvent,edm::Handle<TrackCollectio
theEvent.getByToken(bsSrc_,recoBeamSpotHandle);
if ( recoBeamSpotHandle.isValid() )
bs = *recoBeamSpotHandle;
else
edm::LogWarning("TrackProducerBase") << " BeamSpot is not valid";
else
edm::LogWarning("TrackProducerBase") << " BeamSpot is not valid";
}

#include <TrackingTools/DetLayers/interface/DetLayer.h>
Expand Down Expand Up @@ -185,15 +185,17 @@ TrackProducerBase<T>::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);
Expand All @@ -213,48 +215,48 @@ TrackProducerBase<T>::setSecondHitPattern(Trajectory* traj, T& track,
<< "innerLayers: " << innerCompLayers.size() << "\n"
<< "outerLayers: " << outerCompLayers.size() << "\n";

for(vector<const DetLayer *>::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 DetLayer *>::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 DetLayer *>::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 DetLayer *>::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;
}
Expand Down

0 comments on commit c4d6c6d

Please sign in to comment.