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/PythiaStdlib.h"
23 #include "Pythia8/Settings.h"
46 vector<int> hardOutgoing1;
47 vector<int> hardOutgoing2;
49 vector<int> hardIntermediate;
54 vector<int> PosOutgoing1;
55 vector<int> PosOutgoing2;
57 vector<int> PosIntermediate;
65 virtual ~HardProcess(){}
68 HardProcess(
const HardProcess& hardProcessIn )
69 : state(hardProcessIn.state),
70 tms(hardProcessIn.tms) {
71 hardIncoming1 = hardProcessIn.hardIncoming1;
72 hardIncoming2 = hardProcessIn.hardIncoming2;
73 for(
int i =0; i < int(hardProcessIn.hardOutgoing1.size());++i)
74 hardOutgoing1.push_back( hardProcessIn.hardOutgoing1[i]);
75 for(
int i =0; i < int(hardProcessIn.hardOutgoing2.size());++i)
76 hardOutgoing2.push_back( hardProcessIn.hardOutgoing2[i]);
77 for(
int i =0; i < int(hardProcessIn.hardIntermediate.size());++i)
78 hardIntermediate.push_back( hardProcessIn.hardIntermediate[i]);
79 for(
int i =0; i < int(hardProcessIn.PosOutgoing1.size());++i)
80 PosOutgoing1.push_back( hardProcessIn.PosOutgoing1[i]);
81 for(
int i =0; i < int(hardProcessIn.PosOutgoing2.size());++i)
82 PosOutgoing2.push_back( hardProcessIn.PosOutgoing2[i]);
83 for(
int i =0; i < int(hardProcessIn.PosIntermediate.size());++i)
84 PosIntermediate.push_back( hardProcessIn.PosIntermediate[i]);
88 HardProcess(
string LHEfile, ParticleData* particleData) {
90 state.init(
"(hard process)", particleData);
91 translateLHEFString(LHEfile);
95 virtual void initOnProcess(
string process, ParticleData* particleData);
98 void initOnLHEF(
string LHEfile, ParticleData* particleData);
101 void translateLHEFString(
string LHEpath);
104 virtual void translateProcessString(
string process);
111 virtual bool allowCandidates(
int iPos, vector<int> Pos1, vector<int> Pos2,
114 virtual void storeCandidates(
const Event& event,
string process);
117 virtual bool matchesAnyOutgoing(
int iPos,
const Event& event);
121 virtual bool findOtherCandidates(
int iPos,
const Event& event,
124 virtual bool exchangeCandidates( vector<int> candidates1,
125 vector<int> candidates2, map<int,int> further1, map<int,int> further2);
145 int hasResInCurrent();
155 void listCandidates()
const;
169 doUserMergingSave(false),
170 doMGMergingSave(false),
171 doKTMergingSave(false),
172 doPTLundMergingSave(false),
173 doCutBasedMergingSave(false),
174 doNL3TreeSave(false),
175 doNL3LoopSave(false),
176 doNL3SubtSave(false),
177 doUNLOPSTreeSave(false),
178 doUNLOPSLoopSave(false),
179 doUNLOPSSubtSave(false),
180 doUNLOPSSubtNLOSave(false),
181 doUMEPSTreeSave(false),
182 doUMEPSSubtSave(false),
183 doEstimateXSection(false),
184 doRemoveDecayProducts(false),
185 doOrderHistoriesSave(true),
186 doCutOnRecStateSave(false),
187 doWeakClusteringSave(false),
188 doSQCDClusteringSave(false),
189 doIgnoreEmissionsSave(true),
190 doIgnoreStepSave(true),
191 hasJetMaxLocal(false),
192 includeWGTinXSECSave(false) {
193 inputEvent =
Event(); resonances.resize(0); infoPtr = 0; settingsPtr = 0;
194 particleDataPtr = 0; partonSystemsPtr = 0; useOwnHardProcess =
false;
195 hardProcess = 0; stopScaleSave= 0.0; }
198 friend class History;
202 friend class PartonLevel;
204 friend class SpaceShower;
206 friend class TimeShower;
208 friend class Merging;
215 virtual ~MergingHooks();
217 virtual double tmsDefinition(
const Event& event){
return event[0].e();}
220 virtual double dampenIfFailCuts(
const Event& inEvent ) {
222 if(
false) cout << inEvent[0].e();
228 virtual bool canCutOnRecState() {
return doCutOnRecStateSave; }
233 virtual bool doCutOnRecState(
const Event& event ) {
235 if(
false) cout <<
event[0].e();
238 for(
int i=0; i < int(event.size()); ++i)
239 if( event[i].isFinal()
240 && (
event[i].isGluon() ||
event[i].isQuark()) )
243 if( hasEffectiveG2EW() && nPartons < 2){
244 if(event[3].
id() != 21 &&
event[4].id() != 21)
250 virtual bool canVetoTrialEmission() {
return false;}
252 virtual bool doVetoTrialEmission(
const Event&,
const Event& ) {
256 virtual double hardProcessME(
const Event& inEvent ) {
258 if (
false ) cout << inEvent[0].e();
266 void initPtr( Settings* settingsPtrIn, Info* infoPtrIn,
267 ParticleData* particleDataPtrIn, PartonSystems* partonSystemsPtrIn)
268 { settingsPtr = settingsPtrIn; infoPtr = infoPtrIn;
269 particleDataPtr = particleDataPtrIn;
270 partonSystemsPtr = partonSystemsPtrIn;}
278 if(doCutBasedMergingSave)
return 0.;
280 else return tmsValueNow;
283 if(doCutBasedMergingSave)
return 0.;
284 else return tmsValueSave;
286 void tms(
double tmsIn ) { tmsValueNow = tmsIn; }
291 return ((tmsListSave.size() == 3) ? tmsListSave[0] : 0.);
296 return ((tmsListSave.size() == 3) ? tmsListSave[1] : 0.);
301 return ((tmsListSave.size() == 3) ? tmsListSave[2] : 0.);
304 int nMaxJets() {
return (hasJetMaxLocal) ? nJetMaxLocal : nJetMaxSave;}
308 {
return (hasJetMaxLocal) ? nJetMaxNLOLocal : nJetMaxNLOSave;}
310 string getProcessString() {
return processSave;}
312 int nHardOutPartons(){
return hardProcess->nQuarksOut();}
314 int nHardOutLeptons(){
return hardProcess->nLeptonOut();}
317 int nHardOutBosons(){
return hardProcess->nBosonsOut();}
320 int nHardInPartons(){
return hardProcess->nQuarksIn();}
322 int nHardInLeptons(){
return hardProcess->nLeptonIn();}
325 int nResInCurrent(){
return hardProcess->nResInCurrent();}
327 bool doUserMerging(){
return doUserMergingSave;}
329 bool doMGMerging() {
return doMGMergingSave;}
331 bool doKTMerging() {
return doKTMergingSave;}
333 bool doPTLundMerging() {
return doPTLundMergingSave;}
335 bool doCutBasedMerging() {
return doCutBasedMergingSave;}
336 bool doCKKWLMerging() {
return (doUserMergingSave || doMGMergingSave
337 || doKTMergingSave || doPTLundMergingSave || doCutBasedMergingSave); }
340 bool doUMEPSTree() {
return doUMEPSTreeSave;}
341 bool doUMEPSSubt() {
return doUMEPSSubtSave;}
342 bool doUMEPSMerging() {
return (doUMEPSTreeSave || doUMEPSSubtSave);}
345 bool doNL3Tree() {
return doNL3TreeSave;}
346 bool doNL3Loop() {
return doNL3LoopSave;}
347 bool doNL3Subt() {
return doNL3SubtSave;}
348 bool doNL3Merging() {
return (doNL3TreeSave || doNL3LoopSave
352 bool doUNLOPSTree() {
return doUNLOPSTreeSave;}
353 bool doUNLOPSLoop() {
return doUNLOPSLoopSave;}
354 bool doUNLOPSSubt() {
return doUNLOPSSubtSave;}
355 bool doUNLOPSSubtNLO() {
return doUNLOPSSubtNLOSave;}
356 bool doUNLOPSMerging() {
return (doUNLOPSTreeSave || doUNLOPSLoopSave
357 || doUNLOPSSubtSave || doUNLOPSSubtNLOSave); }
359 int nRecluster() {
return nReclusterSave;}
362 int nRequested() {
return nRequestedSave;}
370 bool isFirstEmission(
const Event& event);
373 bool hasEffectiveG2EW() {
374 if ( getProcessString().compare(
"pp>h") == 0 )
return true;
378 bool allowEffectiveVertex( vector<int> in, vector<int> out) {
379 if ( getProcessString().compare(
"ta+ta->jj") == 0
380 || getProcessString().compare(
"ta-ta+>jj") == 0 ) {
381 int nInFermions(0), nOutFermions(0), nOutBosons(0);
382 for (
int i=0; i < int(in.size()); ++i)
383 if (abs(in[i])<20) nInFermions++;
384 for (
int i=0; i < int(out.size()); ++i) {
385 if (abs(out[i])<20) nOutFermions++;
386 if (abs(out[i])>20) nOutBosons++;
388 return (nInFermions%2==0 && nOutFermions%2==0);
394 Event bareEvent(
const Event& inputEventIn,
bool storeInputEvent );
396 bool reattachResonanceDecays(
Event& process );
399 bool isInHard(
int iPos,
const Event& event);
402 virtual int getNumberOfClusteringSteps(
const Event& event,
403 bool resetNjetMax =
false);
412 void orderHistories(
bool doOrderHistoriesIn) {
413 doOrderHistoriesSave = doOrderHistoriesIn; }
416 void allowCutOnRecState(
bool doCutOnRecStateIn) {
417 doCutOnRecStateSave = doCutOnRecStateIn; }
420 void doWeakClustering(
bool doWeakClusteringIn ) {
421 doWeakClusteringSave = doWeakClusteringIn; }
429 bool checkAgainstCut(
const Particle& particle);
432 virtual double tmsNow(
const Event& event );
434 double rhoms(
const Event& event,
bool withColour);
436 double kTms(
const Event & event);
439 double cutbasedms(
const Event& event );
446 void doIgnoreEmissions(
bool doIgnoreIn ) {
447 doIgnoreEmissionsSave = doIgnoreIn;
450 virtual bool canVetoEmission() {
return !doIgnoreEmissionsSave; }
452 virtual bool doVetoEmission(
const Event& );
458 bool useShowerPluginSave;
459 virtual bool useShowerPlugin() {
return useShowerPluginSave; }
466 bool includeWGTinXSEC() {
return includeWGTinXSECSave;}
472 int nHardNow() {
return nHardNowSave; }
473 double tmsHardNow() {
return tmsHardNowSave; }
474 int nJetsNow() {
return nJetNowSave; }
475 double tmsNow() {
return tmsNowSave;}
477 void setHardProcessPtr(HardProcess* hardProcIn) { hardProcess = hardProcIn; }
484 bool useOwnHardProcess;
485 HardProcess* hardProcess;
490 Settings* settingsPtr;
493 ParticleData* particleDataPtr;
496 PartonSystems* partonSystemsPtr;
498 PartonLevel* showers;
499 void setShowerPointer(PartonLevel* psIn ) {showers = psIn;}
502 AlphaStrong AlphaS_FSRSave;
503 AlphaStrong AlphaS_ISRSave;
504 AlphaEM AlphaEM_FSRSave;
505 AlphaEM AlphaEM_ISRSave;
511 bool doUserMergingSave, doMGMergingSave, doKTMergingSave,
512 doPTLundMergingSave, doCutBasedMergingSave,
513 includeMassiveSave, enforceStrongOrderingSave, orderInRapiditySave,
514 pickByFullPSave, pickByPoPT2Save, includeRedundantSave,
515 pickBySumPTSave, allowColourShufflingSave, resetHardQRenSave,
517 int unorderedScalePrescipSave, unorderedASscalePrescipSave,
518 unorderedPDFscalePrescipSave, incompleteScalePrescipSave,
519 ktTypeSave, nReclusterSave, nQuarksMergeSave, nRequestedSave;
521 double scaleSeparationFactorSave, nonJoinedNormSave,
522 fsrInRecNormSave, herwigAcollFSRSave, herwigAcollISRSave,
523 pT0ISRSave, pTcutSave;
524 bool doNL3TreeSave, doNL3LoopSave, doNL3SubtSave;
525 bool doUNLOPSTreeSave, doUNLOPSLoopSave, doUNLOPSSubtSave,
527 bool doUMEPSTreeSave, doUMEPSSubtSave;
530 bool doEstimateXSection;
536 vector< pair<int,int> > resonances;
537 bool doRemoveDecayProducts;
543 double kFactor0jSave;
544 double kFactor1jSave;
545 double kFactor2jSave;
548 double tmsValueSave, tmsValueNow, DparameterSave;
558 vector<double> tmsListSave;
562 bool doOrderHistoriesSave;
567 bool doCutOnRecStateSave;
570 bool doWeakClusteringSave, doSQCDClusteringSave;
581 bool doIgnoreEmissionsSave;
583 bool doIgnoreStepSave;
586 double weightCKKWL1Save, weightCKKWL2Save;
589 double weightCKKWLSave, weightFIRSTSave;
598 bool includeWGTinXSECSave;
599 int nHardNowSave, nJetNowSave;
600 double tmsHardNowSave, tmsNowSave;
608 void storeHardProcessCandidates(
const Event& event){
609 hardProcess->storeCandidates(event,getProcessString());
618 void setLHEInputFile(
string lheFile) {
619 lheInputFile = lheFile.substr(0,lheFile.size()-6); }
626 AlphaStrong* AlphaS_FSR() {
return &AlphaS_FSRSave;}
627 AlphaStrong* AlphaS_ISR() {
return &AlphaS_ISRSave;}
628 AlphaEM* AlphaEM_FSR() {
return &AlphaEM_FSRSave;}
629 AlphaEM* AlphaEM_ISR() {
return &AlphaEM_ISRSave;}
633 bool includeMassive() {
return includeMassiveSave;}
635 bool enforceStrongOrdering() {
return enforceStrongOrderingSave;}
637 bool orderInRapidity() {
return orderInRapiditySave;}
639 bool pickByFull() {
return pickByFullPSave;}
641 bool pickByPoPT2() {
return pickByPoPT2Save;}
643 bool includeRedundant(){
return includeRedundantSave;}
645 bool pickBySumPT(){
return pickBySumPTSave;}
650 int unorderedScalePrescip() {
return unorderedScalePrescipSave;}
654 int unorderedASscalePrescip() {
return unorderedASscalePrescipSave;}
659 int unorderedPDFscalePrescip() {
return unorderedPDFscalePrescipSave;}
664 int incompleteScalePrescip() {
return incompleteScalePrescipSave;}
667 bool allowColourShuffling() {
return allowColourShufflingSave;}
670 bool resetHardQRen() {
return resetHardQRenSave; }
672 bool resetHardQFac() {
return resetHardQFacSave; }
676 double scaleSeparationFactor() {
return scaleSeparationFactorSave;}
679 double nonJoinedNorm() {
return nonJoinedNormSave;}
682 double fsrInRecNorm() {
return fsrInRecNormSave;}
685 double herwigAcollFSR() {
return herwigAcollFSRSave;}
688 double herwigAcollISR() {
return herwigAcollISRSave;}
690 double pT0ISR() {
return pT0ISRSave;}
692 double pTcut() {
return pTcutSave;}
695 void muMI(
double mu) { muMISave = mu; }
696 double muMI() {
return muMISave;}
699 double kFactor(
int njet = 0) {
700 return (njet == 0) ? kFactor0jSave
701 :(njet == 1) ? kFactor1jSave
705 double k1Factor(
int njet = 0) {
706 return (kFactor(njet) - 1)/infoPtr->alphaS();
711 bool orderHistories() {
return doOrderHistoriesSave;}
716 bool allowCutOnRecState() {
return doCutOnRecStateSave;}
719 bool doWeakClustering() {
return doWeakClusteringSave;}
721 bool doSQCDClustering() {
return doSQCDClusteringSave;}
724 double muF() {
return (muFSave > 0.) ? muFSave : infoPtr->QFac();}
725 double muR() {
return (muRSave > 0.) ? muRSave : infoPtr->QRen();}
729 string mus = infoPtr->getEventAttribute(
"muf2",
true);
730 double mu = (mus.empty()) ? 0. : atof((
char*)mus.c_str());
733 if (infoPtr->scales) mu = infoPtr->getScalesAttribute(
"muf");
734 return (mu > 0.) ? mu : (muFinMESave > 0.) ? muFinMESave : infoPtr->QFac();
738 string mus = infoPtr->getEventAttribute(
"mur2",
true);
739 double mu = (mus.empty()) ? 0. : atof((
char*)mus.c_str());
742 if (infoPtr->scales) mu = infoPtr->getScalesAttribute(
"mur");
743 return (mu > 0.) ? mu : (muRinMESave > 0.) ? muRinMESave : infoPtr->QRen();
752 void doIgnoreStep(
bool doIgnoreIn ) { doIgnoreStepSave = doIgnoreIn; }
754 virtual bool canVetoStep() {
return !doIgnoreStepSave; }
757 void storeWeights(
double weight ){ weightCKKWL1Save = weightCKKWL2Save
761 virtual bool doVetoStep(
const Event& process,
const Event& event,
762 bool doResonance =
false );
765 virtual bool setShowerStartingScales(
bool isTrial,
bool doMergeFirstEmm,
766 double& pTscaleIn,
const Event& event,
767 double& pTmaxFSRIn,
bool& limitPTmaxFSRin,
768 double& pTmaxISRIn,
bool& limitPTmaxISRin,
769 double& pTmaxMPIIn,
bool& limitPTmaxMPIin );
773 double stopScaleSave;
774 void setShowerStoppingScale(
double scale = 0.) { stopScaleSave = scale;}
775 double getShowerStoppingScale() {
return stopScaleSave;}
777 void nMinMPI(
int nMinMPIIn ) { nMinMPISave = nMinMPIIn; }
778 int nMinMPI() {
return nMinMPISave;}
785 double kTdurham(
const Particle& RadAfterBranch,
786 const Particle& EmtAfterBranch,
int Type,
double D );
788 double rhoPythia(
const Event& event,
int rad,
int emt,
int rec,
793 int findColour(
int col,
int iExclude1,
int iExclude2,
794 const Event& event,
int type,
bool isHardIn);
796 double deltaRij(Vec4 jet1, Vec4 jet2);
803 double getWeightNLO() {
return (weightCKKWLSave - weightFIRSTSave);}
805 double getWeightCKKWL() {
return weightCKKWLSave; }
807 double getWeightFIRST() {
return weightFIRSTSave; }
809 void setWeightCKKWL(
double weightIn){
810 weightCKKWLSave = weightIn;
811 if ( !includeWGTinXSEC() ) infoPtr->setWeightCKKWL(weightIn); }
813 void setWeightFIRST(
double weightIn){
814 weightFIRSTSave = weightIn;
815 infoPtr->setWeightFIRST(weightIn); }
823 void setEventVetoInfo(
int nJetNowIn,
double tmsNowIn) {
824 nJetNowSave = nJetNowIn; tmsNowSave = tmsNowIn; }
827 void setHardProcessInfo(
int nHardNowIn,
double tmsHardNowIn) {
828 nHardNowSave = nHardNowIn; tmsHardNowSave = tmsHardNowIn; }
836 #endif // Pythia8_MergingHooks_H