CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
21 
22  std::vector<edm::ParameterSet> creators = iConfig.getParameter<std::vector<edm::ParameterSet> >("producers");
23  for (unsigned int i=0;i<creators.size();++i) {
24  std::string name = creators.at(i).getParameter<std::string>("name");
25  creators_.emplace_back(PFRecHitFactory::get()->create(name,creators.at(i),iC));
26  }
27 
28 
29  edm::ParameterSet navSet = iConfig.getParameter<edm::ParameterSet>("navigator");
30 
32 
33 }
34 
35 
37 {
38  }
39 
40 
41 //
42 // member functions
43 //
44 
45 // ------------ method called to produce the data ------------
46 void
48 {
49  using namespace edm;
50  auto out = std::make_unique<reco::PFRecHitCollection>();
51  auto cleaned = std::make_unique<reco::PFRecHitCollection>();
52 
53  navigator_->beginEvent(iSetup);
54 
55  out->reserve(localRA1.upper());
56  cleaned->reserve(localRA2.upper());
57  for( const auto& creator : creators_ ) {
58  creator->importRecHits(out,cleaned,iEvent,iSetup);
59  }
60  if (out->capacity()>2*out->size()) out->shrink_to_fit();
61  if (cleaned->capacity()>2*cleaned->size()) cleaned->shrink_to_fit();
62  localRA1.update(out->size());
63  localRA2.update(cleaned->size());
64  std::sort(out->begin(),out->end(),sortByDetId);
65 
66  //create a refprod here
69 
70  for( auto& pfrechit : *out ) {
71  navigator_->associateNeighbours(pfrechit,out,refProd);
72  }
73 
74  iEvent.put(std::move(out),"");
75  iEvent.put(std::move(cleaned),"Cleaned");
76 
77 }
78 
79 void
81  //The following says we do not know what parameters are allowed so do no validation
82  // Please change this to state exactly what you do use, even if it is no parameters
84  desc.setUnknown();
85  descriptions.addDefault(desc);
86 }
87 
T getParameter(std::string const &) const
std::vector< std::unique_ptr< PFRecHitCreatorBase > > creators_
int i
Definition: DBlmapReader.cc:9
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
unsigned detId() const
rechit detId
Definition: PFRecHit.h:108
std::vector< PFRecHit > PFRecHitCollection
collection of PFRecHit objects
Definition: PFRecHitFwd.h:9
virtual 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:31
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
def move
Definition: eostools.py:510
RefProd< PROD > getRefBeforePut()
Definition: Event.h:134
PFRecHitProducer(const edm::ParameterSet &iConfig)
double b
Definition: hdecay.h:120
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
double a
Definition: hdecay.h:121
T get(const Candidate &c)
Definition: component.h:55
std::unique_ptr< PFRecHitNavigatorBase > navigator_