ATLAS Offline Software
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
TrigZFinderInternal Class Reference

#include <TrigZFinderInternal.h>

Inheritance diagram for TrigZFinderInternal:
Collaboration diagram for TrigZFinderInternal:

Classes

struct  vertex
 

Public Member Functions

 TrigZFinderInternal (const std::string &, const std::string &)
 
virtual ~TrigZFinderInternal ()
 
void initializeInternal (long maxLayers, long lastBarrel)
 
std::vector< vertex > * findZInternal (const std::vector< TrigSiSpacePointBase > &spVec, const IRoiDescriptor &roi) const
 
void setLayers (long maxLayers, long lastBarrelLayer)
 

Protected Member Functions

const std::string & getType () const
 
const std::string & getName () const
 
long fillVectors (const std::vector< TrigSiSpacePointBase > &spVec, const IRoiDescriptor &roi, std::vector< double > &phi, std::vector< double > &rho, std::vector< double > &zed, std::vector< long > &lyr, std::vector< long > &filledLayers, long &numPhiSlices) const
 
double computeZV (double r1, double z1, double r2, double z2) const
 
double computeZV (double r1, double p1, double z1, double r2, double p2, double z2) const
 

Protected Attributes

long m_IdScan_MaxNumLayers
 maximum number of layers and last barrel layer More...
 
long m_IdScan_LastBrlLayer
 
double m_invPhiSliceSize = 0.0
 
long m_NumPhiSlices = 0L
 
double m_phiBinSize
 
bool m_forcePhiBinSize = false
 
double m_usedphiBinSize
 
double m_ROIphiWidth
 
double m_minZBinSize
 
double m_zBinSizeEtaCoeff
 
long m_numberOfPeaks
 
bool m_pixOnly
 
std::string m_type
 
std::string m_name
 
bool m_chargeAware
 
bool m_zHistoPerPhi
 
double m_dphideta
 
double m_neighborMultiplier
 
std::vector< std::vector< long > > m_extraPhi
 
int m_nFirstLayers
 
double m_vrtxDistCut
 
double m_vrtxMixing
 
int m_nvrtxSeparation
 
bool m_preferCentralZ
 
bool m_trustSPprovider
 
double m_returnval = 0.0
 
bool m_fullScanMode
 
int m_tripletMode
 
double m_tripletDZ
 
double m_tripletDK
 
double m_halfTripletDK
 
double m_tripletDP
 
int m_maxLayer
 
double m_minVtxSignificance
 
double m_percentile
 
double m_weightThreshold
 to apply a threshold to the found vertex candidates More...
 
std::vector< int > m_new2old
 

Detailed Description

Definition at line 34 of file TrigZFinderInternal.h.

Constructor & Destructor Documentation

◆ TrigZFinderInternal()

TrigZFinderInternal::TrigZFinderInternal ( const std::string &  type,
const std::string &  name 
)

to allow variable size layers

Definition at line 13 of file TrigZFinderInternal.cxx.

14  : m_type (type),
15  m_name (name)
16 {
17  m_phiBinSize = 0.2 ;
19  m_pixOnly = false ;
20  m_ROIphiWidth = 0.2 ;
21  m_minZBinSize = 0.2 ;
22  m_zBinSizeEtaCoeff = 0.1 ;
23  m_dphideta = -0.02 ;
25  m_numberOfPeaks = 1 ;
26  m_chargeAware = true ;
27  m_zHistoPerPhi = true ;
28  m_nFirstLayers = 3 ;
29  m_vrtxDistCut = 0. ;
30  m_vrtxMixing = 0. ;
31  m_nvrtxSeparation = 0 ;
32  m_preferCentralZ = false ;
33  m_trustSPprovider = true ;
34  m_fullScanMode = false ;
35  m_tripletMode = 0 ;
36  m_tripletDZ = 25. ;
37  m_tripletDK = 0.005 ;
38  m_halfTripletDK = 0.5*m_tripletDK; // using this in internals avoids unnecessary multiplications when calculating curvature
39  m_tripletDP = 0.05 ;
40 
41  m_maxLayer = 32;
42 
44  m_percentile = 1;
45 
46  // m_applyWeightThreshold = false;
48 
49 
51  m_IdScan_MaxNumLayers = 20; // dphiEC depends on this value !!! 19 without IBL, 20 with IBL!!
52  m_IdScan_LastBrlLayer = 7; // dphiBrl depends on this value
53 
54 }

◆ ~TrigZFinderInternal()

virtual TrigZFinderInternal::~TrigZFinderInternal ( )
inlinevirtual

Definition at line 47 of file TrigZFinderInternal.h.

47 {};

Member Function Documentation

◆ computeZV() [1/2]

double TrigZFinderInternal::computeZV ( double  r1,
double  p1,
double  z1,
double  r2,
double  p2,
double  z2 
) const
protected

Definition at line 170 of file TrigZFinderInternal.cxx.

171  {
172 
173  double x1, y1, x2, y2;
174  //sincos( p1, &y1, &x1 ); x1 *= r1; y1 *= r1;
175  //sincos( p2, &y2, &x2 ); x2 *= r2; y2 *= r2;
176  x1 = r1 * cos(p1);
177  x2 = r2 * cos(p2);
178  y1 = r1 * sin(p1);
179  y2 = r2 * sin(p2);
180 
181 #define _COMPUTEX0_
182 
183 #ifdef _COMPUTEX0_
184  double slope = (y2-y1)/(x2-x1);
185  double invslope = 1./slope;
186  double x0 = (slope*x1-y1)/(slope+invslope);
187  //double y0 = -1*x0*invslope;
188  double d0sqr = x0*x0*(1+invslope*invslope);
189  // s1 and s2 are the track lengths from the point of closest approach
190  double s1 = sqrt(r1*r1-d0sqr);
191  double s2 = sqrt(r2*r2-d0sqr); // or s1*(x1-x0)/(x2-x0)
192 #else
193  double inv_dels = 1./sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) );
194  double dotrr = x1*x2 + y1*y2;
195  double s1 = ( dotrr - r1*r1 ) * inv_dels;
196  double s2 = ( r2*r2 - dotrr ) * inv_dels;
197 #endif
198 
199  return (z2*s1-z1*s2)/(s1-s2);
200 }

