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.

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  }

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

◆ ~PreMixingPileupCopy()

edm::PreMixingPileupCopy::~PreMixingPileupCopy ( )
default

Member Function Documentation

◆ addPileupInfo()

void PreMixingPileupCopy::addPileupInfo ( PileUpEventPrincipal const &  pep)

Definition at line 41 of file PreMixingPileupCopy.cc.

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  }

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().

◆ getBunchSpacing()

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

Definition at line 43 of file PreMixingPileupCopy.h.

43 { return bsStorage_; }

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.

42 { return pileupSummaryStorage_; }

References pileupSummaryStorage_.

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

◆ getTrueNumInteractions()

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

Definition at line 28 of file PreMixingPileupCopy.cc.

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  }

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

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

◆ putPileupInfo()

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

Definition at line 81 of file PreMixingPileupCopy.cc.

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  }

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

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

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().

edm::PreMixingPileupCopy::pileupSummaryStorage_
std::vector< PileupSummaryInfo > pileupSummaryStorage_
Definition: PreMixingPileupCopy.h:55
edm::PreMixingPileupCopy::genPUProtonsInputTags_
std::vector< edm::InputTag > genPUProtonsInputTags_
Definition: PreMixingPileupCopy.h:51
edm::PreMixingPileupCopy::bsStorage_
int bsStorage_
Definition: PreMixingPileupCopy.h:56
edm::PreMixingPileupCopy::cfPlaybackInputTag_
edm::InputTag cfPlaybackInputTag_
Definition: PreMixingPileupCopy.h:49
edm::Handle
Definition: AssociativeIterator.h:50
training_settings.idx
idx
Definition: training_settings.py:16
CrossingFramePlaybackInfoNew
Definition: CrossingFramePlaybackInfoNew.h:23
edm::PreMixingPileupCopy::bunchSpacingInputTag_
edm::InputTag bunchSpacingInputTag_
Definition: PreMixingPileupCopy.h:48
alignCSCRings.s
s
Definition: alignCSCRings.py:92
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
edm::PreMixingPileupCopy::genPUProtons_labels_
std::vector< std::string > genPUProtons_labels_
Definition: PreMixingPileupCopy.h:58
edm::PreMixingPileupCopy::crossingFramePlaybackStorage_
CrossingFramePlaybackInfoNew crossingFramePlaybackStorage_
Definition: PreMixingPileupCopy.h:54
edm::LogWarning
Definition: MessageLogger.h:141
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ProducesCollector::produces
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
Definition: ProducesCollector.h:52
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::PreMixingPileupCopy::foundPlayback_
bool foundPlayback_
Definition: PreMixingPileupCopy.h:61
Exception
Definition: hltDiff.cc:246
edm::PreMixingPileupCopy::pileupInfoInputTag_
edm::InputTag pileupInfoInputTag_
Definition: PreMixingPileupCopy.h:47
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag
Definition: InputTag.h:15
edm::PreMixingPileupCopy::genPUProtons_
std::vector< std::vector< reco::GenParticle > > genPUProtons_
Definition: PreMixingPileupCopy.h:59
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37