TMBTrack.cpp

Go to the documentation of this file.
00001 #include <cmath>
00002 #include "tmb_tree/TMBTrack.hpp"
00003 #include "tmb_tree/TMBIsoTrack.hpp"
00004 #include "tmb_tree/TMBVertex.hpp"
00005 #include "kinem_util/AnglesUtil.hpp"
00006 
00007 using std::abs;
00008 using std::log;
00009 using std::sqrt;
00010 using std::sinh;
00011 using std::sin;
00012 using std::cos;
00013 using std::atan2;
00014 
00015 // Local functions.
00016 
00017 namespace {
00018 
00019   // Constants.
00020 
00021   Double_t CLIGHT = 2.99792458e10; // Speed of light in cm/sec.
00022   Double_t EQ = 1.0e-13 * CLIGHT;  // Electron charge in units GeV/(Tesla-cm).
00023   Double_t MPI = 0.13957;          // Charged pion mass.
00024 
00025 }
00026 
00027 ClassImp(TMBTrack);
00028 
00029 
00030 //_____________________________________________________________________________
00031 
00032 // Default constructor.
00033 
00034 TMBTrack::TMBTrack() :
00035   _q(0),
00036   _chi2_ndof(-1.),
00037   _smtdedx(0.),
00038   _smtededx(0.),
00039   _bz(0.),
00040   _rdca(0.),
00041   _z(0.),
00042   _xdca(0.),
00043   _ydca(0.),
00044   _x_ps(0.),
00045   _y_ps(0.),
00046   _z_ps(0.),
00047   _px_ps(0.),
00048   _py_ps(0.),
00049   _pz_ps(0.),
00050   _trpars_valid(false),
00051   _trpos_valid(false)
00052 {
00053   for(int i=0; i<4; ++i)
00054     _hitmask[i] = 0;
00055   for(int i=0; i<15; ++i)
00056     _trerrs[i] = 0.;
00057 }
00058 
00059 // Initializing constructor.
00060 
00061 TMBTrack::TMBTrack(const Double_t* trpars, const Double_t* trerrs,
00062                    Double_t bz,
00063                    const UInt_t* hitmask, Double_t chi2_ndof, 
00064                    Double_t smtdedx, Double_t smt_ededx,
00065                    const Double_t* ps_position, const Double_t* ps_momentum,
00066                    const Double_t* surfpars,
00067                    const TRef& isotref) :
00068   TMBLorentzVector(trpars[4] != 0. ? 1./abs(trpars[4]) : 0., // pT
00069                    asinh(trpars[3]),                         // eta
00070                    trpars[2],                                // phi
00071                    MPI,                                      // mpi+
00072                    kPtEtaPhiM),
00073   _q(trpars[4] > 0. ? 1 : (trpars[4] < 0. ? -1 : 0)),
00074   _chi2_ndof(chi2_ndof),
00075   _smtdedx(smtdedx),
00076   _smtededx(smt_ededx),
00077   _isotref(isotref),
00078   _bz(bz),
00079   _rdca(trpars[0]),
00080   _z(trpars[1]),
00081   _xdca(surfpars[0]),
00082   _ydca(surfpars[1]),
00083   _x_ps(ps_position[0]),
00084   _y_ps(ps_position[1]),
00085   _z_ps(ps_position[2]),
00086   _px_ps(ps_momentum[0]),
00087   _py_ps(ps_momentum[1]),
00088   _pz_ps(ps_momentum[2]),
00089   _trpars_valid(true),
00090   _trpos_valid(false)
00091 {
00092   for(int i=0; i<3; ++i)
00093     _hitmask[i] = hitmask[i];
00094   _hitmask[3] = 0;
00095   for(int i=0; i<5; ++i)
00096     _trpars[i] = trpars[i];
00097   for(int i=0; i<15; ++i)
00098     _trerrs[i] = trerrs[i];
00099 }
00100 
00101 // Destructor.
00102 
00103 TMBTrack::~TMBTrack()
00104 {}
00105 
00106 // Clear (resets transient attributes).
00107 
00108 void TMBTrack::Clear(Option_t* opt)
00109 {
00110   _trpars_valid = false;
00111   _trpos_valid = false;
00112   TMBLorentzVector::Clear(opt);
00113 }
00114 
00115 Int_t TMBTrack::nhit() const
00116 {
00117   Int_t Nhit = 0;
00118   for (Int_t mask=0; mask<3; ++mask){
00119     for (Int_t bit=0; bit<32; ++bit) {
00120       if (_hitmask[mask] & (1 << bit) ) ++Nhit;
00121     }
00122   }
00123   return Nhit;
00124 }
00125 
00126 Int_t TMBTrack::ncft() const
00127 {
00128   Int_t Ncft = 0;
00129   for (Int_t bit=16; bit<32; ++bit) {
00130     if (_hitmask[0] & (1 << bit) ) ++Ncft;
00131   }
00132   return Ncft;
00133 }
00134 
00135 const TMBIsoTrack* TMBTrack::getIsoTrk() const 
00136 {
00137   return _isotref.IsValid() ? dynamic_cast<const TMBIsoTrack*>(_isotref.GetObject()) : 0;
00138 }
00139 
00140 // detector eta of track for external CFT layer
00141 // code from B. Tuchming (tuchming@cea.fr) 
00142 Double_t TMBTrack::det_etaCFT() const
00143 {
00144   double theta = kinem::theta(Eta());
00145   double pi = kinem::PI;
00146   
00147   // flag whether track is forward or backward
00148   int forward = 1;
00149   if(theta > pi / 2.) forward = -1;
00150   double z_pos = 126. - (forward*_z);
00151   double tantheta = fabs(tan(theta));
00152   double height = z_pos * tantheta;
00153 
00154   //flag is track is central or forward
00155   bool central = (height > 51.430);
00156   double theta_det=0.;
00157 
00158   if(central) {
00159     theta_det = fabs( atan2 (51.430, (51.430/tantheta + forward*_z)));
00160     if(forward==-1) theta_det = pi - theta_det;
00161   }
00162   else {
00163     theta_det = fabs( atan2 (((126. - (forward*_z)) * tantheta), 126.));
00164     if(forward==-1) theta_det = pi - theta_det;
00165   }
00166 
00167   return kinem::eta(theta_det);
00168 }
00169 
00170 void TMBTrack::fill_trpars() const
00171 {
00172   if(_last_p != *this) {
00173     _last_p = *this;
00174     _trpars_valid = false;
00175     _trpos_valid = false;
00176   }
00177   if(_trpars_valid)
00178     return;
00179   _trpars_valid = true;
00180   _trpars[0] = _rdca;
00181   _trpars[1] = _z;
00182   _trpars[2] = Phi();
00183   Double_t c = CosTheta();
00184   _trpars[3] = c / sqrt(1. - c*c);
00185   _trpars[4] = _q / Pt();
00186 }
00187 
00188 void TMBTrack::fill_trpos() const
00189 {
00190   if(_last_p != *this) {
00191     _last_p = *this;
00192     _trpars_valid = false;
00193     _trpos_valid = false;
00194   }
00195   if(_trpos_valid)
00196     return;
00197   _trpos_valid = true;
00198   _trpos[0] = _xdca + _rdca * Py() / Pt();   // x = x0 + r*sin(phid)
00199   _trpos[1] = _ydca - _rdca * Px() / Pt();   // y = y0 - r*cos(phid)
00200   _trpos[2] = _z;
00201 }
00202 
00203 // Analysis methods.
00204 
00205 // Propagate methods.  These implementations use the exact formulas for
00206 // updating the track parameters, but the error matrix is not modified,
00207 // which is correct in leading order in the short-distance approximation.
00208 
00209 void TMBTrack::propagate(const TMBVertex* vert) 
00210 {
00211   propagate(vert->vx(), vert->vy());
00212 }
00213 
00214 void TMBTrack::propagate(Double_t xdca1, Double_t ydca1)
00215 {
00216   // Get original trf track parameters.  Tan(lambda) and q/pT are constants.
00217 
00218   Double_t r0 = rdca();
00219   Double_t z0 = z();
00220   Double_t phid0 = phid();
00221   Double_t tanlm = tlm();
00222   Double_t qpt0 = qpt();
00223 
00224   // Transverse curvature (1/radius).
00225 
00226   Double_t wt = EQ * qpt0 * _bz;
00227   assert(wt != 0.);
00228 
00229   // Difference between final and initial surface parameters 
00230   // (final minus initial).
00231 
00232   Double_t dx = xdca1 - xdca();
00233   Double_t dy = ydca1 - ydca();
00234 
00235   // Sine and cosine of the initial phi direction.
00236 
00237   Double_t sphid0 = sin(phid0);              // sin(phid0)
00238   Double_t cphid0 = cos(phid0);              // cos(phid0)
00239 
00240   // Sine and cosine of the bend angle.
00241 
00242   Double_t dxi = dx * cphid0 + dy * sphid0;
00243   Double_t drho = dx * sphid0 - dy * cphid0;
00244   Double_t sdphi = wt*dxi;                   // sin(dphi)
00245   Double_t cdphi = 1. - wt * (r0 - drho);    // cos(dphi)
00246   Double_t norm = sqrt(sdphi*sdphi + cdphi*cdphi);
00247   sdphi /= norm;
00248   cdphi /= norm;
00249   Double_t dphi = atan2(sdphi, cdphi);
00250 
00251   // Sine and cosine of the final phi direction.
00252 
00253   // Double_t sdphid1 = sphid0 * cdphi + cphid0 * sdphi;   // sin(phid0 + dphi)
00254   // Double_t cdphid1 = cphid0 * cdphi - sphid0 * sdphi;   // cos(phid0 + dphi)
00255 
00256   // Transverse path distance to destination dca.
00257 
00258   Double_t st = dphi / wt;
00259 
00260   // Calculate final trf track parameters.
00261 
00262   Double_t r1 = (r0 - drho - (sdphi*sdphi / (wt * (1. + cdphi)))) / cdphi;
00263 
00264   Double_t sinlm = tanlm / sqrt(1. + tanlm*tanlm);   // sin(lambda)
00265   Double_t z1 = z0 + sinlm * st;
00266   Double_t phid1 = phid0 + dphi;
00267 
00268   // Update class attributes.
00269 
00270   static_cast<TMBLorentzVector>(*this) = 
00271     TMBLorentzVector(Pt(), Eta(), phid1, M(), kPtEtaPhiM);
00272   _rdca = r1;
00273   _z = z1;
00274   _xdca = xdca1;
00275   _ydca = ydca1;
00276   assert(_trpars_valid);
00277   _trpars[0] = r1;
00278   _trpars[1] = z1;
00279   _trpars[2] = phid1;
00280 }
00281 
00282 // Impact parameter methods.
00283 
00284 void TMBTrack::impact(const TMBVertex* vert, Double_t* ip, 
00285                       Double_t* iperr) const 
00286 {
00287     impact(vert->vx(), vert->vy(), vert->vz(), ip, iperr);
00288 }
00289 
00290 void TMBTrack::impact(Double_t x, Double_t y, Double_t z, Double_t* ip, 
00291                       Double_t* iperr) const
00292 {
00293   // Make a non-const copy of track, then call non-const method.
00294 
00295   TMBTrack track(*this);
00296   track.impact(x, y, z, ip, iperr);
00297 }
00298 
00299 void TMBTrack::impact(const TMBVertex* vert, Double_t* ip, Double_t* iperr)
00300 {
00301     impact(vert->vx(), vert->vy(), vert->vz(), ip, iperr);
00302 }
00303 
00304 void TMBTrack::impact(Double_t x, Double_t y, Double_t z, Double_t* ip, 
00305                       Double_t* iperr)
00306 {
00307   // Propagate to vertex dca surface.
00308 
00309   propagate(x, y);
00310 
00311   // Store result.
00312 
00313   ip[0] = _rdca;
00314   ip[1] = _z - z;
00315   if(iperr) {
00316     iperr[0] = _trerrs[0];  // (0,0)
00317     iperr[1] = _trerrs[1];  // (1,0)
00318     iperr[2] = _trerrs[2];  // (1,1)
00319   }
00320 }
00321 
00322 void TMBTrack::constrain(const TMBVertex* vert)
00323 {
00324   // First constrain this track without vertex error.
00325 
00326   constrain(vert->vx(), vert->vy());
00327 }
00328 
00329 void TMBTrack::constrain(Double_t x, Double_t y)
00330 {
00331   // First propagate to the beam dca surface.
00332 
00333   propagate(x, y);
00334   assert(false);
00335 }

Generated on Thu Apr 3 04:14:24 2008 for CAF by doxygen 1.3.4