Skip to content

Commit

Permalink
Merge remote-tracking branch 'official-cmssw/CMSSW_9_0_X' into from-C…
Browse files Browse the repository at this point in the history
…MSSW_9_0_X_upgradematrix_rebase
  • Loading branch information
hengne committed Nov 28, 2016
2 parents eafad7a + 5332703 commit 1c88b6d
Show file tree
Hide file tree
Showing 249 changed files with 5,018 additions and 1,664 deletions.
7 changes: 5 additions & 2 deletions CommonTools/RecoAlgos/interface/RecoTrackSelector.h
Expand Up @@ -9,6 +9,7 @@

class RecoTrackSelector: public RecoTrackSelectorBase {
public:
typedef reco::TrackRef reference_type;
typedef reco::TrackCollection collection;
typedef std::vector<const reco::Track *> container;
typedef container::const_iterator const_iterator;
Expand All @@ -25,10 +26,12 @@ class RecoTrackSelector: public RecoTrackSelectorBase {
init(event,es);
selected_.clear();
for( reco::TrackCollection::const_iterator trk = c->begin();
trk != c->end(); ++ trk )
if ( operator()(*trk) ) {
trk != c->end(); ++ trk ) {
reference_type tkref(c,std::distance(c->begin(),trk));
if ( operator()(*tkref) ) {
selected_.push_back( & * trk );
}
}
}

size_t size() const { return selected_.size(); }
Expand Down
4 changes: 4 additions & 0 deletions CommonTools/RecoAlgos/interface/RecoTrackSelectorBase.h
Expand Up @@ -50,6 +50,10 @@ class RecoTrackSelectorBase {
vertex_ = (*hVtx)[0].position();
}

bool operator()( const reco::TrackRef& tref ) const {
return (*this)(*tref);
}

bool operator()( const reco::Track & t) const {
bool quality_ok = true;
if (quality_.size()!=0) {
Expand Down
8 changes: 5 additions & 3 deletions CommonTools/RecoAlgos/interface/TrackFullCloneSelectorBase.h
Expand Up @@ -83,9 +83,11 @@ class TrackFullCloneSelectorBase : public edm::stream::EDProducer<> {
TrackRefKey current = 0;

selector_.init(evt,es);
for (reco::TrackCollection::const_iterator it = hSrcTrack->begin(), ed = hSrcTrack->end(); it != ed; ++it, ++current) {
const reco::Track & trk = * it;
if (!selector_(trk)) continue;
auto tkBegin = hSrcTrack->begin();
for (reco::TrackCollection::const_iterator it = tkBegin, ed = hSrcTrack->end(); it != ed; ++it, ++current) {
const reco::Track & trk = * it;
const reco::TrackRef tkref(hSrcTrack,std::distance(tkBegin,it));
if (!selector_(tkref)) continue;

selTracks_->push_back( Track( trk ) ); // clone and store
if (!copyExtras_) continue;
Expand Down
17 changes: 14 additions & 3 deletions CommonTools/RecoAlgos/interface/TrackWithVertexSelector.h
Expand Up @@ -10,6 +10,7 @@
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "DataFormats/Common/interface/ValueMap.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
Expand All @@ -23,14 +24,21 @@ class TrackWithVertexSelector {

void init(const edm::Event & event, const edm::EventSetup&) {init(event);}
void init(const edm::Event & event);



bool operator()(const reco::Track &t) const ;
bool operator()(const reco::Track &t, const edm::Event &iEvent) {
init(iEvent); return (*this)(t);
}

bool operator()(const reco::TrackRef &t) const ;
bool operator()(const reco::TrackRef &t, const edm::Event &iEvent) {
init(iEvent); return (*this)(t);
}
bool testTrack(const reco::Track &t) const ;
bool testVertices(const reco::Track &t, const reco::VertexCollection &vtxs) const ;

bool testTrack(const reco::TrackRef &t) const ;
bool testVertices(const reco::TrackRef &t, const reco::VertexCollection &vtxs) const ;
private:
uint32_t numberOfValidHits_;
uint32_t numberOfValidPixelHits_;
Expand All @@ -43,10 +51,13 @@ class TrackWithVertexSelector {

uint32_t nVertices_;
edm::EDGetTokenT<reco::VertexCollection> vertexToken_;
edm::EDGetTokenT<edm::ValueMap<float> > timesToken_, timeResosToken_;
bool vtxFallback_;
double zetaVtx_, rhoVtx_;
double zetaVtx_, rhoVtx_, nSigmaDtVertex_;

reco::VertexCollection const * vcoll_ = nullptr;
edm::ValueMap<float> const * timescoll_ = nullptr;
edm::ValueMap<float> const * timeresoscoll_ = nullptr;
typedef math::XYZPoint Point;
};

Expand Down
Expand Up @@ -21,11 +21,14 @@
# compatibility with a vertex ?
useVtx = cms.bool(True),
vertexTag = cms.InputTag('offlinePrimaryVertices'),
timesTag = cms.InputTag(''),
timeResosTag = cms.InputTag(''),
nVertices = cms.uint32(0), ## how many vertices to look at before dropping the track
vtxFallback = cms.bool(True), ## falback to beam spot if there are no vertices
# uses vtx=(0,0,0) with deltaZeta=15.9, deltaRho = 0.2
zetaVtx = cms.double(1.0),
rhoVtx = cms.double(0.2), ## tags used by b-tagging folks
nSigmaDtVertex = cms.double(0),
# should _not_ be used for the TrackWithVertexRefSelector
copyExtras = cms.untracked.bool(False), ## copies also extras and rechits on RECO
copyTrajectories = cms.untracked.bool(False), # don't set this to true on AOD!
Expand Down
73 changes: 66 additions & 7 deletions CommonTools/RecoAlgos/src/TrackWithVertexSelector.cc
@@ -1,8 +1,13 @@
#include "CommonTools/RecoAlgos/interface/TrackWithVertexSelector.h"
#include "FWCore/Utilities/interface/isFinite.h"
//
// constructors and destructor
//

namespace {
constexpr float fakeBeamSpotTimeWidth = 0.175f;
}

TrackWithVertexSelector::TrackWithVertexSelector(const edm::ParameterSet& iConfig, edm::ConsumesCollector & iC) :
numberOfValidHits_(iConfig.getParameter<uint32_t>("numberOfValidHits")),
numberOfValidPixelHits_(iConfig.getParameter<uint32_t>("numberOfValidPixelHits")),
Expand All @@ -18,9 +23,12 @@ TrackWithVertexSelector::TrackWithVertexSelector(const edm::ParameterSet& iConfi
quality_(iConfig.getParameter<std::string>("quality")),
nVertices_(iConfig.getParameter<bool>("useVtx") ? iConfig.getParameter<uint32_t>("nVertices") : 0),
vertexToken_(iC.consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("vertexTag"))),
timesToken_(iC.consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::InputTag>("timesTag"))),
timeResosToken_(iC.consumes<edm::ValueMap<float> >(iConfig.getParameter<edm::InputTag>("timeResosTag"))),
vtxFallback_(iConfig.getParameter<bool>("vtxFallback")),
zetaVtx_(iConfig.getParameter<double>("zetaVtx")),
rhoVtx_(iConfig.getParameter<double>("rhoVtx")) {
rhoVtx_(iConfig.getParameter<double>("rhoVtx")),
nSigmaDtVertex_(iConfig.getParameter<double>("nSigmaDtVertex")) {
}

TrackWithVertexSelector::~TrackWithVertexSelector() { }
Expand All @@ -30,8 +38,15 @@ void TrackWithVertexSelector::init(const edm::Event & event) {
edm::Handle<reco::VertexCollection> hVtx;
event.getByToken(vertexToken_, hVtx);
vcoll_ = hVtx.product();
}

edm::Handle<edm::ValueMap<float> > hTimes;
event.getByToken(timesToken_, hTimes);
timescoll_ = hTimes.isValid() ? hTimes.product() : nullptr;

edm::Handle<edm::ValueMap<float> > hTimeResos;
event.getByToken(timeResosToken_, hTimeResos);
timeresoscoll_ = hTimeResos.isValid() ? hTimeResos.product() : nullptr;
}

bool TrackWithVertexSelector::testTrack(const reco::Track &t) const {
using std::abs;
Expand All @@ -41,8 +56,8 @@ bool TrackWithVertexSelector::testTrack(const reco::Track &t) const {
(t.normalizedChi2() <= normalizedChi2_) &&
(t.ptError()/t.pt()*std::max(1.,t.normalizedChi2()) <= ptErrorCut_) &&
(t.quality(t.qualityByName(quality_))) &&
(t.pt() >= ptMin_) &&
(t.pt() <= ptMax_) &&
(t.pt() >= ptMin_) &&
(t.pt() <= ptMax_) &&
(abs(t.eta()) <= etaMax_) &&
(abs(t.eta()) >= etaMin_) &&
(abs(t.dz()) <= dzMax_) &&
Expand All @@ -52,14 +67,52 @@ bool TrackWithVertexSelector::testTrack(const reco::Track &t) const {
return false;
}

bool TrackWithVertexSelector::testVertices(const reco::Track &t, const reco::VertexCollection &vtxs) const {
bool TrackWithVertexSelector::testTrack(const reco::TrackRef &tref) const {
return testTrack(*tref);
}

bool TrackWithVertexSelector::testVertices(const reco::Track& t, const reco::VertexCollection &vtxs) const {
bool ok = false;
if (vtxs.size() > 0) {
unsigned int tested = 1;
for (reco::VertexCollection::const_iterator it = vtxs.begin(), ed = vtxs.end();
it != ed; ++it) {
if ((std::abs(t.dxy(it->position())) < rhoVtx_) &&
(std::abs(t.dz(it->position())) < zetaVtx_)) {
if ( (std::abs(t.dxy(it->position())) < rhoVtx_) &&
(std::abs(t.dz(it->position())) < zetaVtx_) ) {
ok = true; break;
}
if (tested++ >= nVertices_) break;
}
} else if (vtxFallback_) {
return ( (std::abs(t.vertex().z()) < 15.9) && (t.vertex().Rho() < 0.2) );
}
return ok;
}

bool TrackWithVertexSelector::testVertices(const reco::TrackRef &tref, const reco::VertexCollection &vtxs) const {
const auto& t = *tref;
const bool timeAvailable = timescoll_ != nullptr && timeresoscoll_ != nullptr;
bool ok = false;
if (vtxs.size() > 0) {
unsigned int tested = 1;
for (reco::VertexCollection::const_iterator it = vtxs.begin(), ed = vtxs.end();
it != ed; ++it) {
const bool useTime = timeAvailable && it->t() != 0.;
float time = useTime ? (*timescoll_)[tref] : -1.f;
float timeReso = useTime ? (*timeresoscoll_)[tref] : -1.f;
timeReso = ( timeReso > 1e-6 ? timeReso : fakeBeamSpotTimeWidth );

if( edm::isNotFinite(time) ) {
time = 0.0;
timeReso = 2.0*fakeBeamSpotTimeWidth;
}

const double vtxSigmaT2 = it->tError() * it->tError();
const double vtxTrackErr = std::sqrt( vtxSigmaT2 + timeReso*timeReso );

if ( (std::abs(t.dxy(it->position())) < rhoVtx_) &&
(std::abs(t.dz(it->position())) < zetaVtx_) &&
( !useTime || (std::abs(time - it->t())/vtxTrackErr < nSigmaDtVertex_) ) ) {
ok = true; break;
}
if (tested++ >= nVertices_) break;
Expand All @@ -76,3 +129,9 @@ bool TrackWithVertexSelector::operator()(const reco::Track &t) const {
return testVertices(t, *vcoll_);
}

bool TrackWithVertexSelector::operator()(const reco::TrackRef &tref) const {
if (!testTrack(tref)) return false;
if (nVertices_ == 0) return true;
return testVertices(tref, *vcoll_);
}

Expand Up @@ -32,7 +32,7 @@ struct SingleElementCollectionSelectorPlusEvent {
void select(const edm::Handle<InputCollection> & c, const edm::Event &ev, const edm::EventSetup &) {
selected_.clear();
for(size_t idx = 0; idx < c->size(); ++ idx) {
if(select_((*c)[idx], ev))
if(select_( edm::Ref<InputCollection>(c,idx), ev) ) //(*c)[idx]
addRef_(selected_, c, idx);
}
}
Expand Down
10 changes: 10 additions & 0 deletions Configuration/Applications/python/ConfigBuilder.py
Expand Up @@ -2217,6 +2217,16 @@ def prepare(self, doChecking = False):

self.pythonCfgCode += self.addCustomiseCmdLine()

# Temporary hack to put the early delete customization after
# everything else
#
# FIXME: remove when no longer needed
if "RECO" in self.stepMap or "RAW2RECO" in self.stepMap:
self.pythonCfgCode += "\n# Add early deletion of temporary data products to reduce peak memory need\n"
self.pythonCfgCode += "from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDeleteForRECO\n"
self.pythonCfgCode += "process = customiseEarlyDeleteForRECO(process)\n"
self.pythonCfgCode += "# End adding early deletion\n"


# make the .io file

Expand Down
4 changes: 4 additions & 0 deletions Configuration/StandardSequences/python/Reconstruction_cff.py
Expand Up @@ -135,6 +135,10 @@
noTrackingAndDependent.append(siStripZeroSuppression)
noTrackingAndDependent.append(siStripClusters)
noTrackingAndDependent.append(initialStepSeedLayersPreSplitting)
noTrackingAndDependent.append(trackerClusterCheckPreSplitting)
noTrackingAndDependent.append(initialStepTrackingRegionsPreSplitting)
noTrackingAndDependent.append(initialStepHitDoubletsPreSplitting)
noTrackingAndDependent.append(initialStepHitTripletsPreSplitting)
noTrackingAndDependent.append(initialStepSeedsPreSplitting)
noTrackingAndDependent.append(initialStepTrackCandidatesPreSplitting)
noTrackingAndDependent.append(initialStepTracksPreSplitting)
Expand Down
@@ -0,0 +1,7 @@
# Abstract all early deletion settings here

from RecoTracker.Configuration.customiseEarlyDeleteForSeeding import customiseEarlyDeleteForSeeding

def customiseEarlyDeleteForRECO(process):
process = customiseEarlyDeleteForSeeding(process)
return process
Expand Up @@ -154,9 +154,6 @@
*SiStripMonitorTrackCommon*SiStripMonitorTrackIB*MonitorTrackResiduals
*dqmInfoSiStrip)
from Configuration.Eras.Modifier_phase1Pixel_cff import phase1Pixel
phase1Pixel.toReplaceWith(SiStripDQMTier0, SiStripDQMTier0.copyAndExclude([ # FIXME
MonitorTrackResiduals # Excessive printouts because 2017 doesn't have HLT yet
]))

SiStripDQMTier0Common = cms.Sequence(
APVPhases*consecutiveHEs*siStripFEDCheck*siStripFEDMonitor*SiStripMonitorDigi*SiStripMonitorClusterBPTX
Expand All @@ -167,9 +164,6 @@
APVPhases*consecutiveHEs*siStripFEDCheck*siStripFEDMonitor*SiStripMonitorDigi*SiStripMonitorClusterBPTX
*SiStripMonitorTrackMB*SiStripMonitorTrackIB*MonitorTrackResiduals
*dqmInfoSiStrip)
phase1Pixel.toReplaceWith(SiStripDQMTier0MinBias, SiStripDQMTier0MinBias.copyAndExclude([ # FIXME
MonitorTrackResiduals # Excessive printouts because 2017 doesn't have HLT yet
]))



9 changes: 7 additions & 2 deletions DQM/SiStripMonitorTrack/interface/SiStripMonitorTrack.h
Expand Up @@ -104,7 +104,7 @@ class SiStripMonitorTrack : public DQMEDAnalyzer {
const SiStripRecHit1D* hit1D,
LocalVector localMomentum,
const bool track_ok);
bool clusterInfos(SiStripClusterInfo* cluster, const uint32_t detid, enum ClusterFlags flags, bool track_ok, LocalVector LV, const Det2MEs& MEs);
bool clusterInfos(SiStripClusterInfo* cluster, const uint32_t detid, enum ClusterFlags flags, bool track_ok, LocalVector LV, const Det2MEs& MEs , const TrackerTopology* tTopo);
template <class T> void RecHitInfo(const T* tkrecHit, LocalVector LV, const edm::EventSetup&, bool ok);

// fill monitorables
Expand Down Expand Up @@ -137,7 +137,7 @@ class SiStripMonitorTrack : public DQMEDAnalyzer {
struct ModMEs{
MonitorElement* ClusterStoNCorr;
MonitorElement* ClusterCharge;
MonitorElement* ClusterChargeCorr;
MonitorElement* ClusterChargeCorr;
MonitorElement* ClusterWidth;
MonitorElement* ClusterPos;
MonitorElement* ClusterPGV;
Expand Down Expand Up @@ -183,6 +183,11 @@ class SiStripMonitorTrack : public DQMEDAnalyzer {
MonitorElement* nClustersOffTrack;
MonitorElement* nClustersTrendOffTrack;
MonitorElement* ClusterStoNCorrOnTrack;
MonitorElement* ClusterStoNCorrThinOnTrack;
MonitorElement* ClusterStoNCorrThickOnTrack;
MonitorElement* ClusterChargeCorrOnTrack;
MonitorElement* ClusterChargeCorrThinOnTrack;
MonitorElement* ClusterChargeCorrThickOnTrack;
MonitorElement* ClusterChargeOnTrack;
MonitorElement* ClusterChargeOffTrack;
MonitorElement* ClusterStoNOffTrack;
Expand Down

0 comments on commit 1c88b6d

Please sign in to comment.