◆ computeZV() [2/2]

double TrigZFinderInternal::computeZV ( double  r1,
double  z1,
double  r2,
double  z2 
) const
protected

Definition at line 166 of file TrigZFinderInternal.cxx.

166  {
167  return (z2*r1-z1*r2)/(r1-r2);
168 }

◆ fillVectors()

long TrigZFinderInternal::fillVectors ( const std::vector< TrigSiSpacePointBase > &  spVec,
const IRoiDescriptor roi,
std::vector< double > &  phi,
std::vector< double > &  rho,
std::vector< double > &  zed,
std::vector< long > &  lyr,
std::vector< long > &  filledLayers,
long &  numPhiSlices 
) const
protected

get from roi now

DOES NOT span the phi=pi boundary

DOES span the phi=pi boundary

resize excluding points outside the RoI

Definition at line 203 of file TrigZFinderInternal.cxx.

211 {
212 
213  std::vector<bool> lcount( m_IdScan_MaxNumLayers, false );
214 
215  // full scan check
216  std::vector<TrigSiSpacePointBase>::const_iterator SpItr = spVec.begin();
217 
218  long nSPs = spVec.size();
219 
220  // to shift the phi of space points as if the RoI starts at phi~0
221  // assumes that RoI->phi0() and the SPs are in range [-pi,+pi]
222  //
223  double roiPhiMin, roiPhiMax;
224 
225  if ( m_fullScanMode || roi.isFullscan() ) {
226  roiPhiMin = -M_PI;
227  roiPhiMax = M_PI;
228  }
229  else {
230  // If we trust that all the SPs are properly input, we determine the RoI phi width
231  // using the SPs themselves.
232  // If the RoI phi range is wider than pi, we keep everything as usual.
234  {
235  double roiPhiPosMin( 9.9), roiPhiPosMax(0);
236  double roiPhiNegMin(-9.9), roiPhiNegMax(0); // least negative and most negative
237  for(long i=0; i<nSPs; ++i, ++SpItr)
238  {
239  double spphi = SpItr->phi();
240  if ( spphi>0 && spphi>roiPhiPosMax ) roiPhiPosMax = spphi;
241  if ( spphi>0 && spphi<roiPhiPosMin ) roiPhiPosMin = spphi;
242 
243  if ( spphi<0 && spphi<roiPhiNegMax ) roiPhiNegMax = spphi;
244  if ( spphi<0 && spphi>roiPhiNegMin ) roiPhiNegMin = spphi;
245  }
246 
247  if ( roiPhiNegMax > roiPhiNegMin ) {
248  // if all SPs are in (0, pi):
249  roiPhiMin = roiPhiPosMin;
250  roiPhiMax = roiPhiPosMax;
251  }
252  else if ( roiPhiPosMax < roiPhiPosMin ) {
253  // if all SPs are in (-pi, 0):
254  roiPhiMin = roiPhiNegMax;
255  roiPhiMax = roiPhiNegMin;
256  }
257  else if ( roiPhiPosMin - roiPhiNegMin < M_PI ) {
258  // if we have an RoI that covers phi=0 axis
259  roiPhiMin = roiPhiNegMax;
260  roiPhiMax = roiPhiPosMax;
261  }
262  else {
263  // if we have an RoI that covers phi=pi axis
264  roiPhiMin = roiPhiPosMin;
265  roiPhiMax = roiPhiNegMin;
266  }
267 
268  roiPhiMin -= 1e-10;
269  roiPhiMax += 1e-10;
270 
271  SpItr = spVec.begin(); // rewind the iterator
272  }
273  else {
274 
276  if ( roi.phiMinus()==roi.phiPlus() ) {
277  roiPhiMin = roi.phi()-0.5*m_ROIphiWidth;
278  roiPhiMax = roi.phi()+0.5*m_ROIphiWidth;
279  if(roiPhiMin<-M_PI) roiPhiMin+=2*M_PI;
280  if(roiPhiMax>M_PI) roiPhiMax-=2*M_PI;
281  }
282  else {
283  // already wrapped by RoiDescriptor
284  roiPhiMin = roi.phiMinus();
285  roiPhiMax = roi.phiPlus();
286  }
287 
288  }
289 
290  }
291 
292 
293  double dphi = roiPhiMax-roiPhiMin;
294 
295  if ( dphi<0 ) dphi+=2*M_PI;
296 
297  numPhiSlices = long (ceil( dphi*m_invPhiSliceSize ));
298 
299 
300  bool piBound=(roiPhiMin>roiPhiMax);
301 
302  int icount = 0;
303 
304  if(!piBound)
305  {
307  for(long i=0; i<nSPs; ++i, ++SpItr)
308  {
309  if ( SpItr->layer()>m_maxLayer || (m_pixOnly && !SpItr->isPixel()) ) continue;
310  double phi2 = SpItr->phi() - roiPhiMin;
311 
312  if ( phi2>=0 && phi2<dphi ) { // ensures space point is in ROI
313  phi[icount] = phi2;
314  rho[icount] = SpItr->r();
315  zed[icount] = SpItr->z();
316  lyr[icount] = m_new2old[SpItr->layer()];
317  lcount[lyr[icount]]=true;
318  ++icount;
319  }
320  }
321  }
322  else
323  {
325  for(long i=0; i<nSPs; ++i, ++SpItr)
326  {
327  if ( SpItr->layer()>m_maxLayer || (m_pixOnly && !SpItr->isPixel()) ) continue;
328  double phi2 = SpItr->phi() - roiPhiMin;
329  if( phi2<0.0) phi2+=2*M_PI;
330  if ( phi2>=0 && phi2<dphi ) { // ensures space point is in ROI
331  phi[icount] = phi2;
332  rho[icount] = SpItr->r();
333  zed[icount] = SpItr->z();
334  lyr[icount] = m_new2old[SpItr->layer()];
335  lcount[lyr[icount]]=true;
336  ++icount;
337  }
338  }
339  }
340 
341  if ( icount<nSPs ) {
342 
343  // std::cout << "TrigZFinderInternal::fillVectors() filtered some spacepoints " << nSPs
344  // << " -> " << icount << std::endl;
346  phi.resize(icount);
347  rho.resize(icount);
348  zed.resize(icount);
349  lyr.resize(icount);
350  }
351 
352 
353  // Store in filledLayers the layerNumber of those layers that contain hits.
354  // So, if there are hits in layers 1,3,8 filledLayers[0]=1, filledLayers[1]=3
355  // and filledLayers[2]=8
356  //
357  long filled = 0;
358 
359  for ( long i=0; i<m_IdScan_MaxNumLayers; ++i ) {
360  if ( lcount[i] ) {
361  filledLayers[filled] = i;
362  ++filled;
363  }
364  }
365 
366  // std::cout << "SUTT NSP : " << phi.size() << " " << spVec.size() << std::endl;
367  // for ( unsigned i=0 ; i<phi.size() ; i++ ) {
368  // std::cout << "SUTT SP : " << i << "\tphi " << phi[i] << "\tz " << zed[i] << "\tr " << rho[i] << std::endl;
369  // }
370 
371  return filled;
372 }

