Fork me on GitHub

Changeset 4acf2fd in git for modules/TimeSmearing.cc


Ignore:
Timestamp:
May 17, 2021, 6:05:38 PM (3 years ago)
Author:
GitHub <noreply@…>
Branches:
master
Children:
7dac4ea
Parents:
46d3442 (diff), 4afb18d (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:
Michele Selvaggi <michele.selvaggi@…> (05/17/21 18:05:38)
git-committer:
GitHub <noreply@…> (05/17/21 18:05:38)
Message:

Merge branch 'master' into master

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/TimeSmearing.cc

    r46d3442 r4acf2fd  
    1919/** \class TimeSmearing
    2020 *
    21  *  Performs transverse momentum resolution smearing.
     21 *  Performs time smearing.
    2222 *
    23  *  \author P. Demin - UCL, Louvain-la-Neuve
     23 *  \author M. Selvaggi - CERN
    2424 *
    2525 */
     
    4949
    5050using namespace std;
    51 
    5251//------------------------------------------------------------------------------
    5352
    5453TimeSmearing::TimeSmearing() :
    55   fItInputArray(0)
     54  fItTrackInputArray(0), fResolutionFormula(0)
    5655{
     56        fResolutionFormula = new DelphesFormula;
    5757}
    5858
     
    6161TimeSmearing::~TimeSmearing()
    6262{
     63        if(fResolutionFormula) delete fResolutionFormula;
    6364}
    6465
     
    6970  // read resolution formula
    7071
    71   fTimeResolution = GetDouble("TimeResolution", 1.0E-10);
    72   // import input array
     72  // read time resolution formula in seconds
     73  fResolutionFormula->Compile(GetString("TimeResolution", "30e-12"));
    7374
    74   fInputArray = ImportArray(GetString("InputArray", "MuonMomentumSmearing/muons"));
    75   fItInputArray = fInputArray->MakeIterator();
     75  // import track input array
     76  fTrackInputArray = ImportArray(GetString("TrackInputArray", "MuonMomentumSmearing/muons"));
     77  fItTrackInputArray = fTrackInputArray->MakeIterator();
     78
    7679
    7780  // create output array
    78 
    79   fOutputArray = ExportArray(GetString("OutputArray", "muons"));
     81  fOutputArray = ExportArray(GetString("OutputArray", "tracks"));
    8082}
    8183
     
    8486void TimeSmearing::Finish()
    8587{
    86   if(fItInputArray) delete fItInputArray;
     88  if(fItTrackInputArray) delete fItTrackInputArray;
    8789}
    8890
     
    9294{
    9395  Candidate *candidate, *mother;
    94   Double_t ti, tf_smeared, tf;
     96  Double_t tf_smeared, tf;
     97  Double_t eta, energy;
     98  Double_t timeResolution;
     99
    95100  const Double_t c_light = 2.99792458E8;
    96101
    97   fItInputArray->Reset();
    98   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     102  fItTrackInputArray->Reset();
     103  while((candidate = static_cast<Candidate *>(fItTrackInputArray->Next())))
    99104  {
    100     const TLorentzVector &candidateInitialPosition = candidate->InitialPosition;
     105    // converting to meters
    101106    const TLorentzVector &candidateFinalPosition = candidate->Position;
     107    const TLorentzVector &candidateMomentum = candidate->Momentum;
    102108
    103     ti = candidateInitialPosition.T() * 1.0E-3 / c_light;
    104109    tf = candidateFinalPosition.T() * 1.0E-3 / c_light;
    105110
     111    eta = candidateMomentum.Eta();
     112    energy = candidateMomentum.E();
     113
    106114    // apply smearing formula
    107     tf_smeared = gRandom->Gaus(tf, fTimeResolution);
    108     ti = ti + tf_smeared - tf;
    109     tf = tf_smeared;
     115    timeResolution = fResolutionFormula->Eval(0.0, eta, 0.0, energy);
     116    tf_smeared = gRandom->Gaus(tf, timeResolution);
    110117
    111118    mother = candidate;
    112119    candidate = static_cast<Candidate *>(candidate->Clone());
    113     candidate->InitialPosition.SetT(ti * 1.0E3 * c_light);
    114     candidate->Position.SetT(tf * 1.0E3 * c_light);
    115120
    116     candidate->ErrorT = fTimeResolution * 1.0E3 * c_light;
     121    candidate->Position.SetT(tf_smeared * 1.0E3 * c_light);
     122    candidate->ErrorT = timeResolution * 1.0E3 * c_light;
    117123
    118124    candidate->AddCandidate(mother);
    119 
    120125    fOutputArray->Add(candidate);
    121126  }
    122127}
    123 
    124 //------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.