13 #ifndef Pythia8_MergingHooks_H
14 #define Pythia8_MergingHooks_H
16 #include "Pythia8/Basics.h"
17 #include "Pythia8/BeamParticle.h"
18 #include "Pythia8/Event.h"
19 #include "Pythia8/Info.h"
20 #include "Pythia8/ParticleData.h"
21 #include "Pythia8/PartonSystems.h"
22 #include "Pythia8/PhysicsBase.h"
23 #include "Pythia8/PythiaStdlib.h"
24 #include "Pythia8/Settings.h"
47 vector<int> hardOutgoing1;
48 vector<int> hardOutgoing2;
50 vector<int> hardIntermediate;
55 vector<int> PosOutgoing1;
56 vector<int> PosOutgoing2;
58 vector<int> PosIntermediate;
64 HardProcess() : hardIncoming1(), hardIncoming2(), tms(){}
66 virtual ~HardProcess(){}
69 HardProcess(
const HardProcess& hardProcessIn )
70 : state(hardProcessIn.state),
71 tms(hardProcessIn.tms) {
72 hardIncoming1 = hardProcessIn.hardIncoming1;
73 hardIncoming2 = hardProcessIn.hardIncoming2;
74 for(
int i =0; i < int(hardProcessIn.hardOutgoing1.size());++i)
75 hardOutgoing1.push_back( hardProcessIn.hardOutgoing1[i]);
76 for(
int i =0; i < int(hardProcessIn.hardOutgoing2.size());++i)
77 hardOutgoing2.push_back( hardProcessIn.hardOutgoing2[i]);
78 for(
int i =0; i < int(hardProcessIn.hardIntermediate.size());++i)
79 hardIntermediate.push_back( hardProcessIn.hardIntermediate[i]);
80 for(
int i =0; i < int(hardProcessIn.PosOutgoing1.size());++i)
81 PosOutgoing1.push_back( hardProcessIn.PosOutgoing1[i]);
82 for(
int i =0; i < int(hardProcessIn.PosOutgoing2.size());++i)
83 PosOutgoing2.push_back( hardProcessIn.PosOutgoing2[i]);
84 for(
int i =0; i < int(hardProcessIn.PosIntermediate.size());++i)
85 PosIntermediate.push_back( hardProcessIn.PosIntermediate[i]);
89 HardProcess(
string LHEfile, ParticleData* particleData) : hardIncoming1(),
90 hardIncoming2(), tms() {
92 state.init(
"(hard process)", particleData);
93 translateLHEFString(LHEfile);
97 virtual void initOnProcess(
string process, ParticleData* particleData);
100 void initOnLHEF(
string LHEfile, ParticleData* particleData);
103 void translateLHEFString(
string LHEpath);
106 virtual void translateProcessString(
string process);
113 virtual bool allowCandidates(
int iPos, vector<int> Pos1, vector<int> Pos2,
116 virtual void storeCandidates(
const Event& event,
string process);
119 virtual bool matchesAnyOutgoing(
int iPos,
const Event& event);
123 virtual bool findOtherCandidates(
int iPos,
const Event& event,
126 virtual bool exchangeCandidates( vector<int> candidates1,
127 vector<int> candidates2,
128 unordered_map<int,int> further1, unordered_map<int,int> further2);
148 int hasResInCurrent();
158 void listCandidates()
const;
166 class MergingHooks :
public PhysicsBase {
171 MergingHooks() : useShowerPluginSave(), showers(),
172 doUserMergingSave(false),
173 doMGMergingSave(false),
174 doKTMergingSave(false),
175 doPTLundMergingSave(false),
176 doCutBasedMergingSave(false), includeMassiveSave(),
177 enforceStrongOrderingSave(),
178 orderInRapiditySave(), pickByFullPSave(), pickByPoPT2Save(),
179 includeRedundantSave(), pickBySumPTSave(), allowColourShufflingSave(),
180 resetHardQRenSave(), resetHardQFacSave(), unorderedScalePrescipSave(),
181 unorderedASscalePrescipSave(), unorderedPDFscalePrescipSave(),
182 incompleteScalePrescipSave(), ktTypeSave(), nReclusterSave(),
183 nQuarksMergeSave(), nRequestedSave(), scaleSeparationFactorSave(),
184 nonJoinedNormSave(), fsrInRecNormSave(), herwigAcollFSRSave(),
185 herwigAcollISRSave(), pT0ISRSave(), pTcutSave(),
186 doNL3TreeSave(false),
187 doNL3LoopSave(false),
188 doNL3SubtSave(false),
189 doUNLOPSTreeSave(false),
190 doUNLOPSLoopSave(false),
191 doUNLOPSSubtSave(false),
192 doUNLOPSSubtNLOSave(false),
193 doUMEPSTreeSave(false),
194 doUMEPSSubtSave(false),
195 doEstimateXSection(false), applyVeto(),
196 doRemoveDecayProducts(false), muMISave(), kFactor0jSave(), kFactor1jSave(),
197 kFactor2jSave(), tmsValueSave(), tmsValueNow(), DparameterSave(),
198 nJetMaxSave(), nJetMaxNLOSave(),
199 doOrderHistoriesSave(true),
200 doCutOnRecStateSave(false),
201 doWeakClusteringSave(false),
202 doSQCDClusteringSave(false), muFSave(), muRSave(), muFinMESave(),
204 doIgnoreEmissionsSave(true),
205 doIgnoreStepSave(true), pTsave(), weightCKKWL1Save(), weightCKKWL2Save(),
206 nMinMPISave(), weightCKKWLSave(), weightFIRSTSave(), nJetMaxLocal(),
208 hasJetMaxLocal(false),
209 includeWGTinXSECSave(false), nHardNowSave(), nJetNowSave(),
210 tmsHardNowSave(), tmsNowSave() {
211 inputEvent =
Event(); resonances.resize(0);
212 useOwnHardProcess =
false; hardProcess = 0; stopScaleSave= 0.0; }
215 friend class History;
219 friend class PartonLevel;
221 friend class SpaceShower;
223 friend class TimeShower;
225 friend class Merging;
232 virtual ~MergingHooks();
234 virtual double tmsDefinition(
const Event& event){
return event[0].e();}
237 virtual double dampenIfFailCuts(
const Event& inEvent ) {
239 if(
false) cout << inEvent[0].e();
245 virtual bool canCutOnRecState() {
return doCutOnRecStateSave; }
250 virtual bool doCutOnRecState(
const Event& event ) {
252 if(
false) cout <<
event[0].e();
255 for(
int i=0; i < int(event.size()); ++i)
256 if( event[i].isFinal()
257 && (
event[i].isGluon() ||
event[i].isQuark()) )
260 if( hasEffectiveG2EW() && nPartons < 2){
261 if(event[3].
id() != 21 &&
event[4].id() != 21)
267 virtual bool canVetoTrialEmission() {
return false;}
269 virtual bool doVetoTrialEmission(
const Event&,
const Event& ) {
273 virtual double hardProcessME(
const Event& inEvent ) {
275 if (
false ) cout << inEvent[0].e();
288 if(doCutBasedMergingSave)
return 0.;
290 else return tmsValueNow;
293 if(doCutBasedMergingSave)
return 0.;
294 else return tmsValueSave;
296 void tms(
double tmsIn ) { tmsValueNow = tmsIn; }
301 return ((tmsListSave.size() == 3) ? tmsListSave[0] : 0.);
306 return ((tmsListSave.size() == 3) ? tmsListSave[1] : 0.);
311 return ((tmsListSave.size() == 3) ? tmsListSave[2] : 0.);
314 int nMaxJets() {
return (hasJetMaxLocal) ? nJetMaxLocal : nJetMaxSave;}
318 {
return (hasJetMaxLocal) ? nJetMaxNLOLocal : nJetMaxNLOSave;}
320 string getProcessString() {
return processNow;}
322 int nHardOutPartons(){
return hardProcess->nQuarksOut();}
324 int nHardOutLeptons(){
return hardProcess->nLeptonOut();}
327 int nHardOutBosons(){
return hardProcess->nBosonsOut();}
330 int nHardInPartons(){
return hardProcess->nQuarksIn();}
332 int nHardInLeptons(){
return hardProcess->nLeptonIn();}
335 int nResInCurrent(){
return hardProcess->nResInCurrent();}
337 bool doUserMerging(){
return doUserMergingSave;}
339 bool doMGMerging() {
return doMGMergingSave;}
341 bool doKTMerging() {
return doKTMergingSave;}
343 bool doPTLundMerging() {
return doPTLundMergingSave;}
345 bool doCutBasedMerging() {
return doCutBasedMergingSave;}
346 bool doCKKWLMerging() {
return (doUserMergingSave || doMGMergingSave
347 || doKTMergingSave || doPTLundMergingSave || doCutBasedMergingSave); }
350 bool doUMEPSTree() {
return doUMEPSTreeSave;}
351 bool doUMEPSSubt() {
return doUMEPSSubtSave;}
352 bool doUMEPSMerging() {
return (doUMEPSTreeSave || doUMEPSSubtSave);}
355 bool doNL3Tree() {
return doNL3TreeSave;}
356 bool doNL3Loop() {
return doNL3LoopSave;}
357 bool doNL3Subt() {
return doNL3SubtSave;}
358 bool doNL3Merging() {
return (doNL3TreeSave || doNL3LoopSave
362 bool doUNLOPSTree() {
return doUNLOPSTreeSave;}
363 bool doUNLOPSLoop() {
return doUNLOPSLoopSave;}
364 bool doUNLOPSSubt() {
return doUNLOPSSubtSave;}
365 bool doUNLOPSSubtNLO() {
return doUNLOPSSubtNLOSave;}
366 bool doUNLOPSMerging() {
return (doUNLOPSTreeSave || doUNLOPSLoopSave
367 || doUNLOPSSubtSave || doUNLOPSSubtNLOSave); }
369 int nRecluster() {
return nReclusterSave;}
372 int nRequested() {
return nRequestedSave;}
380 bool isFirstEmission(
const Event& event);
383 bool hasEffectiveG2EW() {
384 if ( getProcessString().compare(
"pp>h") == 0 )
return true;
388 bool allowEffectiveVertex( vector<int> in, vector<int> out) {
389 if ( getProcessString().compare(
"ta+ta->jj") == 0
390 || getProcessString().compare(
"ta-ta+>jj") == 0 ) {
391 int nInFermions(0), nOutFermions(0), nOutBosons(0);
392 for (
int i=0; i < int(in.size()); ++i)
393 if (abs(in[i])<20) nInFermions++;
394 for (
int i=0; i < int(out.size()); ++i) {
395 if (abs(out[i])<20) nOutFermions++;
396 if (abs(out[i])>20) nOutBosons++;
398 return (nInFermions%2==0 && nOutFermions%2==0);
404 Event bareEvent(
const Event& inputEventIn,
bool storeInputEvent );
406 bool reattachResonanceDecays(
Event& process );
409 bool isInHard(
int iPos,
const Event& event);
412 virtual int getNumberOfClusteringSteps(
const Event& event,
413 bool resetNjetMax =
false);
422 void orderHistories(
bool doOrderHistoriesIn) {
423 doOrderHistoriesSave = doOrderHistoriesIn; }
426 void allowCutOnRecState(
bool doCutOnRecStateIn) {
427 doCutOnRecStateSave = doCutOnRecStateIn; }
430 void doWeakClustering(
bool doWeakClusteringIn ) {
431 doWeakClusteringSave = doWeakClusteringIn; }
439 bool checkAgainstCut(
const Particle& particle);
442 virtual double tmsNow(
const Event& event );
444 double rhoms(
const Event& event,
bool withColour);
446 double kTms(
const Event & event);
449 double cutbasedms(
const Event& event );
456 void doIgnoreEmissions(
bool doIgnoreIn ) {
457 doIgnoreEmissionsSave = doIgnoreIn;
460 virtual bool canVetoEmission() {
return !doIgnoreEmissionsSave; }
462 virtual bool doVetoEmission(
const Event& );
468 bool useShowerPluginSave;
469 virtual bool useShowerPlugin() {
return useShowerPluginSave; }
476 bool includeWGTinXSEC() {
return includeWGTinXSECSave;}
482 int nHardNow() {
return nHardNowSave; }
483 double tmsHardNow() {
return tmsHardNowSave; }
484 int nJetsNow() {
return nJetNowSave; }
485 double tmsNow() {
return tmsNowSave;}
487 void setHardProcessPtr(HardProcess* hardProcIn) { hardProcess = hardProcIn; }
493 int nMuRVar() {
return muRVarFactors.size(); }
494 void printIndividualWeights();
501 bool useOwnHardProcess;
502 HardProcess* hardProcess;
504 PartonLevel* showers;
505 void setShowerPointer(PartonLevel* psIn ) {showers = psIn;}
508 AlphaStrong AlphaS_FSRSave;
509 AlphaStrong AlphaS_ISRSave;
510 AlphaEM AlphaEM_FSRSave;
511 AlphaEM AlphaEM_ISRSave;
517 bool doUserMergingSave, doMGMergingSave, doKTMergingSave,
518 doPTLundMergingSave, doCutBasedMergingSave,
519 includeMassiveSave, enforceStrongOrderingSave, orderInRapiditySave,
520 pickByFullPSave, pickByPoPT2Save, includeRedundantSave,
521 pickBySumPTSave, allowColourShufflingSave, resetHardQRenSave,
523 int unorderedScalePrescipSave, unorderedASscalePrescipSave,
524 unorderedPDFscalePrescipSave, incompleteScalePrescipSave,
525 ktTypeSave, nReclusterSave, nQuarksMergeSave, nRequestedSave;
527 double scaleSeparationFactorSave, nonJoinedNormSave,
528 fsrInRecNormSave, herwigAcollFSRSave, herwigAcollISRSave,
529 pT0ISRSave, pTcutSave;
530 bool doNL3TreeSave, doNL3LoopSave, doNL3SubtSave;
531 bool doUNLOPSTreeSave, doUNLOPSLoopSave, doUNLOPSSubtSave,
533 bool doUMEPSTreeSave, doUMEPSSubtSave;
536 bool doEstimateXSection;
542 vector< pair<int,int> > resonances;
543 bool doRemoveDecayProducts;
549 double kFactor0jSave;
550 double kFactor1jSave;
551 double kFactor2jSave;
554 double tmsValueSave, tmsValueNow, DparameterSave;
558 string processSave, processNow;
564 vector<double> tmsListSave;
568 bool doOrderHistoriesSave;
573 bool doCutOnRecStateSave;
576 bool doWeakClusteringSave, doSQCDClusteringSave;
587 bool doIgnoreEmissionsSave;
589 bool doIgnoreStepSave;
592 vector<double> weightCKKWL1Save, weightCKKWL2Save;
595 vector<double> weightCKKWLSave, weightFIRSTSave;
599 vector<double> wtSave;
600 vector<double> pdfWeightSave;
601 vector<double> mpiWeightSave;
602 vector<double> asWeightSave;
603 vector<double> aemWeightSave;
604 vector<double> bornAsVarFac;
612 vector<double> muRVarFactors;
623 bool includeWGTinXSECSave;
624 int nHardNowSave, nJetNowSave;
625 double tmsHardNowSave, tmsNowSave;
633 void storeHardProcessCandidates(
const Event& event){
634 hardProcess->storeCandidates(event,getProcessString());
643 void setLHEInputFile(
string lheFile) {
644 lheInputFile = lheFile.substr(0,lheFile.size()-6); }
651 AlphaStrong* AlphaS_FSR() {
return &AlphaS_FSRSave;}
652 AlphaStrong* AlphaS_ISR() {
return &AlphaS_ISRSave;}
653 AlphaEM* AlphaEM_FSR() {
return &AlphaEM_FSRSave;}
654 AlphaEM* AlphaEM_ISR() {
return &AlphaEM_ISRSave;}
658 bool includeMassive() {
return includeMassiveSave;}
660 bool enforceStrongOrdering() {
return enforceStrongOrderingSave;}
662 bool orderInRapidity() {
return orderInRapiditySave;}
664 bool pickByFull() {
return pickByFullPSave;}
666 bool pickByPoPT2() {
return pickByPoPT2Save;}
668 bool includeRedundant(){
return includeRedundantSave;}
670 bool pickBySumPT(){
return pickBySumPTSave;}
675 int unorderedScalePrescip() {
return unorderedScalePrescipSave;}
679 int unorderedASscalePrescip() {
return unorderedASscalePrescipSave;}
684 int unorderedPDFscalePrescip() {
return unorderedPDFscalePrescipSave;}
689 int incompleteScalePrescip() {
return incompleteScalePrescipSave;}
692 bool allowColourShuffling() {
return allowColourShufflingSave;}
695 bool resetHardQRen() {
return resetHardQRenSave; }
697 bool resetHardQFac() {
return resetHardQFacSave; }
701 double scaleSeparationFactor() {
return scaleSeparationFactorSave;}
704 double nonJoinedNorm() {
return nonJoinedNormSave;}
707 double fsrInRecNorm() {
return fsrInRecNormSave;}
710 double herwigAcollFSR() {
return herwigAcollFSRSave;}
713 double herwigAcollISR() {
return herwigAcollISRSave;}
715 double pT0ISR() {
return pT0ISRSave;}
717 double pTcut() {
return pTcutSave;}
720 void muMI(
double mu) { muMISave = mu; }
721 double muMI() {
return muMISave;}
724 double kFactor(
int njet = 0) {
725 return (njet == 0) ? kFactor0jSave
726 :(njet == 1) ? kFactor1jSave
730 double k1Factor(
int njet = 0) {
731 return (kFactor(njet) - 1)/infoPtr->alphaS();
736 bool orderHistories() {
return doOrderHistoriesSave;}
741 bool allowCutOnRecState() {
return doCutOnRecStateSave;}
744 bool doWeakClustering() {
return doWeakClusteringSave;}
746 bool doSQCDClustering() {
return doSQCDClusteringSave;}
749 double muF() {
return (muFSave > 0.) ? muFSave : infoPtr->QFac();}
750 double muR() {
return (muRSave > 0.) ? muRSave : infoPtr->QRen();}
754 string mus = infoPtr->getEventAttribute(
"muf2",
true);
755 double mu = (mus.empty()) ? 0. : atof((
char*)mus.c_str());
758 if (infoPtr->scales) mu = infoPtr->getScalesAttribute(
"muf");
759 return (mu > 0.) ? mu : (muFinMESave > 0.) ? muFinMESave
764 string mus = infoPtr->getEventAttribute(
"mur2",
true);
765 double mu = (mus.empty()) ? 0. : atof((
char*)mus.c_str());
768 if (infoPtr->scales) mu = infoPtr->getScalesAttribute(
"mur");
769 return (mu > 0.) ? mu : (muRinMESave > 0.) ? muRinMESave
779 void doIgnoreStep(
bool doIgnoreIn) {doIgnoreStepSave = doIgnoreIn;}
781 virtual bool canVetoStep() {
return !doIgnoreStepSave;}
784 void storeWeights(vector<double> weight) {
785 weightCKKWL1Save = weightCKKWL2Save = weight;}
788 virtual bool doVetoStep(
const Event& process,
const Event& event,
789 bool doResonance =
false);
792 virtual bool setShowerStartingScales(
bool isTrial,
bool doMergeFirstEmm,
793 double& pTscaleIn,
const Event& event,
794 double& pTmaxFSRIn,
bool& limitPTmaxFSRin,
795 double& pTmaxISRIn,
bool& limitPTmaxISRin,
796 double& pTmaxMPIIn,
bool& limitPTmaxMPIin );
800 double stopScaleSave;
801 void setShowerStoppingScale(
double scale = 0.) {stopScaleSave = scale;}
802 double getShowerStoppingScale() {
return stopScaleSave;}
804 void nMinMPI(
int nMinMPIIn) {nMinMPISave = nMinMPIIn; }
805 int nMinMPI() {
return nMinMPISave;}
812 double kTdurham(
const Particle& RadAfterBranch,
813 const Particle& EmtAfterBranch,
int Type,
double D );
815 double rhoPythia(
const Event& event,
int rad,
int emt,
int rec,
820 int findColour(
int col,
int iExclude1,
int iExclude2,
821 const Event& event,
int type,
bool isHardIn);
823 double deltaRij(Vec4 jet1, Vec4 jet2);
830 double getWeightNLO(
int i=0) {
return (weightCKKWLSave[i]
831 - weightFIRSTSave[i]);}
833 vector<double> getWeightCKKWL() {
return weightCKKWLSave; }
835 vector<double> getWeightFIRST() {
return weightFIRSTSave; }
837 void setWeightCKKWL( vector<double> weightIn){
838 weightCKKWLSave = weightIn;
839 if ( !includeWGTinXSEC() ) infoPtr->weightContainerPtr
840 ->weightsMerging.setValueVector(weightIn); }
842 void setWeightFIRST( vector<double> weightIn){
843 weightFIRSTSave = weightIn;
844 infoPtr->weightContainerPtr->weightsMerging
845 .setValueFirstVector(weightIn); }
849 vector<double> getSudakovWeight() {
850 vector<double> ret = individualWeights.wtSave;
851 for (
int i = 0; i < nWgts; ++i) {
852 ret[i] *= individualWeights.pdfWeightSave[i] *
853 individualWeights.mpiWeightSave[i];
858 vector<double> getCouplingWeight() {
859 vector<double> ret = individualWeights.asWeightSave;
860 for (
int i = 0; i < nWgts; ++i) {
861 ret[i] *= individualWeights.aemWeightSave[i];
875 void setEventVetoInfo(
int nJetNowIn,
double tmsNowIn) {
876 nJetNowSave = nJetNowIn; tmsNowSave = tmsNowIn; }
879 void setHardProcessInfo(
int nHardNowIn,
double tmsHardNowIn) {
880 nHardNowSave = nHardNowIn; tmsHardNowSave = tmsHardNowIn; }
888 #endif // Pythia8_MergingHooks_H