Fork me on GitHub

Changeset d612dec in git for modules/ParticlePropagator.cc


Ignore:
Timestamp:
Dec 9, 2021, 7:52:15 AM (3 years ago)
Author:
christinaw97 <christina.wang@…>
Children:
29b722a
Parents:
a5af1df (diff), 0c0c9af (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of github.com:Christinaw97/delphes into HEAD

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/ParticlePropagator.cc

    ra5af1df rd612dec  
    125125  TLorentzVector particlePosition, particleMomentum, beamSpotPosition;
    126126  Double_t px, py, pz, pt, pt2, e, q;
    127   Double_t x, y, z, t, r, phi;
    128   Double_t x_c, y_c, r_c, phi_c, phi_0;
    129   Double_t x_t, y_t, z_t, r_t;
    130   Double_t t1, t2, t3, t4, t5, t6;
    131   Double_t t_z, t_r, t_ra, t_rb;
    132   Double_t tmp, discr, discr2;
    133   Double_t delta, gammam, omega, asinrho;
    134   Double_t rcu, rc2, xd, yd, zd;
    135   Double_t l, d0, dz, p, ctgTheta, phip, etap, alpha;
     127  Double_t x, y, z, t, r;
     128  Double_t x_c, y_c, r_c, phi_0;
     129  Double_t x_t, y_t, z_t, r_t, phi_t;
     130  Double_t t_r, t_z;
     131  Double_t tmp;
     132  Double_t gammam, omega;
     133  Double_t xd, yd, zd;
     134  Double_t l, d0, dz, ctgTheta, alpha;
    136135  Double_t bsx, bsy, bsz;
     136  Double_t td, pio, phid, vz;
    137137
    138138  const Double_t c_light = 2.99792458E8;
    139139
    140140  if(!fBeamSpotInputArray || fBeamSpotInputArray->GetSize() == 0)
     141  {
    141142    beamSpotPosition.SetXYZT(0.0, 0.0, 0.0, 0.0);
     143  }
    142144  else
    143145  {
     
    160162    particlePosition = particle->Position;
    161163    particleMomentum = particle->Momentum;
     164
    162165    x = particlePosition.X() * 1.0E-3;
    163166    y = particlePosition.Y() * 1.0E-3;
     
    206209      // solve pt2*t^2 + 2*(px*x + py*y)*t - (fRadius2 - x*x - y*y) = 0
    207210      tmp = px * y - py * x;
    208       discr2 = pt2 * fRadius2 - tmp * tmp;
    209 
    210       if(discr2 < 0.0)
    211       {
    212         // no solutions
    213         continue;
    214       }
    215 
    216       tmp = px * x + py * y;
    217       discr = TMath::Sqrt(discr2);
    218       t1 = (-tmp + discr) / pt2;
    219       t2 = (-tmp - discr) / pt2;
    220       t = (t1 < 0.0) ? t2 : t1;
    221 
    222       z_t = z + pz * t;
    223       if(TMath::Abs(z_t) > fHalfLength)
    224       {
    225         t3 = (+fHalfLength - z) / pz;
    226         t4 = (-fHalfLength - z) / pz;
    227         t = (t3 < 0.0) ? t4 : t3;
    228       }
     211      t_r = (TMath::Sqrt(pt2 * fRadius2 - tmp * tmp) - px * x - py * y) / pt2;
     212
     213      t_z = (TMath::Sign(fHalfLength, pz) - z) / pz;
     214
     215      t = TMath::Min(t_r, t_z);
    229216
    230217      x_t = x + px * t;
     
    245232
    246233      fOutputArray->Add(candidate);
     234
    247235      if(TMath::Abs(q) > 1.0E-9)
    248236      {
     
    267255    {
    268256
    269       // 1.  initial transverse momentum p_{T0}: Part->pt
    270       //     initial transverse momentum direction phi_0 = -atan(p_X0/p_Y0)
    271       //     relativistic gamma: gamma = E/mc^2; gammam = gamma * m
    272       //     gyration frequency omega = q/(gamma m) fBz
    273       //     helix radius r = p_{T0} / (omega gamma m)
     257      // 1. initial transverse momentum p_{T0}: Part->pt
     258      //    initial transverse momentum direction phi_0 = -atan(p_{X0} / p_{Y0})
     259      //    relativistic gamma: gamma = E / mc^2; gammam = gamma * m
     260      //    gyration frequency omega = q * Bz / (gammam)
     261      //    helix radius r = p_{T0} / (omega * gammam)
    274262
    275263      gammam = e * 1.0E9 / (c_light * c_light); // gammam in [eV/c^2]
    276       omega = q * fBz / (gammam); // omega is here in [89875518/s]
     264      omega = q * fBz / gammam; // omega is here in [89875518/s]
    277265      r = pt / (q * fBz) * 1.0E9 / c_light; // in [m]
    278266
     
    283271      y_c = y - r * TMath::Cos(phi_0);
    284272      r_c = TMath::Hypot(x_c, y_c);
    285       phi_c = TMath::ATan2(y_c, x_c);
    286       phi = phi_c;
    287       if(x_c < 0.0) phi += TMath::Pi();
    288 
    289       rcu = TMath::Abs(r);
    290       rc2 = r_c * r_c;
    291 
    292       // calculate coordinates of closest approach to track circle in transverse plane xd, yd, zd
    293       xd = x_c * x_c * x_c - x_c * rcu * r_c + x_c * y_c * y_c;
    294       xd = (rc2 > 0.0) ? xd / rc2 : -999;
    295       yd = y_c * (-rcu * r_c + rc2);
    296       yd = (rc2 > 0.0) ? yd / rc2 : -999;
    297       zd = z + (TMath::Sqrt(xd * xd + yd * yd) - TMath::Sqrt(x * x + y * y)) * pz / pt;
    298 
    299       // use perigee momentum rather than original particle
    300       // momentum, since the orignal particle momentum isn't known
    301 
    302       px = TMath::Sign(1.0, r) * pt * (-y_c / r_c);
    303       py = TMath::Sign(1.0, r) * pt * (x_c / r_c);
    304       etap = particleMomentum.Eta();
    305       phip = TMath::ATan2(py, px);
    306 
    307       particleMomentum.SetPtEtaPhiE(pt, etap, phip, particleMomentum.E());
     273
     274      // time of closest approach
     275      td = (phi_0 + TMath::ATan2(x_c, y_c)) / omega;
     276
     277      // remove all the modulo pi that might have come from the atan
     278      pio = TMath::Abs(TMath::Pi() / omega);
     279      while(TMath::Abs(td) > 0.5 * pio)
     280      {
     281        td -= TMath::Sign(1.0, td) * pio;
     282      }
     283
     284      vz = pz * c_light / e;
     285
     286      // calculate coordinates of closest approach to z axis
     287      phid = phi_0 - omega * td;
     288      xd = x_c - r * TMath::Sin(phid);
     289      yd = y_c + r * TMath::Cos(phid);
     290      zd = z + vz * td;
     291
     292      // momentum at closest approach
     293      px = pt * TMath::Cos(phid);
     294      py = pt * TMath::Sin(phid);
     295
     296      particleMomentum.SetPtEtaPhiE(pt, particleMomentum.Eta(), phid, particleMomentum.E());
    308297
    309298      // calculate additional track parameters (correct for beamspot position)
    310 
    311       d0 = ((x - bsx) * py - (y - bsy) * px) / pt;
    312       dz = z - ((x - bsx) * px + (y - bsy) * py) / pt * (pz / pt);
    313       p = particleMomentum.P();
     299      d0 = ((xd - bsx) * py - (yd - bsy) * px) / pt;
     300      dz = zd - bsz;
    314301      ctgTheta = 1.0 / TMath::Tan(particleMomentum.Theta());
    315302
     
    317304      //    t_r : time to exit from the sides
    318305      //    t_z : time to exit from the front or the back
    319       t_r = 0.0; // in [ns]
    320       int sign_pz = (pz > 0.0) ? 1 : -1;
    321       if(pz == 0.0)
    322         t_z = 1.0E99;
    323       else
    324         t_z = gammam / (pz * 1.0E9 / c_light) * (-z + fHalfLength * sign_pz);
     306      t_z = (vz == 0.0) ? 1.0E99 : (TMath::Sign(fHalfLength, pz) - z) / vz;
    325307
    326308      if(r_c + TMath::Abs(r) < fRadius)
     
    331313      else
    332314      {
    333         asinrho = TMath::ASin((fRadius * fRadius - r_c * r_c - r * r) / (2 * TMath::Abs(r) * r_c));
    334         delta = phi_0 - phi;
    335         if(delta < -TMath::Pi()) delta += 2 * TMath::Pi();
    336         if(delta > TMath::Pi()) delta -= 2 * TMath::Pi();
    337         t1 = (delta + asinrho) / omega;
    338         t2 = (delta + TMath::Pi() - asinrho) / omega;
    339         t3 = (delta + TMath::Pi() + asinrho) / omega;
    340         t4 = (delta - asinrho) / omega;
    341         t5 = (delta - TMath::Pi() - asinrho) / omega;
    342         t6 = (delta - TMath::Pi() + asinrho) / omega;
    343 
    344         if(t1 < 0.0) t1 = 1.0E99;
    345         if(t2 < 0.0) t2 = 1.0E99;
    346         if(t3 < 0.0) t3 = 1.0E99;
    347         if(t4 < 0.0) t4 = 1.0E99;
    348         if(t5 < 0.0) t5 = 1.0E99;
    349         if(t6 < 0.0) t6 = 1.0E99;
    350 
    351         t_ra = TMath::Min(t1, TMath::Min(t2, t3));
    352         t_rb = TMath::Min(t4, TMath::Min(t5, t6));
    353         t_r = TMath::Min(t_ra, t_rb);
     315        alpha = TMath::ACos((r * r + r_c * r_c - fRadius * fRadius) / (2 * TMath::Abs(r) * r_c));
     316        t_r = td + TMath::Abs(alpha / omega);
     317
    354318        t = TMath::Min(t_r, t_z);
    355319      }
    356320
    357321      // 4. position in terms of x(t), y(t), z(t)
    358       x_t = x_c + r * TMath::Sin(omega * t - phi_0);
    359       y_t = y_c + r * TMath::Cos(omega * t - phi_0);
    360       z_t = z + pz * 1.0E9 / c_light / gammam * t;
     322      phi_t = phi_0 - omega * t;
     323      x_t = x_c - r * TMath::Sin(phi_t);
     324      y_t = y_c + r * TMath::Cos(phi_t);
     325      z_t = z + vz * t;
    361326      r_t = TMath::Hypot(x_t, y_t);
    362327
    363       // compute path length for an helix
    364 
    365       alpha = pz * 1.0E9 / c_light / gammam;
    366       l = t * TMath::Sqrt(alpha * alpha + r * r * omega * omega);
     328      // lenght of the path from production to tracker
     329      l = t * TMath::Hypot(vz, r * omega);
    367330
    368331      if(r_t > 0.0)
    369332      {
    370 
    371333        // store these variables before cloning
    372334        if(particle == candidate)
     
    374336          particle->D0 = d0 * 1.0E3;
    375337          particle->DZ = dz * 1.0E3;
    376           particle->P = p;
     338          particle->P = particleMomentum.P();
    377339          particle->PT = pt;
    378340          particle->CtgTheta = ctgTheta;
    379           particle->Phi = phip;
     341          particle->Phi = particleMomentum.Phi();
    380342        }
    381343
Note: See TracChangeset for help on using the changeset viewer.