CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
edm::HiMixingModule Class Reference
Inheritance diagram for edm::HiMixingModule:
edm::stream::EDProducer<>

Public Member Functions

 HiMixingModule (const edm::ParameterSet &)
 
 ~HiMixingModule () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 
bool verifyRegistry (std::string object, std::string subdet, InputTag &tag, std::string &label)
 

Private Attributes

std::vector< HiMixingWorkerBase * > workers_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 149 of file HiMixingModule.cc.

Constructor & Destructor Documentation

HiMixingModule::HiMixingModule ( const edm::ParameterSet pset)
explicit

Definition at line 175 of file HiMixingModule.cc.

References edm::InputTag::encode(), edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), input, PixelMapPlotter::inputs, HLT_2018_cff::InputTag, edm::InputTag::instance(), label, edm::InputTag::label(), names, AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, and triggerMatcherToHLTDebug_cfi::tags.

175  {
176  ParameterSet ps = pset.getParameter<ParameterSet>("mixObjects");
177  std::vector<std::string> names = ps.getParameterNames();
178  std::vector<std::string> simtags = pset.getParameter<std::vector<std::string> >("srcSIM");
179  std::vector<std::string> gentags = pset.getParameter<std::vector<std::string> >("srcGEN");
180 
181  if (simtags.size() != gentags.size())
182  LogError("MixingInput") << "Generator and Simulation input lists are not matching each other" << endl;
183 
184  for (std::vector<string>::iterator it = names.begin(); it != names.end(); ++it) {
185  ParameterSet pstag = ps.getParameter<ParameterSet>((*it));
186  if (!pstag.exists("type"))
187  continue; //to allow replacement by empty pset
188  std::string object = pstag.getParameter<std::string>("type");
189  std::vector<InputTag> tags = pstag.getParameter<std::vector<InputTag> >("input");
190 
191  std::string signal;
192  for (size_t itag = 0; itag < tags.size(); ++itag) {
193  InputTag tag = tags[itag];
194  std::vector<InputTag> inputs;
195 
196  for (size_t input = 0; input < simtags.size(); ++input) {
197  if (object == "HepMCProduct")
198  signal = gentags[input];
199  else
200  signal = simtags[input];
201  inputs.push_back(InputTag(signal, tag.instance()));
202  }
203 
204  std::string label = tag.label() + tag.instance();
205  // verifyRegistry(object,std::string(""),tag,label);
206  if (object == "HepMCProduct") {
207  workers_.push_back(new HiMixingWorker<HepMCProduct>(object, inputs, label));
208  produces<CrossingFrame<HepMCProduct> >(label);
209  consumes<HepMCProduct>(tag);
210  } else if (object == "SimTrack") {
211  workers_.push_back(new HiMixingWorker<SimTrack>(object, inputs, label));
212  produces<CrossingFrame<SimTrack> >(label);
213  consumes<std::vector<SimTrack> >(tag);
214  } else if (object == "SimVertex") {
215  workers_.push_back(new HiMixingWorker<SimVertex>(object, inputs, label));
216  produces<CrossingFrame<SimVertex> >(label);
217  consumes<std::vector<SimVertex> >(tag);
218  } else if (object == "PSimHit") {
219  workers_.push_back(new HiMixingWorker<PSimHit>(object, inputs, label));
220  produces<CrossingFrame<PSimHit> >(label);
221  consumes<std::vector<PSimHit> >(tag);
222  } else if (object == "PCaloHit") {
223  workers_.push_back(new HiMixingWorker<PCaloHit>(object, inputs, label));
224  produces<CrossingFrame<PCaloHit> >(label);
225  consumes<std::vector<PCaloHit> >(tag);
226  } else
227  LogInfo("Error") << "What the hell is this object?!";
228 
229  LogInfo("HiMixingModule") << "Will mix " << object << "s with InputTag= " << tag.encode() << ", label will be "
230  << label;
231  }
232  }
233 
234  produces<PileupMixingContent>();
235  }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
const std::string names[nVars_]
std::string encode() const
Definition: InputTag.cc:159
static std::string const input
Definition: EdmProvDump.cc:48
char const * label
std::vector< std::string > getParameterNames() const
std::vector< HiMixingWorkerBase * > workers_
std::string const & label() const
Definition: InputTag.h:36
std::string const & instance() const
Definition: InputTag.h:37
HiMixingModule::~HiMixingModule ( )
override

Definition at line 237 of file HiMixingModule.cc.

237  {
238  // do anything here that needs to be done at desctruction time
239  // (e.g. close files, deallocate resources etc.)
240  }

Member Function Documentation

void HiMixingModule::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 247 of file HiMixingModule.cc.

References mps_fire::i, eostools::move(), and edm::Event::put().

247  {
248  using namespace edm;
249 
250  for (size_t i = 0; i < workers_.size(); ++i) {
251  (workers_[i])->addSignals(iEvent);
252  }
253 
254  std::unique_ptr<PileupMixingContent> PileupMixing_ =
255  std::unique_ptr<PileupMixingContent>(new PileupMixingContent());
256  iEvent.put(std::move(PileupMixing_));
257  }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
std::vector< HiMixingWorkerBase * > workers_
HLT enums.
def move(src, dest)
Definition: eostools.py:511
bool HiMixingModule::verifyRegistry ( std::string  object,
std::string  subdet,
InputTag tag,
std::string &  label 
)
private

Definition at line 259 of file HiMixingModule.cc.

References edm::BranchDescription::className(), DEFINE_FWK_MODULE, newFWLiteAna::found, edm::InputTag::instance(), edm::InputTag::label(), edm::BranchDescription::moduleLabel(), resolutioncreator_cfi::object, edm::BranchDescription::productInstanceName(), edm::ConstProductRegistry::productList(), and AlCaHLTBitMon_QueryRunRegistry::string.

259  {
260  // verify that the given product exists in the product registry
261  // and create the label to be given to the CrossingFrame
262 
264  // Loop over provenance of products in registry.
265  std::string lookfor;
266  if (object == "HepMCProduct")
267  lookfor = "edm::" + object; //exception for HepMCProduct
268  else if (object == "edm::HepMCProduct")
269  lookfor = object;
270  else
271  lookfor = "std::vector<" + object + ">";
272  bool found = false;
273  for (edm::ProductRegistry::ProductList::const_iterator it = reg->productList().begin();
274  it != reg->productList().end();
275  ++it) {
276  // See FWCore/Framework/interface/BranchDescription.h
277  // BranchDescription contains all the information for the product.
278  edm::BranchDescription desc = it->second;
279  if (desc.className() == lookfor && desc.moduleLabel() == tag.label() &&
280  desc.productInstanceName() == tag.instance()) {
281  label = desc.moduleLabel() + desc.productInstanceName();
282  found = true;
283  /*
284  wantedBranches_.push_back(desc.friendlyClassName() + '_' +
285  desc.moduleLabel() + '_' +
286  desc.productInstanceName());
287  */
288  break;
289  }
290  }
291  if (!found) {
292  LogWarning("MixingModule") << "!!!!!!!!!Could not find in registry requested object: " << object << " with "
293  << tag << ".\nWill NOT be considered for mixing!!!!!!!!!";
294  return false;
295  }
296 
297  return true;
298  }
char const * label
std::string const & className() const
std::string const & moduleLabel() const
std::string const & productInstanceName() const
std::string const & label() const
Definition: InputTag.h:36
std::string const & instance() const
Definition: InputTag.h:37
ProductList const & productList() const

Member Data Documentation

std::vector<HiMixingWorkerBase*> edm::HiMixingModule::workers_
private

Definition at line 161 of file HiMixingModule.cc.