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
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () 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
 
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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (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::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices 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::EDGetTokenT< edm::View< reco::Jet > > m_jets
 
double m_maxDeltaPhi
 
double m_maxSizeX
 
double m_maxZ
 
std::string m_pixelCPE
 

Additional Inherited Members

- 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
 
- 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<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
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)
 
template<Transition B>
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 (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

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 89 of file FastPrimaryVertexProducer.cc.

89  {
90  m_clusters = consumes<SiPixelClusterCollectionNew>(iConfig.getParameter<edm::InputTag>("clusters"));
91  m_jets = consumes<edm::View<reco::Jet> >(iConfig.getParameter<edm::InputTag>("jets"));
92  m_beamSpot = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot"));
93  m_pixelCPE = iConfig.getParameter<std::string>("pixelCPE");
94  m_maxZ = iConfig.getParameter<double>("maxZ");
95  m_maxSizeX = iConfig.getParameter<double>("maxSizeX");
96  m_maxDeltaPhi = iConfig.getParameter<double>("maxDeltaPhi");
97  m_clusterLength = iConfig.getParameter<double>("clusterLength");
98  produces<reco::VertexCollection>();
99 }

References edm::ParameterSet::getParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

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 101 of file FastPrimaryVertexProducer.cc.

101  {
102  using namespace edm;
103  using namespace reco;
104  using namespace std;
105 
107  iEvent.getByToken(m_clusters, cH);
109 
111  iEvent.getByToken(m_jets, jH);
112  const edm::View<reco::Jet>& jets = *jH.product();
113 
115  for (edm::View<reco::Jet>::const_iterator it = jets.begin(); it != jets.end(); it++) {
116  if (it->pt() > 40 && fabs(it->eta()) < 1.6) {
117  const CaloJet* ca = dynamic_cast<const CaloJet*>(&(*it));
118  if (ca == nullptr)
119  abort();
120  selectedJets.push_back(*ca);
121  // std::cout << "Jet eta,phi,pt: "<< it->eta() << "," << it->phi() << "," << it->pt() << std::endl;
122  }
123  }
124 
127  iSetup.get<TkPixelCPERecord>().get(m_pixelCPE, pe);
128  pp = pe.product();
129 
131  iEvent.getByToken(m_beamSpot, beamSpot);
132 
135  const TrackerGeometry* trackerGeometry = tracker.product();
136 
137  float lengthBmodule = 6.66; //cm
138  std::vector<float> zProjections;
139  for (CaloJetCollection::const_iterator jit = selectedJets.begin(); jit != selectedJets.end(); jit++) {
140  float px = jit->px();
141  float py = jit->py();
142  float pz = jit->pz();
143  float pt = jit->pt();
144 
145  float jetZOverRho = jit->momentum().Z() / jit->momentum().Rho();
146  int minSizeY = fabs(2. * jetZOverRho) - 1;
147  int maxSizeY = fabs(2. * jetZOverRho) + 2;
148  if (fabs(jit->eta()) > 1.6) {
149  minSizeY = 1;
150  }
151 
153  it++) //Loop on pixel modules with clusters
154  {
155  DetId id = it->detId();
156  const edmNew::DetSet<SiPixelCluster>& detset = (*it);
157  Point3DBase<float, GlobalTag> modulepos = trackerGeometry->idToDet(id)->position();
158  float zmodule = modulepos.z() -
159  ((modulepos.x() - beamSpot->x0()) * px + (modulepos.y() - beamSpot->y0()) * py) / pt * pz / pt;
160  if ((fabs(deltaPhi(jit->momentum().Phi(), modulepos.phi())) < m_maxDeltaPhi * 2) &&
161  (fabs(zmodule) < (m_maxZ + lengthBmodule / 2))) {
162  for (size_t j = 0; j < detset.size(); j++) // Loop on pixel clusters on this module
163  {
164  const SiPixelCluster& aCluster = detset[j];
165  if (aCluster.sizeX() < m_maxSizeX && aCluster.sizeY() >= minSizeY && aCluster.sizeY() <= maxSizeY) {
166  Point3DBase<float, GlobalTag> v = trackerGeometry->idToDet(id)->surface().toGlobal(
167  pp->localParametersV(aCluster, (*trackerGeometry->idToDetUnit(id)))[0].first);
168  GlobalPoint v_bs(v.x() - beamSpot->x0(), v.y() - beamSpot->y0(), v.z());
169  if (fabs(deltaPhi(jit->momentum().Phi(), v_bs.phi())) < m_maxDeltaPhi) {
170  float z = v.z() - ((v.x() - beamSpot->x0()) * px + (v.y() - beamSpot->y0()) * py) / pt * pz / pt;
171  if (fabs(z) < m_maxZ) {
172  zProjections.push_back(z);
173  }
174  }
175  } //if compatible cluster
176  } // loop on module hits
177  } // if compatible module
178  } // loop on pixel modules
179 
180  } // loop on selected jets
181  std::sort(zProjections.begin(), zProjections.end());
182 
183  std::vector<float>::iterator itCenter = zProjections.begin();
184  std::vector<float>::iterator itLeftSide = zProjections.begin();
185  std::vector<float>::iterator itRightSide = zProjections.begin();
186  std::vector<int> counts;
187  float zCluster = m_clusterLength / 2.0; //cm
188  int max = 0;
189  std::vector<float>::iterator left, right;
190  for (; itCenter != zProjections.end(); itCenter++) {
191  while (itLeftSide != zProjections.end() && (*itCenter - *itLeftSide) > zCluster)
192  itLeftSide++;
193  while (itRightSide != zProjections.end() && (*itRightSide - *itCenter) < zCluster)
194  itRightSide++;
195 
196  int n = itRightSide - itLeftSide;
197  // std::cout << "algo :"<< *itCenter << " " << itCenter-zProjections.begin() << " dists: " << (*itCenter - *itLeftSide) << " " << (*itRightSide - *itCenter) << " count: " << n << std::endl;
198  counts.push_back(n);
199  if (n > max) {
200  max = n;
201  left = itLeftSide;
202  }
203  if (n >= max) {
204  max = n;
205  right = itRightSide;
206  // std::cout << "algo :"<< i << " " << j << " " << *itCenter << " " << itCenter-zProjections.begin() << " dists: " << (*itCenter - *itLeftSide) << " " << (*itRightSide - *itCenter) << " count: " << n << std::endl;
207  }
208  }
209 
210  float res = 0;
211  if (!zProjections.empty()) {
212  res = *(left + (right - left) / 2);
213  // std::cout << "RES " << res << std::endl;
215  e(0, 0) = 0.0015 * 0.0015;
216  e(1, 1) = 0.0015 * 0.0015;
217  e(2, 2) = 1.5 * 1.5;
219  Vertex thePV(p, e, 1, 1, 0);
220  auto pOut = std::make_unique<reco::VertexCollection>();
221  pOut->push_back(thePV);
222  iEvent.put(std::move(pOut));
223  } else {
224  // std::cout << "DUMMY " << res << std::endl;
225 
227  e(0, 0) = 0.0015 * 0.0015;
228  e(1, 1) = 0.0015 * 0.0015;
229  e(2, 2) = 1.5 * 1.5;
231  Vertex thePV(p, e, 0, 0, 0);
232  auto pOut = std::make_unique<reco::VertexCollection>();
233  pOut->push_back(thePV);
234  iEvent.put(std::move(pOut));
235  }
236 }

