CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

JetChargeProducer Class Reference

#include <JetChargeProducer.h>

Inheritance diagram for JetChargeProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Types

typedef
reco::JetFloatAssociation::Container 
JetChargeCollection

Public Member Functions

 JetChargeProducer (const edm::ParameterSet &cfg)
virtual void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

JetCharge algo_
edm::InputTag src_

Detailed Description

Definition at line 13 of file JetChargeProducer.h.


Member Typedef Documentation

Definition at line 15 of file JetChargeProducer.h.


Constructor & Destructor Documentation

JetChargeProducer::JetChargeProducer ( const edm::ParameterSet cfg) [explicit]

Definition at line 3 of file JetChargeProducer.cc.

                                                               :
src_(cfg.getParameter<edm::InputTag>("src")),
algo_(cfg) {
    produces<JetChargeCollection>();
}

Member Function Documentation

void JetChargeProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 9 of file JetChargeProducer.cc.

References algo_, JetCharge::charge(), edm::Event::getByLabel(), metsig::jet, edm::Event::put(), runTheMatrix::ret, reco::JetExtendedAssociation::setValue(), src_, and testEve_cfg::tracks.

                                                                             {
    edm::Handle<reco::JetTracksAssociationCollection> hJTAs;
    iEvent.getByLabel(src_, hJTAs);
    typedef reco::JetTracksAssociationCollection::const_iterator IT;
    typedef edm::RefToBase<reco::Jet>  JetRef;

    if (hJTAs->keyProduct().isNull()) {
        // need to work around this bug someway, altough it's not stricly my fault
        std::auto_ptr<JetChargeCollection> ret(new JetChargeCollection());
        iEvent.put(ret);
        return;
    }
    std::auto_ptr<JetChargeCollection> ret(new JetChargeCollection(hJTAs->keyProduct()));
    for (IT it = hJTAs->begin(), ed = hJTAs->end(); it != ed; ++it) {
        const JetRef &jet = it->first;
        const reco::TrackRefVector &tracks = it->second;
        float  val = static_cast<float>( algo_.charge(jet->p4(), tracks) );
        reco::JetFloatAssociation::setValue(*ret, jet, val);
    }

    iEvent.put(ret);        
}

Member Data Documentation

Definition at line 21 of file JetChargeProducer.h.

Referenced by produce().

Definition at line 20 of file JetChargeProducer.h.

Referenced by produce().