[7538969] | 1 |
|
---|
| 2 | /** \class TrackCountingTauTagging
|
---|
| 3 | *
|
---|
| 4 | * Determines origin of jet,
|
---|
| 5 | * applies b-tagging efficiency (miss identification rate) formulas
|
---|
| 6 | * and sets b-tagging flags
|
---|
| 7 | *
|
---|
| 8 | * $Date: 2013-07-12 00:22:27 +0200 (Fri, 12 Jul 2013) $
|
---|
| 9 | * $Revision: 1217 $
|
---|
| 10 | *
|
---|
| 11 | *
|
---|
| 12 | * \author P. Demin - UCL, Louvain-la-Neuve
|
---|
| 13 | *
|
---|
| 14 | */
|
---|
| 15 |
|
---|
| 16 | #include "modules/TrackCountingTauTagging.h"
|
---|
| 17 |
|
---|
| 18 | #include "classes/DelphesClasses.h"
|
---|
| 19 | #include "classes/DelphesFactory.h"
|
---|
| 20 | #include "classes/DelphesFormula.h"
|
---|
| 21 |
|
---|
| 22 | #include "ExRootAnalysis/ExRootClassifier.h"
|
---|
[341014c] | 23 | #include "ExRootAnalysis/ExRootFilter.h"
|
---|
| 24 | #include "ExRootAnalysis/ExRootResult.h"
|
---|
[7538969] | 25 |
|
---|
| 26 | #include "TDatabasePDG.h"
|
---|
[341014c] | 27 | #include "TFormula.h"
|
---|
[7538969] | 28 | #include "TLorentzVector.h"
|
---|
[341014c] | 29 | #include "TMath.h"
|
---|
| 30 | #include "TObjArray.h"
|
---|
| 31 | #include "TRandom3.h"
|
---|
| 32 | #include "TString.h"
|
---|
[7538969] | 33 |
|
---|
| 34 | #include <algorithm>
|
---|
| 35 | #include <iostream>
|
---|
| 36 | #include <sstream>
|
---|
[341014c] | 37 | #include <stdexcept>
|
---|
[7538969] | 38 |
|
---|
| 39 | using namespace std;
|
---|
| 40 |
|
---|
| 41 | //------------------------------------------------------------------------------
|
---|
| 42 |
|
---|
| 43 | class TrackCountingTauTaggingPartonClassifier : public ExRootClassifier
|
---|
| 44 | {
|
---|
| 45 | public:
|
---|
| 46 | TrackCountingTauTaggingPartonClassifier(const TObjArray *array);
|
---|
| 47 |
|
---|
| 48 | Int_t GetCategory(TObject *object);
|
---|
| 49 |
|
---|
| 50 | Double_t fEtaMax, fPTMin;
|
---|
| 51 |
|
---|
| 52 | const TObjArray *fParticleInputArray;
|
---|
| 53 | };
|
---|
| 54 |
|
---|
| 55 | //------------------------------------------------------------------------------
|
---|
| 56 | TrackCountingTauTaggingPartonClassifier::TrackCountingTauTaggingPartonClassifier(const TObjArray *array) :
|
---|
| 57 | fParticleInputArray(array)
|
---|
| 58 | {
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | //------------------------------------------------------------------------------
|
---|
| 62 |
|
---|
| 63 | Int_t TrackCountingTauTaggingPartonClassifier::GetCategory(TObject *object)
|
---|
| 64 | {
|
---|
| 65 | Candidate *tau = static_cast<Candidate *>(object);
|
---|
| 66 | Candidate *daughter1 = 0;
|
---|
| 67 | Candidate *daughter2 = 0;
|
---|
[341014c] | 68 |
|
---|
[7538969] | 69 | const TLorentzVector &momentum = tau->Momentum;
|
---|
| 70 | Int_t pdgCode, i, j;
|
---|
| 71 |
|
---|
| 72 | pdgCode = TMath::Abs(tau->PID);
|
---|
| 73 | if(pdgCode != 15) return -1;
|
---|
| 74 |
|
---|
| 75 | if(momentum.Pt() <= fPTMin || TMath::Abs(momentum.Eta()) > fEtaMax) return -1;
|
---|
| 76 |
|
---|
| 77 | if(tau->D1 < 0) return -1;
|
---|
| 78 |
|
---|
| 79 | if(tau->D2 < tau->D1) return -1;
|
---|
| 80 |
|
---|
[341014c] | 81 | if(tau->D1 >= fParticleInputArray->GetEntriesFast() || tau->D2 >= fParticleInputArray->GetEntriesFast())
|
---|
[7538969] | 82 | {
|
---|
| 83 | throw runtime_error("tau's daughter index is greater than the ParticleInputArray size");
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | for(i = tau->D1; i <= tau->D2; ++i)
|
---|
| 87 | {
|
---|
| 88 | daughter1 = static_cast<Candidate *>(fParticleInputArray->At(i));
|
---|
| 89 | pdgCode = TMath::Abs(daughter1->PID);
|
---|
[341014c] | 90 | if(pdgCode == 11 || pdgCode == 13 || pdgCode == 15)
|
---|
| 91 | return -1;
|
---|
[7538969] | 92 | else if(pdgCode == 24)
|
---|
| 93 | {
|
---|
[341014c] | 94 | if(daughter1->D1 < 0) return -1;
|
---|
| 95 | for(j = daughter1->D1; j <= daughter1->D2; ++j)
|
---|
| 96 | {
|
---|
| 97 | daughter2 = static_cast<Candidate *>(fParticleInputArray->At(j));
|
---|
| 98 | pdgCode = TMath::Abs(daughter2->PID);
|
---|
| 99 | if(pdgCode == 11 || pdgCode == 13) return -1;
|
---|
| 100 | }
|
---|
[7538969] | 101 | }
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | return 0;
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | //------------------------------------------------------------------------------
|
---|
| 108 |
|
---|
| 109 | TrackCountingTauTagging::TrackCountingTauTagging() :
|
---|
| 110 | fClassifier(0), fFilter(0),
|
---|
| 111 | fItPartonInputArray(0), fItTrackInputArray(0), fItJetInputArray(0)
|
---|
| 112 | {
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | //------------------------------------------------------------------------------
|
---|
| 116 |
|
---|
| 117 | TrackCountingTauTagging::~TrackCountingTauTagging()
|
---|
| 118 | {
|
---|
| 119 | }
|
---|
| 120 |
|
---|
| 121 | //------------------------------------------------------------------------------
|
---|
| 122 |
|
---|
| 123 | void TrackCountingTauTagging::Init()
|
---|
| 124 | {
|
---|
[341014c] | 125 | map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
|
---|
[7538969] | 126 | ExRootConfParam param;
|
---|
| 127 | DelphesFormula *formula;
|
---|
| 128 | Int_t i, size;
|
---|
| 129 |
|
---|
[7e227ae] | 130 | fBitNumber = GetInt("BitNumber", 0);
|
---|
| 131 |
|
---|
[7538969] | 132 | fDeltaR = GetDouble("DeltaR", 0.5);
|
---|
| 133 | fDeltaRTrack = GetDouble("DeltaRTrack", 0.2);
|
---|
| 134 | fTrackPTMin = GetDouble("TrackPTMin", 1.0);
|
---|
[341014c] | 135 |
|
---|
[7538969] | 136 | // read efficiency formulas
|
---|
| 137 | param = GetParam("EfficiencyFormula");
|
---|
| 138 | size = param.GetSize();
|
---|
| 139 |
|
---|
| 140 | fEfficiencyMap.clear();
|
---|
[341014c] | 141 | for(i = 0; i < size / 2; ++i)
|
---|
[7538969] | 142 | {
|
---|
| 143 | formula = new DelphesFormula;
|
---|
[341014c] | 144 | formula->Compile(param[i * 2 + 1].GetString());
|
---|
[7538969] | 145 |
|
---|
[341014c] | 146 | fEfficiencyMap[param[i * 2].GetInt()] = formula;
|
---|
[7538969] | 147 | }
|
---|
| 148 |
|
---|
| 149 | // set default efficiency formula
|
---|
| 150 | itEfficiencyMap = fEfficiencyMap.find(0);
|
---|
| 151 | if(itEfficiencyMap == fEfficiencyMap.end())
|
---|
| 152 | {
|
---|
| 153 | formula = new DelphesFormula;
|
---|
| 154 | formula->Compile("0.0");
|
---|
| 155 |
|
---|
| 156 | fEfficiencyMap[0] = formula;
|
---|
| 157 | }
|
---|
| 158 |
|
---|
| 159 | // import input array(s)
|
---|
| 160 |
|
---|
| 161 | fParticleInputArray = ImportArray(GetString("ParticleInputArray", "Delphes/allParticles"));
|
---|
| 162 |
|
---|
| 163 | fClassifier = new TrackCountingTauTaggingPartonClassifier(fParticleInputArray);
|
---|
| 164 | fClassifier->fPTMin = GetDouble("TauPTMin", 1.0);
|
---|
| 165 | fClassifier->fEtaMax = GetDouble("TauEtaMax", 2.5);
|
---|
| 166 |
|
---|
| 167 | fPartonInputArray = ImportArray(GetString("PartonInputArray", "Delphes/partons"));
|
---|
| 168 | fItPartonInputArray = fPartonInputArray->MakeIterator();
|
---|
| 169 |
|
---|
| 170 | fTrackInputArray = ImportArray(GetString("TrackInputArray", "TrackMerger/tracks"));
|
---|
| 171 | fItTrackInputArray = fTrackInputArray->MakeIterator();
|
---|
[341014c] | 172 |
|
---|
[7538969] | 173 | fFilter = new ExRootFilter(fPartonInputArray);
|
---|
| 174 |
|
---|
| 175 | fJetInputArray = ImportArray(GetString("JetInputArray", "FastJetFinder/jets"));
|
---|
| 176 | fItJetInputArray = fJetInputArray->MakeIterator();
|
---|
| 177 | }
|
---|
| 178 |
|
---|
| 179 | //------------------------------------------------------------------------------
|
---|
| 180 |
|
---|
| 181 | void TrackCountingTauTagging::Finish()
|
---|
| 182 | {
|
---|
[341014c] | 183 | map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
|
---|
[7538969] | 184 | DelphesFormula *formula;
|
---|
| 185 |
|
---|
| 186 | if(fFilter) delete fFilter;
|
---|
| 187 | if(fClassifier) delete fClassifier;
|
---|
| 188 | if(fItJetInputArray) delete fItJetInputArray;
|
---|
| 189 | if(fItTrackInputArray) delete fItTrackInputArray;
|
---|
| 190 | if(fItPartonInputArray) delete fItPartonInputArray;
|
---|
| 191 |
|
---|
| 192 | for(itEfficiencyMap = fEfficiencyMap.begin(); itEfficiencyMap != fEfficiencyMap.end(); ++itEfficiencyMap)
|
---|
| 193 | {
|
---|
| 194 | formula = itEfficiencyMap->second;
|
---|
| 195 | if(formula) delete formula;
|
---|
| 196 | }
|
---|
| 197 | }
|
---|
| 198 |
|
---|
| 199 | //------------------------------------------------------------------------------
|
---|
| 200 |
|
---|
| 201 | void TrackCountingTauTagging::Process()
|
---|
| 202 | {
|
---|
| 203 | Candidate *jet, *tau, *track, *daughter;
|
---|
| 204 | TLorentzVector tauMomentum;
|
---|
[7e227ae] | 205 | Double_t pt, eta, phi, e;
|
---|
[7538969] | 206 | TObjArray *tauArray;
|
---|
[341014c] | 207 | map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
|
---|
[7538969] | 208 | DelphesFormula *formula;
|
---|
| 209 | Int_t pdgCode, charge, i, identifier;
|
---|
| 210 |
|
---|
| 211 | // select taus
|
---|
| 212 | fFilter->Reset();
|
---|
| 213 | tauArray = fFilter->GetSubArray(fClassifier, 0);
|
---|
| 214 |
|
---|
| 215 | if(tauArray == 0) return;
|
---|
| 216 |
|
---|
| 217 | TIter itTauArray(tauArray);
|
---|
| 218 |
|
---|
| 219 | // loop over all input jets
|
---|
| 220 | fItJetInputArray->Reset();
|
---|
| 221 | while((jet = static_cast<Candidate *>(fItJetInputArray->Next())))
|
---|
| 222 | {
|
---|
| 223 | identifier = 0;
|
---|
| 224 | const TLorentzVector &jetMomentum = jet->Momentum;
|
---|
| 225 | pdgCode = 0;
|
---|
| 226 | charge = 0;
|
---|
| 227 | eta = jetMomentum.Eta();
|
---|
| 228 | phi = jetMomentum.Phi();
|
---|
| 229 | pt = jetMomentum.Pt();
|
---|
[7e227ae] | 230 | e = jetMomentum.E();
|
---|
| 231 |
|
---|
[341014c] | 232 | // loop over all input tracks
|
---|
[7538969] | 233 | fItTrackInputArray->Reset();
|
---|
| 234 | while((track = static_cast<Candidate *>(fItTrackInputArray->Next())))
|
---|
| 235 | {
|
---|
[341014c] | 236 | if((track->Momentum).Pt() < fTrackPTMin) continue;
|
---|
| 237 | if(jetMomentum.DeltaR(track->Momentum) <= fDeltaRTrack)
|
---|
| 238 | {
|
---|
| 239 | identifier -= 1;
|
---|
| 240 | charge += track->Charge;
|
---|
| 241 | }
|
---|
[7538969] | 242 | }
|
---|
[341014c] | 243 |
|
---|
[7538969] | 244 | // loop over all input taus
|
---|
| 245 | itTauArray.Reset();
|
---|
| 246 | bool matchedTau = false;
|
---|
| 247 | while((tau = static_cast<Candidate *>(itTauArray.Next())))
|
---|
| 248 | {
|
---|
| 249 | if(tau->D1 < 0) continue;
|
---|
| 250 |
|
---|
[341014c] | 251 | if(tau->D1 >= fParticleInputArray->GetEntriesFast() || tau->D2 >= fParticleInputArray->GetEntriesFast())
|
---|
[7538969] | 252 | {
|
---|
| 253 | throw runtime_error("tau's daughter index is greater than the ParticleInputArray size");
|
---|
| 254 | }
|
---|
| 255 |
|
---|
| 256 | tauMomentum.SetPxPyPzE(0.0, 0.0, 0.0, 0.0);
|
---|
| 257 |
|
---|
| 258 | for(i = tau->D1; i <= tau->D2; ++i)
|
---|
| 259 | {
|
---|
| 260 | daughter = static_cast<Candidate *>(fParticleInputArray->At(i));
|
---|
| 261 | if(TMath::Abs(daughter->PID) == 16) continue;
|
---|
[341014c] | 262 | tauMomentum += daughter->Momentum;
|
---|
[7538969] | 263 | }
|
---|
| 264 |
|
---|
| 265 | if(jetMomentum.DeltaR(tauMomentum) <= fDeltaR)
|
---|
[341014c] | 266 | {
|
---|
[7538969] | 267 | matchedTau = true;
|
---|
| 268 | pdgCode = 15;
|
---|
| 269 | }
|
---|
| 270 | }
|
---|
| 271 | if(matchedTau)
|
---|
[341014c] | 272 | identifier *= -1;
|
---|
[7538969] | 273 | // find an efficency formula
|
---|
| 274 | // If the identifier is larger than 2, set it to 2 (multiprong requires at least 2 tracks)
|
---|
[341014c] | 275 | if(identifier > 2)
|
---|
| 276 | identifier = 2;
|
---|
| 277 | else if(identifier < -2)
|
---|
| 278 | identifier = -2;
|
---|
[7538969] | 279 |
|
---|
| 280 | itEfficiencyMap = fEfficiencyMap.find(identifier);
|
---|
| 281 | if(itEfficiencyMap == fEfficiencyMap.end())
|
---|
| 282 | {
|
---|
| 283 | itEfficiencyMap = fEfficiencyMap.find(0);
|
---|
| 284 | }
|
---|
| 285 | formula = itEfficiencyMap->second;
|
---|
| 286 |
|
---|
| 287 | // apply an efficency formula
|
---|
| 288 |
|
---|
| 289 | // apply an efficency formula
|
---|
[7e227ae] | 290 | jet->TauTag |= (gRandom->Uniform() <= formula->Eval(pt, eta, phi, e)) << fBitNumber;
|
---|
[341014c] | 291 |
|
---|
[7538969] | 292 | // set tau charge
|
---|
| 293 | jet->Charge = charge;
|
---|
| 294 | }
|
---|
| 295 | }
|
---|
| 296 |
|
---|
| 297 | //------------------------------------------------------------------------------
|
---|