Fork me on GitHub

Changeset c27c038 in git


Ignore:
Timestamp:
May 5, 2021, 6:16:18 PM (3 years ago)
Author:
michele <michele.selvaggi@…>
Branches:
master
Children:
0060caa
Parents:
5862d1f
Message:

TimeSmearing accepts formula, and smears only final position

Location:
modules
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • modules/TimeSmearing.cc

    r5862d1f rc27c038  
    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())))
    99   {
    100     const TLorentzVector &candidateInitialPosition = candidate->InitialPosition;
     102  fItTrackInputArray->Reset();
     103  while((candidate = static_cast<Candidate *>(fItTrackInputArray->Next())))
     104  {    // converting to meters
     105
    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;
     110    eta = candidateMomentum.Eta();
     111    energy = candidateMomentum.E();
    105112
    106113    // apply smearing formula
    107     tf_smeared = gRandom->Gaus(tf, fTimeResolution);
    108     ti = ti + tf_smeared - tf;
    109     tf = tf_smeared;
     114    timeResolution = fResolutionFormula->Eval(0.0, eta, 0.0, energy);
     115    tf_smeared = gRandom->Gaus(tf, timeResolution);
    110116
    111117    mother = candidate;
    112118    candidate = static_cast<Candidate *>(candidate->Clone());
    113     candidate->InitialPosition.SetT(ti * 1.0E3 * c_light);
    114     candidate->Position.SetT(tf * 1.0E3 * c_light);
    115119
    116     candidate->ErrorT = fTimeResolution * 1.0E3 * c_light;
     120    candidate->Position.SetT(tf_smeared * 1.0E3 * c_light);
     121    candidate->ErrorT = timeResolution * 1.0E3 * c_light;
    117122
    118123    candidate->AddCandidate(mother);
    119 
    120124    fOutputArray->Add(candidate);
    121125  }
    122126}
    123 
    124 //------------------------------------------------------------------------------
  • modules/TimeSmearing.h

    r5862d1f rc27c038  
    2222/** \class TimeSmearing
    2323 *
    24  *  Performs transverse time smearing.
     24 *  Performs time smearing.
    2525 *
    26  *  \author Michele Selvaggi - UCL, Louvain-la-Neuve
     26 *  \author Michele Selvaggi - CERN
    2727 *
    2828 */
     
    3232class TIterator;
    3333class TObjArray;
     34class DelphesFormula;
    3435
    3536class TimeSmearing: public DelphesModule
     
    4243  void Process();
    4344  void Finish();
     45  void ComputeVertexMomenta();
    4446
    4547private:
    46   Double_t fTimeResolution;
    4748
    48   TIterator *fItInputArray; //!
     49  DelphesFormula *fResolutionFormula;
     50  Int_t fVertexTimeMode;
    4951
    50   const TObjArray *fInputArray; //!
     52  TIterator *fItTrackInputArray; //!
     53
     54  const TObjArray *fTrackInputArray; //!
    5155
    5256  TObjArray *fOutputArray; //!
Note: See TracChangeset for help on using the changeset viewer.