CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PlotUtils.cc
Go to the documentation of this file.
2 
3 using namespace std;
4 
5 /*****************************************************************************/
7  (const GlobalPoint& p1, const GlobalPoint& p2,
8  const GlobalVector& v2, ofstream& outFile, int charge)
9 {
10  GlobalVector dp = p2 - p1;
11  GlobalVector n2(-v2.y(),v2.x(),0.);
12  n2 = n2.unit();
13 
14  double r = -0.5 * (dp.x()*dp.x() + dp.y()*dp.y()) /
15  (dp.x()*n2.x() + dp.y()*n2.y());
16  GlobalPoint c = p2 + r * n2;
17 
18  double dphi = sqrt(2 * 0.1 / fabs(r)); // allowed deflection: 0.1 cm
19 
20  double phi = acos(( (p1-c).x()*(p2-c).x() +
21  (p1-c).y()*(p2-c).y() )/(r*r));
22 
23  if(dp.x()*v2.x() + dp.y()*v2.y() < 0) phi = 2*M_PI - phi;
24 
25  int nstep = (int)(phi/dphi) + 1;
26 
27  if(nstep > 1)
28  {
29  dphi = phi / nstep;
30  double dz = (p2 - p1).z() / nstep;
31 
32 
33  GlobalPoint P0 = p1;
34  GlobalPoint P1;
35 
36  charge = ((p1 - c).x() * (p2 - c).y() - (p1 - c).y() * (p2 - c).x() > 0 ?
37  -1 : 1);
38  if(dp.x()*v2.x() + dp.y()*v2.y() < 0) charge = -charge;
39 
40  outFile << ", Line[{{"<<P0.x()<<","<<P0.y()<<",("<<P0.z()<<"-zs)*mz}" ;
41 
42  for(int i = 0; i - nstep < 0; i++)
43  {
44  double a = -charge * (i+1)*dphi;
45  double z = p1.z() + (i+1)*dz;
46 
47  double x = c.x() + cos(a)*(p1 - c).x() - sin(a)*(p1 - c).y();
48  double y = c.y() + sin(a)*(p1 - c).x() + cos(a)*(p1 - c).y();
49 
50  P1 = GlobalPoint(x,y,z);
51 
52  outFile << ", {"<<P1.x()<<","<<P1.y()<<",("<<P1.z()<<"-zs)*mz}";
53  P0 = P1;
54  }
55  outFile << "}]" << std::endl;
56  }
57  else
58  {
59  GlobalPoint P0 = p1;
60  GlobalPoint P1 = p2;
61 
62  outFile << ", Line[{{"<<P0.x()<<","<<P0.y()<<",("<<P0.z()<<"-zs)*mz}"
63  << ", {"<<P1.x()<<","<<P1.y()<<",("<<P1.z()<<"-zs)*mz}}]" << std::endl;
64  }
65 }
int i
Definition: DBlmapReader.cc:9
void printHelix(const GlobalPoint &p1, const GlobalPoint &p2, const GlobalVector &n2, std::ofstream &outFile, int charge)
Definition: PlotUtils.cc:7
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:62
double charge(const std::vector< uint8_t > &Ampls)
double double double z
T sqrt(T t)
Definition: SSEVec.h:46
T z() const
Definition: PV3DBase.h:63
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double p2[4]
Definition: TauolaWrapper.h:90
Vector3DBase unit() const
Definition: Vector3DBase.h:57
#define M_PI
Definition: BFit3D.cc:3
double p1[4]
Definition: TauolaWrapper.h:89
double a
Definition: hdecay.h:121
x
Definition: VDTMath.h:216
T x() const
Definition: PV3DBase.h:61
Definition: DDAxes.h:10