CMS 3D CMS Logo

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

#include <RecoBTag/FastPrimaryVertexProducer/src/FastPrimaryVertexProducer.cc>

Inheritance diagram for FastPrimaryVertexProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 FastPrimaryVertexProducer (const edm::ParameterSet &)
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

edm::EDGetTokenT< reco::BeamSpotm_beamSpot
 
double m_clusterLength
 
edm::EDGetTokenT< SiPixelClusterCollectionNewm_clusters
 
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > const m_geomToken
 
edm::EDGetTokenT< edm::View< reco::Jet > > m_jets
 
double m_maxDeltaPhi
 
double m_maxSizeX
 
double m_maxZ
 
edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > const m_pixelCPEToken
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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
 
- 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::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 73 of file FastPrimaryVertexProducer.cc.

Constructor & Destructor Documentation

◆ FastPrimaryVertexProducer()

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

Definition at line 91 of file FastPrimaryVertexProducer.cc.

References edm::ParameterSet::getParameter(), m_beamSpot, m_clusterLength, m_clusters, m_jets, m_maxDeltaPhi, m_maxSizeX, and m_maxZ.

94  m_clusters = consumes<SiPixelClusterCollectionNew>(iConfig.getParameter<edm::InputTag>("clusters"));
95  m_jets = consumes<edm::View<reco::Jet> >(iConfig.getParameter<edm::InputTag>("jets"));
96  m_beamSpot = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot"));
97  m_maxZ = iConfig.getParameter<double>("maxZ");
98  m_maxSizeX = iConfig.getParameter<double>("maxSizeX");
99  m_maxDeltaPhi = iConfig.getParameter<double>("maxDeltaPhi");
100  m_clusterLength = iConfig.getParameter<double>("clusterLength");
101  produces<reco::VertexCollection>();
102 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< edm::View< reco::Jet > > m_jets
edm::EDGetTokenT< SiPixelClusterCollectionNew > m_clusters
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > const m_geomToken
edm::EDGetTokenT< reco::BeamSpot > m_beamSpot
edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > const m_pixelCPEToken

Member Function Documentation

◆ produce()

void FastPrimaryVertexProducer::produce ( edm::StreamID  ,
edm::Event iEvent,
const edm::EventSetup iSetup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 104 of file FastPrimaryVertexProducer.cc.

References pwdgSkimBPark_cfi::beamSpot, dqmiodumpmetadata::counts, SiPixelRawToDigiRegional_cfi::deltaPhi, MillePedeFileConverter_cfg::e, edm::EventSetup::getData(), TrackerGeometry::idToDet(), TrackerGeometry::idToDetUnit(), iEvent, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, dqmiolumiharvest::j, PDWG_EXODelayedJetMET_cff::jets, m_beamSpot, m_clusterLength, m_clusters, m_geomToken, m_jets, m_maxDeltaPhi, m_maxSizeX, m_maxZ, m_pixelCPEToken, SiStripPI::max, eostools::move(), dqmiodumpmetadata::n, AlCaHLTBitMon_ParallelJobs::p, PV3DBase< T, PVType, FrameType >::phi(), DQMOffline_LumiMonitoring_cff::pixelClusters, GeomDet::position(), createTree::pp, edm::Handle< T >::product(), DiDispStaMuonMonitor_cfi::pt, multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, objectSelection_cff::selectedJets, edmNew::DetSet< T >::size(), SiPixelCluster::sizeX(), SiPixelCluster::sizeY(), jetUpdater_cfi::sort, GeomDet::surface(), Surface::toGlobal(), findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), z, and PV3DBase< T, PVType, FrameType >::z().

