forked from cms-sw/cmsdist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LHEEventNum.patch
199 lines (187 loc) · 8.13 KB
/
LHEEventNum.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
diff -u ThePEG-2.2.2/LesHouches/LesHouchesEventHandler.cc leshoucheseventnumbers/ThePEG/LesHouchesEventHandler.cc
--- ThePEG-2.2.2/LesHouches/LesHouchesEventHandler.cc 2021-01-20 21:18:33.000000001 +0100
+++ leshoucheseventnumbers/ThePEG/LesHouchesEventHandler.cc 2022-01-12 19:04:24.000000001 +0100
@@ -244,9 +244,18 @@
const double fact =
theNormWeight ?
double(selector().sum()/picobarn) : 1.;
-
- currentEvent(new_ptr(Event(lastParticles(), this, generator()->runName(),
+
+ //whether to use the LHE event number or not for the event identification
+ if(UseLHEEvent==0 || currentReader()->LHEEventNum() == -1) {
+ currentEvent(new_ptr(Event(lastParticles(), this, generator()->runName(),
generator()->currentEventNumber(), weight*fact )));
+ }
+ else if(UseLHEEvent==1 && currentReader()->LHEEventNum() != -1) {
+ currentEvent(new_ptr(Event(lastParticles(), this, generator()->runName(),
+ currentReader()->LHEEventNum(), weight*fact )));
+ }
+
+
currentEvent()->optionalWeights() = currentReader()->optionalEventWeights();
// normalize the optional weights
for(map<string,double>::iterator it = currentEvent()->optionalWeights().begin();
@@ -512,13 +521,13 @@
void LesHouchesEventHandler::persistentOutput(PersistentOStream & os) const {
os << stats << histStats << theReaders << theSelector
<< oenum(theWeightOption) << theUnitTolerance << theCurrentReader << warnPNum
- << theNormWeight;
+ << theNormWeight << UseLHEEvent;
}
void LesHouchesEventHandler::persistentInput(PersistentIStream & is, int) {
is >> stats >> histStats >> theReaders >> theSelector
>> ienum(theWeightOption) >> theUnitTolerance >> theCurrentReader >> warnPNum
- >> theNormWeight;
+ >> theNormWeight >> UseLHEEvent;
}
ClassDescription<LesHouchesEventHandler>
@@ -613,6 +622,22 @@
"Normalize the weights to the max cross section in pb",
1);
+
+ static Switch<LesHouchesEventHandler,unsigned int> interfaceEventNumbering
+ ("EventNumbering",
+ "How to number the events",
+ &LesHouchesEventHandler::UseLHEEvent, 0, false, false);
+ static SwitchOption interfaceEventNumberingIncremental
+ (interfaceEventNumbering,
+ "Incremental",
+ "Standard incremental numbering (i.e. as they are generated)",
+ 0);
+ static SwitchOption interfaceEventNumberingLHE
+ (interfaceEventNumbering,
+ "LHE",
+ "Corresponding to the LHE event number",
+ 1);
+
interfaceLesHouchesReaders.rank(10);
interfaceWeightOption.rank(9);
diff -u build/BUILD/slc7_amd64_gcc900/external/thepeg/2.2.2-cms2/ThePEG-2.2.2/LesHouches/LesHouchesEventHandler.h leshoucheseventnumbers/ThePEG/LesHouchesEventHandler.h
--- ThePEG-2.2.2/LesHouches/LesHouchesEventHandler.h 2021-01-20 21:18:33.000000001 +0100
+++ leshoucheseventnumbers/ThePEG/LesHouchesEventHandler.h 2022-01-12 19:04:24.000000001 +0100
@@ -71,7 +71,7 @@
*/
LesHouchesEventHandler()
: theWeightOption(unitweight), theUnitTolerance(1.0e-6), warnPNum(true),
- theNormWeight(0)
+ theNormWeight(0), UseLHEEvent(0)
{
selector().tolerance(unitTolerance());
}
@@ -405,6 +405,11 @@
*/
unsigned int theNormWeight;
+ /**
+ * How to number the events
+ */
+ unsigned int UseLHEEvent;
+
public:
/** @cond EXCEPTIONCLASSES */
diff -u build/BUILD/slc7_amd64_gcc900/external/thepeg/2.2.2-cms2/ThePEG-2.2.2/LesHouches/LesHouchesFileReader.cc leshoucheseventnumbers/ThePEG/LesHouchesFileReader.cc
--- ThePEG-2.2.2/LesHouches/LesHouchesFileReader.cc 2021-07-21 00:36:31.000000001 +0200
+++ leshoucheseventnumbers/ThePEG/LesHouchesFileReader.cc 2022-01-12 19:04:24.000000001 +0100
@@ -546,6 +546,14 @@
*/
if(readingInitWeights_sc && !cfile.find("</weightgroup")) {
hs = cfile.getline();
+ //cout << "hs=" << hs << endl;
+ //cout << "weightinfo= " << weightinfo << endl;
+ //fix for potential new lines:
+ if(!cfile.find("<weight") and !cfile.find("</weightgroup")) {
+ weightinfo = weightinfo + hs;
+ //cout << "weightinfo fixed= " << weightinfo << endl;
+ continue;
+ }
istringstream isc(hs);
int ws = 0;
/* get the name that will be used to identify the scale
@@ -724,6 +732,8 @@
}
}
+ LHEeventnum = -1; // set the LHEeventnum to -1, this will be the default if the tag <event_num> is not found
+
// Now read any additional comments and named weights.
// read until the end of rwgt is found
bool readingWeights = false, readingaMCFast = false, readingMG5ClusInfo = false;
@@ -797,6 +807,20 @@
optionalWeights[mg5scinfo.c_str()] = -333; //for the mg5 scale info weights we give them a weight -333 for future identification
}
+ //the event num tag
+ if(cfile.find("<event_num")) {
+ string hs = cfile.getline();
+ string stopDEL = "</event_num>"; //end delimiter
+ unsigned firstLim = hs.find(">") + 1;
+ string LHEeventnum_str = hs.substr(firstLim);
+ erase_substr(LHEeventnum_str,stopDEL);
+ LHEeventnum = std::stol(LHEeventnum_str, nullptr, 10);
+ }
+
+
+
+
+
//determine start of aMCFast weights
if(cfile.find("<applgrid")) { readingaMCFast = true;}
//determine start of optional weights
diff -u build/BUILD/slc7_amd64_gcc900/external/thepeg/2.2.2-cms2/ThePEG-2.2.2/LesHouches/LesHouchesReader.cc leshoucheseventnumbers/ThePEG/LesHouchesReader.cc
--- ThePEG-2.2.2/LesHouches/LesHouchesReader.cc 2021-01-20 21:18:33.000000001 +0100
+++ leshoucheseventnumbers/ThePEG/LesHouchesReader.cc 2022-01-12 19:04:24.000000001 +0100
@@ -1179,6 +1179,7 @@
pos = mwrite(pos, hepeup.SPINUP[0], hepeup.NUP);
pos = mwrite(pos, lastweight);
pos = mwrite(pos, optionalWeights);
+ pos = mwrite(pos, LHEeventnum);
for(size_t ff = 0; ff < optionalWeightsNames.size(); ff++) {
pos = mwrite(pos, optionalWeightsNames[ff]);
}
@@ -1225,6 +1226,7 @@
pos = mread(pos, optionalnpLO);
pos = mread(pos, optionalnpNLO);
pos = mread(pos, preweight);
+ pos = mread(pos, LHEeventnum);
// If we are skipping, we do not have to do anything else.
if ( skipping ) return true;
@@ -1254,7 +1256,7 @@
<< thePartonBinInstances
<< theBeams << theIncoming << theOutgoing << theIntermediates
<< reweights << preweights << preweight << reweightPDF << doInitPDFs
- << theLastXComb << theMaxMultCKKW << theMinMultCKKW << lastweight << optionalWeights << optionalnpLO << optionalnpNLO
+ << theLastXComb << theMaxMultCKKW << theMinMultCKKW << lastweight << optionalWeights << optionalnpLO << optionalnpNLO << LHEeventnum
<< maxFactor << ounit(weightScale, picobarn) << xSecWeights << maxWeights
<< theMomentumTreatment << useWeightWarnings << theReOpenAllowed
<< theIncludeSpin;
@@ -1275,7 +1277,7 @@
>> thePartonBinInstances
>> theBeams >> theIncoming >> theOutgoing >> theIntermediates
>> reweights >> preweights >> preweight >> reweightPDF >> doInitPDFs
- >> theLastXComb >> theMaxMultCKKW >> theMinMultCKKW >> lastweight >> optionalWeights >> optionalnpLO >> optionalnpNLO
+ >> theLastXComb >> theMaxMultCKKW >> theMinMultCKKW >> lastweight >> optionalWeights >> optionalnpLO >> optionalnpNLO >> LHEeventnum
>> maxFactor >> iunit(weightScale, picobarn) >> xSecWeights >> maxWeights
>> theMomentumTreatment >> useWeightWarnings >> theReOpenAllowed
>> theIncludeSpin;
diff -u build/BUILD/slc7_amd64_gcc900/external/thepeg/2.2.2-cms2/ThePEG-2.2.2/LesHouches/LesHouchesReader.h leshoucheseventnumbers/ThePEG/LesHouchesReader.h
--- ThePEG-2.2.2/LesHouches/LesHouchesReader.h 2021-01-20 21:18:33.000000001 +0100
+++ leshoucheseventnumbers/ThePEG/LesHouchesReader.h 2022-01-12 19:04:24.000000001 +0100
@@ -286,6 +286,11 @@
*/
const map<string,double>& optionalEventWeights() const { return optionalWeights; }
+ /**
+ * Return the Les Houches event number associated with the current event
+ */
+ const long& LHEEventNum() const { return LHEeventnum; }
+
/**
* Return the optional npLO and npNLO
*/
@@ -831,6 +836,11 @@
*/
map<string,double> optionalWeights;
+ /**
+ * The event number
+ */
+ long LHEeventnum;
+
/**
* If the maximum cross section of this reader has been increased