◆ findZInternal()

std::vector< typename TrigZFinderInternal::vertex > * TrigZFinderInternal::findZInternal ( const std::vector< TrigSiSpacePointBase > &  spVec,
const IRoiDescriptor roi 
) const

First calculate the pedestal to be subtracted (only used in the HI case at the moment)

skip bins used for the vertex candidates

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

if found a vertex flag the bins so we don't use them again

here we reject those vertex candidates where significance < m_minVtxSignificance

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

NB: if m_weightThreshold==0 then pedestal == 0 also
This is ridiculous, passing parameters about differently because we don't have a proper interface defined

Definition at line 378 of file TrigZFinderInternal.cxx.

379  {
380 
381  std::vector<vertex>* output = new std::vector<vertex>();
382 
383  long nsp = spVec.size();
384  if ( !nsp ) return output; //No points - return nothing
385 
386  // Creating vectors of doubles/longs for storing phi,rho,z and layer of space points.
387  // filledLayers is used to know which of all layers contain space points
388  // and fill with relevant info...
389  //
390  std::vector<double> phi(nsp), rho(nsp), zed(nsp);
391  std::vector<long> lyr(nsp), filledLayers(m_IdScan_MaxNumLayers);
392 
393  long numPhiSlices = 0;
394 
395  long filled = this->fillVectors( spVec, roi, phi, rho, zed, lyr, filledLayers, numPhiSlices );
396 
397  nsp = phi.size();
398 
399  // std::cout << "SUTT roi " << roi << "nsp: " << nsp << std::endl;
400 
401 
402  double zMin = roi.zedMinus();
403  double zMax = roi.zedPlus();
404 
405 
406  // The bin size of the z-histo -and hence the number of bins-
407  // depends on the RoI's |eta| (to account for worsening z-resolution)
408  //
409  const double ZBinSize = m_minZBinSize + m_zBinSizeEtaCoeff*fabs(roi.eta());
410  const double invZBinSize = 1./ZBinSize;
411 
412 
413  const long HalfZhistoBins = long ( ceil( 0.5*(zMax-zMin)*invZBinSize ) );
414  const long NumZhistoBins = 2*HalfZhistoBins;
415 
416  // number of phi bins to look at will get fewer as eta increases
417  const long extraPhiNeg = static_cast<long> ( floor( (0.9 - fabs(roi.eta()))*m_dphideta*m_invPhiSliceSize*m_neighborMultiplier ) );
418 
419 
420 
421  // These are the z-Histograms
422  // Two sets are defined: {n/z}Histo[0][phi][z] will be for positively bending tracks
423  // {n/z}Histo[1][phi][z] will be for negatively bending tracks
424  //
425 
426  long numZhistos = m_zHistoPerPhi ? numPhiSlices : 1 ;
427 
428  // std::vector < std::vector < std::vector<long> > > nHisto( 2, std::vector < std::vector<long> > (numZhistos, std::vector<long> () ) );
429  // std::vector < std::vector < std::vector<double> > > zHisto( 2, std::vector < std::vector<double> > (numZhistos, std::vector<double>() ) );
430 
431  std::vector < std::vector<long> > nHisto[2]; // the actual z histogram count of pairs
432  std::vector < std::vector<double> > zHisto[2]; // summed z position histograms
433 
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); }
436 
437  // std::vector< std::vector<long> >* nHisto = m_nHisto;
438  // std::vector< std::vector<double> >* zHisto = m_zHisto;
439 
440  // nMax = 0;
441 
442  //Make a vector of all the PhiSlice instances we need
443  std::vector< PhiSlice* > allSlices( numPhiSlices );
444  for ( unsigned int sliceIndex = 0; sliceIndex < numPhiSlices; sliceIndex++ )
445  {
446  allSlices[ sliceIndex ] = new PhiSlice( sliceIndex, ZBinSize, m_invPhiSliceSize,
449  }
450 
451  int allSlicesSize = allSlices.size();
452 
453  //Populate the slices
454  for ( long pointIndex = 0; pointIndex < nsp; pointIndex++ )
455  {
456  int phiIndex = floor( phi[ pointIndex ] * m_invPhiSliceSize );
457  if (phiIndex > allSlicesSize) {
458  continue;
459  }
460  allSlices[ phiIndex ]->AddPoint( rho[ pointIndex ], zed[ pointIndex ], phi[ pointIndex ], lyr[ pointIndex ] );
461  }
462 
463  //Read out the slices into flat structures for the whole layers
464  std::vector< std::vector< double > > allLayerRhos, allLayerZs, allLayerPhis;
465  allLayerRhos.resize( m_IdScan_MaxNumLayers );
466  allLayerZs.resize( m_IdScan_MaxNumLayers );
467  allLayerPhis.resize( m_IdScan_MaxNumLayers );
468 
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++ )
471  {
472  allSlices[ sliceIndex ]->MakeWideLayers( &allLayerRhos, &allLayerZs, &allLayerPhis, &allSliceWidths, filled, &filledLayers );
473  }
474 
475  //One histogram per phi slice?
476  if ( m_zHistoPerPhi )
477  {
478  //Allocate all the histograms
479  for ( unsigned int sliceIndex = 0; sliceIndex < numPhiSlices; sliceIndex++ )
480  {
481  nHisto[0][sliceIndex].resize( NumZhistoBins + 1 );
482  zHisto[0][sliceIndex].resize( NumZhistoBins + 1 );
483  }
484  if ( m_chargeAware ) {
485  for ( unsigned int sliceIndex = 0; sliceIndex < numPhiSlices; sliceIndex++ ) {
486  nHisto[1][sliceIndex].resize( NumZhistoBins + 1 );
487  zHisto[1][sliceIndex].resize( NumZhistoBins + 1 );
488  }
489  }
490 
491  //Populate the histograms
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] ),
495  m_extraPhi, extraPhiNeg, m_nFirstLayers, m_tripletMode, m_chargeAware, nHisto, zHisto );
496 
497  //Note the extra arguments here - pointers to the whole histogram collection
498  //This allows the filling of neighbouring slice histograms as required, but breaks thread safety
499 
500  delete allSlices[ sliceIndex ];
501  }
502  }
503  else {
504  //Allocate the z-axis histograms
505  nHisto[0][0].resize( NumZhistoBins + 1 );
506  zHisto[0][0].resize( NumZhistoBins + 1 );
507  if ( m_chargeAware ) {
508  nHisto[1][0].resize( NumZhistoBins + 1 );
509  zHisto[1][0].resize( NumZhistoBins + 1 );
510  }
511 
512  //Populate the histogram - fast and memory-efficient, but not thread safe (use MakeHistogram for thread safety)
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] ),
517 
518  delete allSlices[ sliceIndex ];
519  }
520  }
521 
522 
523 
526 
527  double pedestal = 0;
528 
529  if ( m_weightThreshold>0 ) {
530 
531  int count = 0;
532 
533  for ( long zpm=0; zpm<1 || ( m_chargeAware && zpm<2 ) ; ++zpm ) {
534 
535  for(std::vector< std::vector<long> >::iterator nfiter = nHisto[zpm].begin(); nfiter!=nHisto[zpm].end(); ++nfiter) {
536 
537  if((*nfiter).empty()) continue; // only check the filled zHistos
538  if((*nfiter).size() <= 2 ) continue;// this is only a protection : with proper inputs to zfinder, it is always satisfied
539 
540  for(std::vector<long>::iterator niter=nfiter->begin()+2; niter!=nfiter->end(); ++niter ) {
542  if ( *niter>=0 ) {
543  count++;
544  pedestal += *(niter) + *(niter-1) + *(niter-2);
545  }
546  }
547  }
548  }
549 
550  if ( count>0 ) pedestal /= count;
551 
552  }
553 
554 
561 
562  double bg = 0;
563 
564  if ( m_minVtxSignificance > 0 ) {
565 
566  if ( !m_chargeAware ) {
567 
568  std::vector<long>& n = nHisto[0][0];
569 
570  std::vector<long> n3( nHisto[0][0].size()-2, 0);
571 
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() );
574 
575  unsigned nmax = unsigned(n3.size()*m_percentile);
576 
577  for( unsigned i=nmax ; i-- ; ) bg += n3[i];
578 
579  if ( nmax>0 ) bg /= nmax;
580 
581  }
582  }
583 
584 
585 
586  // Now the nHisto's are filled; find the 3 consecutive bins with the highest number of entries...
587  //
588 
589  std::vector<double> zoutput;
590  std::vector<double> woutput;
591 
592 
593 
594  while((int)zoutput.size() < m_numberOfPeaks) {
595 
596  long maxh=0; // was 1 before triplets were introduced
597  long binMax=0;
598  long bending=0, bestPhi=0;
599  long ztest;
600 
601  for ( long zpm=0; zpm<1 || ( m_chargeAware && zpm<2 ) ; ++zpm ) {
602 
603  std::vector< std::vector<long> >::iterator nfiter = nHisto[zpm].begin();
604  for( ; nfiter!=nHisto[zpm].end() ; ++nfiter) {
605 
606  if((*nfiter).empty()) continue; // only check the filled zHistos
607  if((*nfiter).size() <= 2 ) continue;// this is only a protection : with proper inputs to zfinder, it is always satisfied
608 
609  for(std::vector<long>::iterator niter=(*nfiter).begin()+2; niter!=(*nfiter).end(); ++niter ) {
610 
611  ztest = *(niter-2) + *(niter-1) + *(niter);
612  if ( ztest <= 0 || ztest < maxh ) continue;
615  if ( ztest >= maxh ) { // && ztest>m_weightThreshold ) {
616  long bintest = niter-(*nfiter).begin()-1;
617  if ( ztest > maxh ||
618  // for two candidates at same "height", prefer the more central one
619  (m_preferCentralZ && std::abs( bintest - HalfZhistoBins ) < std::abs( binMax - HalfZhistoBins ) ) ) {
620  maxh = ztest;
621  binMax = bintest;
622  bestPhi = nfiter-nHisto[zpm].begin();
623  bending = zpm;
624  }
625  }
626  }// end of niter loop
627  }
628  }
629 
630  // nMax = maxh;
633  if ( maxh==0 || ( m_tripletMode==0 && maxh<2 ) ) {
634  break;
635  }
636 
637  // ...and compute the "entries-weighted" average bin position
638 
639  double weightedMax = ( zHisto[bending][bestPhi][binMax] +
640  zHisto[bending][bestPhi][binMax+1] +
641  zHisto[bending][bestPhi][binMax-1] ) /maxh;
642 
644  if ( m_numberOfPeaks>0 ) {
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;
651  }
652 
653  int closestVtx = -1; // find the closest vertex already put into the output list
654  float dist2closestVtx = 1000; // should be larger than m_ZFinder_MaxZ*2
655  for ( size_t iv = 0; iv < zoutput.size(); ++iv ) {
656  if ( fabs(weightedMax-zoutput[iv]) < dist2closestVtx ) {
657  closestVtx = iv;
658  dist2closestVtx = fabs(weightedMax-zoutput[iv]);
659  }
660  }
661 
662  if ( dist2closestVtx < m_nvrtxSeparation*ZBinSize || dist2closestVtx < fabs(weightedMax)*m_vrtxDistCut ) {
663  zoutput[closestVtx] = m_vrtxMixing * weightedMax + (1.0 - m_vrtxMixing) * zoutput[closestVtx] ;
664  woutput[closestVtx] = m_vrtxMixing * maxh + (1.0 - m_vrtxMixing) * woutput[closestVtx] ;
665  }
666  else {
667 
670  bool addvtx = true;
671  double significance = 0;
672  if ( bg>0 ) {
673  significance = (maxh-bg)/std::sqrt(bg);
674  if ( significance < m_minVtxSignificance ) break; // if this vertex is not significant then no subsequent vertex could be either
675  }
676 
677  if ( addvtx ) {
678  zoutput.push_back( weightedMax );
679  woutput.push_back( maxh );
680  }
681  }
682 
683  }
684 
685 
690 
698 
701 
702 
706  if ( m_weightThreshold>0 ) {
707  for ( unsigned i=0 ; i<zoutput.size() ; i++ ) {
708  output->push_back( vertex( woutput[i] - pedestal, zoutput[i] ) );
709  }
710  }
711  else {
712  for ( unsigned i=0 ; i<zoutput.size() ; i++ ) {
713  output->push_back( vertex( zoutput[i], woutput[i] - pedestal ) );
714  }
715  }
716 
717  // std::cout << "SUTT zoutput size " << zoutput.size() << "\t" << roi << std::endl;
718  // for ( unsigned i=0 ; i<zoutput.size() ; i++ ) std::cout << "SUTT zoutput " << i << "\t" << zoutput[i] << std::endl;
719 
720  return output;
721 
722 }