104  {
105  using namespace edm;
106  using namespace reco;
107  using namespace std;
108 
110  iEvent.getByToken(m_clusters, cH);
112 
114  iEvent.getByToken(m_jets, jH);
115  const edm::View<reco::Jet>& jets = *jH.product();
116 
118  for (edm::View<reco::Jet>::const_iterator it = jets.begin(); it != jets.end(); it++) {
119  if (it->pt() > 40 && fabs(it->eta()) < 1.6) {
120  const CaloJet* ca = dynamic_cast<const CaloJet*>(&(*it));
121  if (ca == nullptr)
122  abort();
123  selectedJets.push_back(*ca);
124  // std::cout << "Jet eta,phi,pt: "<< it->eta() << "," << it->phi() << "," << it->pt() << std::endl;
125  }
126  }
127 
129 
131  iEvent.getByToken(m_beamSpot, beamSpot);
132 
133  const TrackerGeometry* trackerGeometry = &iSetup.getData(m_geomToken);
134 
135  float lengthBmodule = 6.66; //cm
136  std::vector<float> zProjections;
137  for (CaloJetCollection::const_iterator jit = selectedJets.begin(); jit != selectedJets.end(); jit++) {
138  float px = jit->px();
139  float py = jit->py();
140  float pz = jit->pz();
141  float pt = jit->pt();
142 
143  float jetZOverRho = jit->momentum().Z() / jit->momentum().Rho();
144  int minSizeY = fabs(2. * jetZOverRho) - 1;
145  int maxSizeY = fabs(2. * jetZOverRho) + 2;
146  if (fabs(jit->eta()) > 1.6) {
147  minSizeY = 1;
148  }
149 
151  it++) //Loop on pixel modules with clusters
152  {
153  DetId id = it->detId();
154  const edmNew::DetSet<SiPixelCluster>& detset = (*it);
155  Point3DBase<float, GlobalTag> modulepos = trackerGeometry->idToDet(id)->position();
156  float zmodule = modulepos.z() -
157  ((modulepos.x() - beamSpot->x0()) * px + (modulepos.y() - beamSpot->y0()) * py) / pt * pz / pt;
158  if ((fabs(deltaPhi(jit->momentum().Phi(), modulepos.phi())) < m_maxDeltaPhi * 2) &&
159  (fabs(zmodule) < (m_maxZ + lengthBmodule / 2))) {
160  for (size_t j = 0; j < detset.size(); j++) // Loop on pixel clusters on this module
161  {
162  const SiPixelCluster& aCluster = detset[j];
163  if (aCluster.sizeX() < m_maxSizeX && aCluster.sizeY() >= minSizeY && aCluster.sizeY() <= maxSizeY) {
164  Point3DBase<float, GlobalTag> v = trackerGeometry->idToDet(id)->surface().toGlobal(
165  pp->localParametersV(aCluster, (*trackerGeometry->idToDetUnit(id)))[0].first);
166  GlobalPoint v_bs(v.x() - beamSpot->x0(), v.y() - beamSpot->y0(), v.z());
167  if (fabs(deltaPhi(jit->momentum().Phi(), v_bs.phi())) < m_maxDeltaPhi) {
168  float z = v.z() - ((v.x() - beamSpot->x0()) * px + (v.y() - beamSpot->y0()) * py) / pt * pz / pt;
169  if (fabs(z) < m_maxZ) {
170  zProjections.push_back(z);
171  }
172  }
173  } //if compatible cluster
174  } // loop on module hits
175  } // if compatible module
176  } // loop on pixel modules
177 
178  } // loop on selected jets
179  std::sort(zProjections.begin(), zProjections.end());
180 
181  std::vector<float>::iterator itCenter = zProjections.begin();
182  std::vector<float>::iterator itLeftSide = zProjections.begin();
183  std::vector<float>::iterator itRightSide = zProjections.begin();
184  std::vector<int> counts;
185  float zCluster = m_clusterLength / 2.0; //cm
186  int max = 0;
187  std::vector<float>::iterator left, right;
188  for (; itCenter != zProjections.end(); itCenter++) {
189  while (itLeftSide != zProjections.end() && (*itCenter - *itLeftSide) > zCluster)
190  itLeftSide++;
191  while (itRightSide != zProjections.end() && (*itRightSide - *itCenter) < zCluster)
192  itRightSide++;
193 
194  int n = itRightSide - itLeftSide;
195  // std::cout << "algo :"<< *itCenter << " " << itCenter-zProjections.begin() << " dists: " << (*itCenter - *itLeftSide) << " " << (*itRightSide - *itCenter) << " count: " << n << std::endl;
196  counts.push_back(n);
197  if (n > max) {
198  max = n;
199  left = itLeftSide;
200  }
201  if (n >= max) {
202  max = n;
203  right = itRightSide;
204  // std::cout << "algo :"<< i << " " << j << " " << *itCenter << " " << itCenter-zProjections.begin() << " dists: " << (*itCenter - *itLeftSide) << " " << (*itRightSide - *itCenter) << " count: " << n << std::endl;
205  }
206  }
207 
208  float res = 0;
209  if (!zProjections.empty()) {
210  res = *(left + (right - left) / 2);
211  // std::cout << "RES " << res << std::endl;
213  e(0, 0) = 0.0015 * 0.0015;
214  e(1, 1) = 0.0015 * 0.0015;
215  e(2, 2) = 1.5 * 1.5;
217  Vertex thePV(p, e, 1, 1, 0);
218  auto pOut = std::make_unique<reco::VertexCollection>();
219  pOut->push_back(thePV);
220  iEvent.put(std::move(pOut));
221  } else {
222  // std::cout << "DUMMY " << res << std::endl;
223 
225  e(0, 0) = 0.0015 * 0.0015;
226  e(1, 1) = 0.0015 * 0.0015;
227  e(2, 2) = 1.5 * 1.5;
229  Vertex thePV(p, e, 0, 0, 0);
230  auto pOut = std::make_unique<reco::VertexCollection>();
231  pOut->push_back(thePV);
232  iEvent.put(std::move(pOut));
233  }
234 }
Jets made from CaloTowers.
Definition: CaloJet.h:27
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
edm::EDGetTokenT< edm::View< reco::Jet > > m_jets
T z() const
Definition: PV3DBase.h:61
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
T const * product() const
Definition: Handle.h:70
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:45
int sizeY() const
Definition: Electron.h:6
edm::EDGetTokenT< SiPixelClusterCollectionNew > m_clusters
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
int iEvent
Definition: GenABIO.cc:224
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > const m_geomToken
int sizeX() const
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
edm::EDGetTokenT< reco::BeamSpot > m_beamSpot
const TrackerGeomDet * idToDet(DetId) const override
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
Definition: DetId.h:17
edm::ESGetToken< PixelClusterParameterEstimator, TkPixelCPERecord > const m_pixelCPEToken
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
size_type size() const
Definition: DetSetNew.h:65
Pixel cluster – collection of neighboring pixels above threshold.
fixed size matrix
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:88
def move(src, dest)
Definition: eostools.py:511
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects

