SWGuideFwdRef

Motivation

This page describes the edm::FwdRef prototype. This can be found here.

The motivation to create this is for analysis-level workflows. The canonical example that is not yet dealt with nicely in the framework is if there is a collection that should be skimmed for reasons of space and IO optimization, which is keyed to another collection elsewhere. The EDM uses static keys and the default edm::ValueMap and edm::Ref have no concepts of "forwarding" the association after user operations.

The edm::FwdRef attempts to rectify this by creating a "forwarding" concept. The base design is that two edm::Ref s are kept internally. The "forward" Ref represents the current pointer (suitable for dereferencing, etc). The "backward" Ref represents the pointer to the original collection (suitable for matching to associations off of the original collection).

Using this construct, it is possible to skim collections down for space-conservation or IO speed optimization, while retaining the information to access the original ValueMap, for instance. A single vector of edm::FwdRef s is sufficient to accomplish this, for any number of ValueMap s keyed by the original collection.

Use Cases

Some typical use cases where this will be useful are

  • Retaining ValueMaps of a skimmed collection.
  • Retaining Ref s stored internally to an object that point to a "fat" collection that is typically skimmed (like the TrackRef within TagInfos, which point to generalTracks, which is often desired to be skimmed since most tracks are uninteresting to b-tagging analysis).
  • Transient Ref s being handled the same way as ordinary Ref s for overlap checking.

Prescription

To access the software, working from CMSSW 3.4.1:

cmsrel CMSSW_3_4_1
cd CMSSW_3_4_1/src
cvs co -d Analysis/FwdRefTest -r srappocc_FwdRef_0 UserCode/srappocc/src/Analysis/FwdRefTest
addpkg -r srappocc_FwdRef DataFormats/Common
addpkg -r srappocc_FwdRef DataFormats/JetReco
scram b
cd Analysis/FwdRefTest/test

Walk-through of Usage

To describe the usage it's instructive to walk through the example code to read in the =edm::FwdRef=s here.

The example here will:

  1. Get the value map for the jet ID, which is keyed off of ak5CMS.CaloJets created by reco.
  2. Get the vector of edm::FwdRef to skimmed CMS.CaloJets
  3. demonstrate the access of the original jet ID using the skimmed jet collection by using the vector of edm::FwdRef.

void
FwdRefCheck::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
{
  edm::Handle<reco::CaloJetFwdRefVector> h_refs;
  edm::Handle<reco::JetIDValueMap> h_JetIDMap;
  
    iEvent.getByLabel( refVecSrc_, h_refs );
  iEvent.getByLabel( jetIDSrc_, h_JetIDMap );
  
  for ( reco::CaloJetFwdRefVector::const_iterator refsBegin = h_refs->begin(),
	  refsEnd = h_refs->end(), iref = refsBegin;
	iref != refsEnd; ++iref ) {
    reco::CaloJetFwdRef const & ref = *iref;
    reco::JetID jetId = (*h_JetIDMap)[ ref.backRef() ];

    std::cout << "Processing ref " << iref - refsBegin << ", ref idx = " << ref.key() << ", backref idx = " << ref.backRef().key() 
	      << ", jet pt = " << ref->pt() << ", n90Hits = " << jetId.n90Hits << std::endl;
  }
    
}

-- SalvatoreRoccoRappoccio - 20-Jan-2010

Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r2 - 2011-06-22 - ThiagoTomei
 
    • 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