CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
PFTauSecondaryVertexProducer Class Reference
Inheritance diagram for PFTauSecondaryVertexProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

enum  Alg { useInputPV =0, usePVwithMaxSumPt, useTauPV }
 
- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 PFTauSecondaryVertexProducer (const edm::ParameterSet &iConfig)
 
virtual void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
 ~PFTauSecondaryVertexProducer ()
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- 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 Attributes

const edm::InputTag PFTauTag_
 
const edm::EDGetTokenT
< std::vector< reco::PFTau > > 
PFTauToken_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::global::EDProducerBase
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 50 of file PFTauSecondaryVertexProducer.cc.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Definition at line 62 of file PFTauSecondaryVertexProducer.cc.

62  :
63  PFTauTag_(iConfig.getParameter<edm::InputTag>("PFTauTag")),
64  PFTauToken_(consumes<std::vector<reco::PFTau> >(iConfig.getParameter<edm::InputTag>("PFTauTag")))
65 {
66  produces<edm::AssociationVector<PFTauRefProd, std::vector<std::vector<reco::VertexRef> > > >();
67  produces<VertexCollection>("PFTauSecondaryVertices");
68 }
T getParameter(std::string const &) const
const edm::EDGetTokenT< std::vector< reco::PFTau > > PFTauToken_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
PFTauSecondaryVertexProducer::~PFTauSecondaryVertexProducer ( )

Definition at line 70 of file PFTauSecondaryVertexProducer.cc.

70  {
71 
72 }

Member Function Documentation

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

Implements edm::global::EDProducerBase.

Definition at line 74 of file PFTauSecondaryVertexProducer.cc.

References edm::EventSetup::get(), edm::Event::getByToken(), edm::Event::getRefBeforePut(), TransientVertex::hasRefittedTracks(), edm::HandleBase::isValid(), PFTauToken_, edm::Event::put(), TransientVertex::refittedTracks(), and KalmanVertexFitter::vertex().

74  {
75  // Obtain
76  edm::ESHandle<TransientTrackBuilder> transTrackBuilder;
77  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",transTrackBuilder);
78 
80  iEvent.getByToken(PFTauToken_,Tau);
81 
82  // Set Association Map
83  auto_ptr<edm::AssociationVector<PFTauRefProd, std::vector<std::vector<reco::VertexRef> > > > AVPFTauSV(new edm::AssociationVector<PFTauRefProd, std::vector<std::vector<reco::VertexRef> > >(PFTauRefProd(Tau)));
84  std::auto_ptr<VertexCollection> VertexCollection_out= std::auto_ptr<VertexCollection>(new VertexCollection);
85  reco::VertexRefProd VertexRefProd_out = iEvent.getRefBeforePut<reco::VertexCollection>("PFTauSecondaryVertices");
86 
87  // For each Tau Run Algorithim
88  if(Tau.isValid()) {
89  for(reco::PFTauCollection::size_type iPFTau = 0; iPFTau < Tau->size(); iPFTau++) {
90  reco::PFTauRef RefPFTau(Tau, iPFTau);
91  std::vector<reco::VertexRef> SV;
92  if(RefPFTau->decayMode()>=5){
94  // Get tracks form PFTau daugthers
95  std::vector<reco::TransientTrack> transTrk;
96  TransientVertex transVtx;
97  const std::vector<edm::Ptr<reco::PFCandidate> > cands = RefPFTau->signalPFChargedHadrCands();
98  for (std::vector<edm::Ptr<reco::PFCandidate> >::const_iterator iter = cands.begin(); iter!=cands.end(); ++iter) {
99  if(iter->get()->trackRef().isNonnull())transTrk.push_back(transTrackBuilder->build(iter->get()->trackRef()));
100  else if(iter->get()->gsfTrackRef().isNonnull())transTrk.push_back(transTrackBuilder->build(iter->get()->gsfTrackRef()));
101  }
103  // Fit the secondary vertex
104  bool FitOk(true);
105  KalmanVertexFitter kvf(true);
106  try{
107  transVtx = kvf.vertex(transTrk); //KalmanVertexFitter
108  }catch(...){
109  FitOk=false;
110  }
111  if(!transVtx.hasRefittedTracks()) FitOk=false;
112  if(transVtx.refittedTracks().size()!=transTrk.size()) FitOk=false;
113  if(FitOk){
114  SV.push_back(reco::VertexRef(VertexRefProd_out, VertexCollection_out->size()));
115  VertexCollection_out->push_back(transVtx);
116  }
117  }
118  AVPFTauSV->setValue(iPFTau, SV);
119  }
120  }
121  iEvent.put(VertexCollection_out,"PFTauSecondaryVertices");
122  iEvent.put(AVPFTauSV);
123 }
const edm::EDGetTokenT< std::vector< reco::PFTau > > PFTauToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
bool hasRefittedTracks() const
edm::RefProd< PFTauCollection > PFTauRefProd
references to PFTau collection
Definition: PFTauFwd.h:15
uint16_t size_type
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
bool isValid() const
Definition: HandleBase.h:75
RefProd< PROD > getRefBeforePut()
Definition: Event.h:141
const T & get() const
Definition: EventSetup.h:56
std::vector< reco::TransientTrack > const & refittedTracks() const

Member Data Documentation

const edm::InputTag PFTauSecondaryVertexProducer::PFTauTag_
private

Definition at line 58 of file PFTauSecondaryVertexProducer.cc.

const edm::EDGetTokenT<std::vector<reco::PFTau> > PFTauSecondaryVertexProducer::PFTauToken_
private

Definition at line 59 of file PFTauSecondaryVertexProducer.cc.

Referenced by produce().