◆ getName()

const std::string& TrigZFinderInternal::getName ( ) const
inlineprotected

Definition at line 62 of file TrigZFinderInternal.h.

62 { return m_name; }

◆ getType()

const std::string& TrigZFinderInternal::getType ( ) const
inlineprotected

Definition at line 61 of file TrigZFinderInternal.h.

61 { return m_type; }

◆ initializeInternal()

void TrigZFinderInternal::initializeInternal ( long  maxLayers,
long  lastBarrel 
)

the number of phi slices (numPhiSlices) has to be computed event by event !!!

barrel

standard Endcap

increment all the layer ids by one because of the IBL IF and ONLY IF the IBL is included

Definition at line 58 of file TrigZFinderInternal.cxx.

59 {
61 
62  m_IdScan_MaxNumLayers = maxLayers;
63  m_IdScan_LastBrlLayer = lastBarrel;
64 
65  //initialize new/old layer number transform table
66 
67  if(maxLayers > 20) {
68  int offsetEndcapPixels = lastBarrel + 1;
69  int M = (maxLayers-offsetEndcapPixels)/2;
70  for(int l=0;l<maxLayers;l++) {
71  int oldL = l;
72  if(l>lastBarrel) {
73  oldL = l-offsetEndcapPixels;
74  oldL = oldL < M ? oldL : oldL - M;
75  oldL += offsetEndcapPixels;
76  }
77  m_new2old.push_back(oldL);
78  }
79  m_IdScan_MaxNumLayers = lastBarrel + M + 1;
80  } else {
81  for(int l=0;l<maxLayers;l++) m_new2old.push_back(l);
82  }
83 
84 
85  // std::cout << "m_IdScan_MaxNumLayers " << m_IdScan_MaxNumLayers
86  // << "\tm_IdScan_LastBrlLayer " << m_IdScan_LastBrlLayer << std::endl;
87 
88  // number of phi neighbours to look at
89  // if ( extraPhi.size()==0 )
90 
91  m_extraPhi = std::vector< std::vector<long> >( m_IdScan_MaxNumLayers, std::vector<long>(m_IdScan_MaxNumLayers) );
92 
93  // from TrigZFinder::initialize
96  if ( m_dphideta > 0 ) m_dphideta *= -m_dphideta;
97 
100 
101  for (long l1=0; l1<m_IdScan_MaxNumLayers-1; ++l1) {
102  for (long l2=l1+1; l2<m_IdScan_MaxNumLayers; ++l2) {
103  m_extraPhi[l1][l2]=1; // look at a single phi neighbour
104  }
105  }
106 
108 
109  long first_layer = 0;
110  long offset_layer = 1;
111  if ( m_IdScan_MaxNumLayers<20 ) {
112  first_layer = 1;
113  offset_layer = 0;
114  }
115 
116  long lyrcnt = 0;
117  for (long l1=0; l1<m_IdScan_LastBrlLayer; ++l1) {
118  for (long l2=l1+1; l2<=m_IdScan_LastBrlLayer; ++l2) {
119  double dphi = ZF_dphiBrl[lyrcnt + 7*first_layer];
120  dphi *= m_neighborMultiplier;
121  m_extraPhi[l1][l2]=static_cast<long>( ceil( sqrt(dphi*dphi+ZF_phiRes*ZF_phiRes*2) * m_invPhiSliceSize ) );
122 
123  // std::cout << "test 1 " << l1 << " " << l2 << "\tmax : " << m_IdScan_MaxNumLayers << std::endl;
124 
125  if (m_extraPhi[l1][l2]<1) m_extraPhi[l1][l2]=1;
126  // std::cout << "Delta Phi between layers " << l1 << " and " << l2
127  // << " = "<< ZF_dphiBrl[lyrcnt]
128  // << " rads ( " << m_extraPhi[l1][l2] << " bins including phi resln.)\n";
129  lyrcnt++;
130  }
131  }
132 
133 
135 
136 
137 
138  for ( long lyrpair=12*first_layer ; lyrpair<117; ++lyrpair ) {
139 
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];
146  // std::cout << "Delta Phi between layers " << l1 << " and " << l2
147  // << " = " << dphi << " rads @ eta=" << eta
148  // << ". Extrapolate it to eta=0.9 to get ";
149  dphi = dphi + m_dphideta * ( 0.9 - eta );
150  dphi *= m_neighborMultiplier;
151  m_extraPhi[l1][l2]=static_cast<long>(ceil(sqrt(dphi*dphi+ZF_phiRes*ZF_phiRes*2)*m_invPhiSliceSize));
152 
153  if (m_extraPhi[l1][l2]<1) m_extraPhi[l1][l2]=1;
154 
155  // std::cout << "test 2 " << l1 << " " << l2 << "\tmax : " << m_IdScan_MaxNumLayers << std::endl;
156 
157  // std::cout << dphi << " rads ( " << m_extraPhi[l1][l2] << " bins including phi resln.)\n";
158  }
159 
160 }