References pwdgSkimBPark_cfi::beamSpot, dqmiodumpmetadata::counts, SiPixelRawToDigiRegional_cfi::deltaPhi, MillePedeFileConverter_cfg::e, edm::EventSetup::get(), get, TrackerGeometry::idToDet(), TrackerGeometry::idToDetUnit(), iEvent, dqmiolumiharvest::j, singleTopDQM_cfi::jets, SiStripPI::max, eostools::move(), dqmiodumpmetadata::n, AlCaHLTBitMon_ParallelJobs::p, PV3DBase< T, PVType, FrameType >::phi(), LumiMonitor_cff::pixelClusters, GeomDet::position(), createTree::pp, edm::Handle< T >::product(), edm::ESHandle< 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(), GeomDet::surface(), Surface::toGlobal(), PbPb_ZMuSkimMuonDPG_cff::tracker, findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Member Data Documentation

◆ m_beamSpot

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

Definition at line 81 of file FastPrimaryVertexProducer.cc.

◆ m_clusterLength

double FastPrimaryVertexProducer::m_clusterLength
private

Definition at line 86 of file FastPrimaryVertexProducer.cc.

◆ m_clusters

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

Definition at line 79 of file FastPrimaryVertexProducer.cc.

◆ m_jets

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

Definition at line 80 of file FastPrimaryVertexProducer.cc.

◆ m_maxDeltaPhi

double FastPrimaryVertexProducer::m_maxDeltaPhi
private

Definition at line 85 of file FastPrimaryVertexProducer.cc.

◆ m_maxSizeX