Member Data Documentation

◆ m_beamSpot

edm::EDGetTokenT<reco::BeamSpot> FastPrimaryVertexProducer::m_beamSpot
private

Definition at line 84 of file FastPrimaryVertexProducer.cc.

Referenced by FastPrimaryVertexProducer(), and produce().

◆ m_clusterLength

double FastPrimaryVertexProducer::m_clusterLength
private

Definition at line 88 of file FastPrimaryVertexProducer.cc.

Referenced by FastPrimaryVertexProducer(), and produce().

◆ m_clusters

edm::EDGetTokenT<SiPixelClusterCollectionNew> FastPrimaryVertexProducer::m_clusters
private

Definition at line 82 of file FastPrimaryVertexProducer.cc.

Referenced by FastPrimaryVertexProducer(), and produce().

◆ m_geomToken

edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> const FastPrimaryVertexProducer::m_geomToken
private

Definition at line 80 of file FastPrimaryVertexProducer.cc.

Referenced by produce().

◆ m_jets

edm::EDGetTokenT<edm::View<reco::Jet> > FastPrimaryVertexProducer::m_jets
private

Definition at line 83 of file FastPrimaryVertexProducer.cc.

Referenced by FastPrimaryVertexProducer(), and produce().

◆ m_maxDeltaPhi

double FastPrimaryVertexProducer::m_maxDeltaPhi
private

Definition at line 87 of file FastPrimaryVertexProducer.cc.

Referenced by FastPrimaryVertexProducer(), and produce().

◆ m_maxSizeX

double FastPrimaryVertexProducer::m_maxSizeX
private

Definition at line 86 of file FastPrimaryVertexProducer.cc.

Referenced by FastPrimaryVertexProducer(), and produce().

◆ m_maxZ

double FastPrimaryVertexProducer::m_maxZ
private

Definition at line 85 of file FastPrimaryVertexProducer.cc.

Referenced by FastPrimaryVertexProducer(), and produce().

◆ m_pixelCPEToken

edm::ESGetToken<PixelClusterParameterEstimator, TkPixelCPERecord> const FastPrimaryVertexProducer::m_pixelCPEToken
private

Definition at line 81 of file FastPrimaryVertexProducer.cc.

Referenced by produce().