8 #ifndef Pythia8_Weights_H 9 #define Pythia8_Weights_H 11 #include "Pythia8/Basics.h" 12 #include "Pythia8/LHEF3.h" 13 #include "Pythia8/PythiaStdlib.h" 14 #include "Pythia8/SharedPointers.h" 23 class WeightContainer;
48 virtual void init(
bool) {}
55 virtual void bookVectors(vector<double> weights, vector<string> names) {
56 for (
int i = 0; i < (int)weights.size(); ++i) {
57 replace(names[i].begin(), names[i].end(),
' ',
'_');
78 string name = iPos >= 0
79 && iPos < (int)weightNames.size() ? weightNames[iPos] :
"";
80 if (name.find(
":") != string::npos)
81 replace(name.begin(), name.end(),
':',
'.');
82 return name ==
"" ? to_string(iPos) : name;}
83 virtual double getWeightsValue(
int iPos)
const {
return weightValues[iPos]; }
84 int getWeightsSize()
const {
return weightValues.size(); }
91 weightNames.push_back(name);
98 if (iPos < 0 || iPos >= (
int)
weightValues.size())
return;
101 void setValueByName(
string name,
double val) {
106 if (iPos < 0 || iPos >= (
int)
weightValues.size())
return;
118 vector<string>::iterator it
119 = find(weightNames.begin(), weightNames.end(), name);
120 unsigned long int index = distance(weightNames.begin(), it);
121 if (index == weightNames.size())
return -1;
122 return distance(weightNames.begin(), it);
131 void parse(
string wvecKey, map<
string, map<string, double> > &dct);
135 vector<string> weightNames;
155 virtual int nWeightGroups()
const {
return 0;}
156 virtual string getGroupName(
int )
const {
return "";}
157 virtual double getGroupWeight(
int )
const {
return 1.;}
170 void init(
bool doMerging)
override;
176 double norm = 1.)
override;
179 void initWeightGroups(
bool =
false)
override;
182 string getGroupName(
int iGN)
const override;
185 double getGroupWeight(
int iGW)
const override;
186 int nWeightGroups()
const override {
return externalVariations.size(); }
189 bool initUniqueShowerVars();
194 double getEnhancedTrialPT() {
return pTEnhanced;}
195 double getEnhancedTrialWeight() {
return wtEnhanced;}
199 vector<string> getUniqueShowerVars(vector<string> keys);
202 bool initEnhanceFactors();
203 unordered_map<string,double> getEnhanceFactors() {
return enhanceFactors; }
205 string getInitialName(
int iG)
const {
return initialNameSave[iG]; }
212 unordered_map<string,double> enhanceFactors;
216 vector<vector<string> > externalVarNames;
217 vector<string> externalGroupNames;
218 vector<string> initialNameSave;
219 vector<vector<int> > externalMap;
220 int externalVariationsSize{};
223 vector<double> getMuRWeightVector();
224 vector<vector<string> > mergingVarNames;
225 double pTEnhanced{}, wtEnhanced{};
246 void init()
override;
249 void clear()
override;
252 void bookWeight(
string name,
double value,
double valueFirst);
255 void bookVectors(vector<double> weights, vector<string> names)
override;
256 void bookVectors(vector<double> weights, vector<double> weightsFirst,
257 vector<string> names);
263 return weightValuesP[iPos] - weightValuesFirstP[iPos]; }
264 double getWeightsValuePC(
int iPos)
const {
265 return weightValuesPC[iPos] - weightValuesFirstPC[iPos]; }
272 void setValueFirstByIndex(
int iPos,
double val);
273 void setValueFirstByName(
string name,
double val);
276 void setValueVector(vector<double> ValueVector);
277 void setValueFirstVector(vector<double> ValueFirstVector);
280 vector<double> getMuRVarFactors();
283 void setLHEFvariationMapping();
290 double norm = 1.)
override;
302 weightValuesFirstP, weightValuesFirstPC;
326 void clear()
override;
329 void bookVectors(vector<double> weights, vector<string> names)
override;
334 double norm = 1.)
override;
339 vector<string> convertNames(vector<string> names);
341 void identifyVariationsFromLHAinit(map<string,LHAweight>* weights);
368 void init()
override;
373 zIntBreaks.clear(); zDblBreaks.clear(); pTBreaks.clear();}
375 int nWeightGroups()
const {
return externalGroupNames.size();}
377 string getGroupName(
int iGN)
const {
return iGN < 0 || iGN >= nWeightGroups()
378 ?
"Null" : externalGroupNames[iGN];}
382 if (iGW < 0 || iGW >= nWeightGroups())
return 1.0;
384 for (
const int &iWgt : externalMap[iGW]) wgt *= getWeightsValue(iWgt);
391 double norm = 1.)
override;
394 vector<double> flavParms(
double xi,
double rho,
double x,
double y);
398 return flavWeight(parms, flavBreaks);}
399 double flavWeight(
const vector<double>& parms,
const vector<int>& breaks);
402 double zWeight(
double aLund,
double bLund,
double rFactC,
double rFactB,
403 int idOld,
int idNew,
double mT2,
double z,
double fPrel);
404 double pTWeight(
double sigma,
double pT2,
double mult);
407 vector<map<vector<double>,
int> > weightParms{};
408 vector<string> externalGroupNames{};
409 vector<vector<int> > externalMap{};
418 vector<double> zDblBreaks;
430 const vector<vector< pair<string, string> > > keyOrder{
431 {{
"frag:alund",
"StringZ:aLund"}, {
"frag:blund",
"StringZ:bLund"},
432 {
"frag:rfactc",
"StringZ:rFactC"}, {
"frag:rfactb",
"StringZ:rFactB"}},
433 {{
"frag:xi",
"StringFlav:ProbQQtoQ"}, {
"frag:rho",
"StringFlav:ProbStoUD"},
434 {
"frag:x",
"StringFlav:ProbSQtoQQ"},
435 {
"frag:y",
"StringFlav:ProbQQ1toQQ0"}},
436 {{
"frag:ptsigma",
"StringPT:sigma"}}};
439 const vector<int> flavIdxs{0, 1, 2, 3, 6};
442 vector<double> flavBase;
445 vector<double> pTBase;
451 void flavStore(
int idIn,
bool early,
bool noChoice);
454 void zStore(
int idOld,
int idNew,
double mT2,
455 bool accept,
double z,
double fPrel);
458 void pTStore(
double pT2,
double mult);
478 void setWeightNominal(
double weightNow );
479 double collectWeightNominal();
501 int numberOfWeights();
502 double weightValueByIndex(
int key = 0);
503 string weightNameByIndex(
int key = 0);
509 vector<double> weightValueVector();
513 vector<string> weightNameVector();
522 void init(
bool doMerging);
525 void initPtrs(
Info* infoPtrIn);
531 vector<double> getSampleXsec();
532 vector<double> getTotalXsec();
533 vector<double> getSampleXsecErr();
534 vector<double> getTotalXsecErr();
537 void accumulateXsec(
double norm = 1.);
545 bool doSuppressAUXweights{};
548 vector<double> sigmaTotal, sigmaSample, errorTotal, errorSample;
Z0 Z(f is quark or lepton).*/ void Sigma1ffbar2gmZZprime
Initialize process.
Definition: SigmaNewGaugeBosons.cc:110
double weightNominal
The nominal Pythia weight, in pb for lha strategy 4 and -4.
Definition: Weights.h:477
Purely virtual base class for shower weights.
Definition: Weights.h:146
virtual void bookVectors(vector< double > weights, vector< string > names)
Definition: Weights.h:55
virtual void reweightValueByIndex(int iPos, double val)
Functions to reweight weight values, by index or by name.
Definition: Weights.h:105
vector< double > pTBreaks
Definition: Weights.h:422
double flavWeight(const vector< double > &parms)
Calculate a flavour weight.
Definition: Weights.h:397
FactIndex
Factorization indices.
Definition: Weights.h:425
Definition: Weights.h:468
vector< string > externalVariations
Vectors for weight group handling.
Definition: Weights.h:215
vector< double > weightValuesFirst
Data member for first order weight.
Definition: Weights.h:298
virtual void reweightValueByName(string name, double val)
Definition: Weights.h:109
The StringPT class is used to select select transverse momenta.
Definition: FragmentationFlavZpT.h:300
vector< int > flavBreaks
Track the breaks needed for flavour reweighting.
Definition: Weights.h:412
double getWeightsValue(int iPos) const override
Modified weight getter to include first order weight.
Definition: Weights.h:259
virtual void initWeightGroups(bool=false)
Weight "groups" (combinations of one or more unique weights).
Definition: Weights.h:154
map< int, double > muRvars
Renormalization variations.
Definition: Weights.h:346
void bookWeight(string name, double defaultValue=1.)
Function to create a new, synchronized, pair of weight name and value.
Definition: Weights.h:87
void parse(string wvecKey, map< string, map< string, double > > &dct)
Parse a WVec of variations into a dictionary.
Definition: Weights.cc:43
The StringZ class is used to sample the fragmentation function f(z).
Definition: FragmentationFlavZpT.h:219
double centralWeight
Central weight, needed for normalization, set from ProcessContainer.cc.
Definition: Weights.h:323
vector< string > getUniqueShowerVars()
Extract full list or subset that matches specific keys (e.g., FSR ones).
Definition: Weights.h:198
vector< string > uniqueShowerVars
Vectors for storing shower variatons and enhancement factors.
Definition: Weights.h:211
vector< int > zIntBreaks
Definition: Weights.h:417
Definition: PartonLevel.h:45
double getGroupWeight(int iGW) const
Return group weight.
Definition: Weights.h:381
Definition: Weights.h:237
void setValueByIndex(int iPos, double val)
Functions to set values of weights.
Definition: Weights.h:97
virtual void init()
Initialize the weights.
Definition: Weights.h:46
bool isNLO
Boolean to memorize if LHEF weight needs to be applied (only for NLO).
Definition: Weights.h:305
Info * infoPtr
Pointers necessary for variation initialization.
Definition: Weights.h:138
virtual void collectWeightNames(vector< string > &outputNames)
Similar function to return processed weight names.
Definition: Weights.cc:34
string getWeightsName(int iPos) const
Definition: Weights.h:77
vector< double > weightValues
Weight values and names.
Definition: Weights.h:134
void setEnhancedTrial(double pTIn, double wtIn)
Memorize enhancement factor and pT of enhanced emission.
Definition: Weights.h:192
Definition: Weights.h:355
map< int, double > varPDFplus
Variations that must be known by TimeShower and Spaceshower.
Definition: Weights.h:208
void clear() override
Clear the weights.
Definition: Weights.h:371
Header for classes to set beam momentum and interaction vertex spread.
Definition: Analysis.h:20
virtual void collectWeightValues(vector< double > &outputWeights, double norm=1.)
WeightsBase class.
Definition: Weights.cc:24
The StringFlav class is used to select quark and hadron flavours.
Definition: FragmentationFlavZpT.h:76
void init(bool) override
Initialize weights (more can be booked at any time)
Definition: Weights.h:151
This shows a WeightsShower example implementation for SimpleShower.
Definition: Weights.h:165
virtual void clear()
Reset all internal values.
Definition: Weights.h:51
int findIndexOfName(string name)
Definition: Weights.h:117
map< int, int > muRVarLHEFindex
Corresponding vector with respective LHEF weight indices.
Definition: Weights.h:295
Definition: Weights.h:315
void setPtrs(Info *infoPtrIn)
Set the pointers.
Definition: Weights.h:126
double getWeightsValueP(int iPos) const
Also add getters for UNLOPS-P and -PC schemes.
Definition: Weights.h:262
Definition: History.h:116
WeightContainer()
Definition: Weights.h:474
vector< double > weightValuesP
Data members for UNLOPS-P and -PC.
Definition: Weights.h:301