Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:06:19

0001 // DireMerging.h is a part of the PYTHIA event generator.
0002 // Copyright (C) 2024 Stefan Prestel, Torbjorn Sjostrand.
0003 // PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
0004 // Please respect the MCnet Guidelines, see GUIDELINES for details.
0005 
0006 // Header file for merging with Dire.
0007 
0008 #ifndef Pythia8_DireMerging_H
0009 #define Pythia8_DireMerging_H
0010 
0011 #define DIRE_MERGING_VERSION "2.002"
0012 
0013 #include "Pythia8/Basics.h"
0014 #include "Pythia8/BeamParticle.h"
0015 #include "Pythia8/Event.h"
0016 #include "Pythia8/Info.h"
0017 #include "Pythia8/ParticleData.h"
0018 #include "Pythia8/PartonLevel.h"
0019 #include "Pythia8/PythiaStdlib.h"
0020 #include "Pythia8/Settings.h"
0021 #include "Pythia8/StandardModel.h"
0022 #include "Pythia8/Merging.h"
0023 #include "Pythia8/MergingHooks.h"
0024 #include "Pythia8/LesHouches.h"
0025 
0026 #include "Pythia8/DireHistory.h"
0027 #include "Pythia8/DireMergingHooks.h"
0028 #include "Pythia8/DireWeightContainer.h"
0029 
0030 namespace Pythia8 {
0031 
0032 class DireSpace;
0033 class DireTimes;
0034 
0035 //==========================================================================
0036 
0037 // Merging is a wrapper class for the interface of matrix element merging and
0038 // Pythia8.
0039 
0040 class DireMerging : public Merging {
0041 
0042 public:
0043 
0044   // Constructor.
0045   DireMerging() : totalProbSave(createvector<double>(0.)(0.)(0.)),
0046     sudakovs(1.), asRatios(1.), pdfRatios(1.), psweights(0), first(true) {
0047     vector<double> tmp(createvector<double>(0.)(0.)(0.));
0048     signalProbSave.insert(make_pair("higgs",tmp));
0049     bkgrndProbSave.insert(make_pair("higgs",tmp));
0050     signalProbSave.insert(make_pair("higgs-subt",tmp));
0051     bkgrndProbSave.insert(make_pair("higgs-subt",tmp));
0052     signalProbSave.insert(make_pair("higgs-nosud",tmp));
0053     bkgrndProbSave.insert(make_pair("higgs-nosud",tmp));
0054     signalProbSave.insert(make_pair("qed",tmp));
0055     bkgrndProbSave.insert(make_pair("qed",tmp));
0056     signalProbSave.insert(make_pair("qcd",tmp));
0057     bkgrndProbSave.insert(make_pair("qcd",tmp));
0058     settingsPtr = 0; infoPtr = 0; particleDataPtr = 0; rndmPtr = 0;
0059     beamAPtr = 0; beamBPtr = 0; trialPartonLevelPtr = 0;
0060     mergingHooksPtr = 0; myHistory = 0; fsr = 0; isr = 0;
0061     direInfoPtr = 0; sum_time_1 = sum_time_2 = 0.; sum_paths = 0;
0062     enforceCutOnLHE = doMOPS = applyTMSCut = doMerging
0063       //= doMcAtNloDelta
0064       = allowReject = doMECs = doMEM = doGenerateSubtractions
0065       = doGenerateMergingWeights = doExitAfterMerging
0066       = allowIncompleteReal = false;
0067     usePDF = true;
0068     nQuarksMerge = 5;
0069   }
0070 
0071   void setWeightsPtr( DireWeightContainer* wgtsIn ) { psweights = wgtsIn; }
0072   void setShowerPtrs( shared_ptr<DireTimes> timesPtr,
0073     shared_ptr<DireSpace> spacePtr) {fsr = timesPtr; isr = spacePtr; }
0074 
0075   void initPtrs( DireWeightContainer* wgtsIn, shared_ptr<DireTimes> timesPtr,
0076     shared_ptr<DireSpace> spacePtr, DireInfo* direInfoIn) {
0077     psweights = wgtsIn;
0078     fsr = timesPtr;
0079     isr = spacePtr;
0080     direInfoPtr = direInfoIn;
0081   }
0082 
0083   shared_ptr<DireTimes> fsr;
0084   shared_ptr<DireSpace> isr;
0085   DireInfo* direInfoPtr;
0086 
0087   // Destructor.
0088   ~DireMerging(){
0089     if (myHistory) delete myHistory;
0090   }
0091 
0092   // Initialisation function for internal use inside Pythia source code
0093   virtual void init();
0094   void reset();
0095 
0096   // Function to print statistics.
0097   virtual void statistics();
0098 
0099   // Functions that implement matrix element merging.
0100 
0101   // Function to steer different merging prescriptions.
0102   virtual int mergeProcess( Event& process);
0103 
0104   // Return CKKW-L weight.
0105   void getSudakovs( double & wt )  const { wt = sudakovs;  return; }
0106   void getASratios( double & wt )  const { wt = asRatios;  return; }
0107   void getPDFratios( double & wt ) const { wt = pdfRatios; return; }
0108 
0109   void getSudakovExp( int order, double & wt )  const {
0110     wt = 0.;
0111     if (order >= 0 && order < int(sudakovsExp.size()))
0112       wt = sudakovsExp[order];
0113     return;
0114   }
0115   void getASratioExp( int order, double & wt )  const {
0116     wt = 0.;
0117     if (order >= 0 && order < int(asRatiosExp.size()))
0118       wt = asRatiosExp[order];
0119     return;
0120   }
0121   void getPDFratioExp( int order, double & wt ) const {
0122     wt = 0.;
0123     if (order >= 0 && order <= int(pdfRatiosExp.size()))
0124       wt = pdfRatiosExp[order];
0125     return;
0126   }
0127 
0128   void clearInfos() {
0129     stoppingScalesSave.clear();
0130     startingScalesSave.clear();
0131     mDipSave.clear();
0132     radSave.clear();
0133     emtSave.clear();
0134     recSave.clear();
0135   }
0136   void storeInfos();
0137 
0138   vector<double> getStoppingScales() {
0139     return stoppingScalesSave;
0140   }
0141   vector<double> getStartingScales() {
0142     return startingScalesSave;
0143   }
0144   virtual void getStoppingInfo(double scales[100][100],
0145     double masses[100][100]);
0146   vector<double> startingScalesSave;
0147 
0148   virtual double generateSingleSudakov (double pTbegAll, double pTendAll,
0149     double m2dip, int idA, int type, double s = -1., double x = -1.);
0150 
0151   vector<double> getSignalProb(string key) { return signalProbSave[key]; }
0152   vector<double> getBkgrndProb(string key) { return bkgrndProbSave[key]; }
0153   vector<double> getTotalProb() { return totalProbSave; }
0154   vector<double> totalProbSave;
0155   map<string, vector<double> > signalProbSave, bkgrndProbSave;
0156   void clearClassifier() {
0157     for ( map<string, vector<double> >::iterator it = signalProbSave.begin();
0158       it != signalProbSave.end(); ++it) for (size_t i=0; i<it->second.size();
0159         ++i) it->second[i]=0.;
0160     for ( map<string, vector<double> >::iterator it = bkgrndProbSave.begin();
0161       it != bkgrndProbSave.end(); ++it) for (size_t i=0; i<it->second.size();
0162         ++i) it->second[i]=0.;
0163     for (size_t i=0; i<totalProbSave.size(); ++i) totalProbSave[i]=0.;
0164   }
0165 
0166 protected:
0167 
0168   // The members.
0169   // Make Pythia class friend
0170   friend class Pythia;
0171 
0172   // Function to perform CKKW-L merging on the event.
0173   int mergeProcessCKKWL( Event& process);
0174 
0175   // Function to perform UMEPS merging on the event.
0176   int mergeProcessUMEPS( Event& process);
0177 
0178   // Function to perform NL3 NLO merging on the event.
0179   int mergeProcessNL3( Event& process);
0180 
0181   // Function to perform UNLOPS merging on the event.
0182   int mergeProcessUNLOPS( Event& process);
0183 
0184   // Function to apply the merging scale cut on an input event.
0185   bool cutOnProcess( Event& process);
0186 
0187   // Function to perform CKKW-L merging on the event.
0188   int calculate( Event& process);
0189 
0190   DireHistory* myHistory;
0191 
0192   bool   generateHistories( const Event& process, bool orderedOnly = true);
0193   void   tagHistories();
0194 
0195   double getPathIndex( bool useAll = false);
0196   int    calculateWeights( double RNpath, bool useAll = false);
0197   int    getStartingConditions( double RNpath, Event& process );
0198 
0199   void   setSudakovs( double wt )  { sudakovs = wt;  return; }
0200   void   setASratios( double wt )  { asRatios = wt;  return; }
0201   void   setPDFratios( double wt ) { pdfRatios = wt; return; }
0202 
0203   void setSudakovExp( vector<double> wts ) {
0204     // Clear previous results.
0205     sudakovsExp.clear();
0206     // Store coefficients of Sudakov expansion.
0207     sudakovsExp.insert(sudakovsExp.end(), wts.begin(), wts.end());
0208     return;
0209   }
0210   void setASratioExp( vector<double> wts ) {
0211     // Clear previous results.
0212     asRatiosExp.clear();
0213     // Store coefficients of Sudakov expansion.
0214     asRatiosExp.insert(asRatiosExp.end(), wts.begin(), wts.end());
0215     return;
0216   }
0217   void setPDFratiosExp( vector<double> wts ) {
0218     // Clear previous results.
0219     pdfRatiosExp.clear();
0220     // Store coefficients of Sudakov expansion.
0221     pdfRatiosExp.insert(pdfRatiosExp.end(), wts.begin(), wts.end());
0222     return;
0223   }
0224 
0225   void clearSubtractions() { subtractions.clear(); }
0226   void appendSubtraction( double wt, const Event& event ) {
0227     subtractions.push_back( make_pair(wt, event) );
0228     return;
0229   }
0230   bool calculateSubtractions();
0231 
0232   bool generateUnorderedPoint(Event& process);
0233 
0234   double sudakovs, asRatios, pdfRatios;
0235   vector<double> sudakovsExp, asRatiosExp, pdfRatiosExp;
0236   vector<pair<double,Event> > subtractions;
0237 
0238   DireWeightContainer* psweights;
0239 
0240   double sum_time_1, sum_time_2;
0241   int sum_paths;
0242 
0243   bool enforceCutOnLHE, doMOPS, applyTMSCut, doMerging,
0244        usePDF, allowReject, doMECs, doMEM, doGenerateSubtractions,
0245        doGenerateMergingWeights, doExitAfterMerging, allowIncompleteReal;
0246   int nQuarksMerge;
0247 
0248   bool first;
0249 
0250 };
0251 
0252 //==========================================================================
0253 
0254 } // end namespace Pythia8
0255 
0256 #endif // Pythia8_DireMerging_H