Skip to content

Commit

Permalink
Merge pull request #14356 from makortel/pixelSeedExtension
Browse files Browse the repository at this point in the history
Add pixel-only seed extension
  • Loading branch information
cmsbuild committed May 24, 2016
2 parents 885f908 + 97c8106 commit 05011b7
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 11 deletions.
8 changes: 7 additions & 1 deletion DQM/TrackingMonitor/src/TrackAnalyzer.cc
Expand Up @@ -543,7 +543,13 @@ void TrackAnalyzer::bookHistosForHitProperties(DQMStore::IBooker & ibooker) {
}

// DataFormats/TrackReco/interface/TrajectoryStopReasons.h
std::vector<std::string> StopReasonName = { "UNINITIALIZED", "MAX_HITS", "MAX_LOST_HITS", "MAX_CONSECUTIVE_LOST_HITS", "LOST_HIT_FRACTION", "MIN_PT", "CHARGE_SIGNIFICANCE", "LOOPER", "MAX_CCC_LOST_HITS", "NO_SEGMENTS_FOR_VALID_LAYERS", "NOT_STOPPED" };
std::vector<std::string> StopReasonName = { "UNINITIALIZED", "MAX_HITS", "MAX_LOST_HITS", "MAX_CONSECUTIVE_LOST_HITS", "LOST_HIT_FRACTION", "MIN_PT", "CHARGE_SIGNIFICANCE", "LOOPER", "MAX_CCC_LOST_HITS", "NO_SEGMENTS_FOR_VALID_LAYERS", "SEED_EXTENSION", "NOT_STOPPED" };
if(StopReasonName.size() != static_cast<unsigned int>(StopReason::SIZE)) {
throw cms::Exception("Assert") << "StopReason::SIZE is " << static_cast<unsigned int>(StopReason::SIZE)
<< " but TrackAnalyzer has StopReasonName's only for "
<< StopReasonName.size()
<< ". Please update also TrackAnalyzer.cc near line " << __LINE__ << ".";
}

histname = "stoppingSource_";
stoppingSource = ibooker.book1D(histname+CategoryName, histname+CategoryName, StopReasonName.size(), 0., double(StopReasonName.size()));
Expand Down
8 changes: 7 additions & 1 deletion DQM/TrackingMonitor/src/TrackBuildingAnalyzer.cc
Expand Up @@ -207,7 +207,13 @@ void TrackBuildingAnalyzer::initHisto(DQMStore::IBooker & ibooker)