◆ setLayers()

void TrigZFinderInternal::setLayers ( long  maxLayers,
long  lastBarrelLayer 
)
inline

Definition at line 54 of file TrigZFinderInternal.h.

54  {
55  m_IdScan_MaxNumLayers = maxLayers; // dphiEC depends on this value
56  m_IdScan_LastBrlLayer = lastBarrelLayer; // dphiBrl depends on this value
57  }

Member Data Documentation

◆ m_chargeAware

bool TrigZFinderInternal::m_chargeAware
protected

Definition at line 108 of file TrigZFinderInternal.h.

◆ m_dphideta

double TrigZFinderInternal::m_dphideta
protected

Definition at line 111 of file TrigZFinderInternal.h.

◆ m_extraPhi

std::vector< std::vector<long> > TrigZFinderInternal::m_extraPhi
protected

Definition at line 114 of file TrigZFinderInternal.h.

◆ m_forcePhiBinSize

bool TrigZFinderInternal::m_forcePhiBinSize = false
protected

Definition at line 94 of file TrigZFinderInternal.h.

◆ m_fullScanMode

bool TrigZFinderInternal::m_fullScanMode
protected

Definition at line 128 of file TrigZFinderInternal.h.

◆ m_halfTripletDK

double TrigZFinderInternal::m_halfTripletDK
protected

