[01f457a] | 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 | *
|
---|
[01f457a] | 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 | *
|
---|
[01f457a] | 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 | *
|
---|
[01f457a] | 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 |
|
---|
[be2222c] | 19 | /** \class PdgCodeFilter
|
---|
| 20 | *
|
---|
[6cdc544] | 21 | * Removes particles with specific PDG codes
|
---|
[be2222c] | 22 | *
|
---|
| 23 | * \author M. Selvaggi
|
---|
| 24 | *
|
---|
| 25 | */
|
---|
| 26 |
|
---|
| 27 | #include "modules/PdgCodeFilter.h"
|
---|
| 28 |
|
---|
| 29 | #include "classes/DelphesClasses.h"
|
---|
| 30 | #include "classes/DelphesFactory.h"
|
---|
| 31 | #include "classes/DelphesFormula.h"
|
---|
| 32 |
|
---|
| 33 | #include "ExRootAnalysis/ExRootClassifier.h"
|
---|
[341014c] | 34 | #include "ExRootAnalysis/ExRootFilter.h"
|
---|
| 35 | #include "ExRootAnalysis/ExRootResult.h"
|
---|
[be2222c] | 36 |
|
---|
[6cdc544] | 37 | #include "TDatabasePDG.h"
|
---|
[341014c] | 38 | #include "TFormula.h"
|
---|
[be2222c] | 39 | #include "TLorentzVector.h"
|
---|
[341014c] | 40 | #include "TMath.h"
|
---|
| 41 | #include "TObjArray.h"
|
---|
| 42 | #include "TRandom3.h"
|
---|
| 43 | #include "TString.h"
|
---|
[be2222c] | 44 |
|
---|
| 45 | #include <algorithm>
|
---|
| 46 | #include <iostream>
|
---|
| 47 | #include <sstream>
|
---|
[341014c] | 48 | #include <stdexcept>
|
---|
[be2222c] | 49 |
|
---|
| 50 | using namespace std;
|
---|
| 51 |
|
---|
| 52 | //------------------------------------------------------------------------------
|
---|
| 53 |
|
---|
| 54 | PdgCodeFilter::PdgCodeFilter() :
|
---|
| 55 | fItInputArray(0)
|
---|
| 56 | {
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | //------------------------------------------------------------------------------
|
---|
| 60 |
|
---|
| 61 | PdgCodeFilter::~PdgCodeFilter()
|
---|
| 62 | {
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | //------------------------------------------------------------------------------
|
---|
| 66 |
|
---|
| 67 | void PdgCodeFilter::Init()
|
---|
| 68 | {
|
---|
[6cdc544] | 69 |
|
---|
[be2222c] | 70 | ExRootConfParam param;
|
---|
| 71 | Size_t i, size;
|
---|
[6cdc544] | 72 |
|
---|
[be2222c] | 73 | // PT threshold
|
---|
| 74 | fPTMin = GetDouble("PTMin", 0.0);
|
---|
| 75 |
|
---|
[b3c0535] | 76 | fInvert = GetBool("Invert", false);
|
---|
[fa42514] | 77 |
|
---|
[341014c] | 78 | // no pileup
|
---|
[7a86a5c] | 79 | fRequireNotPileup = GetBool("RequireNotPileup", false);
|
---|
| 80 |
|
---|
[fa42514] | 81 | fRequireStatus = GetBool("RequireStatus", false);
|
---|
| 82 | fStatus = GetInt("Status", 1);
|
---|
| 83 |
|
---|
[56562d0] | 84 | fRequireCharge = GetBool("RequireCharge", false);
|
---|
| 85 | fCharge = GetInt("Charge", 1);
|
---|
| 86 |
|
---|
[2c8865f] | 87 | // keep bhadron
|
---|
| 88 | fRequireKeepGhostBHadron = GetBool("RequireKeepGhostBHadron", false);
|
---|
| 89 |
|
---|
[be2222c] | 90 | // import input array
|
---|
| 91 | fInputArray = ImportArray(GetString("InputArray", "Delphes/allParticles"));
|
---|
| 92 | fItInputArray = fInputArray->MakeIterator();
|
---|
[6cdc544] | 93 |
|
---|
[be2222c] | 94 | param = GetParam("PdgCode");
|
---|
| 95 | size = param.GetSize();
|
---|
| 96 |
|
---|
| 97 | // read PdgCodes to be filtered out from the data card
|
---|
[6cdc544] | 98 |
|
---|
[be2222c] | 99 | fPdgCodes.clear();
|
---|
| 100 | for(i = 0; i < size; ++i)
|
---|
| 101 | {
|
---|
| 102 | fPdgCodes.push_back(param[i].GetInt());
|
---|
| 103 | }
|
---|
[6cdc544] | 104 |
|
---|
[be2222c] | 105 | // create output array
|
---|
| 106 | fOutputArray = ExportArray(GetString("OutputArray", "filteredParticles"));
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | //------------------------------------------------------------------------------
|
---|
| 110 |
|
---|
| 111 | void PdgCodeFilter::Finish()
|
---|
| 112 | {
|
---|
| 113 | if(fItInputArray) delete fItInputArray;
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | //------------------------------------------------------------------------------
|
---|
| 117 |
|
---|
| 118 | void PdgCodeFilter::Process()
|
---|
| 119 | {
|
---|
| 120 | Candidate *candidate;
|
---|
| 121 | Int_t pdgCode;
|
---|
| 122 | Bool_t pass;
|
---|
| 123 | Double_t pt;
|
---|
| 124 |
|
---|
| 125 | fItInputArray->Reset();
|
---|
[341014c] | 126 | while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
|
---|
[be2222c] | 127 | {
|
---|
| 128 | pdgCode = candidate->PID;
|
---|
[2c8865f] | 129 |
|
---|
| 130 | if (fRequireKeepGhostBHadron) {
|
---|
| 131 | if (isBHadron(abs(pdgCode)) ){
|
---|
| 132 | candidate->PT = candidate->PT * 1e-18;
|
---|
| 133 | if (candidate->PT ==0) candidate->PT = 1e-18;
|
---|
[0983d48] | 134 | candidate->Momentum.SetPtEtaPhiM(candidate->PT, candidate->Momentum.Eta(), candidate->Momentum.Phi(), candidate->Momentum.M());
|
---|
[2c8865f] | 135 | fOutputArray->Add(candidate);
|
---|
| 136 | continue;
|
---|
| 137 | }
|
---|
| 138 | }
|
---|
| 139 |
|
---|
[be2222c] | 140 | const TLorentzVector &candidateMomentum = candidate->Momentum;
|
---|
| 141 | pt = candidateMomentum.Pt();
|
---|
[6cdc544] | 142 |
|
---|
[fa42514] | 143 | if(pt < fPTMin) continue;
|
---|
[b3c0535] | 144 | if(fRequireStatus && (candidate->Status != fStatus)) continue;
|
---|
[56562d0] | 145 | if(fRequireCharge && (candidate->Charge != fCharge)) continue;
|
---|
[341014c] | 146 | if(fRequireNotPileup && (candidate->IsPU > 0)) continue;
|
---|
[be2222c] | 147 |
|
---|
[fa42514] | 148 | pass = kTRUE;
|
---|
[6cdc544] | 149 | if(find(fPdgCodes.begin(), fPdgCodes.end(), pdgCode) != fPdgCodes.end()) pass = kFALSE;
|
---|
[be2222c] | 150 |
|
---|
[b3c0535] | 151 | if(fInvert) pass = !pass;
|
---|
[6cdc544] | 152 | if(pass) fOutputArray->Add(candidate);
|
---|
[be2222c] | 153 | }
|
---|
| 154 | }
|
---|
[2c8865f] | 155 |
|
---|
| 156 | Bool_t PdgCodeFilter::isBHadron(const unsigned int absPdgId) {
|
---|
| 157 | if (absPdgId <= 100)
|
---|
| 158 | return false; // Fundamental particles and MC internals
|
---|
| 159 | if (absPdgId >= 1000000000)
|
---|
| 160 | return false; // Nuclei, +-10LZZZAAAI
|
---|
| 161 |
|
---|
| 162 | // General form of PDG ID is 7 digit form
|
---|
| 163 | // +- n nr nL nq1 nq2 nq3 nJ
|
---|
| 164 | //const int nJ = absPdgId % 10; // Spin
|
---|
| 165 | const int nq3 = (absPdgId / 10) % 10;
|
---|
| 166 | const int nq2 = (absPdgId / 100) % 10;
|
---|
| 167 | const int nq1 = (absPdgId / 1000) % 10;
|
---|
| 168 |
|
---|
| 169 | if (nq3 == 0)
|
---|
| 170 | return false; // Diquarks
|
---|
| 171 | if (nq1 == 0 and nq2 == 5)
|
---|
| 172 | return true; // B mesons
|
---|
| 173 | if (nq1 == 5)
|
---|
| 174 | return true; // B baryons
|
---|
| 175 |
|
---|
| 176 | return false;
|
---|
| 177 | }
|
---|
| 178 |
|
---|