- Timestamp:
- May 5, 2021, 6:16:18 PM (3 years ago)
- Branches:
- master
- Children:
- 0060caa
- Parents:
- 5862d1f
- Location:
- modules
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/TimeSmearing.cc
r5862d1f rc27c038 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())))99 { 100 const TLorentzVector &candidateInitialPosition = candidate->InitialPosition; 102 fItTrackInputArray->Reset(); 103 while((candidate = static_cast<Candidate *>(fItTrackInputArray->Next()))) 104 { // converting to meters 105 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; 110 eta = candidateMomentum.Eta(); 111 energy = candidateMomentum.E(); 105 112 106 113 // 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); 110 116 111 117 mother = candidate; 112 118 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 119 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; 117 122 118 123 candidate->AddCandidate(mother); 119 120 124 fOutputArray->Add(candidate); 121 125 } 122 126 } 123 124 //------------------------------------------------------------------------------ -
modules/TimeSmearing.h
r5862d1f rc27c038 22 22 /** \class TimeSmearing 23 23 * 24 * Performs t ransverse time smearing.24 * Performs time smearing. 25 25 * 26 * \author Michele Selvaggi - UCL, Louvain-la-Neuve26 * \author Michele Selvaggi - CERN 27 27 * 28 28 */ … … 32 32 class TIterator; 33 33 class TObjArray; 34 class DelphesFormula; 34 35 35 36 class TimeSmearing: public DelphesModule … … 42 43 void Process(); 43 44 void Finish(); 45 void ComputeVertexMomenta(); 44 46 45 47 private: 46 Double_t fTimeResolution;47 48 48 TIterator *fItInputArray; //! 49 DelphesFormula *fResolutionFormula; 50 Int_t fVertexTimeMode; 49 51 50 const TObjArray *fInputArray; //! 52 TIterator *fItTrackInputArray; //! 53 54 const TObjArray *fTrackInputArray; //! 51 55 52 56 TObjArray *fOutputArray; //!
Note:
See TracChangeset
for help on using the changeset viewer.