Definition at line 133 of file TrigZFinderInternal.h.

◆ m_IdScan_LastBrlLayer

long TrigZFinderInternal::m_IdScan_LastBrlLayer
protected

Definition at line 85 of file TrigZFinderInternal.h.

◆ m_IdScan_MaxNumLayers

long TrigZFinderInternal::m_IdScan_MaxNumLayers
protected

maximum number of layers and last barrel layer

Definition at line 84 of file TrigZFinderInternal.h.

◆ m_invPhiSliceSize

double TrigZFinderInternal::m_invPhiSliceSize = 0.0
protected

Definition at line 90 of file TrigZFinderInternal.h.

◆ m_maxLayer

int TrigZFinderInternal::m_maxLayer
protected

Definition at line 136 of file TrigZFinderInternal.h.

◆ m_minVtxSignificance

double TrigZFinderInternal::m_minVtxSignificance
protected

Definition at line 138 of file TrigZFinderInternal.h.

◆ m_minZBinSize

double TrigZFinderInternal::m_minZBinSize
protected

Definition at line 97 of file TrigZFinderInternal.h.

◆ m_name

std::string TrigZFinderInternal::m_name
protected

Definition at line 105 of file TrigZFinderInternal.h.

◆ m_neighborMultiplier

double TrigZFinderInternal::m_neighborMultiplier
protected

