Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:29

0001 #include "RecoParticleFlow/PFProducer/interface/PFBlockAlgo.h"
0002 #include "FWCore/Framework/interface/Event.h"
0003 #include "FWCore/Framework/interface/MakerMacros.h"
0004 #include "FWCore/Framework/interface/stream/EDProducer.h"
0005 #include "FWCore/Utilities/interface/EDPutToken.h"
0006 #include "FWCore/Utilities/interface/Exception.h"
0007 
0008 /**\class PFBlockProducer 
0009 \brief Producer for particle flow blocks
0010 
0011 This producer makes use of PFBlockAlgo, the particle flow block algorithm.
0012 Particle flow itself consists in reconstructing particles from the particle 
0013 flow blocks This is done at a later stage, see PFProducer and PFAlgo.
0014 
0015 \author Colin Bernet
0016 \date   April 2007
0017 */
0018 
0019 class FSimEvent;
0020 
0021 class PFBlockProducer : public edm::stream::EDProducer<> {
0022 public:
0023   explicit PFBlockProducer(const edm::ParameterSet&);
0024 
0025   void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
0026 
0027   void produce(edm::Event&, const edm::EventSetup&) override;
0028 
0029 private:
0030   /// verbose ?
0031   const bool verbose_;
0032   const edm::EDPutTokenT<reco::PFBlockCollection> putToken_;
0033 
0034   /// Particle flow block algorithm
0035   PFBlockAlgo pfBlockAlgo_;
0036 };
0037 
0038 DEFINE_FWK_MODULE(PFBlockProducer);
0039 
0040 using namespace std;
0041 using namespace edm;
0042 
0043 PFBlockProducer::PFBlockProducer(const edm::ParameterSet& iConfig)
0044     : verbose_{iConfig.getUntrackedParameter<bool>("verbose", false)}, putToken_{produces<reco::PFBlockCollection>()} {
0045   bool debug_ = iConfig.getUntrackedParameter<bool>("debug", false);
0046   pfBlockAlgo_.setDebug(debug_);
0047 
0048   edm::ConsumesCollector cc = consumesCollector();
0049   const std::vector<edm::ParameterSet>& importers = iConfig.getParameterSetVector("elementImporters");
0050   pfBlockAlgo_.setImporters(importers, cc);
0051 
0052   const std::vector<edm::ParameterSet>& linkdefs = iConfig.getParameterSetVector("linkDefinitions");
0053   pfBlockAlgo_.setLinkers(linkdefs);
0054 }
0055 
0056 void PFBlockProducer::beginLuminosityBlock(edm::LuminosityBlock const& lb, edm::EventSetup const& es) {
0057   pfBlockAlgo_.updateEventSetup(es);
0058 }
0059 
0060 void PFBlockProducer::produce(Event& iEvent, const EventSetup& iSetup) {
0061   pfBlockAlgo_.buildElements(iEvent);
0062 
0063   auto blocks = pfBlockAlgo_.findBlocks();
0064 
0065   if (verbose_) {
0066     ostringstream str;
0067     str << pfBlockAlgo_ << endl;
0068     str << "number of blocks : " << blocks.size() << endl;
0069     str << endl;
0070 
0071     for (auto const& block : blocks) {
0072       str << block << endl;
0073     }
0074 
0075     LogInfo("PFBlockProducer") << str.str() << endl;
0076   }
0077 
0078   iEvent.emplace(putToken_, blocks);
0079 }