[6049672] | 1 | /*
|
---|
| 2 | * Delphes: a framework for fast simulation of a generic collider experiment
|
---|
| 3 | * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium
|
---|
| 4 | *
|
---|
| 5 | * This program is free software: you can redistribute it and/or modify
|
---|
| 6 | * it under the terms of the GNU General Public License as published by
|
---|
| 7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 8 | * (at your option) any later version.
|
---|
| 9 | *
|
---|
| 10 | * This program is distributed in the hope that it will be useful,
|
---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 13 | * GNU General Public License for more details.
|
---|
| 14 | *
|
---|
| 15 | * You should have received a copy of the GNU General Public License
|
---|
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 17 | */
|
---|
| 18 |
|
---|
[c7e90d8] | 19 | /** \class PileUpSubtractor4D
|
---|
[6049672] | 20 | *
|
---|
[c7e90d8] | 21 | * Subtract pile-up contribution from tracks using both spatial and timing
|
---|
| 22 | * information
|
---|
[6049672] | 23 | *
|
---|
[c7e90d8] | 24 | * \author M. Selvaggi - CERN
|
---|
[6049672] | 25 | *
|
---|
| 26 | */
|
---|
| 27 |
|
---|
| 28 | #include "modules/PileUpSubtractor4D.h"
|
---|
| 29 |
|
---|
| 30 | #include "classes/DelphesClasses.h"
|
---|
| 31 | #include "classes/DelphesFactory.h"
|
---|
| 32 | #include "classes/DelphesFormula.h"
|
---|
| 33 |
|
---|
| 34 | #include "ExRootAnalysis/ExRootClassifier.h"
|
---|
| 35 | #include "ExRootAnalysis/ExRootFilter.h"
|
---|
| 36 | #include "ExRootAnalysis/ExRootResult.h"
|
---|
| 37 |
|
---|
| 38 | #include "TDatabasePDG.h"
|
---|
| 39 | #include "TFormula.h"
|
---|
| 40 | #include "TLorentzVector.h"
|
---|
| 41 | #include "TMath.h"
|
---|
| 42 | #include "TObjArray.h"
|
---|
| 43 | #include "TRandom3.h"
|
---|
| 44 | #include "TString.h"
|
---|
| 45 |
|
---|
| 46 | #include <algorithm>
|
---|
| 47 | #include <iostream>
|
---|
| 48 | #include <sstream>
|
---|
| 49 | #include <stdexcept>
|
---|
| 50 |
|
---|
| 51 | using namespace std;
|
---|
| 52 |
|
---|
| 53 | //------------------------------------------------------------------------------
|
---|
| 54 |
|
---|
[c7e90d8] | 55 | PileUpSubtractor4D::PileUpSubtractor4D()
|
---|
[6049672] | 56 | {
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | //------------------------------------------------------------------------------
|
---|
| 60 |
|
---|
| 61 | PileUpSubtractor4D::~PileUpSubtractor4D()
|
---|
| 62 | {
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | //------------------------------------------------------------------------------
|
---|
| 66 |
|
---|
| 67 | void PileUpSubtractor4D::Init()
|
---|
| 68 | {
|
---|
| 69 | // import input array
|
---|
| 70 |
|
---|
| 71 | fVertexInputArray = ImportArray(GetString("VertexInputArray", "PileUpMerger/vertices"));
|
---|
| 72 | fItVertexInputArray = fVertexInputArray->MakeIterator();
|
---|
| 73 |
|
---|
| 74 | // read resolution formula in m
|
---|
| 75 | fChargedMinSignificance = GetDouble("ChargedMinSignificance", 3);
|
---|
| 76 | fNeutralMinSignificance = GetDouble("NeutralMinSignificance", 3);
|
---|
| 77 |
|
---|
| 78 | fPTMin = GetDouble("PTMin", 0.);
|
---|
| 79 |
|
---|
| 80 | // import arrays with output from other modules
|
---|
| 81 |
|
---|
| 82 | ExRootConfParam param = GetParam("InputArray");
|
---|
| 83 | Long_t i, size;
|
---|
| 84 | const TObjArray *array;
|
---|
| 85 | TIterator *iterator;
|
---|
| 86 |
|
---|
| 87 | size = param.GetSize();
|
---|
| 88 | for(i = 0; i < size / 2; ++i)
|
---|
| 89 | {
|
---|
| 90 | array = ImportArray(param[i * 2].GetString());
|
---|
| 91 | iterator = array->MakeIterator();
|
---|
| 92 |
|
---|
| 93 | fInputMap[iterator] = ExportArray(param[i * 2 + 1].GetString());
|
---|
| 94 | }
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | //------------------------------------------------------------------------------
|
---|
| 98 |
|
---|
| 99 | void PileUpSubtractor4D::Finish()
|
---|
| 100 | {
|
---|
| 101 | map<TIterator *, TObjArray *>::iterator itInputMap;
|
---|
| 102 | TIterator *iterator;
|
---|
| 103 |
|
---|
| 104 | for(itInputMap = fInputMap.begin(); itInputMap != fInputMap.end(); ++itInputMap)
|
---|
| 105 | {
|
---|
| 106 | iterator = itInputMap->first;
|
---|
| 107 | if(iterator) delete iterator;
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | if(fItVertexInputArray) delete fItVertexInputArray;
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | //------------------------------------------------------------------------------
|
---|
| 114 |
|
---|
| 115 | void PileUpSubtractor4D::Process()
|
---|
| 116 | {
|
---|
[c7e90d8] | 117 | Candidate *candidate;
|
---|
[6049672] | 118 | map<TIterator *, TObjArray *>::iterator itInputMap;
|
---|
| 119 | TIterator *iterator;
|
---|
| 120 | TObjArray *array;
|
---|
| 121 | Double_t z, zvtx = 0;
|
---|
[c7e90d8] | 122 | Double_t zvtx_err = 0;
|
---|
[6049672] | 123 | Double_t t, tvtx = 0;
|
---|
[c7e90d8] | 124 | Double_t tvtx_err = 0;
|
---|
[6049672] | 125 | Double_t sumPTSquare = 0;
|
---|
| 126 | Double_t tempPTSquare = 0;
|
---|
| 127 | Double_t distanceCharged, distanceNeutral = 0;
|
---|
| 128 |
|
---|
| 129 | // find z position of primary vertex
|
---|
| 130 |
|
---|
| 131 | fItVertexInputArray->Reset();
|
---|
| 132 | while((candidate = static_cast<Candidate *>(fItVertexInputArray->Next())))
|
---|
| 133 | {
|
---|
| 134 | tempPTSquare = candidate->SumPT2;
|
---|
| 135 | if(tempPTSquare > sumPTSquare)
|
---|
| 136 | {
|
---|
| 137 | sumPTSquare = tempPTSquare;
|
---|
| 138 | zvtx = candidate->Position.Z();
|
---|
| 139 | zvtx_err = candidate->PositionError.Z();
|
---|
| 140 | tvtx = candidate->Position.T();
|
---|
| 141 | tvtx_err = candidate->PositionError.T();
|
---|
[c7e90d8] | 142 | }
|
---|
[6049672] | 143 | }
|
---|
| 144 |
|
---|
| 145 | // loop over all input arrays
|
---|
| 146 | for(itInputMap = fInputMap.begin(); itInputMap != fInputMap.end(); ++itInputMap)
|
---|
| 147 | {
|
---|
| 148 | iterator = itInputMap->first;
|
---|
| 149 | array = itInputMap->second;
|
---|
| 150 |
|
---|
| 151 | // loop over all candidates
|
---|
| 152 | iterator->Reset();
|
---|
| 153 | while((candidate = static_cast<Candidate *>(iterator->Next())))
|
---|
| 154 | {
|
---|
| 155 |
|
---|
[c7e90d8] | 156 | z = candidate->Position.Z();
|
---|
| 157 | t = candidate->InitialPosition.T();
|
---|
[6049672] | 158 |
|
---|
[4ac0049] | 159 | distanceCharged = TMath::Sqrt(pow((zvtx - z),2)/pow((zvtx_err),2) + pow((tvtx - t),2)/pow((tvtx_err),2));
|
---|
| 160 | distanceNeutral = TMath::Sqrt(pow((tvtx - t),2)/pow((tvtx_err),2));
|
---|
[6049672] | 161 |
|
---|
| 162 | if(candidate->Charge != 0 && distanceCharged < fChargedMinSignificance)
|
---|
| 163 | {
|
---|
[4ac0049] | 164 | candidate->IsRecoPU = 0;
|
---|
[c7e90d8] | 165 | if(candidate->Momentum.Pt() > fPTMin) array->Add(candidate);
|
---|
[6049672] | 166 | }
|
---|
| 167 | else if(candidate->Charge == 0 && distanceNeutral < fNeutralMinSignificance)
|
---|
| 168 | {
|
---|
[4ac0049] | 169 | candidate->IsRecoPU = 0;
|
---|
[c7e90d8] | 170 | if(candidate->Momentum.Pt() > fPTMin) array->Add(candidate);
|
---|
| 171 | }
|
---|
[6049672] | 172 | else
|
---|
| 173 | {
|
---|
[4ac0049] | 174 | candidate->IsRecoPU = 1;
|
---|
[6049672] | 175 | }
|
---|
| 176 | }
|
---|
| 177 | }
|
---|
| 178 | }
|
---|