Skip to content

Commit

Permalink
Merge pull request #1851 from thspeer/consumesTrackingSeedingTwo
Browse files Browse the repository at this point in the history
Consumes migration -- Migrate remaining classes in RecoTracker/TkSeedGenerator
  • Loading branch information
ktf committed Dec 18, 2013
2 parents 109d084 + be66452 commit 926f66d
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 17 deletions.
Expand Up @@ -33,7 +33,6 @@

//#include "DataFormats/TrackReco/src/classes.h"

#include "RecoTracker/TrackProducer/interface/ClusterRemovalRefSetter.h"
#include "CommonTools/Statistics/interface/ChiSquaredProbability.h"


Expand Down
17 changes: 11 additions & 6 deletions RecoTracker/TkSeedGenerator/plugins/SeedCombiner.cc
Expand Up @@ -21,19 +21,24 @@
#include "RecoTracker/TkSeedGenerator/interface/SeedGeneratorFromRegionHits.h"

#include "RecoTracker/TrackProducer/interface/ClusterRemovalRefSetter.h"
#include "FWCore/Utilities/interface/transform.h"

using namespace edm;
//using namespace reco;

SeedCombiner::SeedCombiner(
const edm::ParameterSet& cfg)
:
inputCollections_(cfg.getParameter<std::vector<edm::InputTag> >("seedCollections"))
SeedCombiner::SeedCombiner(const edm::ParameterSet& cfg)
{
inputCollections_ = edm::vector_transform(
cfg.getParameter<std::vector<edm::InputTag> >("seedCollections"),
[this](edm::InputTag const & tag) { return consumes<TrajectorySeedCollection>(tag); } );
produces<TrajectorySeedCollection>();
reKeing_=false;
if (cfg.exists("clusterRemovalInfos")){
clusterRemovalInfos_=cfg.getParameter<std::vector<edm::InputTag> >("clusterRemovalInfos");
clusterRemovalTokens_.resize(clusterRemovalInfos_.size());
for (unsigned int i=0;i<clusterRemovalInfos_.size();++i)
if (!(clusterRemovalInfos_[i]==edm::InputTag("")))
clusterRemovalTokens_[i] = consumes<reco::ClusterRemovalInfo>(clusterRemovalInfos_[i]);
if (clusterRemovalInfos_.size()!=0 && clusterRemovalInfos_.size()==inputCollections_.size()) reKeing_=true;
}
}
Expand All @@ -51,7 +56,7 @@ void SeedCombiner::produce(edm::Event& ev, const edm::EventSetup& es)
size_t nseeds = 0;
std::vector<Handle<TrajectorySeedCollection > > seedCollections(ninputs);
for (size_t i = 0; i < ninputs; ++i) {
ev.getByLabel(inputCollections_[i], seedCollections[i]);
ev.getByToken(inputCollections_[i], seedCollections[i]);
nseeds += seedCollections[i]->size();
}

