File indexing completed on 2025-01-18 10:06:40
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 #ifndef Pythia8_ResonanceDecayFilterHooks_H
0040 #define Pythia8_ResonanceDecayFilterHooks_H
0041
0042
0043 #include "Pythia8/Pythia.h"
0044 #include "Pythia8/UserHooks.h"
0045 #include "Pythia8/Event.h"
0046
0047 namespace Pythia8 {
0048
0049 class ResonanceDecayFilterHook : public UserHooks {
0050 public:
0051
0052
0053 ResonanceDecayFilterHook(Settings &settings);
0054
0055
0056 bool canVetoResonanceDecays() override {return true;}
0057 bool doVetoResonanceDecays(Event& process) override {
0058 return checkVetoResonanceDecays(process);}
0059 bool initAfterBeams() override;
0060
0061
0062 bool checkVetoResonanceDecays(const Event& process);
0063 unsigned long int returnCounter() {return counter;};
0064
0065 private:
0066
0067
0068 int idCat(int id);
0069
0070
0071 bool filter, exclusive, eMuAsEquivalent, eMuTauAsEquivalent,
0072 allNuAsEquivalent, udscAsEquivalent, udscbAsEquivalent, wzAsEquivalent;
0073 unsigned long int counter;
0074 set<int> mothers;
0075 vector<int> daughters;
0076 unordered_map<int, int> requestedDaughters, observedDaughters;
0077
0078 };
0079
0080
0081
0082
0083
0084 ResonanceDecayFilterHook::ResonanceDecayFilterHook(Settings &settings) {
0085 counter = 0;
0086 settings.addFlag("ResonanceDecayFilter:filter", false);
0087 settings.addFlag("ResonanceDecayFilter:exclusive", false);
0088 settings.addFlag("ResonanceDecayFilter:eMuAsEquivalent", false);
0089 settings.addFlag("ResonanceDecayFilter:eMuTauAsEquivalent", false);
0090 settings.addFlag("ResonanceDecayFilter:allNuAsEquivalent", false);
0091 settings.addFlag("ResonanceDecayFilter:udscAsEquivalent", false);
0092 settings.addFlag("ResonanceDecayFilter:udscbAsEquivalent", false);
0093 settings.addFlag("ResonanceDecayFilter:wzAsEquivalent", false);
0094 settings.addMVec("ResonanceDecayFilter:mothers", vector<int>(), false,
0095 false, 0, 0);
0096 settings.addMVec("ResonanceDecayFilter:daughters", vector<int>(), false,
0097 false, 0, 0);
0098 }
0099
0100
0101
0102
0103
0104 int ResonanceDecayFilterHook::idCat(int id) {
0105 id = abs(id);
0106 if (id == 13 && (eMuAsEquivalent || eMuTauAsEquivalent)) id = 11;
0107 else if (id == 15 && eMuTauAsEquivalent) id = 11;
0108 else if ((id == 14 || id == 16) && allNuAsEquivalent) id = 12;
0109 else if ((id == 2 || id == 3 || id == 4) && udscAsEquivalent) id = 1;
0110 else if ((id == 2 || id == 3 || id == 4 || id == 5) &&
0111 udscbAsEquivalent) id = 1;
0112 else if ((id == 23 || id == 24) && wzAsEquivalent) id = 23;
0113 return id;
0114 }
0115
0116
0117
0118
0119
0120 bool ResonanceDecayFilterHook::initAfterBeams() {
0121 filter = settingsPtr->flag("ResonanceDecayFilter:filter");
0122 exclusive = settingsPtr->flag("ResonanceDecayFilter:exclusive");
0123 eMuAsEquivalent = settingsPtr->flag("ResonanceDecayFilter:eMuAsEquivalent");
0124 eMuTauAsEquivalent = settingsPtr->
0125 flag("ResonanceDecayFilter:eMuTauAsEquivalent");
0126 allNuAsEquivalent = settingsPtr->flag
0127 ("ResonanceDecayFilter:allNuAsEquivalent");
0128 udscAsEquivalent = settingsPtr->
0129 flag("ResonanceDecayFilter:udscAsEquivalent");
0130 udscbAsEquivalent = settingsPtr->
0131 flag("ResonanceDecayFilter:udscbAsEquivalent");
0132 wzAsEquivalent = settingsPtr->flag("ResonanceDecayFilter:wzAsEquivalent");
0133 auto mothersIn = settingsPtr->mvec("ResonanceDecayFilter:mothers");
0134 mothers.clear();
0135 mothers.insert(mothersIn.begin(), mothersIn.end());
0136 daughters = settingsPtr->mvec("ResonanceDecayFilter:daughters");
0137 requestedDaughters.clear();
0138
0139
0140 for (int id : daughters) ++requestedDaughters[idCat(id)];
0141 return true;
0142
0143 }
0144
0145
0146
0147
0148
0149 bool ResonanceDecayFilterHook::checkVetoResonanceDecays(const Event &process) {
0150 if (!filter) return false;
0151
0152
0153 counter++;
0154 observedDaughters.clear();
0155
0156
0157 for (int i = 0; i < process.size(); ++i) {
0158 const Particle &p = process[i];
0159 int mid = p.mother1() > 0 ? abs(process[p.mother1()].id()) : 0;
0160
0161
0162
0163 if (mothers.empty() || mothers.count(mid) || mothers.count(-mid))
0164 ++observedDaughters[idCat(p.id())];
0165 }
0166
0167
0168
0169
0170
0171
0172 for (const auto &reqDau : requestedDaughters) {
0173 int reqId = reqDau.first;
0174 int reqCount = reqDau.second;
0175 auto obsItr = observedDaughters.find(reqId);
0176 int obsCount = ( obsItr != observedDaughters.end() ) ? obsItr->second : 0;
0177
0178
0179 if (obsCount < reqCount) return true;
0180
0181
0182 if (exclusive && obsCount > reqCount) return true;
0183 }
0184
0185
0186 return false;
0187
0188 }
0189
0190
0191
0192 }
0193
0194 #endif