Skip to content

Commit

Permalink
Merge pull request #12576 from rovere/StopCauseAndCCCTF
Browse files Browse the repository at this point in the history
Stop cause and ccctf
  • Loading branch information
cmsbuild committed Dec 1, 2015
2 parents f42f68d + 265e83b commit 15cc2e6
Show file tree
Hide file tree
Showing 33 changed files with 428 additions and 93 deletions.
3 changes: 2 additions & 1 deletion DataFormats/GsfTrackReco/src/classes_def.xml
Expand Up @@ -24,7 +24,8 @@
<class name="edm::Ref<std::vector<reco::GsfTrackExtra>,reco::GsfTrackExtra,edm::refhelper::FindUsingAdvance<std::vector<reco::GsfTrackExtra>,reco::GsfTrackExtra> >"/>
<class name="edm::RefVector<std::vector<reco::GsfTrackExtra>,reco::GsfTrackExtra,edm::refhelper::FindUsingAdvance<std::vector<reco::GsfTrackExtra>,reco::GsfTrackExtra> >"/>

<class name="reco::GsfTrack" ClassVersion="17">
<class name="reco::GsfTrack" ClassVersion="19">
<version ClassVersion="19" checksum="2111870580"/>
<version ClassVersion="18" checksum="1193413886"/>
<version ClassVersion="17" checksum="2463004588"/>
<version ClassVersion="16" checksum="4129402716"/>
Expand Down
2 changes: 1 addition & 1 deletion DataFormats/SiStripCluster/interface/SiStripClusterTools.h
Expand Up @@ -9,7 +9,7 @@
namespace siStripClusterTools {

// to be moved and optimized in TrackerCommon when TrackerTopology will support moduleGeometry
float sensorThicknessInverse (DetId detid)
inline float sensorThicknessInverse (DetId detid)
{
if (detid.subdetId()>=SiStripDetId::TIB) {
SiStripDetId siStripDetId = detid();
Expand Down
19 changes: 13 additions & 6 deletions DataFormats/TrackCandidate/interface/TrackCandidate.h
Expand Up @@ -3,6 +3,7 @@

#include "DataFormats/Common/interface/RefToBase.h"
#include "DataFormats/Common/interface/OwnVector.h"
#include "DataFormats/TrackReco/interface/TrajectoryStopReasons.h"
#include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
#include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"

Expand All @@ -26,24 +27,26 @@ class TrackCandidate{
typedef RecHitContainer::const_iterator const_iterator;
typedef std::pair<const_iterator,const_iterator> range;

TrackCandidate(): rh_(), seed_(), state_(), seedRef_(), nLoops_(0) {}
TrackCandidate(): rh_(), seed_(), state_(), seedRef_(), nLoops_(0), stopReason_((uint8_t)StopReason::UNINITIALIZED) {}

explicit TrackCandidate(RecHitContainer & rh) :
rh_(), seed_(), state_(), seedRef_(), nLoops_(0) {rh_.swap(rh);}
rh_(), seed_(), state_(), seedRef_(), nLoops_(0), stopReason_((uint8_t)StopReason::UNINITIALIZED) {rh_.swap(rh);}

TrackCandidate(RecHitContainer & rh,
TrajectorySeed const & s,
PTrajectoryStateOnDet const & st,
signed char nLoops=0):
rh_(), seed_(s), state_(st), seedRef_(),nLoops_(nLoops) {rh_.swap(rh);}
signed char nLoops=0,
uint8_t stopReason=(uint8_t)StopReason::UNINITIALIZED):
rh_(), seed_(s), state_(st), seedRef_(),nLoops_(nLoops), stopReason_(stopReason) {rh_.swap(rh);}


TrackCandidate(RecHitContainer & rh,
TrajectorySeed const & s,
PTrajectoryStateOnDet const & st,
const edm::RefToBase<TrajectorySeed> & seedRef,
signed char nLoops=0) :
rh_(), seed_(s), state_(st), seedRef_(seedRef),nLoops_(nLoops) {rh_.swap(rh);}
signed char nLoops=0,
uint8_t stopReason=(uint8_t)StopReason::UNINITIALIZED) :
rh_(), seed_(s), state_(st), seedRef_(seedRef),nLoops_(nLoops), stopReason_(stopReason) {rh_.swap(rh);}


PTrajectoryStateOnDet const & trajectoryStateOnDet() const { return state_;}
Expand All @@ -55,8 +58,11 @@ class TrackCandidate{

bool isLooper() const {return (nLoops_>0);}
signed char nLoops() const {return nLoops_;}
uint8_t stopReason() const {return stopReason_;}


void setNLoops(signed char value) {nLoops_=value;}
void setStopReason(uint8_t value) {stopReason_ = value;}

/** return the edm::reference to the trajectory seed in the original
* seeds collection. If the collection has been dropped from the
Expand All @@ -73,5 +79,6 @@ class TrackCandidate{
PTrajectoryStateOnDet state_;
edm::RefToBase<TrajectorySeed> seedRef_;
signed char nLoops_;
uint8_t stopReason_;
};
#endif
3 changes: 2 additions & 1 deletion DataFormats/TrackCandidate/src/classes_def.xml
@@ -1,5 +1,6 @@
<lcgdict>
<class name="TrackCandidate" ClassVersion="12">
<class name="TrackCandidate" ClassVersion="13">
<version ClassVersion="13" checksum="2316831923"/>
<version ClassVersion="12" checksum="2330668139"/>
<version ClassVersion="11" checksum="3750078709"/>
<version ClassVersion="10" checksum="1620910795"/>
Expand Down
13 changes: 10 additions & 3 deletions DataFormats/TrackReco/interface/TrackBase.h
Expand Up @@ -143,7 +143,6 @@ class TrackBase

/// algo mask
typedef std::bitset<algoSize> AlgoMask;


static const std::string algoNames[];

Expand All @@ -170,7 +169,7 @@ class TrackBase
TrackBase(double chi2, double ndof, const Point &vertex,
const Vector &momentum, int charge, const CovarianceMatrix &cov,
TrackAlgorithm = undefAlgorithm, TrackQuality quality = undefQuality,
signed char nloops = 0);
signed char nloops = 0, uint8_t stopReason = 0);

/// virtual destructor
virtual ~TrackBase();
Expand Down Expand Up @@ -396,6 +395,11 @@ class TrackBase

signed char nLoops() const;

void setStopReason(uint8_t value) { stopReason_ = value; }

uint8_t stopReason() const { return stopReason_; }


private:
/// hit pattern
HitPattern hitPattern_;
Expand Down Expand Up @@ -433,6 +437,9 @@ class TrackBase

/// number of loops made during the building of the trajectory of a looper particle
signed char nLoops_; // I use signed char because I don't expect more than 128 loops and I could use a negative value for a special purpose.

/// Stop Reason
uint8_t stopReason_;
};

// Access the hit pattern, indicating in which Tracker layers the track has hits.
Expand Down Expand Up @@ -489,7 +496,7 @@ inline TrackBase::TrackAlgorithm TrackBase::algo() const
}
inline TrackBase::TrackAlgorithm TrackBase::originalAlgo() const
{
return (TrackAlgorithm) (originalAlgorithm_);
return (TrackAlgorithm) (originalAlgorithm_);
}


Expand Down
18 changes: 18 additions & 0 deletions DataFormats/TrackReco/interface/TrajectoryStopReasons.h
@@ -0,0 +1,18 @@
#ifndef TRAJECTORYSTOPREASONS_H
#define TRAJECTORYSTOPREASONS_H

enum class StopReason {
UNINITIALIZED = 0,
MAX_HITS = 1,
MAX_LOST_HITS = 2,
MAX_CONSECUTIVE_LOST_HITS = 3,
LOST_HIT_FRACTION = 4,
MIN_PT = 5,
CHARGE_SIGNIFICANCE = 6,
LOOPER = 7,
MAX_CCC_LOST_HITS = 8,
NO_SEGMENTS_FOR_VALID_LAYERS = 9,
NOT_STOPPED = 255 // this is the max allowed since it will be streamed as type uint8_t
};

#endif
8 changes: 5 additions & 3 deletions DataFormats/TrackReco/src/TrackBase.cc
Expand Up @@ -75,7 +75,8 @@ TrackBase::TrackBase() :
algorithm_(undefAlgorithm),
originalAlgorithm_(undefAlgorithm),
quality_(0),
nLoops_(0)
nLoops_(0),
stopReason_(0)
{
algoMask_.set(algorithm_);
index idx = 0;
Expand All @@ -88,7 +89,7 @@ TrackBase::TrackBase() :

TrackBase::TrackBase(double chi2, double ndof, const Point &vertex, const Vector &momentum,
int charge, const CovarianceMatrix &cov, TrackAlgorithm algorithm,
TrackQuality quality, signed char nloops):
TrackQuality quality, signed char nloops, uint8_t stopReason):
chi2_(chi2),
vertex_(vertex),
momentum_(momentum),
Expand All @@ -97,7 +98,8 @@ TrackBase::TrackBase(double chi2, double ndof, const Point &vertex, const Vector
algorithm_(algorithm),
originalAlgorithm_(algorithm),
quality_(0),
nLoops_(nloops)
nLoops_(nloops),
stopReason_(stopReason)
{
algoMask_.set(algorithm_);

Expand Down
6 changes: 4 additions & 2 deletions DataFormats/TrackReco/src/classes_def.xml
Expand Up @@ -8,7 +8,8 @@
<class name="reco::TrackResiduals" ClassVersion="10">
<version ClassVersion="10" checksum="2022291691"/>
</class>
<class name="reco::TrackBase" ClassVersion="17">
<class name="reco::TrackBase" ClassVersion="19">
<version ClassVersion="19" checksum="4090229239"/>
<version ClassVersion="18" checksum="1935215297"/>
<version ClassVersion="17" checksum="1774167599"/>
<version ClassVersion="16" checksum="3673246687"/>
Expand Down Expand Up @@ -314,7 +315,8 @@
<class name="edm::Ref<std::vector<reco::TrackExtra>,reco::TrackExtra,edm::refhelper::FindUsingAdvance<std::vector<reco::TrackExtra>,reco::TrackExtra> >"/>
<class name="edm::RefVector<std::vector<reco::TrackExtra>,reco::TrackExtra,edm::refhelper::FindUsingAdvance<std::vector<reco::TrackExtra>,reco::TrackExtra> >"/>

<class name="reco::Track" ClassVersion="17">
<class name="reco::Track" ClassVersion="19">
<version ClassVersion="19" checksum="362503460"/>
<version ClassVersion="18" checksum="3235158110"/>
<version ClassVersion="17" checksum="3387867292"/>
<version ClassVersion="16" checksum="697987788"/>
Expand Down
Expand Up @@ -10,6 +10,8 @@
maxNumberOfHits = cms.int32(-1),
maxConsecLostHits = cms.int32(1),
nSigmaMinPt = cms.double(5.0),
minimumNumberOfHits = cms.int32(3)
minimumNumberOfHits = cms.int32(3),
maxCCCLostHits = cms.int32(9999),
minGoodStripCharge = cms.double(-1)
)

13 changes: 9 additions & 4 deletions RecoTracker/CkfPattern/plugins/GroupedCkfTrajectoryBuilder.cc
Expand Up @@ -270,8 +270,6 @@ GroupedCkfTrajectoryBuilder::buildTrajectories (const TrajectorySeed& seed,
groupedLimitedCandidates(seed, startingTraj, regionalCondition, forwardPropagator(seed), inOut, work_);
if ( work_.empty() ) return startingTraj;



/* rebuilding is de-coupled from standard building
//
// try to additional hits in the seeding region
Expand Down Expand Up @@ -644,21 +642,23 @@ GroupedCkfTrajectoryBuilder::advanceOneLayer (const TrajectorySeed& seed,

LogDebug("CkfPattern")<<"GCTB: adding updated trajectory to candidates: inOut="<<inOut<<" hits="<<newTraj.foundHits();

newTraj.setStopReason(StopReason::NOT_STOPPED);
newCand.push_back(std::move(newTraj));
foundNewCandidates = true;
}
else {
// Have finished building this track. Check if it passes cuts.

LogDebug("CkfPattern")<< "GCTB: adding completed trajectory to results if passes cuts: inOut="<<inOut<<" hits="<<newTraj.foundHits();

moveToResult(std::move(newTraj), result, inOut);
}
} // loop over segs
} // loop over layers

if ( !foundSegments ){
LogDebug("CkfPattern")<< "GCTB: adding input trajectory to result";
if (stateAndLayers.second.size() > 0)
traj.setStopReason(StopReason::NO_SEGMENTS_FOR_VALID_LAYERS);
addToResult(traj, result, inOut);
}
return foundNewCandidates;
Expand Down Expand Up @@ -878,11 +878,16 @@ GroupedCkfTrajectoryBuilder::rebuildSeedingRegion(const TrajectorySeed&seed,
//
int nRebuilt =
rebuildSeedingRegion (seed, seedHits,reFitted,rebuiltTrajectories);
// Loop over the last nRebuilt trajectories and propagate back the
// real cause that stopped the original in-out trajectory, since
// that's the one we want to monitor
for (size_t i = rebuiltTrajectories.size() - 1; i < rebuiltTrajectories.size() - nRebuilt - 1; --i) {
rebuiltTrajectories[i].setStopReason(it->stopReason());
}

if ( nRebuilt==0 && !theKeepOriginalIfRebuildFails ) it->invalidate(); // won't use original in-out track

if ( nRebuilt<0 ) rebuiltTrajectories.push_back(std::move(*it));

}
//
// Replace input trajectories with new ones
Expand Down
6 changes: 3 additions & 3 deletions RecoTracker/CkfPattern/src/CkfTrackCandidateMakerBase.cc
Expand Up @@ -157,7 +157,7 @@ namespace cms{

// Functions that gets called by framework every event
void CkfTrackCandidateMakerBase::produceBase(edm::Event& e, const edm::EventSetup& es)
{
{
// getting objects from the EventSetup
setEventSetup( es );

Expand Down Expand Up @@ -287,7 +287,6 @@ namespace cms{
theTmpTrajectories.clear();
auto const & startTraj = theTrajectoryBuilder->buildTrajectories( (*collseed)[j], theTmpTrajectories, nullptr );


LogDebug("CkfPattern") << "======== In-out trajectory building found " << theTmpTrajectories.size()
<< " trajectories from seed " << j << " ========"<<endl
<<PrintoutHelper::dumpCandidates(theTmpTrajectories);
Expand Down Expand Up @@ -413,6 +412,7 @@ namespace cms{
Trajectory trajectory(seed, direction);
trajectory.setNLoops(it->nLoops());
trajectory.setSeedRef(it->seedRef());
trajectory.setStopReason(it->stopReason());
// 4) push states in reversed order
Trajectory::DataContainer &meas = it->measurements();
trajectory.reserve(meas.size());
Expand Down Expand Up @@ -482,7 +482,7 @@ namespace cms{
else state = trajectoryStateTransform::persistentState( initState.first,
initState.second->geographicalId().rawId());
LogDebug("CkfPattern") << "pushing a TrackCandidate.";
output->emplace_back(recHits,it->seed(),state,it->seedRef(),it->nLoops());
output->emplace_back(recHits,it->seed(),state,it->seedRef(),it->nLoops(), (uint8_t)it->stopReason());
}
}//output trackcandidates

Expand Down
4 changes: 3 additions & 1 deletion RecoTracker/FinalTrackSelectors/plugins/TrackMerger.cc
Expand Up @@ -158,7 +158,9 @@ TrackCandidate TrackMerger::merge(const reco::Track &inner, const reco::Track &o

}
TrajectorySeed seed(state, TrackCandidate::RecHitContainer(), pdir);
return TrackCandidate(ownHits, seed, state, (useInnermostState_ ? inner : outer).seedRef());
TrackCandidate ret(ownHits, seed, state, (useInnermostState_ ? inner : outer).seedRef());
ret.setStopReason((uint8_t)(useInnermostState_ ? inner : outer).stopReason());
return ret;
}


Expand Down
3 changes: 3 additions & 0 deletions RecoTracker/TrackProducer/interface/TrackProducerAlgorithm.h
Expand Up @@ -57,6 +57,7 @@ class TrackProducerAlgorithm : public AlgoProductTraits<T> {
TrackProducerAlgorithm(const edm::ParameterSet& conf) :
algo_(reco::TrackBase::algoByName(conf.getParameter<std::string>("AlgorithmName"))),
originalAlgo_(reco::TrackBase::undefAlgorithm),
stopReason_(0),
reMatchSplitHits_(false),
usePropagatorForPCA_(false)
{
Expand Down Expand Up @@ -141,6 +142,8 @@ class TrackProducerAlgorithm : public AlgoProductTraits<T> {
reco::TrackBase::TrackAlgorithm algo_;
reco::TrackBase::TrackAlgorithm originalAlgo_;
reco::TrackBase::AlgoMask algoMask_;
uint8_t stopReason_;

bool reMatchSplitHits_;
bool geometricInnerState_;
bool usePropagatorForPCA_;
Expand Down
Expand Up @@ -69,7 +69,8 @@ TrackProducerAlgorithm<T>::runWithCandidate(const TrackingGeometry * theG,
for (auto i = recHitVec.first; i!=recHitVec.second; ++i){
hits.push_back((*i).cloneSH()); // major waste, will be soon fitted and recloned...
}


stopReason_ = theTC.stopReason();
//build Track
LogDebug("TrackProducer") << "going to buildTrack"<< "\n";
FitterCloner fc(theFitter,builder);
Expand Down Expand Up @@ -173,6 +174,8 @@ TrackProducerAlgorithm<T>::runWithTrack(const TrackingGeometry * theG,
originalAlgo_ = theT->originalAlgo();
algoMask_ = theT->algoMask();

stopReason_ = theT->stopReason();

//===== the hits are in the same order as they were in the track::extra.
FitterCloner fc(theFitter,builder);
bool ok = buildTrack(fc.fitter.get(),thePropagator,algoResults, hits, theInitialStateForRefitting,
Expand Down
9 changes: 6 additions & 3 deletions RecoTracker/TrackProducer/src/TrackProducerAlgorithm.cc
Expand Up @@ -87,7 +87,7 @@ TrackProducerAlgorithm<reco::Track>::buildTrack (const TrajectoryFitter * theFit
float ndof,
const reco::BeamSpot& bs,
SeedRef seedRef,
int qualityMask,signed char nLoops)
int qualityMask,signed char nLoops)
{
//variable declarations

Expand Down Expand Up @@ -215,7 +215,8 @@ std::cout << algo_ << ": " << hits.size() <<'|' <<theTraj->measurements().size(
if(algoMask_.any()) theTrack->setAlgoMask(algoMask_);
theTrack->setQualityMask(qualityMask);
theTrack->setNLoops(nLoops);

theTrack->setStopReason(stopReason_);

LogDebug("TrackProducer") << "theTrack->pt()=" << theTrack->pt();

LogDebug("TrackProducer") <<"track done\n";
Expand Down Expand Up @@ -344,7 +345,9 @@ TrackProducerAlgorithm<reco::GsfTrack>::buildTrack (const TrajectoryFitter * the
theTrack->setAlgorithm(algo_);
if(originalAlgo_ != reco::TrackBase::undefAlgorithm) theTrack->setOriginalAlgorithm(originalAlgo_);
if(algoMask_.any()) theTrack->setAlgoMask(algoMask_);


theTrack->setStopReason(stopReason_);

LogDebug("GsfTrackProducer") <<"track done\n";

AlgoProduct aProduct{theTraj,theTrack,seedDir,0};
Expand Down
Expand Up @@ -18,7 +18,9 @@
maxNumberOfHits = cms.int32(-1),
maxConsecLostHits = cms.int32(1),
nSigmaMinPt = cms.double(5.0),
minimumNumberOfHits = cms.int32(5)
minimumNumberOfHits = cms.int32(5),
maxCCCLostHits = cms.int32(9999),
minGoodStripCharge = cms.double(-1)
)

# Trajectory Builder
Expand Down

0 comments on commit 15cc2e6

Please sign in to comment.