Fork me on GitHub

source: svn/trunk/modules/TrackPileUpSubtractor.cc@ 1395

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

JetId v2

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision Date
File size: 3.4 KB
RevLine 
[1069]1
2/** \class TrackPileUpSubtractor
3 *
4 * Subtract pile-up contribution from tracks.
5 *
6 * $Date: 2014-01-17 13:29:22 +0000 (Fri, 17 Jan 2014) $
7 * $Revision: 1349 $
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
[1070]32#include <algorithm>
[1069]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{
[1345]55// import input array
56
57 fVertexInputArray = ImportArray(GetString("VertexInputArray", "PileUpMerger/vertices"));
58 fItVertexInputArray = fVertexInputArray->MakeIterator();
59
[1069]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
[1314]75 fInputMap[iterator] = ExportArray(param[i*2 + 1].GetString());
[1069]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 }
[1345]92
93 if(fItVertexInputArray) delete fItVertexInputArray;
[1069]94}
95
96//------------------------------------------------------------------------------
97
98void TrackPileUpSubtractor::Process()
99{
[1073]100 Candidate *candidate, *particle;
[1069]101 map< TIterator *, TObjArray * >::iterator itInputMap;
102 TIterator *iterator;
103 TObjArray *array;
[1348]104 Double_t z, zvtx=0;
[1069]105
[1345]106
107 // find z position of primary vertex
108
109 fItVertexInputArray->Reset();
110 while((candidate = static_cast<Candidate*>(fItVertexInputArray->Next())))
111 {
[1349]112 if(!candidate->IsPU)
[1345]113 {
114 zvtx = candidate->Position.Z();
[1349]115 // break;
[1345]116 }
117 }
118
[1069]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 {
[1073]129 particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
130 z = particle->Position.Z();
[1349]131
[1069]132 // apply pile-up subtraction
133 // assume perfect pile-up subtraction for tracks outside fZVertexResolution
[1349]134
[1345]135 if(candidate->IsPU && TMath::Abs(z-zvtx) > fZVertexResolution) continue;
[1069]136
137 array->Add(candidate);
138 }
139 }
140}
141
142//------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.