Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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