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) :
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  }
41 
42  // Virtual destructor needed.
44  }
45 
46 
47  void DataMixingPileupCopy::addPileupInfo(const EventPrincipal *ep, unsigned int eventNr,
48  ModuleCallingContext const* mcc) {
49 
50  LogDebug("DataMixingPileupCopy") <<"\n===============> adding pileup Info from event "<<ep->id();
51 
52  // find PileupSummaryInfo, CFPlayback information, if it's there
53 
54  // Pileup info first
55 
56  boost::shared_ptr<Wrapper< std::vector<PileupSummaryInfo> > const> PileupInfoPTR =
57  getProductByTag<std::vector<PileupSummaryInfo>>(*ep,PileupInfoInputTag_, mcc);
58 
59  if(PileupInfoPTR ) {
60 
61  PileupSummaryStorage_ = *(PileupInfoPTR->product()) ;
62 
63  LogDebug("DataMixingEMWorker") << "PileupInfo Size: " << PileupSummaryStorage_.size();
64 
65  }
66 
67  // Playback
68 
69  boost::shared_ptr<Wrapper<CrossingFramePlaybackInfoExtended> const> PlaybackPTR =
70  getProductByTag<CrossingFramePlaybackInfoExtended>(*ep,CFPlaybackInputTag_, mcc);
71 
72  FoundPlayback_ = false;
73 
74  if(PlaybackPTR ) {
75 
76  CrossingFramePlaybackStorage_ = *(PlaybackPTR->product()) ;
77 
78  FoundPlayback_ = true;
79 
80  }
81 
82  }
83 
85 
86  std::auto_ptr<std::vector<PileupSummaryInfo> > PSIVector(new std::vector<PileupSummaryInfo>);
87 
88  std::vector<PileupSummaryInfo>::const_iterator PSiter;
89 
90  for(PSiter = PileupSummaryStorage_.begin(); PSiter != PileupSummaryStorage_.end(); PSiter++){
91 
92  PSIVector->push_back(*PSiter);
93 
94  }
95 
96  if(FoundPlayback_ ) {
97 
98  std::vector<std::vector<edm::EventID> > IdVect;
99 
101 
102  std::auto_ptr< CrossingFramePlaybackInfoExtended > CFPlaybackInfo( new CrossingFramePlaybackInfoExtended(0, IdVect.size(), 1 ));
103 
104  CFPlaybackInfo->setEventStartInfo(IdVect, 0);
105 
106  e.put(CFPlaybackInfo);
107 
108  }
109 
110  e.put(PSIVector);
111 
112 
113  // clear local storage after this event
114  PileupSummaryStorage_.clear();
115 
116  }
117 
118 } //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)