if (doAllTCPlots || doStopSource) {
// DataFormats/TrackReco/interface/TrajectoryStopReasons.h
std::vector<std::string> StopReasonName = { "UNINITIALIZED", "MAX_HITS", "MAX_LOST_HITS", "MAX_CONSECUTIVE_LOST_HITS", "LOST_HIT_FRACTION", "MIN_PT", "CHARGE_SIGNIFICANCE", "LOOPER", "MAX_CCC_LOST_HITS", "NO_SEGMENTS_FOR_VALID_LAYERS", "NOT_STOPPED" };
std::vector<std::string> StopReasonName = { "UNINITIALIZED", "MAX_HITS", "MAX_LOST_HITS", "MAX_CONSECUTIVE_LOST_HITS", "LOST_HIT_FRACTION", "MIN_PT", "CHARGE_SIGNIFICANCE", "LOOPER", "MAX_CCC_LOST_HITS", "NO_SEGMENTS_FOR_VALID_LAYERS", "SEED_EXTENSION", "NOT_STOPPED" };
if(StopReasonName.size() != static_cast<unsigned int>(StopReason::SIZE)) {
throw cms::Exception("Assert") << "StopReason::SIZE is " << static_cast<unsigned int>(StopReason::SIZE)
<< " but TrackBuildingAnalyzer has StopReasonName's only for "
<< StopReasonName.size()
<< ". Please update also TrackBuildingAnalyzer.cc near line " << __LINE__ << ".";
}

histname = "StoppingSource_"+seedProducer.label() + "_";
stoppingSource = ibooker.book1D(histname+CatagoryName,
Expand Down
2 changes: 2 additions & 0 deletions DataFormats/TrackReco/interface/TrajectoryStopReasons.h
Expand Up @@ -12,6 +12,8 @@ enum class StopReason {
LOOPER = 7,
MAX_CCC_LOST_HITS = 8,
NO_SEGMENTS_FOR_VALID_LAYERS = 9,
SEED_EXTENSION = 10,
SIZE = 12, // This gives the number of the stopping reasons. The cound needs to be manually maintained, and should be 2 + the last value above .
NOT_STOPPED = 255 // this is the max allowed since it will be streamed as type uint8_t
};

Expand Down
8 changes: 8 additions & 0 deletions HLTrigger/Configuration/python/customizeHLTforCMSSW.py
Expand Up @@ -62,6 +62,13 @@ def customiseFor14317(process):
pset.seedPairPenalty = cms.int32(0)
return process

# Add pixel seed extension (PR #14356)
def customiseFor14356(process):
for name, pset in process.psets_().iteritems():
if hasattr(pset, "ComponentType") and pset.ComponentType.value() == "CkfBaseTrajectoryFilter" and not hasattr(pset, "pixelSeedExtension"):
pset.pixelSeedExtension = cms.bool(False)
return process

#
# CMSSW version specific customizations
def customizeHLTforCMSSW(process, menuType="GRun"):
Expand All @@ -73,6 +80,7 @@ def customizeHLTforCMSSW(process, menuType="GRun"):
process = customiseFor13753(process)
process = customiseFor14282(process)
process = customiseFor14317(process)
process = customiseFor14356(process)

if cmsswVersion >= "CMSSW_8_0":
# process = customiseFor12718(process)
Expand Down
7 changes: 7 additions & 0 deletions TrackingTools/PatternTools/interface/TempTrajectory.h
Expand Up @@ -76,6 +76,7 @@ class TempTrajectory
theData(std::move(rh.theData)),
theChiSquared(rh.theChiSquared),
theNumberOfFoundHits(rh.theNumberOfFoundHits),
theNumberOfFoundPixelHits(rh.theNumberOfFoundPixelHits),
theNumberOfLostHits(rh.theNumberOfLostHits),
theNumberOfTrailingFoundHits(rh.theNumberOfTrailingFoundHits),
theNumberOfCCCBadHits_(rh.theNumberOfCCCBadHits_),
Expand All @@ -92,6 +93,7 @@ class TempTrajectory
swap(theData,rh.theData);
theChiSquared=rh.theChiSquared;
theNumberOfFoundHits=rh.theNumberOfFoundHits;
theNumberOfFoundPixelHits=rh.theNumberOfFoundPixelHits;
theNumberOfLostHits=rh.theNumberOfLostHits;
theNumberOfTrailingFoundHits=rh.theNumberOfTrailingFoundHits;
theNumberOfCCCBadHits_=rh.theNumberOfCCCBadHits_;
Expand Down Expand Up @@ -205,6 +207,10 @@ class TempTrajectory
*/
int foundHits() const { return theNumberOfFoundHits;}

/** Number of valid pixel RecHits used to determine the trajectory.
*/
int foundPixelHits() const { return theNumberOfFoundPixelHits;}

/** Number of detector layers crossed without valid RecHits.
* Used mainly as a criteria for abandoning a trajectory candidate
* during trajectory building.
Expand Down Expand Up @@ -302,6 +308,7 @@ class TempTrajectory
float theChiSquared=0;

signed short theNumberOfFoundHits=0;
signed short theNumberOfFoundPixelHits=0;
signed short theNumberOfLostHits=0;
signed short theNumberOfTrailingFoundHits=0;
signed short theNumberOfCCCBadHits_=0;
Expand Down
12 changes: 12 additions & 0 deletions TrackingTools/PatternTools/interface/Trajectory.h
Expand Up @@ -107,6 +107,7 @@ class Trajectory
theChiSquared(rh.theChiSquared),
theChiSquaredBad(rh.theChiSquaredBad),
theNumberOfFoundHits(rh.theNumberOfFoundHits),
theNumberOfFoundPixelHits(rh.theNumberOfFoundPixelHits),
theNumberOfLostHits(rh.theNumberOfLostHits),
theNumberOfTrailingFoundHits(rh.theNumberOfTrailingFoundHits),
theNumberOfCCCBadHits_(rh.theNumberOfCCCBadHits_),
Expand All @@ -129,6 +130,7 @@ class Trajectory
theCCCThreshold_=rh.theCCCThreshold_;
theNLoops=rh.theNLoops;
theNumberOfFoundHits=rh.theNumberOfFoundHits;
theNumberOfFoundPixelHits=rh.theNumberOfFoundPixelHits;
theNumberOfLostHits=rh.theNumberOfLostHits;
theNumberOfTrailingFoundHits=rh.theNumberOfTrailingFoundHits;
theNumberOfCCCBadHits_=rh.theNumberOfCCCBadHits_;
Expand Down Expand Up @@ -222,6 +224,10 @@ class Trajectory

int foundHits() const { return theNumberOfFoundHits;}

/** Number of valid pixel RecHits used to determine the trajectory.
*/
int foundPixelHits() const { return theNumberOfFoundPixelHits;}

/** Number of detector layers crossed without valid RecHits.
* Used mainly as a criteria for abandoning a trajectory candidate
* during trajectory building.
Expand Down Expand Up @@ -294,6 +300,11 @@ class Trajectory
*/
static bool isBad( const TrackingRecHit& hit);

/** Returns true if the hit type is TrackingRecHit::bad
* Used in trajectory filtering
*/
static bool pixel( const TrackingRecHit& hit);

/// Redundant method, returns the layer of lastMeasurement() .
const DetLayer* lastLayer() const {
check();
Expand Down Expand Up @@ -357,6 +368,7 @@ class Trajectory
float theChiSquaredBad=0;

signed short theNumberOfFoundHits=0;
signed short theNumberOfFoundPixelHits=0;
signed short theNumberOfLostHits=0;
signed short theNumberOfTrailingFoundHits=0;
signed short theNumberOfCCCBadHits_=0;
Expand Down
9 changes: 7 additions & 2 deletions TrackingTools/PatternTools/src/TempTrajectory.cc
Expand Up @@ -3,6 +3,7 @@
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
#include "DataFormats/TrackerRecHit2D/interface/OmniClusterRef.h"
#include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h"
#include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
#include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
Expand All @@ -17,12 +18,12 @@ namespace {
}
return n;
}

}

TempTrajectory::TempTrajectory(Trajectory && traj):
theChiSquared(0),
theNumberOfFoundHits(0),
theNumberOfFoundPixelHits(0),
theNumberOfLostHits(0),
theNumberOfCCCBadHits_(0),
theDirection(traj.direction()),
Expand All @@ -45,6 +46,7 @@ void TempTrajectory::pop() {
if (theData.back().recHit()->isValid()) {
theNumberOfFoundHits--;
if(badForCCC(theData.back())) theNumberOfCCCBadHits_--;
if(Trajectory::pixel(*(theData.back().recHit()))) theNumberOfFoundPixelHits--;
}
else if(lost(* (theData.back().recHit()) )) {theNumberOfLostHits--;}
theData.pop_back();
Expand All @@ -60,7 +62,8 @@ void TempTrajectory::pushAux(double chi2Increment) {
theNumberOfFoundHits++;
theNumberOfTrailingFoundHits++;
if (badForCCC(tm)) theNumberOfCCCBadHits_++;
}
if(Trajectory::pixel(*(tm.recHit()))) theNumberOfFoundPixelHits++;
}
//else if (lost( tm.recHit()) && !inactive(tm.recHit().det())) theNumberOfLostHits++;
else if (lost( *(tm.recHit()) ) ) { theNumberOfLostHits++; theNumberOfTrailingFoundHits=0;}

Expand All @@ -80,6 +83,7 @@ void TempTrajectory::push(const TempTrajectory& segment) {
tmp[i++] =&tm;
while(i!=0) theData.push_back(*tmp[--i]);
theNumberOfFoundHits+= segment.theNumberOfFoundHits;
theNumberOfFoundPixelHits+= segment.theNumberOfFoundPixelHits;
theNumberOfLostHits += segment.theNumberOfLostHits;
theNumberOfCCCBadHits_ += segment.theNumberOfCCCBadHits_;
theNumberOfTrailingFoundHits=countTrailingValidHits(theData);
Expand All @@ -97,6 +101,7 @@ void TempTrajectory::join( TempTrajectory& segment) {
} else {
theData.join(segment.theData);
theNumberOfFoundHits+= segment.theNumberOfFoundHits;
theNumberOfFoundPixelHits+= segment.theNumberOfFoundPixelHits;
theNumberOfLostHits += segment.theNumberOfLostHits;
theNumberOfCCCBadHits_ += segment.theNumberOfCCCBadHits_;
theNumberOfTrailingFoundHits=countTrailingValidHits(theData);
Expand Down
9 changes: 9 additions & 0 deletions TrackingTools/PatternTools/src/Trajectory.cc
Expand Up @@ -32,6 +32,7 @@ void Trajectory::pop() {
theNumberOfFoundHits--;
theChiSquared -= theData.back().estimate();
if(badForCCC(theData.back())) theNumberOfCCCBadHits_--;
if(pixel(*(theData.back().recHit()))) theNumberOfFoundPixelHits--;
}
else if(lost(* (theData.back().recHit()) )) {
theNumberOfLostHits--;
Expand Down Expand Up @@ -73,6 +74,7 @@ void Trajectory::pushAux(double chi2Increment) {
theNumberOfFoundHits++;
theNumberOfTrailingFoundHits++;
if (badForCCC(tm)) theNumberOfCCCBadHits_++;
if(pixel(*(tm.recHit()))) theNumberOfFoundPixelHits++;
}
// else if (lost( tm.recHit()) && !inactive(tm.recHit().det())) theNumberOfLostHits++;
else if (lost( *(tm.recHit()) ) ) {
Expand Down Expand Up @@ -172,6 +174,13 @@ bool Trajectory::isBad( const TrackingRecHit& hit)
}
}

bool Trajectory::pixel(const TrackingRecHit& hit) {
if (trackerHitRTTI::isUndef(hit))
return false;
auto const * thit = static_cast<const BaseTrackerRecHit*>( hit.hit() );
return thit->isPixel();
}

bool Trajectory::badForCCC(const TrajectoryMeasurement &tm) {
if (trackerHitRTTI::isUndef(*tm.recHit()) |
trackerHitRTTI::isFast(*tm.recHit())
Expand Down
Expand Up @@ -67,6 +67,7 @@ class CkfBaseTrajectoryFilter : public TrajectoryFilter {
protected:

template <class T> bool QF(const T& traj) const{
if (!theSeedExtensionTrajectoryFilter->qualityFilter(traj)) return false;
if (!theChargeSignificanceTrajectoryFilter->qualityFilter(traj)) return false;
if (!theMinHitsTrajectoryFilter->qualityFilter(traj)) return false;
if (!theMinPtTrajectoryFilter->qualityFilter(traj)) return false;
Expand Down
Expand Up @@ -10,40 +10,58 @@ class SeedExtensionTrajectoryFilter final : public TrajectoryFilter {

explicit SeedExtensionTrajectoryFilter(edm::ParameterSet const & pset, edm::ConsumesCollector&) :
theStrict(pset.getParameter<bool>("strictSeedExtension")),
thePixel(pset.getParameter<bool>("pixelSeedExtension")),
theExtension(pset.getParameter<int>("seedExtension")) {}

virtual bool qualityFilter( const Trajectory& traj) const { return TrajectoryFilter::qualityFilterIfNotContributing; }
virtual bool qualityFilter( const TempTrajectory& traj) const { return TrajectoryFilter::qualityFilterIfNotContributing; }
virtual bool qualityFilter( const Trajectory& traj) const { return QF(traj); }
virtual bool qualityFilter( const TempTrajectory& traj) const { return QF(traj); }

virtual bool toBeContinued( TempTrajectory& traj) const { return TBC<TempTrajectory>(traj);}
virtual bool toBeContinued( Trajectory& traj) const{ return TBC<Trajectory>(traj);}

virtual std::string name() const{return "LostHitsFractionTrajectoryFilter";}

private:
template<class T> bool QF(const T & traj) const {
return traj.stopReason() != StopReason::SEED_EXTENSION; // reject tracks killed by seed extension
}

template<class T> bool TBC(const T& traj) const {
if(theExtension <= 0) return true; // skipping checks explicitly when intended to be disabled is the safest way
return theStrict? strictTBC(traj) : looseTBC(traj);
template<class T> bool TBC(T& traj) const {
if(theExtension <= 0) return true; // skipping checks explicitly when intended to be disabled is the safest way
const bool ret = theStrict? strictTBC(traj) : looseTBC(traj);
if(!ret) traj.setStopReason(StopReason::SEED_EXTENSION);
return ret;
}
template<class T> bool looseTBC(const T& traj) const;
template<class T> bool strictTBC(const T& traj) const;


bool theStrict=false;
bool thePixel=false;
int theExtension = 0;


};

template<class T> bool SeedExtensionTrajectoryFilter::looseTBC(const T& traj) const {
return (int(traj.measurements().size())>int(traj.seedNHits())+theExtension) | (0==traj.lostHits());
int nhits = 0;
if(thePixel) {
for(const auto& tm: traj.measurements()) {
if(Trajectory::pixel(*(tm.recHit())))
++nhits;
}
}
else {
nhits = traj.measurements().size();
}
return (nhits>int(traj.seedNHits())+theExtension) | (0==traj.lostHits());
}


// strict case as a real seeding: do not allow even inactive
template<class T> bool SeedExtensionTrajectoryFilter::strictTBC(const T& traj) const {
return traj.foundHits()>=int(traj.seedNHits())+theExtension;
const int nhits = thePixel ? traj.foundPixelHits() : traj.foundHits();
return nhits>=int(traj.seedNHits())+theExtension;
}


Expand Down
Expand Up @@ -33,6 +33,7 @@
# Cut on the length of the seed extention (no lost hits allowed)
seedExtension = cms.int32(0),
strictSeedExtension = cms.bool(False),
pixelSeedExtension = cms.bool(False),

# Cuts for looperTrajectoryFilter
minNumberOfHitsForLoopers = cms.int32(13),
Expand Down

0 comments on commit 05011b7

Please sign in to comment.