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

Add a flag to disable matching in SiStripRecHitConverter #28471

Merged
merged 5 commits into from Nov 27, 2019
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
@@ -1,7 +1,7 @@
#ifndef SiStripRecHitConverterAlgorithm_h
#define SiStripRecHitConverterAlgorithm_h

#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Utilities/interface/ESGetToken.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h"
#include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h"
Expand All @@ -13,9 +13,14 @@
#include "CalibFormats/SiStripObjects/interface/SiStripQuality.h"

namespace edm {
class ConsumesCollector;
class ParameterSet;
class ParameterSetDescription;
class EventSetup;
} // namespace edm
class TrackerDigiGeometryRecord;
class TkStripCPERecord;
class SiStripQualityRcd;

class SiStripRecHitConverterAlgorithm {
public:
Expand All @@ -38,24 +43,28 @@ class SiStripRecHitConverterAlgorithm {
}
};

SiStripRecHitConverterAlgorithm(const edm::ParameterSet&);
SiStripRecHitConverterAlgorithm(const edm::ParameterSet&, edm::ConsumesCollector);
void initialize(const edm::EventSetup&);
void run(edm::Handle<edmNew::DetSetVector<SiStripCluster> > input, products& output);
void run(edm::Handle<edmNew::DetSetVector<SiStripCluster> > input, products& output, LocalVector trackdirection);

static void fillPSetDescription(edm::ParameterSetDescription& desc);

private:
void match(products& output, LocalVector trackdirection) const;
void fillBad128StripBlocks(const uint32_t detid, bool bad128StripBlocks[6]) const;
bool isMasked(const SiStripCluster& cluster, bool bad128StripBlocks[6]) const;
bool useModule(const uint32_t id) const;

bool useQuality, maskBad128StripBlocks;
uint32_t tracker_cache_id, cpe_cache_id, quality_cache_id;
edm::ESInputTag cpeTag, matcherTag, qualityTag;
edm::ESHandle<TrackerGeometry> tracker;
edm::ESHandle<StripClusterParameterEstimator> parameterestimator;
edm::ESHandle<SiStripRecHitMatcher> matcher;
edm::ESHandle<SiStripQuality> quality;
bool useQuality, maskBad128StripBlocks, doMatching;
edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerToken;
edm::ESGetToken<StripClusterParameterEstimator, TkStripCPERecord> cpeToken;
edm::ESGetToken<SiStripRecHitMatcher, TkStripCPERecord> matcherToken;
edm::ESGetToken<SiStripQuality, SiStripQualityRcd> qualityToken;
const TrackerGeometry* tracker = nullptr;
const StripClusterParameterEstimator* parameterestimator = nullptr;
const SiStripRecHitMatcher* matcher = nullptr;
const SiStripQuality* quality = nullptr;

typedef SiStripRecHit2DCollection::FastFiller Collector;
};
Expand Down
@@ -1,19 +1,40 @@
#include "RecoLocalTracker/SiStripRecHitConverter/plugins/SiStripRecHitConverter.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"

SiStripRecHitConverter::SiStripRecHitConverter(edm::ParameterSet const& conf)
: recHitConverterAlgorithm(conf),
: recHitConverterAlgorithm(conf, consumesCollector()),
matchedRecHitsTag(conf.getParameter<std::string>("matchedRecHits")),
rphiRecHitsTag(conf.getParameter<std::string>("rphiRecHits")),
stereoRecHitsTag(conf.getParameter<std::string>("stereoRecHits")) {
stereoRecHitsTag(conf.getParameter<std::string>("stereoRecHits")),
doMatching(conf.getParameter<bool>("doMatching")) {
clusterProducer =
consumes<edmNew::DetSetVector<SiStripCluster> >(conf.getParameter<edm::InputTag>("ClusterProducer"));

produces<SiStripMatchedRecHit2DCollection>(matchedRecHitsTag);
produces<SiStripRecHit2DCollection>(rphiRecHitsTag);
produces<SiStripRecHit2DCollection>(stereoRecHitsTag);
produces<SiStripRecHit2DCollection>(rphiRecHitsTag + "Unmatched");
produces<SiStripRecHit2DCollection>(stereoRecHitsTag + "Unmatched");
if (doMatching) {
produces<SiStripMatchedRecHit2DCollection>(matchedRecHitsTag);
produces<SiStripRecHit2DCollection>(rphiRecHitsTag + "Unmatched");
produces<SiStripRecHit2DCollection>(stereoRecHitsTag + "Unmatched");
}
}

void SiStripRecHitConverter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("ClusterProducer", edm::InputTag("siStripClusters"));
desc.add<std::string>("rphiRecHits", "rphiRecHit");
desc.add<std::string>("stereoRecHits", "stereoRecHit");
desc.add<std::string>("matchedRecHits", "matchedRecHit");

SiStripRecHitConverterAlgorithm::fillPSetDescription(desc);

// unused? could be removed after parameter gets removed from HLT menu?
desc.addOptionalUntracked<int>("VerbosityLevel");

descriptions.addWithDefaultLabel(desc);
}

