Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to consumes interface and getByToken for TrackerSeedGenerator #1849

Merged
merged 1 commit into from Dec 18, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -14,7 +14,7 @@ class TrackingRegion;
class MuonServiceProxy;
class TrackerTopology;

namespace edm {class ParameterSet; class Event; class EventSetup;}
namespace edm {class ParameterSet; class Event; class EventSetup; class ConsumesCollector;}

class TrackerSeedGenerator {

Expand Down
15 changes: 5 additions & 10 deletions RecoMuon/TrackerSeedGenerator/plugins/TSGFromPropagation.cc
Expand Up @@ -26,16 +26,9 @@

#include "FWCore/MessageLogger/interface/MessageLogger.h"

TSGFromPropagation::TSGFromPropagation(const edm::ParameterSet & iConfig, edm::ConsumesCollector& iC): TSGFromPropagation(iConfig, iC, nullptr) {}

TSGFromPropagation::TSGFromPropagation(const edm::ParameterSet & iConfig,edm::ConsumesCollector & iC) :theTkLayerMeasurements (), theTracker(0), theMeasTracker(0), theNavigation(0), theService(0), theEstimator(0), theTSTransformer(0), theSigmaZ(0), theConfig (iConfig)
{
theCategory = "Muon|RecoMuon|TSGFromPropagation";
theMeasTrackerName = iConfig.getParameter<std::string>("MeasurementTrackerName");
theMeasurementTrackerEventTag = iConfig.getParameter<edm::InputTag>("MeasurementTrackerEvent");
beamspotToken = iC.consumes<reco::BeamSpot>(theConfig.getParameter<edm::InputTag>("beamSpot"));
}

TSGFromPropagation::TSGFromPropagation(const edm::ParameterSet & iConfig, const MuonServiceProxy* service,edm::ConsumesCollector& iC) : theTkLayerMeasurements (), theTracker(0), theMeasTracker(0), theNavigation(0), theService(service),theUpdator(0), theEstimator(0), theTSTransformer(0), theSigmaZ(0), theConfig (iConfig)
TSGFromPropagation::TSGFromPropagation(const edm::ParameterSet & iConfig, edm::ConsumesCollector& iC, const MuonServiceProxy* service) : theTkLayerMeasurements (), theTracker(0), theMeasTracker(0), theNavigation(0), theService(service),theUpdator(0), theEstimator(0), theTSTransformer(0), theSigmaZ(0), theConfig (iConfig)
{
theCategory = "Muon|RecoMuon|TSGFromPropagation";
theMeasTrackerName = iConfig.getParameter<std::string>("MeasurementTrackerName");
Expand Down Expand Up @@ -175,6 +168,7 @@ void TSGFromPropagation::init(const MuonServiceProxy* service) {

theSigmaZ = theConfig.getParameter<double>("SigmaZ");

theBeamSpotInputTag = theConfig.getParameter<edm::InputTag>("beamSpot");

edm::ParameterSet errorMatrixPset = theConfig.getParameter<edm::ParameterSet>("errorMatrixPset");
if ( theResetMethod == "matrix" && !errorMatrixPset.empty()){
Expand All @@ -191,7 +185,8 @@ void TSGFromPropagation::init(const MuonServiceProxy* service) {
}

void TSGFromPropagation::setEvent(const edm::Event& iEvent) {
iEvent.getByToken(beamspotToken, beamSpot);
//edm::Handle<reco::BeamSpot> beamSpot;
iEvent.getByLabel(theBeamSpotInputTag, beamSpot);

unsigned long long newCacheId_MT = theService->eventSetup().get<CkfComponentsRecord>().cacheIdentifier();

Expand Down
7 changes: 3 additions & 4 deletions RecoMuon/TrackerSeedGenerator/plugins/TSGFromPropagation.h
Expand Up @@ -18,7 +18,6 @@
#include "RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h"
#include "TrackingTools/MeasurementDet/interface/LayerMeasurements.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

class Chi2MeasurementEstimator;
class Propagator;
Expand All @@ -32,9 +31,9 @@ class TSGFromPropagation : public TrackerSeedGenerator {

public:
/// constructor
TSGFromPropagation(const edm::ParameterSet &pset,edm::ConsumesCollector&);
TSGFromPropagation(const edm::ParameterSet &pset, edm::ConsumesCollector& iC);

TSGFromPropagation(const edm::ParameterSet& par, const MuonServiceProxy*, edm::ConsumesCollector&);
TSGFromPropagation(const edm::ParameterSet& par, edm::ConsumesCollector& iC, const MuonServiceProxy*);

/// destructor
virtual ~TSGFromPropagation();
Expand Down Expand Up @@ -154,7 +153,7 @@ class TSGFromPropagation : public TrackerSeedGenerator {
edm::ParameterSet theConfig;

edm::Handle<reco::BeamSpot> beamSpot;
edm::EDGetTokenT<reco::BeamSpot> beamspotToken;
edm::InputTag theBeamSpotInputTag;

};

Expand Down
3 changes: 1 addition & 2 deletions RecoMuon/TrackerSeedGenerator/plugins/TSGSmart.h
Expand Up @@ -3,7 +3,6 @@

#include "RecoMuon/TrackerSeedGenerator/interface/TrackerSeedGenerator.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

class SeedGeneratorFromRegionHits;
class TrackingRegion;
Expand All @@ -12,7 +11,7 @@ class TrackingRegion;
class TSGSmart : public TrackerSeedGenerator {

public:
TSGSmart(const edm::ParameterSet &pset,edm::ConsumesCollector& iC);
TSGSmart(const edm::ParameterSet &pset, edm::ConsumesCollector& iC);

virtual ~TSGSmart();

Expand Down
Expand Up @@ -58,7 +58,6 @@ PixelTrackReconstruction::PixelTrackReconstruction(const ParameterSet& cfg,

PixelTrackReconstruction::~PixelTrackReconstruction()
{
delete theRegionProducer; theRegionProducer=0;
halt();
}

Expand All @@ -68,6 +67,7 @@ void PixelTrackReconstruction::halt()
delete theFitter; theFitter=0;
delete theCleaner; theCleaner=0;
delete theGenerator; theGenerator=0;
delete theRegionProducer; theRegionProducer=0;
delete theMerger_; theMerger_=0;
}

Expand Down
Expand Up @@ -32,7 +32,7 @@ class CombinedHitPairGeneratorForPhotonConversion : public HitPairGenerator {
virtual ~CombinedHitPairGeneratorForPhotonConversion();

void add(const ctfseeding::SeedingLayer & inner,
const ctfseeding::SeedingLayer & outer);
const ctfseeding::SeedingLayer & outer);

/// form base class
virtual void hitPairs(const TrackingRegion&, OrderedHitPairs&, const edm::Event&, const edm::EventSetup&){};
Expand Down
Expand Up @@ -25,7 +25,7 @@ PhotonConversionTrajectorySeedProducerFromQuadrupletsAlgo(const edm::ParameterSe
hitsfactoryPSet(conf.getParameter<edm::ParameterSet>("OrderedHitsFactoryPSet")),
creatorPSet(conf.getParameter<edm::ParameterSet>("SeedCreatorPSet")),
regfactoryPSet(conf.getParameter<edm::ParameterSet>("RegionFactoryPSet")),
theClusterCheck(conf.getParameter<edm::ParameterSet>("ClusterCheckPSet")),
theClusterCheck(conf.getParameter<edm::ParameterSet>("ClusterCheckPSet"), std::move(iC)),
SeedComparitorPSet(conf.getParameter<edm::ParameterSet>("SeedComparitorPSet")),
QuadCutPSet(conf.getParameter<edm::ParameterSet>("QuadCutPSet")),
theSilentOnClusterCheck(conf.getParameter<edm::ParameterSet>("ClusterCheckPSet").getUntrackedParameter<bool>("silentClusterCheck",false)){
Expand Down
Expand Up @@ -19,7 +19,7 @@ PhotonConversionTrajectorySeedProducerFromSingleLegAlgo(const edm::ParameterSet
hitsfactoryPSet(conf.getParameter<edm::ParameterSet>("OrderedHitsFactoryPSet")),
creatorPSet(conf.getParameter<edm::ParameterSet>("SeedCreatorPSet")),
regfactoryPSet(conf.getParameter<edm::ParameterSet>("RegionFactoryPSet")),
theClusterCheck(conf.getParameter<edm::ParameterSet>("ClusterCheckPSet")),
theClusterCheck(conf.getParameter<edm::ParameterSet>("ClusterCheckPSet"), std::move(iC)),
theSilentOnClusterCheck(conf.getParameter<edm::ParameterSet>("ClusterCheckPSet").getUntrackedParameter<bool>("silentClusterCheck",false)),
_vtxMinDoF(conf.getParameter<double>("vtxMinDoF")),
_maxDZSigmas(conf.getParameter<double>("maxDZSigmas")),
Expand All @@ -35,7 +35,7 @@ PhotonConversionTrajectorySeedProducerFromSingleLegAlgo(const edm::ParameterSet
theRegionProducer = new GlobalTrackingRegionProducerFromBeamSpot(regfactoryPSet, std::move(iC));
init();
}

PhotonConversionTrajectorySeedProducerFromSingleLegAlgo::~PhotonConversionTrajectorySeedProducerFromSingleLegAlgo() {
if(theRegionProducer!=NULL)
delete theRegionProducer;
Expand Down
Expand Up @@ -17,6 +17,7 @@

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "RecoTracker/SpecialSeedGenerators/interface/SeedGeneratorForCosmics.h"
#include "RecoTracker/SpecialSeedGenerators/interface/ClusterChecker.h"


class CosmicSeedGenerator : public edm::EDProducer
Expand All @@ -32,6 +33,7 @@ class CosmicSeedGenerator : public edm::EDProducer
private:
edm::ParameterSet conf_;
SeedGeneratorForCosmics cosmic_seed;
ClusterChecker check;


};
Expand Down
Expand Up @@ -33,6 +33,7 @@
#include "TrackingTools/DetLayers/interface/NavigationDirection.h"
//Geometry
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "RecoTracker/SpecialSeedGenerators/interface/ClusterChecker.h"

#include <map>

Expand Down Expand Up @@ -92,6 +93,7 @@ class CtfSpecialSeedGenerator : public edm::EDProducer
BoundPlane::BoundPlanePointer lowerScintillator;
bool requireBOFF;
int32_t theMaxSeeds;
ClusterChecker check;
};
#endif

Expand Down
6 changes: 3 additions & 3 deletions RecoTracker/SpecialSeedGenerators/src/CosmicSeedGenerator.cc
Expand Up @@ -13,11 +13,12 @@
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/InputTag.h"

#include "RecoTracker/SpecialSeedGenerators/interface/ClusterChecker.h"

using namespace std;
CosmicSeedGenerator::CosmicSeedGenerator(edm::ParameterSet const& conf) :
conf_(conf) ,cosmic_seed(conf)
conf_(conf) ,cosmic_seed(conf),
check(conf,consumesCollector())

{
edm::LogInfo ("CosmicSeedGenerator")<<"Enter the CosmicSeedGenerator";
produces<TrajectorySeedCollection>();
Expand Down Expand Up @@ -46,7 +47,6 @@ void CosmicSeedGenerator::produce(edm::Event& ev, const edm::EventSetup& es)
std::auto_ptr<TrajectorySeedCollection> output(new TrajectorySeedCollection);

//check on the number of clusters
ClusterChecker check(conf_);
size_t clustsOrZero = check.tooManyClusters(ev);
if (!clustsOrZero){
cosmic_seed.init(*stereorecHits,*rphirecHits,*matchedrecHits, es);
Expand Down
Expand Up @@ -13,14 +13,14 @@

#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "RecoTracker/SpecialSeedGenerators/interface/ClusterChecker.h"

using namespace ctfseeding;

CtfSpecialSeedGenerator::CtfSpecialSeedGenerator(const edm::ParameterSet& conf):
conf_(conf),
requireBOFF(conf.getParameter<bool>("requireBOFF")),
theMaxSeeds(conf.getParameter<int32_t>("maxSeeds"))
theMaxSeeds(conf.getParameter<int32_t>("maxSeeds")),
check(conf,consumesCollector())

{
useScintillatorsConstraint = conf_.getParameter<bool>("UseScintillatorsConstraint");
edm::LogVerbatim("CtfSpecialSeedGenerator") << "Constructing CtfSpecialSeedGenerator";
Expand Down Expand Up @@ -146,7 +146,6 @@ void CtfSpecialSeedGenerator::produce(edm::Event& e, const edm::EventSetup& iSet
std::auto_ptr<TrajectorySeedCollection> output(new TrajectorySeedCollection);

//check on the number of clusters
ClusterChecker check(conf_);
if ( !requireBOFF || (theMagfield->inTesla(GlobalPoint(0,0,0)).mag() == 0.00) ) {
size_t clustsOrZero = check.tooManyClusters(e);
if (!clustsOrZero){
Expand Down
Expand Up @@ -23,7 +23,7 @@ SimpleCosmicBONSeeder::SimpleCosmicBONSeeder(edm::ParameterSet const& conf) :
tripletsVerbosity_(conf.getParameter<edm::ParameterSet>("TripletsPSet").getUntrackedParameter<uint32_t>("debugLevel",0)),
seedVerbosity_(conf.getUntrackedParameter<uint32_t>("seedDebugLevel",0)),
helixVerbosity_(conf.getUntrackedParameter<uint32_t>("helixDebugLevel",0)),
check_(conf.getParameter<edm::ParameterSet>("ClusterCheckPSet")),
check_(conf.getParameter<edm::ParameterSet>("ClusterCheckPSet"), consumesCollector()),
maxTriplets_(conf.getParameter<int32_t>("maxTriplets")),
maxSeeds_(conf.getParameter<int32_t>("maxSeeds"))
{
Expand Down
22 changes: 21 additions & 1 deletion RecoTracker/TkSeedGenerator/interface/ClusterChecker.h
Expand Up @@ -3,6 +3,18 @@

#include "FWCore/Utilities/interface/InputTag.h"
#include "CommonTools/Utils/interface/StringCutObjectSelector.h"
#include "DataFormats/Common/interface/DetSetVectorNew.h"
#include "DataFormats/Common/interface/LazyGetter.h"
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
#include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"

#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
#include "FWCore/Framework/interface/ConsumesCollector.h"
#else
namespace edm {
class ConsumesCollector;
}
#endif

namespace edm { class Event; class ParameterSet; }

Expand All @@ -18,18 +30,26 @@ namespace reco { namespace utils {

class ClusterChecker {
public:
ClusterChecker(const edm::ParameterSet & conf) ;
#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
ClusterChecker(const edm::ParameterSet & conf, edm::ConsumesCollector && iC) ;
#endif

~ClusterChecker() ;
size_t tooManyClusters(const edm::Event & e) const ;

private:
ClusterChecker(); // This is only needed for StringCutObjectSelector
bool doACheck_;
edm::InputTag clusterCollectionInputTag_;
edm::InputTag pixelClusterCollectionInputTag_;
unsigned int maxNrOfCosmicClusters_;
unsigned int maxNrOfPixelClusters_;
StringCutObjectSelector<reco::utils::ClusterTotals> selector_;
unsigned int ignoreDetsAboveNClusters_;
#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__REFLEX__)
edm::EDGetTokenT<edmNew::DetSetVector<SiStripCluster> > token_sc;
edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster> > token_pc;
#endif
};

#endif
Expand Up @@ -20,13 +20,12 @@

#include "RecoTracker/TkSeedGenerator/interface/SeedGeneratorFromRegionHits.h"
#include "RecoPixelVertexing/PixelTriplets/interface/QuadrupletSeedMerger.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"


SeedGeneratorFromRegionHitsEDProducer::SeedGeneratorFromRegionHitsEDProducer(
const edm::ParameterSet& cfg)
: theConfig(cfg), theGenerator(0), theRegionProducer(0),
theClusterCheck(cfg.getParameter<edm::ParameterSet>("ClusterCheckPSet")),
theClusterCheck(cfg.getParameter<edm::ParameterSet>("ClusterCheckPSet"),consumesCollector()),
theMerger_(0)
{
theSilentOnClusterCheck = cfg.getParameter<edm::ParameterSet>("ClusterCheckPSet").getUntrackedParameter<bool>("silentClusterCheck",false);
Expand All @@ -53,10 +52,10 @@ SeedGeneratorFromRegionHitsEDProducer::SeedGeneratorFromRegionHitsEDProducer(

SeedGeneratorFromRegionHitsEDProducer::~SeedGeneratorFromRegionHitsEDProducer()
{
delete theRegionProducer;
}

void SeedGeneratorFromRegionHitsEDProducer::endRun(edm::Run const&run, const edm::EventSetup& es) {
delete theRegionProducer;
delete theGenerator;
}

Expand All @@ -81,7 +80,7 @@ void SeedGeneratorFromRegionHitsEDProducer::beginRun(edm::Run const&run, const e

theGenerator = new SeedGeneratorFromRegionHits(hitsGenerator, aComparitor, aCreator);
}

void SeedGeneratorFromRegionHitsEDProducer::produce(edm::Event& ev, const edm::EventSetup& es)
{
std::auto_ptr<TrajectorySeedCollection> triplets(new TrajectorySeedCollection());
Expand Down Expand Up @@ -119,7 +118,7 @@ void SeedGeneratorFromRegionHitsEDProducer::produce(edm::Event& ev, const edm::E
}
}
}

// clear memory
for (IR ir=regions.begin(), irEnd=regions.end(); ir < irEnd; ++ir) delete (*ir);

Expand Down
15 changes: 7 additions & 8 deletions RecoTracker/TkSeedGenerator/src/ClusterChecker.cc
Expand Up @@ -3,14 +3,11 @@
#include "FWCore/Framework/interface/Event.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/Common/interface/LazyGetter.h"
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
#include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
#include "DataFormats/Common/interface/DetSetVectorNew.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"

ClusterChecker::ClusterChecker(const edm::ParameterSet & conf):
ClusterChecker::ClusterChecker(const edm::ParameterSet & conf,
edm::ConsumesCollector && iC):
doACheck_(conf.getParameter<bool>("doClusterCheck")),
selector_(conf.getParameter<bool>("doClusterCheck") && conf.existsAs<std::string>("cut") ?
conf.getParameter<std::string>("cut") :
Expand All @@ -19,6 +16,8 @@ ClusterChecker::ClusterChecker(const edm::ParameterSet & conf):
if (doACheck_){
clusterCollectionInputTag_ = conf.getParameter<edm::InputTag>("ClusterCollectionLabel");
pixelClusterCollectionInputTag_ = conf.getParameter<edm::InputTag>("PixelClusterCollectionLabel");
token_sc = iC.consumes<edmNew::DetSetVector<SiStripCluster> >(clusterCollectionInputTag_);
token_pc = iC.consumes<edmNew::DetSetVector<SiPixelCluster> >(pixelClusterCollectionInputTag_);
maxNrOfCosmicClusters_ = conf.getParameter<unsigned int>("MaxNumberOfCosmicClusters");
maxNrOfPixelClusters_ = conf.getParameter<unsigned int>("MaxNumberOfPixelClusters");
if (conf.existsAs<uint32_t>("DontCountDetsAboveNClusters")) {
Expand All @@ -40,7 +39,7 @@ size_t ClusterChecker::tooManyClusters(const edm::Event & e) const

// get special input for cosmic cluster multiplicity filter
edm::Handle<edmNew::DetSetVector<SiStripCluster> > clusterDSV;
e.getByLabel(clusterCollectionInputTag_, clusterDSV);
e.getByToken(token_sc, clusterDSV);
reco::utils::ClusterTotals totals;
if (!clusterDSV.failedToGet()) {
const edmNew::DetSetVector<SiStripCluster> & input = *clusterDSV;
Expand All @@ -63,7 +62,7 @@ size_t ClusterChecker::tooManyClusters(const edm::Event & e) const
}
else{
edm::Handle<edm::LazyGetter<SiStripCluster> > lazyGH;
e.getByLabel(clusterCollectionInputTag_, lazyGH);
e.getByToken(token_sc, lazyGH);
totals.stripdets = 0; // don't know how to count this online
if (!lazyGH.failedToGet()){
totals.strip = lazyGH->size();
Expand All @@ -77,7 +76,7 @@ size_t ClusterChecker::tooManyClusters(const edm::Event & e) const

// get special input for pixel cluster multiplicity filter
edm::Handle<edmNew::DetSetVector<SiPixelCluster> > pixelClusterDSV;
e.getByLabel(pixelClusterCollectionInputTag_, pixelClusterDSV);
e.getByToken(token_pc, pixelClusterDSV);
if (!pixelClusterDSV.failedToGet()) {
const edmNew::DetSetVector<SiPixelCluster> & input = *pixelClusterDSV;

Expand Down