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 StatusPidFilter
|
---|
20 | *
|
---|
21 | * Removes all generated particles except electrons, muons, taus,
|
---|
22 | * and particles with status == 3.
|
---|
23 | *
|
---|
24 | * \author J. Hirschauer - FNAL
|
---|
25 | *
|
---|
26 | */
|
---|
27 |
|
---|
28 | #include "modules/StatusPidFilter.h"
|
---|
29 |
|
---|
30 | #include "classes/DelphesClasses.h"
|
---|
31 | #include "classes/DelphesFactory.h"
|
---|
32 | #include "classes/DelphesFormula.h"
|
---|
33 |
|
---|
34 | #include "ExRootAnalysis/ExRootResult.h"
|
---|
35 | #include "ExRootAnalysis/ExRootFilter.h"
|
---|
36 | #include "ExRootAnalysis/ExRootClassifier.h"
|
---|
37 |
|
---|
38 | #include "TMath.h"
|
---|
39 | #include "TString.h"
|
---|
40 | #include "TFormula.h"
|
---|
41 | #include "TRandom3.h"
|
---|
42 | #include "TObjArray.h"
|
---|
43 | #include "TDatabasePDG.h"
|
---|
44 | #include "TLorentzVector.h"
|
---|
45 |
|
---|
46 | #include <algorithm>
|
---|
47 | #include <stdexcept>
|
---|
48 | #include <iostream>
|
---|
49 | #include <sstream>
|
---|
50 |
|
---|
51 | using namespace std;
|
---|
52 |
|
---|
53 | namespace {
|
---|
54 | // integer power (faster than TMath::Pow() + cast to integer)
|
---|
55 | int ipow(int base, int exp)
|
---|
56 | {
|
---|
57 | int result = 1;
|
---|
58 | while (exp)
|
---|
59 | {
|
---|
60 | if (exp & 1)
|
---|
61 | result *= base;
|
---|
62 | exp >>= 1;
|
---|
63 | base *= base;
|
---|
64 | }
|
---|
65 |
|
---|
66 | return result;
|
---|
67 | }
|
---|
68 |
|
---|
69 | // standalone function to extract the i-th digit from a number (counting from 0 = rightmost, etc..)
|
---|
70 | int digit(int val, int i)
|
---|
71 | {
|
---|
72 | int y = ipow(10,i);
|
---|
73 | int z = val/y;
|
---|
74 | int val2 = val / (y * 10);
|
---|
75 | return (z - val2*10);
|
---|
76 | }
|
---|
77 |
|
---|
78 | // return the first two digits if this is a "fundamental" particle
|
---|
79 | // ID = 100 is a special case (internal generator ID's are 81-100)
|
---|
80 | // also, 101 and 102 are now used (by HepPID) for geantinos
|
---|
81 | int fundamentalID(int pdgCode)
|
---|
82 | {
|
---|
83 | pdgCode = abs(pdgCode);
|
---|
84 | if( ( digit(pdgCode, 9) == 1 ) && ( digit(pdgCode, 8) == 0 ) ) { return 0; }
|
---|
85 | if( digit(pdgCode, 2) == 0 && digit(pdgCode, 3) == 0) {
|
---|
86 | return pdgCode%10000;
|
---|
87 | } else if( pdgCode <= 102 ) {
|
---|
88 | return pdgCode;
|
---|
89 | } else {
|
---|
90 | return 0;
|
---|
91 | }
|
---|
92 | }
|
---|
93 |
|
---|
94 | bool hasBottom(int pdgCode)
|
---|
95 | {
|
---|
96 | if ( (pdgCode/10000000) > 0)
|
---|
97 | return false;
|
---|
98 | if (pdgCode <= 100)
|
---|
99 | return false;
|
---|
100 | if (fundamentalID(pdgCode) <= 100 && fundamentalID(pdgCode) > 0)
|
---|
101 | return false;
|
---|
102 | if( digit(pdgCode, 3) == 5 || digit(pdgCode, 2) == 5 || digit(pdgCode, 1) == 5 )
|
---|
103 | return true;
|
---|
104 | return false;
|
---|
105 | }
|
---|
106 |
|
---|
107 | bool isTauDaughter(int pdgCode, int M1, const TObjArray *fInputArray){
|
---|
108 | //not needed, just to speed up the code - can be further refined but gives only negligible improvement:
|
---|
109 | if ( pdgCode==15 || pdgCode<11 || (pdgCode > 22 && pdgCode < 100) || pdgCode>1000 )
|
---|
110 | return false;
|
---|
111 |
|
---|
112 | if ( M1 < 0 )
|
---|
113 | return false;
|
---|
114 |
|
---|
115 | Candidate *mother;
|
---|
116 | mother = static_cast<Candidate*>(fInputArray->At( M1 ));
|
---|
117 | if ( TMath::Abs(mother->PID) == 15 )
|
---|
118 | return true;
|
---|
119 |
|
---|
120 | return false;
|
---|
121 | }
|
---|
122 |
|
---|
123 | bool isWDaughter(int M1, const TObjArray *fInputArray)
|
---|
124 | {
|
---|
125 | if ( M1 < 0 ) return false;
|
---|
126 |
|
---|
127 | Candidate *mother;
|
---|
128 | mother = static_cast<Candidate*>(fInputArray->At( M1 ));
|
---|
129 | if ( TMath::Abs(mother->PID) == 24 ) return true;
|
---|
130 |
|
---|
131 | return false;
|
---|
132 | }
|
---|
133 |
|
---|
134 | }
|
---|
135 |
|
---|
136 |
|
---|
137 | //------------------------------------------------------------------------------
|
---|
138 |
|
---|
139 | StatusPidFilter::StatusPidFilter() :
|
---|
140 | fItInputArray(0)
|
---|
141 | {
|
---|
142 | }
|
---|
143 |
|
---|
144 | //------------------------------------------------------------------------------
|
---|
145 |
|
---|
146 | StatusPidFilter::~StatusPidFilter()
|
---|
147 | {
|
---|
148 | }
|
---|
149 |
|
---|
150 | //------------------------------------------------------------------------------
|
---|
151 |
|
---|
152 | void StatusPidFilter::Init()
|
---|
153 | {
|
---|
154 | // PT threshold
|
---|
155 |
|
---|
156 | fPTMin = GetDouble("PTMin", 0.5);
|
---|
157 |
|
---|
158 | // import input array
|
---|
159 | fInputArray = ImportArray(GetString("InputArray", "Delphes/allParticles"));
|
---|
160 | fItInputArray = fInputArray->MakeIterator();
|
---|
161 |
|
---|
162 | // create output array
|
---|
163 |
|
---|
164 | fOutputArray = ExportArray(GetString("OutputArray", "filteredParticles"));
|
---|
165 | }
|
---|
166 |
|
---|
167 | //------------------------------------------------------------------------------
|
---|
168 |
|
---|
169 | void StatusPidFilter::Finish()
|
---|
170 | {
|
---|
171 | if(fItInputArray) delete fItInputArray;
|
---|
172 | }
|
---|
173 |
|
---|
174 | //------------------------------------------------------------------------------
|
---|
175 |
|
---|
176 | void StatusPidFilter::Process()
|
---|
177 | {
|
---|
178 | Candidate *candidate;
|
---|
179 | Int_t status, pdgCode;
|
---|
180 | Bool_t pass;
|
---|
181 |
|
---|
182 | fItInputArray->Reset();
|
---|
183 | while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
|
---|
184 | {
|
---|
185 | status = candidate->Status;
|
---|
186 | pdgCode = TMath::Abs(candidate->PID);
|
---|
187 |
|
---|
188 | pass = kFALSE;
|
---|
189 |
|
---|
190 | // Store all SUSY particles
|
---|
191 | if(pdgCode >= 1000001 && pdgCode <= 1000039) pass = kTRUE;
|
---|
192 |
|
---|
193 | // hard scattering particles (first condition for Py6, second for Py8)
|
---|
194 | if(status == 3) pass = kTRUE;
|
---|
195 | if(status > 20 && status < 30 ) pass = kTRUE;
|
---|
196 |
|
---|
197 | // electrons, muons, taus and neutrinos
|
---|
198 | if(pdgCode > 10 && pdgCode < 17) pass = kTRUE;
|
---|
199 |
|
---|
200 | // heavy quarks
|
---|
201 | if(pdgCode == 4 ||pdgCode == 5 || pdgCode == 6) pass = kTRUE;
|
---|
202 |
|
---|
203 | // Gauge bosons and other fundamental bosons
|
---|
204 | if(pdgCode > 22 && pdgCode < 43) pass = kTRUE;
|
---|
205 |
|
---|
206 | //Stable photons
|
---|
207 | if(pdgCode == 22 && status==1) pass = kTRUE;
|
---|
208 |
|
---|
209 | // logic ported from HepPDF: http://lcgapp.cern.ch/project/simu/HepPDT/HepPDT.2.05.02/html/ParticleID_8cc-source.html#l00081
|
---|
210 | bool is_b_hadron = hasBottom(pdgCode);
|
---|
211 | bool is_b_quark = (pdgCode == 5);
|
---|
212 |
|
---|
213 | bool is_tau_daughter = isTauDaughter(pdgCode, candidate->M1, fInputArray);
|
---|
214 |
|
---|
215 | if (is_b_hadron)
|
---|
216 | pass = kTRUE;
|
---|
217 |
|
---|
218 | if (is_tau_daughter)
|
---|
219 | pass = kTRUE;
|
---|
220 |
|
---|
221 | bool is_W_daughter = isWDaughter(candidate->M1, fInputArray);
|
---|
222 | if (is_W_daughter)
|
---|
223 | pass = kTRUE;
|
---|
224 |
|
---|
225 | // fPTMin not applied to b_hadrons / b_quarks to allow for b-enriched sample stitching
|
---|
226 | // fPTMin not applied to tau decay products to allow visible-tau four momentum determination
|
---|
227 | if(!pass || (candidate->Momentum.Pt() < fPTMin && !(is_b_hadron || is_b_quark || is_tau_daughter || is_W_daughter)) ) continue;
|
---|
228 |
|
---|
229 | fOutputArray->Add(candidate);
|
---|
230 | }
|
---|
231 | }
|
---|
232 |
|
---|