CMS 3D CMS Logo

PFClusterProducer.cc
Go to the documentation of this file.
9 
10 #include <memory>
11 
17 
18 public:
20  ~PFClusterProducer() override = default;
21 
22  void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup&) override;
23  void produce(edm::Event&, const edm::EventSetup&) override;
24 
25 private:
26  // inputs
28  // options
29  const bool _prodInitClusters;
30  // the actual algorithm
31  std::vector<std::unique_ptr<RecHitTopologicalCleanerBase> > _cleaners;
32  std::vector<std::unique_ptr<RecHitTopologicalCleanerBase> > _seedcleaners;
33  std::unique_ptr<SeedFinderBase> _seedFinder;
34  std::unique_ptr<InitialClusteringStepBase> _initialClustering;
35  std::unique_ptr<PFClusterBuilderBase> _pfClusterBuilder;
36  std::unique_ptr<PFCPositionCalculatorBase> _positionReCalc;
37  std::unique_ptr<PFClusterEnergyCorrectorBase> _energyCorrector;
38 };
39 
42 
43 #ifdef PFLOW_DEBUG
44 #define LOGVERB(x) edm::LogVerbatim(x)
45 #define LOGWARN(x) edm::LogWarning(x)
46 #define LOGERR(x) edm::LogError(x)
47 #define LOGDRESSED(x) edm::LogInfo(x)
48 #else
49 #define LOGVERB(x) LogTrace(x)
50 #define LOGWARN(x) edm::LogWarning(x)
51 #define LOGERR(x) edm::LogError(x)
52 #define LOGDRESSED(x) LogDebug(x)
53 #endif
54 
56  : _prodInitClusters(conf.getUntrackedParameter<bool>("prodInitialClusters", false)) {
57  _rechitsLabel = consumes<reco::PFRecHitCollection>(conf.getParameter<edm::InputTag>("recHitsSource"));
58  edm::ConsumesCollector cc = consumesCollector();
59 
60  //setup rechit cleaners
61  const edm::VParameterSet& cleanerConfs = conf.getParameterSetVector("recHitCleaners");
62  for (const auto& conf : cleanerConfs) {
63  const std::string& cleanerName = conf.getParameter<std::string>("algoName");
64  _cleaners.emplace_back(RecHitTopologicalCleanerFactory::get()->create(cleanerName, conf, cc));
65  }
66 
67  if (conf.exists("seedCleaners")) {
68  const edm::VParameterSet& seedcleanerConfs = conf.getParameterSetVector("seedCleaners");
69 
70  for (const auto& conf : seedcleanerConfs) {
71  const std::string& seedcleanerName = conf.getParameter<std::string>("algoName");
72  _seedcleaners.emplace_back(RecHitTopologicalCleanerFactory::get()->create(seedcleanerName, conf, cc));
73  }
74  }
75 
76  // setup seed finding
77  const edm::ParameterSet& sfConf = conf.getParameterSet("seedFinder");
78  const std::string& sfName = sfConf.getParameter<std::string>("algoName");
79  _seedFinder = SeedFinderFactory::get()->create(sfName, sfConf);
80  //setup topo cluster builder
81  const edm::ParameterSet& initConf = conf.getParameterSet("initialClusteringStep");
82  const std::string& initName = initConf.getParameter<std::string>("algoName");
83  _initialClustering = InitialClusteringStepFactory::get()->create(initName, initConf, cc);
84  //setup pf cluster builder if requested
85  const edm::ParameterSet& pfcConf = conf.getParameterSet("pfClusterBuilder");
86  if (!pfcConf.empty()) {
87  const std::string& pfcName = pfcConf.getParameter<std::string>("algoName");
88  _pfClusterBuilder = PFClusterBuilderFactory::get()->create(pfcName, pfcConf, cc);
89  }
90  //setup (possible) recalcuation of positions
91  const edm::ParameterSet& pConf = conf.getParameterSet("positionReCalc");
92  if (!pConf.empty()) {
93  const std::string& pName = pConf.getParameter<std::string>("algoName");
94  _positionReCalc = PFCPositionCalculatorFactory::get()->create(pName, pConf, cc);
95  }
96  // see if new need to apply corrections, setup if there.
97  const edm::ParameterSet& cConf = conf.getParameterSet("energyCorrector");
98  if (!cConf.empty()) {
99  const std::string& cName = cConf.getParameter<std::string>("algoName");
100  _energyCorrector = PFClusterEnergyCorrectorFactory::get()->create(cName, cConf);
101  }
102 
103  if (_prodInitClusters) {
104  produces<reco::PFClusterCollection>("initialClusters");
105  }
106  produces<reco::PFClusterCollection>();
107 }
108 
110  _initialClustering->update(es);
111  if (_pfClusterBuilder)
112  _pfClusterBuilder->update(es);
113  if (_positionReCalc)
114  _positionReCalc->update(es);
115  for (const auto& cleaner : _cleaners)
116  cleaner->update(es);
117  for (const auto& cleaner : _seedcleaners)
118  cleaner->update(es);
119 }
120 
122  _initialClustering->reset();
123  if (_pfClusterBuilder)
124  _pfClusterBuilder->reset();
125 
127  e.getByToken(_rechitsLabel, rechits);
128 
129  _initialClustering->updateEvent(e);
130 
131  std::vector<bool> mask(rechits->size(), true);
132  for (const auto& cleaner : _cleaners) {
133  cleaner->clean(rechits, mask);
134  }
135 
136  // no seeding on these hits
137  std::vector<bool> seedmask = mask;
138  for (const auto& cleaner : _seedcleaners) {
139  cleaner->clean(rechits, seedmask);
140  }
141 
142  std::vector<bool> seedable(rechits->size(), false);
143  _seedFinder->findSeeds(rechits, seedmask, seedable);
144 
145  auto initialClusters = std::make_unique<reco::PFClusterCollection>();
146  _initialClustering->buildClusters(rechits, mask, seedable, *initialClusters);
147  LOGVERB("PFClusterProducer::produce()") << *_initialClustering;
148 
149  auto pfClusters = std::make_unique<reco::PFClusterCollection>();
150  pfClusters = std::make_unique<reco::PFClusterCollection>();
151  if (_pfClusterBuilder) { // if we've defined a re-clustering step execute it
152  _pfClusterBuilder->buildClusters(*initialClusters, seedable, *pfClusters);
153  LOGVERB("PFClusterProducer::produce()") << *_pfClusterBuilder;
154  } else {
155  pfClusters->insert(pfClusters->end(), initialClusters->begin(), initialClusters->end());
156  }
157 
158  if (_positionReCalc) {
159  _positionReCalc->calculateAndSetPositions(*pfClusters);
160  }
161 
162  if (_energyCorrector) {
163  _energyCorrector->correctEnergies(*pfClusters);
164  }
165 
166  if (_prodInitClusters)
167  e.put(std::move(initialClusters), "initialClusters");
168  e.put(std::move(pfClusters));
169 }
electrons_cff.bool
bool
Definition: electrons_cff.py:366
InitialClusteringStepBase.h
funct::false
false
Definition: Factorize.h:29
SeedFinderBase.h
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::EDGetTokenT< reco::PFRecHitCollection >
PFClusterProducer::RHCB
RecHitTopologicalCleanerBase RHCB
Definition: PFClusterProducer.cc:13
PFClusterProducer::_seedFinder
std::unique_ptr< SeedFinderBase > _seedFinder
Definition: PFClusterProducer.cc:33
edm::VParameterSet
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:34
EDProducer.h
PFClusterProducer::_pfClusterBuilder
std::unique_ptr< PFClusterBuilderBase > _pfClusterBuilder
Definition: PFClusterProducer.cc:35
PFClusterProducer::_positionReCalc
std::unique_ptr< PFCPositionCalculatorBase > _positionReCalc
Definition: PFClusterProducer.cc:36
beamerCreator.create
def create(alignables, pedeDump, additionalData, outputFile, config)
Definition: beamerCreator.py:44
edm::Handle< reco::PFRecHitCollection >
PFClusterProducer::_prodInitClusters
const bool _prodInitClusters
Definition: PFClusterProducer.cc:29
MakerMacros.h
PFClusterEnergyCorrectorBase.h
PFClusterProducer::_seedcleaners
std::vector< std::unique_ptr< RecHitTopologicalCleanerBase > > _seedcleaners
Definition: PFClusterProducer.cc:32
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PFClusterProducer::~PFClusterProducer
~PFClusterProducer() override=default
PFClusterBuilderBase.h
PFClusterProducer::PosCalc
PFCPositionCalculatorBase PosCalc
Definition: PFClusterProducer.cc:16
PFClusterProducer::beginLuminosityBlock
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) override
Definition: PFClusterProducer.cc:109
PFClusterProducer::_initialClustering
std::unique_ptr< InitialClusteringStepBase > _initialClustering
Definition: PFClusterProducer.cc:34
HI_PhotonSkim_cff.rechits
rechits
Definition: HI_PhotonSkim_cff.py:76
PFCPositionCalculatorBase.h
PFCPositionCalculatorBase
Definition: PFCPositionCalculatorBase.h:15
PFClusterProducer::_cleaners
std::vector< std::unique_ptr< RecHitTopologicalCleanerBase > > _cleaners
Definition: PFClusterProducer.cc:31
RecHitTopologicalCleanerBase.h
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:681
edm::ParameterSet
Definition: ParameterSet.h:47
InitialClusteringStepBase
Definition: InitialClusteringStepBase.h:24
Event.h
PFClusterProducer::PFCBB
PFClusterBuilderBase PFCBB
Definition: PFClusterProducer.cc:15
PFClusterProducer::_rechitsLabel
edm::EDGetTokenT< reco::PFRecHitCollection > _rechitsLabel
Definition: PFClusterProducer.cc:27
edm::stream::EDProducer
Definition: EDProducer.h:36
edm::EventSetup
Definition: EventSetup.h:58
get
#define get
cc
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PFClusterProducer::ICSB
InitialClusteringStepBase ICSB
Definition: PFClusterProducer.cc:14
eostools.move
def move(src, dest)
Definition: eostools.py:511
PFClusterProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: PFClusterProducer.cc:121
LOGVERB
#define LOGVERB(x)
Definition: PFClusterProducer.cc:49
PFClusterProducer::PFClusterProducer
PFClusterProducer(const edm::ParameterSet &)
Definition: PFClusterProducer.cc:55
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PFClusterBuilderBase
Definition: PFClusterBuilderBase.h:19
edm::ParameterSet::getParameterSetVector
VParameterSet const & getParameterSetVector(std::string const &name) const
Definition: ParameterSet.cc:2160
RecHitTopologicalCleanerBase
Definition: RecHitTopologicalCleanerBase.h:13
edm::Event
Definition: Event.h:73
lumi
Definition: LumiSectionData.h:20
PFClusterProducer
Definition: PFClusterProducer.cc:12
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
edm::ParameterSet::empty
bool empty() const
Definition: ParameterSet.h:201
edm::ParameterSet::getParameterSet
ParameterSet const & getParameterSet(std::string const &) const
Definition: ParameterSet.cc:2128
PFClusterProducer::_energyCorrector
std::unique_ptr< PFClusterEnergyCorrectorBase > _energyCorrector
Definition: PFClusterProducer.cc:37
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37