CMS 3D CMS Logo

PFRecHitProducer.cc
Go to the documentation of this file.
3 
4 namespace {
5  bool sortByDetId(const reco::PFRecHit& a,
6  const reco::PFRecHit& b) {
7  return a.detId() < b.detId();
8  }
9 
10  edm::RunningAverage localRA1;
11  edm::RunningAverage localRA2;
12 }
13 
15 {
16 
17  produces<reco::PFRecHitCollection>();
18  produces<reco::PFRecHitCollection>("Cleaned");
19 
20  edm::ConsumesCollector iC = consumesCollector();
21 
22  std::vector<edm::ParameterSet> creators = iConfig.getParameter<std::vector<edm::ParameterSet> >("producers");
23  for (auto & creator : creators) {
24  std::string name = creator.getParameter<std::string>("name");
25  creators_.emplace_back(PFRecHitFactory::get()->create(name,creator,iC));
26  }
27 
28 
29  edm::ParameterSet navSet = iConfig.getParameter<edm::ParameterSet>("navigator");
30 
32 
33 }
34 
35 
37 
38 
39 //
40 // member functions
41 //
42 
43 void
45  for( const auto& creator : creators_ ) {
46  creator->init(iSetup);
47  }
48 }
49 
50 void
52 
53 // ------------ method called to produce the data ------------
54 void
56 {
57  using namespace edm;
58  auto out = std::make_unique<reco::PFRecHitCollection>();
59  auto cleaned = std::make_unique<reco::PFRecHitCollection>();
60 
61  navigator_->beginEvent(iSetup);
62 
63  out->reserve(localRA1.upper());
64  cleaned->reserve(localRA2.upper());
65 
66  for( const auto& creator : creators_ ) {
67  creator->importRecHits(out,cleaned,iEvent,iSetup);
68  }
69 
70  if (out->capacity()>2*out->size()) out->shrink_to_fit();
71  if (cleaned->capacity()>2*cleaned->size()) cleaned->shrink_to_fit();
72  localRA1.update(out->size());
73  localRA2.update(cleaned->size());
74  std::sort(out->begin(),out->end(),sortByDetId);
75 
76  //create a refprod here
79 
80  for( auto& pfrechit : *out ) {
81  navigator_->associateNeighbours(pfrechit,out,refProd);
82  }
83 
84  iEvent.put(std::move(out),"");
85  iEvent.put(std::move(cleaned),"Cleaned");
86 
87 }
88 
89 void
91  //The following says we do not know what parameters are allowed so do no validation
92  // Please change this to state exactly what you do use, even if it is no parameters
94  desc.setUnknown();
95  descriptions.addDefault(desc);
96 }
97 
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:137
def create(alignables, pedeDump, additionalData, outputFile, config)
unsigned detId() const
rechit detId
Definition: PFRecHit.h:108
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:230
void addDefault(ParameterSetDescription const &psetDescription)
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:32
void endLuminosityBlock(edm::LuminosityBlock const &, const edm::EventSetup &) override
RefProd< PROD > getRefBeforePut()
Definition: Event.h:167
PFRecHitProducer(const edm::ParameterSet &iConfig)
void beginLuminosityBlock(edm::LuminosityBlock const &, const edm::EventSetup &) override
double b
Definition: hdecay.h:120
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HLT enums.
double a
Definition: hdecay.h:121
def move(src, dest)
Definition: eostools.py:510
T get(const Candidate &c)
Definition: component.h:55
std::unique_ptr< PFRecHitNavigatorBase > navigator_