CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
VertexTableProducer Class Reference

#include <PhysicsTools/VertexTableProducer/plugins/VertexTableProducer.cc>

Inheritance diagram for VertexTableProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 VertexTableProducer (const edm::ParameterSet &)
 
 ~VertexTableProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::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)
 
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)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

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

Private Attributes

const double dlenMin_
 
const double dlenSigMin_
 
const StringCutObjectSelector< reco::VertexgoodPvCut_
 
const std::string goodPvCutString_
 
const std::string pvName_
 
const edm::EDGetTokenT< std::vector< reco::Vertex > > pvs_
 
const edm::EDGetTokenT< edm::ValueMap< float > > pvsScore_
 
const StringCutObjectSelector< reco::CandidatesvCut_
 
const std::string svDoc_
 
const std::string svName_
 
const edm::EDGetTokenT< edm::View< reco::VertexCompositePtrCandidate > > svs_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase 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
 
- 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

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 48 of file VertexTableProducer.cc.

Constructor & Destructor Documentation

VertexTableProducer::VertexTableProducer ( const edm::ParameterSet params)
explicit

Definition at line 85 of file VertexTableProducer.cc.

85  :
86  pvs_(consumes<std::vector<reco::Vertex>>( params.getParameter<edm::InputTag>("pvSrc") )),
89  svCut_(params.getParameter<std::string>("svCut") , true),
90  goodPvCut_(params.getParameter<std::string>("goodPvCut") , true),
91  goodPvCutString_(params.getParameter<std::string>("goodPvCut") ),
92  pvName_(params.getParameter<std::string>("pvName") ),
93  svName_(params.getParameter<std::string>("svName") ),
94  svDoc_(params.getParameter<std::string>("svDoc") ),
95  dlenMin_(params.getParameter<double>("dlenMin") ),
96  dlenSigMin_(params.getParameter<double>("dlenSigMin") )
97 
98 {
99  produces<nanoaod::FlatTable>("pv");
100  produces<nanoaod::FlatTable>("otherPVs");
101  produces<nanoaod::FlatTable>("svs");
102  produces<edm::PtrVector<reco::Candidate> >();
103 
104 }
T getParameter(std::string const &) const
const edm::EDGetTokenT< std::vector< reco::Vertex > > pvs_
const std::string pvName_
const std::string svDoc_
const edm::EDGetTokenT< edm::ValueMap< float > > pvsScore_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const std::string goodPvCutString_
const edm::EDGetTokenT< edm::View< reco::VertexCompositePtrCandidate > > svs_
const std::string svName_
const StringCutObjectSelector< reco::Vertex > goodPvCut_
const StringCutObjectSelector< reco::Candidate > svCut_
VertexTableProducer::~VertexTableProducer ( )
override

Definition at line 107 of file VertexTableProducer.cc.

108 {
109 
110  // do anything here that needs to be done at destruction time
111  // (e.g. close files, deallocate resources etc.)
112 
113 }

Member Function Documentation

void VertexTableProducer::beginStream ( edm::StreamID  )
overrideprivatevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 189 of file VertexTableProducer.cc.

190 {
191 }
void VertexTableProducer::endStream ( )
overrideprivatevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 195 of file VertexTableProducer.cc.

195  {
196 }
void VertexTableProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 200 of file VertexTableProducer.cc.

References edm::ConfigurationDescriptions::addDefault(), DEFINE_FWK_MODULE, and edm::ParameterSetDescription::setUnknown().

200  {
201  //The following says we do not know what parameters are allowed so do no validation
202  // Please change this to state exactly what you do use, even if it is no parameters
204  desc.setUnknown();
205  descriptions.addDefault(desc);
206 }
void addDefault(ParameterSetDescription const &psetDescription)
void VertexTableProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 124 of file VertexTableProducer.cc.

References EnergyCorrector::c, RecoVertex::convertError(), RecoVertex::convertPos(), VertexDistance3D::distance(), dlenMin_, dlenSigMin_, PVValHelper::dx, PVValHelper::dy, PVValHelper::dz, nanoaod::FlatTable::FloatColumn, edm::Event::getByToken(), goodPvCut_, goodPvCutString_, AlcaRecoSelection_cff::goodPVs, mps_fire::i, nanoaod::FlatTable::IntColumn, eostools::move(), edm::Event::put(), MetAnalyzer::pv(), pvName_, pvs_, pvsScore_, Measurement1D::significance(), pfDeepBoostedJetPreprocessParams_cfi::sv, svCut_, svName_, svs_, and Measurement1D::value().

