#include <FWCore/Framework/interface/PrincipalGetAdapter.h>
Description: This is the implementation for accessing EDProducts and inserting new EDproducts.
Usage:
Getting Data
The edm::PrincipalGetAdapter class provides many 'get*" methods for getting data it contains.
The primary method for getting data is to use getByLabel(). The labels are the label of the module assigned in the configuration file and the 'product instance label' (which can be omitted in the case the 'product instance label' is the default value). The C++ type of the product plus the two labels uniquely identify a product in the PrincipalGetAdapter.
We use an event in the examples, but a run or a luminosity block can also hold products.
edm::Handle<AppleCollection> apples; event.getByLabel("tree",apples);
edm::Handle<FruitCollection> fruits; event.getByLabel("market", "apple", fruits);
Putting Data
std::auto_ptr<AppleCollection> pApples(new AppleCollection); //fill the collection ... event.put(pApples);
std::auto_ptr<FruitCollection> pFruits(new FruitCollection); //fill the collection ... event.put("apple", pFruits);
Getting a reference to a product before that product is put into the event/lumiBlock/run. NOTE: The edm::RefProd returned will not work until after the edm::PrincipalGetAdapter has been committed (which happens after the EDProducer::produce method has ended)
std::auto_ptr<AppleCollection> pApples(new AppleCollection); edm::RefProd<AppleCollection> refApples = event.getRefBeforePut<AppleCollection>(); //do loop and fill collection for(unsigned int index = 0; .....) { .... apples->push_back(Apple(...)); //create an edm::Ref to the new object edm::Ref<AppleCollection> ref(refApples, index); .... }