Expand All @@ -64,7 +69,7 @@ void SeedCombiner::produce(edm::Event& ev, const edm::EventSetup& es)
for (;iSC!=iSC_max;++iSC){
Handle<TrajectorySeedCollection> & collection=seedCollections[iSC];
if (reKeing_ && !(clusterRemovalInfos_[iSC]==edm::InputTag(""))){
ClusterRemovalRefSetter refSetter(ev, clusterRemovalInfos_[iSC]);
ClusterRemovalRefSetter refSetter(ev, clusterRemovalTokens_[iSC]);

for (TrajectorySeedCollection::const_iterator iS=collection->begin();
iS!=collection->end();++iS){
Expand Down
5 changes: 4 additions & 1 deletion RecoTracker/TkSeedGenerator/plugins/SeedCombiner.h
Expand Up @@ -3,6 +3,8 @@

#include <vector>
#include "FWCore/Framework/interface/EDProducer.h"
#include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
#include "DataFormats/TrackerRecHit2D/interface/ClusterRemovalInfo.h"
#include "FWCore/Utilities/interface/InputTag.h"

namespace edm { class Event; class EventSetup; class ParameterSet; }
Expand All @@ -17,9 +19,10 @@ class SeedCombiner : public edm::EDProducer {
virtual void produce(edm::Event& ev, const edm::EventSetup& es) override;

private:
std::vector<edm::InputTag> inputCollections_;
std::vector<edm::EDGetTokenT<TrajectorySeedCollection>> inputCollections_;
bool reKeing_;
std::vector<edm::InputTag> clusterRemovalInfos_;
std::vector<edm::EDGetTokenT<reco::ClusterRemovalInfo>> clusterRemovalTokens_;
};

#endif
Expand Up @@ -3,6 +3,7 @@
#include "FWCore/Framework/interface/Event.h"
#include "DataFormats/Common/interface/Handle.h"

#include "FWCore/Utilities/interface/InputTag.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
Expand All @@ -21,8 +22,6 @@
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"


#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include <vector>
#include <cassert>
Expand Down Expand Up @@ -52,8 +51,8 @@ SeedGeneratorFromProtoTracksEDProducer::SeedGeneratorFromProtoTracksEDProducer(c

{
produces<TrajectorySeedCollection>();
theInputCollectionTag = cfg.getParameter<InputTag>("InputCollection");
theInputVertexCollectionTag = cfg.getParameter<InputTag>("InputVertexCollection");
theInputCollectionTag = consumes<reco::TrackCollection>(cfg.getParameter<InputTag>("InputCollection"));
theInputVertexCollectionTag = consumes<reco::VertexCollection>(cfg.getParameter<InputTag>("InputVertexCollection"));
originHalfLength = cfg.getParameter<double>("originHalfLength");
originRadius = cfg.getParameter<double>("originRadius");
useProtoTrackKinematics = cfg.getParameter<bool>("useProtoTrackKinematics");
Expand All @@ -67,12 +66,12 @@ void SeedGeneratorFromProtoTracksEDProducer::produce(edm::Event& ev, const edm::
{
std::auto_ptr<TrajectorySeedCollection> result(new TrajectorySeedCollection());
Handle<reco::TrackCollection> trks;
ev.getByLabel(theInputCollectionTag, trks);
ev.getByToken(theInputCollectionTag, trks);

const TrackCollection &protos = *(trks.product());

edm::Handle<reco::VertexCollection> vertices;
bool foundVertices = ev.getByLabel(theInputVertexCollectionTag, vertices);
bool foundVertices = ev.getByToken(theInputVertexCollectionTag, vertices);
//const reco::VertexCollection & vertices = *(h_vertices.product());

///
Expand Down
Expand Up @@ -2,8 +2,9 @@
#define RecoTracker_TkSeedGenerator_SeedGeneratorFromProtoTracksEDProducer_H

#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"

namespace edm { class Event; class EventSetup; }

Expand All @@ -17,8 +18,8 @@ class SeedGeneratorFromProtoTracksEDProducer : public edm::EDProducer {

private:
edm::ParameterSet theConfig;
edm::InputTag theInputCollectionTag;
edm::InputTag theInputVertexCollectionTag;
edm::EDGetTokenT<reco::TrackCollection> theInputCollectionTag;
edm::EDGetTokenT<reco::VertexCollection> theInputVertexCollectionTag;
double originHalfLength;
double originRadius;
bool useProtoTrackKinematics;
Expand Down
4 changes: 4 additions & 0 deletions RecoTracker/TrackProducer/interface/ClusterRemovalRefSetter.h
Expand Up @@ -13,13 +13,17 @@
#include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2D.h"
#include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h"
#include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit1D.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Utilities/interface/InputTag.h"

class ClusterRemovalRefSetter {
public:
ClusterRemovalRefSetter(const edm::Event &iEvent, const edm::InputTag& tag) ;
ClusterRemovalRefSetter(const edm::Event &iEvent,
const edm::EDGetTokenT<reco::ClusterRemovalInfo>& token) ;

void reKey(TrackingRecHit *hit) const ;
private:
typedef OmniClusterRef::ClusterPixelRef ClusterPixelRef;
Expand Down
7 changes: 7 additions & 0 deletions RecoTracker/TrackProducer/src/ClusterRemovalRefSetter.cc
Expand Up @@ -10,6 +10,13 @@ ClusterRemovalRefSetter::ClusterRemovalRefSetter(const edm::Event &iEvent, const
//std::cout << "Rekeying STRIP ProdID " << cri_->stripNewRefProd().id() << " => " << cri_->stripRefProd().id() << std::endl;
}

ClusterRemovalRefSetter::ClusterRemovalRefSetter(const edm::Event &iEvent,
const edm::EDGetTokenT<reco::ClusterRemovalInfo>& token) {
edm::Handle<reco::ClusterRemovalInfo> hCRI;
iEvent.getByToken(token, hCRI);
cri_ = &*hCRI;
}

void ClusterRemovalRefSetter::reKey(TrackingRecHit *hit) const {
if (!hit->isValid()) return;
DetId detid = hit->geographicalId();
Expand Down

0 comments on commit 926f66d

Please sign in to comment.