LCOV - code coverage report
Current view: top level - HLT/ITS/trackingSAP - AliITSSAPAux.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 3 0.0 %
Date: 2016-06-14 17:26:59 Functions: 0 1 0.0 %

          Line data    Source code
       1             : #ifndef ALIITSSAPAUX_H
       2             : #define ALIITSSAPAUX_H
       3             : 
       4             : ///////////////////////////////////////////////////////////////////////
       5             : //                                                                   //
       6             : //  Namespace AliITSSAPAux                                             //
       7             : //  Set of utilities for the XXX classes                            //
       8             : //                                                                   //
       9             : ///////////////////////////////////////////////////////////////////////
      10             : 
      11             : 
      12             : namespace AliITSSAPAux {
      13             :   void   BringTo02Pi(double &phi);
      14             :   void   BringTo02Pi(float  &phi);
      15             :   bool   OKforPhiMin(double phiMin,double phi);
      16             :   bool   OKforPhiMax(double phiMax,double phi);
      17             :   double MeanPhiSmall(double phi0, double phi1);
      18             :   double DeltaPhiSmall(double phi0, double phi1);
      19             :   //
      20             :   bool   OKforPhiMin(float phiMin,float phi);
      21             :   bool   OKforPhiMax(float phiMax,float phi);
      22             :   float  MeanPhiSmall(float phi0, float phi1);
      23             :   float  DeltaPhiSmall(float phi0, float phi1);
      24             : 
      25             :   unsigned int PackCluster(int lr, int clID);
      26             :   int    UnpackCluster(unsigned int p, int &lr);
      27             :   int    UnpackLayer(unsigned int p);
      28             :   int    UnpackCluster(unsigned int p);
      29             :   bool   IsCluster(unsigned int p);
      30             :   int    NumberOfBitsSet(unsigned int x);
      31             :   void   PrintBits(unsigned long long patt, int maxBits);
      32             :   //
      33             :   const double   kNominalBz = 5.01;           // nominal field
      34             :   const double   kPionMass  = 1.3957e-01;
      35             :   const double   kPi  = 3.14159265358979312e+00;
      36             :   const double   k2Pi = 2*kPi;
      37             :   const unsigned int   kLrBitLow  = 28;             // layer mask lowest bit
      38             :   const unsigned int   kLrMask    = 0xf0000000;     // layer mask
      39             :   const unsigned int   kClMask    = 0x0fffffff;     // cluster mask
      40             :   const unsigned int   kMaxLayers = 15;             // max number of active layers
      41             :   const unsigned int   kMaxLrMask = 0x7fff;         // bitmask for allowed layers
      42             : }
      43             : 
      44             : //_________________________________________________________________________________
      45             : inline void AliITSSAPAux::BringTo02Pi(double &phi) {   
      46             :   // bring phi to 0-2pi range
      47             :   while (phi<0) phi+=k2Pi; 
      48             :   while (phi>k2Pi) phi-=k2Pi;
      49             : }
      50             : 
      51             : //_________________________________________________________________________________
      52             : inline void AliITSSAPAux::BringTo02Pi(float &phi) {   
      53             :   // bring phi to 0-2pi range
      54           0 :   while (phi<0) phi+=k2Pi; 
      55           0 :   while (phi>k2Pi) phi-=k2Pi;
      56           0 : }
      57             : 
      58             : //_________________________________________________________________________________
      59             : inline bool AliITSSAPAux::OKforPhiMin(double phiMin,double phi) {
      60             :   // check if phi is above the phiMin, phi's must be in 0-2pi range
      61             :   double dphi = phi-phiMin;
      62             :   return ((dphi>0 && dphi<kPi) || dphi<-kPi) ? true:false;
      63             : }
      64             : 
      65             : //_________________________________________________________________________________
      66             : inline bool AliITSSAPAux::OKforPhiMin(float phiMin,float phi) {
      67             :   // check if phi is above the phiMin, phi's must be in 0-2pi range
      68             :   float dphi = phi-phiMin;
      69             :   return ((dphi>0 && dphi<kPi) || dphi<-kPi) ? true:false;
      70             : }
      71             : 
      72             : //_________________________________________________________________________________
      73             : inline bool AliITSSAPAux::OKforPhiMax(double phiMax,double phi) {
      74             :   // check if phi is below the phiMax, phi's must be in 0-2pi range
      75             :   double dphi = phi-phiMax;
      76             :   return ((dphi<0 && dphi>-kPi) || dphi>kPi) ? true:false;
      77             : }
      78             : 
      79             : //_________________________________________________________________________________
      80             : inline bool AliITSSAPAux::OKforPhiMax(float phiMax,float phi) {
      81             :   // check if phi is below the phiMax, phi's must be in 0-2pi range
      82             :   float dphi = phi-phiMax;
      83             :   return ((dphi<0 && dphi>-kPi) || dphi>kPi) ? true:false;
      84             : }
      85             : 
      86             : //_________________________________________________________________________________
      87             : inline unsigned int AliITSSAPAux::PackCluster(int lr, int clID) {
      88             :   // pack layer/cluster into single uint
      89             :   unsigned int p = (clID<0 ? 0 : clID+1) + (lr<<=kLrBitLow);
      90             :   return p;
      91             : }
      92             : 
      93             : //_________________________________________________________________________________
      94             : inline int AliITSSAPAux::UnpackCluster(unsigned int p, int &lr) {
      95             :   // unpack layer/cluster
      96             :   lr = (p&kLrMask)>>kLrBitLow;
      97             :   p &= kClMask;
      98             :   return int(p)-1;
      99             : }
     100             : 
     101             : //_________________________________________________________________________________
     102             : inline int AliITSSAPAux::UnpackLayer(unsigned int p) {
     103             :   // unpack layer
     104             :   return (p&kLrMask)>>kLrBitLow;
     105             : }
     106             : 
     107             : //_________________________________________________________________________________
     108             : inline int AliITSSAPAux::UnpackCluster(unsigned int p) {
     109             :   // unpack cluster
     110             :   return int(p&kClMask)-1;
     111             : }
     112             : 
     113             : //_________________________________________________________________________________
     114             : inline bool AliITSSAPAux::IsCluster(unsigned int p) {
     115             :   // does it correspond to cluster?
     116             :   return (p&kClMask);
     117             : }
     118             : 
     119             : //_________________________________________________________________________________
     120             : inline int AliITSSAPAux::NumberOfBitsSet(unsigned int x) {
     121             :   // count number of non-0 bits in 32bit word
     122             :   x = x - ((x >> 1) & 0x55555555);
     123             :   x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
     124             :   return (((x + (x >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
     125             : }
     126             : 
     127             : //_________________________________________________________________________________
     128             : inline double AliITSSAPAux::MeanPhiSmall(double phi0, double phi1) {
     129             :   // return mean phi, assume phis in 0:2pi
     130             :   double phi;
     131             :   if (!OKforPhiMin(phi0,phi1)) {phi=phi0; phi0=phi1; phi1=phi;}
     132             :   if (phi0>phi1) phi = (phi1 - (k2Pi-phi0))/2; // wrap
     133             :   else           phi = (phi0+phi1)/2;
     134             :   BringTo02Pi(phi);
     135             :   return phi;
     136             : }
     137             : 
     138             : //_________________________________________________________________________________
     139             : inline float AliITSSAPAux::MeanPhiSmall(float phi0, float phi1) {
     140             :   // return mean phi, assume phis in 0:2pi
     141             :   float phi;
     142             :   if (!OKforPhiMin(phi0,phi1)) {phi=phi0; phi0=phi1; phi1=phi;}
     143             :   if (phi0>phi1) phi = (phi1 - (k2Pi-phi0))/2; // wrap
     144             :   else           phi = (phi0+phi1)/2;
     145             :   BringTo02Pi(phi);
     146             :   return phi;
     147             : }
     148             : 
     149             : //_________________________________________________________________________________
     150             : inline double AliITSSAPAux::DeltaPhiSmall(double phi0, double phi1) {
     151             :   // return delta phi, assume phis in 0:2pi
     152             :   double del;
     153             :   if (!OKforPhiMin(phi0,phi1)) {del=phi0; phi0=phi1; phi1=del;}
     154             :   del = phi1 - phi0;
     155             :   if (del<0) del += k2Pi;
     156             :   return del;
     157             : }
     158             : 
     159             : //_________________________________________________________________________________
     160             : inline float AliITSSAPAux::DeltaPhiSmall(float phi0, float phi1) {
     161             :   // return delta phi, assume phis in 0:2pi
     162             :   float del;
     163             :   if (!OKforPhiMin(phi0,phi1)) {del=phi0; phi0=phi1; phi1=del;}
     164             :   del = phi1 - phi0;
     165             :   if (del<0) del += k2Pi;
     166             :   return del;
     167             : }
     168             : 
     169             : 
     170             : #endif

Generated by: LCOV version 1.11