Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deliver TrackerTopology via ESProducers to TrackCleaner
Browse files Browse the repository at this point in the history
makortel committed Nov 29, 2016
1 parent 7bf7712 commit 7b054b6
Showing 9 changed files with 41 additions and 49 deletions.
12 changes: 6 additions & 6 deletions RecoPixelVertexing/PixelLowPtUtilities/interface/TrackCleaner.h
Original file line number Diff line number Diff line change
@@ -15,23 +15,23 @@ class TrackerTopology;
class TrackCleaner : public PixelTrackCleaner
{
public:
TrackCleaner();
explicit TrackCleaner(const TrackerTopology *tTopo);
virtual ~TrackCleaner();

virtual TracksWithRecHits cleanTracks
(const TracksWithRecHits & tracksWithRecHits, const TrackerTopology *tTopo) const;
(const TracksWithRecHits & tracksWithRecHits) const;

private:
bool areSame(const TrackingRecHit * a,
const TrackingRecHit * b) const;
bool isCompatible(const DetId & i1,
const DetId & i2,
const TrackerTopology *tTopo) const;
const DetId & i2) const;
bool canBeMerged(const std::vector<const TrackingRecHit *>& recHitsA,
const std::vector<const TrackingRecHit *>& recHitsB,
const TrackerTopology *tTopo) const;
const std::vector<const TrackingRecHit *>& recHitsB) const;

std::vector<const TrackingRecHit*> ttrhs(const SeedingHitSet & h) const;

const TrackerTopology *tTopo_;
};

#endif
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// user include files
#include "FWCore/Framework/interface/ModuleFactory.h"
#include "FWCore/Framework/interface/ESProducer.h"

#include "FWCore/Framework/interface/ESHandle.h"

#include "Geometry/Records/interface/TrackerTopologyRcd.h"

#include "RecoPixelVertexing/PixelLowPtUtilities/interface/TrackCleaner.h"

class TrackCleanerESProducer: public edm::ESProducer {
@@ -28,7 +29,11 @@ void TrackCleanerESProducer::fillDescriptions(edm::ConfigurationDescriptions& de
}

std::unique_ptr<PixelTrackCleaner> TrackCleanerESProducer::produce(const PixelTrackCleaner::Record& iRecord) {
return std::make_unique<TrackCleaner>();
edm::ESHandle<TrackerTopology> tTopoHand;
iRecord.getRecord<TrackerTopologyRcd>().get(tTopoHand);
const TrackerTopology *tTopo=tTopoHand.product();

return std::make_unique<TrackCleaner>(tTopo);
}

#include "FWCore/PluginManager/interface/ModuleDef.h"
39 changes: 18 additions & 21 deletions RecoPixelVertexing/PixelLowPtUtilities/src/TrackCleaner.cc
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ class HitComparator
};

/*****************************************************************************/
TrackCleaner::TrackCleaner()
TrackCleaner::TrackCleaner(const TrackerTopology *tTopo): tTopo_(tTopo)
{
}

@@ -97,37 +97,36 @@ bool TrackCleaner::areSame(const TrackingRecHit * a,

/*****************************************************************************/
bool TrackCleaner::isCompatible(const DetId & i1,
const DetId & i2,
const TrackerTopology *tTopo) const
const DetId & i2) const
{
// different subdet
if(i1.subdetId() != i2.subdetId()) return true;

if(i1.subdetId() == int(PixelSubdetector::PixelBarrel))
{ // barrel

if(tTopo->pxbLayer(i1) != tTopo->pxbLayer(i2)) return true;
if(tTopo_->pxbLayer(i1) != tTopo_->pxbLayer(i2)) return true;

int dphi = abs(int(tTopo->pxbLadder(i1) - tTopo->pxbLadder(i2)));
int dphi = abs(int(tTopo_->pxbLadder(i1) - tTopo_->pxbLadder(i2)));
constexpr int max[3] = {20, 32, 44};
if(dphi > max[tTopo->pxbLayer(i1)-1] / 2) dphi = max[tTopo->pxbLayer(i1)-1] - dphi;
if(dphi > max[tTopo_->pxbLayer(i1)-1] / 2) dphi = max[tTopo_->pxbLayer(i1)-1] - dphi;

int dz = abs(int(tTopo->pxbModule(i1) - tTopo->pxbModule(i2)));
int dz = abs(int(tTopo_->pxbModule(i1) - tTopo_->pxbModule(i2)));

if(dphi == 1 && dz <= 1) return true;
}
else
{ // endcap

if(tTopo->pxfSide(i1) != tTopo->pxfSide(i2) ||
tTopo->pxfDisk(i1) != tTopo->pxfDisk(i2)) return true;
if(tTopo_->pxfSide(i1) != tTopo_->pxfSide(i2) ||
tTopo_->pxfDisk(i1) != tTopo_->pxfDisk(i2)) return true;

int dphi = abs(int(tTopo->pxfBlade(i1) - tTopo->pxfBlade(i2)));
int dphi = abs(int(tTopo_->pxfBlade(i1) - tTopo_->pxfBlade(i2)));
constexpr int max = 24;
if(dphi > max / 2) dphi = max - dphi;

int dr = abs(int( ((tTopo->pxfModule(i1)-1) * 2 + (tTopo->pxfPanel(i1)-1)) -
((tTopo->pxfModule(i2)-1) * 2 + (tTopo->pxfPanel(i2)-1)) ));
int dr = abs(int( ((tTopo_->pxfModule(i1)-1) * 2 + (tTopo_->pxfPanel(i1)-1)) -
((tTopo_->pxfModule(i2)-1) * 2 + (tTopo_->pxfPanel(i2)-1)) ));

if(dphi <= 1 && dr <= 1 && !(dphi == 0 && dr == 0)) return true;
}
@@ -138,8 +137,7 @@ bool TrackCleaner::isCompatible(const DetId & i1,
/*****************************************************************************/
bool TrackCleaner::canBeMerged
(const vector<const TrackingRecHit *>& recHitsA,
const vector<const TrackingRecHit *>& recHitsB,
const TrackerTopology *tTopo) const
const vector<const TrackingRecHit *>& recHitsB) const
{
bool ok = true;

@@ -149,16 +147,15 @@ bool TrackCleaner::canBeMerged
recHitB = recHitsB.begin(); recHitB!= recHitsB.end(); recHitB++)
if(!areSame(*recHitA,*recHitB))
if(!isCompatible((*recHitA)->geographicalId(),
(*recHitB)->geographicalId(),
tTopo))
(*recHitB)->geographicalId()))
ok = false;

