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 #include <map>
7 #include <memory>
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  BunchSpacingInputTag_ = ps.getParameter<edm::InputTag>("BunchSpacingInputTag");
39  CFPlaybackInputTag_ = ps.getParameter<edm::InputTag>("CFPlaybackInputTag");
40 
41 
42  // apparently, we don't need consumes from Secondary input stream
43  //iC.consumes<std::vector<PileupSummaryInfo>>(PileupInfoInputTag_);
44  //iC.consumes<int>(BunchSpacingInputTag_);
45  //iC.consumes<CrossingFramePlaybackInfoNew>(CFPlaybackInputTag_);
46  }
47 
48  // Virtual destructor needed.
50  }
51 
52 
53  void DataMixingPileupCopy::addPileupInfo(const EventPrincipal *ep, unsigned int eventNr,
54  ModuleCallingContext const* mcc) {
55 
56  LogDebug("DataMixingPileupCopy") <<"\n===============> adding pileup Info from event "<<ep->id();
57 
58  // find PileupSummaryInfo, CFPlayback information, if it's there
59 
60  // Pileup info first
61 
62  std::shared_ptr<Wrapper< std::vector<PileupSummaryInfo> > const> PileupInfoPTR =
63  getProductByTag<std::vector<PileupSummaryInfo>>(*ep,PileupInfoInputTag_, mcc);
64 
65  std::shared_ptr<Wrapper< int > const> bsPTR =
66  getProductByTag<int>(*ep,BunchSpacingInputTag_, mcc);
67 
68  if(PileupInfoPTR ) {
69  PileupSummaryStorage_ = *(PileupInfoPTR->product()) ;
70  LogDebug("DataMixingEMWorker") << "PileupInfo Size: " << PileupSummaryStorage_.size();
71  }
72 
73  if(bsPTR ) {
74  bsStorage_ = *(bsPTR->product()) ;
75  }
76  else {
77  bsStorage_=10000;
78  }
79 
80  // Playback
81  std::shared_ptr<Wrapper<CrossingFramePlaybackInfoNew> const> PlaybackPTR =
82  getProductByTag<CrossingFramePlaybackInfoNew>(*ep,CFPlaybackInputTag_, mcc);
83  FoundPlayback_ = false;
84  if(PlaybackPTR ) {
85  CrossingFramePlaybackStorage_ = *(PlaybackPTR->product()) ;
86  FoundPlayback_ = true;
87  }
88  }
89 
91  std::auto_ptr<std::vector<PileupSummaryInfo> > PSIVector(new std::vector<PileupSummaryInfo>);
92  std::auto_ptr<int> bsInt(new int);
93 
94  std::vector<PileupSummaryInfo>::const_iterator PSiter;
95  for(PSiter = PileupSummaryStorage_.begin(); PSiter != PileupSummaryStorage_.end(); PSiter++){
96  PSIVector->push_back(*PSiter);
97  }
98 
99  *bsInt=bsStorage_;
100 
101  if(FoundPlayback_ ) {
102  std::auto_ptr<CrossingFramePlaybackInfoNew> CFPlaybackInfo(new CrossingFramePlaybackInfoNew(CrossingFramePlaybackStorage_));
103  e.put(CFPlaybackInfo);
104  }
105  e.put(PSIVector);
106  e.put(bsInt,"bunchSpacing");
107 
108  // clear local storage after this event
109  PileupSummaryStorage_.clear();
110  }
111 } //edm
#define LogDebug(id)
T getParameter(std::string const &) const
CrossingFramePlaybackInfoNew CrossingFramePlaybackStorage_
void putPileupInfo(edm::Event &e)
EventID const & id() const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
std::vector< PileupSummaryInfo > PileupSummaryStorage_
void addPileupInfo(const edm::EventPrincipal *, unsigned int EventId, ModuleCallingContext const *mcc)