127 clustersToken = consumes<SiPixelClusterCollectionNew>(m_clusters);
130 beamSpotToken = consumes<reco::BeamSpot>(m_beamSpot);
132 jetsToken = consumes<edm::View<reco::Jet> >(m_jets);
135 m_maxJetEta = iConfig.
getParameter<
double>(
"maxJetEta");
140 m_maxDeltaPhi = iConfig.
getParameter<
double>(
"maxDeltaPhi");
141 m_PixelCellHeightOverWidth = iConfig.
getParameter<
double>(
"PixelCellHeightOverWidth");
142 m_weight_charge_down = iConfig.
getParameter<
double>(
"weight_charge_down");
143 m_weight_charge_up = iConfig.
getParameter<
double>(
"weight_charge_up");
144 m_minSizeY_q = iConfig.
getParameter<
double>(
"minSizeY_q");
145 m_maxSizeY_q = iConfig.
getParameter<
double>(
"maxSizeY_q");
147 m_weight_dPhi = iConfig.
getParameter<
double>(
"weight_dPhi");
148 m_weight_SizeX1 = iConfig.
getParameter<
double>(
"weight_SizeX1");
149 m_weight_rho_up = iConfig.
getParameter<
double>(
"weight_rho_up");
150 m_weight_charge_peak = iConfig.
getParameter<
double>(
"weight_charge_peak");
151 m_peakSizeY_q = iConfig.
getParameter<
double>(
"peakSizeY_q");
154 m_minJetEta_EC = iConfig.
getParameter<
double>(
"minJetEta_EC");
155 m_maxJetEta_EC = iConfig.
getParameter<
double>(
"maxJetEta_EC");
156 m_maxDeltaPhi_EC = iConfig.
getParameter<
double>(
"maxDeltaPhi_EC");
157 m_EC_weight = iConfig.
getParameter<
double>(
"EC_weight");
158 m_weight_dPhi_EC = iConfig.
getParameter<
double>(
"weight_dPhi_EC");
160 m_zClusterWidth_step1 = iConfig.
getParameter<
double>(
"zClusterWidth_step1");
162 m_zClusterWidth_step2 = iConfig.
getParameter<
double>(
"zClusterWidth_step2");
163 m_zClusterSearchArea_step2 = iConfig.
getParameter<
double>(
"zClusterSearchArea_step2");
164 m_weightCut_step2 = iConfig.
getParameter<
double>(
"weightCut_step2");
166 m_zClusterWidth_step3 = iConfig.
getParameter<
double>(
"zClusterWidth_step3");
167 m_zClusterSearchArea_step3 = iConfig.
getParameter<
double>(
"zClusterSearchArea_step3");
168 m_weightCut_step3 = iConfig.
getParameter<
double>(
"weightCut_step3");
170 produces<reco::VertexCollection>();
183 desc.
add<
double>(
"maxZ",19.0);
184 desc.
add<
int>(
"njets",999);
185 desc.
add<
double>(
"maxJetEta",2.6);
186 desc.
add<
double>(
"minJetPt",40.);
187 desc.
add<
bool>(
"barrel",
true);
188 desc.
add<
double>(
"maxSizeX",2.1);
189 desc.
add<
double>(
"maxDeltaPhi",0.21);
190 desc.
add<
double>(
"PixelCellHeightOverWidth",1.8);
191 desc.
add<
double>(
"weight_charge_down",11.*1000.);
192 desc.
add<
double>(
"weight_charge_up",190.*1000.);
193 desc.
add<
double>(
"maxSizeY_q",2.0);
194 desc.
add<
double>(
"minSizeY_q",-0.6);
195 desc.
add<
double>(
"weight_dPhi",0.13888888);
196 desc.
add<
double>(
"weight_SizeX1",0.88);
197 desc.
add<
double>(
"weight_rho_up",22.);
198 desc.
add<
double>(
"weight_charge_peak",22.*1000.);
199 desc.
add<
double>(
"peakSizeY_q",1.0);
200 desc.
add<
bool>(
"endCap",
true);
201 desc.
add<
double>(
"minJetEta_EC",1.3);
202 desc.
add<
double>(
"maxJetEta_EC",2.6);
203 desc.
add<
double>(
"maxDeltaPhi_EC",0.14);
204 desc.
add<
double>(
"EC_weight",0.008);
205 desc.
add<
double>(
"weight_dPhi_EC",0.064516129);
206 desc.
add<
double>(
"zClusterWidth_step1",2.0);
207 desc.
add<
double>(
"zClusterWidth_step2",0.65);
208 desc.
add<
double>(
"zClusterSearchArea_step2",3.0);
209 desc.
add<
double>(
"weightCut_step2",0.05);
210 desc.
add<
double>(
"zClusterWidth_step3",0.3);
211 desc.
add<
double>(
"zClusterSearchArea_step3",0.55);
212 desc.
add<
double>(
"weightCut_step3",0.1);
213 descriptions.
add(
"fastPrimaryVertexWithWeightsProducer",desc);
221 using namespace reco;
224 const float barrel_lenght=30;
236 vector<const reco::Jet*> selectedJets;
241 ((it->pt() >= m_minJetPt) && fabs(it->eta()) <= m_maxJetEta) ||
242 ((it->pt() >= m_minJetPt) && fabs(it->eta()) <= m_maxJetEta_EC && fabs(it->eta()) >= m_minJetEta_EC)
245 selectedJets.push_back(&(*it));
266 std::vector<float> zProjections;
267 std::vector<float> zWeights;
269 for(vector<const reco::Jet*>::iterator jit = selectedJets.begin() ; jit != selectedJets.end() ; jit++)
271 float px=(*jit)->px();
272 float py=(*jit)->py();
273 float pz=(*jit)->pz();
274 float pt=(*jit)->pt();
275 float eta=(*jit)->eta();
276 float jetZOverRho = (*jit)->momentum().Z()/(*jit)->momentum().Rho();
279 DetId id = it->detId();
282 float zmodule = modulepos.
z() - ((modulepos.
x()-
beamSpot->x0())*px+(modulepos.
y()-
beamSpot->y0())*py)/pt * pz/
pt;
283 if ((fabs(
deltaPhi((*jit)->momentum().Phi(),modulepos.
phi()))< m_maxDeltaPhi*2)&&(fabs(zmodule)<(m_maxZ+barrel_lenght))){
284 for(
size_t j = 0 ;
j < detset.
size() ;
j ++)
290 fabs(modulepos.
z())<barrel_lenght &&
293 fabs(eta)<=m_maxJetEta &&
294 aCluster.
sizeX() <= m_maxSizeX &&
295 aCluster.
sizeY() >= m_PixelCellHeightOverWidth*fabs(jetZOverRho)+m_minSizeY_q &&
296 aCluster.
sizeY() <= m_PixelCellHeightOverWidth*fabs(jetZOverRho)+m_maxSizeY_q
301 fabs(modulepos.
z())>barrel_lenght &&
304 fabs(eta) <= m_maxJetEta_EC &&
305 fabs(eta) >= m_minJetEta_EC &&
306 aCluster.
sizeX() <= m_maxSizeX
309 Point3DBase<float, GlobalTag> v = trackerGeometry->idToDet(
id)->surface().toGlobal(
pp->localParametersV( aCluster,( *trackerGeometry->idToDetUnit(
id)))[0].first) ;
312 (m_barrel && fabs(modulepos.
z())<barrel_lenght && fabs(
deltaPhi((*jit)->momentum().Phi(),v_bs.phi())) <= m_maxDeltaPhi ) ||
313 (m_endCap && fabs(modulepos.
z())>barrel_lenght && fabs(
deltaPhi((*jit)->momentum().Phi(),v_bs.phi())) <= m_maxDeltaPhi_EC )
319 zProjections.push_back(z);
322 if(fabs(modulepos.
z())<barrel_lenght)
325 float sizeY=aCluster.
sizeY();
326 float sizeY_up = m_PixelCellHeightOverWidth*fabs(jetZOverRho)+m_maxSizeY_q;
327 float sizeY_peak = m_PixelCellHeightOverWidth*fabs(jetZOverRho)+m_peakSizeY_q;
328 float sizeY_down = m_PixelCellHeightOverWidth*fabs(jetZOverRho)+m_minSizeY_q;
329 float weight_sizeY_up = (sizeY_up-sizeY)/(sizeY_up-sizeY_peak);
330 float weight_sizeY_down = (sizeY-sizeY_down)/(sizeY_peak-sizeY_down);
331 weight_sizeY_down = weight_sizeY_down *(weight_sizeY_down>0)*(weight_sizeY_down<1);
332 weight_sizeY_up = weight_sizeY_up *(weight_sizeY_up>0)*(weight_sizeY_up<1);
333 float weight_sizeY = weight_sizeY_up + weight_sizeY_down;
336 float rho =
sqrt(v_bs.x()*v_bs.x() + v_bs.y()*v_bs.y());
337 float weight_rho = ((m_weight_rho_up -
rho)/m_weight_rho_up);
340 float weight_dPhi =
exp(- fabs(
deltaPhi((*jit)->momentum().Phi(),v_bs.phi()))/m_weight_dPhi );
343 float weight_sizeX1= (aCluster.
sizeX()==2) + (aCluster.
sizeX()==1)*m_weight_SizeX1;
347 float weightCluster_up = (m_weight_charge_up-
charge)/(m_weight_charge_up-m_weight_charge_peak);
348 float weightCluster_down = (charge-m_weight_charge_down)/(m_weight_charge_peak-m_weight_charge_down);
349 weightCluster_down = weightCluster_down *(weightCluster_down>0)*(weightCluster_down<1);
350 weightCluster_up = weightCluster_up *(weightCluster_up>0)*(weightCluster_up<1);
351 float weight_charge = weightCluster_up + weightCluster_down;
354 weight = weight_dPhi * weight_sizeY * weight_rho * weight_sizeX1 * weight_charge ;
356 else if(fabs(modulepos.
z())>barrel_lenght)
359 float weight_dPhi =
exp(- fabs(
deltaPhi((*jit)->momentum().Phi(),v_bs.phi())) /m_weight_dPhi_EC );
361 weight= m_EC_weight*(weight_dPhi) ;
363 zWeights.push_back(weight);
374 std::multimap<float,float> zWithW;
376 for(
i=0;
i<zProjections.size();
i++) zWithW.insert(std::pair<float,float>(zProjections[
i],zWeights[i]));
378 for(std::multimap<float,float>::iterator it=zWithW.begin(); it!=zWithW.end(); it++,i++) { zProjections[
i]=it->first; zWeights[
i]=it->second; }
382 std::vector<float> zWeightsSquared;
383 for(std::vector<float>::iterator it=zWeights.begin();it!=zWeights.end();it++) {zWeightsSquared.push_back((*it)*(*it));}
386 float res_step1 =
FindPeakFastPV( zProjections, zWeights, 0.0, m_zClusterWidth_step1, 999.0, -1.0);
387 float res_step2 =
FindPeakFastPV( zProjections, zWeights, res_step1, m_zClusterWidth_step2, m_zClusterSearchArea_step2, m_weightCut_step2);
388 float res_step3 =
FindPeakFastPV( zProjections, zWeightsSquared, res_step2, m_zClusterWidth_step3, m_zClusterSearchArea_step3, m_weightCut_step3*m_weightCut_step3);
390 float centerWMax=res_step3;
395 if(zProjections.size() > 2)
399 e(0, 0) = 0.0015 * 0.0015;
400 e(1, 1) = 0.0015 * 0.0015;
405 pOut->push_back(thePV);
410 e(0, 0) = 0.0015 * 0.0015;
411 e(1, 1) = 0.0015 * 0.0015;
416 pOut->push_back(thePV);
424 const float half_width_peak=1;
425 float nWeightedTot=0;
426 float nWeightedTotPeak=0;
427 for(std::vector<float>::iterator it = zProjections.begin();it!=zProjections.end(); it++)
429 nWeightedTot+=zWeights[it-zProjections.begin()];
430 if((res-half_width_peak)<=(*it) && (*it)<=(res+half_width_peak))
432 nWeightedTotPeak+=zWeights[it-zProjections.begin()];
436 std::auto_ptr<float > zClusterQuality(
new float());
440 *zClusterQuality=nWeightedTotPeak /
sqrt(nWeightedTot/(2*half_width_peak));
441 iEvent.
put(zClusterQuality);
444 iEvent.
put(zClusterQuality);
T getParameter(std::string const &) const
double m_weight_charge_up
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken
double m_zClusterWidth_step1
Geom::Phi< T > phi() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
math::Error< dimension >::type Error
covariance error matrix (3x3)
double m_weight_charge_peak
std::vector< Vertex > VertexCollection
collection of Vertex objects
double m_zClusterSearchArea_step3
FastPrimaryVertexWithWeightsProducer(const edm::ParameterSet &)
virtual void produce(edm::Event &, const edm::EventSetup &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
double m_weight_charge_down
math::XYZPoint Point
point in the space
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< edm::View< reco::Jet > > jetsToken
double m_PixelCellHeightOverWidth
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Pixel cluster – collection of neighboring pixels above threshold.
double m_zClusterWidth_step3
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)
double m_zClusterSearchArea_step2
double m_zClusterWidth_step2
edm::EDGetTokenT< SiPixelClusterCollectionNew > clustersToken