14 if(cosmics && !field) {
18 else if(cosmics && field) {
22 else if(!cosmics && !field) {
35 #ifndef TIF_COSMIC_SETUP
36 const double Rmu = 385;
37 const double zmu = 560;
39 TVector3 r0(hit[0],hit[1],hit[2]);
40 TVector3 pr(phit[0],phit[1],phit[2]);
41 TVector2 r0_xy = r0.XYvector();
42 TVector2 pr_xy = pr.Unit().XYvector();
43 double t_barrel = ((r0_xy*pr_xy)+
sqrt( (r0_xy*pr_xy)*(r0_xy*pr_xy) - r0_xy.Mod2() + Rmu*Rmu ))/c*pr.Mag()/pr.Perp();
45 double t_endcap = fabs(((phit[2]/fabs(phit[2])*zmu)+hit[2])/c*pr.Mag()/pr.Pz());
47 return t_barrel<t_endcap ? t_barrel : t_endcap;
49 const double y_trigger = 100;
50 double p =
sqrt(phit[0]*phit[0]+phit[1]*phit[1]+phit[2]*phit[2]);
54 return fabs((y_trigger-hit[1])*(p/phit[1])/c);
61 const double Rmu = 385;
62 const double zmu = 560;
65 double&
kappa = trackParameters[0];
66 double&
theta = trackParameters[1];
67 double& phi_0 = trackParameters[2];
68 double& d_0 = trackParameters[3];
69 double& z_0 = trackParameters[4];
70 double invkappa = 1/
kappa;
73 double phi =
getPhi(trackParameters,hit,onDisk) - phi_0;
76 double phi_mu_b = (kappa>0 ? -1 : 1 ) * acos((Rmu*Rmu-d_0*d_0-2*invkappa*invkappa+2*invkappa*d_0)/(2*invkappa*d_0-2*invkappa*invkappa));
77 double phi_mu_e = kappa*
tan(theta)*((phit[2]<0 ? 1 : -1)*zmu-z_0);
79 double t_barrel = fabs(invkappa/(c*
sin(theta))*(phi-phi_mu_b));
81 double t_endcap = fabs(invkappa/(c*
sin(theta))*(phi-phi_mu_e));
83 return t_barrel<t_endcap ? t_barrel : t_endcap;
90 TVector3 r0(hit[0],hit[1],hit[2]);
99 double&
theta = trackParameters[1];
101 return onDisk? fabs(hit[2]/(c*
cos(theta))) : fabs(
sqrt(hit[0]*hit[0]+hit[1]*hit[1])/(c*
sin(theta)));
106 return trackParameters[3]*
sin(trackParameters[2]) + (1/trackParameters[0])*(
sin(phi)-
sin(trackParameters[2]));
111 return -trackParameters[3]*
cos(trackParameters[2]) - (1/trackParameters[0])*(
cos(phi)-
cos(trackParameters[2]));
116 return trackParameters[4] + (phi-trackParameters[2])/(trackParameters[0]*
tan(trackParameters[1]));
122 return trackParameters[2] + trackParameters[0]*
tan(trackParameters[1])*(hit[2]-trackParameters[4]);
126 if(trackParameters[2]>-2.35 && trackParameters[2]<-0.78) {
128 phi = acos(-trackParameters[0]*(hit[1]-(trackParameters[3]-1/trackParameters[0])*(-
cos(trackParameters[2]))));
130 if(fabs(
x(trackParameters,phi)-hit[0])>fabs(
x(trackParameters,-phi)-hit[0])) phi *= -1.;
133 phi = asin(trackParameters[0]*(hit[0]-(trackParameters[3]-1/trackParameters[0])*
sin(trackParameters[2])));
135 if((fabs(
y(trackParameters,phi)-hit[1])>fabs(
y(trackParameters,
TMath::Pi()-phi)-hit[1])))
147 LogDebug(
"trackParameters") <<
"outer position: " << position.x() <<
" " << position.y() <<
" " << position.z();
148 LogDebug(
"trackParameters") <<
"outer momentum: " << momentum.x() <<
" " << momentum.y() <<
" " << momentum.z();
152 position -= radius / trackParameters[0];
153 LogDebug(
"trackParameters") <<
"center of curvature: " << position.x() <<
" " << position.y() <<
" " << position.z();
155 trackParameters[3] = position.rho() - fabs(1/trackParameters[0]);
156 if(trackParameters[0]>0) trackParameters[3] *= -1.;
158 double phi_out = trackParameters[2];
159 double phi_0 = position.phi() -
TMath::Pi()/2;
160 if(trackParameters[0]<0) phi_0 -=
TMath::Pi();
164 LogDebug(
"trackParameters") <<
"phi_0: " << phi_0;
165 trackParameters[2] = phi_0;
167 trackParameters[4] = tk.
outerPosition().z() - (phi_out-phi_0)/TMath::Tan(trackParameters[1])/trackParameters[0];
static double timeOfFlightBeamB(double *trackParameters, double *hit, double *phit, bool onDisk)
static double x(double *trackParameters, double phi)
Sin< T >::type sin(const T &t)
Geom::Theta< T > theta() const
const math::XYZPoint & outerPosition() const
position of the outermost hit
static int position[TOTALCHAMBERS][3]
const math::XYZPoint & innerPosition() const
position of the innermost hit
static double timeOfFlight(bool cosmics, bool field, double *trackParameters, double *hit, double *phit, bool onDisk)
Cos< T >::type cos(const T &t)
Tan< T >::type tan(const T &t)
static double timeOfFlightCosmicB(double *trackParameters, double *hit, double *phit, bool onDisk)
static void trackParameters(const reco::Track &tk, double *trackParameters)
static double getPhi(double *trackParameters, double *hit, bool onDisk)
static double timeOfFlightCosmic(double *hit, double *phit)
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
static double y(double *trackParameters, double phi)
static double timeOfFlightBeam(double *hit, double *phit)
static double z(double *trackParameters, double phi)
static const G4double kappa