Skip to content

Commit

Permalink
do not fetch PixelClusterCountsInEvent when the handle is not valid
Browse files Browse the repository at this point in the history
  • Loading branch information
mmusich committed Apr 27, 2022
1 parent 0b3455d commit 067f72d
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions Calibration/LumiAlCaRecoProducers/plugins/AlcaPCCIntegrator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,24 @@ ________________________________________________________________**/
// C++ standard
#include <string>
// CMS
#include "DataFormats/Luminosity/interface/PixelClusterCountsInEvent.h"
#include "DataFormats/Luminosity/interface/PixelClusterCounts.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "DataFormats/Luminosity/interface/PixelClusterCountsInEvent.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/LuminosityBlock.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/one/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/LuminosityBlock.h"
#include "TMath.h"
//The class
class AlcaPCCIntegrator
: public edm::one::EDProducer<edm::EndLuminosityBlockProducer, edm::one::WatchLuminosityBlocks> {
public:
explicit AlcaPCCIntegrator(const edm::ParameterSet&);
~AlcaPCCIntegrator() override;
~AlcaPCCIntegrator() override = default;

private:
void beginLuminosityBlock(edm::LuminosityBlock const& lumiSeg, const edm::EventSetup& iSetup) override;
Expand Down Expand Up @@ -67,9 +63,6 @@ AlcaPCCIntegrator::AlcaPCCIntegrator(const edm::ParameterSet& iConfig) {
pccToken_ = consumes<reco::PixelClusterCountsInEvent>(PCCInputTag_);
}

//--------------------------------------------------------------------------------------------------
AlcaPCCIntegrator::~AlcaPCCIntegrator() {}

//--------------------------------------------------------------------------------------------------
void AlcaPCCIntegrator::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
countEvt_++;
Expand All @@ -83,7 +76,12 @@ void AlcaPCCIntegrator::produce(edm::Event& iEvent, const edm::EventSetup& iSetu
edm::Handle<reco::PixelClusterCountsInEvent> pccHandle;
iEvent.getByToken(pccToken_, pccHandle);

const reco::PixelClusterCountsInEvent inputPcc = *(pccHandle.product());
if (!pccHandle.isValid()) {
// do not resolve a not existing product!
return;
}

const reco::PixelClusterCountsInEvent inputPcc = *pccHandle;
thePCCob->add(inputPcc);
}

Expand Down

0 comments on commit 067f72d

Please sign in to comment.