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;
47 virtual void init(
bool) {}
54 virtual void bookVectors(vector<double> weights, vector<string> names) {
55 for (
int i = 0; i < (int)weights.size(); ++i) {
56 replace(names[i].begin(), names[i].end(),
' ',
'_');
77 string name = iPos >= 0
78 && iPos < (int)weightNames.size() ? weightNames[iPos] :
"";
79 if (name.find(
":") != string::npos)
80 replace(name.begin(), name.end(),
':',
'.');
81 return name ==
"" ? to_string(iPos) : name;}
82 virtual double getWeightsValue(
int iPos)
const {
return weightValues[iPos]; }
83 int getWeightsSize()
const {
return weightValues.size(); }
90 weightNames.push_back(name);
97 if (iPos < 0 || iPos >= (
int)
weightValues.size())
return;
100 void setValueByName(
string name,
double val) {
105 if (iPos < 0 || iPos >= (
int)
weightValues.size())
return;
117 vector<string>::iterator it
118 = find(weightNames.begin(), weightNames.end(), name);
119 unsigned long int index = distance(weightNames.begin(), it);
120 if (index == weightNames.size())
return -1;
121 return distance(weightNames.begin(), it);
130 void parse(
string wvecKey, map<
string, map<string, double> > &dct);
134 vector<string> weightNames;
154 virtual int nWeightGroups()
const {
return 0;}
155 virtual string getGroupName(
int )
const {
return "";}
156 virtual double getGroupWeight(
int )
const {
return 1.;}
169 void init(
bool doMerging)
override;
175 double norm = 1.)
override;
178 void initWeightGroups(
bool =
false)
override;
181 string getGroupName(
int iGN)
const override;
184 double getGroupWeight(
int iGW)
const override;
185 int nWeightGroups()
const override {
return externalVariations.size(); }
188 bool initUniqueShowerVars();
193 double getEnhancedTrialPT() {
return pTEnhanced;}
194 double getEnhancedTrialWeight() {
return wtEnhanced;}
198 vector<string> getUniqueShowerVars(vector<string> keys);
201 bool initEnhanceFactors();
202 unordered_map<string,double> getEnhanceFactors() {
return enhanceFactors; }
204 string getInitialName(
int iG)
const {
return initialNameSave[iG]; }
211 unordered_map<string,double> enhanceFactors;
215 vector<vector<string> > externalVarNames;
216 vector<string> externalGroupNames;
217 vector<string> initialNameSave;
218 vector<vector<int> > externalMap;
219 int externalVariationsSize{};
222 vector<double> getMuRWeightVector();
223 vector<vector<string> > mergingVarNames;
224 double pTEnhanced{}, wtEnhanced{};
245 void init()
override;
248 void clear()
override;
251 void bookWeight(
string name,
double value,
double valueFirst);
254 void bookVectors(vector<double> weights, vector<string> names)
override;
255 void bookVectors(vector<double> weights, vector<double> weightsFirst,
256 vector<string> names);
262 return weightValuesP[iPos] - weightValuesFirstP[iPos]; }
263 double getWeightsValuePC(
int iPos)
const {
264 return weightValuesPC[iPos] - weightValuesFirstPC[iPos]; }
271 void setValueFirstByIndex(
int iPos,
double val);
272 void setValueFirstByName(
string name,
double val);
275 void setValueVector(vector<double> ValueVector);
276 void setValueFirstVector(vector<double> ValueFirstVector);
279 vector<double> getMuRVarFactors();
282 void setLHEFvariationMapping();
289 double norm = 1.)
override;
301 weightValuesFirstP, weightValuesFirstPC;
325 void clear()
override;
328 void bookVectors(vector<double> weights, vector<string> names)
override;
333 double norm = 1.)
override;
338 vector<string> convertNames(vector<string> names);
340 void identifyVariationsFromLHAinit(map<string,LHAweight>* weights);
362 void init()
override;
368 int nWeightGroups()
const {
return externalGroupNames.size();}
370 string getGroupName(
int iGN)
const {
return iGN < 0 || iGN >= nWeightGroups()
371 ?
"Null" : externalGroupNames[iGN];}
375 if (iGW < 0 || iGW >= nWeightGroups())
return 1.0;
377 for (
const int &iWgt : externalMap[iGW]) wgt *= getWeightsValue(iWgt);
384 double norm = 1.)
override;
387 vector<double> flavParms(
double xi,
double rho,
double x,
double y);
391 return flavWeight(parms, flavBreaks);}
392 double flavWeight(
const vector<double>& parms,
const vector<int>& breaks);
395 vector<map<vector<double>,
int> > weightParms{};
396 vector<string> externalGroupNames{};
397 vector<vector<int> > externalMap{};
408 const vector<vector< pair<string, string> > > keyOrder{
409 {{
"frag:alund",
"StringZ:aLund"}, {
"frag:blund",
"StringZ:bLund"},
410 {
"frag:rfactc",
"StringZ:rFactC"}, {
"frag:rfactb",
"StringZ:rFactB"}},
411 {{
"frag:xi",
"StringFlav:ProbQQtoQ"}, {
"frag:rho",
"StringFlav:ProbStoUD"},
412 {
"frag:x",
"StringFlav:ProbSQtoQQ"},
413 {
"frag:y",
"StringFlav:ProbQQ1toQQ0"}},
414 {{
"frag:ptsigma",
"StringPT:sigma"}}};
417 const vector<int> flavIdxs{0, 1, 2, 3, 6};
420 vector<double> flavBase;
423 void flavCount(
int idIn,
bool early,
bool noChoice);
443 void setWeightNominal(
double weightNow );
444 double collectWeightNominal();
466 int numberOfWeights();
467 double weightValueByIndex(
int key = 0);
468 string weightNameByIndex(
int key = 0);
474 vector<double> weightValueVector();
478 vector<string> weightNameVector();
487 void init(
bool doMerging);
490 void initPtrs(
Info* infoPtrIn);
496 vector<double> getSampleXsec();
497 vector<double> getTotalXsec();
498 vector<double> getSampleXsecErr();
499 vector<double> getTotalXsecErr();
502 void accumulateXsec(
double norm = 1.);
510 bool doSuppressAUXweights{};
513 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:442
Purely virtual base class for shower weights.
Definition: Weights.h:145
virtual void bookVectors(vector< double > weights, vector< string > names)
Definition: Weights.h:54
virtual void reweightValueByIndex(int iPos, double val)
Functions to reweight weight values, by index or by name.
Definition: Weights.h:104
double flavWeight(const vector< double > &parms)
Calculate a flavor weight.
Definition: Weights.h:390
FactIndex
Factorization indices.
Definition: Weights.h:403
Definition: Weights.h:433
vector< string > externalVariations
Vectors for weight group handling.
Definition: Weights.h:214
vector< double > weightValuesFirst
Data member for first order weight.
Definition: Weights.h:297
virtual void reweightValueByName(string name, double val)
Definition: Weights.h:108
vector< int > flavBreaks
Track the breaks needed for reweighting.
Definition: Weights.h:400
double getWeightsValue(int iPos) const override
Modified weight getter to include first order weight.
Definition: Weights.h:258
virtual void initWeightGroups(bool=false)
Weight "groups" (combinations of one or more unique weights).
Definition: Weights.h:153
map< int, double > muRvars
Renormalization variations.
Definition: Weights.h:345
void bookWeight(string name, double defaultValue=1.)
Function to create a new, synchronized, pair of weight name and value.
Definition: Weights.h:86
void parse(string wvecKey, map< string, map< string, double > > &dct)
Parse a WVec of variations into a dictionary.
Definition: Weights.cc:43
double centralWeight
Central weight, needed for normalization, set from ProcessContainer.cc.
Definition: Weights.h:322
vector< string > getUniqueShowerVars()
Extract full list or subset that matches specific keys (e.g., FSR ones).
Definition: Weights.h:197
vector< string > uniqueShowerVars
Vectors for storing shower variatons and enhancement factors.
Definition: Weights.h:210
Definition: PartonLevel.h:45
double getGroupWeight(int iGW) const
Return group weight.
Definition: Weights.h:374
Definition: Weights.h:236
void setValueByIndex(int iPos, double val)
Functions to set values of weights.
Definition: Weights.h:96
virtual void init()
Initialize the weights.
Definition: Weights.h:45
bool isNLO
Boolean to memorize if LHEF weight needs to be applied (only for NLO).
Definition: Weights.h:304
Info * infoPtr
Pointers necessary for variation initialization.
Definition: Weights.h:137
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:76
vector< double > weightValues
Weight values and names.
Definition: Weights.h:133
void setEnhancedTrial(double pTIn, double wtIn)
Memorize enhancement factor and pT of enhanced emission.
Definition: Weights.h:191
Definition: Weights.h:354
map< int, double > varPDFplus
Variations that must be known by TimeShower and Spaceshower.
Definition: Weights.h:207
void clear() override
Clear the weights.
Definition: Weights.h:365
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:84
void init(bool) override
Initialize weights (more can be booked at any time)
Definition: Weights.h:150
This shows a WeightsShower example implementation for SimpleShower.
Definition: Weights.h:164
virtual void clear()
Reset all internal values.
Definition: Weights.h:50
int findIndexOfName(string name)
Definition: Weights.h:116
map< int, int > muRVarLHEFindex
Corresponding vector with respective LHEF weight indices.
Definition: Weights.h:294
Definition: Weights.h:314
void setPtrs(Info *infoPtrIn)
Set the pointers.
Definition: Weights.h:125
double getWeightsValueP(int iPos) const
Also add getters for UNLOPS-P and -PC schemes.
Definition: Weights.h:261
Definition: History.h:116
WeightContainer()
Definition: Weights.h:439
vector< double > weightValuesP
Data members for UNLOPS-P and -PC.
Definition: Weights.h:300