CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
edm::PreMixingPileupCopy Class Reference

#include <PreMixingPileupCopy.h>

Public Member Functions

void addPileupInfo (PileUpEventPrincipal const &pep)
 
int getBunchSpacing () const
 
const std::vector< PileupSummaryInfo > & getPileupSummaryInfo () const
 
float getTrueNumInteractions (PileUpEventPrincipal const &pep) const
 
 PreMixingPileupCopy (const edm::ParameterSet &ps, edm::ProducerBase &producer, edm::ConsumesCollector &&iC)
 
void putPileupInfo (edm::Event &e)
 
 ~PreMixingPileupCopy ()=default
 

Private Attributes

int bsStorage_
 
edm::InputTag bunchSpacingInputTag_
 
edm::InputTag cfPlaybackInputTag_
 
CrossingFramePlaybackInfoNew crossingFramePlaybackStorage_
 
bool foundPlayback_
 
std::vector< std::vector< reco::GenParticle > > genPUProtons_
 
std::vector< std::string > genPUProtons_labels_
 
std::vector< edm::InputTaggenPUProtonsInputTags_
 
edm::InputTag pileupInfoInputTag_
 
std::vector< PileupSummaryInfopileupSummaryStorage_
 

Detailed Description

Definition at line 33 of file PreMixingPileupCopy.h.

Constructor & Destructor Documentation

PreMixingPileupCopy::PreMixingPileupCopy ( const edm::ParameterSet ps,
edm::ProducerBase producer,
edm::ConsumesCollector &&  iC 
)

Definition at line 14 of file PreMixingPileupCopy.cc.

References genPUProtonsInputTags_, edm::ProductRegistryHelper::produces(), and GlobalPosition_Frontier_DevDB_cff::tag.

14  :
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  }
BranchAliasSetterT< ProductType > produces()
declare what type of product will make and with which optional label
T getParameter(std::string const &) const
std::vector< edm::InputTag > genPUProtonsInputTags_
edm::PreMixingPileupCopy::~PreMixingPileupCopy ( )
default

Member Function Documentation

void PreMixingPileupCopy::addPileupInfo ( PileUpEventPrincipal const &  pep)

Definition at line 44 of file PreMixingPileupCopy.cc.

References bsStorage_, bunchSpacingInputTag_, cfPlaybackInputTag_, crossingFramePlaybackStorage_, foundPlayback_, genPUProtons_, genPUProtons_labels_, genPUProtonsInputTags_, PileUpEventPrincipal::getByLabel(), edm::EventPrincipal::id(), edm::HandleBase::isValid(), LogDebug, pileupInfoInputTag_, pileupSummaryStorage_, PileUpEventPrincipal::principal(), and GlobalPosition_Frontier_DevDB_cff::tag.

Referenced by edm::PreMixingModule::pileWorker().

44  {
45 
46  LogDebug("PreMixingPileupCopy") <<"\n===============> adding pileup Info from event "<<pep.principal().id();
47 
48  // find PileupSummaryInfo, CFPlayback information, if it's there
49 
50  // Pileup info first
52  pep.getByLabel(pileupInfoInputTag_, pileupInfoHandle);
53 
54  edm::Handle<int> bsHandle;
55  pep.getByLabel(bunchSpacingInputTag_, bsHandle);
56 
57  if(pileupInfoHandle.isValid()) {
58  pileupSummaryStorage_ = *pileupInfoHandle;
59  LogDebug("PreMixingPileupCopy") << "PileupInfo Size: " << pileupSummaryStorage_.size();
60  }
61  bsStorage_ = bsHandle.isValid() ? *bsHandle : 10000;
62 
63  // Gen. PU protons
65  for(const auto& tag: genPUProtonsInputTags_) {
66  pep.getByLabel(tag, genPUProtonsHandle);
67  if(genPUProtonsHandle.isValid()) {
68  genPUProtons_.push_back(*genPUProtonsHandle);
69  genPUProtons_labels_.push_back(tag.label());
70  }
71  else {
72  edm::LogWarning("PreMixingPileupCopy") << "Missing product with label: " << tag.label();
73  }
74  }
75 
76  // Playback
78  pep.getByLabel(cfPlaybackInputTag_, playbackHandle);
79  foundPlayback_ = false;
80  if(playbackHandle.isValid()) {
81  crossingFramePlaybackStorage_ = *playbackHandle;
82  foundPlayback_ = true;
83  }
84  }
#define LogDebug(id)
std::vector< std::vector< reco::GenParticle > > genPUProtons_
CrossingFramePlaybackInfoNew crossingFramePlaybackStorage_
std::vector< std::string > genPUProtons_labels_
std::vector< PileupSummaryInfo > pileupSummaryStorage_
std::vector< edm::InputTag > genPUProtonsInputTags_
bool isValid() const
Definition: HandleBase.h:74
int edm::PreMixingPileupCopy::getBunchSpacing ( ) const
inline

Definition at line 42 of file PreMixingPileupCopy.h.