Definition at line 112 of file TrigZFinderInternal.h.

◆ m_new2old

std::vector<int> TrigZFinderInternal::m_new2old
protected

Definition at line 146 of file TrigZFinderInternal.h.

◆ m_nFirstLayers

int TrigZFinderInternal::m_nFirstLayers
protected

Definition at line 117 of file TrigZFinderInternal.h.

◆ m_numberOfPeaks

long TrigZFinderInternal::m_numberOfPeaks
protected

Definition at line 100 of file TrigZFinderInternal.h.

◆ m_NumPhiSlices

long TrigZFinderInternal::m_NumPhiSlices = 0L
protected

Definition at line 91 of file TrigZFinderInternal.h.

◆ m_nvrtxSeparation

int TrigZFinderInternal::m_nvrtxSeparation
protected

Definition at line 121 of file TrigZFinderInternal.h.

◆ m_percentile

double TrigZFinderInternal::m_percentile
protected

Definition at line 139 of file TrigZFinderInternal.h.

◆ m_phiBinSize

double TrigZFinderInternal::m_phiBinSize
protected

Definition at line 93 of file TrigZFinderInternal.h.

◆ m_pixOnly

bool TrigZFinderInternal::m_pixOnly
protected

Definition at line 102 of file TrigZFinderInternal.h.

◆ m_preferCentralZ

bool TrigZFinderInternal::m_preferCentralZ
protected

Definition at line 122 of file TrigZFinderInternal.h.

◆ m_returnval

double TrigZFinderInternal::m_returnval = 0.0
protected

Definition at line 126 of file TrigZFinderInternal.h.

◆ m_ROIphiWidth

double TrigZFinderInternal::m_ROIphiWidth
protected

Definition at line 96 of file TrigZFinderInternal.h.

◆ m_tripletDK

double TrigZFinderInternal::m_tripletDK
protected

Definition at line 132 of file TrigZFinderInternal.h.

◆ m_tripletDP

double TrigZFinderInternal::m_tripletDP
protected

Definition at line 134 of file TrigZFinderInternal.h.

◆ m_tripletDZ

double TrigZFinderInternal::m_tripletDZ
protected

Definition at line 131 of file TrigZFinderInternal.h.

◆ m_tripletMode

int TrigZFinderInternal::m_tripletMode
protected

Definition at line 130 of file TrigZFinderInternal.h.

◆ m_trustSPprovider

bool TrigZFinderInternal::m_trustSPprovider
protected

Definition at line 124 of file TrigZFinderInternal.h.

◆ m_type

std::string TrigZFinderInternal::m_type
protected

Definition at line 104 of file TrigZFinderInternal.h.

◆ m_usedphiBinSize

double TrigZFinderInternal::m_usedphiBinSize
protected

Definition at line 95 of file TrigZFinderInternal.h.

◆ m_vrtxDistCut

double TrigZFinderInternal::m_vrtxDistCut
protected

Definition at line 119 of file TrigZFinderInternal.h.

◆ m_vrtxMixing

double TrigZFinderInternal::m_vrtxMixing
protected

Definition at line 120 of file TrigZFinderInternal.h.

◆ m_weightThreshold

double TrigZFinderInternal::m_weightThreshold
protected

to apply a threshold to the found vertex candidates

Definition at line 144 of file TrigZFinderInternal.h.

◆ m_zBinSizeEtaCoeff

double TrigZFinderInternal::m_zBinSizeEtaCoeff
protected

Definition at line 98 of file TrigZFinderInternal.h.

◆ m_zHistoPerPhi

bool TrigZFinderInternal::m_zHistoPerPhi
protected

