CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MixingWorker.cc
Go to the documentation of this file.
6 #include "MixingWorker.h"
7 
8 #include "boost/shared_ptr.hpp"
9 
10 namespace edm {
11  template <>
12  void MixingWorker<PCaloHit>::addPileups(const int bcr, const EventPrincipal &ep, unsigned int eventNr,int vertexoffset) {
13 
14  boost::shared_ptr<Wrapper<std::vector<PCaloHit> > const> shPtr = edm::getProductByTag<std::vector<PCaloHit> >(ep, tag_);
15 
16  if (shPtr) {
17  LogDebug("MixingModule") <<shPtr->product()->size()<<" pileup objects added, eventNr "<<eventNr;
18  crFrame_->setPileupPtr(shPtr);
19  crFrame_->addPileups(bcr,const_cast< std::vector<PCaloHit> * >(shPtr->product()),eventNr);
20  }
21  }
22 
23  template <>
24  void MixingWorker<PSimHit>::addPileups(const int bcr, const EventPrincipal &ep,unsigned int eventNr,int vertexoffset) {
25  // changed for high/low treatment
26  boost::shared_ptr<Wrapper<std::vector<PSimHit> > const> shPtr = getProductByTag<std::vector<PSimHit> >(ep, tag_);
27  if (shPtr) {
28  LogDebug("MixingModule") <<shPtr->product()->size()<<" pileup objects added, eventNr "<<eventNr;
29  crFrame_->setPileupPtr(shPtr);
30  crFrame_->addPileups(bcr,const_cast< std::vector<PSimHit> * > (shPtr->product()),eventNr);
31  }
32  }
33 
34  template <>
35  void MixingWorker<SimTrack>::addPileups(const int bcr, const EventPrincipal &ep,unsigned int eventNr,int vertexoffset) {
36  // changed to transmit vertexoffset
37  boost::shared_ptr<Wrapper<std::vector<SimTrack> > const> shPtr = getProductByTag<std::vector<SimTrack> >(ep, tag_);
38 
39  if (shPtr) {
40  LogDebug("MixingModule") <<shPtr->product()->size()<<" pileup objects added, eventNr "<<eventNr;
41  crFrame_->setPileupPtr(shPtr);
42  crFrame_->addPileups(bcr,const_cast< std::vector<SimTrack> * > (shPtr->product()),eventNr,vertexoffset);
43  }
44  }
45 
46  template <>
47  void MixingWorker<SimVertex>::addPileups(const int bcr, const EventPrincipal &ep,unsigned int eventNr,int vertexoffset) {
48 
49  // changed to take care of vertexoffset
50  boost::shared_ptr<Wrapper<std::vector<SimVertex> > const> shPtr = getProductByTag<std::vector<SimVertex> >(ep, tag_);
51 
52  if (shPtr) {
53  LogDebug("MixingModule") <<shPtr->product()->size()<<" pileup objects added, eventNr "<<eventNr;
54  vertexoffset+=shPtr->product()->size();
55  crFrame_->setPileupPtr(shPtr);
56  crFrame_->addPileups(bcr,const_cast< std::vector<SimVertex> * > (shPtr->product()),eventNr);
57  }
58  }
59 
60  template <>
61  void MixingWorker<HepMCProduct>::addPileups(const int bcr, const EventPrincipal& ep,unsigned int eventNr,int vertexoffset) {
62  // HepMCProduct does not come as a vector....
63  boost::shared_ptr<Wrapper<HepMCProduct> const> shPtr = getProductByTag<HepMCProduct>(ep, tag_);
64  if (shPtr) {
65  LogDebug("MixingModule") <<"HepMC pileup objects added, eventNr "<<eventNr << " Tag " << tag_ << std::endl;
66  crFrame_->setPileupPtr(shPtr);
67  crFrame_->addPileups(bcr,const_cast<HepMCProduct*> (shPtr->product()),eventNr);
68  }
69  }
70 
71  template <>
73  //HepMC - here the interface is different!!!
74  Handle<HepMCProduct> result_t;
75  bool got = e.getByLabel(tag_,result_t);
76  if (got) {
77  LogDebug("MixingModule") <<" adding HepMCProduct from signal event with "<<tag_;
78  crFrame_->addSignals(result_t.product(),e.id());
79  } else {
80  LogInfo("MixingModule") <<"!!!!!!! Did not get any signal data for HepMCProduct with "<<tag_;
81  }
82  }
83 
84  template <>
86  bool got;
87  InputTag t;
88 
89  Handle<HepMCProduct> result_t;
90  got = e.getByLabel(tag_,result_t);
91  t = InputTag(tag_.label(),tag_.instance());
92 
93  if (got) {
94  LogInfo("MixingModule") <<" Will create a CrossingFrame for HepMCProduct with "
95  << " with InputTag= "<< t.encode();
96  }
97 
98  return got;
99  }
100 
101 }//namespace edm
#define LogDebug(id)
virtual void addPileups(const int bcr, const EventPrincipal &ep, unsigned int eventNr, int vertexoffset)
virtual void addSignals(const edm::Event &e)
Definition: MixingWorker.h:109
virtual bool checkSignal(const edm::Event &e)
Definition: MixingWorker.h:90