Fork me on GitHub

Changeset 21eab4f in git for modules/MomentumSmearing.cc


Ignore:
Timestamp:
Aug 26, 2016, 5:17:14 PM (8 years ago)
Author:
GitHub <noreply@…>
Parents:
ec5e04b (diff), 94cacb6 (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.
git-author:
AlexandreMertens <alexandre.mertens@…> (08/26/16 17:17:14)
git-committer:
GitHub <noreply@…> (08/26/16 17:17:14)
Message:

Merge 94cacb6ab322f96b75a06369dfd9b7389d0d6802 into ec5e04b014990ea45a8708f4f726b6b214cdb82b

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/MomentumSmearing.cc

    rec5e04b r21eab4f  
    9696{
    9797  Candidate *candidate, *mother;
    98   Double_t pt, eta, phi, e;
     98  Double_t pt, eta, phi, e, res;
    9999
    100100  fItInputArray->Reset();
     
    107107    pt = candidateMomentum.Pt();
    108108    e = candidateMomentum.E();
     109    res = fFormula->Eval(pt, eta, phi, e);
     110 
     111    // apply smearing formula
     112    //pt = gRandom->Gaus(pt, fFormula->Eval(pt, eta, phi, e) * pt);
     113   
     114    res = ( res > 1.0 ) ? 1.0 : res;
    109115
    110     // apply smearing formula
    111     pt = gRandom->Gaus(pt, fFormula->Eval(pt, eta, phi, e) * pt);
     116    pt = LogNormal(pt, res * pt );
    112117   
    113     if(pt <= 0.0) continue;
     118    //if(pt <= 0.0) continue;
    114119
    115120    mother = candidate;
     
    118123    phi = candidateMomentum.Phi();
    119124    candidate->Momentum.SetPtEtaPhiE(pt, eta, phi, pt*TMath::CosH(eta));
    120     candidate->TrackResolution = fFormula->Eval(pt, eta, phi, e);
     125    //candidate->TrackResolution = fFormula->Eval(pt, eta, phi, e);
     126    candidate->TrackResolution = res;
    121127    candidate->AddCandidate(mother);
    122128       
     
    124130  }
    125131}
     132//----------------------------------------------------------------
     133
     134Double_t MomentumSmearing::LogNormal(Double_t mean, Double_t sigma)
     135{
     136  Double_t a, b;
     137
     138  if(mean > 0.0)
     139  {
     140    b = TMath::Sqrt(TMath::Log((1.0 + (sigma*sigma)/(mean*mean))));
     141    a = TMath::Log(mean) - 0.5*b*b;
     142
     143    return TMath::Exp(a + b*gRandom->Gaus(0.0, 1.0));
     144  }
     145  else
     146  {
     147    return 0.0;
     148  }
     149}
     150
    126151
    127152//------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.