Definition at line 109 of file TrigZFinderInternal.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
IRoiDescriptor::phi
virtual double phi() const =0
Methods to retrieve data members.
TrigZFinderInternal::m_tripletDP
double m_tripletDP
Definition: TrigZFinderInternal.h:134
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
ReadCellNoiseFromCoolCompare.s1
s1
Definition: ReadCellNoiseFromCoolCompare.py:378
TrigZFinderInternal::m_numberOfPeaks
long m_numberOfPeaks
Definition: TrigZFinderInternal.h:100
TrigZFinderInternal::m_pixOnly
bool m_pixOnly
Definition: TrigZFinderInternal.h:102
Merge_LAr_blobs.filled
list filled
Definition: Merge_LAr_blobs.py:43
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
TrigZFinderInternal::m_extraPhi
std::vector< std::vector< long > > m_extraPhi
Definition: TrigZFinderInternal.h:114
StandaloneBunchgroupHandler.bg
bg
Definition: StandaloneBunchgroupHandler.py:243
TrigZFinderInternal::m_zBinSizeEtaCoeff
double m_zBinSizeEtaCoeff
Definition: TrigZFinderInternal.h:98
TrigZFinderInternal::m_trustSPprovider
bool m_trustSPprovider
Definition: TrigZFinderInternal.h:124
TrigZFinderInternal::m_preferCentralZ
bool m_preferCentralZ
Definition: TrigZFinderInternal.h:122
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
TrigZFinderInternal::m_phiBinSize
double m_phiBinSize
Definition: TrigZFinderInternal.h:93
plotBeamSpotCompare.x2
x2
Definition: plotBeamSpotCompare.py:218
TrigZFinderInternal::m_chargeAware
bool m_chargeAware
Definition: TrigZFinderInternal.h:108
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
TrigZFinderInternal::m_IdScan_LastBrlLayer
long m_IdScan_LastBrlLayer
Definition: TrigZFinderInternal.h:85
TrigZFinderInternal::m_vrtxDistCut
double m_vrtxDistCut
Definition: TrigZFinderInternal.h:119
M_PI
#define M_PI
Definition: ActiveFraction.h:11
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
TrigZFinderInternal::m_maxLayer
int m_maxLayer
Definition: TrigZFinderInternal.h:136
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
TrigZFinderInternal::m_usedphiBinSize
double m_usedphiBinSize
Definition: TrigZFinderInternal.h:95
MCP::ScaleSmearParam::r2
@ r2
xAOD::unsigned
unsigned
Definition: RingSetConf_v1.cxx:662
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
makeTRTBarrelCans.y1
tuple y1
Definition: makeTRTBarrelCans.py:15
TrigZFinderInternal::m_weightThreshold
double m_weightThreshold
to apply a threshold to the found vertex candidates
Definition: TrigZFinderInternal.h:144
TrigZFinderInternal::m_fullScanMode
bool m_fullScanMode
Definition: TrigZFinderInternal.h:128
TrigZFinderInternal::m_type
std::string m_type
Definition: TrigZFinderInternal.h:104
TrigZFinderInternal::m_zHistoPerPhi
bool m_zHistoPerPhi
Definition: TrigZFinderInternal.h:109
TrigZFinderInternal::m_nFirstLayers
int m_nFirstLayers
Definition: TrigZFinderInternal.h:117
TrigZFinderInternal::m_ROIphiWidth
double m_ROIphiWidth
Definition: TrigZFinderInternal.h:96
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
IRoiDescriptor::eta
virtual double eta() const =0
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
TrigZFinderInternal::m_vrtxMixing
double m_vrtxMixing
Definition: TrigZFinderInternal.h:120
skel.l2
l2
Definition: skel.GENtoEVGEN.py:399
TrigZFinderInternal::m_neighborMultiplier
double m_neighborMultiplier
Definition: TrigZFinderInternal.h:112
ZF_phiRes
const double ZF_phiRes
Definition: ZFinderConstants.h:37
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrigZFinderInternal::m_invPhiSliceSize
double m_invPhiSliceSize
Definition: TrigZFinderInternal.h:90
beamspotman.n
n
Definition: beamspotman.py:731
TrigZFinderInternal::m_IdScan_MaxNumLayers
long m_IdScan_MaxNumLayers
maximum number of layers and last barrel layer
Definition: TrigZFinderInternal.h:84
PhiSlice
Definition: PhiSlice.h:13
makeTRTBarrelCans.y2
tuple y2
Definition: makeTRTBarrelCans.py:18
TrigZFinderInternal::m_new2old
std::vector< int > m_new2old
Definition: TrigZFinderInternal.h:146
IRoiDescriptor::phiMinus
virtual double phiMinus() const =0
TrigZFinderInternal::m_tripletMode
int m_tripletMode
Definition: TrigZFinderInternal.h:130
MuonR4::SegmentFit::ParamDefs::x0
@ x0
TrigZFinderInternal::m_nvrtxSeparation
int m_nvrtxSeparation
Definition: TrigZFinderInternal.h:121
TrigZFinderInternal::m_forcePhiBinSize
bool m_forcePhiBinSize
Definition: TrigZFinderInternal.h:94
IRoiDescriptor::phiPlus
virtual double phiPlus() const =0
extreme phi values
merge.output
output
Definition: merge.py:17
TrigZFinderInternal::m_minVtxSignificance
double m_minVtxSignificance
Definition: TrigZFinderInternal.h:138
TrigZFinderInternal::m_halfTripletDK
double m_halfTripletDK
Definition: TrigZFinderInternal.h:133
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ZFinder_MinPhiSliceSize
const double ZFinder_MinPhiSliceSize
Definition: ZFinderConstants.h:34
TrigZFinderInternal::m_tripletDZ
double m_tripletDZ
Definition: TrigZFinderInternal.h:131
eflowRec::phiIndex
unsigned int phiIndex(float phi, float binsize)
calculate phi index for a given phi
Definition: EtaPhiLUT.cxx:23
TrigZFinderInternal::m_percentile
double m_percentile
Definition: TrigZFinderInternal.h:139
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
IRoiDescriptor::zedPlus
virtual double zedPlus() const =0
the zed and eta values at the most forward and most rear ends of the RoI
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
TrigZFinderInternal::m_dphideta
double m_dphideta
Definition: TrigZFinderInternal.h:111
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
ReadCellNoiseFromCoolCompare.s2
s2
Definition: ReadCellNoiseFromCoolCompare.py:379
IRoiDescriptor::isFullscan
virtual bool isFullscan() const =0
is this a full detector RoI?
IRoiDescriptor::zedMinus
virtual double zedMinus() const =0
skel.l1
l1
Definition: skel.GENtoEVGEN.py:398
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
CreatePhysValWebPage.nHisto
nHisto
Definition: CreatePhysValWebPage.py:89
MCP::ScaleSmearParam::r1
@ r1
TrigZFinderInternal::m_tripletDK
double m_tripletDK
Definition: TrigZFinderInternal.h:132
TrigZFinderInternal::m_name
std::string m_name
Definition: TrigZFinderInternal.h:105
nmax
const int nmax(200)
TrigZFinderInternal::m_minZBinSize
double m_minZBinSize
Definition: TrigZFinderInternal.h:97
fitman.rho
rho
Definition: fitman.py:532
TrigZFinderInternal::fillVectors
long fillVectors(const std::vector< TrigSiSpacePointBase > &spVec, const IRoiDescriptor &roi, std::vector< double > &phi, std::vector< double > &rho, std::vector< double > &zed, std::vector< long > &lyr, std::vector< long > &filledLayers, long &numPhiSlices) const
Definition: TrigZFinderInternal.cxx:203