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>
15 //
16 //
17 #include "DataMixingPileupCopy.h"
18 
19 
20 using namespace std;
21 
22 namespace edm
23 {
24 
25  // Virtual constructor
26 
27  DataMixingPileupCopy::DataMixingPileupCopy() { }
28 
29  // Constructor
30  DataMixingPileupCopy::DataMixingPileupCopy(const edm::ParameterSet& ps, edm::ConsumesCollector && iC) :
31  label_(ps.getParameter<std::string>("Label"))
32 
33  {
34 
35  // Pileup/Playback information
36 
37  PileupInfoInputTag_ = ps.getParameter<edm::InputTag>("PileupInfoInputTag");
38  CFPlaybackInputTag_ = ps.getParameter<edm::InputTag>("CFPlaybackInputTag");
39 
40  iC.consumes<std::vector<PileupSummaryInfo>>(PileupInfoInputTag_);
42  }
43 
44  // Virtual destructor needed.
46  }
47 
48 
49  void DataMixingPileupCopy::addPileupInfo(const EventPrincipal *ep, unsigned int eventNr,
50  ModuleCallingContext const* mcc) {
51 
52  LogDebug("DataMixingPileupCopy") <<"\n===============> adding pileup Info from event "<<ep->id();
53 
54  // find PileupSummaryInfo, CFPlayback information, if it's there
55 
56  // Pileup info first
57 
58  boost::shared_ptr<Wrapper< std::vector<PileupSummaryInfo> > const> PileupInfoPTR =
59  getProductByTag<std::vector<PileupSummaryInfo>>(*ep,PileupInfoInputTag_, mcc);
60 
61  if(PileupInfoPTR ) {
62 
63  PileupSummaryStorage_ = *(PileupInfoPTR->product()) ;
64 
65  LogDebug("DataMixingEMWorker") << "PileupInfo Size: " << PileupSummaryStorage_.size();
66 
67  }
68 
69  // Playback
70 
71  boost::shared_ptr<Wrapper<CrossingFramePlaybackInfoExtended> const> PlaybackPTR =
72  getProductByTag<CrossingFramePlaybackInfoExtended>(*ep,CFPlaybackInputTag_, mcc);
73 
74  FoundPlayback_ = false;
75 
76  if(PlaybackPTR ) {
77 
78  CrossingFramePlaybackStorage_ = *(PlaybackPTR->product()) ;
79 
80  FoundPlayback_ = true;
81 
82  }
83 
84  }
85 
87 
88  std::auto_ptr<std::vector<PileupSummaryInfo> > PSIVector(new std::vector<PileupSummaryInfo>);
89 
90  std::vector<PileupSummaryInfo>::const_iterator PSiter;
91 
92  for(PSiter = PileupSummaryStorage_.begin(); PSiter != PileupSummaryStorage_.end(); PSiter++){
93 
94  PSIVector->push_back(*PSiter);
95 
96  }
97 
98  if(FoundPlayback_ ) {
99 
100  std::vector<std::vector<edm::EventID> > IdVect;
101 
103 
104  std::auto_ptr< CrossingFramePlaybackInfoExtended > CFPlaybackInfo( new CrossingFramePlaybackInfoExtended(0, IdVect.size(), 1 ));
105 
106  CFPlaybackInfo->setEventStartInfo(IdVect, 0);
107 
108  e.put(CFPlaybackInfo);
109 
110  }
111 
112  e.put(PSIVector);
113 
114 
115  // clear local storage after this event
116  PileupSummaryStorage_.clear();
117 
118  }
119 
120 } //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:116
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)