Changeset 341014c in git for modules/StatusPidFilter.cc
- Timestamp:
- Feb 12, 2019, 9:29:17 PM (6 years ago)
- Branches:
- ImprovedOutputFile, Timing, llp, master
- Children:
- 6455202
- Parents:
- 45e58be
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/StatusPidFilter.cc
r45e58be r341014c 32 32 #include "classes/DelphesFormula.h" 33 33 34 #include "ExRootAnalysis/ExRootClassifier.h" 35 #include "ExRootAnalysis/ExRootFilter.h" 34 36 #include "ExRootAnalysis/ExRootResult.h" 35 #include "ExRootAnalysis/ExRootFilter.h" 36 #include "ExRootAnalysis/ExRootClassifier.h" 37 37 38 #include "TDatabasePDG.h" 39 #include "TFormula.h" 40 #include "TLorentzVector.h" 38 41 #include "TMath.h" 42 #include "TObjArray.h" 43 #include "TRandom3.h" 39 44 #include "TString.h" 40 #include "TFormula.h"41 #include "TRandom3.h"42 #include "TObjArray.h"43 #include "TDatabasePDG.h"44 #include "TLorentzVector.h"45 45 46 46 #include <algorithm> 47 #include <stdexcept>48 47 #include <iostream> 49 48 #include <sstream> 49 #include <stdexcept> 50 50 51 51 using namespace std; 52 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 53 namespace 54 { 55 // integer power (faster than TMath::Pow() + cast to integer) 56 int ipow(int base, int exp) 57 { 58 int result = 1; 59 while(exp) 60 { 61 if(exp & 1) 62 result *= base; 63 exp >>= 1; 64 base *= base; 65 } 66 67 return result; 68 } 69 70 // standalone function to extract the i-th digit from a number (counting from 0 = rightmost, etc..) 71 int digit(int val, int i) 72 { 73 int y = ipow(10, i); 74 int z = val / y; 75 int val2 = val / (y * 10); 76 return (z - val2 * 10); 77 } 78 79 // return the first two digits if this is a "fundamental" particle 80 // ID = 100 is a special case (internal generator ID's are 81-100) 81 // also, 101 and 102 are now used (by HepPID) for geantinos 82 int fundamentalID(int pdgCode) 83 { 84 pdgCode = abs(pdgCode); 85 if((digit(pdgCode, 9) == 1) && (digit(pdgCode, 8) == 0)) 86 { 87 return 0; 88 } 89 if(digit(pdgCode, 2) == 0 && digit(pdgCode, 3) == 0) 90 { 91 return pdgCode % 10000; 92 } 93 else if(pdgCode <= 102) 94 { 95 return pdgCode; 96 } 97 else 98 { 99 return 0; 100 } 101 } 102 103 bool hasBottom(int pdgCode) 104 { 105 if((pdgCode / 10000000) > 0) 106 return false; 107 if(pdgCode <= 100) 108 return false; 109 if(fundamentalID(pdgCode) <= 100 && fundamentalID(pdgCode) > 0) 110 return false; 111 if(digit(pdgCode, 3) == 5 || digit(pdgCode, 2) == 5 || digit(pdgCode, 1) == 5) 112 return true; 113 return false; 114 } 115 116 bool isTauDaughter(int pdgCode, int M1, const TObjArray *fInputArray) 117 { 118 //not needed, just to speed up the code - can be further refined but gives only negligible improvement: 119 if(pdgCode == 15 || pdgCode < 11 || (pdgCode > 22 && pdgCode < 100) || pdgCode > 1000) 120 return false; 121 122 if(M1 < 0) 123 return false; 124 125 Candidate *mother; 126 mother = static_cast<Candidate *>(fInputArray->At(M1)); 127 if(TMath::Abs(mother->PID) == 15) 128 return true; 129 130 return false; 131 } 132 133 bool isWDaughter(int M1, const TObjArray *fInputArray) 134 { 135 if(M1 < 0) return false; 136 137 Candidate *mother; 138 mother = static_cast<Candidate *>(fInputArray->At(M1)); 139 if(TMath::Abs(mother->PID) == 24) return true; 140 141 return false; 142 } 143 144 } // namespace 136 145 137 146 //------------------------------------------------------------------------------ … … 183 192 184 193 fItInputArray->Reset(); 185 while((candidate = static_cast<Candidate *>(fItInputArray->Next())))194 while((candidate = static_cast<Candidate *>(fItInputArray->Next()))) 186 195 { 187 196 status = candidate->Status; … … 195 204 // hard scattering particles (first condition for Py6, second for Py8) 196 205 if(status == 3) pass = kTRUE; 197 if(status > 20 && status < 30 206 if(status > 20 && status < 30) pass = kTRUE; 198 207 199 208 // electrons, muons, taus and neutrinos … … 201 210 202 211 // heavy quarks 203 if(pdgCode == 4 || pdgCode == 5 || pdgCode == 6) pass = kTRUE;212 if(pdgCode == 4 || pdgCode == 5 || pdgCode == 6) pass = kTRUE; 204 213 205 214 // Gauge bosons and other fundamental bosons 206 215 if(pdgCode > 22 && pdgCode < 43) pass = kTRUE; 207 216 208 //Stable photons 209 if(pdgCode == 22 && status ==1) pass = kTRUE;217 //Stable photons 218 if(pdgCode == 22 && status == 1) pass = kTRUE; 210 219 211 220 // logic ported from HepPDF: http://lcgapp.cern.ch/project/simu/HepPDT/HepPDT.2.05.02/html/ParticleID_8cc-source.html#l00081 212 221 bool is_b_hadron = hasBottom(pdgCode); 213 bool is_b_quark 222 bool is_b_quark = (pdgCode == 5); 214 223 215 224 bool is_tau_daughter = isTauDaughter(pdgCode, candidate->M1, fInputArray); 216 225 217 if 226 if(is_b_hadron) 218 227 pass = kTRUE; 219 228 220 if 229 if(is_tau_daughter) 221 230 pass = kTRUE; 222 231 223 232 bool is_W_daughter = isWDaughter(candidate->M1, fInputArray); 224 if (is_W_daughter)233 if(is_W_daughter) 225 234 pass = kTRUE; 226 235 227 236 // fPTMin not applied to b_hadrons / b_quarks to allow for b-enriched sample stitching 228 237 // fPTMin not applied to tau decay products to allow visible-tau four momentum determination 229 if(!pass || (candidate->Momentum.Pt() < fPTMin && !(is_b_hadron || is_b_quark || is_tau_daughter || is_W_daughter)) 238 if(!pass || (candidate->Momentum.Pt() < fPTMin && !(is_b_hadron || is_b_quark || is_tau_daughter || is_W_daughter))) continue; 230 239 231 240 // not pileup particles 232 if(fRequireNotPileup && (candidate->IsPU > 0)) continue;241 if(fRequireNotPileup && (candidate->IsPU > 0)) continue; 233 242 234 243 fOutputArray->Add(candidate); 235 244 } 236 245 } 237
Note:
See TracChangeset
for help on using the changeset viewer.