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
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 PFTauSecondaryVertexProducer (const edm::ParameterSet &iConfig)
 
void produce (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
 ~PFTauSecondaryVertexProducer () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
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, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- 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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) 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 ( )
override

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
override

Definition at line 74 of file PFTauSecondaryVertexProducer.cc.

References TransientTrackBuilder::build(), egammaForCoreTracking_cff::cands, 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(), nanoDQM_cfi::SV, 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  if(transTrk.size() > 1) {
107  try{
108  transVtx = kvf.vertex(transTrk); //KalmanVertexFitter
109  }catch(...){
110  FitOk=false;
111  }
112  } else {
113  FitOk = false;
114  }
115  if(!transVtx.hasRefittedTracks()) FitOk=false;
116  if(transVtx.refittedTracks().size()!=transTrk.size()) FitOk=false;
117  if(FitOk){
118  SV.push_back(reco::VertexRef(VertexRefProd_out, VertexCollection_out->size()));
119  VertexCollection_out->push_back(transVtx);
120  }
121  }
122  AVPFTauSV->setValue(iPFTau, SV);
123  }
124  }
125  iEvent.put(std::move(VertexCollection_out),"PFTauSecondaryVertices");
126  iEvent.put(std::move(AVPFTauSV));
127 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
const edm::EDGetTokenT< std::vector< reco::PFTau > > PFTauToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
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:167
T get() const
Definition: EventSetup.h:63
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().