double FastPrimaryVertexProducer::m_maxSizeX
private

Definition at line 84 of file FastPrimaryVertexProducer.cc.

◆ m_maxZ

double FastPrimaryVertexProducer::m_maxZ
private

Definition at line 83 of file FastPrimaryVertexProducer.cc.

◆ m_pixelCPE

std::string FastPrimaryVertexProducer::m_pixelCPE
private

Definition at line 82 of file FastPrimaryVertexProducer.cc.

GeomDet::position
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
TrackerGeometry::idToDet
const TrackerGeomDet * idToDet(DetId) const override
Definition: TrackerGeometry.cc:193
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
PixelClusterParameterEstimator
Definition: PixelClusterParameterEstimator.h:15
reco::CaloJet
Jets made from CaloTowers.
Definition: CaloJet.h:27
pwdgSkimBPark_cfi.beamSpot
beamSpot
Definition: pwdgSkimBPark_cfi.py:5
LumiMonitor_cff.pixelClusters
pixelClusters
Definition: LumiMonitor_cff.py:10
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
edm::Handle::product
T const * product() const
Definition: Handle.h:70
FastPrimaryVertexProducer::m_clusters
edm::EDGetTokenT< SiPixelClusterCollectionNew > m_clusters
Definition: FastPrimaryVertexProducer.cc:79
FastPrimaryVertexProducer::m_beamSpot
edm::EDGetTokenT< reco::BeamSpot > m_beamSpot
Definition: FastPrimaryVertexProducer.cc:81
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
edm
HLT enums.
Definition: AlignableModifier.h:19
reco::Vertex::Error
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:44
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edmNew::DetSetVector::const_iterator
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
Definition: DetSetVectorNew.h:231
TkPixelCPERecord
Definition: TkPixelCPERecord.h:18
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
SiPixelCluster
Pixel cluster – collection of neighboring pixels above threshold.
Definition: SiPixelCluster.h:27
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
findQualityFiles.v
v
Definition: findQualityFiles.py:179
FastPrimaryVertexProducer::m_clusterLength
double m_clusterLength
Definition: FastPrimaryVertexProducer.cc:86
FastPrimaryVertexProducer::m_jets
edm::EDGetTokenT< edm::View< reco::Jet > > m_jets
Definition: FastPrimaryVertexProducer.cc:80
edm::Handle
Definition: AssociativeIterator.h:50
edmNew::DetSet::size
size_type size() const
Definition: DetSetNew.h:68
TrackerGeometry::idToDetUnit
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: TrackerGeometry.cc:183
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
DetId
Definition: DetId.h:17
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
SiPixelCluster::sizeY
int sizeY() const
Definition: SiPixelCluster.h:128
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
Surface::toGlobal
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79
DDAxes::z
edm::ESHandle
Definition: DTSurvey.h:22
edmNew::DetSet
Definition: DetSetNew.h:22
FastPrimaryVertexProducer::m_maxDeltaPhi
double m_maxDeltaPhi
Definition: FastPrimaryVertexProducer.cc:85
Point3DBase< float, GlobalTag >
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FastPrimaryVertexProducer::m_pixelCPE
std::string m_pixelCPE
Definition: FastPrimaryVertexProducer.cc:82
PbPb_ZMuSkimMuonDPG_cff.tracker
tracker
Definition: PbPb_ZMuSkimMuonDPG_cff.py:60
edm::View
Definition: CaloClusterFwd.h:14
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
iEvent
int iEvent
Definition: GenABIO.cc:224
reco::CaloJetCollection
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects
Definition: CaloJetCollection.h:15
get
#define get
res
Definition: Electron.h:6
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
edmNew::DetSetVector
Definition: DetSetNew.h:13
FastPrimaryVertexProducer::m_maxSizeX
double m_maxSizeX
Definition: FastPrimaryVertexProducer.cc:84
reco::Vertex::Point
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
dqmiodumpmetadata.counts
counts
Definition: dqmiodumpmetadata.py:25
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
objectSelection_cff.selectedJets
selectedJets
Definition: objectSelection_cff.py:99
createTree.pp
pp
Definition: createTree.py:17
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
SiPixelCluster::sizeX
int sizeX() const
Definition: SiPixelCluster.h:125
FastPrimaryVertexProducer::m_maxZ
double m_maxZ
Definition: FastPrimaryVertexProducer.cc:83
edm::InputTag
Definition: InputTag.h:15
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
reco::Vertex
Definition: Vertex.h:35
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
TrackerGeometry
Definition: TrackerGeometry.h:14