Skip to content

Commit

Permalink
Make some protection in accessing inpu collections for MTD so that so…
Browse files Browse the repository at this point in the history
…me FasTsim tests can proceed
  • Loading branch information
Sunanda committed Apr 10, 2022
1 parent 6272f05 commit bbd405e
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 24 deletions.
11 changes: 9 additions & 2 deletions RecoLocalFastTime/FTLClusterizer/plugins/MTDClusterProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,15 @@ 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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit bbd405e

Please sign in to comment.