CMS 3D CMS Logo

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

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

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

Public Member Functions

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

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

virtual void produce (edm::Event &, const edm::EventSetup &)
 

Private Attributes

edm::EDGetTokenT< reco::BeamSpotbeamSpotToken
 
edm::EDGetTokenT< SiPixelClusterCollectionNewclustersToken
 
edm::EDGetTokenT< edm::View< reco::Jet > > jetsToken
 
const bool m_barrel
 
const edm::InputTag m_clusters
 
const double m_EC_weight
 
const bool m_endCap
 
const double m_maxDeltaPhi
 
const double m_maxDeltaPhi_EC
 
const double m_maxJetEta
 
const double m_maxJetEta_EC
 
const double m_maxSizeX
 
const double m_maxSizeY_q
 
const double m_maxZ
 
const double m_minJetEta_EC
 
const double m_minJetPt
 
const double m_minSizeY_q
 
const int m_njets
 
const double m_peakSizeY_q
 
const double m_PixelCellHeightOverWidth
 
std::string m_pixelCPE
 
const bool m_ptWeighting
 
const double m_ptWeighting_offset
 
const double m_ptWeighting_slope
 
const double m_weight_charge_down
 
const double m_weight_charge_peak
 
const double m_weight_charge_up
 
const double m_weight_dPhi
 
const double m_weight_dPhi_EC
 
const double m_weight_rho_up
 
const double m_weight_SizeX1
 
const double m_weightCut_step2
 
const double m_weightCut_step3
 
const double m_zClusterSearchArea_step2
 
const double m_zClusterSearchArea_step3
 
const double m_zClusterWidth_step1
 
const double m_zClusterWidth_step2
 
const double m_zClusterWidth_step3
 

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
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: The FastPrimaryVertex is an algorithm used to find the primary vertex of an event . It takes the pixel clusters compabible with a jet and project it to the beamSpot with the eta-angle of the jet. The peak on the z-projected clusters distribution is our FastPrimaryVertex.

Implementation: [Notes on implementation]

Definition at line 56 of file FastPrimaryVertexWithWeightsProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 125 of file FastPrimaryVertexWithWeightsProducer.cc.

References beamSpotToken, clustersToken, edm::ParameterSet::getParameter(), and jetsToken.

