[b443089] | 1 | /*
|
---|
| 2 | * Delphes: a framework for fast simulation of a generic collider experiment
|
---|
| 3 | * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium
|
---|
[1fa50c2] | 4 | *
|
---|
[b443089] | 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.
|
---|
[1fa50c2] | 9 | *
|
---|
[b443089] | 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.
|
---|
[1fa50c2] | 14 | *
|
---|
[b443089] | 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 |
|
---|
[d7d2da3] | 19 |
|
---|
| 20 | /** \class Isolation
|
---|
| 21 | *
|
---|
| 22 | * Sums transverse momenta of isolation objects (tracks, calorimeter towers, etc)
|
---|
| 23 | * within a DeltaR cone around a candidate and calculates fraction of this sum
|
---|
| 24 | * to the candidate's transverse momentum. outputs candidates that have
|
---|
| 25 | * the transverse momenta fraction within (PTRatioMin, PTRatioMax].
|
---|
| 26 | *
|
---|
[7f9ae0a] | 27 | * \author P. Demin, M. Selvaggi, R. Gerosa - UCL, Louvain-la-Neuve
|
---|
[d7d2da3] | 28 | *
|
---|
| 29 | */
|
---|
| 30 |
|
---|
| 31 | #include "modules/Isolation.h"
|
---|
| 32 |
|
---|
| 33 | #include "classes/DelphesClasses.h"
|
---|
| 34 | #include "classes/DelphesFactory.h"
|
---|
| 35 | #include "classes/DelphesFormula.h"
|
---|
| 36 |
|
---|
| 37 | #include "ExRootAnalysis/ExRootResult.h"
|
---|
| 38 | #include "ExRootAnalysis/ExRootFilter.h"
|
---|
| 39 | #include "ExRootAnalysis/ExRootClassifier.h"
|
---|
| 40 |
|
---|
| 41 | #include "TMath.h"
|
---|
| 42 | #include "TString.h"
|
---|
| 43 | #include "TFormula.h"
|
---|
| 44 | #include "TRandom3.h"
|
---|
| 45 | #include "TObjArray.h"
|
---|
| 46 | #include "TDatabasePDG.h"
|
---|
| 47 | #include "TLorentzVector.h"
|
---|
| 48 |
|
---|
| 49 | #include <algorithm>
|
---|
| 50 | #include <stdexcept>
|
---|
| 51 | #include <iostream>
|
---|
| 52 | #include <sstream>
|
---|
| 53 |
|
---|
| 54 | using namespace std;
|
---|
| 55 |
|
---|
| 56 | //------------------------------------------------------------------------------
|
---|
| 57 |
|
---|
| 58 | class IsolationClassifier : public ExRootClassifier
|
---|
| 59 | {
|
---|
| 60 | public:
|
---|
| 61 |
|
---|
| 62 | IsolationClassifier() {}
|
---|
| 63 |
|
---|
| 64 | Int_t GetCategory(TObject *object);
|
---|
| 65 |
|
---|
| 66 | Double_t fPTMin;
|
---|
| 67 | };
|
---|
| 68 |
|
---|
| 69 | //------------------------------------------------------------------------------
|
---|
| 70 |
|
---|
| 71 | Int_t IsolationClassifier::GetCategory(TObject *object)
|
---|
| 72 | {
|
---|
| 73 | Candidate *track = static_cast<Candidate*>(object);
|
---|
| 74 | const TLorentzVector &momentum = track->Momentum;
|
---|
| 75 |
|
---|
| 76 | if(momentum.Pt() < fPTMin) return -1;
|
---|
| 77 |
|
---|
| 78 | return 0;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | //------------------------------------------------------------------------------
|
---|
| 82 |
|
---|
| 83 | Isolation::Isolation() :
|
---|
| 84 | fClassifier(0), fFilter(0),
|
---|
[e9023b9] | 85 | fItIsolationInputArray(0), fItCandidateInputArray(0),
|
---|
| 86 | fItRhoInputArray(0)
|
---|
[d7d2da3] | 87 | {
|
---|
| 88 | fClassifier = new IsolationClassifier;
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | //------------------------------------------------------------------------------
|
---|
| 92 |
|
---|
| 93 | Isolation::~Isolation()
|
---|
| 94 | {
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | //------------------------------------------------------------------------------
|
---|
| 98 |
|
---|
| 99 | void Isolation::Init()
|
---|
| 100 | {
|
---|
| 101 | const char *rhoInputArrayName;
|
---|
| 102 |
|
---|
| 103 | fDeltaRMax = GetDouble("DeltaRMax", 0.5);
|
---|
| 104 |
|
---|
| 105 | fPTRatioMax = GetDouble("PTRatioMax", 0.1);
|
---|
| 106 |
|
---|
[b286067] | 107 | fPTSumMax = GetDouble("PTSumMax", 5.0);
|
---|
| 108 |
|
---|
| 109 | fUsePTSum = GetBool("UsePTSum", false);
|
---|
| 110 |
|
---|
[844a970] | 111 | fUseRhoCorrection = GetBool("UseRhoCorrection", true);
|
---|
| 112 |
|
---|
[d7d2da3] | 113 | fClassifier->fPTMin = GetDouble("PTMin", 0.5);
|
---|
| 114 |
|
---|
| 115 | // import input array(s)
|
---|
| 116 |
|
---|
| 117 | fIsolationInputArray = ImportArray(GetString("IsolationInputArray", "Delphes/partons"));
|
---|
| 118 | fItIsolationInputArray = fIsolationInputArray->MakeIterator();
|
---|
| 119 |
|
---|
| 120 | fFilter = new ExRootFilter(fIsolationInputArray);
|
---|
| 121 |
|
---|
| 122 | fCandidateInputArray = ImportArray(GetString("CandidateInputArray", "Calorimeter/electrons"));
|
---|
| 123 | fItCandidateInputArray = fCandidateInputArray->MakeIterator();
|
---|
| 124 |
|
---|
[48b6e45] | 125 | rhoInputArrayName = GetString("RhoInputArray", "");
|
---|
[d7d2da3] | 126 | if(rhoInputArrayName[0] != '\0')
|
---|
| 127 | {
|
---|
| 128 | fRhoInputArray = ImportArray(rhoInputArrayName);
|
---|
[e9023b9] | 129 | fItRhoInputArray = fRhoInputArray->MakeIterator();
|
---|
[d7d2da3] | 130 | }
|
---|
| 131 | else
|
---|
| 132 | {
|
---|
| 133 | fRhoInputArray = 0;
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | // create output array
|
---|
| 137 |
|
---|
| 138 | fOutputArray = ExportArray(GetString("OutputArray", "electrons"));
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | //------------------------------------------------------------------------------
|
---|
| 142 |
|
---|
| 143 | void Isolation::Finish()
|
---|
| 144 | {
|
---|
[e9023b9] | 145 | if(fItRhoInputArray) delete fItRhoInputArray;
|
---|
[d7d2da3] | 146 | if(fFilter) delete fFilter;
|
---|
| 147 | if(fItCandidateInputArray) delete fItCandidateInputArray;
|
---|
| 148 | if(fItIsolationInputArray) delete fItIsolationInputArray;
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | //------------------------------------------------------------------------------
|
---|
| 152 |
|
---|
| 153 | void Isolation::Process()
|
---|
| 154 | {
|
---|
[e9023b9] | 155 | Candidate *candidate, *isolation, *object;
|
---|
[d7d2da3] | 156 | TObjArray *isolationArray;
|
---|
[cef50c9] | 157 | Double_t sumChargedNoPU, sumChargedPU, sumNeutral, sumAllParticles;
|
---|
[004aa60] | 158 | Double_t sumDBeta, ratioDBeta, sumRhoCorr, ratioRhoCorr, sum, ratio;
|
---|
[d7d2da3] | 159 | Int_t counter;
|
---|
[e9023b9] | 160 | Double_t eta = 0.0;
|
---|
[d7d2da3] | 161 | Double_t rho = 0.0;
|
---|
| 162 |
|
---|
| 163 | // select isolation objects
|
---|
| 164 | fFilter->Reset();
|
---|
| 165 | isolationArray = fFilter->GetSubArray(fClassifier, 0);
|
---|
| 166 |
|
---|
| 167 | if(isolationArray == 0) return;
|
---|
| 168 |
|
---|
| 169 | TIter itIsolationArray(isolationArray);
|
---|
| 170 |
|
---|
| 171 | // loop over all input jets
|
---|
| 172 | fItCandidateInputArray->Reset();
|
---|
| 173 | while((candidate = static_cast<Candidate*>(fItCandidateInputArray->Next())))
|
---|
| 174 | {
|
---|
| 175 | const TLorentzVector &candidateMomentum = candidate->Momentum;
|
---|
[e9023b9] | 176 | eta = TMath::Abs(candidateMomentum.Eta());
|
---|
[d7d2da3] | 177 |
|
---|
[7aea88d] | 178 | // find rho
|
---|
| 179 | rho = 0.0;
|
---|
| 180 | if(fRhoInputArray)
|
---|
| 181 | {
|
---|
| 182 | fItRhoInputArray->Reset();
|
---|
| 183 | while((object = static_cast<Candidate*>(fItRhoInputArray->Next())))
|
---|
| 184 | {
|
---|
| 185 | if(eta >= object->Edges[0] && eta < object->Edges[1])
|
---|
| 186 | {
|
---|
| 187 | rho = object->Momentum.Pt();
|
---|
| 188 | }
|
---|
| 189 | }
|
---|
| 190 | }
|
---|
| 191 |
|
---|
[d7d2da3] | 192 | // loop over all input tracks
|
---|
[004aa60] | 193 |
|
---|
[3db5282] | 194 | sumNeutral = 0.0;
|
---|
[cef50c9] | 195 | sumChargedNoPU = 0.0;
|
---|
[7f9ae0a] | 196 | sumChargedPU = 0.0;
|
---|
| 197 | sumAllParticles = 0.0;
|
---|
[004aa60] | 198 |
|
---|
[d7d2da3] | 199 | counter = 0;
|
---|
| 200 | itIsolationArray.Reset();
|
---|
[004aa60] | 201 |
|
---|
[d7d2da3] | 202 | while((isolation = static_cast<Candidate*>(itIsolationArray.Next())))
|
---|
| 203 | {
|
---|
| 204 | const TLorentzVector &isolationMomentum = isolation->Momentum;
|
---|
| 205 |
|
---|
| 206 | if(candidateMomentum.DeltaR(isolationMomentum) <= fDeltaRMax &&
|
---|
[e8abecd] | 207 | candidate->GetUniqueID() != isolation->GetUniqueID())
|
---|
[d7d2da3] | 208 | {
|
---|
[7f9ae0a] | 209 | sumAllParticles += isolationMomentum.Pt();
|
---|
[fdfac34] | 210 | if(isolation->Charge != 0)
|
---|
[004aa60] | 211 | {
|
---|
[fdfac34] | 212 | if(isolation->IsRecoPU)
|
---|
| 213 | {
|
---|
| 214 | sumChargedPU += isolationMomentum.Pt();
|
---|
| 215 | }
|
---|
| 216 | else
|
---|
| 217 | {
|
---|
[cef50c9] | 218 | sumChargedNoPU += isolationMomentum.Pt();
|
---|
[fdfac34] | 219 | }
|
---|
[004aa60] | 220 | }
|
---|
[e8abecd] | 221 | else
|
---|
[004aa60] | 222 | {
|
---|
| 223 | sumNeutral += isolationMomentum.Pt();
|
---|
[e8abecd] | 224 | }
|
---|
[d7d2da3] | 225 | ++counter;
|
---|
| 226 | }
|
---|
| 227 | }
|
---|
| 228 |
|
---|
[e9023b9] | 229 | // find rho
|
---|
| 230 | rho = 0.0;
|
---|
| 231 | if(fRhoInputArray)
|
---|
| 232 | {
|
---|
| 233 | fItRhoInputArray->Reset();
|
---|
| 234 | while((object = static_cast<Candidate*>(fItRhoInputArray->Next())))
|
---|
| 235 | {
|
---|
| 236 | if(eta >= object->Edges[0] && eta < object->Edges[1])
|
---|
| 237 | {
|
---|
| 238 | rho = object->Momentum.Pt();
|
---|
| 239 | }
|
---|
| 240 | }
|
---|
| 241 | }
|
---|
| 242 |
|
---|
[004aa60] | 243 | // correct sum for pile-up contamination
|
---|
[cef50c9] | 244 | sumDBeta = sumChargedNoPU + TMath::Max(sumNeutral - 0.5*sumChargedPU, 0.0);
|
---|
| 245 | sumRhoCorr = sumChargedNoPU + TMath::Max(sumNeutral - TMath::Max(rho, 0.0)*fDeltaRMax*fDeltaRMax*TMath::Pi(), 0.0);
|
---|
[7f9ae0a] | 246 | ratioDBeta = sumDBeta/candidateMomentum.Pt();
|
---|
| 247 | ratioRhoCorr = sumRhoCorr/candidateMomentum.Pt();
|
---|
[004aa60] | 248 |
|
---|
[b62c2da] | 249 | candidate->IsolationVar = ratioDBeta;
|
---|
[7f9ae0a] | 250 | candidate->IsolationVarRhoCorr = ratioRhoCorr;
|
---|
[cef50c9] | 251 | candidate->SumPtCharged = sumChargedNoPU;
|
---|
[b62c2da] | 252 | candidate->SumPtNeutral = sumNeutral;
|
---|
| 253 | candidate->SumPtChargedPU = sumChargedPU;
|
---|
| 254 | candidate->SumPt = sumAllParticles;
|
---|
[7f9ae0a] | 255 |
|
---|
[844a970] | 256 | sum = fUseRhoCorrection ? sumRhoCorr : sumDBeta;
|
---|
[004aa60] | 257 | if(fUsePTSum && sum > fPTSumMax) continue;
|
---|
| 258 |
|
---|
[844a970] | 259 | ratio = fUseRhoCorrection ? ratioRhoCorr : ratioDBeta;
|
---|
[004aa60] | 260 | if(!fUsePTSum && ratio > fPTRatioMax) continue;
|
---|
| 261 |
|
---|
[d7d2da3] | 262 | fOutputArray->Add(candidate);
|
---|
| 263 | }
|
---|
| 264 | }
|
---|
| 265 |
|
---|
| 266 | //------------------------------------------------------------------------------
|
---|