Fork me on GitHub

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/TimeSmearing.cc

    r04e2040 r341014c  
    1919/** \class TimeSmearing
    2020 *
    21  *  Performs time smearing.
     21 *  Performs transverse momentum resolution smearing.
    2222 *
    23  *  \author M. Selvaggi - CERN
     23 *  \author P. Demin - UCL, Louvain-la-Neuve
    2424 *
    2525 */
     
    4949
    5050using namespace std;
     51
    5152//------------------------------------------------------------------------------
    5253
    5354TimeSmearing::TimeSmearing() :
    54   fItTrackInputArray(0), fResolutionFormula(0)
     55  fItInputArray(0)
    5556{
    56         fResolutionFormula = new DelphesFormula;
    5757}
    5858
     
    6161TimeSmearing::~TimeSmearing()
    6262{
    63         if(fResolutionFormula) delete fResolutionFormula;
    6463}
    6564
     
    7069  // read resolution formula
    7170
    72   // read time resolution formula in seconds
    73   fResolutionFormula->Compile(GetString("TimeResolution", "30e-12"));
     71  fTimeResolution = GetDouble("TimeResolution", 1.0E-10);
     72  // import input array
    7473
    75   // import track input array
    76   fTrackInputArray = ImportArray(GetString("TrackInputArray", "MuonMomentumSmearing/muons"));
    77   fItTrackInputArray = fTrackInputArray->MakeIterator();
    78 
     74  fInputArray = ImportArray(GetString("InputArray", "MuonMomentumSmearing/muons"));
     75  fItInputArray = fInputArray->MakeIterator();
    7976
    8077  // create output array
    81   fOutputArray = ExportArray(GetString("OutputArray", "tracks"));
     78
     79  fOutputArray = ExportArray(GetString("OutputArray", "muons"));
    8280}
    8381
     
    8684void TimeSmearing::Finish()
    8785{
    88   if(fItTrackInputArray) delete fItTrackInputArray;
     86  if(fItInputArray) delete fItInputArray;
    8987}
    9088
     
    9492{
    9593  Candidate *candidate, *mother;
    96   Double_t tf_smeared, tf;
    97   Double_t eta, energy;
    98   Double_t timeResolution;
    99 
     94  Double_t ti, tf_smeared, tf;
    10095  const Double_t c_light = 2.99792458E8;
    10196
    102   fItTrackInputArray->Reset();
    103   while((candidate = static_cast<Candidate *>(fItTrackInputArray->Next())))
     97  fItInputArray->Reset();
     98  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    10499  {
    105     // converting to meters
     100    const TLorentzVector &candidateInitialPosition = candidate->InitialPosition;
    106101    const TLorentzVector &candidateFinalPosition = candidate->Position;
    107     const TLorentzVector &candidateMomentum = candidate->Momentum;
    108102
     103    ti = candidateInitialPosition.T() * 1.0E-3 / c_light;
    109104    tf = candidateFinalPosition.T() * 1.0E-3 / c_light;
    110105
    111     eta = candidateMomentum.Eta();
    112     energy = candidateMomentum.E();
    113 
    114106    // apply smearing formula
    115     timeResolution = fResolutionFormula->Eval(0.0, eta, 0.0, energy);
    116     tf_smeared = gRandom->Gaus(tf, timeResolution);
     107    tf_smeared = gRandom->Gaus(tf, fTimeResolution);
     108    ti = ti + tf_smeared - tf;
     109    tf = tf_smeared;
    117110
    118111    mother = candidate;
    119112    candidate = static_cast<Candidate *>(candidate->Clone());
     113    candidate->InitialPosition.SetT(ti * 1.0E3 * c_light);
     114    candidate->Position.SetT(tf * 1.0E3 * c_light);
    120115
    121     candidate->Position.SetT(tf_smeared * 1.0E3 * c_light);
    122     candidate->ErrorT = timeResolution * 1.0E3 * c_light;
     116    candidate->ErrorT = fTimeResolution * 1.0E3 * c_light;
    123117
    124118    candidate->AddCandidate(mother);
     119
    125120    fOutputArray->Add(candidate);
    126121  }
    127122}
     123
     124//------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.