test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
ShallowSimTracksProducer Class Reference

#include <ShallowSimTracksProducer.h>

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

Public Member Functions

 ShallowSimTracksProducer (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

Private Attributes

const edm::EDGetTokenT
< reco::TrackToTrackingParticleAssociator
associator_token_
 
const std::string Prefix
 
const std::string Suffix
 
const edm::EDGetTokenT
< TrackingParticleCollection
trackingParticles_token_
 
const edm::EDGetTokenT
< edm::View< reco::Track > > 
tracks_token_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 12 of file ShallowSimTracksProducer.h.

Constructor & Destructor Documentation

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

Definition at line 11 of file ShallowSimTracksProducer.cc.

References Prefix, and Suffix.

12  : Prefix( conf.getParameter<std::string>("Prefix") ),
13  Suffix( conf.getParameter<std::string>("Suffix") ),
14  trackingParticles_token_(consumes<TrackingParticleCollection>(conf.getParameter<edm::InputTag>("TrackingParticles"))),
15  associator_token_( consumes<reco::TrackToTrackingParticleAssociator>(conf.getParameter<edm::InputTag>("Associator"))),
17 {
18  produces <std::vector<unsigned> > ( Prefix + "multi" + Suffix );
19  produces <std::vector<int> > ( Prefix + "type" + Suffix );
20  produces <std::vector<float> > ( Prefix + "charge" + Suffix );
21  produces <std::vector<float> > ( Prefix + "momentum" + Suffix );
22  produces <std::vector<float> > ( Prefix + "pt" + Suffix );
23  produces <std::vector<double> > ( Prefix + "theta" + Suffix );
24  produces <std::vector<double> > ( Prefix + "phi" + Suffix );
25  produces <std::vector<double> > ( Prefix + "eta" + Suffix );
26  produces <std::vector<double> > ( Prefix + "qoverp" + Suffix );
27  produces <std::vector<double> > ( Prefix + "vx" + Suffix );
28  produces <std::vector<double> > ( Prefix + "vy" + Suffix );
29  produces <std::vector<double> > ( Prefix + "vz" + Suffix );
30 }
const edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > associator_token_
T getParameter(std::string const &) const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EDGetTokenT< edm::View< reco::Track > > tracks_token_
const edm::EDGetTokenT< TrackingParticleCollection > trackingParticles_token_

Member Function Documentation

void ShallowSimTracksProducer::produce ( edm::Event event,
const edm::EventSetup setup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 34 of file ShallowSimTracksProducer.cc.

References associator_token_, edm::AssociationMap< Tag >::begin(), RecoTauCleanerPlugins::charge, TrackingParticle::charge(), edm::AssociationMap< Tag >::const_iterator, edm::AssociationMap< Tag >::end(), eta, TrackingParticle::eta(), shallow::findTrackIndex(), edm::Ref< C, T, F >::get(), i, matches, trackerHitRTTI::multi, TrackingParticle::p(), TrackingParticle::parentVertex(), TrackingParticle::pdgId(), phi, TrackingParticle::phi(), TrackingVertex::position(), Prefix, EnergyCorrector::pt, TrackingParticle::pt(), findQualityFiles::size, Suffix, theta(), TrackingParticle::theta(), trackingTruthProducer_cfi::trackingParticles, trackingParticles_token_, testEve_cfg::tracks, and tracks_token_.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

34  {
35 
36  edm::Handle<edm::View<reco::Track> > tracks ; event.getByToken(tracks_token_, tracks);
38  edm::Handle<reco::TrackToTrackingParticleAssociator> associator ; event.getByToken(associator_token_, associator);
39 
40  unsigned size = tracks->size();
41  std::auto_ptr<std::vector<unsigned> > multi ( new std::vector<unsigned>(size, 0));
42  std::auto_ptr<std::vector<int> > type ( new std::vector<int> (size, 0));
43  std::auto_ptr<std::vector<float> > charge ( new std::vector<float> (size, 0));
44  std::auto_ptr<std::vector<float> > momentum ( new std::vector<float> (size, -1));
45  std::auto_ptr<std::vector<float> > pt ( new std::vector<float> (size, -1));
46  std::auto_ptr<std::vector<double> > theta ( new std::vector<double> (size,-1000));
47  std::auto_ptr<std::vector<double> > phi ( new std::vector<double> (size,-1000));
48  std::auto_ptr<std::vector<double> > eta ( new std::vector<double> (size,-1000));
49  std::auto_ptr<std::vector<double> > dxy ( new std::vector<double> (size,-1000));
50  std::auto_ptr<std::vector<double> > dsz ( new std::vector<double> (size,-1000));
51  std::auto_ptr<std::vector<double> > qoverp ( new std::vector<double> (size,-1000));
52  std::auto_ptr<std::vector<double> > vx ( new std::vector<double> (size,-1000));
53  std::auto_ptr<std::vector<double> > vy ( new std::vector<double> (size,-1000));
54  std::auto_ptr<std::vector<double> > vz ( new std::vector<double> (size,-1000));
55 
56  reco::RecoToSimCollection associations = associator->associateRecoToSim( tracks, trackingParticles);
57 
58  for( reco::RecoToSimCollection::const_iterator association = associations.begin();
59  association != associations.end(); association++) {
60 
61  const reco::Track* track = association->key.get();
62  const int matches = association->val.size();
63  if(matches>0) {
64  const TrackingParticle* tparticle = association->val[0].first.get();
65  unsigned i = shallow::findTrackIndex(tracks, track);
66 
67  multi->at(i) = matches;
68  type->at(i) = tparticle->pdgId();
69  charge->at(i)= tparticle->charge();
70  momentum->at(i)=tparticle->p() ;
71  pt->at(i) = tparticle->pt() ;
72  theta->at(i) = tparticle->theta() ;
73  phi->at(i) = tparticle->phi() ;
74  eta->at(i) = tparticle->eta() ;
75  qoverp->at(i)= tparticle->charge()/tparticle->p();
76 
77  const TrackingVertex* tvertex = tparticle->parentVertex().get();
78  vx->at(i) = tvertex->position().x();
79  vy->at(i) = tvertex->position().y();
80  vz->at(i) = tvertex->position().z();
81  }
82  }
83 
84  event.put( multi ,Prefix + "multi" + Suffix );
85  event.put( type ,Prefix + "type" + Suffix );
86  event.put( charge ,Prefix + "charge" + Suffix );
87  event.put( momentum ,Prefix + "momentum" + Suffix );
88  event.put( pt ,Prefix + "pt" + Suffix );
89  event.put( theta ,Prefix + "theta" + Suffix );
90  event.put( phi ,Prefix + "phi" + Suffix );
91  event.put( eta ,Prefix + "eta" + Suffix );
92  event.put( qoverp ,Prefix + "qoverp" + Suffix );
93  event.put( vx ,Prefix + "vx" + Suffix );
94  event.put( vy ,Prefix + "vy" + Suffix );
95  event.put( vz ,Prefix + "vz" + Suffix );
96 
97 }
type
Definition: HCALResponse.h:21
const edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > associator_token_
int i
Definition: DBlmapReader.cc:9
friend struct const_iterator
const_iterator end() const
last iterator over the map (read only)
int findTrackIndex(const edm::Handle< edm::View< reco::Track > > &h, const reco::Track *t)
Definition: ShallowTools.cc:28
int pdgId() const
PDG ID.
Geom::Theta< T > theta() const
double pt() const
Transverse momentum. Note this is taken from the first SimTrack only.
float charge() const
Electric charge. Note this is taken from the first SimTrack only.
double p() const
Magnitude of momentum vector. Note this is taken from the first SimTrack only.
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:244
const TrackingVertexRef & parentVertex() const
tuple tracks
Definition: testEve_cfg.py:39
double eta() const
Momentum pseudorapidity. Note this is taken from the first SimTrack only.
Monte Carlo truth information used for tracking validation.
const_iterator begin() const
first iterator over the map (read only)
const edm::EDGetTokenT< edm::View< reco::Track > > tracks_token_
const edm::EDGetTokenT< TrackingParticleCollection > trackingParticles_token_
tuple size
Write out results.
double phi() const
Momentum azimuthal angle. Note this is taken from the first SimTrack only.
double theta() const
Momentum polar angle. Note this is taken from the first SimTrack only.
const LorentzVector & position() const

Member Data Documentation

const edm::EDGetTokenT<reco::TrackToTrackingParticleAssociator> ShallowSimTracksProducer::associator_token_
private

Definition at line 23 of file ShallowSimTracksProducer.h.

Referenced by produce().

const std::string ShallowSimTracksProducer::Prefix
private

Definition at line 20 of file ShallowSimTracksProducer.h.

Referenced by produce(), and ShallowSimTracksProducer().

const std::string ShallowSimTracksProducer::Suffix
private

Definition at line 21 of file ShallowSimTracksProducer.h.

Referenced by produce(), and ShallowSimTracksProducer().

const edm::EDGetTokenT<TrackingParticleCollection> ShallowSimTracksProducer::trackingParticles_token_
private

Definition at line 22 of file ShallowSimTracksProducer.h.

Referenced by produce().

const edm::EDGetTokenT<edm::View<reco::Track> > ShallowSimTracksProducer::tracks_token_
private

Definition at line 24 of file ShallowSimTracksProducer.h.

Referenced by produce().