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 beginRun(edm::Run const&, const edm::EventSetup&) override;
26  std::vector<std::unique_ptr<PFRecHitCreatorBase> > creators_;
27  std::unique_ptr<PFRecHitNavigatorBase> navigator_;
28  bool init_;
29 };
30 
33 
34 namespace {
35  bool sortByDetId(const reco::PFRecHit& a, const reco::PFRecHit& b) { return a.detId() < b.detId(); }
36 
37  edm::RunningAverage localRA1;
38  edm::RunningAverage localRA2;
39 } // namespace
40 
42  produces<reco::PFRecHitCollection>();
43  produces<reco::PFRecHitCollection>("Cleaned");
44 
45  edm::ConsumesCollector cc = consumesCollector();
46 
47  std::vector<edm::ParameterSet> creators = iConfig.getParameter<std::vector<edm::ParameterSet> >("producers");
48  for (auto& creator : creators) {
49  std::string name = creator.getParameter<std::string>("name");
50  creators_.emplace_back(PFRecHitFactory::get()->create(name, creator, cc));
51  }
52 
53  edm::ParameterSet navSet = iConfig.getParameter<edm::ParameterSet>("navigator");
54  navigator_ = PFRecHitNavigationFactory::get()->create(navSet.getParameter<std::string>("name"), navSet, cc);
55 }
56 
58 
59 //
60 // member functions
61 //
62 
63 void PFRecHitProducer::beginRun(edm::Run const& iRun, const edm::EventSetup& iSetup) {
64  for (const auto& creator : creators_) {
65  creator->init(iSetup);
66  }
67  navigator_->init(iSetup);
68 }
69 
70 // ------------ method called to produce the data ------------
72  using namespace edm;
73  auto out = std::make_unique<reco::PFRecHitCollection>();
74  auto cleaned = std::make_unique<reco::PFRecHitCollection>();
75 
76  out->reserve(localRA1.upper());
77  cleaned->reserve(localRA2.upper());
78 
79  for (const auto& creator : creators_) {
80  creator->importRecHits(out, cleaned, iEvent, iSetup);
81  }
82 
83  if (out->capacity() > 2 * out->size())
84  out->shrink_to_fit();
85  if (cleaned->capacity() > 2 * cleaned->size())
86  cleaned->shrink_to_fit();
87  localRA1.update(out->size());
88  localRA2.update(cleaned->size());
89  std::sort(out->begin(), out->end(), sortByDetId);
90 
91  //create a refprod here
93 
94  for (auto& pfrechit : *out) {
95  navigator_->associateNeighbours(pfrechit, out, refProd);
96  }
97 
98  iEvent.put(std::move(out), "");
99  iEvent.put(std::move(cleaned), "Cleaned");
100 }
101 
103  //The following says we do not know what parameters are allowed so do no validation
104  // Please change this to state exactly what you do use, even if it is no parameters
106  desc.setUnknown();
107  descriptions.addDefault(desc);
108 }
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)
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
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
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PFRecHitProducer(const edm::ParameterSet &iConfig)
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_
Definition: Run.h:45
void beginRun(edm::Run const &, const edm::EventSetup &) override