calculate the vertex significance: First sort the n entries in each bin in to order, then calculate the mean bg excluding the largest (1-m_percentile), then the significance for each peak will be sig = (ypeak - bg)/sqrt(bg) and we can keep only those where sig > m_minVtxSignificance
if ( ztest >= maxh && ( ( m_applyWeightThreshold && ztest>m_weightThreshold ) || !m_applyWeightThreshold ) ) { apply threshold later - should we wish it
if we are in triplet mode, even a single pair means 3 consistent hits also bomb out if no maximum (above threshold) is found
at this point we have the histogram with the highest N vertices removed so we can find the "non vertex" pedestal from these, although it will be somewhat lower than perhaps it should be, in case some of the "vertices" we are removing are just random upwards fluctuations
NB: have moved pedestal calculation to before the extraction of the vertices if we calculate it after, then we have too low a pedestal if some vertices are really random fluctuations. If we calculate it before then we overestimate the pedestal, really we should try to decide how many real vertices we have, and then only exclude them, but that level of detail is probably not justified by the correlation with the offline track multiplicity on the vertex
copy vertices to output vector - this is so we can first impose cuts on the vertices we have found should we wish to
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;
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++ )
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 ) {
537 if((*nfiter).empty())
continue;
538 if((*nfiter).size() <= 2 )
continue;
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 ) {
604 for( ; nfiter!=
nHisto[zpm].end() ; ++nfiter) {
606 if((*nfiter).empty())
continue;
607 if((*nfiter).size() <= 2 )
continue;
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++ ) {
712 for (
unsigned i=0 ;
i<zoutput.size() ;
i++ ) {