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 Types | Private Attributes
pat::PATTrackAndVertexUnpacker Class Reference
Inheritance diagram for pat::PATTrackAndVertexUnpacker:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PATTrackAndVertexUnpacker (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~PATTrackAndVertexUnpacker ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 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
 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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Types

typedef std::vector
< edm::InputTag
VInputTag
 

Private Attributes

edm::EDGetTokenT< std::vector
< pat::PackedCandidate > > 
AdditionalTracks_
 
edm::EDGetTokenT< std::vector
< pat::PackedCandidate > > 
Cands_
 
edm::EDGetTokenT
< reco::VertexCollection
PVs_
 
edm::EDGetTokenT
< reco::VertexCompositePtrCandidateCollection
SVs_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 28 of file TrackAndVertexUnpacker.cc.

Member Typedef Documentation

Definition at line 39 of file TrackAndVertexUnpacker.cc.

Constructor & Destructor Documentation

PATTrackAndVertexUnpacker::PATTrackAndVertexUnpacker ( const edm::ParameterSet iConfig)
explicit

Definition at line 53 of file TrackAndVertexUnpacker.cc.

53  :
54  Cands_(consumes< std::vector<pat::PackedCandidate> >(iConfig.getParameter<edm::InputTag>("packedCandidates"))),
55  PVs_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("slimmedVertices"))),
56  SVs_(consumes<reco::VertexCompositePtrCandidateCollection>(iConfig.getParameter<edm::InputTag>("slimmedSecondaryVertices"))),
57  AdditionalTracks_(consumes<pat::PackedCandidateCollection>(iConfig.getParameter<edm::InputTag>("additionalTracks")))
58 {
59  produces<reco::TrackCollection>();
60  produces<reco::VertexCollection>();
61  produces<reco::VertexCollection>("secondary");
62 }
T getParameter(std::string const &) const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< reco::VertexCompositePtrCandidateCollection > SVs_
edm::EDGetTokenT< std::vector< pat::PackedCandidate > > AdditionalTracks_
edm::EDGetTokenT< std::vector< pat::PackedCandidate > > Cands_
edm::EDGetTokenT< reco::VertexCollection > PVs_
PATTrackAndVertexUnpacker::~PATTrackAndVertexUnpacker ( )

Definition at line 65 of file TrackAndVertexUnpacker.cc.

65  {
66 }

Member Function Documentation

void PATTrackAndVertexUnpacker::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 69 of file TrackAndVertexUnpacker.cc.

References AdditionalTracks_, trackerHits::c, Cands_, pat::PackedCandidate::charge(), reco::CompositePtrCandidate::daughterPtr(), pat::PackedCandidate::fromPV(), edm::Event::getByToken(), i, edm::ProductID::id(), edm::Ptr< T >::id(), j, edm::Ptr< T >::key(), reco::CompositePtrCandidate::numberOfDaughters(), pat::PackedCandidate::numberOfHits(), pat::PackedCandidate::pseudoTrack(), edm::Event::put(), PVs_, pat::PackedCandidate::PVUsedInFit, alignCSCRings::r, dt_dqm_sourceclient_common_cff::reco, findQualityFiles::rr, SVs_, reco::LeafCandidate::vertex(), reco::VertexCompositePtrCandidate::vertexChi2(), reco::VertexCompositePtrCandidate::vertexCovariance(), and reco::VertexCompositePtrCandidate::vertexNdof().

