Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

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<3; ++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   for(int i=0; i<5; ++i)
00095     _trpars[i] = trpars[i];
00096   for(int i=0; i<15; ++i)
00097     _trerrs[i] = trerrs[i];
00098 }
00099 
00100 // Destructor.
00101 
00102 TMBTrack::~TMBTrack()
00103 {}
00104 
00105 // Clear (resets transient attributes).
00106 
00107 void TMBTrack::Clear(Option_t* opt)
00108 {
00109   _trpars_valid = false;
00110   _trpos_valid = false;
00111   TMBLorentzVector::Clear(opt);
00112 }
00113 
00114 Int_t TMBTrack::nhit() const
00115 {
00116   Int_t Nhit = 0;
00117   for (Int_t mask=0; mask<3; ++mask){
00118     for (Int_t bit=0; bit<32; ++bit) {
00119       if (_hitmask[mask] & (1 << bit) ) ++Nhit;
00120     }
00121   }
00122   return Nhit;
00123 }
00124 
00125 Int_t TMBTrack::ncft() const
00126 {
00127   Int_t Ncft = 0;
00128   for (Int_t bit=16; bit<32; ++bit) {
00129     if (_hitmask[0] & (1 << bit) ) ++Ncft;
00130   }
00131   return Ncft;
00132 }
00133 
00134 const TMBIsoTrack* TMBTrack::getIsoTrk() const 
00135 {
00136   return _isotref.IsValid() ? dynamic_cast<const TMBIsoTrack*>(_isotref.GetObject()) : 0;
00137 }
00138 
00139 // detector eta of track for external CFT layer
00140 // code from B. Tuchming (tuchming@cea.fr) 
00141 Double_t TMBTrack::det_etaCFT() const
00142 {
00143   double theta = kinem::theta(Eta());
00144   double pi = kinem::PI;
00145   
00146   // flag whether track is forward or backward
00147   int forward = 1;
00148   if(theta > pi / 2.) forward = -1;
00149   double z_pos = 126. - (forward*_z);
00150   double tantheta = fabs(tan(theta));
00151   double height = z_pos * tantheta;
00152 
00153   //flag is track is central or forward
00154   bool central = (height > 51.430);
00155   double theta_det=0.;
00156 
00157   if(central) {
00158     theta_det = fabs( atan2 (51.430, (51.430/tantheta + forward*_z)));
00159     if(forward==-1) theta_det = pi - theta_det;
00160   }
00161   else {
00162     theta_det = fabs( atan2 (((126. - (forward*_z)) * tantheta), 126.));
00163     if(forward==-1) theta_det = pi - theta_det;
00164   }
00165 
00166   return kinem::eta(theta_det);
00167 }
00168 
00169 void TMBTrack::fill_trpars() const
00170 {
00171   if(_last_p != *this) {
00172     _last_p = *this;
00173     _trpars_valid = false;
00174     _trpos_valid = false;
00175   }
00176   if(_trpars_valid)
00177     return;
00178   _trpars_valid = true;
00179   _trpars[0] = _rdca;
00180   _trpars[1] = _z;
00181   _trpars[2] = Phi();
00182   Double_t c = CosTheta();
00183   _trpars[3] = c / sqrt(1. - c*c);
00184   _trpars[4] = _q / Pt();
00185 }
00186 
00187 void TMBTrack::fill_trpos() const
00188 {
00189   if(_last_p != *this) {
00190     _last_p = *this;
00191     _trpars_valid = false;
00192     _trpos_valid = false;
00193   }
00194   if(_trpos_valid)
00195     return;
00196   _trpos_valid = true;
00197   _trpos[0] = _xdca + _rdca * Py() / Pt();   // x = x0 + r*sin(phid)
00198   _trpos[1] = _ydca - _rdca * Px() / Pt();   // y = y0 - r*cos(phid)
00199   _trpos[2] = _z;
00200 }
00201 
00202 // Analysis methods.
00203 
00204 // Propagate methods.  These implementations use the exact formulas for
00205 // updating the track parameters, but the error matrix is not modified,
00206 // which is correct in leading order in the short-distance approximation.
00207 
00208 void TMBTrack::propagate(const TMBVertex* vert) 
00209 {
00210   propagate(vert->vx(), vert->vy());
00211 }
00212 
00213 void TMBTrack::propagate(Double_t xdca1, Double_t ydca1)
00214 {
00215   // Get original trf track parameters.  Tan(lambda) and q/pT are constants.
00216 
00217   Double_t r0 = rdca();
00218   Double_t z0 = z();
00219   Double_t phid0 = phid();
00220   Double_t tanlm = tlm();
00221   Double_t qpt0 = qpt();
00222 
00223   // Transverse curvature (1/radius).
00224 
00225   Double_t wt = EQ * qpt0 * _bz;
00226   assert(wt != 0.);
00227 
00228   // Difference between final and initial surface parameters 
00229   // (final minus initial).
00230 
00231   Double_t dx = xdca1 - xdca();
00232   Double_t dy = ydca1 - ydca();
00233 
00234   // Sine and cosine of the initial phi direction.
00235 
00236   Double_t sphid0 = sin(phid0);              // sin(phid0)
00237   Double_t cphid0 = cos(phid0);              // cos(phid0)
00238 
00239   // Sine and cosine of the bend angle.
00240 
00241   Double_t dxi = dx * cphid0 + dy * sphid0;
00242   Double_t drho = dx * sphid0 - dy * cphid0;
00243   Double_t sdphi = wt*dxi;                   // sin(dphi)
00244   Double_t cdphi = 1. - wt * (r0 - drho);    // cos(dphi)
00245   Double_t norm = sqrt(sdphi*sdphi + cdphi*cdphi);
00246   sdphi /= norm;
00247   cdphi /= norm;
00248   Double_t dphi = atan2(sdphi, cdphi);
00249 
00250   // Sine and cosine of the final phi direction.
00251 
00252   // Double_t sdphid1 = sphid0 * cdphi + cphid0 * sdphi;   // sin(phid0 + dphi)
00253   // Double_t cdphid1 = cphid0 * cdphi - sphid0 * sdphi;   // cos(phid0 + dphi)
00254 
00255   // Transverse path distance to destination dca.
00256 
00257   Double_t st = dphi / wt;
00258 
00259   // Calculate final trf track parameters.
00260 
00261   Double_t r1 = (r0 - drho - (sdphi*sdphi / (wt * (1. + cdphi)))) / cdphi;
00262 
00263   Double_t sinlm = tanlm / sqrt(1. + tanlm*tanlm);   // sin(lambda)
00264   Double_t z1 = z0 + sinlm * st;
00265   Double_t phid1 = phid0 + dphi;
00266 
00267   // Update class attributes.
00268 
00269   static_cast<TMBLorentzVector>(*this) = 
00270     TMBLorentzVector(Pt(), Eta(), phid1, M(), kPtEtaPhiM);
00271   _rdca = r1;
00272   _z = z1;
00273   _xdca = xdca1;
00274   _ydca = ydca1;
00275   assert(_trpars_valid);
00276   _trpars[0] = r1;
00277   _trpars[1] = z1;
00278   _trpars[2] = phid1;
00279 }
00280 
00281 // Impact parameter methods.
00282 
00283 void TMBTrack::impact(const TMBVertex* vert, Double_t* ip, 
00284                       Double_t* iperr) const 
00285 {
00286     impact(vert->vx(), vert->vy(), vert->vz(), ip, iperr);
00287 }
00288 
00289 void TMBTrack::impact(Double_t x, Double_t y, Double_t z, Double_t* ip, 
00290                       Double_t* iperr) const
00291 {
00292   // Make a non-const copy of track, then call non-const method.
00293 
00294   TMBTrack track(*this);
00295   track.impact(x, y, z, ip, iperr);
00296 }
00297 
00298 void TMBTrack::impact(const TMBVertex* vert, Double_t* ip, Double_t* iperr)
00299 {
00300     impact(vert->vx(), vert->vy(), vert->vz(), ip, iperr);
00301 }
00302 
00303 void TMBTrack::impact(Double_t x, Double_t y, Double_t z, Double_t* ip, 
00304                       Double_t* iperr)
00305 {
00306   // Propagate to vertex dca surface.
00307 
00308   propagate(x, y);
00309 
00310   // Store result.
00311 
00312   ip[0] = _rdca;
00313   ip[1] = _z - z;
00314   if(iperr) {
00315     iperr[0] = _trerrs[0];  // (0,0)
00316     iperr[1] = _trerrs[1];  // (1,0)
00317     iperr[2] = _trerrs[2];  // (1,1)
00318   }
00319 }
00320 
00321 void TMBTrack::constrain(const TMBVertex* vert)
00322 {
00323   // First constrain this track without vertex error.
00324 
00325   constrain(vert->vx(), vert->vy());
00326 }
00327 
00328 void TMBTrack::constrain(Double_t x, Double_t y)
00329 {
00330   // First propagate to the beam dca surface.
00331 
00332   propagate(x, y);
00333   assert(false);
00334 }

Generated on Tue Mar 28 10:13:05 2006 for CAF by doxygen 1.3.4