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 
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 void
47  for( const auto& creator : creators_ ) {
48  creator->init(iSetup);
49  }
50 }
51 
52 void
54 
55 // ------------ method called to produce the data ------------
56 void
58 {
59  using namespace edm;
60  auto out = std::make_unique<reco::PFRecHitCollection>();
61  auto cleaned = std::make_unique<reco::PFRecHitCollection>();
62 
63  navigator_->beginEvent(iSetup);
64 
65  out->reserve(localRA1.upper());
66  cleaned->reserve(localRA2.upper());
67 
68  for( const auto& creator : creators_ ) {
69  creator->importRecHits(out,cleaned,iEvent,iSetup);
70  }
71 
72  if (out->capacity()>2*out->size()) out->shrink_to_fit();
73  if (cleaned->capacity()>2*cleaned->size()) cleaned->shrink_to_fit();
74  localRA1.update(out->size());
75  localRA2.update(cleaned->size());
76  std::sort(out->begin(),out->end(),sortByDetId);
77 
78  //create a refprod here
81 
82  for( auto& pfrechit : *out ) {
83  navigator_->associateNeighbours(pfrechit,out,refProd);
84  }
85 
86  iEvent.put(std::move(out),"");
87  iEvent.put(std::move(cleaned),"Cleaned");
88 
89 }
90 
91 void
93  //The following says we do not know what parameters are allowed so do no validation
94  // Please change this to state exactly what you do use, even if it is no parameters
96  desc.setUnknown();
97  descriptions.addDefault(desc);
98 }
99 
T getParameter(std::string const &) const
std::vector< std::unique_ptr< PFRecHitCreatorBase > > creators_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
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
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.
virtual void endLuminosityBlock(edm::LuminosityBlock const &, const edm::EventSetup &) override
RefProd< PROD > getRefBeforePut()
Definition: Event.h:134
PFRecHitProducer(const edm::ParameterSet &iConfig)
virtual 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_