Changeset 4acf2fd in git for modules/TimeSmearing.cc
- Timestamp:
- May 17, 2021, 6:05:38 PM (3 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/TimeSmearing.cc
r46d3442 r4acf2fd 19 19 /** \class TimeSmearing 20 20 * 21 * Performs t ransverse momentum resolutionsmearing.21 * Performs time smearing. 22 22 * 23 * \author P. Demin - UCL, Louvain-la-Neuve23 * \author M. Selvaggi - CERN 24 24 * 25 25 */ … … 49 49 50 50 using namespace std; 51 52 51 //------------------------------------------------------------------------------ 53 52 54 53 TimeSmearing::TimeSmearing() : 55 fIt InputArray(0)54 fItTrackInputArray(0), fResolutionFormula(0) 56 55 { 56 fResolutionFormula = new DelphesFormula; 57 57 } 58 58 … … 61 61 TimeSmearing::~TimeSmearing() 62 62 { 63 if(fResolutionFormula) delete fResolutionFormula; 63 64 } 64 65 … … 69 70 // read resolution formula 70 71 71 fTimeResolution = GetDouble("TimeResolution", 1.0E-10);72 // import input array72 // read time resolution formula in seconds 73 fResolutionFormula->Compile(GetString("TimeResolution", "30e-12")); 73 74 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 76 79 77 80 // create output array 78 79 fOutputArray = ExportArray(GetString("OutputArray", "muons")); 81 fOutputArray = ExportArray(GetString("OutputArray", "tracks")); 80 82 } 81 83 … … 84 86 void TimeSmearing::Finish() 85 87 { 86 if(fIt InputArray) delete fItInputArray;88 if(fItTrackInputArray) delete fItTrackInputArray; 87 89 } 88 90 … … 92 94 { 93 95 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 95 100 const Double_t c_light = 2.99792458E8; 96 101 97 fIt InputArray->Reset();98 while((candidate = static_cast<Candidate *>(fIt InputArray->Next())))102 fItTrackInputArray->Reset(); 103 while((candidate = static_cast<Candidate *>(fItTrackInputArray->Next()))) 99 104 { 100 const TLorentzVector &candidateInitialPosition = candidate->InitialPosition;105 // converting to meters 101 106 const TLorentzVector &candidateFinalPosition = candidate->Position; 107 const TLorentzVector &candidateMomentum = candidate->Momentum; 102 108 103 ti = candidateInitialPosition.T() * 1.0E-3 / c_light;104 109 tf = candidateFinalPosition.T() * 1.0E-3 / c_light; 105 110 111 eta = candidateMomentum.Eta(); 112 energy = candidateMomentum.E(); 113 106 114 // 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); 110 117 111 118 mother = candidate; 112 119 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 120 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; 117 123 118 124 candidate->AddCandidate(mother); 119 120 125 fOutputArray->Add(candidate); 121 126 } 122 127 } 123 124 //------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.