CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
edm::HiMixingModule Class Reference
Inheritance diagram for edm::HiMixingModule:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 HiMixingModule (const edm::ParameterSet &)
 
 ~HiMixingModule ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
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::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 149 of file HiMixingModule.cc.

Constructor & Destructor Documentation

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

Definition at line 177 of file HiMixingModule.cc.

References edm::InputTag::encode(), edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), collect_tpl::input, edm::InputTag::instance(), edm::InputTag::label(), label, h::names, GlobalPosition_Frontier_DevDB_cff::tag, and o2o::tags.

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

Definition at line 232 of file HiMixingModule.cc.

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

Member Function Documentation

void HiMixingModule::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 262 of file HiMixingModule.cc.

263 {
264 }
void HiMixingModule::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 268 of file HiMixingModule.cc.

268  {
269 }
void HiMixingModule::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 247 of file HiMixingModule.cc.

References i, and edm::Event::put().

248 {
249  using namespace edm;
250 
251  for(size_t i = 0; i < workers_.size(); ++i){
252  (workers_[i])->addSignals(iEvent);
253  }
254 
255  std::auto_ptr< PileupMixingContent > PileupMixing_ = std::auto_ptr< PileupMixingContent >(new PileupMixingContent());
256  iEvent.put(PileupMixing_);
257 
258 }
int i
Definition: DBlmapReader.cc:9
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
std::vector< HiMixingWorkerBase * > workers_
bool HiMixingModule::verifyRegistry ( std::string  object,
std::string  subdet,
InputTag tag,
std::string &  label 
)
private

Definition at line 271 of file HiMixingModule.cc.

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

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

Member Data Documentation

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

Definition at line 161 of file HiMixingModule.cc.