References MillePedeFileConverter_cfg::e.

Referenced by edm::PreMixingModule::put().

const std::vector<PileupSummaryInfo>& edm::PreMixingPileupCopy::getPileupSummaryInfo ( ) const
inline

Definition at line 41 of file PreMixingPileupCopy.h.

Referenced by edm::PreMixingModule::put().

41 { return pileupSummaryStorage_; }
std::vector< PileupSummaryInfo > pileupSummaryStorage_
float PreMixingPileupCopy::getTrueNumInteractions ( PileUpEventPrincipal const &  pep) const

Definition at line 29 of file PreMixingPileupCopy.cc.

References Exception, PileUpEventPrincipal::getByLabel(), pileupInfoInputTag_, and alignCSCRings::s.

Referenced by edm::PreMixingModule::pileWorker().

29  {
31  pep.getByLabel(pileupInfoInputTag_, pileupInfoHandle);
32 
33  auto it = std::find_if(pileupInfoHandle->begin(), pileupInfoHandle->end(),
34  [](const auto& s) {
35  return s.getBunchCrossing() == 0;
36  });
37  if(it == pileupInfoHandle->end()) {
38  throw cms::Exception("LogicError") << "Did not find PileupSummaryInfo in bunch crossing 0";
39  }
40 
41  return it->getTrueNumInteractions();
42  }
void PreMixingPileupCopy::putPileupInfo ( edm::Event e)

Definition at line 86 of file PreMixingPileupCopy.cc.

References bsStorage_, crossingFramePlaybackStorage_, foundPlayback_, genPUProtons_, genPUProtons_labels_, training_settings::idx, eostools::move(), pileupSummaryStorage_, and edm::Event::put().

Referenced by edm::PreMixingModule::put().

86  {
87  if(foundPlayback_ ) {
88  e.put(std::make_unique<CrossingFramePlaybackInfoNew>(std::move(crossingFramePlaybackStorage_)));
89  }
90  e.put(std::make_unique<std::vector<PileupSummaryInfo> >(std::move(pileupSummaryStorage_)));
91  e.put(std::make_unique<int>(bsStorage_), "bunchSpacing");
92 
93  // Gen. PU protons
94  for(size_t idx = 0; idx < genPUProtons_.size(); ++idx){
95  e.put(std::make_unique<std::vector<reco::GenParticle> >(std::move(genPUProtons_[idx])),
97  }
98 
99  // clear local storage after this event
100  pileupSummaryStorage_.clear();
101  genPUProtons_.clear();
102  genPUProtons_labels_.clear();
103  }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
std::vector< std::vector< reco::GenParticle > > genPUProtons_
CrossingFramePlaybackInfoNew crossingFramePlaybackStorage_
std::vector< std::string > genPUProtons_labels_
std::vector< PileupSummaryInfo > pileupSummaryStorage_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

int edm::PreMixingPileupCopy::bsStorage_
private

Definition at line 55 of file PreMixingPileupCopy.h.

Referenced by addPileupInfo(), and putPileupInfo().

edm::InputTag edm::PreMixingPileupCopy::bunchSpacingInputTag_
private

Definition at line 47 of file PreMixingPileupCopy.h.

Referenced by addPileupInfo().

edm::InputTag edm::PreMixingPileupCopy::cfPlaybackInputTag_
private

Definition at line 48 of file PreMixingPileupCopy.h.

Referenced by addPileupInfo().

CrossingFramePlaybackInfoNew edm::PreMixingPileupCopy::crossingFramePlaybackStorage_
private

Definition at line 53 of file PreMixingPileupCopy.h.

Referenced by addPileupInfo(), and putPileupInfo().

bool edm::PreMixingPileupCopy::foundPlayback_
private

Definition at line 60 of file PreMixingPileupCopy.h.

Referenced by addPileupInfo(), and putPileupInfo().

std::vector<std::vector<reco::GenParticle> > edm::PreMixingPileupCopy::genPUProtons_
private

Definition at line 58 of file PreMixingPileupCopy.h.

Referenced by addPileupInfo(), and putPileupInfo().

std::vector<std::string> edm::PreMixingPileupCopy::genPUProtons_labels_
private

Definition at line 57 of file PreMixingPileupCopy.h.

Referenced by addPileupInfo(), and putPileupInfo().

std::vector<edm::InputTag> edm::PreMixingPileupCopy::genPUProtonsInputTags_
private

Definition at line 50 of file PreMixingPileupCopy.h.

Referenced by addPileupInfo(), and PreMixingPileupCopy().

edm::InputTag edm::PreMixingPileupCopy::pileupInfoInputTag_
private

Definition at line 46 of file PreMixingPileupCopy.h.

Referenced by addPileupInfo(), and getTrueNumInteractions().

std::vector<PileupSummaryInfo> edm::PreMixingPileupCopy::pileupSummaryStorage_
private

Definition at line 54 of file PreMixingPileupCopy.h.

Referenced by addPileupInfo(), and putPileupInfo().