CMS 3D CMS Logo

PFRecHitProducer.cc
Go to the documentation of this file.
3 
4 namespace {
5  bool sortByDetId(const reco::PFRecHit& a, const reco::PFRecHit& b) { return a.detId() < b.detId(); }
6 
7  edm::RunningAverage localRA1;
8  edm::RunningAverage localRA2;
9 } // namespace
10 
12  produces<reco::PFRecHitCollection>();
13  produces<reco::PFRecHitCollection>("Cleaned");
14 
15  edm::ConsumesCollector iC = consumesCollector();
16 
17  std::vector<edm::ParameterSet> creators = iConfig.getParameter<std::vector<edm::ParameterSet> >("producers");
18  for (auto& creator : creators) {
19  std::string name = creator.getParameter<std::string>("name");
20  creators_.emplace_back(PFRecHitFactory::get()->create(name, creator, iC));
21  }
22 
23  edm::ParameterSet navSet = iConfig.getParameter<edm::ParameterSet>("navigator");
24 
25  navigator_ = PFRecHitNavigationFactory::get()->create(navSet.getParameter<std::string>("name"), navSet);
26 }
27 
29 
30 //
31 // member functions
32 //
33 
35  for (const auto& creator : creators_) {
36  creator->init(iSetup);
37  }
38 }
39 
41 
42 // ------------ method called to produce the data ------------
44  using namespace edm;
45  auto out = std::make_unique<reco::PFRecHitCollection>();
46  auto cleaned = std::make_unique<reco::PFRecHitCollection>();
47 
48  navigator_->beginEvent(iSetup);
49 
50  out->reserve(localRA1.upper());
51  cleaned->reserve(localRA2.upper());
52 
53  for (const auto& creator : creators_) {
54  creator->importRecHits(out, cleaned, iEvent, iSetup);
55  }
56 
57  if (out->capacity() > 2 * out->size())
58  out->shrink_to_fit();
59  if (cleaned->capacity() > 2 * cleaned->size())
60  cleaned->shrink_to_fit();
61  localRA1.update(out->size());
62  localRA2.update(cleaned->size());
63  std::sort(out->begin(), out->end(), sortByDetId);
64 
65  //create a refprod here
67 
68  for (auto& pfrechit : *out) {
69  navigator_->associateNeighbours(pfrechit, out, refProd);
70  }
71 
72  iEvent.put(std::move(out), "");
73  iEvent.put(std::move(cleaned), "Cleaned");
74 }
75 
77  //The following says we do not know what parameters are allowed so do no validation
78  // Please change this to state exactly what you do use, even if it is no parameters
80  desc.setUnknown();
81  descriptions.addDefault(desc);
82 }
T getParameter(std::string const &) const
std::vector< std::unique_ptr< PFRecHitCreatorBase > > creators_
~PFRecHitProducer() override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
def create(alignables, pedeDump, additionalData, outputFile, config)
unsigned detId() const
rechit detId
Definition: PFRecHit.h:89
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
RefProd< PROD > getRefBeforePut()
Definition: Event.h:156
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
def move(src, dest)
Definition: eostools.py:511
std::unique_ptr< PFRecHitNavigatorBase > navigator_