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

Phase2-gex127M Make some protection in accessing inpu collections for MTD so that some FasTsim tests can proceed #37517

Merged
merged 2 commits into from Apr 12, 2022
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
10 changes: 8 additions & 2 deletions RecoLocalFastTime/FTLClusterizer/plugins/MTDClusterProducer.cc
Expand Up @@ -127,8 +127,14 @@ void MTDClusterProducer::produce(edm::Event& e, const edm::EventSetup& es) {
auto outputBarrel = std::make_unique<FTLClusterCollection>();
auto outputEndcap = std::make_unique<FTLClusterCollection>();

run(*inputBarrel, *outputBarrel);
run(*inputEndcap, *outputEndcap);
if (inputBarrel.isValid())
run(*inputBarrel, *outputBarrel);
else
edm::LogWarning("MTDReco") << "MTDClusterProducer:: Missing Barrel Digis";
if (inputEndcap.isValid())
run(*inputEndcap, *outputEndcap);
else
edm::LogWarning("MTDReco") << "MTDClusterProducer:: Missing Endcap Digis";

e.put(std::move(outputBarrel), ftlbInstance_);
e.put(std::move(outputEndcap), ftleInstance_);
Expand Down
32 changes: 20 additions & 12 deletions RecoLocalFastTime/FTLRecProducers/plugins/MTDRecHitProducer.cc
Expand Up @@ -79,22 +79,30 @@ void MTDRecHitProducer::produce(edm::Event& evt, const edm::EventSetup& es) {

edm::Handle<FTLUncalibratedRecHitCollection> hBarrel;
evt.getByToken(ftlbURecHits_, hBarrel);
barrelRechits->reserve(hBarrel->size() / 2);
for (const auto& uhit : *hBarrel) {
uint32_t flags = FTLRecHit::kGood;
auto rechit = barrel_->makeRecHit(uhit, flags);
if (flags == FTLRecHit::kGood)
barrelRechits->push_back(rechit);
if (hBarrel.isValid()) {
barrelRechits->reserve(hBarrel->size() / 2);
for (const auto& uhit : *hBarrel) {
uint32_t flags = FTLRecHit::kGood;
auto rechit = barrel_->makeRecHit(uhit, flags);
if (flags == FTLRecHit::kGood)
barrelRechits->push_back(rechit);
}
} else {
edm::LogWarning("MTDReco") << "MTDRecHitProducer: Missing Uncalibrated Barrel RecHit Collection";
}

edm::Handle<FTLUncalibratedRecHitCollection> hEndcap;
evt.getByToken(ftleURecHits_, hEndcap);
endcapRechits->reserve(hEndcap->size() / 2);
for (const auto& uhit : *hEndcap) {
uint32_t flags = FTLRecHit::kGood;
auto rechit = endcap_->makeRecHit(uhit, flags);
if (flags == FTLRecHit::kGood)
endcapRechits->push_back(rechit);
if (hEndcap.isValid()) {
endcapRechits->reserve(hEndcap->size() / 2);
for (const auto& uhit : *hEndcap) {
uint32_t flags = FTLRecHit::kGood;
auto rechit = endcap_->makeRecHit(uhit, flags);
if (flags == FTLRecHit::kGood)
endcapRechits->push_back(rechit);
}
} else {
edm::LogWarning("MTDReco") << "MTDRecHitProducer: Missing Uncalibrated Endcap RecHit Collection";
}

// put the collection of recunstructed hits in the event
Expand Down
Expand Up @@ -73,6 +73,10 @@ void MTDTrackingRecHitProducer::produce(edm::StreamID, edm::Event& evt, const ed
//---------------------------------------------------------------------------

for (auto const& theInput : inputHandle) {
if (!theInput.isValid()) {
edm::LogWarning("MTDReco") << "MTDTrackingRecHitProducer: Invalid collection";
continue;
}
const edmNew::DetSetVector<FTLCluster>& input = *theInput;

LogDebug("MTDTrackingRecHitProducer") << "inputCollection " << input.size();
Expand Down
Expand Up @@ -65,16 +65,24 @@ void MTDUncalibratedRecHitProducer::produce(edm::Event& evt, const edm::EventSet

edm::Handle<BTLDigiCollection> hBarrel;
evt.getByToken(ftlbDigis_, hBarrel);
barrelRechits->reserve(hBarrel->size() / 2);
for (const auto& digi : *hBarrel) {
barrelRechits->emplace_back(barrel_->makeRecHit(digi));
if (hBarrel.isValid()) {
barrelRechits->reserve(hBarrel->size() / 2);
for (const auto& digi : *hBarrel) {
barrelRechits->emplace_back(barrel_->makeRecHit(digi));
}
} else {
edm::LogWarning("MTDReco") << "MTDUncalibratedRecHitProducer: Missing BTL Digi Collection";
}

edm::Handle<ETLDigiCollection> hEndcap;
evt.getByToken(ftleDigis_, hEndcap);
endcapRechits->reserve(hEndcap->size() / 2);
for (const auto& digi : *hEndcap) {
endcapRechits->emplace_back(endcap_->makeRecHit(digi));
if (hEndcap.isValid()) {
endcapRechits->reserve(hEndcap->size() / 2);
for (const auto& digi : *hEndcap) {
endcapRechits->emplace_back(endcap_->makeRecHit(digi));
}
} else {
edm::LogWarning("MTDReco") << "MTDUncalibratedRecHitProducer: Missing ETL Digi Collection";
}

// put the collection of recunstructed hits in the event
Expand Down
10 changes: 8 additions & 2 deletions SimFastTiming/FastTimingCommon/interface/MTDDigitizer.h
Expand Up @@ -179,7 +179,10 @@ namespace mtd_digitizer {
void MTDDigitizer<Traits>::accumulate(edm::Event const& e, edm::EventSetup const& c, CLHEP::HepRandomEngine* hre) {
edm::Handle<edm::PSimHitContainer> simHits;
e.getByLabel(inputSimHits_, simHits);
accumulate(simHits, 0, hre);
if (simHits.isValid())
accumulate(simHits, 0, hre);
else
edm::LogWarning("MTDMix") << "MTDDigitizer:: Cannot find hits for " << inputSimHits_;
}

template <class Traits>
Expand All @@ -188,7 +191,10 @@ namespace mtd_digitizer {
CLHEP::HepRandomEngine* hre) {
edm::Handle<edm::PSimHitContainer> simHits;
e.getByLabel(inputSimHits_, simHits);
accumulate(simHits, e.bunchCrossing(), hre);
if (simHits.isValid())
accumulate(simHits, e.bunchCrossing(), hre);
else
edm::LogWarning("MTDMix") << "MTDDigitizer:: Cannot find hits for " << inputSimHits_;
}

template <class Traits>
Expand Down
10 changes: 8 additions & 2 deletions SimFastTiming/FastTimingCommon/plugins/PreMixingMTDWorker.cc
Expand Up @@ -52,13 +52,19 @@ void PreMixingMTDWorker::initializeEvent(const edm::Event& e, const edm::EventSe
void PreMixingMTDWorker::addSignals(const edm::Event& e, const edm::EventSetup& ES) {
edm::Handle<PMTDSimAccumulator> handle;
e.getByToken(signalToken_, handle);
digitizer_->accumulate(*handle);
if (handle.isValid())
digitizer_->accumulate(*handle);
else
edm::LogWarning("MtdMix") << "PreMixingMTDWorker::Cannot find Signal collection";
}

void PreMixingMTDWorker::addPileups(const PileUpEventPrincipal& pep, const edm::EventSetup& ES) {
edm::Handle<PMTDSimAccumulator> handle;
pep.getByLabel(pileInputTag_, handle);
digitizer_->accumulate(*handle);
if (handle.isValid())
digitizer_->accumulate(*handle);
else
edm::LogWarning("MtdMix") << "PreMixingMTDWorker::Cannot find PileUp collection";
}

void PreMixingMTDWorker::put(edm::Event& e,
Expand Down