CMS 3D CMS Logo

Public Member Functions | Private Types | Private Member Functions | Private Attributes

GenTrackMatcher Class Reference

Inheritance diagram for GenTrackMatcher:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 GenTrackMatcher (const edm::ParameterSet &)
 constructor

Private Types

typedef edm::Association
< reco::GenParticleCollection
GenParticleMatch

Private Member Functions

void produce (edm::Event &evt, const edm::EventSetup &es)

Private Attributes

edm::InputTag genParticles_
TrackHistory tracer_
edm::InputTag tracks_

Detailed Description

Author:
Luca Lista, INFN
Victor E. Bazterra, UIC
Version:
Id:
GenTrackMatcher.cc,v 1.6 2008/07/23 01:40:41 bazterra Exp

Definition at line 21 of file GenTrackMatcher.cc.


Member Typedef Documentation

Definition at line 31 of file GenTrackMatcher.cc.


Constructor & Destructor Documentation

GenTrackMatcher::GenTrackMatcher ( const edm::ParameterSet p)

constructor

Definition at line 44 of file GenTrackMatcher.cc.

                                                       :
        tracer_(p),
        tracks_(p.getUntrackedParameter<edm::InputTag>("trackProducer")),
        genParticles_(p.getUntrackedParameter<edm::InputTag>("genParticles"))
{
    produces<GenParticleMatch>();
}

Member Function Documentation

void GenTrackMatcher::produce ( edm::Event evt,
const edm::EventSetup es 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 52 of file GenTrackMatcher.cc.

References b, alignCSCRings::e, TrackHistory::evaluate(), Exception, f, edm::helper::Filler< Map >::fill(), spr::find(), HistoryBase::genParticle(), configurableAnalysis::GenParticle, genParticleCandidates2GenParticles_cfi::genParticles, genParticles_, edm::Event::getByLabel(), i, edm::helper::Filler< Map >::insert(), edm::errors::InvalidReference, match(), n, TrackHistory::newEvent(), edm::Event::put(), tracer_, testEve_cfg::tracks, and tracks_.

{
    Handle<View<Track> > tracks;
    evt.getByLabel(tracks_, tracks);
    Handle<vector<int> > barCodes;
    evt.getByLabel(genParticles_, barCodes);
    Handle<GenParticleCollection> genParticles;
    evt.getByLabel(genParticles_, genParticles);
    auto_ptr<GenParticleMatch> match(new GenParticleMatch(GenParticleRefProd(genParticles)));
    GenParticleMatch::Filler filler(*match);
    size_t n = tracks->size();
    vector<int> indices(n,-1);
    tracer_.newEvent(evt, es);
    for (size_t i = 0; i < n; ++ i )
    {
        RefToBase<Track> track(tracks, i);
        if (tracer_.evaluate(track))
        {
            const HepMC::GenParticle * particle = tracer_.genParticle();
            if (particle)
            {
                int barCode = particle->barcode();
                vector<int>::const_iterator b = barCodes->begin(), e = barCodes->end(), f = find( b, e, barCode );
                if (f == e) throw edm::Exception(errors::InvalidReference)
                    << "found matching particle with barcode" << *f
                    << " which has not been found in " << genParticles_;
                indices[i] = *f;
            }
        }
    }
    filler.insert(tracks, indices.begin(), indices.end());
    filler.fill();
    evt.put(match);
}

Member Data Documentation

Definition at line 30 of file GenTrackMatcher.cc.

Referenced by produce().

Definition at line 29 of file GenTrackMatcher.cc.

Referenced by produce().

Definition at line 30 of file GenTrackMatcher.cc.

Referenced by produce().