125 {
126  using namespace edm;
129  iEvent.getByToken(pvs_, pvsIn);
130  iEvent.getByToken(pvsScore_, pvsScoreIn);
131  auto pvTable = std::make_unique<nanoaod::FlatTable>(1,pvName_,true);
132  pvTable->addColumnValue<float>("ndof",(*pvsIn)[0].ndof(),"main primary vertex number of degree of freedom",nanoaod::FlatTable::FloatColumn,8);
133  pvTable->addColumnValue<float>("x",(*pvsIn)[0].position().x(),"main primary vertex position x coordinate",nanoaod::FlatTable::FloatColumn,10);
134  pvTable->addColumnValue<float>("y",(*pvsIn)[0].position().y(),"main primary vertex position y coordinate",nanoaod::FlatTable::FloatColumn,10);
135  pvTable->addColumnValue<float>("z",(*pvsIn)[0].position().z(),"main primary vertex position z coordinate",nanoaod::FlatTable::FloatColumn,16);
136  pvTable->addColumnValue<float>("chi2",(*pvsIn)[0].normalizedChi2(),"main primary vertex reduced chi2",nanoaod::FlatTable::FloatColumn,8);
137  int goodPVs=0;
138  for (const auto & pv : *pvsIn) if (goodPvCut_(pv)) goodPVs++;
139  pvTable->addColumnValue<int>("npvs",(*pvsIn).size(),"total number of reconstructed primary vertices",nanoaod::FlatTable::IntColumn);
140  pvTable->addColumnValue<int>("npvsGood",goodPVs,"number of good reconstructed primary vertices. selection:"+goodPvCutString_,nanoaod::FlatTable::IntColumn);
141  pvTable->addColumnValue<float>("score",(*pvsScoreIn).get(pvsIn.id(),0),"main primary vertex score, i.e. sum pt2 of clustered objects",nanoaod::FlatTable::FloatColumn,8);
142 
143  auto otherPVsTable = std::make_unique<nanoaod::FlatTable>((*pvsIn).size() >4?3:(*pvsIn).size()-1,"Other"+pvName_,false);
144  std::vector<float> pvsz;
145  for(size_t i=1;i < (*pvsIn).size() && i < 4; i++) pvsz.push_back((*pvsIn)[i-1].position().z());
146  otherPVsTable->addColumn<float>("z",pvsz,"Z position of other primary vertices, excluding the main PV",nanoaod::FlatTable::FloatColumn,8);
147 
148 
150  iEvent.getByToken(svs_, svsIn);
151  auto selCandSv = std::make_unique<PtrVector<reco::Candidate>>();
152  std::vector<float> dlen,dlenSig,pAngle;
153  VertexDistance3D vdist;
154 
155  size_t i=0;
156  const auto & PV0 = pvsIn->front();
157  for (const auto & sv : *svsIn) {
158  if (svCut_(sv)) {
160  if(dl.value() > dlenMin_ and dl.significance() > dlenSigMin_){
161  dlen.push_back(dl.value());
162  dlenSig.push_back(dl.significance());
163  edm::Ptr<reco::Candidate> c = svsIn->ptrAt(i);
164  selCandSv->push_back(c);
165  double dx = (PV0.x() - sv.vx()), dy = (PV0.y() - sv.vy()), dz = (PV0.z() - sv.vz());
166  double pdotv = (dx * sv.px() + dy*sv.py() + dz*sv.pz())/sv.p();
167  pAngle.push_back(std::acos(pdotv));
168  }
169  }
170  i++;
171  }
172 
173 
174  auto svsTable = std::make_unique<nanoaod::FlatTable>(selCandSv->size(),svName_,false);
175  // For SV we fill from here only stuff that cannot be created with the SimpleFlatTableProducer
176  svsTable->addColumn<float>("dlen",dlen,"decay length in cm",nanoaod::FlatTable::FloatColumn,10);
177  svsTable->addColumn<float>("dlenSig",dlenSig,"decay length significance",nanoaod::FlatTable::FloatColumn, 10);
178  svsTable->addColumn<float>("pAngle",pAngle,"pointing angle, i.e. acos(p_SV * (SV - PV)) ",nanoaod::FlatTable::FloatColumn,10);
179 
180 
181  iEvent.put(std::move(pvTable),"pv");
182  iEvent.put(std::move(otherPVsTable),"otherPVs");
183  iEvent.put(std::move(svsTable),"svs");
184  iEvent.put(std::move(selCandSv));
185 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
const edm::EDGetTokenT< std::vector< reco::Vertex > > pvs_
const std::string pvName_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
const edm::EDGetTokenT< edm::ValueMap< float > > pvsScore_
const std::string goodPvCutString_
Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const override
goodPVs
Good Primary Vertex Selection.
const edm::EDGetTokenT< edm::View< reco::VertexCompositePtrCandidate > > svs_
def pv(vc)
Definition: MetAnalyzer.py:6
double significance() const
Definition: Measurement1D.h:32
double value() const
Definition: Measurement1D.h:28
const std::string svName_
HLT enums.
const StringCutObjectSelector< reco::Vertex > goodPvCut_
const StringCutObjectSelector< reco::Candidate > svCut_
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

const double VertexTableProducer::dlenMin_
private

Definition at line 76 of file VertexTableProducer.cc.

Referenced by produce().

const double VertexTableProducer::dlenSigMin_
private

Definition at line 76 of file VertexTableProducer.cc.

Referenced by produce().

const StringCutObjectSelector<reco::Vertex> VertexTableProducer::goodPvCut_
private

Definition at line 71 of file VertexTableProducer.cc.

Referenced by produce().

const std::string VertexTableProducer::goodPvCutString_
private

Definition at line 72 of file VertexTableProducer.cc.

Referenced by produce().

const std::string VertexTableProducer::pvName_
private

Definition at line 73 of file VertexTableProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<std::vector<reco::Vertex> > VertexTableProducer::pvs_
private

Definition at line 67 of file VertexTableProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<edm::ValueMap<float> > VertexTableProducer::pvsScore_
private

Definition at line 68 of file VertexTableProducer.cc.

Referenced by produce().

const StringCutObjectSelector<reco::Candidate> VertexTableProducer::svCut_
private

Definition at line 70 of file VertexTableProducer.cc.

Referenced by produce().

const std::string VertexTableProducer::svDoc_
private

Definition at line 75 of file VertexTableProducer.cc.

const std::string VertexTableProducer::svName_
private

Definition at line 74 of file VertexTableProducer.cc.

Referenced by produce().

const edm::EDGetTokenT<edm::View<reco::VertexCompositePtrCandidate> > VertexTableProducer::svs_
private

Definition at line 69 of file VertexTableProducer.cc.

Referenced by produce().