ATLAS Offline Software
Functions
RegSelSiLUT.cxx File Reference
#include "RegSelLUT/RegSelSiLUT.h"
#include "RegSelLUT/RegSelModule.h"
#include "RegSelLUT/RegSelTimer.h"
#include "RegSelLUT/RegSelROB.h"
#include <iostream>
#include <fstream>
#include <set>
Include dependency graph for RegSelSiLUT.cxx:

Go to the source code of this file.

Functions

double phiprime (double x, double y, double phi, double r, bool &status)
 
bool philimits (double x, double y, double rmin, double rmax, double &phimin, double &phimax)
 

Function Documentation

◆ philimits()

bool philimits ( double  x,
double  y,
double  rmin,
double  rmax,
double &  phimin,
double &  phimax 
)

Definition at line 374 of file RegSelSiLUT.cxx.

374  {
375 
376  double phi[4];
377 
378  bool status = true;
379 
380  // std::cout << "phimin=" << phimin << "\tphimax=" << phimax << "\tlimits" << std::endl;
381 
382  phi[0] = phiprime(x, y, phimin, rmin, status);
383  phi[1] = phiprime(x, y, phimin, rmax, status);
384 
385  phi[2] = phiprime(x, y, phimax, rmin, status);
386  phi[3] = phiprime(x, y, phimax, rmax, status);
387 
388  // for ( int i=0 ; i<4 ; i++ ) std::cout << "phi[" << i << "]=" << phi[i] << std::endl;
389 
390  if ( status ) {
391 
392  // this is needed to take account of the phi=pi boundary, it's not rigorous, but it works
393 
394  if ( phi[0]*phi[1]<0 && (phi[0]>0.5*M_PI||phi[1]>0.5*M_PI) ) phimin = ( phi[0]<phi[1] ? phi[1] : phi[0] );
395  else phimin = ( phi[0]<phi[1] ? phi[0] : phi[1] );
396 
397  if ( phi[2]*phi[3]<0 && (phi[2]>0.5*M_PI||phi[3]>0.5*M_PI) ) phimax = ( phi[2]>phi[3] ? phi[3] : phi[2] );
398  else phimax = ( phi[2]>phi[3] ? phi[2] : phi[3] );
399 
400  }
401 
402  // std::cout << "phimin=" << phimin << "\tphimax=" << phimax << "\tlimits (out)" << std::endl;
403 
404  return status;
405 
406 }

◆ phiprime()

double phiprime ( double  x,
double  y,
double  phi,
double  r,
bool &  status 
)

Definition at line 342 of file RegSelSiLUT.cxx.

342  {
343 
344  if ( x*x+y*y>r*r ) {
345  // std::cerr << "duffer x=" << x << "\ty=" << y << "\tr=" << r << std::endl;
346  status = false;
347  return 0;
348  }
349 
350  double a = (y*cos(phi)-x*sin(phi))/r;
351 
352  // this is bad, getting the return value to issue an error code.
353  // ouch! should maybe define an exception and catch it?
354  // this should never happen
355  if ( fabs(a)>1 ) { status = false; return 0; }
356 
357  status &= true;
358 
359  double phip = asin(a)+phi;
360 
361  // std::cout << "phiprime()\tx=" << x << "\ty=" << y << "\tphi=" << phi << "\tr=" << r << "\tphiprime=" << phip << " before" << std::endl;
362 
363  // make sure wrapped between -pi to pi
364  if ( phip>M_PI ) phip = phip-2*M_PI;
365  if ( phip<-M_PI ) phip = phip+2*M_PI;
366 
367  // std::cout << "phiprime()\tx=" << x << "\ty=" << y << "\tphi=" << phi << "\tr=" << r << "\tphiprime=" << phip << std::endl;
368 
369  return phip;
370 
371 }
beamspotman.r
def r
Definition: beamspotman.py:676
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
M_PI
#define M_PI
Definition: ActiveFraction.h:11
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
x
#define x
phiprime
double phiprime(double x, double y, double phi, double r, bool &status)
Definition: RegSelSiLUT.cxx:342
a
TList * a
Definition: liststreamerinfos.cxx:10
y
#define y
merge.status
status
Definition: merge.py:17
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36