[1069] | 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 |
|
---|
[1070] | 32 | #include <algorithm>
|
---|
[1069] | 33 | #include <stdexcept>
|
---|
| 34 | #include <iostream>
|
---|
| 35 | #include <sstream>
|
---|
| 36 |
|
---|
| 37 | using namespace std;
|
---|
| 38 |
|
---|
| 39 | //------------------------------------------------------------------------------
|
---|
| 40 |
|
---|
| 41 | TrackPileUpSubtractor::TrackPileUpSubtractor()
|
---|
| 42 | {
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | //------------------------------------------------------------------------------
|
---|
| 46 |
|
---|
| 47 | TrackPileUpSubtractor::~TrackPileUpSubtractor()
|
---|
| 48 | {
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | //------------------------------------------------------------------------------
|
---|
| 52 |
|
---|
| 53 | void 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 |
|
---|
| 81 | void 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 |
|
---|
| 98 | void TrackPileUpSubtractor::Process()
|
---|
| 99 | {
|
---|
[1073] | 100 | Candidate *candidate, *particle;
|
---|
[1069] | 101 | map< TIterator *, TObjArray * >::iterator itInputMap;
|
---|
| 102 | TIterator *iterator;
|
---|
| 103 | TObjArray *array;
|
---|
[1345] | 104 | Double_t z, zvtx;
|
---|
[1069] | 105 |
|
---|
[1345] | 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 |
|
---|
[1069] | 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 | {
|
---|
[1073] | 130 | particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
|
---|
| 131 | z = particle->Position.Z();
|
---|
[1070] | 132 |
|
---|
[1069] | 133 | // apply pile-up subtraction
|
---|
| 134 | // assume perfect pile-up subtraction for tracks outside fZVertexResolution
|
---|
[1345] | 135 | if(candidate->IsPU && TMath::Abs(z-zvtx) > fZVertexResolution) continue;
|
---|
[1069] | 136 |
|
---|
| 137 | array->Add(candidate);
|
---|
| 138 | }
|
---|
| 139 | }
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | //------------------------------------------------------------------------------
|
---|