CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ESProducer Class Reference

#include <FWCore/Framework/interface/ESProducer.h>

Detailed Description

Description: An EventSetup algorithmic Provider that encapsulates the algorithm as a member method

Usage: Inheriting from this class is the simplest way to create an algorithm which gets called when a new data item is needed for the EventSetup. This class is designed to call a member method of inheriting classes each time the algorithm needs to be run. (A more flexible system in which the algorithms can be set at run-time instead of compile time can be obtained by inheriting from ESProxyFactoryProducer instead.)

If only one algorithm is being encapsulated then the user needs to 1) add a method name 'produce' to the class. The 'produce' takes as its argument a const reference to the record that is to hold the data item being produced. If only one data item is being produced, the 'produce' method must return either an 'std::auto_ptr' or 'boost::shared_ptr' to the object being produced. (The choice depends on if the EventSetup or the ESProducer is managing the lifetime of the object). If multiple items are being Produced they the 'produce' method must return an ESProducts<> object which holds all of the items. 2) add 'setWhatProduced(this);' to their classes constructor

Example: one algorithm creating only one object

class FooProd : public edm::ESProducer {
std::auto_ptr<Foo> produce(const FooRecord&);
...
};
FooProd::FooProd(const edm::ParameterSet&) {
setWhatProduced(this);
...
}

Example: one algorithm creating two objects

class FoosProd : public edm::ESProducer {
edm::ESProducts<std::auto_ptr<Foo1>, std::auto_ptr<Foo2> > produce(const FooRecord&);
...
};

If multiple algorithms are being encapsulated then 1) like 1 above except the methods can have any names you want 2) add 'setWhatProduced(this, &<class name>::<method name>);' for each method in the class' constructor NOTE: the algorithms can put data into the same record or into different records

Example: two algorithms each creating only one objects

class FooBarProd : public edm::eventsetup::ESProducer {
std::auto_ptr<Foo> produceFoo(const FooRecord&);
std::auto_ptr<Bar> produceBar(const BarRecord&);
...
};
FooBarProd::FooBarProd(const edm::ParameterSet&) {
setWhatProduced(this,&FooBarProd::produceFoo);
setWhatProduced(this,&FooBarProd::produceBar);
...
}