CMS 3D CMS Logo

MixingWorker.h
Go to the documentation of this file.
1 #ifndef MixingWorker_h
2 #define MixingWorker_h
3 
19 
24 
29 
30 #include <memory>
31 #include <vector>
32 #include <string>
33 #include <typeinfo>
34 #include "MixingWorkerBase.h"
35 
36 class SimTrack;
37 class SimVertex;
38 namespace edm {
39  template <class T>
40  class MixingWorker : public MixingWorkerBase {
41  public:
43  explicit MixingWorker()
44  : minBunch_(-5),
45  maxBunch_(3),
46  bunchSpace_(75),
47  subdet_(std::string(" ")),
48  label_(std::string(" ")),
49  labelCF_(std::string(" ")),
50  maxNbSources_(5),
52  tag_(),
53  tagSignal_(),
54  allTags_(),
55  crFrame_(nullptr) {}
56 
57  /*Normal constructor*/
59  int maxBunch,
60  int bunchSpace,
61  std::string subdet,
63  std::string labelCF,
64  int maxNbSources,
65  InputTag &tag,
66  InputTag &tagCF,
67  bool makePCrossingFrame = false)
68  : MixingWorkerBase(),
71  bunchSpace_(bunchSpace),
72  subdet_(subdet),
73  label_(label),
74  labelCF_(labelCF),
75  maxNbSources_(maxNbSources),
76  makePCrossingFrame_(makePCrossingFrame),
77  tag_(tag),
78  tagSignal_(tagCF),
79  allTags_(),
80  crFrame_(nullptr) {}
81 
82  /*constructor for HepMCproduct case*/
84  int maxBunch,
85  int bunchSpace,
86  std::string subdet,
88  std::string labelCF,
89  int maxNbSources,
90  InputTag &tag,
91  InputTag &tagCF,
92  std::vector<InputTag> const &tags)
93  : MixingWorkerBase(),
96  bunchSpace_(bunchSpace),
97  subdet_(subdet),
98  label_(label),
99  labelCF_(labelCF),
100  maxNbSources_(maxNbSources),
102  tag_(tag),
103  tagSignal_(tagCF),
104  allTags_(tags),
105  crFrame_(nullptr) {}
106 
108  ~MixingWorker() override { ; }
109 
110  public:
111  void reload(const edm::EventSetup &setup) override {
112  //get the required parameters from DB.
113  // watch the label/tag
115  setup.get<MixingRcd>().get(config);
116  minBunch_ = config->minBunch();
117  maxBunch_ = config->maxBunch();
118  bunchSpace_ = config->bunchSpace();
119  }
120 
121  bool checkSignal(const edm::Event &e) override {
122  bool got;
123  InputTag t;
124  edm::Handle<std::vector<T> > result_t;
125  got = e.getByLabel(tag_, result_t);
126  t = InputTag(tag_.label(), tag_.instance());
127 
128  if (got)
129  LogInfo("MixingModule") << " Will create a CrossingFrame for " << typeid(T).name()
130  << " with InputTag= " << t.encode();
131 
132  return got;
133  }
134 
135  void createnewEDProduct() override {
136  crFrame_ = std::make_unique<CrossingFrame<T> >(minBunch_, maxBunch_, bunchSpace_, subdet_, maxNbSources_);
137  }
138 
139  void addSignals(const edm::Event &e) override {
140  edm::Handle<std::vector<T> > result_t;
141  bool got = e.getByLabel(tag_, result_t);
142  if (got) {
143  LogDebug("MixingModule") << " adding " << result_t.product()->size() << " signal objects for "
144  << typeid(T).name() << " with " << tag_;
145  crFrame_->addSignals(result_t.product(), e.id());
146  } else {
147  LogInfo("MixingModule") << "!!!!!!! Did not get any signal data for " << typeid(T).name() << ", with " << tag_;
148  }
149  }
150 
151  void addPileups(const EventPrincipal &ep, ModuleCallingContext const *, unsigned int eventNr) override;
152 
153  void setBcrOffset() override { crFrame_->setBcrOffset(); }
154  void setSourceOffset(const unsigned int s) override { crFrame_->setSourceOffset(s); }
155 
156  void setTof() override;
157 
158  void put(edm::Event &e) override {
159  if (makePCrossingFrame_) {
160  e.put(std::make_unique<PCrossingFrame<T> >(*crFrame_), label_);
161  }
162  e.put(std::move(crFrame_), label_);
163  LogDebug("MixingModule") << " CF was put for type " << typeid(T).name() << " with " << label_;
164  }
165 
166  // When using mixed secondary source
167  // Copy the data from the PCrossingFrame to the CrossingFrame
168  virtual void copyPCrossingFrame(const PCrossingFrame<T> *PCF);
169 
170  private:
177  unsigned int const maxNbSources_;
181  std::vector<InputTag> allTags_; // for HepMCProduct
182 
183  std::unique_ptr<CrossingFrame<T> > crFrame_;
184  };
185 
186  template <typename T>
187  void MixingWorker<T>::addPileups(const EventPrincipal &ep, ModuleCallingContext const *mcc, unsigned int eventNr) {
188  std::shared_ptr<Wrapper<std::vector<T> > const> shPtr = getProductByTag<std::vector<T> >(ep, tag_, mcc);
189  if (shPtr) {
190  LogDebug("MixingModule") << shPtr->product()->size() << " pileup objects added, eventNr " << eventNr;
191  crFrame_->setPileupPtr(shPtr);
192  crFrame_->addPileups(*shPtr->product());
193  }
194  }
195  //=============== template specializations ====================================================================================
196 
197  template <>
199  ModuleCallingContext const *,
200  unsigned int eventNr);
201 
202  template <class T>
204  ;
205  }
206 
207  template <class T>
209  crFrame_->setBunchRange(PCF->getBunchRange());
210  crFrame_->setBunchSpace(PCF->getBunchSpace());
211  crFrame_->setMaxNbSources(PCF->getMaxNbSources());
212  crFrame_->setSubDet(PCF->getSubDet());
213  crFrame_->setPileupOffsetsBcr(PCF->getPileupOffsetsBcr());
214  crFrame_->setPileupOffsetsSource(PCF->getPileupOffsetsSource());
215  crFrame_->setPileups(PCF->getPileups());
216 
217  // For playback option
218  crFrame_->setPileupFileNr(PCF->getPileupFileNr());
219  crFrame_->setIdFirstPileup(PCF->getIdFirstPileup());
220  }
221 
222 } // namespace edm
223 
224 #endif
edm::MixingWorker::MixingWorker
MixingWorker()
Definition: MixingWorker.h:43
Handle.h
edm::MixingWorker::setSourceOffset
void setSourceOffset(const unsigned int s) override
Definition: MixingWorker.h:154
MixingRcd
Definition: MixingRcd.h:24
edm::MixingWorker::~MixingWorker
~MixingWorker() override
Definition: MixingWorker.h:108
SimVertex
Definition: SimVertex.h:5
PCrossingFrame::getBunchSpace
int getBunchSpace() const
Definition: PCrossingFrame.h:37
funct::false
false
Definition: Factorize.h:29
edm::Handle::product
T const * product() const
Definition: Handle.h:70
edm::InputTag::instance
std::string const & instance() const
Definition: InputTag.h:37
ESHandle.h
MixingModule_cfi.maxBunch
maxBunch
Definition: MixingModule_cfi.py:42
edm::MixingWorker::tag_
InputTag tag_
Definition: MixingWorker.h:179
edm::MixingWorker::tagSignal_
InputTag tagSignal_
Definition: MixingWorker.h:180
MixingModuleConfig.h
edm
HLT enums.
Definition: AlignableModifier.h:19
CrossingFrame.h
PSimHitContainer.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89281
PCrossingFrame
Definition: CrossingFrame.h:27
edm::MixingWorker::maxBunch_
int maxBunch_
Definition: MixingWorker.h:172
edm::MixingWorker::labelCF_
const std::string labelCF_
Definition: MixingWorker.h:176
edm::MixingWorker::setBcrOffset
void setBcrOffset() override
Definition: MixingWorker.h:153
edm::MixingWorker::createnewEDProduct
void createnewEDProduct() override
Definition: MixingWorker.h:135
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle
Definition: AssociativeIterator.h:50
edm::MixingWorker
Definition: MixingWorker.h:40
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
PCrossingFrame::getMaxNbSources
unsigned int getMaxNbSources() const
Definition: PCrossingFrame.h:38
edm::MixingWorker::subdet_
const std::string subdet_
Definition: MixingWorker.h:174
edm::MixingWorker::setTof
void setTof() override
Definition: MixingWorker.h:203
config
Definition: config.py:1
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
edm::MixingWorker::addSignals
void addSignals(const edm::Event &e) override
Definition: MixingWorker.h:139
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edm::MixingWorker::makePCrossingFrame_
const bool makePCrossingFrame_
Definition: MixingWorker.h:178
edm::MixingWorker::crFrame_
std::unique_ptr< CrossingFrame< T > > crFrame_
Definition: MixingWorker.h:183
edm::EventPrincipal
Definition: EventPrincipal.h:46
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
EventPrincipal.h
PCrossingFrame::getPileupFileNr
unsigned int getPileupFileNr() const
Definition: PCrossingFrame.h:40
submitPVResolutionJobs.config
config
parse the configuration file
Definition: submitPVResolutionJobs.py:281
PCrossingFrame::getBunchRange
std::pair< int, int > getBunchRange() const
Definition: PCrossingFrame.h:46
edm::ESHandle
Definition: DTSurvey.h:22
PCrossingFrame::getPileupOffsetsBcr
const std::vector< unsigned int > & getPileupOffsetsBcr() const
Definition: PCrossingFrame.h:42
edm::MixingWorker::MixingWorker
MixingWorker(int minBunch, int maxBunch, int bunchSpace, std::string subdet, std::string label, std::string labelCF, int maxNbSources, InputTag &tag, InputTag &tagCF, std::vector< InputTag > const &tags)
Definition: MixingWorker.h:83
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::MixingWorker::put
void put(edm::Event &e) override
Definition: MixingWorker.h:158
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
Event.h
PCrossingFrame.h
edm::get
T const & get(Event const &event, InputTag const &tag) noexcept(false)
Definition: Event.h:675
MixingRcd.h
MixingWorkerBase.h
edm::MixingWorker::bunchSpace_
int bunchSpace_
Definition: MixingWorker.h:173
edm::MixingWorker::minBunch_
int minBunch_
Definition: MixingWorker.h:171
PCrossingFrame::getSubDet
std::string getSubDet() const
Definition: PCrossingFrame.h:39
edm::EventSetup
Definition: EventSetup.h:58
PCrossingFrame::getIdFirstPileup
edm::EventID getIdFirstPileup() const
Definition: PCrossingFrame.h:41
edm::MixingWorker::label_
const std::string label_
Definition: MixingWorker.h:175
edm::MixingWorker::reload
void reload(const edm::EventSetup &setup) override
Definition: MixingWorker.h:111
InputTag.h
edm::MixingWorker::copyPCrossingFrame
virtual void copyPCrossingFrame(const PCrossingFrame< T > *PCF)
Definition: MixingWorker.h:208
Wrapper.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
edm::MixingWorkerBase
Definition: MixingWorkerBase.h:28
edm::MixingWorker::allTags_
std::vector< InputTag > allTags_
Definition: MixingWorker.h:181
SimTrack
Definition: SimTrack.h:9
T
long double T
Definition: Basic3DVectorLD.h:48
PCrossingFrame::getPileups
std::vector< const T * > getPileups() const
Definition: PCrossingFrame.h:30
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
MixingModule_cfi.minBunch
minBunch
Definition: MixingModule_cfi.py:43
edm::MixingWorker::checkSignal
bool checkSignal(const edm::Event &e) override
Definition: MixingWorker.h:121
triggerMatcherToHLTDebug_cfi.tags
tags
Definition: triggerMatcherToHLTDebug_cfi.py:9
edm::MixingWorker::maxNbSources_
unsigned const int maxNbSources_
Definition: MixingWorker.h:177
edm::MixingWorker::MixingWorker
MixingWorker(int minBunch, int maxBunch, int bunchSpace, std::string subdet, std::string label, std::string labelCF, int maxNbSources, InputTag &tag, InputTag &tagCF, bool makePCrossingFrame=false)
Definition: MixingWorker.h:58
edm::MixingWorker::addPileups
void addPileups(const EventPrincipal &ep, ModuleCallingContext const *, unsigned int eventNr) override
Definition: MixingWorker.h:187
edm::Event
Definition: Event.h:73
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
PCrossingFrame::getPileupOffsetsSource
const std::vector< std::vector< unsigned int > > & getPileupOffsetsSource() const
Definition: PCrossingFrame.h:43
SiStripBadComponentsDQMServiceTemplate_cfg.ep
ep
Definition: SiStripBadComponentsDQMServiceTemplate_cfg.py:86
edm::InputTag
Definition: InputTag.h:15
label
const char * label
Definition: PFTauDecayModeTools.cc:11
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
edm::ModuleCallingContext
Definition: ModuleCallingContext.h:29