Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:21:00

0001 #ifndef __PFClusterBuilderBase_H__
0002 #define __PFClusterBuilderBase_H__
0003 
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/Framework/interface/ConsumesCollector.h"
0006 #include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
0007 #include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
0008 
0009 #include "RecoParticleFlow/PFClusterProducer/interface/PFCPositionCalculatorBase.h"
0010 
0011 #include <string>
0012 #include <iostream>
0013 #include <memory>
0014 
0015 namespace edm {
0016   class EventSetup;
0017 }
0018 
0019 class PFClusterBuilderBase {
0020   typedef PFClusterBuilderBase PFCBB;
0021 
0022 public:
0023   typedef PFCPositionCalculatorBase PosCalc;
0024   PFClusterBuilderBase(const edm::ParameterSet& conf, edm::ConsumesCollector& cc)
0025       : _nSeeds(0),
0026         _nClustersFound(0),
0027         _minFractionToKeep(conf.getParameter<double>("minFractionToKeep")),
0028         _algoName(conf.getParameter<std::string>("algoName")) {
0029     if (conf.exists("positionCalc")) {
0030       const edm::ParameterSet& pcConf = conf.getParameterSet("positionCalc");
0031       const std::string& algo = pcConf.getParameter<std::string>("algoName");
0032       _positionCalc = PFCPositionCalculatorFactory::get()->create(algo, pcConf, cc);
0033     }
0034   }
0035   virtual ~PFClusterBuilderBase() = default;
0036   // get rid of things we should never use...
0037   PFClusterBuilderBase(const PFCBB&) = delete;
0038   PFCBB& operator=(const PFCBB&) = delete;
0039 
0040   virtual void update(const edm::EventSetup&) {}
0041 
0042   virtual void buildClusters(const reco::PFClusterCollection& topos,
0043                              const std::vector<bool>& seedable,
0044                              reco::PFClusterCollection& outclus) = 0;
0045 
0046   std::ostream& operator<<(std::ostream& o) const {
0047     o << "PFClusterBuilder with algo \"" << _algoName << "\" located " << _nSeeds << " seeds and built "
0048       << _nClustersFound << " PFClusters from those seeds"
0049       << " using position calculation: " << _positionCalc->name() << "." << std::endl;
0050     return o;
0051   }
0052 
0053   void reset() { _nSeeds = _nClustersFound = 0; }
0054 
0055 protected:
0056   unsigned _nSeeds, _nClustersFound;  // basic performance information
0057   const float _minFractionToKeep;     // min fraction value to keep in clusters
0058   std::unique_ptr<PosCalc> _positionCalc;
0059 
0060 private:
0061   std::string _algoName;
0062 };
0063 
0064 std::ostream& operator<<(std::ostream& o, const PFClusterBuilderBase& a);
0065 
0066 #include "FWCore/PluginManager/interface/PluginFactory.h"
0067 typedef edmplugin::PluginFactory<PFClusterBuilderBase*(const edm::ParameterSet&, edm::ConsumesCollector&)>
0068     PFClusterBuilderFactory;
0069 
0070 #endif