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

Use esConsumes in CosmicSeedGenerator #35258

Merged
merged 6 commits into from Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -5,7 +5,6 @@
#include "RecoPixelVertexing/PixelTriplets/interface/OrderedHitTriplets.h"
#include "RecoPixelVertexing/PixelTriplets/interface/CosmicHitTripletGeneratorFromLayerTriplet.h"
#include "DataFormats/Common/interface/RangeMap.h"
#include "FWCore/Framework/interface/EventSetup.h"

class LayerWithHits;
class DetLayer;
Expand All @@ -20,7 +19,7 @@ class CosmicHitTripletGenerator {
typedef std::vector<std::unique_ptr<CosmicHitTripletGeneratorFromLayerTriplet> > Container;

public:
CosmicHitTripletGenerator(CosmicLayerTriplets& layers, const edm::EventSetup& iSetup);
CosmicHitTripletGenerator(CosmicLayerTriplets& layers, const TrackerGeometry& trackGeom);
CosmicHitTripletGenerator(CosmicLayerTriplets& layers);

~CosmicHitTripletGenerator();
Expand All @@ -30,9 +29,9 @@ class CosmicHitTripletGenerator {
void add(const LayerWithHits* inner,
const LayerWithHits* middle,
const LayerWithHits* outer,
const edm::EventSetup& iSetup);
const TrackerGeometry& trackGeom);

void hitTriplets(const TrackingRegion& reg, OrderedHitTriplets& prs, const edm::EventSetup& iSetup);
void hitTriplets(const TrackingRegion& reg, OrderedHitTriplets& prs);

private:
Container theGenerators;
Expand Down
Expand Up @@ -18,17 +18,16 @@ class CosmicHitTripletGeneratorFromLayerTriplet {
CosmicHitTripletGeneratorFromLayerTriplet(const LayerWithHits* inner,
const LayerWithHits* middle,
const LayerWithHits* outer,
const edm::EventSetup& iSetup);
const TrackerGeometry& trackGeom);
~CosmicHitTripletGeneratorFromLayerTriplet() {}

void hitTriplets(const TrackingRegion& ar, OrderedHitTriplets& ap, const edm::EventSetup& iSetup);
void hitTriplets(const TrackingRegion& ar, OrderedHitTriplets& ap);

const LayerWithHits* innerLayer() const { return theInnerLayer; }
const LayerWithHits* middleLayer() const { return theMiddleLayer; }
const LayerWithHits* outerLayer() const { return theOuterLayer; }

private:
const TransientTrackingRecHitBuilder* TTRHbuilder;
const TrackerGeometry* trackerGeometry;
const LayerWithHits* theOuterLayer;
const LayerWithHits* theMiddleLayer;
Expand Down
22 changes: 11 additions & 11 deletions RecoPixelVertexing/PixelTriplets/interface/CosmicLayerTriplets.h
Expand Up @@ -6,8 +6,6 @@
*/
#include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h"
#include "DataFormats/Common/interface/RangeMap.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESWatcher.h"
#include "TrackingTools/DetLayers/interface/BarrelDetLayer.h"
#include "TrackingTools/DetLayers/interface/ForwardDetLayer.h"
#include "RecoTracker/TkHitPairs/interface/LayerWithHits.h"
Expand All @@ -18,12 +16,18 @@
#include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h"
#include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h"

#include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h"
class GeometricSearchTracker;
class TrackerTopology;

#include <vector>
class CosmicLayerTriplets {
public:
CosmicLayerTriplets(){};
CosmicLayerTriplets(std::string geometry,
const SiStripRecHit2DCollection &collrphi,
const GeometricSearchTracker &track,
const TrackerTopology &ttopo) {
init(collrphi, std::move(geometry), track, ttopo);
};
~CosmicLayerTriplets();
// explicit PixelSeedLayerPairs(const edm::EventSetup& iSetup);
typedef std::pair<SeedLayerPairs::LayerPair, std::vector<const LayerWithHits *> > LayerPairAndLayers;
Expand All @@ -40,18 +44,14 @@ class CosmicLayerTriplets {
LayerWithHits *lh3;
LayerWithHits *lh4;

edm::ESWatcher<TrackerRecoGeometryRecord> watchTrackerGeometry_;

std::vector<BarrelDetLayer const *> bl;
//MP
std::vector<LayerWithHits *> allLayersWithHits;

public:
void init(const SiStripRecHit2DCollection &collstereo,
const SiStripRecHit2DCollection &collrphi,
const SiStripMatchedRecHit2DCollection &collmatched,
void init(const SiStripRecHit2DCollection &collrphi,
std::string geometry,
const edm::EventSetup &iSetup);
const GeometricSearchTracker &track,
const TrackerTopology &ttopo);

private:
std::string _geometry;
Expand Down
Expand Up @@ -6,7 +6,7 @@

using namespace std;

CosmicHitTripletGenerator::CosmicHitTripletGenerator(CosmicLayerTriplets& layers, const edm::EventSetup& iSetup) {
CosmicHitTripletGenerator::CosmicHitTripletGenerator(CosmicLayerTriplets& layers, const TrackerGeometry& trackGeom) {
// vector<LayerTriplets::LayerTriplet> layerTriplets = layers();
vector<CosmicLayerTriplets::LayerPairAndLayers> layerTriplets = layers.layers();
vector<CosmicLayerTriplets::LayerPairAndLayers>::const_iterator it;
Expand All @@ -17,7 +17,7 @@ CosmicHitTripletGenerator::CosmicHitTripletGenerator(CosmicLayerTriplets& layers
// const LayerWithHits* second=(*it).first.second;
// const LayerWithHits* third=(*ilwh);
// add( (*it).first.first, (*it).first.second, (*it).second,iSetup);
add((*it).first.first, (*it).first.second, (*ilwh), iSetup);
add((*it).first.first, (*it).first.second, (*ilwh), trackGeom);
}
}
}
Expand All @@ -27,15 +27,13 @@ CosmicHitTripletGenerator::~CosmicHitTripletGenerator() {}
void CosmicHitTripletGenerator::add(const LayerWithHits* inner,
const LayerWithHits* middle,
const LayerWithHits* outer,
const edm::EventSetup& iSetup) {
theGenerators.push_back(std::make_unique<CosmicHitTripletGeneratorFromLayerTriplet>(inner, middle, outer, iSetup));
const TrackerGeometry& trackGeom) {
theGenerators.push_back(std::make_unique<CosmicHitTripletGeneratorFromLayerTriplet>(inner, middle, outer, trackGeom));
}

void CosmicHitTripletGenerator::hitTriplets(const TrackingRegion& region,
OrderedHitTriplets& pairs,
const edm::EventSetup& iSetup) {
void CosmicHitTripletGenerator::hitTriplets(const TrackingRegion& region, OrderedHitTriplets& pairs) {
Container::const_iterator i;
for (i = theGenerators.begin(); i != theGenerators.end(); i++) {
(**i).hitTriplets(region, pairs, iSetup);
(**i).hitTriplets(region, pairs);
}
}
Expand Up @@ -2,12 +2,8 @@
#include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h"
#include "TrackingTools/DetLayers/interface/DetLayer.h"
#include "RecoPixelVertexing/PixelTriplets/interface/OrderedHitTriplets.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "TrackingTools/DetLayers/interface/BarrelDetLayer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "RecoTracker/TransientTrackingRecHit/interface/TkTransientTrackingRecHitBuilder.h"
#include "TrackingTools/Records/interface/TransientRecHitRecord.h"

#include <cmath>

Expand All @@ -16,20 +12,13 @@ typedef TransientTrackingRecHit::ConstRecHitPointer TkHitPairsCachedHit;
CosmicHitTripletGeneratorFromLayerTriplet::CosmicHitTripletGeneratorFromLayerTriplet(const LayerWithHits *inner,
const LayerWithHits *middle,
const LayerWithHits *outer,
const edm::EventSetup &iSetup)
: TTRHbuilder(nullptr),
trackerGeometry(nullptr),
const TrackerGeometry &trackGeom)
: trackerGeometry(&trackGeom),
//theLayerCache(*layerCache),
theOuterLayer(outer),
theMiddleLayer(middle),
theInnerLayer(inner) {
edm::ESHandle<TrackerGeometry> tracker;
iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
trackerGeometry = tracker.product();
}
void CosmicHitTripletGeneratorFromLayerTriplet::hitTriplets(const TrackingRegion &region,
OrderedHitTriplets &result,
const edm::EventSetup &iSetup) {
theInnerLayer(inner) {}
void CosmicHitTripletGeneratorFromLayerTriplet::hitTriplets(const TrackingRegion &region, OrderedHitTriplets &result) {
if (theInnerLayer->recHits().empty())
return;
if (theMiddleLayer->recHits().empty())
Expand All @@ -44,10 +33,6 @@ void CosmicHitTripletGeneratorFromLayerTriplet::hitTriplets(const TrackingRegion
std::vector<const TrackingRecHit *>::const_iterator mhh;
std::vector<const TrackingRecHit *>::const_iterator ihh;

std::string builderName = "WithTrackAngle";
edm::ESHandle<TransientTrackingRecHitBuilder> builder;
iSetup.get<TransientRecHitRecord>().get(builderName, builder);

if (!seedfromoverlaps) {
for (ohh = theOuterLayer->recHits().begin(); ohh != theOuterLayer->recHits().end(); ohh++) {
auto oh = (BaseTrackerRecHit const *)(&*ohh);
Expand Down
19 changes: 5 additions & 14 deletions RecoPixelVertexing/PixelTriplets/src/CosmicLayerTriplets.cc
Expand Up @@ -53,21 +53,12 @@ CosmicLayerTriplets::~CosmicLayerTriplets() {
}
}

void CosmicLayerTriplets::init(const SiStripRecHit2DCollection& collstereo,
const SiStripRecHit2DCollection& collrphi,
const SiStripMatchedRecHit2DCollection& collmatched,
void CosmicLayerTriplets::init(const SiStripRecHit2DCollection& collrphi,
std::string geometry,
const edm::EventSetup& iSetup) {
_geometry = geometry;
if (watchTrackerGeometry_.check(iSetup)) {
edm::ESHandle<GeometricSearchTracker> track;
iSetup.get<TrackerRecoGeometryRecord>().get(track);
bl = track->barrelLayers();
}
edm::ESHandle<TrackerTopology> httopo;
iSetup.get<TrackerTopologyRcd>().get(httopo);
const TrackerTopology& ttopo = *httopo;

const GeometricSearchTracker& track,
const TrackerTopology& ttopo) {
_geometry = std::move(geometry);
bl = track.barrelLayers();
for (vector<LayerWithHits*>::const_iterator it = allLayersWithHits.begin(); it != allLayersWithHits.end(); it++) {
delete *it;
}
Expand Down
Expand Up @@ -9,6 +9,7 @@
#include "RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h"
//#include "RecoTracker/SpecialSeedGenerators/interface/SeedGeneratorFromLayerPairs.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h"
#include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h"
Expand All @@ -22,33 +23,43 @@
#include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h"
#include "RecoPixelVertexing/PixelTriplets/interface/CosmicHitTripletGenerator.h"
class PixelSeedLayerPairs;
class GeometricSearchTracker;
class TrackerRecoGeometryRecord;

class SeedGeneratorForCosmics {
public:
typedef TrajectoryStateOnSurface TSOS;
SeedGeneratorForCosmics(const edm::ParameterSet &conf);
virtual ~SeedGeneratorForCosmics(){};
SeedGeneratorForCosmics(const edm::ParameterSet &conf, edm::ConsumesCollector);

void run(const SiStripRecHit2DCollection &collstereo,
const SiStripRecHit2DCollection &collrphi,
const SiStripMatchedRecHit2DCollection &collmatched,
const edm::EventSetup &c,
TrajectorySeedCollection &);

private:
void init(const SiStripRecHit2DCollection &collstereo,
const SiStripRecHit2DCollection &collrphi,
const SiStripMatchedRecHit2DCollection &collmatched,
const edm::EventSetup &c);

void run(TrajectorySeedCollection &, const edm::EventSetup &c);
bool seeds(TrajectorySeedCollection &output, const edm::EventSetup &c, const TrackingRegion &region);
bool seeds(TrajectorySeedCollection &output, const TrackingRegion &region);

private:
int32_t maxSeeds_;
GlobalTrackingRegion region;
CosmicHitPairGenerator *thePairGenerator;
CosmicHitTripletGenerator *theTripletGenerator;
edm::ESHandle<MagneticField> magfield;
edm::ESHandle<TrackerGeometry> tracker;

const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> theMagfieldToken;
const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> theTrackerToken;
const edm::ESGetToken<GeometricSearchTracker, TrackerRecoGeometryRecord> theSearchTrackerToken;
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> theTTopoToken;

KFUpdator *theUpdator;
PropagatorWithMaterial *thePropagatorAl;
PropagatorWithMaterial *thePropagatorOp;
const TransientTrackingRecHitBuilder *TTTRHBuilder;
std::string builderName;
std::string geometry;
std::string hitsforseeds;
float seedpt;
Expand Down
6 changes: 2 additions & 4 deletions RecoTracker/SpecialSeedGenerators/src/CosmicSeedGenerator.cc
Expand Up @@ -15,7 +15,7 @@

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

{
Expand Down Expand Up @@ -45,10 +45,8 @@ void CosmicSeedGenerator::produce(edm::Event& ev, const edm::EventSetup& es) {
//check on the number of clusters
size_t clustsOrZero = check.tooManyClusters(ev);
if (!clustsOrZero) {
cosmic_seed.init(*stereorecHits, *rphirecHits, *matchedrecHits, es);

// invoke the seed finding algorithm
cosmic_seed.run(*output, es);
cosmic_seed.run(*stereorecHits, *rphirecHits, *matchedrecHits, es, *output);
} else
edm::LogError("TooManyClusters") << "Found too many clusters (" << clustsOrZero << "), bailing out.\n";

Expand Down
12 changes: 8 additions & 4 deletions RecoTracker/SpecialSeedGenerators/src/SeedGeneratorForCRack.cc
Expand Up @@ -2,6 +2,7 @@
#include "RecoTracker/TkHitPairs/interface/CosmicLayerPairs.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "TrackingTools/Records/interface/TransientRecHitRecord.h"
#include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h"
void SeedGeneratorForCRack::init(const SiStripRecHit2DCollection& collstereo,
const SiStripRecHit2DCollection& collrphi,
const SiStripMatchedRecHit2DCollection& collmatched,
Expand All @@ -18,11 +19,14 @@ void SeedGeneratorForCRack::init(const SiStripRecHit2DCollection& collstereo,

iSetup.get<TransientRecHitRecord>().get(builderName, theBuilder);
TTTRHBuilder = theBuilder.product();
CosmicLayerPairs cosmiclayers(geometry);
cosmiclayers.init(collstereo, collrphi, collmatched, iSetup);
thePairGenerator = new CosmicHitPairGenerator(cosmiclayers, iSetup);
edm::ESHandle<GeometricSearchTracker> track;
iSetup.get<TrackerRecoGeometryRecord>().get(track);
edm::ESHandle<TrackerTopology> httopo;
iSetup.get<TrackerTopologyRcd>().get(httopo);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this and 4 more es::get left for another PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That class apparently isn't used in any of the RelVals so its conversion isn't pressing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is occasionally used by the SiStrip group to test reconstruction with the Cosmic Rack, I can have a look next week.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #35367

CosmicLayerPairs cosmiclayers(geometry, collrphi, collmatched, *track, *httopo);
thePairGenerator = new CosmicHitPairGenerator(cosmiclayers, *tracker);
HitPairs.clear();
thePairGenerator->hitPairs(region, HitPairs, iSetup);
thePairGenerator->hitPairs(region, HitPairs);
LogDebug("CosmicSeedFinder") << "Initialized with " << HitPairs.size() << " hit pairs" << std::endl;
}

Expand Down