File indexing completed on 2025-01-18 10:06:34
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef VINCIA_History_H
0010 #define VINCIA_History_H
0011
0012 #include "Pythia8/History.h"
0013 #include "Pythia8/Info.h"
0014 #include "Pythia8/Vincia.h"
0015 #include "Pythia8/VinciaAntennaFunctions.h"
0016 #include "Pythia8/VinciaMergingHooks.h"
0017
0018 namespace Pythia8 {
0019
0020
0021
0022
0023
0024 struct PseudoChain {
0025
0026 vector<int> chainlist;
0027
0028 int index;
0029
0030 int cindex;
0031
0032 bool hasInitial;
0033
0034 int flavStart;
0035 int flavEnd;
0036
0037 int charge;
0038 };
0039
0040
0041
0042
0043
0044
0045
0046 class ColourFlow {
0047
0048 public:
0049
0050
0051 ColourFlow() : nChains(0), nBeamChainsMin(0), nBeamChainsMax(0), nRes(0) {
0052 for(int i=0; i<4; i++) {countChainsByChargeIndex[i]=0;
0053 countResByChargeIndex[i]=0;}}
0054
0055
0056
0057
0058 void addChain(int charge, int flavStart, int flavEnd, bool hasInitialIn);
0059 void selectResChains(int index,int iorder, int id);
0060 void selectBeamChains(int index,int iorder);
0061
0062
0063 bool initHard(map<int, map<int,int> >& countRes,
0064 shared_ptr<VinciaMergingHooks> vinMergingHooksPtr);
0065
0066
0067 bool checkChains(int cIndex);
0068 bool checkChains();
0069 int getNChainsLeft();
0070 int maxLength();
0071 int minLength();
0072
0073
0074 void print(bool printpsch = false);
0075
0076
0077
0078
0079 map<int, vector<PseudoChain> > resChains;
0080
0081
0082 vector<PseudoChain> beamChains;
0083
0084
0085
0086
0087 map< int , vector< PseudoChain > > pseudochains;
0088
0089
0090
0091 map<int,vector<int> > chainToIndices;
0092
0093
0094 map<int,int> chainStartToFlav;
0095 map<int,int> chainEndToFlav;
0096
0097 map<int,bool> hasInitial;
0098
0099 map<int,int> chainToCharge;
0100
0101 private:
0102
0103
0104 void addChain(int oldIndex, int chainsIndex, int iChain,
0105 vector<int> & newIndices);
0106 void selectPseudochain(vector<int> & psch);
0107 void selectChain(int iChain);
0108
0109
0110 void addResonances(vector<int>& idsIn, map<int, map<int,int> >& idCounter,
0111 int charge, bool fc);
0112
0113
0114 int getChargeIndex(int charge, bool fc);
0115
0116
0117 int getID(PseudoChain& psc) {
0118 int id = 0;
0119 int iChains = psc.chainlist.size()-1;
0120 for (int iPwr(iChains); iPwr>=0; --iPwr)
0121 id += (psc.chainlist.at(iPwr)+1)*pow(10,iChains-iPwr);
0122 return id;
0123 }
0124
0125
0126 vector<int> pseudochainIDs;
0127
0128
0129 int nChains;
0130 int nBeamChainsMin, nBeamChainsMax, nRes;
0131 map<int,int> countChainsByChargeIndex;
0132 map<int,int> countResByChargeIndex;
0133
0134 };
0135
0136
0137
0138
0139
0140 class HistoryNode {
0141
0142 public:
0143
0144
0145 HistoryNode() {};
0146 HistoryNode(Event& stateIn, vector< vector<int> > chainsIn,
0147 double scaleIn) : HistoryNode() {
0148 state = stateIn;
0149 clusterableChains = chainsIn;
0150 qEvolNow = scaleIn;
0151 hasRes = false;
0152 iRes = 0;
0153 idRes = 0;
0154 isInitPtr=false;
0155 };
0156
0157
0158 void initPtr(VinciaCommon* vinComPtrIn, Resolution* resPtrIn,
0159 AntennaSetFSR* antSetPtrIn) {
0160 resPtr = resPtrIn;
0161 vinComPtr = vinComPtrIn;
0162 antSetFSRptr = antSetPtrIn;
0163 isInitPtr=true;
0164 nMinQQbar = 0;
0165 }
0166
0167
0168 int getNClusterings(shared_ptr<VinciaMergingHooks> vinMergingHooksPtr,
0169 Logger* loggerPtr, int verboseIn);
0170 void setClusterList(shared_ptr<VinciaMergingHooks> vinMergingHooksPtr,
0171 Logger* loggerPtr, int verboseIn);
0172
0173
0174 bool cluster(HistoryNode& nodeClus,
0175 Logger* loggerPtr, int verboseIn);
0176
0177
0178 double xA() const {return 2. * state[3].e() / state[0].e();}
0179 double xB() const {return 2. * state[4].e() / state[0].e();}
0180
0181
0182 int idA() const {return state[3].id();}
0183 int idB() const {return state[4].id();}
0184
0185
0186 int colTypeA() const {return state[3].colType();}
0187 int colTypeB() const {return state[4].colType();}
0188
0189
0190 double getEvolNow() const {return qEvolNow;}
0191
0192
0193 void setEvolScale(double scaleIn) {qEvolNow = scaleIn;}
0194
0195
0196 Event state;
0197
0198
0199 bool hasRes;
0200 int iRes;
0201 int idRes;
0202
0203
0204 int nMinQQbar;
0205
0206
0207 vector<vector<int>> clusterableChains;
0208
0209
0210 VinciaClustering lastClustering;
0211
0212 private:
0213
0214
0215 bool doClustering(VinciaClustering& clus, Event& clusEvent,
0216 vector<vector<int>>& clusChains, Logger* loggerPtr, int verboseIn);
0217
0218
0219 double calcResolution(VinciaClustering& clusIn) {
0220 return resPtr->q2sector(clusIn);}
0221 double calcEvolScale(VinciaClustering& clusIn) {
0222 return resPtr->q2evol(clusIn);}
0223
0224
0225
0226
0227 Resolution* resPtr;
0228 VinciaCommon* vinComPtr;
0229 AntennaSetFSR* antSetFSRptr;
0230
0231 bool isInitPtr;
0232
0233
0234 double qEvolNow;
0235
0236
0237
0238 map<double, VinciaClustering> clusterList;
0239
0240 };
0241 typedef map<int, vector<HistoryNode> > HistoryNodes;
0242
0243
0244
0245
0246
0247 class VinciaHistory {
0248
0249 public:
0250
0251
0252 VinciaHistory(Event &stateIn,
0253 BeamParticle* beamAPtrIn, BeamParticle* beamBPtrIn,
0254 MergingHooksPtr mergingHooksPtrIn,
0255 PartonLevel* trialPartonLevelPtrIn,
0256 ParticleData* particleDataPtrIn,
0257 Info* infoPtrIn);
0258
0259
0260 bool isValid() {return foundValidHistory;}
0261
0262
0263 bool isBelowMS() {return failedMSCut;}
0264
0265
0266 double getWeightCKKWL();
0267
0268
0269 int getNClusterSteps();
0270
0271
0272 double getRestartScale();
0273
0274
0275
0276 bool hasNewProcess() {return hasNewProcessSav;}
0277 Event getNewProcess() {return newProcess;}
0278 bool doAbort() {return aborted;}
0279
0280 private:
0281
0282
0283 void findBestHistory();
0284
0285
0286 unsigned int countPerms();
0287
0288
0289 bool getColChains();
0290
0291
0292 bool assignResChains(map<int, map<int,int>>& idCounter,
0293 vector<ColourFlow>& flowsSoFar);
0294
0295
0296 bool assignResFromEvent(map<int, map<int,int>>& idCounter,
0297 vector<ColourFlow>& flowsSoFar);
0298
0299
0300
0301 bool assignBeamChains(vector<ColourFlow>& flowsSoFar);
0302
0303
0304 bool assignNext(vector<ColourFlow>& flowsSoFar, bool isRes = false,
0305 int id = 0, int cIndex = 0);
0306
0307
0308 bool assignThis(vector<ColourFlow>& flowsSoFar, int id, int cIndex,
0309 vector<int>& chains);
0310
0311
0312
0313 bool check(ColourFlow& flow);
0314
0315
0316 tuple<bool, double, HistoryNodes> findHistoryPerm(ColourFlow& flow);
0317
0318
0319 bool checkMergingCut(HistoryNodes& history);
0320
0321
0322 HistoryNodes initHistoryNodes(ColourFlow& flow );
0323
0324
0325
0326 map<int, vector<vector<int>>> getSystems(ColourFlow& flow,
0327 map<int, int>& sysToRes);
0328
0329
0330 bool isBorn(const HistoryNode& nodeIn, bool isRes);
0331
0332
0333 bool setupBeams(const HistoryNode* node, double scale2);
0334
0335
0336 double calcME2guess(vector<HistoryNode>& history,bool isRes);
0337
0338 double calcME2Born(const HistoryNode& bornNode, bool isRes);
0339
0340
0341 double calcAntFun(const VinciaClustering& clusNow);
0342
0343
0344 double calcPDFRatio(const HistoryNode* nodeNow,
0345 double pT2now, double pT2next);
0346
0347
0348 double calcAlphaSRatio(const HistoryNode& node);
0349
0350
0351 double getStartScale(Event& event, bool isRes);
0352
0353
0354 double qNextTrial(double qStart, Event& evtIn);
0355
0356
0357 void printChains();
0358
0359
0360 int verbose;
0361
0362
0363 BeamParticle beamA, beamB;
0364
0365
0366 shared_ptr<VinciaMergingHooks> vinMergingHooksPtr{};
0367
0368
0369 PartonLevel* trialPartonLevel{};
0370
0371
0372 ParticleData* particleDataPtr{};
0373
0374
0375 Info* infoPtr{};
0376 Logger* loggerPtr{};
0377
0378
0379 shared_ptr<VinciaFSR> fsrShowerPtr{};
0380 shared_ptr<VinciaISR> isrShowerPtr{};
0381 MECs* mecsPtr{};
0382 VinciaCommon* vinComPtr{};
0383 Resolution* resPtr{};
0384 AntennaSetFSR* antSetFSRptr{};
0385
0386
0387 bool foundValidHistory;
0388
0389
0390 bool failedMSCut;
0391
0392
0393 HistoryNodes historyBest;
0394
0395
0396
0397 double ME2guessBest;
0398
0399
0400
0401 vector<vector<int>> colChainsSav;
0402
0403
0404 map<int, bool> chainHasInitial;
0405
0406
0407 map<int, vector<int>> resIDToIndices;
0408 map<int, vector<int>> resIndexToChains;
0409
0410
0411 vector<ColourFlow> colPerms;
0412
0413
0414 Event state;
0415
0416
0417 int nQSave, nGluonLoopsSave;
0418
0419
0420 double qms;
0421 bool msIsEvolVar;
0422
0423
0424 int nMax, nMaxRes;
0425
0426
0427 bool hasNewProcessSav;
0428 Event newProcess;
0429 double newProcessScale;
0430
0431
0432 bool aborted;
0433
0434 };
0435
0436
0437
0438 }
0439
0440 #endif