CMS 3D CMS Logo

Public Member Functions | Private Types | Private Member Functions | Private Attributes

MSLayersAtAngle Class Reference

#include <MSLayersAtAngle.h>

List of all members.

Public Member Functions

const MSLayerfindLayer (const MSLayer &layer) const
 MSLayersAtAngle ()
 MSLayersAtAngle (const std::vector< MSLayer > &layers)
void print () const
int size () const
float sumX0D (const PixelRecoPointRZ &pointI, const PixelRecoPointRZ &pointM, const PixelRecoPointRZ &pointO) const
float sumX0D (const PixelRecoPointRZ &pointI, const PixelRecoPointRZ &pointO) const
float sumX0D (float zV, int il, int ol, const PixelRecoPointRZ &pointI, const PixelRecoPointRZ &pointO) const
float sumX0D (int il, int ol, const PixelRecoPointRZ &pointI, const PixelRecoPointRZ &pointO) const
void update (const MSLayer &layer)

Private Types

typedef std::vector< MSLayer >
::const_iterator 
LayerItr

Private Member Functions

LayerItr findLayer (const PixelRecoPointRZ &point, LayerItr i1, LayerItr i2) const
void init ()
float sum2RmRn (LayerItr i1, LayerItr i2, float rTarget, const SimpleLineRZ &line) const

Private Attributes

std::vector< int > indeces
std::vector< MSLayertheLayers

Detailed Description

Definition at line 16 of file MSLayersAtAngle.h.


Member Typedef Documentation

typedef std::vector<MSLayer>::const_iterator MSLayersAtAngle::LayerItr [private]

Definition at line 51 of file MSLayersAtAngle.h.


Constructor & Destructor Documentation

MSLayersAtAngle::MSLayersAtAngle ( ) [inline]

Definition at line 19 of file MSLayersAtAngle.h.

{ }
MSLayersAtAngle::MSLayersAtAngle ( const std::vector< MSLayer > &  layers)

Member Function Documentation

const MSLayer * MSLayersAtAngle::findLayer ( const MSLayer layer) const

Definition at line 34 of file MSLayersAtAngle.cc.

References spr::find(), and theLayers.

Referenced by MSLayer::sumX0D(), sumX0D(), and MSLayer::x0().

{
  vector<MSLayer>::const_iterator it =
     find(theLayers.begin(), theLayers.end(), layer);
  return it==theLayers.end() ? 0 : &(*it);  
}
MSLayersAtAngle::LayerItr MSLayersAtAngle::findLayer ( const PixelRecoPointRZ point,
MSLayersAtAngle::LayerItr  ibeg,
MSLayersAtAngle::LayerItr  iend 
) const [private]

Definition at line 181 of file MSLayersAtAngle.cc.

References kinem::EPSILON, and f.

{
  const float BIG=99999.f;
  const float EPSILON = 1.e-8f;
  LayerItr theIt = ibeg; float dist = BIG;
  for (LayerItr it = ibeg; it < iend; it++) {
    float d = it->distance2(point);
    if (d < dist) {
      if (d < EPSILON) return it; 
      dist = d;
      theIt = it;
    }
  }
  return theIt;
}
void MSLayersAtAngle::init ( void  ) [private]

Definition at line 15 of file MSLayersAtAngle.cc.

References i, prof2calltree::l, and python::multivaluedict::sort().

Referenced by update().

                      {
  std::sort(theLayers.begin(), theLayers.end());
  int i = -1; indeces.clear();
  for ( auto const & l :  theLayers ) {
    ++i;
    int sq = l.seqNum();
    if (sq<0) continue; 
    if (sq>=int(indeces.size())) indeces.resize(sq+1,-1);
    indeces[sq]=i;
  }
}
void MSLayersAtAngle::print ( void  ) const

Definition at line 201 of file MSLayersAtAngle.cc.

References gather_cfg::cout, and theLayers.

{
  for (LayerItr it = theLayers.begin(); it != theLayers.end(); it++) 
    cout <<*it<<endl;
}
int MSLayersAtAngle::size ( void  ) const [inline]

Definition at line 41 of file MSLayersAtAngle.h.

{ return theLayers.size(); }
float MSLayersAtAngle::sum2RmRn ( MSLayersAtAngle::LayerItr  i1,
MSLayersAtAngle::LayerItr  i2,
float  rTarget,
const SimpleLineRZ line 
) const [private]

Definition at line 160 of file MSLayersAtAngle.cc.

References SimpleLineRZ::cotLine(), cross(), alignCSCRings::e, and f.

Referenced by sumX0D().

{
  float sum2 = 0.f;
  float cotTh = line.cotLine();
  for (LayerItr it = i1; it < i2; it++) {
    std::pair<PixelRecoPointRZ,bool> cross = it->crossing(line);
    if (cross.second) {
      float x0 = it->x0(cotTh);
      float dr = rTarget-cross.first.r();
      if (x0 > 1.e-5f) dr *= 1.f+0.038f*unsafe_logf<2>(x0); 
      sum2 += x0*dr*dr;
    } 
//  cout << *it << " crossing: "<<cross.second<<endl;
  }
  return sum2;
}
float MSLayersAtAngle::sumX0D ( const PixelRecoPointRZ pointI,
const PixelRecoPointRZ pointO 
) const

Definition at line 54 of file MSLayersAtAngle.cc.

References findLayer(), PixelRecoPointRZ::r(), mathSSE::sqrt(), sum2RmRn(), and theLayers.

Referenced by MultipleScatteringParametrisation::operator()(), and sumX0D().

