CMS 3D CMS Logo

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

#include <DataMixingPileupCopy.h>

Public Member Functions

void addPileupInfo (const edm::EventPrincipal *, unsigned int EventId, ModuleCallingContext const *mcc)
 
 DataMixingPileupCopy ()
 
 DataMixingPileupCopy (const edm::ParameterSet &ps, edm::ConsumesCollector &&iC)
 
void getPileupInfo (std::vector< PileupSummaryInfo > &ps, int &bs)
 
void putPileupInfo (edm::Event &e)
 
virtual ~DataMixingPileupCopy ()
 

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_
 
std::string label_
 
edm::InputTag PileupInfoInputTag_
 
std::vector< PileupSummaryInfoPileupSummaryStorage_
 

Detailed Description

Definition at line 40 of file DataMixingPileupCopy.h.

Constructor & Destructor Documentation

DataMixingPileupCopy::DataMixingPileupCopy ( )

Definition at line 29 of file DataMixingPileupCopy.cc.

29 { }
DataMixingPileupCopy::DataMixingPileupCopy ( const edm::ParameterSet ps,
edm::ConsumesCollector &&  iC 
)
explicit

standard constructor

Definition at line 32 of file DataMixingPileupCopy.cc.

References BunchSpacingInputTag_, CFPlaybackInputTag_, GenPUProtonsInputTags_, edm::ParameterSet::getParameter(), and PileupInfoInputTag_.

32  :
33  label_(ps.getParameter<std::string>("Label"))
34 
35  {
36 
37  // Pileup/Playback information
38 
39  PileupInfoInputTag_ = ps.getParameter<edm::InputTag>("PileupInfoInputTag");
40  BunchSpacingInputTag_ = ps.getParameter<edm::InputTag>("BunchSpacingInputTag");
41  CFPlaybackInputTag_ = ps.getParameter<edm::InputTag>("CFPlaybackInputTag");
42 
43  GenPUProtonsInputTags_ = ps.getParameter<std::vector<edm::InputTag> >("GenPUProtonsInputTags");
44 
45  // apparently, we don't need consumes from Secondary input stream
46  //iC.consumes<std::vector<PileupSummaryInfo>>(PileupInfoInputTag_);
47  //iC.consumes<int>(BunchSpacingInputTag_);
48  //iC.consumes<CrossingFramePlaybackInfoNew>(CFPlaybackInputTag_);
49  }
T getParameter(std::string const &) const
std::vector< edm::InputTag > GenPUProtonsInputTags_
DataMixingPileupCopy::~DataMixingPileupCopy ( )
virtual

Default destructor

Definition at line 52 of file DataMixingPileupCopy.cc.

52  {
53  }

Member Function Documentation

void DataMixingPileupCopy::addPileupInfo ( const edm::EventPrincipal ep,
unsigned int  EventId,
ModuleCallingContext const *  mcc 
)

Definition at line 56 of file DataMixingPileupCopy.cc.

References bsStorage_, BunchSpacingInputTag_, CFPlaybackInputTag_, CrossingFramePlaybackStorage_, FoundPlayback_, GenPUProtons_, GenPUProtons_labels_, GenPUProtonsInputTags_, edm::EventPrincipal::id(), LogDebug, PileupInfoInputTag_, and PileupSummaryStorage_.

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

57  {
58 
59  LogDebug("DataMixingPileupCopy") <<"\n===============> adding pileup Info from event "<<ep->id();
60 
61  // find PileupSummaryInfo, CFPlayback information, if it's there
62 
63  // Pileup info first
64 
65  std::shared_ptr<Wrapper< std::vector<PileupSummaryInfo> > const> PileupInfoPTR =
66  getProductByTag<std::vector<PileupSummaryInfo>>(*ep,PileupInfoInputTag_, mcc);
67 
68  std::shared_ptr<Wrapper< int > const> bsPTR =
69  getProductByTag<int>(*ep,BunchSpacingInputTag_, mcc);
70 
71  if(PileupInfoPTR ) {
72  PileupSummaryStorage_ = *(PileupInfoPTR->product()) ;
73  LogDebug("DataMixingEMWorker") << "PileupInfo Size: " << PileupSummaryStorage_.size();
74  }
75 
76  if(bsPTR ) {
77  bsStorage_ = *(bsPTR->product()) ;
78  }
79  else {
80  bsStorage_=10000;
81  }
82 
83  // Gen. PU protons
84  std::shared_ptr<edm::Wrapper<std::vector<reco::GenParticle> > const> GenPUProtonsPTR;
85  for(std::vector<edm::InputTag>::const_iterator it_InputTag = GenPUProtonsInputTags_.begin();
86  it_InputTag != GenPUProtonsInputTags_.end(); ++it_InputTag){
87  GenPUProtonsPTR = getProductByTag<std::vector<reco::GenParticle> >( *ep, *it_InputTag , mcc);
88  if( GenPUProtonsPTR != nullptr ){
89  GenPUProtons_.push_back( *( GenPUProtonsPTR->product() ) );
90  GenPUProtons_labels_.push_back( it_InputTag->label() );
91  } else edm::LogWarning("DataMixingPileupCopy") << "Missing product with label: " << ( *it_InputTag ).label();
92  }
93 
94  // Playback
95  std::shared_ptr<Wrapper<CrossingFramePlaybackInfoNew> const> PlaybackPTR =
96  getProductByTag<CrossingFramePlaybackInfoNew>(*ep,CFPlaybackInputTag_, mcc);
97  FoundPlayback_ = false;
98  if(PlaybackPTR ) {
99  CrossingFramePlaybackStorage_ = *(PlaybackPTR->product()) ;
100  FoundPlayback_ = true;
101  }
102  }
#define LogDebug(id)
std::vector< std::vector< reco::GenParticle > > GenPUProtons_
CrossingFramePlaybackInfoNew CrossingFramePlaybackStorage_
EventID const & id() const
std::vector< PileupSummaryInfo > PileupSummaryStorage_
std::vector< std::string > GenPUProtons_labels_
std::vector< edm::InputTag > GenPUProtonsInputTags_
void edm::DataMixingPileupCopy::getPileupInfo ( std::vector< PileupSummaryInfo > &  ps,
int &  bs 
)
inline

