CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFClusterProducer.cc
Go to the documentation of this file.
1 #include "PFClusterProducer.h"
2 
3 #ifdef PFLOW_DEBUG
4 #define LOGVERB(x) edm::LogVerbatim(x)
5 #define LOGWARN(x) edm::LogWarning(x)
6 #define LOGERR(x) edm::LogError(x)
7 #define LOGDRESSED(x) edm::LogInfo(x)
8 #else
9 #define LOGVERB(x) LogTrace(x)
10 #define LOGWARN(x) edm::LogWarning(x)
11 #define LOGERR(x) edm::LogError(x)
12 #define LOGDRESSED(x) LogDebug(x)
13 #endif
14 
16  _prodInitClusters(conf.getUntrackedParameter<bool>("prodInitialClusters",false))
17 {
18  _rechitsLabel = consumes<reco::PFRecHitCollection>(conf.getParameter<edm::InputTag>("recHitsSource"));
19  //setup rechit cleaners
20  const edm::VParameterSet& cleanerConfs =
21  conf.getParameterSetVector("recHitCleaners");
22  for( const auto& conf : cleanerConfs ) {
23  const std::string& cleanerName =
24  conf.getParameter<std::string>("algoName");
25  RHCB* cleaner =
26  RecHitTopologicalCleanerFactory::get()->create(cleanerName,conf);
27  _cleaners.push_back(std::unique_ptr<RHCB>(cleaner));
28  }
29  // setup seed finding
30  const edm::ParameterSet& sfConf =
31  conf.getParameterSet("seedFinder");
32  const std::string& sfName = sfConf.getParameter<std::string>("algoName");
33  SeedFinderBase* sfb = SeedFinderFactory::get()->create(sfName,sfConf);
34  _seedFinder.reset(sfb);
35  //setup topo cluster builder
36  const edm::ParameterSet& initConf =
37  conf.getParameterSet("initialClusteringStep");
38  const std::string& initName = initConf.getParameter<std::string>("algoName");
39  ICSB* initb = InitialClusteringStepFactory::get()->create(initName,initConf);
40  _initialClustering.reset(initb);
41  //setup pf cluster builder if requested
42  _pfClusterBuilder.reset(NULL);
43  const edm::ParameterSet& pfcConf = conf.getParameterSet("pfClusterBuilder");
44  if( !pfcConf.empty() ) {
45  const std::string& pfcName = pfcConf.getParameter<std::string>("algoName");
46  PFCBB* pfcb = PFClusterBuilderFactory::get()->create(pfcName,pfcConf);
47  _pfClusterBuilder.reset(pfcb);
48  }
49  //setup (possible) recalcuation of positions
50  _positionReCalc.reset(NULL);
51  const edm::ParameterSet& pConf = conf.getParameterSet("positionReCalc");
52  if( !pConf.empty() ) {
53  const std::string& pName = pConf.getParameter<std::string>("algoName");
54  PosCalc* pcalc = PFCPositionCalculatorFactory::get()->create(pName,pConf);
55  _positionReCalc.reset(pcalc);
56  }
57  // see if new need to apply corrections, setup if there.
58  const edm::ParameterSet& cConf = conf.getParameterSet("energyCorrector");
59  if( !cConf.empty() ) {
60  const std::string& cName = cConf.getParameter<std::string>("algoName");
62  PFClusterEnergyCorrectorFactory::get()->create(cName,cConf);
63  _energyCorrector.reset(eCorr);
64  }
65 
66 
67  if( _prodInitClusters ) {
68  produces<reco::PFClusterCollection>("initialClusters");
69  }
70  produces<reco::PFClusterCollection>();
71 }
72 
74  const edm::EventSetup& es) {
75  _initialClustering->update(es);
76  _pfClusterBuilder->update(es);
77  if( _positionReCalc ) _positionReCalc->update(es);
78 
79 }
80 
82  _initialClustering->reset();
83  _pfClusterBuilder->reset();
84 
86  e.getByToken(_rechitsLabel,rechits);
87 
88  std::vector<bool> mask(rechits->size(),true);
89  for( const auto& cleaner : _cleaners ) {
90  cleaner->clean(rechits, mask);
91  }
92 
93 
94 
95  std::vector<bool> seedable(rechits->size(),false);
96  _seedFinder->findSeeds(rechits,mask,seedable);
97 
98 
99 
100  std::auto_ptr<reco::PFClusterCollection> initialClusters;
101  initialClusters.reset(new reco::PFClusterCollection);
102  _initialClustering->buildClusters(rechits, mask, seedable, *initialClusters);
103  LOGVERB("PFClusterProducer::produce()") << *_initialClustering;
104 
105 
106 
107 
108  std::auto_ptr<reco::PFClusterCollection> pfClusters;
109  pfClusters.reset(new reco::PFClusterCollection);
110  if( _pfClusterBuilder ) { // if we've defined a re-clustering step execute it
111  _pfClusterBuilder->buildClusters(*initialClusters, seedable, *pfClusters);
112  LOGVERB("PFClusterProducer::produce()") << *_pfClusterBuilder;
113  } else {
114  pfClusters->insert(pfClusters->end(),
115  initialClusters->begin(),initialClusters->end());
116  }
117 
118 
119 
120 
121  if( _positionReCalc ) {
122  _positionReCalc->calculateAndSetPositions(*pfClusters);
123  }
124 
125  if( _energyCorrector ) {
126  _energyCorrector->correctEnergies(*pfClusters);
127  }
128 
129  if( _prodInitClusters ) e.put(initialClusters,"initialClusters");
130  e.put(pfClusters);
131 }
std::unique_ptr< SeedFinderBase > _seedFinder
T getParameter(std::string const &) const
std::unique_ptr< PFClusterEnergyCorrectorBase > _energyCorrector
bool empty() const
Definition: ParameterSet.h:216
VParameterSet const & getParameterSetVector(std::string const &name) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
tuple lumi
Definition: fjr2json.py:35
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
std::unique_ptr< PFClusterBuilderBase > _pfClusterBuilder
#define NULL
Definition: scimark2.h:8
#define LOGVERB(x)
std::unique_ptr< PFCPositionCalculatorBase > _positionReCalc
virtual void produce(edm::Event &, const edm::EventSetup &)
std::vector< std::unique_ptr< RecHitTopologicalCleanerBase > > _cleaners
virtual void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
const bool _prodInitClusters
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
edm::EDGetTokenT< reco::PFRecHitCollection > _rechitsLabel
std::unique_ptr< InitialClusteringStepBase > _initialClustering
tuple conf
Definition: dbtoconf.py:185
ParameterSet const & getParameterSet(std::string const &) const
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
Definition: PFClusterFwd.h:9
PFClusterProducer(const edm::ParameterSet &)
volatile std::atomic< bool > shutdown_flag false
static float eCorr(int ieta, int iphi, double ampl, int runnum)
Ugly hack to apply energy corrections to some HB- cells.
T get(const Candidate &c)
Definition: component.h:55