Fork me on GitHub

source: svn/trunk/modules/EnergyScale.cc@ 1364

Last change on this file since 1364 was 1338, checked in by Pavel Demin, 11 years ago

fix comments and formatting in EnergyScale

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision Date
File size: 2.2 KB
RevLine 
[1141]1
2/** \class EnergyScale
3 *
[1338]4 * Applies energy scale.
[1141]5 *
6 * $Date: 2013-11-21 10:38:22 +0000 (Thu, 21 Nov 2013) $
7 * $Revision: 1338 $
8 *
9 *
10 * \author P. Demin - UCL, Louvain-la-Neuve
11 *
12 */
13
14#include "modules/EnergyScale.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
41EnergyScale::EnergyScale() :
42 fFormula(0), fItInputArray(0)
43{
44 fFormula = new DelphesFormula;
45}
46
47//------------------------------------------------------------------------------
48
49EnergyScale::~EnergyScale()
50{
51 if(fFormula) delete fFormula;
52}
53
54//------------------------------------------------------------------------------
55
56void EnergyScale::Init()
57{
58 // read resolution formula
59
60 fFormula->Compile(GetString("ScaleFormula", "0.0"));
61
62 // import input array
63
[1338]64 fInputArray = ImportArray(GetString("InputArray", "FastJetFinder/jets"));
[1141]65 fItInputArray = fInputArray->MakeIterator();
66
67 // create output array
68
[1338]69 fOutputArray = ExportArray(GetString("OutputArray", "jets"));
[1141]70}
71
72//------------------------------------------------------------------------------
73
74void EnergyScale::Finish()
75{
76 if(fItInputArray) delete fItInputArray;
77}
78
79//------------------------------------------------------------------------------
80
81void EnergyScale::Process()
82{
83 Candidate *candidate;
84 TLorentzVector momentum;
85 Double_t scale;
86
87 fItInputArray->Reset();
88 while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
89 {
[1338]90 momentum = candidate->Momentum;
[1141]91
[1338]92 scale = fFormula->Eval(momentum.Pt(), momentum.Eta());
[1141]93
[1338]94 if(scale > 0.0) momentum *= scale;
95
96 candidate = static_cast<Candidate*>(candidate->Clone());
97 candidate->Momentum = momentum;
98
99 fOutputArray->Add(candidate);
[1141]100 }
101}
102
103//------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.