10 #ifndef Pythia8_History_H
11 #define Pythia8_History_H
13 #include "Pythia8/Basics.h"
14 #include "Pythia8/BeamParticle.h"
15 #include "Pythia8/Event.h"
16 #include "Pythia8/Info.h"
17 #include "Pythia8/ParticleData.h"
18 #include "Pythia8/PartonLevel.h"
19 #include "Pythia8/PythiaStdlib.h"
20 #include "Pythia8/Settings.h"
21 #include "Pythia8/StandardModel.h"
22 #include "Pythia8/SimpleWeakShowerMEs.h"
62 Clustering() : emitted(0), emittor(0), recoiler(0), partner(0), pTscale(),
63 flavRadBef(0), spinRad(9), spinEmt(9), spinRec(9), spinRadBef(9),
64 radBef(0), recBef(0) {}
70 Clustering(
const Clustering& inSystem ) :
71 emitted(inSystem.emitted), emittor(inSystem.emittor),
72 recoiler(inSystem.recoiler), partner(inSystem.partner),
73 pTscale(inSystem.pTscale), flavRadBef(inSystem.flavRadBef),
74 spinRad(inSystem.spinRad), spinEmt(inSystem.spinEmt),
75 spinRec(inSystem.spinRec), spinRadBef(inSystem.spinRad),
76 radBef(inSystem.radBef), recBef(inSystem.recBef) {}
79 Clustering(
int emtIn,
int radIn,
int recIn,
int partnerIn,
80 double pTscaleIn,
int flavRadBefIn = 0,
int spinRadIn = 9,
81 int spinEmtIn = 9,
int spinRecIn = 9,
int spinRadBefIn = 9,
82 int radBefIn = 0,
int recBefIn = 0)
83 : emitted(emtIn), emittor(radIn), recoiler(recIn), partner(partnerIn),
84 pTscale(pTscaleIn), flavRadBef(flavRadBefIn), spinRad(spinRadIn),
85 spinEmt(spinEmtIn), spinRec(spinRecIn), spinRadBef(spinRadBefIn),
86 radBef(radBefIn), recBef(recBefIn) {}
89 double pT()
const {
return pTscale; }
126 History(
int depthIn,
130 MergingHooksPtr mergingHooksPtrIn,
131 BeamParticle beamAIn,
132 BeamParticle beamBIn,
133 ParticleData* particleDataPtrIn,
135 PartonLevel* showersIn,
138 bool isStronglyOrdered,
146 for (
int i = 0, N = children.size(); i < N; ++i )
delete children[i];
150 bool projectOntoDesiredHistories();
162 vector<double> weightCKKWL(PartonLevel* trial, AlphaStrong * asFSR,
163 AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR,
double RN);
168 vector<double> weightNL3Loop(PartonLevel* trial,
double RN);
170 vector<double> weightNL3First(PartonLevel* trial, AlphaStrong* asFSR,
171 AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR,
double RN,
173 vector<double> weightNL3Tree(PartonLevel* trial, AlphaStrong * asFSR,
174 AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR,
double RN);
178 vector<double> weightUMEPSTree(PartonLevel* trial, AlphaStrong * asFSR,
179 AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR,
double RN);
180 vector<double> weightUMEPSSubt(PartonLevel* trial, AlphaStrong * asFSR,
181 AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR,
double RN);
185 vector<double> weightUNLOPSTree(PartonLevel* trial, AlphaStrong * asFSR,
186 AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR,
double RN,
188 vector<double> weightUNLOPSSubt(PartonLevel* trial, AlphaStrong * asFSR,
189 AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR,
double RN,
191 vector<double> weightUNLOPSLoop(PartonLevel* trial, AlphaStrong * asFSR,
192 AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR,
double RN,
194 vector<double> weightUNLOPSSubtNLO(PartonLevel* trial, AlphaStrong * asFSR,
195 AlphaStrong * asISR, AlphaEM * aemFSR, AlphaEM * aemISR,
double RN,
197 vector<double> weightUNLOPSFirst(
int order, PartonLevel* trial,
198 AlphaStrong* asFSR, AlphaStrong * asISR, AlphaEM * aemFSR,
199 AlphaEM * aemISR,
double RN, Rndm* rndmPtr );
202 bool foundAllowedHistories() {
203 return (children.size() > 0 && foundAllowedPath); }
205 bool foundOrderedHistories() {
206 return (children.size() > 0 && foundOrderedPath); }
208 bool foundCompleteHistories() {
209 return (children.size() > 0 && foundCompletePath); }
212 void getStartingConditions(
const double RN,
Event& outState );
214 bool getClusteredEvent(
const double RN,
int nSteps,
Event& outState);
216 bool getFirstClusteredEventAboveTMS(
const double RN,
int nDesired,
217 Event& process,
int & nPerformed,
bool updateProcess =
true );
223 Event lowestMultProc(
const double RN) {
225 return (select(RN)->state);
229 double getPDFratio(
int side,
bool forSudakov,
bool useHardPDF,
230 int flavNum,
double xNum,
double muNum,
231 int flavDen,
double xDen,
double muDen);
234 double getWeakProb();
239 double getWeakProb(vector<int>& mode, vector<Vec4>& mom,
240 vector<int> fermionLines);
245 double getSingleWeakProb(vector<int> &mode, vector<Vec4> &mom,
246 vector<int> fermionLines);
252 void findStateTransfer(map<int,int> &transfer);
256 void printHistory(
const double RN );
264 friend class Merging;
270 static const int NTRIAL;
274 void setScalesInHistory();
283 void findPath(vector<int>& out);
303 void setScales( vector<int> index,
bool forward);
312 void scaleCopies(
int iPart,
const Event& refEvent,
double rho);
318 void setEventScales();
322 void printScales() {
if ( mother ) mother->printScales();
323 cout <<
" size " << state.size() <<
" scale " << scale <<
" clusterIn "
324 << clusterIn.pT() <<
" state.scale() " << state.scale() << endl; }
327 bool trimHistories();
329 void remove(){ doInclude =
false; }
331 bool keep(){
return doInclude; }
336 bool isOrderedPath(
double maxscale );
338 bool followsInputPath();
342 bool allIntermediateAboveRhoMS(
double rhoms,
bool good =
true );
344 bool foundAnyOrderedPaths();
370 Event clusteredState(
int nSteps);
376 History * select(
double rnd);
390 vector<double> weightTree(PartonLevel* trial,
double as0,
double aem0,
391 double maxscale,
double pdfScale, AlphaStrong * asFSR, AlphaStrong * asISR,
392 AlphaEM * aemFSR, AlphaEM * aemISR, vector<double>& asWeight,
393 vector<double>& aemWeight, vector<double>& pdfWeight);
396 vector<double> weightTreeAlphaS(
double as0, AlphaStrong * asFSR,
397 AlphaStrong * asISR,
int njetMax = -1,
bool asVarInME =
false );
399 vector<double> weightTreeAlphaEM(
double aem0, AlphaEM * aemFSR,
400 AlphaEM * aemISR,
int njetMax = -1 );
402 vector<double> weightTreePDFs(
double maxscale,
double pdfScale,
405 vector<double> weightTreeEmissions( PartonLevel* trial,
int type,
406 int njetMin,
int njetMax,
double maxscale );
409 double weightFirst(PartonLevel* trial,
double as0,
double muR,
410 double maxscale, AlphaStrong * asFSR, AlphaStrong * asISR, Rndm* rndmPtr );
414 double weightFirstAlphaS(
double as0,
double muR, AlphaStrong * asFSR,
415 AlphaStrong * asISR);
418 double weightFirstAlphaEM(
double aem0,
double muR, AlphaEM * aemFSR,
422 double weightFirstPDFs(
double as0,
double maxscale,
double pdfScale,
426 double weightFirstEmissions(PartonLevel* trial,
double as0,
double maxscale,
427 AlphaStrong * asFSR, AlphaStrong * asISR,
bool fixpdf,
bool fixas );
430 double hardFacScale(
const Event& event);
432 double hardRenScale(
const Event& event);
442 vector<double> doTrialShower(PartonLevel* trial,
int type,
double maxscale,
443 double minscale = 0.);
446 bool updateind(vector<int> & ind,
int i,
int N);
449 vector<double> countEmissions(PartonLevel* trial,
double maxscale,
450 double minscale,
int showerType,
double as0, AlphaStrong * asFSR,
451 AlphaStrong * asISR,
int N,
bool fixpdf,
bool fixas);
455 double monteCarloPDFratios(
int flav,
double x,
double maxScale,
456 double minScale,
double pdfScale,
double asME, Rndm* rndmPtr);
461 bool onlyOrderedPaths();
466 bool onlyStronglyOrderedPaths();
471 bool onlyAllowedPaths();
479 bool registerPath(History & l,
bool isOrdered,
bool isStronglyOrdered,
480 bool isAllowed,
bool isComplete);
486 vector<Clustering> getAllQCDClusterings();
491 vector<Clustering> getQCDClusterings(
const Event& event);
502 vector<Clustering> findQCDTriple (
int emtTagIn,
int colTopIn,
503 const Event& event, vector<int> posFinalPartn,
504 vector <int> posInitPartn );
506 vector<Clustering> getAllEWClusterings();
507 vector<Clustering> getEWClusterings(
const Event& event);
508 vector<Clustering> findEWTripleW(
int emtTagIn,
const Event& event,
509 vector<int> posFinalPartn, vector<int> posInitPartn );
510 vector<Clustering> findEWTripleZ(
int emtTagIn,
const Event& event,
511 vector<int> posFinalPartn, vector<int> posInitPartn );
513 vector<Clustering> getAllSQCDClusterings();
514 vector<Clustering> getSQCDClusterings(
const Event& event);
515 vector<Clustering> findSQCDTriple (
int emtTagIn,
int colTopIn,
516 const Event& event, vector<int> posFinalPartn,
517 vector <int> posInitPartn );
520 void attachClusterings (vector<Clustering>& clus,
int iEmt,
int iRad,
521 int iRec,
int iPartner,
double pT,
const Event& event);
527 double getProb(
const Clustering & SystemIn);
542 double pdfForSudakov();
546 double hardProcessME(
const Event& event);
552 Event cluster( Clustering & inSystem);
560 int getRadBeforeFlav(
const int radAfter,
const int emtAfter,
567 int getRadBeforeSpin(
const int radAfter,
const int emtAfter,
568 const int spinRadAfter,
const int spinEmtAfter,
577 int getRadBeforeCol(
const int radAfter,
const int emtAfter,
586 int getRadBeforeAcol(
const int radAfter,
const int emtAfter,
594 int getColPartner(
const int in,
const Event& event);
601 int getAcolPartner(
const int in,
const Event& event);
611 vector<int> getReclusteredPartners(
const int rad,
const int emt,
630 bool getColSinglet(
const int flavType,
const int iParton,
631 const Event& event, vector<int>& exclude,
632 vector<int>& colSinglet);
638 bool isColSinglet(
const Event& event, vector<int> system);
645 bool isFlavSinglet(
const Event& event,
646 vector<int> system,
int flav=0);
657 bool connectRadiator( Particle& radiator,
const int radType,
658 const Particle& recoiler,
const int recType,
659 const Event& event );
675 int FindCol(
int col,
int iExclude1,
int iExclude2,
676 const Event& event,
int type,
bool isHardIn);
684 int FindParticle(
const Particle& particle,
const Event& event,
685 bool checkStatus =
true );
692 bool allowedClustering(
int rad,
int emt,
int rec,
int partner,
693 const Event& event );
700 bool isSinglett(
int rad,
int emt,
int rec,
const Event& event );
708 bool validEvent(
const Event& event );
712 bool equalClustering( Clustering clus1 , Clustering clus2 );
717 double choseHardScale(
const Event& event )
const;
721 int getCurrentFlav(
const int)
const;
725 double getCurrentX(
const int)
const;
727 double getCurrentZ(
const int rad,
const int rec,
const int emt,
728 int idRadBef = 0)
const;
731 double pTLund(
const Event& event,
int radAfterBranch,
int emtAfterBranch,
732 int recAfterBranch,
int showerType,
int idRadBef = 0);
736 int posChangedIncoming(
const Event& event,
bool before);
742 double pdfFactor(
const Event& event,
const int type,
double pdfScale,
748 double integrand(
int flav,
double x,
double scaleInt,
double z);
752 vector<int> posFlavCKM(
int flav);
757 bool checkFlavour(vector<int>& flavCounts,
int flavRad,
int flavRadBef,
761 bool checkWeakRecoils(map<int,int> &allowedRecoils,
bool isFirst =
false);
765 int findISRRecoiler();
770 void reverseBoostISR(Vec4& pMother, Vec4& pSister, Vec4& pPartner,
771 Vec4& pDaughter, Vec4& pRecoiler,
int sign,
double eCM,
double& phi);
775 bool isQCD2to2(
const Event& event);
779 bool isEW2to1(
const Event& event);
782 void setSelectedChild();
785 void setupSimpleWeakShower(
int nSteps);
788 void transferSimpleWeakShower(vector<int> &mode, vector<Vec4> &mom,
789 vector<int> fermionLines, vector<pair<int,int> > &dipoles,
int nSteps);
792 vector<int> updateWeakModes(vector<int>& weakModes,
793 map<int,int>& stateTransfer);
797 vector<int> updateWeakFermionLines(vector<int> fermionLines,
798 map<int,int>& stateTransfer);
801 vector<pair<int,int> > updateWeakDipoles(vector<pair<int,int> > &dipoles,
802 map<int,int>& stateTransfer);
806 void setupWeakHard(vector<int>& mode, vector<int>& fermionLines,
810 double getShowerPluginScale(
const Event& event,
int rad,
int emt,
int rec,
811 string key,
double scalePythia);
828 vector<History *> children;
836 map<double,History *> paths;
845 map<double,History *> goodBranches, badBranches;
848 double sumGoodBranches, sumBadBranches;
852 bool foundOrderedPath;
856 bool foundStronglyOrderedPath;
860 bool foundAllowedPath;
864 bool foundCompletePath;
880 Clustering clusterIn;
881 int iReclusteredOld, iReclusteredNew;
887 MergingHooksPtr mergingHooksPtr;
890 History() : mother(), selectedChild(), sumpath(), sumGoodBranches(),
891 sumBadBranches(), foundOrderedPath(), foundStronglyOrderedPath(),
892 foundAllowedPath(), foundCompletePath(), scale(), nextInInput(), prob(),
893 iReclusteredOld(), iReclusteredNew(), doInclude(), mergingHooksPtr(),
894 particleDataPtr(), infoPtr(), showers(), coupSMPtr(), sumScalarPT(),
895 probMaxSave(), depth(), minDepthSave() {}
898 History(
const History &) {}
901 History & operator=(
const History &) {
910 ParticleData* particleDataPtr;
916 SimpleWeakShowerMEs simpleWeakShowerMEs;
919 PartonLevel* showers;
929 if (mother)
return mother->probMax();
932 void updateProbMax(
double probIn,
bool isComplete =
false) {
933 if (mother) mother->updateProbMax(probIn, isComplete);
934 if (!isComplete && !foundCompletePath)
return;
935 if (abs(probIn) > probMaxSave) probMaxSave = probIn;
938 int depth, minDepthSave;
940 if ( mother )
return mother->minDepth();
943 void updateMinDepth(
int depthIn) {
944 if ( mother )
return mother->updateMinDepth(depthIn);
945 minDepthSave = (minDepthSave>0) ? min(minDepthSave,depthIn) : depthIn;
954 #endif // end Pythia8_History_H