Fork me on GitHub

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

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

timing implemented

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision Date
File size: 3.4 KB
Line 
1
2/** \class TrackPileUpSubtractor
3 *
4 * Subtract pile-up contribution from tracks.
5 *
6 * $Date: 2013-12-21 14:00:11 +0000 (Sat, 21 Dec 2013) $
7 * $Revision: 1345 $
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;
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 == 0)
113 {
114 zvtx = candidate->Position.Z();
115 break;
116 }
117 }
118
119
120 // loop over all input arrays
121 for(itInputMap = fInputMap.begin(); itInputMap != fInputMap.end(); ++itInputMap)
122 {
123 iterator = itInputMap->first;
124 array = itInputMap->second;
125
126 // loop over all candidates
127 iterator->Reset();
128 while((candidate = static_cast<Candidate*>(iterator->Next())))
129 {
130 particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
131 z = particle->Position.Z();
132
133 // apply pile-up subtraction
134 // assume perfect pile-up subtraction for tracks outside fZVertexResolution
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.