68 int offsetEndcapPixels = lastBarrel + 1;
69 int M = (maxLayers-offsetEndcapPixels)/2;
70 for(
int l=0;
l<maxLayers;
l++) {
73 oldL =
l-offsetEndcapPixels;
74 oldL = oldL < M ? oldL : oldL - M;
75 oldL += offsetEndcapPixels;
109 long first_layer = 0;
110 long offset_layer = 1;
119 double dphi = ZF_dphiBrl[lyrcnt + 7*first_layer];
138 for (
long lyrpair=12*first_layer ; lyrpair<117; ++lyrpair ) {
140 double dphi = ZF_dphiEC[lyrpair*4+2];
143 long l1 = (long)ZF_dphiEC[lyrpair*4] + offset_layer;
144 long l2 = (long)ZF_dphiEC[lyrpair*4+1] + offset_layer;
145 double eta = ZF_dphiEC[lyrpair*4+3];
167 return (z2*r1-z1*r2)/(r1-r2);
171 double r2,
double p2,
double z2)
const {
185 double invslope = 1./slope;
186 double x0 = (slope*
x1-
y1)/(slope+invslope);
188 double d0sqr = x0*x0*(1+invslope*invslope);
190 double s1 = sqrt(r1*r1-d0sqr);
191 double s2 = sqrt(r2*r2-d0sqr);
195 double s1 = ( dotrr - r1*r1 ) * inv_dels;
196 double s2 = ( r2*r2 - dotrr ) * inv_dels;
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;
377 std::vector<typename TrigZFinderInternal::vertex>*
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] );
573 std::sort( n3.begin(), n3.end() );
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++ ) {