CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DataMixingPileupCopy.cc
Go to the documentation of this file.
1 // File: DataMixingPileupCopy.cc
2 // Description: see DataMixingPileupCopy.h
3 // Author: Mike Hildreth, University of Notre Dame
4 //
5 //--------------------------------------------
6 
7 #include <map>
8 #include <memory>
16 //
17 //
18 #include "DataMixingPileupCopy.h"
19 
20 
21 using namespace std;
22 
23 namespace edm
24 {
25 
26  // Virtual constructor
27 
28  DataMixingPileupCopy::DataMixingPileupCopy() { }
29 
30  // Constructor
31  DataMixingPileupCopy::DataMixingPileupCopy(const edm::ParameterSet& ps, edm::ConsumesCollector && iC) :
32  label_(ps.getParameter<std::string>("Label"))
33 
34  {
35 
36  // Pileup/Playback information
37 
38  PileupInfoInputTag_ = ps.getParameter<edm::InputTag>("PileupInfoInputTag");
39  CFPlaybackInputTag_ = ps.getParameter<edm::InputTag>("CFPlaybackInputTag");
40 
41  iC.consumes<std::vector<PileupSummaryInfo>>(PileupInfoInputTag_);
43  }
44 
45  // Virtual destructor needed.
47  }
48 
49 
50  void DataMixingPileupCopy::addPileupInfo(const EventPrincipal *ep, unsigned int eventNr,
51  ModuleCallingContext const* mcc) {
52 
53  LogDebug("DataMixingPileupCopy") <<"\n===============> adding pileup Info from event "<<ep->id();
54 
55  // find PileupSummaryInfo, CFPlayback information, if it's there
56 
57  // Pileup info first
58 
59  std::shared_ptr<Wrapper< std::vector<PileupSummaryInfo> > const> PileupInfoPTR =
60  getProductByTag<std::vector<PileupSummaryInfo>>(*ep,PileupInfoInputTag_, mcc);
61 
62  if(PileupInfoPTR ) {
63 
64  PileupSummaryStorage_ = *(PileupInfoPTR->product()) ;
65 
66  LogDebug("DataMixingEMWorker") << "PileupInfo Size: " << PileupSummaryStorage_.size();
67 
68  }
69 
70  // Playback
71 
72  std::shared_ptr<Wrapper<CrossingFramePlaybackInfoExtended> const> PlaybackPTR =
73  getProductByTag<CrossingFramePlaybackInfoExtended>(*ep,CFPlaybackInputTag_, mcc);
74 
75  FoundPlayback_ = false;
76 
77  if(PlaybackPTR ) {
78 
79  CrossingFramePlaybackStorage_ = *(PlaybackPTR->product()) ;
80 
81  FoundPlayback_ = true;
82 
83  }
84 
85  }
86 
88 
89  std::auto_ptr<std::vector<PileupSummaryInfo> > PSIVector(new std::vector<PileupSummaryInfo>);
90 
91  std::vector<PileupSummaryInfo>::const_iterator PSiter;
92 
93  for(PSiter = PileupSummaryStorage_.begin(); PSiter != PileupSummaryStorage_.end(); PSiter++){
94 
95  PSIVector->push_back(*PSiter);
96 
97  }
98 
99  if(FoundPlayback_ ) {
100 
101  std::vector<std::vector<edm::EventID> > IdVect;
102 
104 
105  std::auto_ptr< CrossingFramePlaybackInfoExtended > CFPlaybackInfo( new CrossingFramePlaybackInfoExtended(0, IdVect.size(), 1 ));
106 
107  CFPlaybackInfo->setEventStartInfo(IdVect, 0);
108 
109  e.put(CFPlaybackInfo);
110 
111  }
112 
113  e.put(PSIVector);
114 
115 
116  // clear local storage after this event
117  PileupSummaryStorage_.clear();
118 
119  }
120 
121 } //edm
#define LogDebug(id)
T getParameter(std::string const &) const
void putPileupInfo(edm::Event &e)
EventID const & id() const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
std::vector< PileupSummaryInfo > PileupSummaryStorage_
void getEventStartInfo(std::vector< std::vector< edm::EventID > > &ids, const unsigned int s) const
CrossingFramePlaybackInfoExtended CrossingFramePlaybackStorage_
void addPileupInfo(const edm::EventPrincipal *, unsigned int EventId, ModuleCallingContext const *mcc)