Fork me on GitHub

source: git/modules/TrackPileUpSubtractor.cc@ 54b6dfc

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

JetId v2

  • Property mode set to 100644
File size: 3.4 KB
RevLine 
[d7d2da3]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{
[22dc7fd]55// import input array
56
57 fVertexInputArray = ImportArray(GetString("VertexInputArray", "PileUpMerger/vertices"));
58 fItVertexInputArray = fVertexInputArray->MakeIterator();
59
[d7d2da3]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
[498cda4]75 fInputMap[iterator] = ExportArray(param[i*2 + 1].GetString());
[d7d2da3]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 }
[22dc7fd]92
93 if(fItVertexInputArray) delete fItVertexInputArray;
[d7d2da3]94}
95
96//------------------------------------------------------------------------------
97
98void TrackPileUpSubtractor::Process()
99{
100 Candidate *candidate, *particle;
101 map< TIterator *, TObjArray * >::iterator itInputMap;
102 TIterator *iterator;
103 TObjArray *array;
[24d005f]104 Double_t z, zvtx=0;
[22dc7fd]105
106
107 // find z position of primary vertex
108
109 fItVertexInputArray->Reset();
110 while((candidate = static_cast<Candidate*>(fItVertexInputArray->Next())))
111 {
[54b6dfc]112 if(!candidate->IsPU)
[22dc7fd]113 {
114 zvtx = candidate->Position.Z();
[54b6dfc]115 // break;
[22dc7fd]116 }
117 }
118
[d7d2da3]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();
[54b6dfc]131
[d7d2da3]132 // apply pile-up subtraction
133 // assume perfect pile-up subtraction for tracks outside fZVertexResolution
[54b6dfc]134
[22dc7fd]135 if(candidate->IsPU && TMath::Abs(z-zvtx) > fZVertexResolution) continue;
[d7d2da3]136
137 array->Add(candidate);
138 }
139 }
140}
141
142//------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.