Fork me on GitHub

source: svn/trunk/modules/TimeSmearing.cc@ 1366

Last change on this file since 1366 was 1344, checked in by Michele Selvaggi, 11 years ago

add TimeSmearing

File size: 2.4 KB
RevLine 
[1344]1
2/** \class TimeSmearing
3 *
4 * Performs transverse momentum resolution smearing.
5 *
6 * $Date: 2013-02-13 16:58:53 +0100 (Wed, 13 Feb 2013) $
7 * $Revision: 911 $
8 *
9 *
10 * \author P. Demin - UCL, Louvain-la-Neuve
11 *
12 */
13
14#include "modules/TimeSmearing.h"
15
16#include "classes/DelphesClasses.h"
17#include "classes/DelphesFactory.h"
18#include "classes/DelphesFormula.h"
19
20#include "ExRootAnalysis/ExRootResult.h"
21#include "ExRootAnalysis/ExRootFilter.h"
22#include "ExRootAnalysis/ExRootClassifier.h"
23
24#include "TMath.h"
25#include "TString.h"
26#include "TFormula.h"
27#include "TRandom3.h"
28#include "TObjArray.h"
29#include "TDatabasePDG.h"
30#include "TLorentzVector.h"
31
32#include <algorithm>
33#include <stdexcept>
34#include <iostream>
35#include <sstream>
36
37using namespace std;
38
39//------------------------------------------------------------------------------
40
41TimeSmearing::TimeSmearing() :
42fItInputArray(0)
43{
44}
45
46//------------------------------------------------------------------------------
47
48TimeSmearing::~TimeSmearing()
49{
50}
51
52//------------------------------------------------------------------------------
53
54void TimeSmearing::Init()
55{
56 // read resolution formula
57
58 fTimeResolution = GetDouble("TimeResolution", 1.0E-10);
59 // import input array
60
61 fInputArray = ImportArray(GetString("InputArray", "MuonMomentumSmearing/muons"));
62 fItInputArray = fInputArray->MakeIterator();
63
64 // create output array
65
66 fOutputArray = ExportArray(GetString("OutputArray", "muons"));
67}
68
69//------------------------------------------------------------------------------
70
71void TimeSmearing::Finish()
72{
73 if(fItInputArray) delete fItInputArray;
74}
75
76//------------------------------------------------------------------------------
77
78void TimeSmearing::Process()
79{
80 Candidate *candidate, *mother;
81 Double_t t;
82 const Double_t c_light = 2.99792458E8;
83
84 fItInputArray->Reset();
85 while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
86 {
87 const TLorentzVector &candidatePosition = candidate->Position;
88 t = candidatePosition.T()*1.0E-3/c_light;
89
90 // apply smearing formula
91 t = gRandom->Gaus(t, fTimeResolution);
92
93 mother = candidate;
94 candidate = static_cast<Candidate*>(candidate->Clone());
95 candidate->Position.SetT(t*1.0E3*c_light);
96
97 candidate->AddCandidate(mother);
98
99 fOutputArray->Add(candidate);
100 }
101}
102
103//------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.