CMS 3D CMS Logo

PFRecHitProducer.cc
Go to the documentation of this file.
9 
10 #include <memory>
11 
12 //
13 // class declaration
14 //
15 
16 class PFRecHitProducer final : public edm::stream::EDProducer<> {
17 public:
18  explicit PFRecHitProducer(const edm::ParameterSet& iConfig);
19  ~PFRecHitProducer() override;
20 
21  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
22 
23 private:
24  void produce(edm::Event&, const edm::EventSetup&) override;
25  void beginLuminosityBlock(edm::LuminosityBlock const&, const edm::EventSetup&) override;
26  void endLuminosityBlock(edm::LuminosityBlock const&, const edm::EventSetup&) override;
27  std::vector<std::unique_ptr<PFRecHitCreatorBase> > creators_;
28  std::unique_ptr<PFRecHitNavigatorBase> navigator_;
29  bool init_;
30 };
31 
34 
35 namespace {
36  bool sortByDetId(const reco::PFRecHit& a, const reco::PFRecHit& b) { return a.detId() < b.detId(); }
37 
38  edm::RunningAverage localRA1;
39  edm::RunningAverage localRA2;
40 } // namespace
41 
43  produces<reco::PFRecHitCollection>();
44  produces<reco::PFRecHitCollection>("Cleaned");
45 
46  edm::ConsumesCollector cc = consumesCollector();
47 
48  std::vector<edm::ParameterSet> creators = iConfig.getParameter<std::vector<edm::ParameterSet> >("producers");
49  for (auto& creator : creators) {
50  std::string name = creator.getParameter<std::string>("name");
51  creators_.emplace_back(PFRecHitFactory::get()->create(name, creator, cc));
52  }
53 
54  edm::ParameterSet navSet = iConfig.getParameter<edm::ParameterSet>("navigator");
55  navigator_ = PFRecHitNavigationFactory::get()->create(navSet.getParameter<std::string>("name"), navSet, cc);
56 }
57 
59 
60 //
61 // member functions
62 //
63 
65  for (const auto& creator : creators_) {
66  creator->init(iSetup);
67  }
68  navigator_->init(iSetup);
69 }
70 
72 
73 // ------------ method called to produce the data ------------
75  using namespace edm;
76  auto out = std::make_unique<reco::PFRecHitCollection>();
77  auto cleaned = std::make_unique<reco::PFRecHitCollection>();
78 
79  out->reserve(localRA1.upper());
80  cleaned->reserve(localRA2.upper());
81 
82  for (const auto& creator : creators_) {
83  creator->importRecHits(out, cleaned, iEvent, iSetup);
84  }
85 
86  if (out->capacity() > 2 * out->size())
87  out->shrink_to_fit();
88  if (cleaned->capacity() > 2 * cleaned->size())
89  cleaned->shrink_to_fit();
90  localRA1.update(out->size());
91  localRA2.update(cleaned->size());
92  std::sort(out->begin(), out->end(), sortByDetId);
93 
94  //create a refprod here
96 
97  for (auto& pfrechit : *out) {
98  navigator_->associateNeighbours(pfrechit, out, refProd);
99  }
100 
101  iEvent.put(std::move(out), "");
102  iEvent.put(std::move(cleaned), "Cleaned");
103 }
104 
106  //The following says we do not know what parameters are allowed so do no validation
107  // Please change this to state exactly what you do use, even if it is no parameters
109  desc.setUnknown();
110  descriptions.addDefault(desc);
111 }
std::vector< std::unique_ptr< PFRecHitCreatorBase > > creators_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
~PFRecHitProducer() override
def create(alignables, pedeDump, additionalData, outputFile, config)
std::vector< PFRecHit > PFRecHitCollection
collection of PFRecHit objects
Definition: PFRecHitFwd.h:9
void produce(edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:224
void addDefault(ParameterSetDescription const &psetDescription)
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
void endLuminosityBlock(edm::LuminosityBlock const &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PFRecHitProducer(const edm::ParameterSet &iConfig)
void beginLuminosityBlock(edm::LuminosityBlock const &, const edm::EventSetup &) override
double b
Definition: hdecay.h:118
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HLT enums.
double a
Definition: hdecay.h:119
#define get
def move(src, dest)
Definition: eostools.py:511
std::unique_ptr< PFRecHitNavigatorBase > navigator_