CMS 3D CMS Logo

GenTrackMatcher Class Reference

Author:
Luca Lista, INFN
More...

Inheritance diagram for GenTrackMatcher:

edm::EDProducer edm::ProducerBase 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

Author:
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

typedef edm::Association<reco::GenParticleCollection> GenTrackMatcher::GenParticleMatch [private]

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.

00044                                                        :
00045         tracer_(p),
00046         tracks_(p.getUntrackedParameter<edm::InputTag>("trackProducer")),
00047         genParticles_(p.getUntrackedParameter<edm::InputTag>("genParticles"))
00048 {
00049     produces<GenParticleMatch>();
00050 }


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, e, TrackHistory::evaluate(), f, edm::helper::Filler< Map >::fill(), find(), TrackHistory::genParticle(), genParticles_cfi::genParticles, genParticles_, edm::Event::getByLabel(), i, edm::helper::Filler< Map >::insert(), edm::errors::InvalidReference, edm::match(), n, TrackHistory::newEvent(), edm::Event::put(), tracer_, track, tracks, and tracks_.

00053 {
00054     Handle<View<Track> > tracks;
00055     evt.getByLabel(tracks_, tracks);
00056     Handle<vector<int> > barCodes;
00057     evt.getByLabel(genParticles_, barCodes);
00058     Handle<GenParticleCollection> genParticles;
00059     evt.getByLabel(genParticles_, genParticles);
00060     auto_ptr<GenParticleMatch> match(new GenParticleMatch(GenParticleRefProd(genParticles)));
00061     GenParticleMatch::Filler filler(*match);
00062     size_t n = tracks->size();
00063     vector<int> indices(n,-1);
00064     tracer_.newEvent(evt, es);
00065     for (size_t i = 0; i < n; ++ i )
00066     {
00067         RefToBase<Track> track(tracks, i);
00068         if (tracer_.evaluate(track))
00069         {
00070             const HepMC::GenParticle * particle = tracer_.genParticle();
00071             if (particle)
00072             {
00073                 int barCode = particle->barcode();
00074                 vector<int>::const_iterator b = barCodes->begin(), e = barCodes->end(), f = find( b, e, barCode );
00075                 if (f == e) throw edm::Exception(errors::InvalidReference)
00076                     << "found matching particle with barcode" << *f
00077                     << " which has not been found in " << genParticles_;
00078                 indices[i] = *f;
00079             }
00080         }
00081     }
00082     filler.insert(tracks, indices.begin(), indices.end());
00083     filler.fill();
00084     evt.put(match);
00085 }


Member Data Documentation

edm::InputTag GenTrackMatcher::genParticles_ [private]

Definition at line 30 of file GenTrackMatcher.cc.

Referenced by produce().

TrackHistory GenTrackMatcher::tracer_ [private]

Definition at line 29 of file GenTrackMatcher.cc.

Referenced by produce().

edm::InputTag GenTrackMatcher::tracks_ [private]

Definition at line 30 of file GenTrackMatcher.cc.

Referenced by produce().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:21:22 2009 for CMSSW by  doxygen 1.5.4