CMS 3D CMS Logo

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