Fork me on GitHub

source: git/modules/TimeSmearingTail.cc@ 1a35f96

Last change on this file since 1a35f96 was 1a35f96, checked in by Roberto Preghenella <preghenella@…>, 3 years ago

Added modules for TimeSmearing with tails

  • Property mode set to 100644
File size: 4.1 KB
Line 
1/*
2 * Delphes: a framework for fast simulation of a generic collider experiment
3 * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/** \class TimeSmearingTail
20 *
21 * Performs transverse momentum resolution smearing.
22 *
23 * \author P. Demin - UCL, Louvain-la-Neuve
24 *
25 * With addition of non-gaussian tails (R+Preghenella, preghenella@bo.infn.it)
26 * non-gaussian tails can be added on both the left/right side of the peak
27 * according to the "TailLeft" and "TailRight" parameters
28 * following a q-gaussian PDF, where Tail is the value of q (=1 for gaussian)
29 *
30 */
31
32#include "modules/TimeSmearingTail.h"
33
34#include "classes/DelphesClasses.h"
35#include "classes/DelphesFactory.h"
36#include "classes/DelphesFormula.h"
37
38#include "ExRootAnalysis/ExRootClassifier.h"
39#include "ExRootAnalysis/ExRootFilter.h"
40#include "ExRootAnalysis/ExRootResult.h"
41
42#include "TDatabasePDG.h"
43#include "TFormula.h"
44#include "TLorentzVector.h"
45#include "TMath.h"
46#include "TObjArray.h"
47#include "TRandom3.h"
48#include "TString.h"
49#include "TF1.h"
50
51#include <algorithm>
52#include <iostream>
53#include <sstream>
54#include <stdexcept>
55
56using namespace std;
57
58//------------------------------------------------------------------------------
59
60TimeSmearingTail::TimeSmearingTail() :
61 fSignal(0),
62 fItInputArray(0)
63{
64}
65
66//------------------------------------------------------------------------------
67
68TimeSmearingTail::~TimeSmearingTail()
69{
70 if (fSignal)
71 delete fSignal;
72}
73
74//------------------------------------------------------------------------------
75
76void TimeSmearingTail::Init()
77{
78 // read resolution formula
79
80 fTimeResolution = GetDouble("TimeResolution", 1.0E-10);
81 fTailLeft = GetDouble("TailLeft", 1.0);
82 fTailRight = GetDouble("TailRight", 1.0);
83 // import input array
84
85 fInputArray = ImportArray(GetString("InputArray", "MuonMomentumSmearing/muons"));
86 fItInputArray = fInputArray->MakeIterator();
87
88 // create output array
89
90 fOutputArray = ExportArray(GetString("OutputArray", "muons"));
91
92 // create signal function
93
94 fSignal = new TF1("fSignal", TimeSmearingTail::qTOF, -10.*fTimeResolution, 20.*fTimeResolution, 3);
95 fSignal->SetParameter(0, fTimeResolution);
96 fSignal->SetParameter(1, fTailRight);
97 fSignal->SetParameter(2, fTailLeft);
98}
99
100//------------------------------------------------------------------------------
101
102void TimeSmearingTail::Finish()
103{
104 if(fItInputArray) delete fItInputArray;
105}
106
107//------------------------------------------------------------------------------
108
109void TimeSmearingTail::Process()
110{
111 Candidate *candidate, *mother;
112 Double_t ti, tf_smeared, tf;
113 const Double_t c_light = 2.99792458E8;
114
115 fItInputArray->Reset();
116 while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
117 {
118 const TLorentzVector &candidateInitialPosition = candidate->InitialPosition;
119 const TLorentzVector &candidateFinalPosition = candidate->Position;
120
121 ti = candidateInitialPosition.T() * 1.0E-3 / c_light;
122 tf = candidateFinalPosition.T() * 1.0E-3 / c_light;
123
124 // apply smearing formula
125
126 tf_smeared = tf + fSignal->GetRandom();
127 ti = ti + tf_smeared - tf;
128 tf = tf_smeared;
129
130 mother = candidate;
131 candidate = static_cast<Candidate *>(candidate->Clone());
132 candidate->InitialPosition.SetT(ti * 1.0E3 * c_light);
133 candidate->Position.SetT(tf * 1.0E3 * c_light);
134
135 candidate->ErrorT = fTimeResolution * 1.0E3 * c_light;
136
137 candidate->AddCandidate(mother);
138
139 fOutputArray->Add(candidate);
140 }
141}
142
143//------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.