Fork me on GitHub

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/TimeSmearing.cc

    r2b5ff2c r341014c  
    5353
    5454TimeSmearing::TimeSmearing() :
    55   fFormula(0), fItInputArray(0)
     55  fItInputArray(0)
    5656{
    57   fFormula = new DelphesFormula;
    5857}
    5958
     
    6261TimeSmearing::~TimeSmearing()
    6362{
    64   if(fFormula) delete fFormula;
    6563}
    6664
     
    7169  // read resolution formula
    7270
    73   fFormula->Compile(GetString("TimeResolution", "1.0"));
     71  fTimeResolution = GetDouble("TimeResolution", 1.0E-10);
     72  // import input array
    7473
    75   // import input array
    76   fEtaMax = GetDouble("EtaMax", 6.);
    7774  fInputArray = ImportArray(GetString("InputArray", "MuonMomentumSmearing/muons"));
    7875  fItInputArray = fInputArray->MakeIterator();
     
    9592{
    9693  Candidate *candidate, *mother;
    97   Double_t ti, tf_smeared, tf, timeResolution;
    98   Double_t pt, eta, phi, e, d0, dz, ctgTheta;
    99 
    100 
     94  Double_t ti, tf_smeared, tf;
    10195  const Double_t c_light = 2.99792458E8;
    10296
    10397  fItInputArray->Reset();
    104   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     98  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    10599  {
    106     ti = candidate->InitialPosition.T()*1.0E-3/c_light;
    107     tf = candidate->Position.T()*1.0E-3/c_light;
    108    
    109     // dummy, only need to properly call TFormula
    110     const TLorentzVector &candidatePosition = candidate->Position;
    111     const TLorentzVector &candidateMomentum = candidate->Momentum;
    112     eta = candidatePosition.Eta();
    113     phi = candidatePosition.Phi();
    114     pt = candidateMomentum.Pt();
    115     e = candidateMomentum.E();
    116     d0 = candidate->D0;
    117     dz = candidate->DZ;
    118     ctgTheta = candidate->CtgTheta;
     100    const TLorentzVector &candidateInitialPosition = candidate->InitialPosition;
     101    const TLorentzVector &candidateFinalPosition = candidate->Position;
     102
     103    ti = candidateInitialPosition.T() * 1.0E-3 / c_light;
     104    tf = candidateFinalPosition.T() * 1.0E-3 / c_light;
    119105
    120106    // apply smearing formula
    121    
    122     timeResolution = fFormula->Eval(pt, eta, phi, e, d0, dz, ctgTheta);
    123     if(fabs(candidate->Position.Eta())<fEtaMax)
    124     {
    125       tf_smeared = tf + timeResolution*gRandom->Gaus(0, 1);
    126     }
    127     else continue;
    128 
    129     // double beta_particle = candidate->Momentum.P()/candidate->Momentum.E();
    130     // ti = tf_smeared - candidate->Ld*1.0E-3/(c_light*beta_particle);
     107    tf_smeared = gRandom->Gaus(tf, fTimeResolution);
     108    ti = ti + tf_smeared - tf;
     109    tf = tf_smeared;
    131110
    132111    mother = candidate;
    133     candidate = static_cast<Candidate*>(candidate->Clone());
     112    candidate = static_cast<Candidate *>(candidate->Clone());
     113    candidate->InitialPosition.SetT(ti * 1.0E3 * c_light);
     114    candidate->Position.SetT(tf * 1.0E3 * c_light);
     115
     116    candidate->ErrorT = fTimeResolution * 1.0E3 * c_light;
     117
    134118    candidate->AddCandidate(mother);
    135     candidate->InitialPosition.SetT((100+ti)*1.0E3*c_light);
    136     candidate->Position.SetT(tf_smeared*1.0E3*c_light);
    137     candidate->ErrorT = timeResolution*1.0E3*c_light;
    138119
    139120    fOutputArray->Add(candidate);
Note: See TracChangeset for help on using the changeset viewer.