205 std::vector<double>&
phi,
206 std::vector<double>& rho,
207 std::vector<double>& zed,
208 std::vector<long>& lyr,
209 std::vector<long>& filledLayers,
210 long& numPhiSlices )
const
216 std::vector<TrigSiSpacePointBase>::const_iterator SpItr = spVec.begin();
218 long nSPs = spVec.size();
223 double roiPhiMin, roiPhiMax;
235 double roiPhiPosMin( 9.9), roiPhiPosMax(0);
236 double roiPhiNegMin(-9.9), roiPhiNegMax(0);
237 for(
long i=0; i<nSPs; ++i, ++SpItr)
239 double spphi = SpItr->phi();
240 if ( spphi>0 && spphi>roiPhiPosMax ) roiPhiPosMax = spphi;
241 if ( spphi>0 && spphi<roiPhiPosMin ) roiPhiPosMin = spphi;
243 if ( spphi<0 && spphi<roiPhiNegMax ) roiPhiNegMax = spphi;
244 if ( spphi<0 && spphi>roiPhiNegMin ) roiPhiNegMin = spphi;
247 if ( roiPhiNegMax > roiPhiNegMin ) {
249 roiPhiMin = roiPhiPosMin;
250 roiPhiMax = roiPhiPosMax;
252 else if ( roiPhiPosMax < roiPhiPosMin ) {
254 roiPhiMin = roiPhiNegMax;
255 roiPhiMax = roiPhiNegMin;
257 else if ( roiPhiPosMin - roiPhiNegMin <
M_PI ) {
259 roiPhiMin = roiPhiNegMax;
260 roiPhiMax = roiPhiPosMax;
264 roiPhiMin = roiPhiPosMin;
265 roiPhiMax = roiPhiNegMin;
271 SpItr = spVec.begin();
279 if(roiPhiMin<-
M_PI) roiPhiMin+=2*
M_PI;
280 if(roiPhiMax>
M_PI) roiPhiMax-=2*
M_PI;
293 double dphi = roiPhiMax-roiPhiMin;
295 if ( dphi<0 ) dphi+=2*
M_PI;
300 bool piBound=(roiPhiMin>roiPhiMax);
307 for(
long i=0; i<nSPs; ++i, ++SpItr)
310 double phi2 = SpItr->phi() - roiPhiMin;
312 if ( phi2>=0 && phi2<dphi ) {
314 rho[icount] = SpItr->r();
315 zed[icount] = SpItr->z();
317 lcount[lyr[icount]]=
true;
325 for(
long i=0; i<nSPs; ++i, ++SpItr)
328 double phi2 = SpItr->phi() - roiPhiMin;
329 if( phi2<0.0) phi2+=2*
M_PI;
330 if ( phi2>=0 && phi2<dphi ) {
332 rho[icount] = SpItr->r();
333 zed[icount] = SpItr->z();
335 lcount[lyr[icount]]=
true;
361 filledLayers[filled] = i;
381 std::vector<vertex>* output =
new std::vector<vertex>();
383 long nsp = spVec.size();
384 if ( !nsp )
return output;
390 std::vector<double>
phi(nsp), rho(nsp), zed(nsp);
393 long numPhiSlices = 0;
395 long filled = this->
fillVectors( spVec, roi,
phi, rho, zed, lyr, filledLayers, numPhiSlices );
410 const double invZBinSize = 1./ZBinSize;
413 const long HalfZhistoBins = long ( ceil( 0.5*(zMax-zMin)*invZBinSize ) );
414 const long NumZhistoBins = 2*HalfZhistoBins;
431 std::vector < std::vector<long> > nHisto[2];
432 std::vector < std::vector<double> > zHisto[2];
434 for (
int i=2 ; i-- ; ) { nHisto[i].clear(); nHisto[i].resize(numZhistos); }
435 for (
int i=2 ; i-- ; ) { zHisto[i].clear(); zHisto[i].resize(numZhistos); }
443 std::vector< PhiSlice* > allSlices( numPhiSlices );
444 for (
unsigned int sliceIndex = 0; sliceIndex < numPhiSlices; sliceIndex++ )
451 int allSlicesSize = allSlices.size();
454 for (
long pointIndex = 0; pointIndex < nsp; pointIndex++ )
457 if (phiIndex > allSlicesSize) {
460 allSlices[ phiIndex ]->AddPoint( rho[ pointIndex ], zed[ pointIndex ],
phi[ pointIndex ], lyr[ pointIndex ] );
464 std::vector< std::vector< double > > allLayerRhos, allLayerZs, allLayerPhis;
469 std::vector< std::vector< int > > allSliceWidths(
m_IdScan_MaxNumLayers, std::vector< int >( numPhiSlices + 1, 0 ) );
470 for (
unsigned int sliceIndex = 0; sliceIndex < numPhiSlices; sliceIndex++ )
472 allSlices[ sliceIndex ]->MakeWideLayers( &allLayerRhos, &allLayerZs, &allLayerPhis, &allSliceWidths, filled, &filledLayers );
479 for (
unsigned int sliceIndex = 0; sliceIndex < numPhiSlices; sliceIndex++ )
481 nHisto[0][sliceIndex].resize( NumZhistoBins + 1 );
482 zHisto[0][sliceIndex].resize( NumZhistoBins + 1 );
485 for (
unsigned int sliceIndex = 0; sliceIndex < numPhiSlices; sliceIndex++ ) {
486 nHisto[1][sliceIndex].resize( NumZhistoBins + 1 );
487 zHisto[1][sliceIndex].resize( NumZhistoBins + 1 );
492 for (
unsigned int sliceIndex = 0; sliceIndex < numPhiSlices; sliceIndex++ ) {
493 allSlices[ sliceIndex ]->GetHistogram( &( nHisto[0][sliceIndex] ), &( zHisto[0][sliceIndex] ),
494 &( nHisto[1][sliceIndex] ), &( zHisto[1][sliceIndex] ),
500 delete allSlices[ sliceIndex ];
505 nHisto[0][0].resize( NumZhistoBins + 1 );
506 zHisto[0][0].resize( NumZhistoBins + 1 );
508 nHisto[1][0].resize( NumZhistoBins + 1 );
509 zHisto[1][0].resize( NumZhistoBins + 1 );
513 for (
unsigned int sliceIndex = 0; sliceIndex < numPhiSlices; sliceIndex++ ) {
514 allSlices[ sliceIndex ]->GetHistogram( &( nHisto[0][0] ), &( zHisto[0][0] ),
515 &( nHisto[1][0] ), &( zHisto[1][0] ),
518 delete allSlices[ sliceIndex ];
533 for (
long zpm=0; zpm<1 || (
m_chargeAware && zpm<2 ) ; ++zpm ) {
535 for(std::vector< std::vector<long> >
::iterator nfiter = nHisto[zpm].begin(); nfiter!=nHisto[zpm].end(); ++nfiter) {
537 if((*nfiter).empty())
continue;
538 if((*nfiter).size() <= 2 )
continue;
540 for(std::vector<long>::iterator niter=nfiter->begin()+2; niter!=nfiter->end(); ++niter ) {
544 pedestal += *(niter) + *(niter-1) + *(niter-2);
568 std::vector<long>& n = nHisto[0][0];
570 std::vector<long> n3( nHisto[0][0].size()-2, 0);
572 for(
unsigned i=n.size()-2 ; i-- ; ) n3[i] = ( n[i+2] + n[i+1] + n[i] );
577 for(
unsigned i=
nmax ; i-- ; ) bg += n3[i];
589 std::vector<double> zoutput;
590 std::vector<double> woutput;
598 long bending=0, bestPhi=0;
601 for (
long zpm=0; zpm<1 || (
m_chargeAware && zpm<2 ) ; ++zpm ) {
603 std::vector< std::vector<long> >
::iterator nfiter = nHisto[zpm].begin();
604 for( ; nfiter!=nHisto[zpm].end() ; ++nfiter) {
606 if((*nfiter).empty())
continue;
607 if((*nfiter).size() <= 2 )
continue;
609 for(std::vector<long>::iterator niter=(*nfiter).begin()+2; niter!=(*nfiter).end(); ++niter ) {
611 ztest = *(niter-2) + *(niter-1) + *(niter);
612 if ( ztest <= 0 || ztest < maxh )
continue;
615 if ( ztest >= maxh ) {
616 long bintest = niter-(*nfiter).begin()-1;
619 (
m_preferCentralZ && std::abs( bintest - HalfZhistoBins ) < std::abs( binMax - HalfZhistoBins ) ) ) {
622 bestPhi = nfiter-nHisto[zpm].begin();
639 double weightedMax = ( zHisto[bending][bestPhi][binMax] +
640 zHisto[bending][bestPhi][binMax+1] +
641 zHisto[bending][bestPhi][binMax-1] ) /maxh;
645 nHisto[bending][bestPhi][binMax] = -1;
646 nHisto[bending][bestPhi][binMax-1] = -1;
647 nHisto[bending][bestPhi][binMax+1] = -1;
648 zHisto[bending][bestPhi][binMax] = 0;
649 zHisto[bending][bestPhi][binMax-1] = 0;
650 zHisto[bending][bestPhi][binMax+1] = 0;
654 float dist2closestVtx = 1000;
655 for (
size_t iv = 0; iv < zoutput.size(); ++iv ) {
656 if ( fabs(weightedMax-zoutput[iv]) < dist2closestVtx ) {
658 dist2closestVtx = fabs(weightedMax-zoutput[iv]);
671 double significance = 0;
673 significance = (maxh-bg)/std::sqrt(bg);
678 zoutput.push_back( weightedMax );
679 woutput.push_back( maxh );
707 for (
unsigned i=0 ; i<zoutput.size() ; i++ ) {
708 output->push_back(
vertex( woutput[i] - pedestal, zoutput[i] ) );
712 for (
unsigned i=0 ; i<zoutput.size() ; i++ ) {
713 output->push_back(
vertex( zoutput[i], woutput[i] - pedestal ) );