void SiStripRecHitConverter::produce(edm::Event& e, const edm::EventSetup& es) {
Expand All @@ -28,9 +49,11 @@ void SiStripRecHitConverter::produce(edm::Event& e, const edm::EventSetup& es) {
<< output.rphi->dataSize() << " clusters in mono detectors\n"
<< output.stereo->dataSize() << " clusters in partners stereo detectors\n";

e.put(std::move(output.matched), matchedRecHitsTag);
e.put(std::move(output.rphi), rphiRecHitsTag);
e.put(std::move(output.stereo), stereoRecHitsTag);
e.put(std::move(output.rphiUnmatched), rphiRecHitsTag + "Unmatched");
e.put(std::move(output.stereoUnmatched), stereoRecHitsTag + "Unmatched");
if (doMatching) {
e.put(std::move(output.matched), matchedRecHitsTag);
e.put(std::move(output.rphiUnmatched), rphiRecHitsTag + "Unmatched");
e.put(std::move(output.stereoUnmatched), stereoRecHitsTag + "Unmatched");
}
}
Expand Up @@ -10,9 +10,12 @@ class SiStripRecHitConverter : public edm::stream::EDProducer<> {
explicit SiStripRecHitConverter(const edm::ParameterSet&);
void produce(edm::Event&, const edm::EventSetup&) override;

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
SiStripRecHitConverterAlgorithm recHitConverterAlgorithm;
std::string matchedRecHitsTag, rphiRecHitsTag, stereoRecHitsTag;
edm::EDGetTokenT<edmNew::DetSetVector<SiStripCluster> > clusterProducer;
bool doMatching;
};
#endif
@@ -1,14 +1,5 @@
import FWCore.ParameterSet.Config as cms

siStripMatchedRecHits = cms.EDProducer("SiStripRecHitConverter",
ClusterProducer = cms.InputTag('siStripClusters'),
StripCPE = cms.ESInputTag('StripCPEfromTrackAngleESProducer:StripCPEfromTrackAngle'),
Matcher = cms.ESInputTag('SiStripRecHitMatcherESProducer:StandardMatcher'),
siStripQualityLabel = cms.ESInputTag(''),
useSiStripQuality = cms.bool(False),
MaskBadAPVFibers = cms.bool(False),
rphiRecHits = cms.string('rphiRecHit'),
stereoRecHits = cms.string('stereoRecHit'),
matchedRecHits = cms.string('matchedRecHit'),
VerbosityLevel = cms.untracked.int32(1)
)
from RecoLocalTracker.SiStripRecHitConverter.siStripRecHitConverter_cfi import siStripRecHitConverter as _siStripRecHitConverter

siStripMatchedRecHits = _siStripRecHitConverter.clone()
@@ -0,0 +1,3 @@
#include "RecoLocalTracker/SiStripRecHitConverter/interface/SiStripRecHitMatcher.h"
#include "FWCore/Utilities/interface/typelookup.h"
TYPELOOKUP_DATA_REG(SiStripRecHitMatcher);
Expand Up @@ -8,38 +8,45 @@
#include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
#include "DataFormats/Common/interface/Ref.h"

#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/typelookup.h"
TYPELOOKUP_DATA_REG(SiStripRecHitMatcher);

SiStripRecHitConverterAlgorithm::SiStripRecHitConverterAlgorithm(const edm::ParameterSet& conf)
SiStripRecHitConverterAlgorithm::SiStripRecHitConverterAlgorithm(const edm::ParameterSet& conf,
edm::ConsumesCollector iC)
: useQuality(conf.getParameter<bool>("useSiStripQuality")),
maskBad128StripBlocks(conf.existsAs<bool>("MaskBadAPVFibers") && conf.getParameter<bool>("MaskBadAPVFibers")),
tracker_cache_id(0),
cpe_cache_id(0),
quality_cache_id(0),
cpeTag(conf.getParameter<edm::ESInputTag>("StripCPE")),
matcherTag(conf.getParameter<edm::ESInputTag>("Matcher")),
qualityTag(conf.getParameter<edm::ESInputTag>("siStripQualityLabel")) {}
maskBad128StripBlocks(conf.getParameter<bool>("MaskBadAPVFibers")),
doMatching(conf.getParameter<bool>("doMatching")),
trackerToken(iC.esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>()),
cpeToken(iC.esConsumes<StripClusterParameterEstimator, TkStripCPERecord>(
conf.getParameter<edm::ESInputTag>("StripCPE"))) {
if (doMatching) {
matcherToken = iC.esConsumes<SiStripRecHitMatcher, TkStripCPERecord>(conf.getParameter<edm::ESInputTag>("Matcher"));
}
if (useQuality) {
qualityToken =
iC.esConsumes<SiStripQuality, SiStripQualityRcd>(conf.getParameter<edm::ESInputTag>("siStripQualityLabel"));
}
}

void SiStripRecHitConverterAlgorithm::initialize(const edm::EventSetup& es) {
uint32_t tk_cache_id = es.get<TrackerDigiGeometryRecord>().cacheIdentifier();
uint32_t c_cache_id = es.get<TkStripCPERecord>().cacheIdentifier();
uint32_t q_cache_id = es.get<SiStripQualityRcd>().cacheIdentifier();
void SiStripRecHitConverterAlgorithm::fillPSetDescription(edm::ParameterSetDescription& desc) {
desc.add<bool>("useSiStripQuality", false);
desc.add<bool>("MaskBadAPVFibers", false);
desc.add<bool>("doMatching", true);
desc.add<edm::ESInputTag>("StripCPE", edm::ESInputTag("StripCPEfromTrackAngleESProducer", "StripCPEfromTrackAngle"));
desc.add<edm::ESInputTag>("Matcher", edm::ESInputTag("SiStripRecHitMatcherESProducer", "StandardMatcher"));
desc.add<edm::ESInputTag>("siStripQualityLabel", edm::ESInputTag());
}

if (tk_cache_id != tracker_cache_id) {
es.get<TrackerDigiGeometryRecord>().get(tracker);
tracker_cache_id = tk_cache_id;
}
if (c_cache_id != cpe_cache_id) {
es.get<TkStripCPERecord>().get(matcherTag, matcher);
es.get<TkStripCPERecord>().get(cpeTag, parameterestimator);
cpe_cache_id = c_cache_id;
void SiStripRecHitConverterAlgorithm::initialize(const edm::EventSetup& es) {
tracker = &es.getData(trackerToken);
parameterestimator = &es.getData(cpeToken);
if (doMatching) {
matcher = &es.getData(matcherToken);
}
if (useQuality && q_cache_id != quality_cache_id) {
es.get<SiStripQualityRcd>().get(qualityTag, quality);
quality_cache_id = q_cache_id;
if (useQuality) {
quality = &es.getData(qualityToken);
}
}

Expand Down Expand Up @@ -73,7 +80,9 @@ void SiStripRecHitConverterAlgorithm::run(edm::Handle<edmNew::DetSetVector<SiStr
if (collector.empty())
collector.abort();
}
match(output, trackdirection);
if (doMatching) {
match(output, trackdirection);
}
}

namespace {
Expand Down