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::ProducesCollector, 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 34 of file PreMixingPileupCopy.h.

Constructor & Destructor Documentation

◆ PreMixingPileupCopy()

PreMixingPileupCopy::PreMixingPileupCopy ( const edm::ParameterSet ps,
edm::ProducesCollector  producesCollector,
edm::ConsumesCollector &&  iC 
)

Definition at line 12 of file PreMixingPileupCopy.cc.

References genPUProtonsInputTags_, edm::ProducesCollector::produces(), and makeGlobalPositionRcd_cfg::tag.

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  producesCollector.produces<std::vector<PileupSummaryInfo>>();
20  producesCollector.produces<int>("bunchSpacing");
21  producesCollector.produces<CrossingFramePlaybackInfoNew>();
22 
23  for (const auto& tag : genPUProtonsInputTags_) {
24  producesCollector.produces<std::vector<reco::GenParticle>>(tag.label());
25  }
26  }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
std::vector< edm::InputTag > genPUProtonsInputTags_

◆ ~PreMixingPileupCopy()

edm::PreMixingPileupCopy::~PreMixingPileupCopy ( )
default

Member Function Documentation

◆ addPileupInfo()

void PreMixingPileupCopy::addPileupInfo ( PileUpEventPrincipal const &  pep)

Definition at line 41 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 makeGlobalPositionRcd_cfg::tag.

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

41  {
42  LogDebug("PreMixingPileupCopy") << "\n===============> adding pileup Info from event " << pep.principal().id();
43 
44  // find PileupSummaryInfo, CFPlayback information, if it's there
45 
46  // Pileup info first
48  pep.getByLabel(pileupInfoInputTag_, pileupInfoHandle);
49 
50  edm::Handle<int> bsHandle;
51  pep.getByLabel(bunchSpacingInputTag_, bsHandle);
52 
53  if (pileupInfoHandle.isValid()) {
54  pileupSummaryStorage_ = *pileupInfoHandle;
55  LogDebug("PreMixingPileupCopy") << "PileupInfo Size: " << pileupSummaryStorage_.size();
56  }
57  bsStorage_ = bsHandle.isValid() ? *bsHandle : 10000;
58 
59  // Gen. PU protons
61  for (const auto& tag : genPUProtonsInputTags_) {
62  pep.getByLabel(tag, genPUProtonsHandle);
63  if (genPUProtonsHandle.isValid()) {
64  genPUProtons_.push_back(*genPUProtonsHandle);
65  genPUProtons_labels_.push_back(tag.label());
66  } else {
67  edm::LogWarning("PreMixingPileupCopy") << "Missing product with label: " << tag.label();
68  }
69  }
70 
71  // Playback
73  pep.getByLabel(cfPlaybackInputTag_, playbackHandle);
74  foundPlayback_ = false;
75  if (playbackHandle.isValid()) {
76  crossingFramePlaybackStorage_ = *playbackHandle;
77  foundPlayback_ = true;
78  }
79  }
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:70
Log< level::Warning, false > LogWarning
#define LogDebug(id)

◆ getBunchSpacing()

int edm::PreMixingPileupCopy::getBunchSpacing ( ) const
inline

Definition at line 43 of file PreMixingPileupCopy.h.

References bsStorage_.

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

◆ getPileupSummaryInfo()

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

Definition at line 42 of file PreMixingPileupCopy.h.

References pileupSummaryStorage_.

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

42 { return pileupSummaryStorage_; }
std::vector< PileupSummaryInfo > pileupSummaryStorage_

◆ getTrueNumInteractions()

float PreMixingPileupCopy::getTrueNumInteractions ( PileUpEventPrincipal const &  pep) const

Definition at line 28 of file PreMixingPileupCopy.cc.

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

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

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

◆ putPileupInfo()

void PreMixingPileupCopy::putPileupInfo ( edm::Event e)

Definition at line 81 of file PreMixingPileupCopy.cc.

References bsStorage_, crossingFramePlaybackStorage_, MillePedeFileConverter_cfg::e, foundPlayback_, genPUProtons_, genPUProtons_labels_, heavyIonCSV_trainingSettings::idx, eostools::move(), and pileupSummaryStorage_.

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

81  {
82  if (foundPlayback_) {
83  e.put(std::make_unique<CrossingFramePlaybackInfoNew>(std::move(crossingFramePlaybackStorage_)));
84  }
85  e.put(std::make_unique<std::vector<PileupSummaryInfo>>(std::move(pileupSummaryStorage_)));
86  e.put(std::make_unique<int>(bsStorage_), "bunchSpacing");
87 
88  // Gen. PU protons
89  for (size_t idx = 0; idx < genPUProtons_.size(); ++idx) {
90  e.put(std::make_unique<std::vector<reco::GenParticle>>(std::move(genPUProtons_[idx])), genPUProtons_labels_[idx]);
91  }
92 
93  // clear local storage after this event
94  pileupSummaryStorage_.clear();
95  genPUProtons_.clear();
96  genPUProtons_labels_.clear();
97  }
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

◆ bsStorage_

int edm::PreMixingPileupCopy::bsStorage_
private

Definition at line 56 of file PreMixingPileupCopy.h.

Referenced by addPileupInfo(), getBunchSpacing(), and putPileupInfo().

◆ bunchSpacingInputTag_

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

Definition at line 48 of file PreMixingPileupCopy.h.

Referenced by addPileupInfo().

◆ cfPlaybackInputTag_

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

Definition at line 49 of file PreMixingPileupCopy.h.

Referenced by addPileupInfo().

◆ crossingFramePlaybackStorage_

CrossingFramePlaybackInfoNew edm::PreMixingPileupCopy::crossingFramePlaybackStorage_
private

Definition at line 54 of file PreMixingPileupCopy.h.

Referenced by addPileupInfo(), and putPileupInfo().

◆ foundPlayback_

bool edm::PreMixingPileupCopy::foundPlayback_
private

Definition at line 61 of file PreMixingPileupCopy.h.

Referenced by addPileupInfo(), and putPileupInfo().

◆ genPUProtons_

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

Definition at line 59 of file PreMixingPileupCopy.h.

Referenced by addPileupInfo(), and putPileupInfo().

◆ genPUProtons_labels_

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

Definition at line 58 of file PreMixingPileupCopy.h.

Referenced by addPileupInfo(), and putPileupInfo().

◆ genPUProtonsInputTags_

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

Definition at line 51 of file PreMixingPileupCopy.h.

Referenced by addPileupInfo(), and PreMixingPileupCopy().

◆ pileupInfoInputTag_

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

Definition at line 47 of file PreMixingPileupCopy.h.

Referenced by addPileupInfo(), and getTrueNumInteractions().

◆ pileupSummaryStorage_

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

Definition at line 55 of file PreMixingPileupCopy.h.

Referenced by addPileupInfo(), getPileupSummaryInfo(), and putPileupInfo().