CMS 3D CMS Logo

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)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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

Definition at line 74 of file PFTauSecondaryVertexProducer.cc.

References TransientTrackBuilder::build(), DEFINE_FWK_MODULE, edm::EventSetup::get(), edm::Event::getByToken(), edm::Event::getRefBeforePut(), TransientVertex::hasRefittedTracks(), edm::HandleBase::isValid(), eostools::move(), 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 AVPFTauSV = std::make_unique<edm::AssociationVector<PFTauRefProd, std::vector<std::vector<reco::VertexRef>>>>(PFTauRefProd(Tau));
84  auto VertexCollection_out = std::make_unique<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(std::move(VertexCollection_out),"PFTauSecondaryVertices");
122  iEvent.put(std::move(AVPFTauSV));
123 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
const edm::EDGetTokenT< std::vector< reco::PFTau > > PFTauToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
reco::TransientTrack build(const reco::Track *p) const
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
bool isValid() const
Definition: HandleBase.h:74
RefProd< PROD > getRefBeforePut()
Definition: Event.h:134
const T & get() const
Definition: EventSetup.h:56
std::vector< reco::TransientTrack > const & refittedTracks() const
def move(src, dest)
Definition: eostools.py:510

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().