return ok;
}

/*****************************************************************************/
TracksWithRecHits TrackCleaner::cleanTracks
(const TracksWithRecHits & tracks_, const TrackerTopology *tTopo) const
(const TracksWithRecHits & tracks_) const
{
// Local copy
TracksWithRecHits tracks = tracks_;
@@ -175,7 +172,7 @@ TracksWithRecHits TrackCleaner::cleanTracks

for(unsigned int i = 0; i < tracks.size(); i++)
LogTrace("TrackCleaner")
<< " Track #" << i << " : " << HitInfo::getInfo(tracks[i].second,tTopo);
<< " Track #" << i << " : " << HitInfo::getInfo(tracks[i].second, tTopo_);

do
{
@@ -240,7 +237,7 @@ TracksWithRecHits TrackCleaner::cleanTracks
if((*sharing).second > min(int(tracks[i].second.size()),
int(tracks[j].second.size()))/2)
{ // more than min(hits1,hits2)/2 rechits are shared
if(canBeMerged(tracks[i].second,tracks[j].second,tTopo))
if(canBeMerged(tracks[i].second,tracks[j].second))
{ // no common layer
// merge tracks, add separate hits of the second to the first one
for(vector<const TrackingRecHit *>::const_iterator
@@ -260,7 +257,7 @@ TracksWithRecHits TrackCleaner::cleanTracks

sort(tracks[i].second.begin(),
tracks[i].second.end(),
HitComparatorByRadius(tTopo));
HitComparatorByRadius(tTopo_));

//addedNewHit = true;
}
@@ -350,7 +347,7 @@ TracksWithRecHits TrackCleaner::cleanTracks

for(unsigned int i = 0; i < cleaned.size(); i++)
LogTrace("TrackCleaner")
<< " Track #" << i << " : " << HitInfo::getInfo(cleaned[i].second,tTopo);
<< " Track #" << i << " : " << HitInfo::getInfo(cleaned[i].second,tTopo_);

return cleaned;
}
Original file line number Diff line number Diff line change
@@ -11,8 +11,6 @@ Discards reconstructed tracks that reflects one real track.
#include "RecoPixelVertexing/PixelTrackFitting/interface/TracksWithHits.h"
#include<cassert>

class TrackerTopology;

class PixelTrackCleaner {
protected:
explicit PixelTrackCleaner(bool fast=false): fast_(fast) {}
@@ -26,16 +24,15 @@ class PixelTrackCleaner {

// used by HI?
typedef pixeltrackfitting::TracksWithRecHits TracksWithRecHits;
virtual TracksWithRecHits cleanTracks(const TracksWithRecHits & tracksWithRecHits, const TrackerTopology *tTopo) const {
virtual TracksWithRecHits cleanTracks(const TracksWithRecHits & tracksWithRecHits) const {
assert(false);
return TracksWithRecHits();
}


// fast
using TracksWithTTRHs = pixeltrackfitting::TracksWithTTRHs;
virtual void cleanTracks(TracksWithTTRHs & tracksWithRecHits,
const TrackerTopology *tTopo) const {assert(false);}
virtual void cleanTracks(TracksWithTTRHs & tracksWithRecHits) const {assert(false);}

private:
const bool fast_;
Original file line number Diff line number Diff line change
@@ -23,8 +23,7 @@ class PixelTrackCleanerBySharedHits final : public PixelTrackCleaner {

using TrackWithTTRHs = pixeltrackfitting::TrackWithTTRHs;
using TracksWithTTRHs = pixeltrackfitting::TracksWithTTRHs;
void cleanTracks(TracksWithTTRHs & tracksWithRecHits,
const TrackerTopology *tTopo) const override;
void cleanTracks(TracksWithTTRHs & tracksWithRecHits) const override;

private:
const bool useQuadrupletAlgo_;
Original file line number Diff line number Diff line change
@@ -12,8 +12,7 @@ class PixelTrackCleanerWrapper {
public:
PixelTrackCleanerWrapper(const PixelTrackCleaner * tc) : theCleaner(tc) {}
pixeltrackfitting::TracksWithTTRHs clean(
const pixeltrackfitting::TracksWithTTRHs & initialT_TTRHs,
const TrackerTopology *tTopo) const {
const pixeltrackfitting::TracksWithTTRHs & initialT_TTRHs) const {

pixeltrackfitting::TracksWithRecHits initialT_TRHs;
std::map<const TrackingRecHit *, SeedingHitSet::ConstRecHitPointer> hitMap;
@@ -29,7 +28,7 @@ class PixelTrackCleanerWrapper {
initialT_TRHs.push_back( pixeltrackfitting::TrackWithRecHits(it->first, trhs) );
}

pixeltrackfitting::TracksWithRecHits finalT_TRHs = theCleaner->cleanTracks(initialT_TRHs, tTopo);
pixeltrackfitting::TracksWithRecHits finalT_TRHs = theCleaner->cleanTracks(initialT_TRHs);
pixeltrackfitting::TracksWithTTRHs finalT_TTRHs;

for (pixeltrackfitting::TracksWithRecHits::const_iterator it = finalT_TRHs.begin(), iend = finalT_TRHs.end(); it < iend; ++it) {
Original file line number Diff line number Diff line change
@@ -18,8 +18,7 @@ PixelTrackCleanerBySharedHits::~PixelTrackCleanerBySharedHits()
{}


void PixelTrackCleanerBySharedHits::cleanTracks(TracksWithTTRHs & trackHitPairs,
const TrackerTopology *tTopo) const
void PixelTrackCleanerBySharedHits::cleanTracks(TracksWithTTRHs & trackHitPairs) const
{

LogDebug("PixelTrackCleanerBySharedHits") << "Cleanering tracks" << "\n";
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "DataFormats/TrackReco/interface/TrackExtra.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"

#include "RecoPixelVertexing/PixelTriplets/interface/QuadrupletSeedMerger.h"

@@ -80,11 +79,6 @@ void PixelTrackReconstruction::run(TracksWithTTRHs& tracks, edm::Event& ev, cons
typedef Regions::const_iterator IR;
Regions regions = theRegionProducer->regions(ev,es);

//Retrieve tracker topology from geometry
edm::ESHandle<TrackerTopology> tTopoHand;
es.get<TrackerTopologyRcd>().get(tTopoHand);
const TrackerTopology *tTopo=tTopoHand.product();

edm::Handle<PixelFitter> hfitter;
ev.getByToken(theFitterToken, hfitter);
const auto& fitter = *hfitter;
@@ -135,8 +129,8 @@ void PixelTrackReconstruction::run(TracksWithTTRHs& tracks, edm::Event& ev, cons
es.get<PixelTrackCleaner::Record>().get(theCleanerName, hcleaner);
const auto& cleaner = *hcleaner;
if(cleaner.fast())
cleaner.cleanTracks(tracks,tTopo);
cleaner.cleanTracks(tracks);
else
tracks = PixelTrackCleanerWrapper(&cleaner).clean(tracks,tTopo);
tracks = PixelTrackCleanerWrapper(&cleaner).clean(tracks);
}
}
2 changes: 2 additions & 0 deletions RecoTracker/Record/interface/CkfComponentsRecord.h
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
#include "RecoLocalTracker/Records/interface/TkPixelCPERecord.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
#include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
#include "TrackingTools/Records/interface/TransientRecHitRecord.h"
#include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
@@ -27,6 +28,7 @@ class CkfComponentsRecord : public edm::eventsetup::DependentRecordImplementatio
TransientRecHitRecord,
TrackingComponentsRecord,
TrackerRecoGeometryRecord,
TrackerTopologyRcd,
SiStripQualityRcd,
SiStripDetCablingRcd,
SiStripNoisesRcd,

0 comments on commit 7b054b6

Please sign in to comment.