CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MSLayersAtAngle.cc
Go to the documentation of this file.
1 
3 
5 using namespace std;
6 
7 template <class T> inline T sqr( T t) {return t*t;}
8 
9 //------------------------------------------------------------------------------
10 MSLayersAtAngle::MSLayersAtAngle(const vector<MSLayer> & layers)
11  : theLayers(layers)
12 { sort(theLayers.begin(), theLayers.end()); }
13 //------------------------------------------------------------------------------
14 const MSLayer * MSLayersAtAngle::findLayer(const MSLayer & layer) const
15 {
16  vector<MSLayer>::const_iterator it =
17  find(theLayers.begin(), theLayers.end(), layer);
18  return it==theLayers.end() ? 0 : &(*it);
19 }
20 
21 //------------------------------------------------------------------------------
22 void MSLayersAtAngle::update(const MSLayer & layer)
23 {
24  vector<MSLayer>::iterator it = find(theLayers.begin(),theLayers.end(),layer);
25  if (it == theLayers.end()) {
26  theLayers.push_back(layer);
27  sort(theLayers.begin(), theLayers.end());
28  } else {
29  *it = layer;
30  }
31 }
32 
33 //------------------------------------------------------------------------------
35  const PixelRecoPointRZ & pointI,
36  const PixelRecoPointRZ & pointO,
37  float tip) const
38 {
39  LayerItr iO = findLayer(pointO, theLayers.begin(), theLayers.end());
40 // cout << "outer Layer: "<<*iO<<endl;
41  LayerItr iI = findLayer(pointI, theLayers.begin(), iO);
42 // cout << "inner Layer: "<<*iI<<endl;
43 
44  return sqrt(sum2RmRn(iI,iO, pointO.r(),
45  PixelRecoLineRZ(pointI, pointO, tip)));
46 }
47 //------------------------------------------------------------------------------
49  const PixelRecoPointRZ & pointI,
50  const PixelRecoPointRZ & pointM,
51  const PixelRecoPointRZ & pointO,
52  float tip) const
53 {
54  LayerItr iO = findLayer(pointO, theLayers.begin(), theLayers.end());
55  LayerItr iI = findLayer(pointI, theLayers.begin(), iO);
56  LayerItr iM = findLayer(pointM, iI, iO);
57 
58  float drOI = pointO.r() - pointI.r();
59  float drMO = pointO.r() - pointM.r();
60  float drMI = pointM.r() - pointI.r();
61 
62  PixelRecoLineRZ line(pointI, pointO, tip);
63  float sum2I = sum2RmRn(iI+1, iM, pointI.r(), line);
64  float sum2O = sum2RmRn(iM, iO, pointO.r(), line);
65 
66  return sqrt( sum2I* sqr(drMO) + sum2O*sqr(drMI) )/drOI;
67 }
68 
69 //------------------------------------------------------------------------------
73  float rTarget,
74  const PixelRecoLineRZ & line) const
75 {
76  float sum2 = 0.f;
77  float cotTh = line.cotLine();
78  for (LayerItr it = i1; it < i2; it++) {
79  pair<PixelRecoPointRZ,bool> cross = it->crossing(line);
80  if (cross.second) {
81  float x0 = it->x0(cotTh);
82  float dr = rTarget-cross.first.r();
83  if (x0 > 1.e-5f) dr *= 1.f+0.038f*std::log(x0);
84  sum2 += x0*dr*dr;
85  }
86 // cout << *it << " crossing: "<<cross.second<<endl;
87  }
88  return sum2;
89 }
90 //------------------------------------------------------------------------------
92  const PixelRecoPointRZ & point,
94  MSLayersAtAngle::LayerItr iend) const
95 {
96  const float BIG=99999.f;
97  const float EPSILON = 1.e-4f;
98  LayerItr theIt = ibeg; float dist = BIG;
99  for (LayerItr it = ibeg; it < iend; it++) {
100  float d = it->distance(point);
101  if (d < dist) {
102  if (d < EPSILON) return it;
103  dist = d;
104  theIt = it;
105  }
106  }
107  return theIt;
108 }
109 
110 //------------------------------------------------------------------------------
112 {
113  for (LayerItr it = theLayers.begin(); it != theLayers.end(); it++)
114  cout <<*it<<endl;
115 }
116 
std::vector< MSLayer > theLayers
void print() const
float sum2RmRn(LayerItr i1, LayerItr i2, float rTarget, const PixelRecoLineRZ &line) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
void update(const MSLayer &layer)
float cotLine() const
T sqrt(T t)
Definition: SSEVec.h:46
double f[11][100]
std::vector< MSLayer >::const_iterator LayerItr
const float EPSILON
Definition: AnglesUtil.h:23
float sumX0D(const PixelRecoPointRZ &pointI, const PixelRecoPointRZ &pointO, float tip=0.) const
float r() const
Square< F >::type sqr(const F &f)
Definition: Square.h:13
tuple cout
Definition: gather_cfg.py:121
long double T
const MSLayer * findLayer(const MSLayer &layer) const
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
Basic3DVector cross(const Basic3DVector &v) const
Vector product, or &quot;cross&quot; product, with a vector of same type.