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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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 152 of file HiMixingModule.cc.

Constructor & Destructor Documentation

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

Definition at line 180 of file HiMixingModule.cc.

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

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

241 {
242 
243  // do anything here that needs to be done at desctruction time
244  // (e.g. close files, deallocate resources etc.)
245 
246 }

Member Function Documentation

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

Definition at line 255 of file HiMixingModule.cc.

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

256 {
257  using namespace edm;
258 
259  for(size_t i = 0; i < workers_.size(); ++i){
260  (workers_[i])->addSignals(iEvent);
261  }
262 
263  std::unique_ptr< PileupMixingContent > PileupMixing_ = std::unique_ptr< PileupMixingContent >(new PileupMixingContent());
264  iEvent.put(std::move(PileupMixing_));
265 
266 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
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 268 of file HiMixingModule.cc.

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

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