CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

ShallowSimTracksProducer Class Reference

#include <ShallowSimTracksProducer.h>

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

List of all members.

Public Member Functions

 ShallowSimTracksProducer (const edm::ParameterSet &)

Private Member Functions

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

Private Attributes

const edm::ESInputTag associator_tag
const std::string Prefix
const std::string Suffix
const edm::InputTag trackingParticles_tag
const edm::InputTag tracks_tag

Detailed Description

Definition at line 9 of file ShallowSimTracksProducer.h.


Constructor & Destructor Documentation

ShallowSimTracksProducer::ShallowSimTracksProducer ( const edm::ParameterSet conf) [explicit]

Definition at line 13 of file ShallowSimTracksProducer.cc.

References Prefix, and Suffix.

  : Prefix( conf.getParameter<std::string>("Prefix") ),
    Suffix( conf.getParameter<std::string>("Suffix") ),
    trackingParticles_tag( conf.getParameter<edm::InputTag>("TrackingParticles")),
    associator_tag( conf.getParameter<edm::ESInputTag>("Associator")),
    tracks_tag( conf.getParameter<edm::InputTag>("Tracks"))
{
  produces <std::vector<unsigned> >     ( Prefix + "multi"      + Suffix );
  produces <std::vector<int> >          ( Prefix + "type"      + Suffix );
  produces <std::vector<float> >        ( Prefix + "charge"    + Suffix );
  produces <std::vector<float> >        ( Prefix + "momentum"  + Suffix );
  produces <std::vector<float> >        ( Prefix + "pt"        + Suffix );
  produces <std::vector<double> >       ( Prefix + "theta"     + Suffix );
  produces <std::vector<double> >       ( Prefix + "phi"       + Suffix );
  produces <std::vector<double> >       ( Prefix + "eta"       + Suffix );
  produces <std::vector<double> >       ( Prefix + "qoverp"    + Suffix );
  produces <std::vector<double> >       ( Prefix + "vx"        + Suffix );
  produces <std::vector<double> >       ( Prefix + "vy"        + Suffix );
  produces <std::vector<double> >       ( Prefix + "vz"        + Suffix );
}

Member Function Documentation