125  :
126  m_maxZ(iConfig.getParameter<double>("maxZ")),
127  m_pixelCPE(iConfig.getParameter<std::string>("pixelCPE")),
128 
129  m_njets(iConfig.getParameter<int>("njets")),
130  m_maxJetEta(iConfig.getParameter<double>("maxJetEta")),
131  m_minJetPt(iConfig.getParameter<double>("minJetPt")),
132 
133  m_barrel(iConfig.getParameter<bool>("barrel")),
134  m_maxSizeX(iConfig.getParameter<double>("maxSizeX")),
135  m_maxDeltaPhi(iConfig.getParameter<double>("maxDeltaPhi")),
136  m_weight_charge_down(iConfig.getParameter<double>("weight_charge_down")),
137  m_weight_charge_up(iConfig.getParameter<double>("weight_charge_up")),
138  m_PixelCellHeightOverWidth(iConfig.getParameter<double>("PixelCellHeightOverWidth")),
139  m_minSizeY_q(iConfig.getParameter<double>("minSizeY_q")),
140  m_maxSizeY_q(iConfig.getParameter<double>("maxSizeY_q")),
141 
142  m_weight_dPhi(iConfig.getParameter<double>("weight_dPhi")),
143  m_weight_SizeX1(iConfig.getParameter<double>("weight_SizeX1")),
144  m_weight_rho_up(iConfig.getParameter<double>("weight_rho_up")),
145  m_weight_charge_peak(iConfig.getParameter<double>("weight_charge_peak")),
146  m_peakSizeY_q(iConfig.getParameter<double>("peakSizeY_q")),
147 
148  m_endCap(iConfig.getParameter<bool>("endCap")),
149  m_minJetEta_EC(iConfig.getParameter<double>("minJetEta_EC")),
150  m_maxJetEta_EC(iConfig.getParameter<double>("maxJetEta_EC")),
151  m_maxDeltaPhi_EC(iConfig.getParameter<double>("maxDeltaPhi_EC")),
152  m_EC_weight(iConfig.getParameter<double>("EC_weight")),
153  m_weight_dPhi_EC(iConfig.getParameter<double>("weight_dPhi_EC")),
154 
155  m_zClusterWidth_step1(iConfig.getParameter<double>("zClusterWidth_step1")),
156 
157  m_zClusterWidth_step2(iConfig.getParameter<double>("zClusterWidth_step2")),
158  m_zClusterSearchArea_step2(iConfig.getParameter<double>("zClusterSearchArea_step2")),
159  m_weightCut_step2(iConfig.getParameter<double>("weightCut_step2")),
160 
161  m_zClusterWidth_step3(iConfig.getParameter<double>("zClusterWidth_step3")),
162  m_zClusterSearchArea_step3(iConfig.getParameter<double>("zClusterSearchArea_step3")),
163  m_weightCut_step3(iConfig.getParameter<double>("weightCut_step3")),
164 
165  m_ptWeighting(iConfig.getParameter<bool>("ptWeighting")),
166  m_ptWeighting_slope(iConfig.getParameter<double>("ptWeighting_slope")),
167  m_ptWeighting_offset(iConfig.getParameter<double>("ptWeighting_offset"))
168 {
169 
170  clustersToken = consumes<SiPixelClusterCollectionNew>(iConfig.getParameter<edm::InputTag>("clusters"));
171  beamSpotToken = consumes<reco::BeamSpot>(iConfig.getParameter<edm::InputTag>("beamSpot"));
172  jetsToken = consumes<edm::View<reco::Jet> >(iConfig.getParameter<edm::InputTag>("jets"));
173 
174  produces<reco::VertexCollection>();
175  produces<float>();
176 
177 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::View< reco::Jet > > jetsToken
edm::EDGetTokenT< SiPixelClusterCollectionNew > clustersToken

Member Function Documentation

void FastPrimaryVertexWithWeightsProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 180 of file FastPrimaryVertexWithWeightsProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and AlCaHLTBitMon_QueryRunRegistry::string.

181 {
183  desc.add<edm::InputTag> ("clusters",edm::InputTag("hltSiPixelClusters"));
184  desc.add<edm::InputTag> ("beamSpot",edm::InputTag("hltOnlineBeamSpot"));
185  desc.add<edm::InputTag> ("jets",edm::InputTag("hltCaloJetL1FastJetCorrected"));
186  desc.add<std::string>("pixelCPE","hltESPPixelCPEGeneric");
187  desc.add<double>("maxZ",19.0);
188  desc.add<int>("njets",999);
189  desc.add<double>("maxJetEta",2.6);
190  desc.add<double>("minJetPt",40.);
191  desc.add<bool>("barrel",true);
192  desc.add<double>("maxSizeX",2.1);
193  desc.add<double>("maxDeltaPhi",0.21);
194  desc.add<double>("PixelCellHeightOverWidth",1.8);
195  desc.add<double>("weight_charge_down",11.*1000.);
196  desc.add<double>("weight_charge_up",190.*1000.);
197  desc.add<double>("maxSizeY_q",2.0);
198  desc.add<double>("minSizeY_q",-0.6);
199  desc.add<double>("weight_dPhi",0.13888888);
200  desc.add<double>("weight_SizeX1",0.88);
201  desc.add<double>("weight_rho_up",22.);
202  desc.add<double>("weight_charge_peak",22.*1000.);
203  desc.add<double>("peakSizeY_q",1.0);
204  desc.add<bool>("endCap",true);
205  desc.add<double>("minJetEta_EC",1.3);
206  desc.add<double>("maxJetEta_EC",2.6);
207  desc.add<double>("maxDeltaPhi_EC",0.14);
208  desc.add<double>("EC_weight",0.008);
209  desc.add<double>("weight_dPhi_EC",0.064516129);
210  desc.add<double>("zClusterWidth_step1",2.0);
211  desc.add<double>("zClusterWidth_step2",0.65);
212  desc.add<double>("zClusterSearchArea_step2",3.0);
213  desc.add<double>("weightCut_step2",0.05);
214  desc.add<double>("zClusterWidth_step3",0.3);
215  desc.add<double>("zClusterSearchArea_step3",0.55);
216  desc.add<double>("weightCut_step3",0.1);
217  desc.add<bool>("ptWeighting",false); // <---- newMethod
218  desc.add<double>("ptWeighting_slope",1/20.);
219  desc.add<double>("ptWeighting_offset",-1);
220  descriptions.add("fastPrimaryVertexWithWeightsProducer",desc);
221 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void FastPrimaryVertexWithWeightsProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

if it is a cluster to project

Definition at line 224 of file FastPrimaryVertexWithWeightsProducer.cc.

References funct::abs(), ecalDrivenElectronSeedsParameters_cff::beamSpot, beamSpotToken, edm::View< T >::begin(), edmNew::DetSetVector< T >::begin(), ALCARECOTkAlJpsiMuMu_cff::charge, SiPixelCluster::charge(), clustersToken, DEFINE_FWK_MODULE, MuonCkfTrajectoryBuilder_cfi::deltaPhi, MillePedeFileConverter_cfg::e, edm::View< T >::end(), edmNew::DetSetVector< T >::end(), stringResolutionProvider_cfi::eta, JetChargeProducer_cfi::exp, FindPeakFastPV(), edm::EventSetup::get(), edm::Event::getByToken(), mps_fire::i, TrackerGeometry::idToDet(), TrackerGeometry::idToDetUnit(), fwrapper::jets, jetsToken, PixelClusterParameterEstimator::localParametersV(), m_barrel, m_EC_weight, m_endCap, m_maxDeltaPhi, m_maxDeltaPhi_EC, m_maxJetEta, m_maxJetEta_EC, m_maxSizeX, m_maxSizeY_q, m_maxZ, m_minJetEta_EC, m_minJetPt, m_minSizeY_q, m_njets, m_peakSizeY_q, m_PixelCellHeightOverWidth, m_pixelCPE, m_ptWeighting, m_ptWeighting_offset, m_ptWeighting_slope, m_weight_charge_down, m_weight_charge_peak, m_weight_charge_up, m_weight_dPhi, m_weight_dPhi_EC, m_weight_rho_up, m_weight_SizeX1, m_weightCut_step2, m_weightCut_step3, m_zClusterSearchArea_step2, m_zClusterSearchArea_step3, m_zClusterWidth_step1, m_zClusterWidth_step2, m_zClusterWidth_step3, eostools::move(), AlCaHLTBitMon_ParallelJobs::p, PV3DBase< T, PVType, FrameType >::phi(), HiRegitMuonDetachedTripletStep_cff::pixelClusters, GeomDet::position(), createTree::pp, edm::Handle< T >::product(), edm::ESHandle< T >::product(), EnergyCorrector::pt, edm::Event::put(), rho, objectSelection_cff::selectedJets, edmNew::DetSet< T >::size(), SiPixelCluster::sizeX(), SiPixelCluster::sizeY(), RecoTauValidation_cfi::sizeY, mathSSE::sqrt(), GeomDet::surface(), Surface::toGlobal(), mixOne_simraw_on_sim_cfi::tracker, findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), reco::BeamSpot::x(), reco::BeamSpot::x0(), PV3DBase< T, PVType, FrameType >::y(), reco::BeamSpot::y(), reco::BeamSpot::y0(), z, and PV3DBase< T, PVType, FrameType >::z().

225 {
226 
227  using namespace edm;
228  using namespace reco;
229  using namespace std;
230 
231  const float barrel_lenght=30; //half lenght of the pixel barrel 30 cm
232 
233  //get pixel cluster
235  iEvent.getByToken(clustersToken,cH);
237 
238  //get jets
240  iEvent.getByToken(jetsToken,jH);
241  const edm::View<reco::Jet> & jets = *jH.product();
242 
243  vector<const reco::Jet*> selectedJets;
244  int countjet=0;
245  for(edm::View<reco::Jet>::const_iterator it = jets.begin() ; it != jets.end() && countjet<m_njets ; it++)
246  {
247  if( //select jets used in barrel or endcap pixel cluster projections
248  ((it->pt() >= m_minJetPt) && std::abs(it->eta()) <= m_maxJetEta) || //barrel
249  ((it->pt() >= m_minJetPt) && std::abs(it->eta()) <= m_maxJetEta_EC && std::abs(it->eta()) >= m_minJetEta_EC) //endcap
250  )
251  {
252  selectedJets.push_back(&(*it));
253  countjet++;
254  }
255  }
256 
257  //get PixelClusterParameterEstimator
260  iSetup.get<TkPixelCPERecord>().get(m_pixelCPE , pe );
261  pp = pe.product();
262 
263  //get beamSpot
265  iEvent.getByToken(beamSpotToken,beamSpot);
266 
267  //get TrackerGeometry
269  iSetup.get<TrackerDigiGeometryRecord>().get(tracker);
270  const TrackerGeometry * trackerGeometry = tracker.product();
271 
272 // PART I: get z-projections with z-weights
273  std::vector<float> zProjections;
274  std::vector<float> zWeights;
275  int jet_count=0;
276  for(vector<const reco::Jet*>::iterator jit = selectedJets.begin() ; jit != selectedJets.end() ; jit++)
277  {//loop on selected jets
278  float px=(*jit)->px();
279  float py=(*jit)->py();
280  float pz=(*jit)->pz();
281  float pt=(*jit)->pt();
282  float eta=(*jit)->eta();
283  float jetZOverRho = (*jit)->momentum().Z()/(*jit)->momentum().Rho();
284  float pt_weight= pt*m_ptWeighting_slope +m_ptWeighting_offset;
285  for(SiPixelClusterCollectionNew::const_iterator it = pixelClusters.begin() ; it != pixelClusters.end() ; it++) //Loop on pixel modules with clusters
286  {//loop on pixel modules
287  DetId id = it->detId();
288  const edmNew::DetSet<SiPixelCluster> & detset = (*it);
289  Point3DBase<float, GlobalTag> modulepos=trackerGeometry->idToDet(id)->position();
290  float zmodule = modulepos.z() - ((modulepos.x()-beamSpot->x0())*px+(modulepos.y()-beamSpot->y0())*py)/pt * pz/pt;
291  if ((std::abs(deltaPhi((*jit)->momentum().Phi(),modulepos.phi()))< m_maxDeltaPhi*2)&&(std::abs(zmodule)<(m_maxZ+barrel_lenght))){//if it is a compatible module
292  for(size_t j = 0 ; j < detset.size() ; j ++)
293  {//loop on pixel clusters on this module
294  const SiPixelCluster & aCluster = detset[j];
295  if(//it is a cluster to project
296  (// barrel
297  m_barrel &&
298  std::abs(modulepos.z())<barrel_lenght &&
299  pt>=m_minJetPt &&
300  jet_count<m_njets &&
301  std::abs(eta)<=m_maxJetEta &&
302  aCluster.sizeX() <= m_maxSizeX &&
303  aCluster.sizeY() >= m_PixelCellHeightOverWidth*std::abs(jetZOverRho)+m_minSizeY_q &&
304  aCluster.sizeY() <= m_PixelCellHeightOverWidth*std::abs(jetZOverRho)+m_maxSizeY_q
305  )
306  ||
307  (// EC
308  m_endCap &&
309  std::abs(modulepos.z())>barrel_lenght &&
310  pt > m_minJetPt &&
311  jet_count<m_njets &&
312  std::abs(eta) <= m_maxJetEta_EC &&
313  std::abs(eta) >= m_minJetEta_EC &&
314  aCluster.sizeX() <= m_maxSizeX
315  )
316  ){
317  Point3DBase<float, GlobalTag> v = trackerGeometry->idToDet(id)->surface().toGlobal(pp->localParametersV( aCluster,( *trackerGeometry->idToDetUnit(id)))[0].first) ;
318  GlobalPoint v_bs(v.x()-beamSpot->x0(),v.y()-beamSpot->y0(),v.z());
319  if(//it pass DeltaPhi(Jet,Cluster) requirements
320  (m_barrel && std::abs(modulepos.z())<barrel_lenght && std::abs(deltaPhi((*jit)->momentum().Phi(),v_bs.phi())) <= m_maxDeltaPhi ) || //barrel
321  (m_endCap && std::abs(modulepos.z())>barrel_lenght && std::abs(deltaPhi((*jit)->momentum().Phi(),v_bs.phi())) <= m_maxDeltaPhi_EC ) //EC
322  )
323  {
324  float z = v.z() - ((v.x()-beamSpot->x0())*px+(v.y()-beamSpot->y0())*py)/pt * pz/pt; //calculate z-projection
325  if(std::abs(z) < m_maxZ)
326  {
327  zProjections.push_back(z); //add z-projection in zProjections
328  float weight=0;
329  //calculate zWeight
330  if(std::abs(modulepos.z())<barrel_lenght)
331  { //barrel
332  //calculate weight_sizeY
333  float sizeY=aCluster.sizeY();
334  float sizeY_up = m_PixelCellHeightOverWidth*std::abs(jetZOverRho)+m_maxSizeY_q;
335  float sizeY_peak = m_PixelCellHeightOverWidth*std::abs(jetZOverRho)+m_peakSizeY_q;
336  float sizeY_down = m_PixelCellHeightOverWidth*std::abs(jetZOverRho)+m_minSizeY_q;
337  float weight_sizeY_up = (sizeY_up-sizeY)/(sizeY_up-sizeY_peak);
338  float weight_sizeY_down = (sizeY-sizeY_down)/(sizeY_peak-sizeY_down);
339  weight_sizeY_down = weight_sizeY_down *(weight_sizeY_down>0)*(weight_sizeY_down<1);
340  weight_sizeY_up = weight_sizeY_up *(weight_sizeY_up>0)*(weight_sizeY_up<1);
341  float weight_sizeY = weight_sizeY_up + weight_sizeY_down;
342 
343  //calculate weight_rho
344  float rho = sqrt(v_bs.x()*v_bs.x() + v_bs.y()*v_bs.y());
345  float weight_rho = ((m_weight_rho_up - rho)/m_weight_rho_up);
346 
347  //calculate weight_dPhi
348  float weight_dPhi = exp(- std::abs(deltaPhi((*jit)->momentum().Phi(),v_bs.phi()))/m_weight_dPhi );
349 
350  //calculate weight_sizeX1
351  float weight_sizeX1= (aCluster.sizeX()==2) + (aCluster.sizeX()==1)*m_weight_SizeX1;
352 
353  //calculate weight_charge
354  float charge=aCluster.charge();
356  float weightCluster_down = (charge-m_weight_charge_down)/(m_weight_charge_peak-m_weight_charge_down);
357  weightCluster_down = weightCluster_down *(weightCluster_down>0)*(weightCluster_down<1);
358  weightCluster_up = weightCluster_up *(weightCluster_up>0)*(weightCluster_up<1);
359  float weight_charge = weightCluster_up + weightCluster_down;
360 
361  //calculate the final weight
362  weight = weight_dPhi * weight_sizeY * weight_rho * weight_sizeX1 * weight_charge ;
363  }
364  else if(std::abs(modulepos.z())>barrel_lenght) // EC
365  {// EC
366  //calculate weight_dPhi
367  float weight_dPhi = exp(- std::abs(deltaPhi((*jit)->momentum().Phi(),v_bs.phi())) /m_weight_dPhi_EC );
368  //calculate the final weight
369  weight= m_EC_weight*(weight_dPhi) ;
370  }
371  if(m_ptWeighting) weight=weight*pt_weight;
372  zWeights.push_back(weight); //add the weight to zWeights
373  }
374  }//if it pass DeltaPhi(Jet,Cluster) requirements
375  }
376  }//loop on pixel clusters on this module
377  }//if it is a compatible module
378  }//loop on pixel modules
379  jet_count++;
380  }//loop on selected jets
381 
382  //order zProjections and zWeights by z
383  std::multimap<float,float> zWithW;
384  size_t i=0;
385  for(i=0;i<zProjections.size();i++) zWithW.insert(std::pair<float,float>(zProjections[i],zWeights[i]));
386  i=0;
387  for(std::multimap<float,float>::iterator it=zWithW.begin(); it!=zWithW.end(); it++,i++) { zProjections[i]=it->first; zWeights[i]=it->second; } //order zProjections and zWeights by z
388 
389 
390  //calculate zWeightsSquared
391  std::vector<float> zWeightsSquared;
392  for(std::vector<float>::iterator it=zWeights.begin();it!=zWeights.end();it++) {zWeightsSquared.push_back((*it)*(*it));}
393 
394  //do multi-step peak searching
395  float res_step1 = FindPeakFastPV( zProjections, zWeights, 0.0, m_zClusterWidth_step1, 999.0, -1.0);
396  float res_step2 = FindPeakFastPV( zProjections, zWeights, res_step1, m_zClusterWidth_step2, m_zClusterSearchArea_step2, m_weightCut_step2);
397  float res_step3 = FindPeakFastPV( zProjections, zWeightsSquared, res_step2, m_zClusterWidth_step3, m_zClusterSearchArea_step3, m_weightCut_step3*m_weightCut_step3);
398 
399  float centerWMax=res_step3;
400  //End of PART II
401 
402  //Make the output
403  float res=0;
404  if(zProjections.size() > 2)
405  {
406  res=centerWMax;
407  Vertex::Error e;
408  e(0, 0) = 0.0015 * 0.0015;
409  e(1, 1) = 0.0015 * 0.0015;
410  e(2, 2) = 1.5 * 1.5;
411  Vertex::Point p(beamSpot->x(res), beamSpot->y(res), res);
412  Vertex thePV(p, e, 1, 1, 0);
413  auto pOut = std::make_unique<reco::VertexCollection>();
414  pOut->push_back(thePV);
415  iEvent.put(std::move(pOut));
416  } else
417  {
419  e(0, 0) = 0.0015 * 0.0015;
420  e(1, 1) = 0.0015 * 0.0015;
421  e(2, 2) = 1.5 * 1.5;
422  Vertex::Point p(beamSpot->x(res), beamSpot->y(res), res);
423  Vertex thePV(p, e, 0, 0, 0);
424  auto pOut = std::make_unique<reco::VertexCollection>();
425  pOut->push_back(thePV);
426  iEvent.put(std::move(pOut));
427  }
428 
429 //Finally, calculate the zClusterQuality as Sum(weights near the fastPV)/sqrt(Sum(total weights)) [a kind of zCluster significance]
430 
431 
432 
433  const float half_width_peak=1;
434  float nWeightedTot=0;
435  float nWeightedTotPeak=0;
436  for(std::vector<float>::iterator it = zProjections.begin();it!=zProjections.end(); it++)
437  {
438  nWeightedTot+=zWeights[it-zProjections.begin()];
439  if((res-half_width_peak)<=(*it) && (*it)<=(res+half_width_peak))
440  {
441  nWeightedTotPeak+=zWeights[it-zProjections.begin()];
442  }
443  }
444 
445 auto zClusterQuality = std::make_unique<float>();
446 *zClusterQuality=-1;
447 if(nWeightedTot!=0)
448 {
449  *zClusterQuality=nWeightedTotPeak / sqrt(nWeightedTot/(2*half_width_peak)); // where 30 is the beam spot lenght
450  iEvent.put(std::move(zClusterQuality));
451 }
452 else
453  iEvent.put(std::move(zClusterQuality));
454 
455 }
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:106
const TrackerGeomDet * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const_iterator end(bool update=false) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T y() const
Definition: PV3DBase.h:63
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
Definition: weight.py:1
int charge() const
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:42
Definition: Electron.h:4
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:48
const_iterator begin() const
T sqrt(T t)
Definition: SSEVec.h:18
vector< PseudoJet > jets
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
edm::EDGetTokenT< edm::View< reco::Jet > > jetsToken
virtual VLocalValues localParametersV(const SiPixelCluster &cluster, const GeomDetUnit &gd) const
Definition: DetId.h:18
T const * product() const
Definition: Handle.h:81
double x(const double z) const
x coordinate of the beeam spot position at a given z value (it takes into account the dxdz slope) ...
Definition: BeamSpot.h:71
const T & get() const
Definition: EventSetup.h:56
int sizeY() const
Pixel cluster – collection of neighboring pixels above threshold.
fixed size matrix
HLT enums.
double y(const double z) const
y coordinate of the beeam spot position at a given z value (it takes into account the dydz slope) ...
Definition: BeamSpot.h:73
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
double y0() const
y coordinate
Definition: BeamSpot.h:66
const_iterator end() const
float FindPeakFastPV(const std::vector< float > &zProjections, const std::vector< float > &zWeights, const float oldVertex, const float m_zClusterWidth, const float m_zClusterSearchArea, const float m_weightCut)
size_type size() const
Definition: DetSetNew.h:87
int sizeX() const
edm::EDGetTokenT< SiPixelClusterCollectionNew > clustersToken
T x() const
Definition: PV3DBase.h:62
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510
const_iterator begin(bool update=false) const
const TrackerGeomDet * idToDet(DetId) const
double x0() const
x coordinate
Definition: BeamSpot.h:64

Member Data Documentation

edm::EDGetTokenT<reco::BeamSpot> FastPrimaryVertexWithWeightsProducer::beamSpotToken
private
edm::EDGetTokenT<SiPixelClusterCollectionNew> FastPrimaryVertexWithWeightsProducer::clustersToken
private
edm::EDGetTokenT<edm::View<reco::Jet> > FastPrimaryVertexWithWeightsProducer::jetsToken
private
const bool FastPrimaryVertexWithWeightsProducer::m_barrel
private

Definition at line 77 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const edm::InputTag FastPrimaryVertexWithWeightsProducer::m_clusters
private

Definition at line 67 of file FastPrimaryVertexWithWeightsProducer.cc.

const double FastPrimaryVertexWithWeightsProducer::m_EC_weight
private

Definition at line 102 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const bool FastPrimaryVertexWithWeightsProducer::m_endCap
private

Definition at line 96 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_maxDeltaPhi
private

Definition at line 79 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_maxDeltaPhi_EC
private

Definition at line 99 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_maxJetEta
private

Definition at line 75 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_maxJetEta_EC
private

Definition at line 98 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_maxSizeX
private

Definition at line 78 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_maxSizeY_q
private

Definition at line 84 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_maxZ
private

Definition at line 66 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_minJetEta_EC
private

Definition at line 97 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_minJetPt
private

Definition at line 76 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_minSizeY_q
private

Definition at line 83 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const int FastPrimaryVertexWithWeightsProducer::m_njets
private

Definition at line 74 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_peakSizeY_q
private

Definition at line 93 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_PixelCellHeightOverWidth
private

Definition at line 82 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

std::string FastPrimaryVertexWithWeightsProducer::m_pixelCPE
private

Definition at line 68 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const bool FastPrimaryVertexWithWeightsProducer::m_ptWeighting
private

Definition at line 120 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_ptWeighting_offset
private

Definition at line 122 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_ptWeighting_slope
private

Definition at line 121 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_weight_charge_down
private

Definition at line 80 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_weight_charge_peak
private

Definition at line 92 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_weight_charge_up
private

Definition at line 81 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_weight_dPhi
private

Definition at line 89 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_weight_dPhi_EC
private

Definition at line 103 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_weight_rho_up
private

Definition at line 91 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_weight_SizeX1
private

Definition at line 90 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_weightCut_step2
private

Definition at line 112 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_weightCut_step3
private

Definition at line 117 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_zClusterSearchArea_step2
private

Definition at line 111 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_zClusterSearchArea_step3
private

Definition at line 116 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_zClusterWidth_step1
private

Definition at line 107 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_zClusterWidth_step2
private

Definition at line 110 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().

const double FastPrimaryVertexWithWeightsProducer::m_zClusterWidth_step3
private

Definition at line 115 of file FastPrimaryVertexWithWeightsProducer.cc.

Referenced by produce().