CMS 3D CMS Logo

PreMixingPileupCopy.cc
Go to the documentation of this file.
1 #include "PreMixingPileupCopy.h"
2 
7 
9 
10 
11 #include <memory>
12 
13 namespace edm {
15  pileupInfoInputTag_(ps.getParameter<edm::InputTag>("PileupInfoInputTag")),
16  bunchSpacingInputTag_(ps.getParameter<edm::InputTag>("BunchSpacingInputTag")),
17  cfPlaybackInputTag_(ps.getParameter<edm::InputTag>("CFPlaybackInputTag")),
18  genPUProtonsInputTags_(ps.getParameter<std::vector<edm::InputTag> >("GenPUProtonsInputTags"))
19  {
20  producer.produces<std::vector<PileupSummaryInfo> >();
21  producer.produces<int>("bunchSpacing");
23 
24  for(const auto& tag: genPUProtonsInputTags_) {
25  producer.produces<std::vector<reco::GenParticle> >(tag.label());
26  }
27  }
28 
30 
31  LogDebug("PreMixingPileupCopy") <<"\n===============> adding pileup Info from event "<<pep.principal().id();
32 
33  // find PileupSummaryInfo, CFPlayback information, if it's there
34 
35  // Pileup info first
37  pep.getByLabel(pileupInfoInputTag_, pileupInfoHandle);
38 
39  edm::Handle<int> bsHandle;
40  pep.getByLabel(bunchSpacingInputTag_, bsHandle);
41 
42  if(pileupInfoHandle.isValid()) {
43  pileupSummaryStorage_ = *pileupInfoHandle;
44  LogDebug("PreMixingPileupCopy") << "PileupInfo Size: " << pileupSummaryStorage_.size();
45  }
46  bsStorage_ = bsHandle.isValid() ? *bsHandle : 10000;
47 
48  // Gen. PU protons
50  for(const auto& tag: genPUProtonsInputTags_) {
51  pep.getByLabel(tag, genPUProtonsHandle);
52  if(genPUProtonsHandle.isValid()) {
53  genPUProtons_.push_back(*genPUProtonsHandle);
54  genPUProtons_labels_.push_back(tag.label());
55  }
56  else {
57  edm::LogWarning("PreMixingPileupCopy") << "Missing product with label: " << tag.label();
58  }
59  }
60 
61  // Playback
63  pep.getByLabel(cfPlaybackInputTag_, playbackHandle);
64  foundPlayback_ = false;
65  if(playbackHandle.isValid()) {
66  crossingFramePlaybackStorage_ = *playbackHandle;
67  foundPlayback_ = true;
68  }
69  }
70 
72  if(foundPlayback_ ) {
73  e.put(std::make_unique<CrossingFramePlaybackInfoNew>(std::move(crossingFramePlaybackStorage_)));
74  }
75  e.put(std::make_unique<std::vector<PileupSummaryInfo> >(std::move(pileupSummaryStorage_)));
76  e.put(std::make_unique<int>(bsStorage_), "bunchSpacing");
77 
78  // Gen. PU protons
79  for(size_t idx = 0; idx < genPUProtons_.size(); ++idx){
80  e.put(std::make_unique<std::vector<reco::GenParticle> >(std::move(genPUProtons_[idx])),
82  }
83 
84  // clear local storage after this event
85  pileupSummaryStorage_.clear();
86  genPUProtons_.clear();
87  genPUProtons_labels_.clear();
88  }
89 } //edm
#define LogDebug(id)
BranchAliasSetterT< ProductType > produces()
declare what type of product will make and with which optional label
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
PreMixingPileupCopy(const edm::ParameterSet &ps, edm::ProducerBase &producer, edm::ConsumesCollector &&iC)
std::vector< std::vector< reco::GenParticle > > genPUProtons_
EventID const & id() const
void putPileupInfo(edm::Event &e)
CrossingFramePlaybackInfoNew crossingFramePlaybackStorage_
std::vector< std::string > genPUProtons_labels_
void addPileupInfo(PileUpEventPrincipal const &pep)
edm::EventPrincipal const & principal()
std::vector< PileupSummaryInfo > pileupSummaryStorage_
std::vector< edm::InputTag > genPUProtonsInputTags_
bool isValid() const
Definition: HandleBase.h:74
HLT enums.
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const
def move(src, dest)
Definition: eostools.py:510