[7e83689] | 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 |
|
---|
| 19 | /** \class ParticleDensity
|
---|
| 20 | *
|
---|
| 21 | * This module calculates the particle multiplicity density in eta-phi bins.
|
---|
| 22 | * It then assigns the value to the candidates according to the candidate eta.
|
---|
| 23 | *
|
---|
| 24 | * \author R. Preghenella - INFN, Bologna
|
---|
| 25 | *
|
---|
| 26 | */
|
---|
| 27 |
|
---|
| 28 | #include "modules/ParticleDensity.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 "TFormula.h"
|
---|
| 39 | #include "TLorentzVector.h"
|
---|
| 40 | #include "TMath.h"
|
---|
| 41 | #include "TObjArray.h"
|
---|
| 42 | #include "TRandom3.h"
|
---|
| 43 | #include "TString.h"
|
---|
| 44 | #include "TH2F.h"
|
---|
| 45 |
|
---|
| 46 | #include <algorithm>
|
---|
| 47 | #include <iostream>
|
---|
| 48 | #include <sstream>
|
---|
| 49 | #include <stdexcept>
|
---|
| 50 |
|
---|
| 51 | using namespace std;
|
---|
| 52 |
|
---|
| 53 | //------------------------------------------------------------------------------
|
---|
| 54 |
|
---|
| 55 | ParticleDensity::ParticleDensity() :
|
---|
| 56 | fItInputArray(0)
|
---|
| 57 | {}
|
---|
| 58 |
|
---|
| 59 | //------------------------------------------------------------------------------
|
---|
| 60 |
|
---|
| 61 | ParticleDensity::~ParticleDensity()
|
---|
| 62 | {}
|
---|
| 63 |
|
---|
| 64 | //------------------------------------------------------------------------------
|
---|
| 65 |
|
---|
| 66 | void ParticleDensity::Init()
|
---|
| 67 | {
|
---|
| 68 |
|
---|
| 69 | // import input array(s)
|
---|
| 70 |
|
---|
| 71 | fInputArray = ImportArray(GetString("InputArray", "FastJetFinder/jets"));
|
---|
| 72 | fItInputArray = fInputArray->MakeIterator();
|
---|
| 73 |
|
---|
| 74 | // create output array(s)
|
---|
| 75 |
|
---|
| 76 | fOutputArray = ExportArray(GetString("OutputArray", "tracks"));
|
---|
| 77 |
|
---|
| 78 | // create multiplicity histogram
|
---|
| 79 |
|
---|
| 80 | ExRootConfParam paramEta = GetParam("EtaBins");
|
---|
| 81 | const Long_t sizeEta = paramEta.GetSize();
|
---|
| 82 | Int_t nbinsEta = sizeEta - 1;
|
---|
| 83 | Float_t binsEta[sizeEta];
|
---|
| 84 | for (Int_t i = 0; i < sizeEta; ++i) {
|
---|
| 85 | binsEta[i] = paramEta[i].GetDouble();
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | ExRootConfParam paramPhi = GetParam("PhiBins");
|
---|
| 89 | const Long_t sizePhi = paramPhi.GetSize();
|
---|
| 90 | Int_t nbinsPhi = sizePhi - 1;
|
---|
| 91 | Float_t binsPhi[sizePhi];
|
---|
| 92 | for (Int_t i = 0; i < sizePhi; ++i) {
|
---|
| 93 | binsPhi[i] = paramPhi[i].GetDouble();
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | fHisto = new TH2F("hParticleDensity", ";#eta;#varphi;d^{2}N/d#etad#varphi", nbinsEta, binsEta, nbinsPhi, binsPhi);
|
---|
| 97 |
|
---|
| 98 | fUseMomentumVector = GetBool("UseMomentumVector", false);
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | //------------------------------------------------------------------------------
|
---|
| 102 |
|
---|
| 103 | void ParticleDensity::Finish()
|
---|
| 104 | {
|
---|
| 105 | if(fItInputArray) delete fItInputArray;
|
---|
| 106 | if (fHisto) delete fHisto;
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | //------------------------------------------------------------------------------
|
---|
| 110 |
|
---|
| 111 | void ParticleDensity::Process()
|
---|
| 112 | {
|
---|
| 113 | Candidate *candidate;
|
---|
| 114 | fHisto->Reset();
|
---|
| 115 |
|
---|
| 116 | // loop over all input candidates to fill histogram
|
---|
| 117 | fItInputArray->Reset();
|
---|
| 118 | while((candidate = static_cast<Candidate *>(fItInputArray->Next()))) {
|
---|
| 119 | if (fUseMomentumVector) fHisto->Fill(candidate->Momentum.Eta(), candidate->Momentum.Phi());
|
---|
| 120 | else fHisto->Fill(candidate->Position.Eta(), candidate->Position.Phi());
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | // normalise by bin width
|
---|
| 124 | fHisto->Scale(1., "width");
|
---|
| 125 |
|
---|
| 126 | // loop over all input candidates to assign multiplicity
|
---|
| 127 | fItInputArray->Reset();
|
---|
| 128 | while((candidate = static_cast<Candidate *>(fItInputArray->Next()))) {
|
---|
| 129 | Int_t ieta, iphi;
|
---|
| 130 | if (fUseMomentumVector) {
|
---|
| 131 | ieta = fHisto->GetXaxis()->FindBin(candidate->Momentum.Eta());
|
---|
| 132 | iphi = fHisto->GetYaxis()->FindBin(candidate->Momentum.Phi());
|
---|
| 133 | } else {
|
---|
| 134 | ieta = fHisto->GetXaxis()->FindBin(candidate->Position.Eta());
|
---|
| 135 | iphi = fHisto->GetYaxis()->FindBin(candidate->Position.Phi());
|
---|
| 136 | }
|
---|
| 137 | candidate->ParticleDensity = fHisto->GetBinContent(ieta, iphi);
|
---|
| 138 | fOutputArray->Add(candidate);
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 |
|
---|
| 142 | }
|
---|
| 143 |
|
---|
| 144 | //------------------------------------------------------------------------------
|
---|