{
  LayerItr iO = findLayer(pointO, theLayers.begin(), theLayers.end());
//  cout << "outer Layer: "<<*iO<<endl;
  LayerItr iI = findLayer(pointI, theLayers.begin(), iO);
//  cout << "inner Layer: "<<*iI<<endl;

  return sqrt(sum2RmRn(iI,iO, pointO.r(),
                              SimpleLineRZ(pointI, pointO)));
}
float MSLayersAtAngle::sumX0D ( int  il,
int  ol,
const PixelRecoPointRZ pointI,
const PixelRecoPointRZ pointO 
) const

Definition at line 68 of file MSLayersAtAngle.cc.

References indeces, PixelRecoPointRZ::r(), mathSSE::sqrt(), sum2RmRn(), sumX0D(), and theLayers.

{
  // if layer not at this angle (WHY???) revert to slow comp
  if  (il>=int(indeces.size()) || ol>=int(indeces.size()) ||
       indeces[il]<0 || indeces[ol] < 0)  return sumX0D(pointI,pointO);

  LayerItr iI = theLayers.begin() + indeces[il];
  LayerItr iO = theLayers.begin() + indeces[ol];


  return sqrt(sum2RmRn(iI,iO, pointO.r(),
                              SimpleLineRZ(pointI, pointO)));
}
float MSLayersAtAngle::sumX0D ( const PixelRecoPointRZ pointI,
const PixelRecoPointRZ pointM,
const PixelRecoPointRZ pointO 
) const

Definition at line 88 of file MSLayersAtAngle.cc.

References gather_cfg::cout, doPrint, findLayer(), geometryCSVtoXML::line, PixelRecoPointRZ::r(), funct::sqr(), mathSSE::sqrt(), sum2RmRn(), theLayers, and PixelRecoPointRZ::z().

{
  LayerItr iO = findLayer(pointO, theLayers.begin(), theLayers.end());
  LayerItr iI = findLayer(pointI, theLayers.begin(), iO);
  LayerItr iM = findLayer(pointM, iI, iO);


  float drOI = pointO.r() - pointI.r();
  float drMO = pointO.r() - pointM.r();
  float drMI = pointM.r() - pointI.r();

  SimpleLineRZ line(pointI, pointO);
  float sum2I = sum2RmRn(iI+1, iM, pointI.r(), line);
  float sum2O = sum2RmRn(iM, iO, pointO.r(), line);

  float sum =  std::sqrt( sum2I* sqr(drMO) + sum2O*sqr(drMI) )/drOI;
 
 // if (iI!=theLayers.begin() )
 // doPrint = ((*iM).seqNum()<0 || (*iO).seqNum()<0); 
  if (doPrint)
  std::cout << "old " << (*iI).seqNum() << " " << iI-theLayers.begin() << ", "
    << (*iM).seqNum() << " " << iM-theLayers.begin() << ", "
    << (*iO).seqNum() << " " << iO-theLayers.begin() << "  "
    << pointI.r() << " " << pointI.z()
     << " " << sum
     << std::endl;
 

  return sum;
}
float MSLayersAtAngle::sumX0D ( float  zV,
int  il,
int  ol,
const PixelRecoPointRZ pointI,
const PixelRecoPointRZ pointO 
) const

Definition at line 123 of file MSLayersAtAngle.cc.

References gather_cfg::cout, doPrint, f, indeces, geometryCSVtoXML::line, PixelRecoPointRZ::r(), funct::sqr(), mathSSE::sqrt(), sum2RmRn(), sumX0D(), and theLayers.

                                                                     {

  PixelRecoPointRZ pointV(0.f,zV);

  // if layer not at this angle (WHY???) revert to slow comp
  if  (il>=int(indeces.size()) || ol>=int(indeces.size()) ||
       indeces[il]<0 || indeces[ol] < 0)  return sumX0D(pointV,pointI,pointO);

  LayerItr iI = theLayers.begin() + indeces[il];
  LayerItr iO = theLayers.begin() + indeces[ol];



  float drOI = pointO.r();
  float drMO = pointO.r() - pointI.r();
  float drMI = pointI.r();

  SimpleLineRZ line(pointV, pointO);
  float sum2I = sum2RmRn(theLayers.begin()+1, iI, pointV.r(), line);
  float sum2O = sum2RmRn(iI, iO, pointO.r(), line);

  float sum =  std::sqrt( sum2I* sqr(drMO) + sum2O*sqr(drMI) )/drOI;

  if (doPrint)
  std::cout << "new " << il << " " << (*iI).seqNum() << " " << iI-theLayers.begin() << ", "
    << ol << " " << (*iO).seqNum() << " " << iO-theLayers.begin() << "  " << zV
    << " " << sum
    << std::endl;

  return sum;

}
void MSLayersAtAngle::update ( const MSLayer layer)

Definition at line 42 of file MSLayersAtAngle.cc.

References spr::find(), init(), and theLayers.

{
  vector<MSLayer>::iterator it = find(theLayers.begin(),theLayers.end(),layer); 
  if (it == theLayers.end()) {
    theLayers.push_back(layer);
    init();
  } else {
    *it = layer;
  }
}

Member Data Documentation

std::vector<int> MSLayersAtAngle::indeces [private]

Definition at line 46 of file MSLayersAtAngle.h.

Referenced by sumX0D().

std::vector<MSLayer> MSLayersAtAngle::theLayers [private]

Definition at line 45 of file MSLayersAtAngle.h.

Referenced by findLayer(), print(), sumX0D(), and update().