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;
46 virtual void init(
bool) {}
53 virtual void bookVectors(vector<double> weights, vector<string> names) {
54 for (
int i = 0; i < (int)weights.size(); ++i) {
55 replace(names[i].begin(), names[i].end(),
' ',
'_');
76 string name = iPos >= 0
77 && iPos < (int)weightNames.size() ? weightNames[iPos] :
"";
78 if (name.find(
":") != string::npos)
79 replace(name.begin(), name.end(),
':',
'.');
80 return name ==
"" ? to_string(iPos) : name;}
81 virtual double getWeightsValue(
int iPos)
const {
return weightValues[iPos]; }
82 int getWeightsSize()
const {
return weightValues.size(); }
89 weightNames.push_back(name);
96 if (iPos < 0 || iPos >= (
int)
weightValues.size())
return;
99 void setValueByName(
string name,
double val) {
104 if (iPos < 0 || iPos >= (
int)
weightValues.size())
return;
116 vector<string>::iterator it
117 = find(weightNames.begin(), weightNames.end(), name);
118 unsigned long int index = distance(weightNames.begin(), it);
119 if (index == weightNames.size())
return -1;
120 return distance(weightNames.begin(), it);
129 void parse(
string wvecKey, map<
string, map<string, double> > &dct);
133 vector<string> weightNames;
153 virtual int nWeightGroups()
const {
return 0;}
154 virtual string getGroupName(
int )
const {
return "";}
155 virtual double getGroupWeight(
int )
const {
return 1.;}
168 void init(
bool doMerging)
override;
174 double norm = 1.)
override;
177 void initWeightGroups(
bool =
false)
override;
180 string getGroupName(
int iGN)
const override;
183 double getGroupWeight(
int iGW)
const override;
184 int nWeightGroups()
const override {
return externalVariations.size(); }
187 bool initUniqueShowerVars();
192 double getEnhancedTrialPT() {
return pTEnhanced;}
193 double getEnhancedTrialWeight() {
return wtEnhanced;}
197 vector<string> getUniqueShowerVars(vector<string> keys);
200 bool initEnhanceFactors();
201 unordered_map<string,double> getEnhanceFactors() {
return enhanceFactors; }
203 string getInitialName(
int iG)
const {
return initialNameSave[iG]; }
210 unordered_map<string,double> enhanceFactors;
214 vector<vector<string> > externalVarNames;
215 vector<string> externalGroupNames;
216 vector<string> initialNameSave;
217 vector<vector<int> > externalMap;
218 int externalVariationsSize{};
221 vector<double> getMuRWeightVector();
222 vector<vector<string> > mergingVarNames;
223 double pTEnhanced{}, wtEnhanced{};
244 void init()
override;
247 void clear()
override;
250 void bookWeight(
string name,
double value,
double valueFirst);
253 void bookVectors(vector<double> weights, vector<string> names)
override;
254 void bookVectors(vector<double> weights, vector<double> weightsFirst,
255 vector<string> names);
261 return weightValuesP[iPos] - weightValuesFirstP[iPos]; }
262 double getWeightsValuePC(
int iPos)
const {
263 return weightValuesPC[iPos] - weightValuesFirstPC[iPos]; }
270 void setValueFirstByIndex(
int iPos,
double val);
271 void setValueFirstByName(
string name,
double val);
274 void setValueVector(vector<double> ValueVector);
275 void setValueFirstVector(vector<double> ValueFirstVector);
278 vector<double> getMuRVarFactors();
281 void setLHEFvariationMapping();
288 double norm = 1.)
override;
300 weightValuesFirstP, weightValuesFirstPC;
324 void clear()
override;
327 void bookVectors(vector<double> weights, vector<string> names)
override;
332 double norm = 1.)
override;
337 vector<string> convertNames(vector<string> names);
339 void identifyVariationsFromLHAinit(map<string,LHAweight>* weights);
358 void init()
override;
360 int nWeightGroups()
const {
return externalGroupNames.size();}
362 string getGroupName(
int iGN)
const {
return iGN < 0 || iGN >= nWeightGroups()
363 ?
"Null" : externalGroupNames[iGN];}
367 if (iGW < 0 || iGW >= nWeightGroups())
return 1.0;
369 for (
const int &iWgt : externalMap[iGW]) wgt *= getWeightsValue(iWgt);
376 double norm = 1.)
override;
379 vector<map<vector<double>,
int> > weightParms{};
380 vector<string> externalGroupNames{};
381 vector<vector<int> > externalMap{};
404 void setWeightNominal(
double weightNow );
405 double collectWeightNominal();
427 int numberOfWeights();
428 double weightValueByIndex(
int key = 0);
429 string weightNameByIndex(
int key = 0);
435 vector<double> weightValueVector();
439 vector<string> weightNameVector();
448 void init(
bool doMerging);
451 void initPtrs(
Info* infoPtrIn);
457 vector<double> getSampleXsec();
458 vector<double> getTotalXsec();
459 vector<double> getSampleXsecErr();
460 vector<double> getTotalXsecErr();
463 void accumulateXsec(
double norm = 1.);
471 bool doSuppressAUXweights{};
474 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:403
Purely virtual base class for shower weights.
Definition: Weights.h:144
virtual void bookVectors(vector< double > weights, vector< string > names)
Definition: Weights.h:53
virtual void reweightValueByIndex(int iPos, double val)
Functions to reweight weight values, by index or by name.
Definition: Weights.h:103
FactIndex
Factorization indices.
Definition: Weights.h:384
Definition: Weights.h:394
vector< string > externalVariations
Vectors for weight group handling.
Definition: Weights.h:213
vector< double > weightValuesFirst
Data member for first order weight.
Definition: Weights.h:296
virtual void reweightValueByName(string name, double val)
Definition: Weights.h:107
double getWeightsValue(int iPos) const override
Modified weight getter to include first order weight.
Definition: Weights.h:257
virtual void initWeightGroups(bool=false)
Weight "groups" (combinations of one or more unique weights).
Definition: Weights.h:152
map< int, double > muRvars
Renormalization variations.
Definition: Weights.h:344
void bookWeight(string name, double defaultValue=1.)
Function to create a new, synchronized, pair of weight name and value.
Definition: Weights.h:85
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:321
vector< string > getUniqueShowerVars()
Extract full list or subset that matches specific keys (e.g., FSR ones).
Definition: Weights.h:196
vector< string > uniqueShowerVars
Vectors for storing shower variatons and enhancement factors.
Definition: Weights.h:209
Definition: PartonLevel.h:45
double getGroupWeight(int iGW) const
Return group weight.
Definition: Weights.h:366
Definition: Weights.h:235
void setValueByIndex(int iPos, double val)
Functions to set values of weights.
Definition: Weights.h:95
virtual void init()
Initialize the weights.
Definition: Weights.h:44
bool isNLO
Boolean to memorize if LHEF weight needs to be applied (only for NLO).
Definition: Weights.h:303
Info * infoPtr
Pointers necessary for variation initialization.
Definition: Weights.h:136
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:75
vector< double > weightValues
Weight values and names.
Definition: Weights.h:132
void setEnhancedTrial(double pTIn, double wtIn)
Memorize enhancement factor and pT of enhanced emission.
Definition: Weights.h:190
Definition: Weights.h:353
map< int, double > varPDFplus
Variations that must be known by TimeShower and Spaceshower.
Definition: Weights.h:206
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
void init(bool) override
Initialize weights (more can be booked at any time)
Definition: Weights.h:149
This shows a WeightsShower example implementation for SimpleShower.
Definition: Weights.h:163
virtual void clear()
Reset all internal values.
Definition: Weights.h:49
int findIndexOfName(string name)
Definition: Weights.h:115
map< int, int > muRVarLHEFindex
Corresponding vector with respective LHEF weight indices.
Definition: Weights.h:293
Definition: Weights.h:313
void setPtrs(Info *infoPtrIn)
Set the pointers.
Definition: Weights.h:124
double getWeightsValueP(int iPos) const
Also add getters for UNLOPS-P and -PC schemes.
Definition: Weights.h:260
Definition: History.h:116
WeightContainer()
Definition: Weights.h:400
vector< double > weightValuesP
Data members for UNLOPS-P and -PC.
Definition: Weights.h:299