Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:28:53

0001 #include "FWCore/Framework/interface/stream/EDProducer.h"
0002 #include "FWCore/Framework/interface/Event.h"
0003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 
0008 #include "RecoTracker/TkSeedGenerator/interface/ClusterChecker.h"
0009 
0010 class ClusterCheckerEDProducer : public edm::stream::EDProducer<> {
0011 public:
0012   ClusterCheckerEDProducer(const edm::ParameterSet& iConfig);
0013   ~ClusterCheckerEDProducer() override = default;
0014 
0015   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0016 
0017   void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
0018 
0019 private:
0020   ClusterChecker theClusterCheck;
0021   bool theSilentOnClusterCheck;
0022 };
0023 
0024 ClusterCheckerEDProducer::ClusterCheckerEDProducer(const edm::ParameterSet& iConfig)
0025     : theClusterCheck(iConfig, consumesCollector()),
0026       theSilentOnClusterCheck(iConfig.getUntrackedParameter<bool>("silentClusterCheck")) {
0027   produces<bool>();
0028 }
0029 
0030 void ClusterCheckerEDProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0031   edm::ParameterSetDescription desc;
0032   ClusterChecker::fillDescriptions(desc);
0033   desc.addUntracked<bool>("silentClusterCheck", false);
0034 
0035   descriptions.add("trackerClusterCheckDefault", desc);
0036 }
0037 
0038 void ClusterCheckerEDProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0039   auto ret = std::make_unique<bool>(true);
0040 
0041   //protection for big ass events...
0042   size_t clustsOrZero = theClusterCheck.tooManyClusters(iEvent);
0043   if (clustsOrZero) {
0044     if (!theSilentOnClusterCheck)
0045       edm::LogError("TooManyClusters") << "Found too many clusters (" << clustsOrZero << "), bailing out.";
0046     *ret = false;
0047   }
0048 
0049   iEvent.put(std::move(ret));
0050 }
0051 
0052 #include "FWCore/Framework/interface/MakerMacros.h"
0053 DEFINE_FWK_MODULE(ClusterCheckerEDProducer);