[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 |
|
---|
[c41c262] | 19 | /** \class PileUpMergerPythia8
|
---|
| 20 | *
|
---|
| 21 | * Merges particles from pile-up sample into event
|
---|
| 22 | *
|
---|
[dacd9c5] | 23 | * \author M. Selvaggi - UCL, Louvain-la-Neuve
|
---|
[c41c262] | 24 | *
|
---|
| 25 | */
|
---|
| 26 |
|
---|
| 27 | #include "modules/PileUpMergerPythia8.h"
|
---|
| 28 |
|
---|
| 29 | #include "classes/DelphesClasses.h"
|
---|
| 30 | #include "classes/DelphesFactory.h"
|
---|
| 31 | #include "classes/DelphesFormula.h"
|
---|
| 32 | #include "classes/DelphesPileUpReader.h"
|
---|
| 33 |
|
---|
| 34 | #include "ExRootAnalysis/ExRootResult.h"
|
---|
| 35 | #include "ExRootAnalysis/ExRootFilter.h"
|
---|
| 36 | #include "ExRootAnalysis/ExRootClassifier.h"
|
---|
| 37 |
|
---|
[280667b] | 38 | #include "Pythia.h"
|
---|
[c41c262] | 39 |
|
---|
| 40 | #include "TMath.h"
|
---|
| 41 | #include "TString.h"
|
---|
| 42 | #include "TFormula.h"
|
---|
| 43 | #include "TRandom3.h"
|
---|
| 44 | #include "TObjArray.h"
|
---|
| 45 | #include "TDatabasePDG.h"
|
---|
| 46 | #include "TLorentzVector.h"
|
---|
| 47 |
|
---|
| 48 | #include <algorithm>
|
---|
| 49 | #include <stdexcept>
|
---|
| 50 | #include <iostream>
|
---|
| 51 | #include <sstream>
|
---|
| 52 |
|
---|
| 53 | using namespace std;
|
---|
| 54 |
|
---|
| 55 | //------------------------------------------------------------------------------
|
---|
| 56 |
|
---|
| 57 | PileUpMergerPythia8::PileUpMergerPythia8() :
|
---|
| 58 | fPythia(0), fItInputArray(0)
|
---|
| 59 | {
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | //------------------------------------------------------------------------------
|
---|
| 63 |
|
---|
| 64 | PileUpMergerPythia8::~PileUpMergerPythia8()
|
---|
| 65 | {
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | //------------------------------------------------------------------------------
|
---|
| 69 |
|
---|
| 70 | void PileUpMergerPythia8::Init()
|
---|
| 71 | {
|
---|
[eced822] | 72 | const char *fileName;
|
---|
| 73 |
|
---|
[c41c262] | 74 | fMeanPileUp = GetDouble("MeanPileUp", 10);
|
---|
| 75 | fZVertexSpread = GetDouble("ZVertexSpread", 0.05)*1.0E3;
|
---|
| 76 |
|
---|
[eced822] | 77 | fPTMin = GetDouble("PTMin", 0.0);
|
---|
[c41c262] | 78 |
|
---|
[eced822] | 79 | fileName = GetString("ConfigFile", "MinBias.cmnd");
|
---|
[c41c262] | 80 | fPythia = new Pythia8::Pythia();
|
---|
[eced822] | 81 | fPythia->readFile(fileName);
|
---|
[c41c262] | 82 |
|
---|
| 83 | // import input array
|
---|
| 84 | fInputArray = ImportArray(GetString("InputArray", "Delphes/stableParticles"));
|
---|
| 85 | fItInputArray = fInputArray->MakeIterator();
|
---|
| 86 |
|
---|
| 87 | // create output arrays
|
---|
| 88 | fOutputArray = ExportArray(GetString("OutputArray", "stableParticles"));
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | //------------------------------------------------------------------------------
|
---|
| 92 |
|
---|
| 93 | void PileUpMergerPythia8::Finish()
|
---|
| 94 | {
|
---|
| 95 | if(fPythia) delete fPythia;
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | //------------------------------------------------------------------------------
|
---|
| 99 |
|
---|
| 100 | void PileUpMergerPythia8::Process()
|
---|
| 101 | {
|
---|
| 102 | TDatabasePDG *pdg = TDatabasePDG::Instance();
|
---|
| 103 | TParticlePDG *pdgParticle;
|
---|
[dacd9c5] | 104 | Int_t pid, status;
|
---|
[c41c262] | 105 | Float_t x, y, z, t;
|
---|
| 106 | Float_t px, py, pz, e;
|
---|
| 107 | Double_t dz, dphi;
|
---|
| 108 | Int_t poisson, event, i;
|
---|
| 109 | Candidate *candidate;
|
---|
| 110 | DelphesFactory *factory;
|
---|
| 111 |
|
---|
| 112 | fItInputArray->Reset();
|
---|
| 113 | while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
|
---|
| 114 | {
|
---|
| 115 | fOutputArray->Add(candidate);
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | factory = GetFactory();
|
---|
| 119 |
|
---|
| 120 | poisson = gRandom->Poisson(fMeanPileUp);
|
---|
| 121 |
|
---|
| 122 | for(event = 0; event < poisson; ++event)
|
---|
| 123 | {
|
---|
| 124 | while(!fPythia->next());
|
---|
| 125 |
|
---|
| 126 | dz = gRandom->Gaus(0.0, fZVertexSpread);
|
---|
| 127 | dphi = gRandom->Uniform(-TMath::Pi(), TMath::Pi());
|
---|
| 128 |
|
---|
[d8b1858] | 129 | for(i = 1; i < fPythia->event.size(); ++i)
|
---|
[c41c262] | 130 | {
|
---|
[c466459] | 131 | Pythia8::Particle &particle = fPythia->event[i];
|
---|
[c41c262] | 132 |
|
---|
[dacd9c5] | 133 | status = particle.statusHepMC();
|
---|
| 134 |
|
---|
| 135 | if(status != 1 || !particle.isVisible() || particle.pT() <= fPTMin) continue;
|
---|
[c41c262] | 136 |
|
---|
| 137 | pid = particle.id();
|
---|
| 138 | px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.e();
|
---|
| 139 | x = particle.xProd(); y = particle.yProd(); z = particle.zProd(); t = particle.tProd();
|
---|
| 140 |
|
---|
| 141 | candidate = factory->NewCandidate();
|
---|
| 142 |
|
---|
| 143 | candidate->PID = pid;
|
---|
| 144 |
|
---|
[dacd9c5] | 145 | candidate->Status = status;
|
---|
[c41c262] | 146 |
|
---|
| 147 | pdgParticle = pdg->GetParticle(pid);
|
---|
| 148 | candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
|
---|
| 149 | candidate->Mass = pdgParticle ? pdgParticle->Mass() : -999.9;
|
---|
| 150 |
|
---|
| 151 | candidate->IsPU = 1;
|
---|
| 152 |
|
---|
| 153 | candidate->Momentum.SetPxPyPzE(px, py, pz, e);
|
---|
| 154 | candidate->Momentum.RotateZ(dphi);
|
---|
| 155 |
|
---|
| 156 | candidate->Position.SetXYZT(x, y, z + dz, t);
|
---|
| 157 | candidate->Position.RotateZ(dphi);
|
---|
| 158 |
|
---|
| 159 | fOutputArray->Add(candidate);
|
---|
| 160 | }
|
---|
| 161 | }
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | //------------------------------------------------------------------------------
|
---|
| 165 |
|
---|