69  {
70  using namespace edm; using namespace std; using namespace reco;
72  iEvent.getByToken(Cands_, cands);
74  iEvent.getByToken(PVs_, pvs);
76  iEvent.getByToken(SVs_, svs);
78  iEvent.getByToken(AdditionalTracks_, addTracks);
79 
80  std::auto_ptr< std::vector<reco::Track> > outTks( new std::vector<reco::Track> );
81  std::vector<unsigned int> asso;
82  std::map<unsigned int, unsigned int> trackKeys;
83  unsigned int j=0;
84  for(unsigned int i=0;i<cands->size();i++) {
85  const pat::PackedCandidate & c = (*cands)[i];
86  if(c.charge() != 0 && c.numberOfHits()> 0){
87  outTks->push_back(c.pseudoTrack());
89  {
90  asso.push_back(j);
91  }
92  trackKeys[i]=j;
93  j++;
94  }
95  }
96  reco::Vertex pv = (*pvs)[0];
97  std::auto_ptr< std::vector<reco::Vertex> > outPv( new std::vector<reco::Vertex> );
98  int offsetAdd=j;
99  for(unsigned int i = 0; i < addTracks->size(); i++) {
100  outTks->push_back((*addTracks)[i].pseudoTrack());
101  if((*addTracks)[i].fromPV()==pat::PackedCandidate::PVUsedInFit)
102  {
103 // std::cout << "USEDINFIT " << i <<std::endl;
104  asso.push_back(j);
105  }
106  j++;
107 
108  }
109  edm::OrphanHandle< std::vector<reco::Track> > oh = iEvent.put( outTks );
110  for(unsigned int i=0;i<asso.size();i++)
111  {
112  TrackRef r(oh,asso[i]);
113  TrackBaseRef rr(r);
114  pv.add(rr);
115  }
116  outPv->push_back(pv);
117  iEvent.put(outPv);
118 
119  std::auto_ptr< std::vector<reco::Vertex> > outSv( new std::vector<reco::Vertex> );
120  for(size_t i=0;i< svs->size(); i++) {
121  const reco::VertexCompositePtrCandidate &sv = (*svs)[i];
122  outSv->push_back(reco::Vertex(sv.vertex(),sv.vertexCovariance(),sv.vertexChi2(),sv.vertexNdof(),0));
123  for(size_t j=0;j<sv.numberOfDaughters();j++){
124  TrackRef r;
125  if(sv.daughterPtr(j).id() == cands.id()) {
126  r= TrackRef(oh,trackKeys[sv.daughterPtr(j).key()]); // use trackKeys because cand->track has gaps from neutral
127  } else {
128 // std::cout << "vertex " << i << " using lost Track " << sv.daughterPtr(j).key() << " " << offsetAdd+sv.daughterPtr(j).key() << std::endl;
129  r=TrackRef(oh,offsetAdd+sv.daughterPtr(j).key()); // use directly the key because addTracks is only charged
130  }
131  TrackBaseRef rr(r);
132  outSv->back().add(rr);
133 
134  }
135  }
136 
137  iEvent.put(outSv,"secondary");
138 
139 }
int i
Definition: DBlmapReader.cc:9
virtual double vertexChi2() const
chi-squares
int numberOfHits() const
CandidatePtr daughterPtr(size_type i) const
reference to daughter at given position
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
virtual const Point & vertex() const
vertex position (overwritten by PF...)
edm::EDGetTokenT< reco::VertexCompositePtrCandidateCollection > SVs_
virtual double vertexCovariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
virtual size_t numberOfDaughters() const
number of daughters
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:164
int j
Definition: DBlmapReader.cc:9
virtual int charge() const
electric charge
key_type key() const
Definition: Ptr.h:169
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:14
edm::EDGetTokenT< std::vector< pat::PackedCandidate > > AdditionalTracks_
edm::EDGetTokenT< std::vector< pat::PackedCandidate > > Cands_
ProductIndex id() const
Definition: ProductID.h:38
edm::EDGetTokenT< reco::VertexCollection > PVs_
const PVAssoc fromPV() const
virtual reco::Track pseudoTrack() const
Return by value (no caching heavy function) a pseudo track made with candidate kinematics, parameterized error for eta,phi,pt and full IP covariance.

Member Data Documentation

edm::EDGetTokenT<std::vector<pat::PackedCandidate> > pat::PATTrackAndVertexUnpacker::AdditionalTracks_
private

Definition at line 44 of file TrackAndVertexUnpacker.cc.

Referenced by produce().

edm::EDGetTokenT< std::vector<pat::PackedCandidate> > pat::PATTrackAndVertexUnpacker::Cands_
private

Definition at line 41 of file TrackAndVertexUnpacker.cc.

Referenced by produce().

edm::EDGetTokenT<reco::VertexCollection> pat::PATTrackAndVertexUnpacker::PVs_
private

Definition at line 42 of file TrackAndVertexUnpacker.cc.

Referenced by produce().

edm::EDGetTokenT<reco::VertexCompositePtrCandidateCollection> pat::PATTrackAndVertexUnpacker::SVs_
private

Definition at line 43 of file TrackAndVertexUnpacker.cc.

Referenced by produce().