9 #ifndef Pythia8_VinciaFSR_H
10 #define Pythia8_VinciaFSR_H
12 #include "Pythia8/TimeShower.h"
13 #include "Pythia8/VinciaAntennaFunctions.h"
14 #include "Pythia8/VinciaCommon.h"
15 #include "Pythia8/VinciaISR.h"
16 #include "Pythia8/VinciaQED.h"
17 #include "Pythia8/VinciaWeights.h"
18 #include "Pythia8/VinciaDiagnostics.h"
40 bool canSetResonanceScale() {
return true;}
41 virtual double scaleResonance(
int iRes,
const Event& event) {
42 return event[iRes].m();}
55 double alphaSmax, b0, kMu2, lambda2, qMin;
56 map<int, double> mass;
95 Brancher() : hasTrialSav(
false), swapped(
false) {;}
99 reset(iSysIn, event, iIn);}
102 Brancher(
int iSysIn,
Event& event,
int i0In,
int i1In,
int i2In = 0) {
103 vector<int> iIn {i0In, i1In};
if (i2In >= 1) iIn.push_back(i2In);
104 reset(iSysIn,event,iIn);}
110 virtual void reset(
int iSysIn,
Event& event, vector<int> iIn);
113 void reset(
int iSysIn,
Event& event,
int i0In,
int i1In,
int i2In = 0) {
114 vector<int> iIn {i0In, i1In};
if (i2In >= 1) iIn.push_back(i2In);
115 reset(iSysIn,event,iIn);}
118 int i0()
const {
return (iSav.size() >= 1) ? iSav[0] : -1;}
119 int i1()
const {
return (iSav.size() >= 2) ? iSav[1] : -1;}
120 int i2()
const {
return (iSav.size() >= 3) ? iSav[2] : -1;}
121 int iVec(
unsigned int i)
const {
return (iSav.size() > i) ? iSav[i] : -1;}
122 vector<int> iVec() {
return iSav;}
123 int id0()
const {
return (idSav.size() >= 1) ? idSav[0] : -1;}
124 int id1()
const {
return (idSav.size() >= 2) ? idSav[1] : -1;}
125 int id2()
const {
return (idSav.size() >= 3) ? idSav[2] : -1;}
126 vector<int> idVec()
const {
return idSav;}
127 int colType0()
const {
return (colTypeSav.size() >= 1) ? colTypeSav[0] : -1;}
128 int colType1()
const {
return (colTypeSav.size() >= 2) ? colTypeSav[1] : -1;}
129 int colType2()
const {
return (colTypeSav.size() >= 3) ? colTypeSav[2] : -1;}
130 vector<int> colTypeVec()
const {
return colTypeSav;}
131 int col0()
const {
return (colSav.size() >= 1) ? colSav[0] : 0;}
132 int col1()
const {
return (colSav.size() >= 2) ? colSav[1] : 0;}
133 int col2()
const {
return (colSav.size() >= 3) ? colSav[2] : 0;}
134 vector<int> colVec()
const {
return colSav;}
135 int acol0()
const {
return (acolSav.size() >= 1) ? acolSav[0] : 0;}
136 int acol1()
const {
return (acolSav.size() >= 2) ? acolSav[1] : 0;}
137 int acol2()
const {
return (acolSav.size() >= 3) ? acolSav[2] : 0;}
138 vector<int> acolVec()
const {
return acolSav;}
139 int h0()
const {
return (hSav.size() >= 1) ? hSav[0] : -1;}
140 int h1()
const {
return (hSav.size() >= 2) ? hSav[1] : -1;}
141 int h2()
const {
return (hSav.size() >= 3) ? hSav[2] : -1;}
142 vector<int> hVec()
const {
return hSav;}
143 double m0()
const {
return (mSav.size() >= 1) ? mSav[0] : -1;}
144 double m1()
const {
return (mSav.size() >= 2) ? mSav[1] : -1;}
145 double m2()
const {
return (mSav.size() >= 3) ? mSav[2] : -1;}
146 vector<double> mVec()
const {
return mSav;}
147 vector<double> getmPostVec() {
return mPostSav;}
148 int colTag() {
return colTagSav;}
152 virtual double getQ2Max(
int) = 0;
155 int system()
const {
return systemSav;}
156 double mAnt()
const {
return mAntSav;}
157 double m2Ant()
const {
return m2AntSav;}
158 double sAnt()
const {
return sAntSav;}
159 double kallenFac()
const {
return kallenFacSav;}
160 double enhanceFac()
const {
return enhanceSav;}
161 double q2Trial()
const {
return q2NewSav;}
162 int iAntPhys()
const {
return iAntSav;}
165 virtual void init() = 0;
168 virtual double genQ2(
int evTypeIn,
double Q2MaxNow,
Rndm* rndmPtr,
170 vector<double> headroomIn, vector<double> enhanceFacIn,
175 virtual bool genInvariants(vector<double>& invariants,
Rndm*,
int) {
176 invariants.clear();
return false;}
180 virtual double pAccept(
const double,
int = 0) {
return 0.;}
183 virtual double getpTscale();
186 virtual double getXj();
190 virtual int idNew()
const {
return 0;}
191 virtual double mNew()
const {
return 0.0;}
194 virtual bool getNewParticles(
Event& event, vector<Vec4> momIn,
195 vector<int> hIn, vector<Particle> &pNew,
Rndm* rndmPtr,
200 virtual void list(
string header=
"none")
const;
203 virtual void setidPost();
204 virtual vector<double> setmPostVec();
205 virtual void setStatPost();
206 virtual void setMaps(
int);
213 virtual int posR() {
return -1;}
217 virtual int posF() {
return -1;}
220 int getBranchType() {
return branchType;}
222 bool isSwapped() {
return swapped;}
224 vector<double> getInvariants() {
return invariantsSav;}
227 void resetEnhanceFac(
const double enhanceIn) {enhanceSav = enhanceIn;}
231 bool hasTrial()
const {
return hasTrialSav;}
233 void needsNewTrial() {hasTrialSav =
false;}
235 void eraseTrial() {hasTrialSav =
false; q2NewSav = 0.;}
238 map<int, pair<int, int> > mothers2daughters;
239 map<int, pair<int, int> > daughters2mothers;
245 vector<int> iSav, idSav, colTypeSav, hSav, colSav, acolSav;
246 vector<int> idPostSav, statPostSav;
247 vector<double> mSav, mPostSav;
248 int colTagSav, evTypeSav;
254 double mAntSav, m2AntSav, kallenFacSav, sAntSav;
258 double headroomSav, enhanceSav, q2BegSav, q2NewSav;
259 vector<double> invariantsSav;
295 reset(iSysIn, event, iIn);}
299 reset(iSysIn, event, i0In, i1In);}
308 double genQ2(
int evTypeIn,
double Q2MaxNow,
Rndm* rndmPtr,
310 vector<double> headroomIn, vector<double> enhanceFacIn,
int verboseIn);
315 virtual bool genInvariants(vector<double>& invariants,
Rndm* rndmPtr,
321 virtual double pAccept(
const double antPhys,
int = 0);
324 double getQ2Max(
int evType);
327 virtual void setMaps(
int sizeOld);
330 virtual int idNew()
const {
return 21;}
331 virtual double mNew()
const {
return 0.0;}
334 virtual bool getNewParticles(
Event& event, vector<Vec4> momIn,
335 vector<int> hIn, vector<Particle> &pNew,
Rndm* rndmPtr,
Colour* colourPtr);
354 reset(iSysIn, event, iIn);}
360 bool col2acol) { reset(iSysIn, event, i0In, i1In); isXGsav = !col2acol; }
370 virtual bool isXG()
const {
return isXGsav;}
373 virtual int idNew()
const {
return idFlavSav;}
374 virtual double mNew()
const {
return mFlavSav;}
378 double genQ2(
int evTypeIn,
double Q2MaxNow,
Rndm* rndmPtr,
380 vector<double> headroomIn, vector<double> enhanceFacIn,
int verboseIn);
384 virtual bool genInvariants(vector<double>& invariants,
Rndm* rnmdPtr,
390 virtual double pAccept(
const double antPhys,
int);
393 double getQ2Max(
int evType);
394 virtual vector<double> setmPostVec();
395 virtual void setidPost();
396 virtual void setStatPost();
397 virtual void setMaps(
int sizeOld);
400 virtual bool getNewParticles(
Event& event, vector<Vec4> momIn,
401 vector<int> hIn, vector<Particle> &pNew,
Rndm*,
Colour*);
432 unsigned int posResIn,
unsigned int posFIn,
double Q2cut) {
433 reset(iSysIn, event, allIn); init(event, allIn, posResIn, posFIn, Q2cut);}
439 void resetResBrancher(
int iSysIn,
Event& event, vector<int> allIn,
440 unsigned int posResIn,
unsigned int posFIn,
double Q2cut) {
441 reset(iSysIn, event, allIn); init(event,allIn,posResIn,posFIn,Q2cut);}
447 virtual void init(
Event& event, vector<int> allIn,
unsigned int posResIn,
448 unsigned int posFIn,
double Q2cut);
451 virtual vector<double> setmPostVec();
452 virtual void setidPost();
453 virtual void setStatPost();
455 virtual void setMaps(
int sizeOld);
458 virtual bool getNewParticles(
Event& event, vector<Vec4> momIn,
459 vector<int> hIn, vector<Particle> &pNew,
Rndm* rndmPtr,
Colour*);
462 int posR() {
return int(posRes);}
465 int posF() {
return int(posFinal);}
468 double getQ2Max(
int evType) {
return evType == 1 ? Q2MaxSav : 0.;}
471 virtual double genQ2(
int evTypeIn,
double Q2MaxNow,
Rndm* rndmPtr,
473 vector<double> headroomIn, vector<double> enhanceFacIn,
478 virtual bool genInvariants(vector<double>& invariants,
Rndm* rndmPtr,
483 virtual double pAccept(
const double,
int);
488 double KallenFunction(
double x,
double y,
double z);
489 virtual double zetaIntSingleLim(
double zetaLim);
490 double zetaIntegral(
double zLow,
double zHigh);
491 double getsAK(
double mA,
double mK,
double mAK);
492 double zetaMinCalc(
double mA,
double mK,
double mAK,
double Q2cut);
493 double zetaMaxCalc(
double mA,
double mK,
double mAK);
494 virtual double getZetaNext(
Rndm* rndmPtr);
495 virtual double calcQ2Max(
double mA,
double mAK,
double mK);
498 bool vetoPhSpPoint(
double saj,
double sjk,
double sak,
int verboseIn);
502 double getEjMax(
double cosTheta,
double mA,
double mAK,
double mK);
506 unsigned int posRes{}, posFinal{};
516 double zetaMin{}, zetaMax{};
520 double zetaIntSave{};
525 map<unsigned int,unsigned int> posNewtoOld{};
541 unsigned int posResIn,
unsigned int posFIn,
double Q2cut) {
542 reset(iSysIn, event, allIn); init(event,allIn,posResIn,posFIn,Q2cut);}
551 void init(
Event& event, vector<int> allIn,
unsigned int posResIn,
552 unsigned int posFIn,
double Q2cut);
555 vector<double> setmPostVec();
556 virtual void setidPost();
557 virtual void setStatPost();
560 virtual bool getNewParticles(
Event& event, vector<Vec4> momIn,
561 vector<int> hIn, vector<Particle>& pNew,
Rndm*,
Colour*);
564 double genQ2(
int evTypeIn,
double Q2MaxNow,
Rndm* rndmPtr,
566 vector<double> headroomIn, vector<double> enhanceFacIn,
571 bool genInvariants(vector<double>& invariants,
Rndm* rndmPtr,
int verboseIn);
575 double pAccept(
const double,
int);
580 virtual double getZetaNext(
Rndm* rndmPtr) {
581 return zetaMin + rndmPtr->flat()*(zetaMax - zetaMin);}
584 double zetaMinCalc(
double mA,
double mK,
double mAK,
double Q2cut){
585 double sajMax = mA*mA -(mAK + mK)*(mAK + mK);
586 return Q2cut/sajMax + 1.- sajMax/sAK;}
608 VinciaFSR() {verbose = 0; headerIsPrinted =
false; isInit =
false;
609 isPrepared =
false; diagnosticsPtr = 0;}
626 bool limitPTmax(
Event& event,
double Q2Fac = 0.,
double Q2Ren = 0.)
override;
630 int shower(
int iBeg,
int iEnd,
Event& event,
double pTmax,
631 int nBranchMax = 0)
override;
634 int showerQED(
int iBeg,
int iEnd,
Event& event,
double pTmax)
override;
638 int showerQEDafterRemnants(
Event& event)
override;
644 void prepare(
int iSys,
Event& event,
bool limitPTmaxIn)
override;
651 void update(
int iSys,
Event& event,
bool hasWeakRad =
false)
override;
654 double pTnext(
Event& event,
double pTbegAll,
double pTendAll,
655 bool isFirstTrial =
false,
bool doTrialIn =
false)
override;
658 bool branch(
Event& event,
bool isInterleaved =
false)
override;
661 void list()
const override;
672 int system()
const override {
return iSysWin;}
676 double enhancePTmax()
override {
return pTmaxFudge;}
680 double pTLastInShower()
override {
return pTLastAcceptedSav;}
695 void initVinciaPtrs(
Colour* colourPtrIn, shared_ptr<VinciaISR> isrPtrIn,
700 void initAntPtr(
AntennaSetFSR* antSetIn) {antSetPtr = antSetIn;}
705 vector<int> getIant() {
return antSetPtr->getIant();}
711 void printInfo(
bool pluginCall =
false );
717 void writeHistos(
string fileName =
"vincia",
string suffix =
"dat");
720 const Hist& getDiagnosticHistogram(
string name) {
return vinciaHistos[name];}
722 int getNsys() {
return nBranchFSR.size();}
725 int getNbranch(
int iSys = -1);
729 double getQbranch(
int iSys,
int iBranch) {
730 return (iSys < 4 && iSys >= 0 && iBranch <= 10 && iBranch >= 1) ?
731 qBranch[iSys][iBranch] : 0.;}
732 double getPTphys(
int iSys,
int iBranch) {
733 return (iSys < 4 && iSys >= 0 && iBranch <= 10 && iBranch >= 1) ?
734 pTphys[iSys][iBranch] : 0.;}
736 void doforceQuit(
int nBranchQuitIn) {
737 allowforceQuit =
true; nBranchQuit = nBranchQuitIn;}
739 void setDiagnostics(shared_ptr<VinciaDiagnostics> diagnosticsPtrIn) {
740 diagnosticsPtr = diagnosticsPtrIn;
741 if (diagnosticsPtr !=
nullptr) {
742 doDiagnostics =
true;
743 if (verbose >= normal)
744 printOut(__METHOD_NAME__,
"Diagnostics enabled...");
745 diagnosticsPtr->init();
747 doDiagnostics =
false;
748 if (verbose >= normal)
749 printOut(__METHOD_NAME__,
"Diagnostics disabled...");
754 bool check(
Event &event);
757 void setVerbose(
int verboseIn) {verbose = verboseIn;}
762 void initEvolutionWindows(
void);
764 double getQ2Window(
int iWindow,
double q2cutoff);
768 double getkMu2(
bool isEmit);
771 double getMu2(
bool isEmit);
773 void clearContainers();
775 bool getAntennae(
int iSys,
Event& event);
777 void setStartScale(
int iSys,
Event& event);
781 bool q2NextEmit(
const double q2Begin,
double q2End);
782 bool q2NextSplit(
const double q2Begin,
double q2End);
783 bool q2NextResEmit(
const double q2Begin,
const double q2End);
784 bool q2NextResSplit(
const double q2Begin,
const double q2End);
785 bool q2NextEmitQED(
double q2Begin,
const double q2End);
786 bool q2NextSplitQED(
double q2Begin,
const double q2End);
789 template <
class Brancher>
bool q2NextBranch( vector<Brancher> &brancherVec,
790 const map<double, EvolutionWindow>& evWindows,
const int evType,
791 const double q2Begin,
const double q2End,
bool isEmit);
793 bool branchQED(
Event& event);
799 double pAcceptCalc(
double antPhys);
801 bool genFullKinematics(
int kineMap,
Event event, vector<Vec4> &pPost);
803 bool acceptTrial(
Event& event);
806 vector<Particle> &newParts);
822 void updatePartonSystems();
824 void saveEmitter(
int iSysIn,
Event& event,
int i0,
int i1);
826 void saveResEmitter(
int iSys,
Event& event, vector<int> allIn,
827 unsigned int posResIn,
unsigned int posFIn,
bool colMode);
829 void saveResSplitter(
int iSysIn,
Event& event, vector<int> allIn,
830 unsigned int posResIn,
unsigned int posFIn,
bool colMode);
832 void saveSplitter(
int iSysIn,
Event& event,
int i0,
int i1,
bool col2acol);
834 template <
class Brancher>
void updateBranchers(vector<Brancher>& brancherVec,
835 map<pair<int, bool>,
unsigned int>& lookupBrancher,
Event& event,
int iOld,
838 template <
class Brancher>
void updateBrancher(vector<Brancher>& brancherVec,
839 map<pair<int, bool>,
unsigned int>& lookupBrancher,
Event& event,
840 int iOld1,
int iOld2,
int iNew1,
int iNew2);
842 void updateEmitters(
Event& event,
int iOld,
int iNew);
844 void updateEmitter(
Event& event,
int iOld1,
int iOld2,
int iNew1,
int iNew2);
846 void updateSplitters(
Event& event,
int iOld,
int iNew);
848 void updateSplitter(
Event& event,
int iOld1,
int iOld2,
int iNew1,
int iNew2,
852 void removeSplitter(
int iRemove);
854 bool updateResBranchers(
int iSysRes,
Event& event,
int iRes);
856 void updateResBranchers(
int iSysRes,
Event& event, vector<int> resSysAll,
857 unsigned int posRes,
unsigned int posPartner,
bool isCol);
859 bool updateAntennae(
Event& event);
861 bool updateAfterQED(
Event& event,
int sizeOld);
863 void printLookup(map< pair<int, bool>,
unsigned int > lookupBrancher,
868 vector<double> getHeadroom(
int iSys,
bool isEmit,
double q2Next);
870 vector<double> getEnhance(
int iSys,
bool isEmit,
double q2Next);
873 bool isInit, isPrepared;
878 double eCMBeamsSav, m2BeamsSav;
881 bool doFF, doRF, doII, doIF, doQED;
887 bool helicityShower, sectorShower;
888 int evTypeEmit, evTypeSplit, nGluonToQuark;
889 double q2CutoffEmit, q2CutoffSplit;
891 map<int,int> resSystems;
897 double pTmaxFudge, pT2maxFudge, pT2maxFudgeMPI;
902 double alphaSvalue, alphaSmax, alphaSmuFreeze, alphaSmuMin;
903 double aSkMu2Emit, aSkMu2Split;
906 double mu2freeze, mu2min;
909 map<double, EvolutionWindow> evWindowsEmit;
910 map<double, EvolutionWindow> evWindowsSplit;
913 vector<BrancherEmitRF> resEmitters;
914 vector<BrancherSplitRF> resSplitters;
915 vector<BrancherEmitFF> emitters;
916 vector<BrancherSplitFF> splitters;
921 map< pair<int, bool>,
unsigned int > lookupBrancherRF;
922 map< pair<int, bool>,
unsigned int > lookupSplitterRF;
924 map< pair<int, bool>,
unsigned int > lookupBrancherFF;
926 map< pair<int, bool>,
unsigned int > lookupSplitter;
931 double q2WinSav, pTLastAcceptedSav;
934 int iSysWin, iAntWin;
941 vector<Particle> pNew;
943 vector<double> pAccept;
946 bool doCR, CRjunctions;
949 bool enhanceInHard, enhanceInResDec, enhanceInMPI;
950 double enhanceAll, enhanceBottom, enhanceCharm, enhanceCutoff;
953 bool hasUserHooks, canVetoEmission;
956 map<int, bool> isHardSys, isResonanceSys, polarisedSys, doMECsSys;
957 map<int, bool> stateChangeSys;
958 bool stateChangeLast;
961 map<int, double> Q2hat;
964 map<int, int> nBranch, nBranchFSR;
967 map<int, double> mSystem;
970 map<int, int> nG, nQ, nLep, nGam;
974 map< pair<int, pair<bool,bool> > , vector<double> > headroomSav;
975 map< pair<int, pair<bool,bool> > , vector<double> > enhanceSav;
978 map<int, bool> hasResJunction;
979 map<int, resJunctionInfo> junctionInfo;
983 bool headerIsPrinted;
986 shared_ptr<VinciaDiagnostics> diagnosticsPtr;
988 map<string,Hist> vinciaHistos;
991 bool firstQBranchBinned;
992 double qBranch[4][11], pTphys[4][11];
996 vector<long> nTrials, nTrialsAccepted, nFailedVeto, nFailedHull, nFailedKine;
997 vector<long> nFailedMass, nFailedCutoff, nClosePSforHQ, nSectorReject;
1000 long nAccepted, nSelected;
1001 int nVetoUserHooks, nFailHadLevel, nCallPythiaNext;
1004 bool allowforceQuit, forceQuit;
1012 shared_ptr<VinciaISR> isrPtr;
1027 #endif // end Pythia8_VinciaFSR_H