void ShallowSimTracksProducer::produce ( edm::Event event,
const edm::EventSetup setup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 36 of file ShallowSimTracksProducer.cc.

References associator_tag, edm::AssociationMap< Tag >::begin(), ParticleBase::charge(), DeDxDiscriminatorTools::charge(), edm::AssociationMap< edm::OneToManyWithQualityGeneric< edm::View< reco::Track >, TrackingParticleCollection, double > >::const_iterator, edm::AssociationMap< Tag >::end(), ParticleBase::eta(), eta(), shallow::findTrackIndex(), edm::EventSetup::get(), edm::Ref< C, T, F >::get(), i, ParticleBase::p(), TrackingParticle::parentVertex(), TrackingParticle::pdgId(), ParticleBase::phi(), phi, TrackingVertex::position(), Prefix, ExpressReco_HICollisions_FallBack::pt, ParticleBase::pt(), findQualityFiles::size, Suffix, theta(), ParticleBase::theta(), ExpressReco_HICollisions_FallBack::track, trackingParticlesFastSim_cfi::trackingParticles, trackingParticles_tag, testEve_cfg::tracks, and tracks_tag.

                                                     {

  edm::Handle<edm::View<reco::Track> >                tracks ;   event.getByLabel( tracks_tag, tracks);
  edm::Handle<TrackingParticleCollection>  trackingParticles ;   event.getByLabel( trackingParticles_tag, trackingParticles );  
  edm::ESHandle<TrackAssociatorBase>              associator ;   setup.get<TrackAssociatorRecord>().get( associator_tag, associator);

  unsigned size = tracks->size();
  std::auto_ptr<std::vector<unsigned> > multi        ( new std::vector<unsigned>(size,    0));
  std::auto_ptr<std::vector<int> >      type         ( new std::vector<int>     (size,    0));
  std::auto_ptr<std::vector<float> >    charge       ( new std::vector<float>   (size,    0));
  std::auto_ptr<std::vector<float> >    momentum     ( new std::vector<float>   (size,   -1));
  std::auto_ptr<std::vector<float> >    pt           ( new std::vector<float>   (size,   -1));
  std::auto_ptr<std::vector<double> >   theta        ( new std::vector<double>  (size,-1000));
  std::auto_ptr<std::vector<double> >   phi          ( new std::vector<double>  (size,-1000));
  std::auto_ptr<std::vector<double> >   eta          ( new std::vector<double>  (size,-1000));
  std::auto_ptr<std::vector<double> >   dxy          ( new std::vector<double>  (size,-1000));
  std::auto_ptr<std::vector<double> >   dsz          ( new std::vector<double>  (size,-1000));
  std::auto_ptr<std::vector<double> >   qoverp       ( new std::vector<double>  (size,-1000));
  std::auto_ptr<std::vector<double> >   vx           ( new std::vector<double>  (size,-1000));
  std::auto_ptr<std::vector<double> >   vy           ( new std::vector<double>  (size,-1000));
  std::auto_ptr<std::vector<double> >   vz           ( new std::vector<double>  (size,-1000));

  reco::RecoToSimCollection associations = associator->associateRecoToSim( tracks, trackingParticles, &event );
  
  for( reco::RecoToSimCollection::const_iterator association = associations.begin(); 
       association != associations.end(); association++) {

    const reco::Track* track = association->key.get();
    const int matches        = association->val.size();
    if(matches>0) {
      const TrackingParticle* tparticle = association->val[0].first.get();
      unsigned i = shallow::findTrackIndex(tracks, track);

      multi->at(i) = matches;
      type->at(i)  = tparticle->pdgId();
      charge->at(i)= tparticle->charge();
      momentum->at(i)=tparticle->p() ;
      pt->at(i) = tparticle->pt()    ;
      theta->at(i) = tparticle->theta() ;
      phi->at(i)   = tparticle->phi()   ;
      eta->at(i)   = tparticle->eta()   ;
      qoverp->at(i)= tparticle->charge()/tparticle->p();

      const TrackingVertex* tvertex = tparticle->parentVertex().get();
      vx->at(i) = tvertex->position().x();
      vy->at(i) = tvertex->position().y();
      vz->at(i) = tvertex->position().z();
    }
  }
  
  event.put(  multi    ,Prefix + "multi"     + Suffix );
  event.put(  type     ,Prefix + "type"      + Suffix );
  event.put(  charge   ,Prefix + "charge"    + Suffix );
  event.put(  momentum ,Prefix + "momentum"  + Suffix );
  event.put(  pt       ,Prefix + "pt"        + Suffix );
  event.put(  theta    ,Prefix + "theta"     + Suffix );
  event.put(  phi      ,Prefix + "phi"       + Suffix );
  event.put(  eta      ,Prefix + "eta"       + Suffix );
  event.put(  qoverp   ,Prefix + "qoverp"    + Suffix );
  event.put(  vx       ,Prefix + "vx"        + Suffix );
  event.put(  vy       ,Prefix + "vy"        + Suffix );
  event.put(  vz       ,Prefix + "vz"        + Suffix );
  
}

Member Data Documentation

Definition at line 20 of file ShallowSimTracksProducer.h.

Referenced by produce().

const std::string ShallowSimTracksProducer::Prefix [private]

Definition at line 17 of file ShallowSimTracksProducer.h.

Referenced by produce(), and ShallowSimTracksProducer().

const std::string ShallowSimTracksProducer::Suffix [private]

Definition at line 18 of file ShallowSimTracksProducer.h.

Referenced by produce(), and ShallowSimTracksProducer().

Definition at line 19 of file ShallowSimTracksProducer.h.

Referenced by produce().

Definition at line 21 of file ShallowSimTracksProducer.h.

Referenced by produce().