Definition at line 56 of file DataMixingPileupCopy.h.

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

std::vector< PileupSummaryInfo > PileupSummaryStorage_
void DataMixingPileupCopy::putPileupInfo ( edm::Event e)

Definition at line 104 of file DataMixingPileupCopy.cc.

References bsStorage_, CrossingFramePlaybackStorage_, FoundPlayback_, GenPUProtons_, GenPUProtons_labels_, training_settings::idx, eostools::move(), PileupSummaryStorage_, and edm::Event::put().

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

104  {
105  std::unique_ptr<std::vector<PileupSummaryInfo> > PSIVector(new std::vector<PileupSummaryInfo>);
106  std::unique_ptr<int> bsInt(new int);
107 
108  std::vector<PileupSummaryInfo>::const_iterator PSiter;
109  for(PSiter = PileupSummaryStorage_.begin(); PSiter != PileupSummaryStorage_.end(); PSiter++){
110  PSIVector->push_back(*PSiter);
111  }
112 
113  *bsInt=bsStorage_;
114 
115  if(FoundPlayback_ ) {
116  std::unique_ptr<CrossingFramePlaybackInfoNew> CFPlaybackInfo(new CrossingFramePlaybackInfoNew(CrossingFramePlaybackStorage_));
117  e.put(std::move(CFPlaybackInfo));
118  }
119  e.put(std::move(PSIVector));
120  e.put(std::move(bsInt),"bunchSpacing");
121 
122  // Gen. PU protons
123  for(size_t idx = 0; idx < GenPUProtons_.size(); ++idx){
124  std::unique_ptr<std::vector<reco::GenParticle> > GenPUProtons_ptr( new std::vector<reco::GenParticle>() );
125  std::vector<reco::GenParticle>::const_iterator it_GenParticle = GenPUProtons_.at(idx).begin();
126  std::vector<reco::GenParticle>::const_iterator it_GenParticle_end = GenPUProtons_.at(idx).end();
127  for(; it_GenParticle != it_GenParticle_end; ++ it_GenParticle) GenPUProtons_ptr->push_back( *it_GenParticle );
128 
129  e.put( std::move(GenPUProtons_ptr), GenPUProtons_labels_.at(idx) );
130  }
131 
132  // clear local storage after this event
133  PileupSummaryStorage_.clear();
134  GenPUProtons_.clear();
135  GenPUProtons_labels_.clear();
136  }
std::vector< std::vector< reco::GenParticle > > GenPUProtons_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
CrossingFramePlaybackInfoNew CrossingFramePlaybackStorage_
std::vector< PileupSummaryInfo > PileupSummaryStorage_
std::vector< std::string > GenPUProtons_labels_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

int edm::DataMixingPileupCopy::bsStorage_
private

Definition at line 72 of file DataMixingPileupCopy.h.

Referenced by addPileupInfo(), and putPileupInfo().

edm::InputTag edm::DataMixingPileupCopy::BunchSpacingInputTag_
private

Definition at line 64 of file DataMixingPileupCopy.h.

Referenced by addPileupInfo(), and DataMixingPileupCopy().

edm::InputTag edm::DataMixingPileupCopy::CFPlaybackInputTag_
private

Definition at line 65 of file DataMixingPileupCopy.h.

Referenced by addPileupInfo(), and DataMixingPileupCopy().

CrossingFramePlaybackInfoNew edm::DataMixingPileupCopy::CrossingFramePlaybackStorage_
private

Definition at line 69 of file DataMixingPileupCopy.h.

Referenced by addPileupInfo(), and putPileupInfo().

bool edm::DataMixingPileupCopy::FoundPlayback_
private

Definition at line 81 of file DataMixingPileupCopy.h.

Referenced by addPileupInfo(), and putPileupInfo().

std::vector<std::vector<reco::GenParticle> > edm::DataMixingPileupCopy::GenPUProtons_
private

Definition at line 75 of file DataMixingPileupCopy.h.

Referenced by addPileupInfo(), and putPileupInfo().

std::vector<std::string> edm::DataMixingPileupCopy::GenPUProtons_labels_
private

Definition at line 74 of file DataMixingPileupCopy.h.

Referenced by addPileupInfo(), and putPileupInfo().

std::vector<edm::InputTag> edm::DataMixingPileupCopy::GenPUProtonsInputTags_
private

Definition at line 67 of file DataMixingPileupCopy.h.

Referenced by addPileupInfo(), and DataMixingPileupCopy().

std::string edm::DataMixingPileupCopy::label_
private
edm::InputTag edm::DataMixingPileupCopy::PileupInfoInputTag_
private

Definition at line 63 of file DataMixingPileupCopy.h.

Referenced by addPileupInfo(), and DataMixingPileupCopy().

std::vector<PileupSummaryInfo> edm::DataMixingPileupCopy::PileupSummaryStorage_
private

Definition at line 71 of file DataMixingPileupCopy.h.

Referenced by addPileupInfo(), and putPileupInfo().