Fork me on GitHub

source: git/modules/TrackPileUpSubtractor.cc@ f42fdd9

ImprovedOutputFile Timing dual_readout llp
Last change on this file since f42fdd9 was 54b6dfc, checked in by mselvaggi <mselvaggi@…>, 11 years ago

JetId v2

  • Property mode set to 100644
File size: 3.4 KB
Line 
1
2/** \class TrackPileUpSubtractor
3 *
4 * Subtract pile-up contribution from tracks.
5 *
6 * $Date$
7 * $Revision$
8 *
9 *
10 * \author P. Demin - UCL, Louvain-la-Neuve
11 *
12 */
13
14#include "modules/TrackPileUpSubtractor.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
41TrackPileUpSubtractor::TrackPileUpSubtractor()
42{
43}
44
45//------------------------------------------------------------------------------
46
47TrackPileUpSubtractor::~TrackPileUpSubtractor()
48{
49}
50
51//------------------------------------------------------------------------------
52
53void TrackPileUpSubtractor::Init()
54{
55// import input array
56
57 fVertexInputArray = ImportArray(GetString("VertexInputArray", "PileUpMerger/vertices"));
58 fItVertexInputArray = fVertexInputArray->MakeIterator();
59
60 fZVertexResolution = GetDouble("ZVertexResolution", 0.005)*1.0E3;
61
62 // import arrays with output from other modules
63
64 ExRootConfParam param = GetParam("InputArray");
65 Long_t i, size;
66 const TObjArray *array;
67 TIterator *iterator;
68
69 size = param.GetSize();
70 for(i = 0; i < size/2; ++i)
71 {
72 array = ImportArray(param[i*2].GetString());
73 iterator = array->MakeIterator();
74
75 fInputMap[iterator] = ExportArray(param[i*2 + 1].GetString());
76 }
77}
78
79//------------------------------------------------------------------------------
80
81void TrackPileUpSubtractor::Finish()
82{
83 map< TIterator *, TObjArray * >::iterator itInputMap;
84 TIterator *iterator;
85
86 for(itInputMap = fInputMap.begin(); itInputMap != fInputMap.end(); ++itInputMap)
87 {
88 iterator = itInputMap->first;
89
90 if(iterator) delete iterator;
91 }
92
93 if(fItVertexInputArray) delete fItVertexInputArray;
94}
95
96//------------------------------------------------------------------------------
97
98void TrackPileUpSubtractor::Process()
99{
100 Candidate *candidate, *particle;
101 map< TIterator *, TObjArray * >::iterator itInputMap;
102 TIterator *iterator;
103 TObjArray *array;
104 Double_t z, zvtx=0;
105
106
107 // find z position of primary vertex
108
109 fItVertexInputArray->Reset();
110 while((candidate = static_cast<Candidate*>(fItVertexInputArray->Next())))
111 {
112 if(!candidate->IsPU)
113 {
114 zvtx = candidate->Position.Z();
115 // break;
116 }
117 }
118
119 // loop over all input arrays
120 for(itInputMap = fInputMap.begin(); itInputMap != fInputMap.end(); ++itInputMap)
121 {
122 iterator = itInputMap->first;
123 array = itInputMap->second;
124
125 // loop over all candidates
126 iterator->Reset();
127 while((candidate = static_cast<Candidate*>(iterator->Next())))
128 {
129 particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
130 z = particle->Position.Z();
131
132 // apply pile-up subtraction
133 // assume perfect pile-up subtraction for tracks outside fZVertexResolution
134
135 if(candidate->IsPU && TMath::Abs(z-zvtx) > fZVertexResolution) continue;
136
137 array->Add(candidate);
138 }
139 }
140}
141
142//------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.