Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-06-22 02:24:03

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