File indexing completed on 2025-01-18 10:06:38
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef Pythia8_JetMatching_H
0019 #define Pythia8_JetMatching_H
0020
0021
0022 #include "Pythia8/Pythia.h"
0023 #include "Pythia8Plugins/GeneratorInput.h"
0024
0025 namespace Pythia8 {
0026
0027
0028
0029 class HJSlowJet: public SlowJet {
0030
0031 public:
0032
0033 HJSlowJet(int powerIn, double Rin, double pTjetMinIn = 0.,
0034 double etaMaxIn = 25., int selectIn = 1, int massSetIn = 2,
0035 SlowJetHook* sjHookPtrIn = 0, bool useFJcoreIn = false,
0036 bool useStandardRin = true) :
0037 SlowJet(powerIn, Rin, pTjetMinIn, etaMaxIn, selectIn, massSetIn,
0038 sjHookPtrIn, useFJcoreIn, useStandardRin) {}
0039
0040
0041
0042
0043
0044 void findNext();
0045
0046 };
0047
0048
0049
0050
0051
0052 void HJSlowJet::findNext() {
0053
0054
0055 if (clSize > 0) {
0056 iMin = 0;
0057 jMin = -1;
0058 dMin = 1.0/TINY;
0059
0060 for (int i = 1; i < clSize; ++i) {
0061 for (int j = 0; j < i; ++j) {
0062 if (dij[i*(i-1)/2 + j] < dMin) {
0063 iMin = i;
0064 jMin = j;
0065 dMin = dij[i*(i-1)/2 + j];
0066 }
0067 }
0068 }
0069
0070
0071 } else {
0072 iMin = -1;
0073 jMin = -1;
0074 dMin = 0.;
0075 }
0076
0077 }
0078
0079
0080
0081
0082
0083
0084
0085 class JetMatching : virtual public UserHooks {
0086
0087 public:
0088
0089
0090 JetMatching() : cellJet(nullptr), slowJet(nullptr), slowJetHard(nullptr),
0091 hjSlowJet(nullptr) {}
0092 ~JetMatching() {
0093 if (cellJet) delete cellJet;
0094 if (slowJet) delete slowJet;
0095 if (slowJetHard) delete slowJetHard;
0096 if (hjSlowJet) delete hjSlowJet;
0097
0098
0099
0100 cout << "\n *------- JetMatching Error and Warning Messages Statistics"
0101 << " -----------------------------------------------------* \n"
0102 << " | "
0103 << " | \n"
0104 << " | times message "
0105 << " | \n"
0106 << " | "
0107 << " | \n";
0108
0109
0110 map<string, int>::iterator messageEntry = messages.begin();
0111 if (messageEntry == messages.end())
0112 cout << " | 0 no errors or warnings to report "
0113 << " | \n";
0114 while (messageEntry != messages.end()) {
0115
0116 string temp = messageEntry->first;
0117 int len = temp.length();
0118 temp.insert( len, max(0, 102 - len), ' ');
0119 cout << " | " << setw(6) << messageEntry->second << " "
0120 << temp << " | \n";
0121 ++messageEntry;
0122 }
0123
0124
0125 cout << " | "
0126 << " | \n"
0127 << " *------- End JetMatching Error and Warning Messages "
0128 << "Statistics -------------------------------------------------* "
0129 << endl;
0130 }
0131
0132
0133 virtual bool initAfterBeams() = 0;
0134
0135
0136 bool canVetoProcessLevel() { return doMerge; }
0137 bool doVetoProcessLevel(Event& process) {
0138 eventProcessOrig = process;
0139 return false;
0140 }
0141
0142
0143 bool canVetoPartonLevelEarly() { return doMerge; }
0144 bool doVetoPartonLevelEarly(const Event& event);
0145
0146
0147 int numberVetoStep() {return 1;}
0148 bool canVetoStep() { return false; }
0149 bool doVetoStep(int, int, int, const Event& ) { return false; }
0150
0151
0152
0153
0154
0155
0156 virtual void sortIncomingProcess(const Event &)=0;
0157 virtual void jetAlgorithmInput(const Event &, int)=0;
0158 virtual void runJetAlgorithm()=0;
0159 virtual bool matchPartonsToJets(int)=0;
0160 virtual int matchPartonsToJetsLight()=0;
0161 virtual int matchPartonsToJetsHeavy()=0;
0162
0163
0164 void errorMsg(string messageIn) {
0165
0166 int times = messages[messageIn];
0167 ++messages[messageIn];
0168
0169 if (times < TIMESTOPRINT) cout << " PYTHIA " << messageIn << endl;
0170 }
0171
0172 protected:
0173
0174
0175 static const bool MATCHINGDEBUG, MATCHINGCHECK;
0176
0177 enum vetoStatus { NONE, LESS_JETS, MORE_JETS, HARD_JET,
0178 UNMATCHED_PARTON, INCLUSIVE_VETO };
0179 enum partonTypes { ID_CHARM=4, ID_BOT=5, ID_TOP=6, ID_LEPMIN=11,
0180 ID_LEPMAX=16, ID_GLUON=21, ID_PHOTON=22 };
0181
0182
0183 bool doMerge;
0184
0185
0186 bool doShowerKt;
0187
0188
0189 int nJetMax, nJet;
0190
0191
0192 int jetAlgorithm;
0193 double eTjetMin, coneRadius, etaJetMax, etaJetMaxAlgo;
0194
0195
0196 CellJet* cellJet;
0197 SlowJet* slowJet;
0198 SlowJet* slowJetHard;
0199 HJSlowJet* hjSlowJet;
0200
0201
0202 int slowJetPower;
0203
0204
0205
0206
0207
0208 Event eventProcessOrig, eventProcess, workEventJet;
0209
0210
0211 vector<int> typeIdx[3];
0212 set<int> typeSet[3];
0213
0214
0215
0216 vector<Vec4> jetMomenta;
0217
0218
0219 int nEta, nPhi;
0220 double eTseed, eTthreshold;
0221
0222
0223 int jetAllow, jetMatch, exclusiveMode;
0224 double coneMatchLight, coneRadiusHeavy, coneMatchHeavy;
0225 bool exclusive;
0226
0227
0228 double eTpTlightMin;
0229
0230
0231 map<string, int> messages;
0232
0233 static const int TIMESTOPRINT = 1;
0234
0235 };
0236
0237
0238
0239
0240
0241 class JetMatchingAlpgen : virtual public JetMatching {
0242
0243 public:
0244
0245
0246 JetMatchingAlpgen() { }
0247 ~JetMatchingAlpgen() { }
0248
0249
0250 bool initAfterBeams();
0251
0252 private:
0253
0254
0255 void sortIncomingProcess(const Event &);
0256 void jetAlgorithmInput(const Event &, int);
0257 void runJetAlgorithm();
0258 bool matchPartonsToJets(int);
0259 int matchPartonsToJetsLight();
0260 int matchPartonsToJetsHeavy();
0261
0262
0263 void sortTypeIdx(vector < int > &vecIn);
0264
0265
0266 static const double GHOSTENERGY, ZEROTHRESHOLD;
0267
0268 };
0269
0270
0271
0272
0273
0274 class JetMatchingMadgraph : virtual public JetMatching {
0275
0276 public:
0277
0278
0279 JetMatchingMadgraph() : slowJetDJR(nullptr) { }
0280 ~JetMatchingMadgraph() { if (slowJetDJR) delete slowJetDJR; }
0281
0282
0283 bool initAfterBeams();
0284
0285
0286 bool canVetoProcessLevel() { return doMerge; }
0287 bool doVetoProcessLevel(Event& process);
0288
0289
0290 int numberVetoStep() {return 1;}
0291 bool canVetoStep() { return doShowerKt; }
0292 bool doVetoStep(int, int, int, const Event& );
0293
0294
0295
0296 SlowJet* slowJetDJR;
0297
0298
0299 vector<double> getDJR() { return DJR;}
0300 pair<int,int> nMEpartons() { return nMEpartonsSave;}
0301
0302
0303
0304
0305
0306 Event getWorkEventJet() { return workEventJetSave; }
0307 Event getProcessSubset() { return processSubsetSave; }
0308 bool getExclusive() { return exclusive; }
0309 double getPTfirst() { return pTfirstSave; }
0310
0311
0312
0313
0314
0315
0316 void sortIncomingProcess(const Event &);
0317 void jetAlgorithmInput(const Event &, int);
0318 void runJetAlgorithm();
0319 bool matchPartonsToJets(int);
0320 int matchPartonsToJetsLight();
0321 int matchPartonsToJetsHeavy();
0322 int matchPartonsToJetsOther();
0323 bool doShowerKtVeto(double pTfirst);
0324
0325
0326 void clearDJR() { DJR.resize(0);}
0327 void setDJR( const Event& event);
0328
0329 void clear_nMEpartons() { nMEpartonsSave.first = nMEpartonsSave.second =-1;}
0330 void set_nMEpartons( const int nOrig, const int nMatch) {
0331 clear_nMEpartons();
0332 nMEpartonsSave.first = nOrig;
0333 nMEpartonsSave.second = nMatch;
0334 };
0335
0336
0337
0338 int npNLO();
0339
0340 private:
0341
0342
0343
0344 Event processSubsetSave;
0345 Event workEventJetSave;
0346 double pTfirstSave;
0347
0348
0349
0350 bool performVeto;
0351
0352
0353 vector<int> origTypeIdx[3];
0354 int nQmatch;
0355 double qCut, qCutSq, clFact;
0356 bool doFxFx;
0357 int nPartonsNow;
0358 double qCutME, qCutMESq;
0359
0360
0361 vector<double> DJR;
0362
0363
0364 pair<int,int> nMEpartonsSave;
0365
0366 };
0367
0368
0369
0370
0371
0372
0373
0374
0375
0376
0377 const bool JetMatching::MATCHINGDEBUG = false;
0378 const bool JetMatching::MATCHINGCHECK = false;
0379
0380
0381
0382
0383
0384 inline bool JetMatching::doVetoPartonLevelEarly(const Event& event) {
0385
0386
0387
0388
0389
0390
0391
0392
0393
0394
0395
0396 sortIncomingProcess(event);
0397
0398
0399
0400 if ( doShowerKt ) return false;
0401
0402
0403 if (MATCHINGDEBUG) {
0404
0405 cout << endl << "-------- Begin Madgraph Debug --------" << endl;
0406
0407 cout << endl << "Original incoming process:";
0408 eventProcessOrig.list();
0409
0410 cout << endl << "Final-state incoming process:";
0411 eventProcess.list();
0412
0413 for (size_t i = 0; i < typeIdx[0].size(); i++)
0414 cout << ((i == 0) ? "Light jets: " : ", ") << setw(3) << typeIdx[0][i];
0415 if( typeIdx[0].size()== 0 )
0416 cout << "Light jets: None";
0417
0418 for (size_t i = 0; i < typeIdx[1].size(); i++)
0419 cout << ((i == 0) ? "\nHeavy jets: " : ", ") << setw(3) << typeIdx[1][i];
0420 for (size_t i = 0; i < typeIdx[2].size(); i++)
0421 cout << ((i == 0) ? "\nOther: " : ", ") << setw(3) << typeIdx[2][i];
0422
0423 cout << endl << endl << "Event:";
0424 event.list();
0425
0426 cout << endl << "Work event:";
0427 workEvent.list();
0428 }
0429
0430
0431 int iTypeEnd = (typeIdx[2].empty()) ? 2 : 3;
0432 for (int iType = 0; iType < iTypeEnd; iType++) {
0433
0434
0435
0436 jetAlgorithmInput(event, iType);
0437
0438
0439 if (MATCHINGDEBUG) {
0440
0441 cout << endl << "Jet algorithm event (iType = " << iType << "):";
0442 workEventJet.list();
0443 }
0444
0445
0446
0447 runJetAlgorithm();
0448
0449
0450 if (matchPartonsToJets(iType) == true) {
0451
0452 if (MATCHINGDEBUG) {
0453 cout << endl << "Event vetoed" << endl
0454 << "---------- End MLM Debug ----------" << endl;
0455 }
0456 return true;
0457 }
0458 }
0459
0460
0461 if (MATCHINGDEBUG) {
0462 cout << endl << "Event accepted" << endl
0463 << "---------- End MLM Debug ----------" << endl;
0464 }
0465
0466
0467 return false;
0468
0469 }
0470
0471
0472
0473
0474
0475
0476
0477
0478
0479
0480
0481
0482
0483
0484 const double JetMatchingAlpgen::GHOSTENERGY = 1e-15;
0485
0486
0487 const double JetMatchingAlpgen::ZEROTHRESHOLD = 1e-10;
0488
0489
0490
0491
0492
0493
0494
0495 inline void JetMatchingAlpgen::sortTypeIdx(vector < int > &vecIn) {
0496 for (size_t i = 0; i < vecIn.size(); i++) {
0497 size_t jMax = i;
0498 double vMax = (jetAlgorithm == 1) ?
0499 eventProcess[vecIn[i]].eT() :
0500 eventProcess[vecIn[i]].pT();
0501 for (size_t j = i + 1; j < vecIn.size(); j++) {
0502 double vNow = (jetAlgorithm == 1)
0503 ? eventProcess[vecIn[j]].eT() : eventProcess[vecIn[j]].pT();
0504 if (vNow > vMax) {
0505 vMax = vNow;
0506 jMax = j;
0507 }
0508 }
0509 if (jMax != i) swap(vecIn[i], vecIn[jMax]);
0510 }
0511 }
0512
0513
0514
0515
0516
0517
0518 inline bool JetMatchingAlpgen::initAfterBeams() {
0519
0520
0521 doMerge = settingsPtr->flag("JetMatching:merge");
0522 jetAlgorithm = settingsPtr->mode("JetMatching:jetAlgorithm");
0523 nJet = settingsPtr->mode("JetMatching:nJet");
0524 nJetMax = settingsPtr->mode("JetMatching:nJetMax");
0525 eTjetMin = settingsPtr->parm("JetMatching:eTjetMin");
0526 coneRadius = settingsPtr->parm("JetMatching:coneRadius");
0527 etaJetMax = settingsPtr->parm("JetMatching:etaJetMax");
0528 doShowerKt = settingsPtr->flag("JetMatching:doShowerKt");
0529
0530
0531 etaJetMaxAlgo = etaJetMax + coneRadius;
0532
0533
0534 nEta = settingsPtr->mode("JetMatching:nEta");
0535 nPhi = settingsPtr->mode("JetMatching:nPhi");
0536 eTseed = settingsPtr->parm("JetMatching:eTseed");
0537 eTthreshold = settingsPtr->parm("JetMatching:eTthreshold");
0538
0539
0540 slowJetPower = settingsPtr->mode("JetMatching:slowJetPower");
0541 coneMatchLight = settingsPtr->parm("JetMatching:coneMatchLight");
0542 coneRadiusHeavy = settingsPtr->parm("JetMatching:coneRadiusHeavy");
0543 if (coneRadiusHeavy < 0.) coneRadiusHeavy = coneRadius;
0544 coneMatchHeavy = settingsPtr->parm("JetMatching:coneMatchHeavy");
0545
0546
0547 jetAllow = settingsPtr->mode("JetMatching:jetAllow");
0548 jetMatch = settingsPtr->mode("JetMatching:jetMatch");
0549 exclusiveMode = settingsPtr->mode("JetMatching:exclusive");
0550
0551
0552 if (!doMerge) return true;
0553
0554
0555 if (exclusiveMode == 2) {
0556
0557
0558 if (nJet < 0 || nJetMax < 0) {
0559 errorMsg("Warning in JetMatchingAlpgen:init: "
0560 "missing jet multiplicity information; running in exclusive mode");
0561 exclusive = true;
0562
0563
0564 } else {
0565 exclusive = (nJet == nJetMax) ? false : true;
0566 }
0567
0568
0569 } else {
0570 exclusive = (exclusiveMode == 0) ? false : true;
0571 }
0572
0573
0574 if (jetAlgorithm == 1) {
0575
0576
0577
0578
0579 int nSel = 2, smear = 0;
0580 double resolution = 0.5, upperCut = 2.;
0581 cellJet = new CellJet(etaJetMaxAlgo, nEta, nPhi, nSel,
0582 smear, resolution, upperCut, eTthreshold);
0583
0584
0585 } else if (jetAlgorithm == 2) {
0586 slowJet = new SlowJet(slowJetPower, coneRadius, eTjetMin, etaJetMaxAlgo);
0587 }
0588
0589
0590 if (jetAlgorithm == 1 && jetMatch == 2) {
0591 errorMsg("Warning in JetMatchingAlpgen:init: "
0592 "jetMatch = 2 only valid with SlowJet algorithm. "
0593 "Reverting to jetMatch = 1");
0594 jetMatch = 1;
0595 }
0596
0597
0598 eventProcessOrig.init("(eventProcessOrig)", particleDataPtr);
0599 eventProcess.init("(eventProcess)", particleDataPtr);
0600 workEventJet.init("(workEventJet)", particleDataPtr);
0601
0602
0603 string jetStr = (jetAlgorithm == 1) ? "CellJet" :
0604 (slowJetPower == -1) ? "anti-kT" :
0605 (slowJetPower == 0) ? "C/A" :
0606 (slowJetPower == 1) ? "kT" : "unknown";
0607 string modeStr = (exclusive) ? "exclusive" : "inclusive";
0608 stringstream nJetStr, nJetMaxStr;
0609 if (nJet >= 0) nJetStr << nJet; else nJetStr << "unknown";
0610 if (nJetMax >= 0) nJetMaxStr << nJetMax; else nJetMaxStr << "unknown";
0611 cout << endl
0612 << " *------- MLM matching parameters -------*" << endl
0613 << " | nJet | " << setw(14)
0614 << nJetStr.str() << " |" << endl
0615 << " | nJetMax | " << setw(14)
0616 << nJetMaxStr.str() << " |" << endl
0617 << " | Jet algorithm | " << setw(14)
0618 << jetStr << " |" << endl
0619 << " | eTjetMin | " << setw(14)
0620 << eTjetMin << " |" << endl
0621 << " | coneRadius | " << setw(14)
0622 << coneRadius << " |" << endl
0623 << " | etaJetMax | " << setw(14)
0624 << etaJetMax << " |" << endl
0625 << " | jetAllow | " << setw(14)
0626 << jetAllow << " |" << endl
0627 << " | jetMatch | " << setw(14)
0628 << jetMatch << " |" << endl
0629 << " | coneMatchLight | " << setw(14)
0630 << coneMatchLight << " |" << endl
0631 << " | coneRadiusHeavy | " << setw(14)
0632 << coneRadiusHeavy << " |" << endl
0633 << " | coneMatchHeavy | " << setw(14)
0634 << coneMatchHeavy << " |" << endl
0635 << " | Mode | " << setw(14)
0636 << modeStr << " |" << endl
0637 << " *-----------------------------------------*" << endl;
0638
0639 return true;
0640 }
0641
0642
0643
0644
0645
0646 inline void JetMatchingAlpgen::sortIncomingProcess(const Event &event) {
0647
0648
0649
0650 omitResonanceDecays(eventProcessOrig, true);
0651 eventProcess = workEvent;
0652
0653
0654
0655
0656
0657
0658
0659
0660
0661
0662 for (int i = 0; i < 3; i++) {
0663 typeIdx[i].clear();
0664 typeSet[i].clear();
0665 }
0666 for (int i = 0; i < eventProcess.size(); i++) {
0667
0668 if (!eventProcess[i].isFinal()) continue;
0669 int idx = 2;
0670
0671
0672 if (eventProcess[i].id() == ID_GLUON
0673 || (eventProcess[i].idAbs() <= ID_BOT
0674 && abs(eventProcess[i].m()) < ZEROTHRESHOLD)) idx = 0;
0675
0676
0677 else if (eventProcess[i].idAbs() >= ID_CHARM
0678 && eventProcess[i].idAbs() <= ID_TOP) idx = 1;
0679
0680
0681 typeIdx[idx].push_back(i);
0682 typeSet[idx].insert(eventProcess[i].daughter1());
0683 }
0684
0685
0686
0687 subEvent(event);
0688 }
0689
0690
0691
0692
0693
0694 inline void JetMatchingAlpgen::jetAlgorithmInput(const Event &event,
0695 int iType) {
0696
0697
0698 workEventJet = workEvent;
0699
0700
0701 for (int i = 0; i < workEventJet.size(); ++i) {
0702 if (!workEventJet[i].isFinal()) continue;
0703
0704
0705 if (jetAllow == 1) {
0706
0707
0708
0709 int id = workEventJet[i].idAbs();
0710 if ( (id >= ID_LEPMIN && id <= ID_LEPMAX) || id == ID_TOP
0711 || id == ID_PHOTON) {
0712 workEventJet[i].statusNeg();
0713 continue;
0714 }
0715 }
0716
0717
0718 int idx = workEventJet[i].daughter1();
0719
0720
0721 while (true) {
0722
0723
0724 if (iType == 0) {
0725
0726
0727 if (typeSet[1].find(idx) != typeSet[1].end() ||
0728 typeSet[2].find(idx) != typeSet[2].end()) {
0729 workEventJet[i].statusNeg();
0730 break;
0731 }
0732
0733
0734 if (idx == 0) break;
0735
0736 idx = event[idx].mother1();
0737
0738
0739 } else if (iType == 1) {
0740
0741
0742 if (typeSet[1].find(idx) != typeSet[1].end()) break;
0743
0744
0745
0746 if (idx == 0) {
0747 workEventJet[i].statusNeg();
0748 break;
0749 }
0750
0751
0752 idx = event[idx].mother1();
0753
0754
0755 } else if (iType == 2) {
0756
0757
0758 if (typeSet[2].find(idx) != typeSet[2].end()) break;
0759
0760
0761
0762 if (idx == 0) {
0763 workEventJet[i].statusNeg();
0764 break;
0765 }
0766
0767
0768 idx = event[idx].mother1();
0769
0770 }
0771 }
0772 }
0773
0774
0775
0776 if (jetMatch == 2) {
0777 for (int i = 0; i < int(typeIdx[iType].size()); i++) {
0778
0779 Vec4 pIn = eventProcess[typeIdx[iType][i]].p();
0780 double y = pIn.rap();
0781 double phi = pIn.phi();
0782
0783
0784 double e = GHOSTENERGY;
0785 double e2y = exp(2. * y);
0786 double pz = e * (e2y - 1.) / (e2y + 1.);
0787 double pt = sqrt(e*e - pz*pz);
0788 double px = pt * cos(phi);
0789 double py = pt * sin(phi);
0790 workEventJet.append( ID_GLUON, 99, 0, 0, 0, 0, 0, 0, px, py, pz, e);
0791
0792
0793
0794 if (MATCHINGCHECK) {
0795 int lastIdx = workEventJet.size() - 1;
0796 if (abs(y - workEventJet[lastIdx].y()) > ZEROTHRESHOLD ||
0797 abs(phi - workEventJet[lastIdx].phi()) > ZEROTHRESHOLD)
0798 errorMsg("Warning in JetMatchingAlpgen:jetAlgorithmInput: "
0799 "ghost particle y/phi mismatch");
0800 }
0801
0802 }
0803 }
0804 }
0805
0806
0807
0808
0809
0810 inline void JetMatchingAlpgen::runJetAlgorithm() {
0811
0812
0813 if (jetAlgorithm == 1)
0814 cellJet->analyze(workEventJet, eTjetMin, coneRadius, eTseed);
0815 else
0816 slowJet->analyze(workEventJet);
0817
0818
0819
0820
0821 jetMomenta.clear();
0822 int iJet = (jetAlgorithm == 1) ? cellJet->size() - 1:
0823 slowJet->sizeJet() - 1;
0824 for (int i = iJet; i > -1; i--) {
0825 Vec4 jetMom = (jetAlgorithm == 1) ? cellJet->pMassive(i) :
0826 slowJet->p(i);
0827 double eta = jetMom.eta();
0828
0829 if (abs(eta) > etaJetMax) {
0830 if (jetAlgorithm == 2) slowJet->removeJet(i);
0831 continue;
0832 }
0833 jetMomenta.push_back(jetMom);
0834 }
0835
0836
0837 reverse(jetMomenta.begin(), jetMomenta.end());
0838 }
0839
0840
0841
0842
0843
0844 inline bool JetMatchingAlpgen::matchPartonsToJets(int iType) {
0845
0846
0847
0848 if (iType == 0) return (matchPartonsToJetsLight() > 0);
0849 else if (iType == 1) return (matchPartonsToJetsHeavy() > 0);
0850 else if (iType == 2) return false;
0851 return true;
0852 }
0853
0854
0855
0856
0857
0858
0859
0860
0861
0862
0863
0864
0865
0866
0867 inline int JetMatchingAlpgen::matchPartonsToJetsLight() {
0868
0869
0870 if (jetMomenta.size() < typeIdx[0].size()) return LESS_JETS;
0871
0872 if (exclusive && jetMomenta.size() > typeIdx[0].size()) return MORE_JETS;
0873
0874
0875 sortTypeIdx(typeIdx[0]);
0876
0877
0878 int nParton = typeIdx[0].size();
0879
0880
0881 vector < bool > jetAssigned;
0882 jetAssigned.assign(jetMomenta.size(), false);
0883
0884
0885 if (jetMatch == 1) {
0886
0887
0888 for (int i = 0; i < nParton; i++) {
0889 Vec4 p1 = eventProcess[typeIdx[0][i]].p();
0890
0891
0892 int jMin = -1;
0893 double dRmin = 0.;
0894
0895
0896 for (int j = 0; j < int(jetMomenta.size()); j++) {
0897 if (jetAssigned[j]) continue;
0898
0899
0900 double dR = (jetAlgorithm == 1)
0901 ? REtaPhi(p1, jetMomenta[j]) : RRapPhi(p1, jetMomenta[j]);
0902 if (jMin < 0 || dR < dRmin) {
0903 dRmin = dR;
0904 jMin = j;
0905 }
0906 }
0907
0908
0909 if (jMin >= 0 && dRmin < coneRadius * coneMatchLight) {
0910
0911
0912
0913
0914 if (jMin >= nParton) return HARD_JET;
0915
0916
0917 jetAssigned[jMin] = true;
0918
0919
0920 } else return UNMATCHED_PARTON;
0921
0922 }
0923
0924
0925 } else {
0926
0927
0928 for (int i = workEventJet.size() - nParton;
0929 i < workEventJet.size(); i++) {
0930 int jMin = slowJet->jetAssignment(i);
0931
0932
0933
0934
0935
0936 if (jMin >= nParton) return HARD_JET;
0937 if (jMin < 0 || jetAssigned[jMin]) return UNMATCHED_PARTON;
0938
0939
0940 jetAssigned[jMin] = true;
0941
0942 }
0943 }
0944
0945
0946
0947 if (nParton > 0)
0948 eTpTlightMin = (jetAlgorithm == 1) ? jetMomenta[nParton - 1].eT()
0949 : jetMomenta[nParton - 1].pT();
0950 else
0951 eTpTlightMin = -1.;
0952
0953
0954 return NONE;
0955 }
0956
0957
0958
0959
0960
0961
0962
0963
0964
0965
0966
0967 inline int JetMatchingAlpgen::matchPartonsToJetsHeavy() {
0968
0969
0970 if (jetMomenta.empty()) return NONE;
0971
0972
0973 int nParton = typeIdx[1].size();
0974
0975
0976 set < int > removeJets;
0977
0978
0979 if (jetMatch == 1) {
0980
0981
0982 for (int i = 0; i < nParton; i++) {
0983 Vec4 p1 = eventProcess[typeIdx[1][i]].p();
0984
0985
0986 for (int j = 0; j < int(jetMomenta.size()); j++) {
0987 double dR = (jetAlgorithm == 1) ?
0988 REtaPhi(p1, jetMomenta[j]) : RRapPhi(p1, jetMomenta[j]);
0989 if (dR < coneRadiusHeavy * coneMatchHeavy)
0990 removeJets.insert(j);
0991
0992 }
0993 }
0994
0995
0996 } else {
0997
0998
0999
1000 for (int i = workEventJet.size() - nParton;
1001 i < workEventJet.size(); i++) {
1002 int jMin = slowJet->jetAssignment(i);
1003 if (jMin >= 0) removeJets.insert(jMin);
1004 }
1005
1006 }
1007
1008
1009 for (set < int >::reverse_iterator it = removeJets.rbegin();
1010 it != removeJets.rend(); it++)
1011 jetMomenta.erase(jetMomenta.begin() + *it);
1012
1013
1014 if (!jetMomenta.empty()) {
1015
1016
1017 if (exclusive) return MORE_JETS;
1018
1019
1020 else if (eTpTlightMin >= 0.)
1021 for (size_t j = 0; j < jetMomenta.size(); j++) {
1022
1023 if ( (jetAlgorithm == 1 && jetMomenta[j].eT() > eTpTlightMin) ||
1024 (jetAlgorithm == 2 && jetMomenta[j].pT() > eTpTlightMin) )
1025 return HARD_JET;
1026 }
1027
1028 }
1029
1030
1031 return NONE;
1032 }
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045 inline bool JetMatchingMadgraph::initAfterBeams() {
1046
1047
1048 pTfirstSave = -1.;
1049 processSubsetSave.init("(eventProcess)", particleDataPtr);
1050 workEventJetSave.init("(workEventJet)", particleDataPtr);
1051
1052
1053 bool setMad = settingsPtr->flag("JetMatching:setMad");
1054
1055
1056 MadgraphPar par;
1057 string parStr = infoPtr->header("MGRunCard");
1058 if (!parStr.empty()) {
1059 par.parse(parStr);
1060 par.printParams();
1061 }
1062
1063
1064 if (setMad) {
1065 if ( par.haveParam("xqcut") && par.haveParam("maxjetflavor")
1066 && par.haveParam("alpsfact") && par.haveParam("ickkw") ) {
1067 settingsPtr->flag("JetMatching:merge", par.getParam("ickkw"));
1068 settingsPtr->parm("JetMatching:qCut", par.getParam("xqcut"));
1069 settingsPtr->mode("JetMatching:nQmatch",
1070 par.getParamAsInt("maxjetflavor"));
1071 settingsPtr->parm("JetMatching:clFact",
1072 clFact = par.getParam("alpsfact"));
1073 if (par.getParamAsInt("ickkw") == 0)
1074 errorMsg("Error in JetMatchingMadgraph:init: "
1075 "Madgraph file parameters are not set for merging");
1076
1077
1078 } else {
1079 errorMsg("Warning in JetMatchingMadgraph:init: "
1080 "Madgraph merging parameters not found");
1081 if (!par.haveParam("xqcut")) errorMsg("Warning in "
1082 "JetMatchingMadgraph:init: No xqcut");
1083 if (!par.haveParam("ickkw")) errorMsg("Warning in "
1084 "JetMatchingMadgraph:init: No ickkw");
1085 if (!par.haveParam("maxjetflavor")) errorMsg("Warning in "
1086 "JetMatchingMadgraph:init: No maxjetflavor");
1087 if (!par.haveParam("alpsfact")) errorMsg("Warning in "
1088 "JetMatchingMadgraph:init: No alpsfact");
1089 }
1090 }
1091
1092
1093 doFxFx = settingsPtr->flag("JetMatching:doFxFx");
1094 nPartonsNow = settingsPtr->mode("JetMatching:nPartonsNow");
1095 qCutME = settingsPtr->parm("JetMatching:qCutME");
1096 qCutMESq = pow(qCutME,2);
1097
1098
1099 doMerge = settingsPtr->flag("JetMatching:merge");
1100 doShowerKt = settingsPtr->flag("JetMatching:doShowerKt");
1101 qCut = settingsPtr->parm("JetMatching:qCut");
1102 nQmatch = settingsPtr->mode("JetMatching:nQmatch");
1103 clFact = settingsPtr->parm("JetMatching:clFact");
1104
1105
1106 jetAlgorithm = settingsPtr->mode("JetMatching:jetAlgorithm");
1107 nJetMax = settingsPtr->mode("JetMatching:nJetMax");
1108 eTjetMin = settingsPtr->parm("JetMatching:eTjetMin");
1109 coneRadius = settingsPtr->parm("JetMatching:coneRadius");
1110 etaJetMax = settingsPtr->parm("JetMatching:etaJetMax");
1111 slowJetPower = settingsPtr->mode("JetMatching:slowJetPower");
1112
1113
1114 jetAllow = settingsPtr->mode("JetMatching:jetAllow");
1115 exclusiveMode = settingsPtr->mode("JetMatching:exclusive");
1116 qCutSq = pow(qCut,2);
1117 etaJetMaxAlgo = etaJetMax;
1118
1119
1120 performVeto = settingsPtr->flag("JetMatching:doVeto");
1121
1122
1123 if (!doMerge) return true;
1124
1125
1126 if (exclusiveMode == 2) {
1127
1128
1129 if (nJetMax < 0) {
1130 errorMsg("Warning in JetMatchingMadgraph:init: "
1131 "missing jet multiplicity information; running in exclusive mode");
1132 exclusiveMode = 1;
1133 }
1134 }
1135
1136
1137
1138
1139 jetAlgorithm = 2;
1140 slowJetPower = 1;
1141 slowJet = new SlowJet(slowJetPower, coneRadius, eTjetMin,
1142 etaJetMaxAlgo, 2, 2, nullptr, false);
1143
1144
1145
1146
1147 slowJetHard = new SlowJet(slowJetPower, coneRadius, qCutME,
1148 etaJetMaxAlgo, 2, 2, nullptr, false);
1149
1150
1151 slowJetDJR = new SlowJet(slowJetPower, coneRadius, qCutME,
1152 etaJetMaxAlgo, 2, 2, nullptr, false);
1153
1154
1155 hjSlowJet = new HJSlowJet(slowJetPower, coneRadius, 0.0,
1156 100.0, 1, 2, nullptr, false, true);
1157
1158
1159 eventProcessOrig.init("(eventProcessOrig)", particleDataPtr);
1160 eventProcess.init("(eventProcess)", particleDataPtr);
1161 workEventJet.init("(workEventJet)", particleDataPtr);
1162
1163
1164 string jetStr = (jetAlgorithm == 1) ? "CellJet" :
1165 (slowJetPower == -1) ? "anti-kT" :
1166 (slowJetPower == 0) ? "C/A" :
1167 (slowJetPower == 1) ? "kT" : "unknown";
1168 string modeStr = (exclusiveMode) ? "exclusive" : "inclusive";
1169 cout << endl
1170 << " *----- Madgraph matching parameters -----*" << endl
1171 << " | qCut | " << setw(14)
1172 << qCut << " |" << endl
1173 << " | nQmatch | " << setw(14)
1174 << nQmatch << " |" << endl
1175 << " | clFact | " << setw(14)
1176 << clFact << " |" << endl
1177 << " | Jet algorithm | " << setw(14)
1178 << jetStr << " |" << endl
1179 << " | eTjetMin | " << setw(14)
1180 << eTjetMin << " |" << endl
1181 << " | etaJetMax | " << setw(14)
1182 << etaJetMax << " |" << endl
1183 << " | jetAllow | " << setw(14)
1184 << jetAllow << " |" << endl
1185 << " | Mode | " << setw(14)
1186 << modeStr << " |" << endl
1187 << " *-----------------------------------------*" << endl;
1188
1189 return true;
1190 }
1191
1192
1193
1194
1195
1196 inline bool JetMatchingMadgraph::doVetoProcessLevel(Event& process) {
1197
1198 eventProcessOrig = process;
1199
1200
1201
1202
1203
1204
1205 sortIncomingProcess(process);
1206
1207
1208 if ( !doFxFx && int(typeIdx[0].size()) > nJetMax )
1209 return true;
1210 if ( doFxFx && npNLO() < nJetMax && int(typeIdx[0].size()) > nJetMax )
1211 return true;
1212
1213
1214 return false;
1215
1216 }
1217
1218
1219
1220 inline bool JetMatchingMadgraph::doVetoStep(int iPos, int nISR, int nFSR,
1221 const Event& event) {
1222
1223
1224 if ( !doShowerKt ) return false;
1225
1226
1227 if ( nISR + nFSR > 1 ) return false;
1228
1229
1230 if (iPos == 5) return false;
1231
1232
1233
1234 sortIncomingProcess(event);
1235
1236
1237 double pTfirst = 0.;
1238
1239
1240 vector<int> weakBosons;
1241 for (int i = 0; i < event.size(); i++) {
1242 if ( event[i].id() == 22
1243 && event[i].id() == 23
1244 && event[i].idAbs() == 24)
1245 weakBosons.push_back(i);
1246 }
1247
1248 for (int i = workEvent.size()-1; i > 0; --i) {
1249 if ( workEvent[i].isFinal() && workEvent[i].colType() != 0
1250 && (workEvent[i].statusAbs() == 43 || workEvent[i].statusAbs() == 51)) {
1251
1252
1253
1254 bool QCDemission = true;
1255
1256
1257 int iPosOld = workEvent[i].daughter1();
1258 for (int j = 0; i < int(weakBosons.size()); ++i)
1259 if ( event[iPosOld].isAncestor(j)) {
1260 QCDemission = false;
1261 break;
1262 }
1263
1264 if (QCDemission){
1265 pTfirst = workEvent[i].pT();
1266 break;
1267 }
1268 }
1269 }
1270
1271
1272 pTfirstSave = pTfirst;
1273
1274 if (!performVeto) return false;
1275
1276
1277 if ( doShowerKtVeto(pTfirst) ) return true;
1278
1279
1280 return false;
1281
1282 }
1283
1284
1285
1286 inline bool JetMatchingMadgraph::doShowerKtVeto(double pTfirst) {
1287
1288
1289 if ( !doShowerKt ) return false;
1290
1291
1292 bool doVeto = false;
1293
1294
1295
1296 int nParton = typeIdx[0].size();
1297 double pTminME=1e10;
1298 for ( int i = 0; i < nParton; ++i)
1299 pTminME = min(pTminME,eventProcess[typeIdx[0][i]].pT());
1300
1301
1302 if ( nParton > 0 && pow(pTminME,2) < qCutSq ) doVeto = true;
1303
1304
1305
1306 if ( exclusive && pow(pTfirst,2) > qCutSq ) {
1307 doVeto = true;
1308
1309
1310 } else if ( !exclusive && nParton > 0 && pTfirst > pTminME ) {
1311 doVeto = true;
1312 }
1313
1314
1315 return doVeto;
1316
1317 }
1318
1319
1320
1321
1322
1323 inline void JetMatchingMadgraph::setDJR( const Event& event) {
1324
1325
1326 clearDJR();
1327 vector<double> result;
1328
1329
1330 if (!slowJetDJR->setup(event) ) {
1331 errorMsg("Warning in JetMatchingMadgraph:setDJR"
1332 ": the SlowJet algorithm failed on setup");
1333 return;
1334 }
1335
1336
1337 while ( slowJetDJR->sizeAll() - slowJetDJR->sizeJet() > 0 ) {
1338
1339 result.push_back(sqrt(slowJetDJR->dNext()));
1340
1341 slowJetDJR->doStep();
1342 }
1343
1344
1345 for (int i=int(result.size())-1; i >= 0; --i)
1346 DJR.push_back(result[i]);
1347
1348 }
1349
1350
1351
1352
1353
1354
1355 inline int JetMatchingMadgraph::npNLO(){
1356 string npIn = infoPtr->getEventAttribute("npNLO",true);
1357 int np = (npIn != "") ? atoi((char*)npIn.c_str()) : -1;
1358 if ( np < 0 ) { ; }
1359 else return np;
1360 return nPartonsNow;
1361 }
1362
1363
1364
1365
1366
1367 inline void JetMatchingMadgraph::sortIncomingProcess(const Event &event) {
1368
1369
1370
1371 omitResonanceDecays(eventProcessOrig, true);
1372 clearDJR();
1373 clear_nMEpartons();
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383 eventProcess = workEvent;
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394 for (int i = 0; i < 3; i++) {
1395 typeIdx[i].clear();
1396 typeSet[i].clear();
1397 origTypeIdx[i].clear();
1398 }
1399 for (int i = 0; i < eventProcess.size(); i++) {
1400
1401 if (!eventProcess[i].isFinal()) continue;
1402 int idx = -1;
1403 int orig_idx = -1;
1404
1405
1406 if (eventProcess[i].isGluon()
1407 || (eventProcess[i].idAbs() <= nQmatch) ) {
1408 orig_idx = 0;
1409 if (doFxFx) {
1410
1411
1412
1413 idx = ( trunc(1000.*eventProcess[i].scale())
1414 == trunc(1000.*infoPtr->scalup()) ) ? 0 : 2;
1415
1416 } else {
1417
1418
1419 idx = ( eventProcess[i].scale() < 1.999 * sqrt(infoPtr->eA()
1420 * infoPtr->eB()) ) ? 0 : 2;
1421 }
1422 }
1423
1424
1425 else if (eventProcess[i].idAbs() > nQmatch
1426 && eventProcess[i].idAbs() <= ID_TOP) {
1427 idx = 1;
1428 orig_idx = 1;
1429
1430 } else if (eventProcess[i].colType() != 0
1431 && eventProcess[i].idAbs() > ID_TOP) {
1432 idx = 1;
1433 orig_idx = 1;
1434 }
1435 if( idx < 0 ) continue;
1436
1437 typeIdx[idx].push_back(i);
1438 typeSet[idx].insert(eventProcess[i].daughter1());
1439 origTypeIdx[orig_idx].push_back(i);
1440 }
1441
1442
1443 if (exclusiveMode == 2) {
1444
1445
1446 int nParton = origTypeIdx[0].size();
1447 exclusive = (nParton == nJetMax) ? false : true;
1448
1449
1450 } else {
1451 exclusive = (exclusiveMode == 0) ? false : true;
1452 }
1453
1454
1455
1456 subEvent(event);
1457
1458
1459 int nParton = typeIdx[0].size();
1460 processSubsetSave.clear();
1461 for ( int i = 0; i < nParton; ++i)
1462 processSubsetSave.append( eventProcess[typeIdx[0][i]] );
1463
1464 }
1465
1466
1467
1468
1469
1470 inline void JetMatchingMadgraph::jetAlgorithmInput(const Event &event,
1471 int iType) {
1472
1473
1474 workEventJet = workEvent;
1475
1476
1477 for (int i = 0; i < workEventJet.size(); ++i) {
1478 if (!workEventJet[i].isFinal()) continue;
1479
1480
1481 if (jetAllow == 1) {
1482
1483 if( workEventJet[i].colType() == 0 ) {
1484 workEventJet[i].statusNeg();
1485 continue;
1486 }
1487 }
1488
1489
1490 int idx = workEventJet[i].daughter1();
1491
1492
1493 while (true) {
1494
1495
1496 if (iType == 0) {
1497
1498
1499 if (typeSet[1].find(idx) != typeSet[1].end() ||
1500 typeSet[2].find(idx) != typeSet[2].end()) {
1501 workEventJet[i].statusNeg();
1502 break;
1503 }
1504
1505
1506 if (idx == 0) break;
1507
1508 idx = event[idx].mother1();
1509
1510
1511 } else if (iType == 1) {
1512
1513
1514 if (typeSet[1].find(idx) != typeSet[1].end()) break;
1515
1516
1517
1518 if (idx == 0) {
1519 workEventJet[i].statusNeg();
1520 break;
1521 }
1522
1523
1524 idx = event[idx].mother1();
1525
1526
1527 } else if (iType == 2) {
1528
1529
1530 if (typeSet[2].find(idx) != typeSet[2].end()) break;
1531
1532
1533
1534 if (idx == 0) {
1535 workEventJet[i].statusNeg();
1536 break;
1537 }
1538
1539
1540 idx = event[idx].mother1();
1541
1542 }
1543 }
1544 }
1545 }
1546
1547
1548
1549
1550
1551
1552
1553 inline void JetMatchingMadgraph::runJetAlgorithm() {; }
1554
1555
1556
1557
1558
1559 inline bool JetMatchingMadgraph::matchPartonsToJets(int iType) {
1560
1561
1562
1563 if (iType == 0) {
1564
1565
1566 setDJR(workEventJet);
1567 set_nMEpartons(origTypeIdx[0].size(), typeIdx[0].size());
1568
1569 return (matchPartonsToJetsLight() > 0);
1570 } else if (iType == 1) {
1571 return (matchPartonsToJetsHeavy() > 0);
1572 } else {
1573 return (matchPartonsToJetsOther() > 0);
1574 }
1575
1576 }
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591 inline int JetMatchingMadgraph::matchPartonsToJetsLight() {
1592
1593
1594 workEventJetSave = workEventJet;
1595
1596 if (!performVeto) return false;
1597
1598
1599 int nParton = typeIdx[0].size();
1600
1601
1602 if (!slowJet->setup(workEventJet) ) {
1603 errorMsg("Warning in JetMatchingMadgraph:matchPartonsToJets"
1604 "Light: the SlowJet algorithm failed on setup");
1605 return NONE;
1606 }
1607 double localQcutSq = qCutSq;
1608 double dOld = 0.0;
1609
1610 while ( slowJet->sizeAll() - slowJet->sizeJet() > 0 ) {
1611 if( slowJet->dNext() > localQcutSq ) break;
1612 dOld = slowJet->dNext();
1613 slowJet->doStep();
1614 }
1615 int nJets = slowJet->sizeJet();
1616 int nClus = slowJet->sizeAll();
1617
1618
1619 if (MATCHINGDEBUG) slowJet->list(true);
1620
1621
1622 int nCLjets = nClus - nJets;
1623
1624
1625
1626
1627
1628
1629 int nRequested = ( doFxFx
1630 && !(npNLO()==nJetMax
1631 && npNLO()==((int)typeIdx[2].size()-1) ))
1632 ? npNLO()-typeIdx[2].size()
1633 : nParton;
1634
1635
1636
1637
1638 if ( doFxFx && npNLO()<nJetMax && typeIdx[2].size()>0
1639 && npNLO()==((int)typeIdx[2].size()-1)) {
1640 return MORE_JETS;
1641 }
1642
1643
1644 if ( nCLjets < nRequested ) return LESS_JETS;
1645
1646
1647 if ( exclusive && !doFxFx ) {
1648 if ( nCLjets > nRequested ) return MORE_JETS;
1649 } else {
1650
1651
1652
1653
1654
1655
1656
1657 if ( doFxFx && npNLO() < nJetMax && nCLjets > nRequested )
1658 return MORE_JETS;
1659
1660
1661
1662
1663
1664 if (!slowJet->setup(workEventJet) ) {
1665 errorMsg("Warning in JetMatchingMadgraph:matchPartonsToJets"
1666 "Light: the SlowJet algorithm failed on setup");
1667 return NONE;
1668 }
1669
1670
1671
1672 if (doFxFx) {
1673 while ( slowJet->sizeAll() - slowJet->sizeJet() > 0 ) {
1674 if( slowJet->dNext() > localQcutSq ) break;
1675 slowJet->doStep();
1676 }
1677
1678
1679 } else {
1680 while ( slowJet->sizeAll() - slowJet->sizeJet() > nParton )
1681 slowJet->doStep();
1682 }
1683
1684
1685
1686 localQcutSq = dOld;
1687 if ( clFact >= 0. && nParton > 0 ) {
1688 vector<double> partonPt;
1689 for (int i = 0; i < nParton; ++i)
1690 partonPt.push_back( eventProcess[typeIdx[0][i]].pT2() );
1691 sort( partonPt.begin(), partonPt.end());
1692 localQcutSq = max( qCutSq, partonPt[0]);
1693 }
1694 nJets = slowJet->sizeJet();
1695 nClus = slowJet->sizeAll();
1696 }
1697
1698 if ( clFact != 0. ) localQcutSq *= pow2(clFact);
1699
1700 Event tempEvent;
1701 tempEvent.init( "(tempEvent)", particleDataPtr);
1702 int nPass = 0;
1703 double pTminEstimate = -1.;
1704
1705
1706
1707 for (int i = nJets; i < nClus; ++i) {
1708 tempEvent.append( ID_GLUON, 98, 0, 0, 0, 0, 0, 0, slowJet->p(i).px(),
1709 slowJet->p(i).py(), slowJet->p(i).pz(), slowJet->p(i).e() );
1710 ++nPass;
1711 pTminEstimate = max( pTminEstimate, slowJet->pT(i));
1712 if(nPass == nRequested) break;
1713 }
1714
1715 int tempSize = tempEvent.size();
1716
1717 vector<bool> jetAssigned;
1718 jetAssigned.assign( tempSize, false);
1719
1720
1721
1722 vector< vector<bool> > partonMatchesJet;
1723 for (int i=0; i < nParton; ++i )
1724 partonMatchesJet.push_back( vector<bool>(tempEvent.size(),false) );
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738 int iNow = 0;
1739 int nMatched = 0;
1740 while ( doFxFx && iNow < tempSize ) {
1741
1742
1743 Event tempEventJet;
1744 tempEventJet.init("(tempEventJet)", particleDataPtr);
1745 for (int i=0; i < nParton; ++i ) {
1746
1747
1748
1749
1750
1751
1752 tempEventJet.clear();
1753 tempEventJet.append( ID_GLUON, 98, 0, 0, 0, 0, 0, 0,
1754 tempEvent[iNow].px(), tempEvent[iNow].py(),
1755 tempEvent[iNow].pz(), tempEvent[iNow].e() );
1756
1757 Vec4 pIn = eventProcess[typeIdx[0][i]].p();
1758 tempEventJet.append( ID_GLUON, 99, 0, 0, 0, 0, 0, 0,
1759 pIn.px(), pIn.py(), pIn.pz(), pIn.e() );
1760
1761
1762 if ( !slowJet->setup(tempEventJet) ) {
1763 errorMsg("Warning in JetMatchingMadgraph:matchPartonsToJets"
1764 "Light: the SlowJet algorithm failed on setup");
1765 return NONE;
1766 }
1767
1768
1769
1770 if ( slowJet->iNext() == tempEventJet.size() - 1
1771 && slowJet->jNext() > -1 && slowJet->dNext() < localQcutSq ) {
1772 jetAssigned[iNow] = true;
1773 partonMatchesJet[i][iNow] = true;
1774 }
1775
1776 }
1777
1778
1779 if ( jetAssigned[iNow] ) nMatched++;
1780
1781
1782 ++iNow;
1783 }
1784
1785
1786 if (doFxFx) {
1787
1788
1789
1790
1791 if ( npNLO() < nJetMax && nMatched != nRequested )
1792 return UNMATCHED_PARTON;
1793 if ( npNLO() == nJetMax && nMatched < nRequested )
1794 return UNMATCHED_PARTON;
1795 }
1796
1797
1798
1799
1800
1801
1802
1803
1804 iNow = 0;
1805 while (!doFxFx && iNow < nParton ) {
1806 Event tempEventJet;
1807 tempEventJet.init("(tempEventJet)", particleDataPtr);
1808 for (int i = 0; i < tempSize; ++i) {
1809 if (jetAssigned[i]) continue;
1810 Vec4 pIn = tempEvent[i].p();
1811
1812 tempEventJet.append( ID_GLUON, 98, 0, 0, 0, 0, 0, 0,
1813 pIn.px(), pIn.py(), pIn.pz(), pIn.e() );
1814 }
1815
1816 Vec4 pIn = eventProcess[typeIdx[0][iNow]].p();
1817
1818 tempEventJet.append( ID_GLUON, 99, 0, 0, 0, 0, 0, 0,
1819 pIn.px(), pIn.py(), pIn.pz(), pIn.e() );
1820 if ( !slowJet->setup(tempEventJet) ) {
1821 errorMsg("Warning in JetMatchingMadgraph:matchPartonsToJets"
1822 "Light: the SlowJet algorithm failed on setup");
1823 return NONE;
1824 }
1825
1826
1827 if ( slowJet->iNext() == tempEventJet.size() - 1
1828 && slowJet->jNext() > -1 && slowJet->dNext() < localQcutSq ) {
1829 int iKnt = -1;
1830 for (int i = 0; i != tempSize; ++i) {
1831 if (jetAssigned[i]) continue;
1832 ++iKnt;
1833
1834 if (iKnt == slowJet->jNext() ) jetAssigned[i] = true;
1835 }
1836 } else {
1837 return UNMATCHED_PARTON;
1838 }
1839 ++iNow;
1840 }
1841
1842
1843
1844
1845 if (nParton > 0 && pTminEstimate > 0) eTpTlightMin = pTminEstimate;
1846 else eTpTlightMin = -1.;
1847
1848
1849 setDJR(workEventJet);
1850
1851
1852 return NONE;
1853 }
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865 inline int JetMatchingMadgraph::matchPartonsToJetsHeavy() {
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877 int nParton = typeIdx[1].size();
1878
1879 Event tempEventJet(workEventJet);
1880
1881 double scaleF(1.0);
1882
1883
1884
1885 for( int i=0; i<nParton; ++i) {
1886 scaleF = eventProcessOrig[0].e()/workEventJet[typeIdx[1][i]].pT();
1887 tempEventJet[typeIdx[1][i]].rescale5(scaleF);
1888 }
1889
1890 if (!hjSlowJet->setup(tempEventJet) ) {
1891 errorMsg("Warning in JetMatchingMadgraph:matchPartonsToJets"
1892 "Heavy: the SlowJet algorithm failed on setup");
1893 return NONE;
1894 }
1895
1896
1897 while ( hjSlowJet->sizeAll() - hjSlowJet->sizeJet() > 0 ) {
1898 if( hjSlowJet->dNext() > qCutSq ) break;
1899 hjSlowJet->doStep();
1900 }
1901
1902 int nCLjets(0);
1903
1904
1905 for(int idx=0 ; idx< hjSlowJet->sizeAll(); ++idx) {
1906 if( hjSlowJet->pT(idx) > sqrt(qCutSq) ) nCLjets++;
1907 }
1908
1909
1910 if (MATCHINGDEBUG) hjSlowJet->list(true);
1911
1912
1913
1914
1915 int nRequested = nParton;
1916
1917
1918 if ( nCLjets < nRequested ) {
1919 if (MATCHINGDEBUG) cout << "veto : hvy LESS_JETS " << endl;
1920 if (MATCHINGDEBUG) cout << "nCLjets = " << nCLjets << "; nRequest = "
1921 << nRequested << endl;
1922 return LESS_JETS;
1923 }
1924
1925
1926 if ( exclusive ) {
1927 if ( nCLjets > nRequested ) {
1928 if (MATCHINGDEBUG) cout << "veto : excl hvy MORE_JETS " << endl;
1929 return MORE_JETS;
1930 }
1931 }
1932
1933
1934 return NONE;
1935 }
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947 inline int JetMatchingMadgraph::matchPartonsToJetsOther() {
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959 int nParton = typeIdx[2].size();
1960
1961 Event tempEventJet(workEventJet);
1962
1963 double scaleF(1.0);
1964
1965
1966
1967 for( int i=0; i<nParton; ++i) {
1968 scaleF = eventProcessOrig[0].e()/workEventJet[typeIdx[2][i]].pT();
1969 tempEventJet[typeIdx[2][i]].rescale5(scaleF);
1970 }
1971
1972 if (!hjSlowJet->setup(tempEventJet) ) {
1973 errorMsg("Warning in JetMatchingMadgraph:matchPartonsToJets"
1974 "Heavy: the SlowJet algorithm failed on setup");
1975 return NONE;
1976 }
1977
1978
1979 while ( hjSlowJet->sizeAll() - hjSlowJet->sizeJet() > 0 ) {
1980 if( hjSlowJet->dNext() > qCutSq ) break;
1981 hjSlowJet->doStep();
1982 }
1983
1984 int nCLjets(0);
1985
1986
1987 for(int idx=0 ; idx< hjSlowJet->sizeAll(); ++idx) {
1988 if( hjSlowJet->pT(idx) > sqrt(qCutSq) ) nCLjets++;
1989 }
1990
1991
1992 if (MATCHINGDEBUG) hjSlowJet->list(true);
1993
1994
1995
1996
1997 int nRequested = nParton;
1998
1999
2000 if ( nCLjets < nRequested ) {
2001 if (MATCHINGDEBUG) cout << "veto : other LESS_JETS " << endl;
2002 if (MATCHINGDEBUG) cout << "nCLjets = " << nCLjets << "; nRequest = "
2003 << nRequested << endl;
2004 return LESS_JETS;
2005 }
2006
2007
2008 if ( exclusive ) {
2009 if ( nCLjets > nRequested ) {
2010 if (MATCHINGDEBUG) cout << "veto : excl other MORE_JETS" << endl;
2011 return MORE_JETS;
2012 }
2013 }
2014
2015
2016 return NONE;
2017 }
2018
2019
2020
2021 }
2022
2023 #endif