Getting Data from a Dependent Record in an ESProducer

Complete: 4

The produce methods of a ESProducer are only passed the Record to which the data being produced will be added. Sometimes that is insufficient and you need data from other Records. As long as the Record passed to the ESProducer has been declared as depending upon these other Records you can get access to the other Records.

With ESGetToken

See here.

Getting a Record from a dependent Record

If ARecord is dependent on BRecord then you can call the method getRecord of ARecord
  const BRecord& b = aRecord.getRecord<BRecord>();

Having a method of ESProducer called whenever a depends upon Record changes

Consider the case where you are putting data into one Record, say ARecord, but need data from another Record, say BRecord, and you only need the data from BRecord when BRecord changes because you will need to redo a big calculation (e.g. if alignment changes you need to redo your calculations of coordinate transformations you calculate and cache locally). In such a case, you can ask the ESProducer to call a particular member function each time the BRecord has changed since the last time the produce method was called.

class AESProducer : public edm::ESProducer {
    ...
    void callWhenBChanges(const BRecord&);
    ...
};

AESProducer::AESProducer(const edm::ParameterSet& iPSet) {
 ...
    setWhatProduced(this, edm::eventsetup::dependsOn(&AESProducer::callWhenBChanges));
 }

In the example AESProducer::callWhenBChanges will be called before AESProducer::produce if and only if BRecord has changed since the last time AESProducer::produce was called.


Review Status

ChristopherJones - 27 Sep 2007: Page author

Responsible: ChristopherJones

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r4 - 2019-05-24 - MattiKortelainen



 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    CMSPublic All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback