Fork me on GitHub

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/ParticlePropagator.cc

    r341014c r5b51d33  
    1717 */
    1818
     19
    1920/** \class ParticlePropagator
    2021 *
     
    3435#include "classes/DelphesFormula.h"
    3536
     37#include "ExRootAnalysis/ExRootResult.h"
     38#include "ExRootAnalysis/ExRootFilter.h"
    3639#include "ExRootAnalysis/ExRootClassifier.h"
    37 #include "ExRootAnalysis/ExRootFilter.h"
    38 #include "ExRootAnalysis/ExRootResult.h"
    39 
     40
     41#include "TMath.h"
     42#include "TString.h"
     43#include "TFormula.h"
     44#include "TRandom3.h"
     45#include "TObjArray.h"
    4046#include "TDatabasePDG.h"
    41 #include "TFormula.h"
    4247#include "TLorentzVector.h"
    43 #include "TMath.h"
    44 #include "TObjArray.h"
    45 #include "TRandom3.h"
    46 #include "TString.h"
    4748
    4849#include <algorithm>
     50#include <stdexcept>
    4951#include <iostream>
    5052#include <sstream>
    51 #include <stdexcept>
    5253
    5354using namespace std;
     
    6667}
    6768
     69
    6870//------------------------------------------------------------------------------
    6971
     
    7173{
    7274  fRadius = GetDouble("Radius", 1.0);
    73   fRadius2 = fRadius * fRadius;
     75  fRadius2 = fRadius*fRadius;
    7476  fHalfLength = GetDouble("HalfLength", 3.0);
    7577  fBz = GetDouble("Bz", 0.0);
     
    138140  const Double_t c_light = 2.99792458E8;
    139141
    140   if(!fBeamSpotInputArray || fBeamSpotInputArray->GetSize() == 0)
     142  if (!fBeamSpotInputArray || fBeamSpotInputArray->GetSize () == 0)
    141143    beamSpotPosition.SetXYZT(0.0, 0.0, 0.0, 0.0);
    142144  else
    143145  {
    144     Candidate &beamSpotCandidate = *((Candidate *)fBeamSpotInputArray->At(0));
     146    Candidate &beamSpotCandidate = *((Candidate *) fBeamSpotInputArray->At(0));
    145147    beamSpotPosition = beamSpotCandidate.Position;
    146148  }
    147149
    148150  fItInputArray->Reset();
    149   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     151  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    150152  {
    151153    if(candidate->GetCandidates()->GetEntriesFast() == 0)
     
    155157    else
    156158    {
    157       particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
     159      particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
    158160    }
    159161
    160162    particlePosition = particle->Position;
    161163    particleMomentum = particle->Momentum;
    162     x = particlePosition.X() * 1.0E-3;
    163     y = particlePosition.Y() * 1.0E-3;
    164     z = particlePosition.Z() * 1.0E-3;
    165 
    166     bsx = beamSpotPosition.X() * 1.0E-3;
    167     bsy = beamSpotPosition.Y() * 1.0E-3;
    168     bsz = beamSpotPosition.Z() * 1.0E-3;
     164    x = particlePosition.X()*1.0E-3;
     165    y = particlePosition.Y()*1.0E-3;
     166    z = particlePosition.Z()*1.0E-3;
     167
     168    bsx = beamSpotPosition.X()*1.0E-3;
     169    bsy = beamSpotPosition.Y()*1.0E-3;
     170    bsz = beamSpotPosition.Z()*1.0E-3;
    169171
    170172    q = particle->Charge;
     
    191193    {
    192194      mother = candidate;
    193       candidate = static_cast<Candidate *>(candidate->Clone());
     195      candidate = static_cast<Candidate*>(candidate->Clone());
    194196
    195197      candidate->InitialPosition = particlePosition;
     
    205207    {
    206208      // solve pt2*t^2 + 2*(px*x + py*y)*t - (fRadius2 - x*x - y*y) = 0
    207       tmp = px * y - py * x;
    208       discr2 = pt2 * fRadius2 - tmp * tmp;
     209      tmp = px*y - py*x;
     210      discr2 = pt2*fRadius2 - tmp*tmp;
    209211
    210212      if(discr2 < 0.0)
     
    214216      }
    215217
    216       tmp = px * x + py * y;
     218      tmp = px*x + py*y;
    217219      discr = TMath::Sqrt(discr2);
    218       t1 = (-tmp + discr) / pt2;
    219       t2 = (-tmp - discr) / pt2;
     220      t1 = (-tmp + discr)/pt2;
     221      t2 = (-tmp - discr)/pt2;
    220222      t = (t1 < 0.0) ? t2 : t1;
    221223
    222       z_t = z + pz * t;
     224      z_t = z + pz*t;
    223225      if(TMath::Abs(z_t) > fHalfLength)
    224226      {
     
    228230      }
    229231
    230       x_t = x + px * t;
    231       y_t = y + py * t;
    232       z_t = z + pz * t;
    233 
    234       l = TMath::Sqrt((x_t - x) * (x_t - x) + (y_t - y) * (y_t - y) + (z_t - z) * (z_t - z));
     232      x_t = x + px*t;
     233      y_t = y + py*t;
     234      z_t = z + pz*t;
     235
     236      l = TMath::Sqrt( (x_t - x)*(x_t - x) + (y_t - y)*(y_t - y) + (z_t - z)*(z_t - z));
    235237
    236238      mother = candidate;
    237       candidate = static_cast<Candidate *>(candidate->Clone());
     239      candidate = static_cast<Candidate*>(candidate->Clone());
    238240
    239241      candidate->InitialPosition = particlePosition;
    240       candidate->Position.SetXYZT(x_t * 1.0E3, y_t * 1.0E3, z_t * 1.0E3, particlePosition.T() + t * e * 1.0E3);
    241       candidate->L = l * 1.0E3;
     242      candidate->Position.SetXYZT(x_t*1.0E3, y_t*1.0E3, z_t*1.0E3, particlePosition.T() + t*e*1.0E3);
     243      candidate->L = l*1.0E3;
    242244
    243245      candidate->Momentum = particleMomentum;
     
    249251        switch(TMath::Abs(candidate->PID))
    250252        {
    251         case 11:
    252           fElectronOutputArray->Add(candidate);
    253           break;
    254         case 13:
    255           fMuonOutputArray->Add(candidate);
    256           break;
    257         default:
    258           fChargedHadronOutputArray->Add(candidate);
     253          case 11:
     254            fElectronOutputArray->Add(candidate);
     255            break;
     256          case 13:
     257            fMuonOutputArray->Add(candidate);
     258            break;
     259          default:
     260            fChargedHadronOutputArray->Add(candidate);
    259261        }
    260262      }
    261263      else
    262264      {
    263         fNeutralOutputArray->Add(candidate);
     265         fNeutralOutputArray->Add(candidate);
    264266      }
    265267    }
     
    273275      //     helix radius r = p_{T0} / (omega gamma m)
    274276
    275       gammam = e * 1.0E9 / (c_light * c_light); // gammam in [eV/c^2]
    276       omega = q * fBz / (gammam); // omega is here in [89875518/s]
    277       r = pt / (q * fBz) * 1.0E9 / c_light; // in [m]
     277      gammam = e*1.0E9 / (c_light*c_light);      // gammam in [eV/c^2]
     278      omega = q * fBz / (gammam);                // omega is here in [89875518/s]
     279      r = pt / (q * fBz) * 1.0E9/c_light;        // in [m]
    278280
    279281      phi_0 = TMath::ATan2(py, px); // [rad] in [-pi, pi]
    280282
    281283      // 2. helix axis coordinates
    282       x_c = x + r * TMath::Sin(phi_0);
    283       y_c = y - r * TMath::Cos(phi_0);
     284      x_c = x + r*TMath::Sin(phi_0);
     285      y_c = y - r*TMath::Cos(phi_0);
    284286      r_c = TMath::Hypot(x_c, y_c);
    285287      phi_c = TMath::ATan2(y_c, x_c);
     
    288290
    289291      rcu = TMath::Abs(r);
    290       rc2 = r_c * r_c;
     292      rc2 = r_c*r_c;
    291293
    292294      // 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;
     295      xd = x_c*x_c*x_c - x_c*rcu*r_c + x_c*y_c*y_c;
    294296      xd = (rc2 > 0.0) ? xd / rc2 : -999;
    295       yd = y_c * (-rcu * r_c + rc2);
     297      yd = y_c*(-rcu*r_c + rc2);
    296298      yd = (rc2 > 0.0) ? yd / rc2 : -999;
    297       zd = z + (TMath::Sqrt(xd * xd + yd * yd) - TMath::Sqrt(x * x + y * y)) * pz / pt;
     299      zd = z + (TMath::Sqrt(xd*xd + yd*yd) - TMath::Sqrt(x*x + y*y))*pz/pt;
    298300
    299301      // use perigee momentum rather than original particle
     
    309311      // calculate additional track parameters (correct for beamspot position)
    310312
    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();
    314       ctgTheta = 1.0 / TMath::Tan(particleMomentum.Theta());
     313      d0        = ((x - bsx) * py - (y - bsy) * px) / pt;
     314      dz        = z - ((x - bsx) * px + (y - bsy) * py) / pt * (pz / pt);
     315      p         = particleMomentum.P();
     316      ctgTheta  = 1.0 / TMath::Tan (particleMomentum.Theta());
     317
    315318
    316319      // 3. time evaluation t = TMath::Min(t_r, t_z)
     
    319322      t_r = 0.0; // in [ns]
    320323      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);
    325 
    326       if(r_c + TMath::Abs(r) < fRadius)
     324      if(pz == 0.0) t_z = 1.0E99;
     325      else t_z = gammam / (pz*1.0E9/c_light) * (-z + fHalfLength*sign_pz);
     326
     327      if(r_c + TMath::Abs(r)  < fRadius)
    327328      {
    328329        // helix does not cross the cylinder sides
     
    331332      else
    332333      {
    333         asinrho = TMath::ASin((fRadius * fRadius - r_c * r_c - r * r) / (2 * TMath::Abs(r) * r_c));
     334        asinrho = TMath::ASin((fRadius*fRadius - r_c*r_c - r*r) / (2*TMath::Abs(r)*r_c));
    334335        delta = phi_0 - phi;
    335         if(delta < -TMath::Pi()) delta += 2 * TMath::Pi();
    336         if(delta > TMath::Pi()) delta -= 2 * TMath::Pi();
     336        if(delta <-TMath::Pi()) delta += 2*TMath::Pi();
     337        if(delta > TMath::Pi()) delta -= 2*TMath::Pi();
    337338        t1 = (delta + asinrho) / omega;
    338339        t2 = (delta + TMath::Pi() - asinrho) / omega;
     
    358359      x_t = x_c + r * TMath::Sin(omega * t - phi_0);
    359360      y_t = y_c + r * TMath::Cos(omega * t - phi_0);
    360       z_t = z + pz * 1.0E9 / c_light / gammam * t;
     361      z_t = z + pz*1.0E9 / c_light / gammam * t;
    361362      r_t = TMath::Hypot(x_t, y_t);
    362363
     364
    363365      // compute path length for an helix
    364366
    365       alpha = pz * 1.0E9 / c_light / gammam;
    366       l = t * TMath::Sqrt(alpha * alpha + r * r * omega * omega);
     367      alpha = pz*1.0E9 / c_light / gammam;
     368      l = t * TMath::Sqrt(alpha*alpha + r*r*omega*omega);
    367369
    368370      if(r_t > 0.0)
     
    372374        if(particle == candidate)
    373375        {
    374           particle->D0 = d0 * 1.0E3;
    375           particle->DZ = dz * 1.0E3;
     376          particle->D0 = d0*1.0E3;
     377          particle->DZ = dz*1.0E3;
    376378          particle->P = p;
    377379          particle->PT = pt;
     
    381383
    382384        mother = candidate;
    383         candidate = static_cast<Candidate *>(candidate->Clone());
     385        candidate = static_cast<Candidate*>(candidate->Clone());
    384386
    385387        candidate->InitialPosition = particlePosition;
    386         candidate->Position.SetXYZT(x_t * 1.0E3, y_t * 1.0E3, z_t * 1.0E3, particlePosition.T() + t * c_light * 1.0E3);
     388        candidate->Position.SetXYZT(x_t*1.0E3, y_t*1.0E3, z_t*1.0E3, particlePosition.T() + t*c_light*1.0E3);
    387389
    388390        candidate->Momentum = particleMomentum;
    389391
    390         candidate->L = l * 1.0E3;
    391 
    392         candidate->Xd = xd * 1.0E3;
    393         candidate->Yd = yd * 1.0E3;
    394         candidate->Zd = zd * 1.0E3;
     392        candidate->L = l*1.0E3;
     393
     394        candidate->Xd = xd*1.0E3;
     395        candidate->Yd = yd*1.0E3;
     396        candidate->Zd = zd*1.0E3;
    395397
    396398        candidate->AddCandidate(mother);
     
    399401        switch(TMath::Abs(candidate->PID))
    400402        {
    401         case 11:
    402           fElectronOutputArray->Add(candidate);
    403           break;
    404         case 13:
    405           fMuonOutputArray->Add(candidate);
    406           break;
    407         default:
    408           fChargedHadronOutputArray->Add(candidate);
     403          case 11:
     404            fElectronOutputArray->Add(candidate);
     405            break;
     406          case 13:
     407            fMuonOutputArray->Add(candidate);
     408            break;
     409          default:
     410            fChargedHadronOutputArray->Add(candidate);
    409411        }
    410412      }
     
    414416
    415417//------------------------------------------------------------------------------
     418
Note: See TracChangeset for help on using the changeset viewer.