JHUGen MELA  v2.4.1
Matrix element calculations as used in JHUGen. MELA is an important tool that was used for the Higgs boson discovery and for precise measurements of its structure and interactions. Please see the website https://spin.pha.jhu.edu/ and papers cited there for more details, and kindly cite those papers when using this code.
Public Member Functions | Public Attributes | List of all members
ExtBin Struct Reference

Public Member Functions

void addEvent (float mass, float me, float me2, float weight=1)
 
void sift ()
 
void adjustWeights (float refth=3.)
 
void mergeBin (const ExtBin &other)
 
void addEvent (SimpleEntry evt)
 
void addEvent (int ev, float trueval, float recoval, float recotrackval=0, float weight=1)
 
void sortByRecoMinusTrueVals (vector< pair< float, int >> &res)
 
void sortByRecoVals (vector< pair< float, int >> &res)
 
void sift (double threshold=0.998, bool use_recominustrue=false)
 
void adjustWeights (float refth=-1)
 
void mergeBin (const ExtBin &other)
 

Public Attributes

double binlow
 
double binhigh
 
vector< int > events
 
vector< float > masses
 
vector< float > mevals
 
vector< float > me2vals
 
vector< float > weights
 
vector< SimpleEntrycollection
 

Detailed Description

Definition at line 111 of file calcC_lintolog.c.

Member Function Documentation

◆ addEvent() [1/3]

void ExtBin::addEvent ( float  mass,
float  me,
float  me2,
float  weight = 1 
)
inline

Definition at line 120 of file calcC_lintolog.c.

120  {
121  masses.push_back(mass);
122  mevals.push_back(me);
123  me2vals.push_back(me2);
124  weights.push_back(weight);
125  }

◆ addEvent() [2/3]

void ExtBin::addEvent ( int  ev,
float  trueval,
float  recoval,
float  recotrackval = 0,
float  weight = 1 
)
inline

Definition at line 185 of file getResolution.c.

185  {
186  SimpleEntry tmp(ev, trueval, recoval, recotrackval, weight);
187  collection.push_back(tmp);
188  }

◆ addEvent() [3/3]

void ExtBin::addEvent ( SimpleEntry  evt)
inline

Definition at line 182 of file getResolution.c.

182  {
183  collection.push_back(evt);
184  }

◆ adjustWeights() [1/2]

void ExtBin::adjustWeights ( float  refth = -1)
inline

Definition at line 228 of file getResolution.c.

228  {
229  if (collection.size()==0) return;
230 
231  vector<pair<float, int>> weight_entry;
232  for (unsigned int ev=0; ev<collection.size(); ev++) addByLowest<float, int>(weight_entry, collection.at(ev).weight, ev);
233  int bin=weight_entry.size()-1;
234 
235  int at99p0ev = (float(weight_entry.size()))*0.99;
236  if (at99p0ev==(int)weight_entry.size()) at99p0ev--;
237  float threshold = weight_entry.at(at99p0ev).first;
238  while (bin>at99p0ev){
239  if (
240  threshold*2.<weight_entry.at(bin).first
241  ){
242  if (weight_entry.at(bin).first==0.) cerr << "Weight=0!" << endl;
243  collection.at(weight_entry.at(bin).second).weight = pow(threshold, 2)/weight_entry.at(bin).first;
244  cout << "Adjusting weight for event " << bin << endl;
245  }
246  bin--;
247  }
248  float sum[2]={ 0 };
249  for (unsigned int ev=0; ev<collection.size(); ev++){
250  sum[0] += collection.at(ev).weight;
251  sum[1] += 1;
252  }
253  if (sum[0]==0. || sum[1]==0.) cerr << "sum[0]=" << sum[0] << " or sum[1]=" << sum[1] << " is invalid." << endl;
254  for (unsigned int ev=0; ev<collection.size(); ev++) collection.at(ev).weight *= sum[1]/sum[0];
255  if (refth>0.){
256  for (unsigned int ev=0; ev<collection.size(); ev++){
257  if (collection.at(ev).weight<=refth) continue;
258  collection.at(ev).weight = pow(refth, 2)/collection.at(ev).weight;
259  }
260  }
261  }

◆ adjustWeights() [2/2]

void ExtBin::adjustWeights ( float  refth = 3.)
inline

Definition at line 158 of file calcC_lintolog.c.

158  {
159  if (masses.size()==0) return;
160 
161  vector<pair<float, int>> weight_entry;
162  for (unsigned int ev=0; ev<masses.size(); ev++) addByLowest<float, int>(weight_entry, weights.at(ev), ev);
163  int bin=weight_entry.size()-1;
164 
165  int at99p0ev = (float(weight_entry.size()))*0.99;
166  if (at99p0ev==(int)weight_entry.size()) at99p0ev--;
167  float threshold = weight_entry.at(at99p0ev).first;
168  while (bin>at99p0ev){
169  if (
170  threshold*2.<weight_entry.at(bin).first
171  ){
172  weights.at(weight_entry.at(bin).second) = pow(threshold, 2)/weight_entry.at(bin).first;
173  cout << "Adjusting weight for event " << bin << endl;
174  }
175  bin--;
176  }
177  float sum[2]={ 0 };
178  for (unsigned int ev=0; ev<weights.size(); ev++){
179  sum[0] += weights.at(ev);
180  sum[1] += 1;
181  }
182  for (unsigned int ev=0; ev<weights.size(); ev++) weights.at(ev) *= sum[1]/sum[0];
183  if (refth>0.){
184  for (unsigned int ev=0; ev<weights.size(); ev++){
185  if (weights.at(ev)<=refth) continue;
186  weights.at(ev) = pow(refth, 2)/weights.at(ev);
187  }
188  }
189  }

◆ mergeBin() [1/2]

void ExtBin::mergeBin ( const ExtBin other)
inline

Definition at line 190 of file calcC_lintolog.c.

190  {
191  if (
192  other.events.size()!=other.masses.size()
193  ||
194  other.events.size()!=other.mevals.size()
195  ||
196  other.events.size()!=other.me2vals.size()
197  ||
198  other.events.size()!=other.weights.size()
199  ){
200  cerr << "Size of the following elements are not the same:" << endl;
201  cerr << "\t- Events: " << other.events.size() << endl;
202  cerr << "\t- Masses: " << other.masses.size() << endl;
203  cerr << "\t- MEs: " << other.mevals.size() << endl;
204  cerr << "\t- MEs (2): " << other.me2vals.size() << endl;
205  cerr << "\t- Weights: " << other.weights.size() << endl;
206  }
207  for (unsigned int ev=0; ev<other.events.size(); ev++){
208  events.push_back(other.events.at(ev));
209  addEvent(other.masses.at(ev), other.mevals.at(ev), other.me2vals.at(ev), other.weights.at(ev));
210  }
211  }

◆ mergeBin() [2/2]

void ExtBin::mergeBin ( const ExtBin other)
inline

Definition at line 262 of file getResolution.c.

262 { for (unsigned int ev=0; ev<other.collection.size(); ev++) collection.push_back(other.collection.at(ev)); }

◆ sift() [1/2]

void ExtBin::sift ( )
inline

Definition at line 126 of file calcC_lintolog.c.

126  {
127  if (masses.size()==0) return;
128 
129  vector<int> take_out;
130  vector<pair<float, int>> me_entry[2];
131  for (unsigned int ev=0; ev<masses.size(); ev++){
132  addByLowest<float, int>(me_entry[0], mevals.at(ev), ev);
133  addByLowest<float, int>(me_entry[1], me2vals.at(ev), ev);
134  }
135  for (unsigned int im=0; im<2; im++){
136  int at99p8ev = (float(me_entry[im].size()))*0.998;
137  if (at99p8ev==(int)me_entry[im].size()) at99p8ev--;
138  int bin=me_entry[im].size()-1;
139  while (bin>at99p8ev){
140  if (
141  me_entry[im].at(at99p8ev).first*2.<me_entry[im].at(bin).first
142  ) addByLowest<int>(take_out, me_entry[im].at(bin).second, true);
143  bin--;
144  }
145  }
146  for (int bin=take_out.size()-1; bin>=0; bin--){
147  int t_ev = take_out.at(bin);
148  cout << "Discarding event " << events.at(t_ev) << endl;
149  vector<int>::iterator itev;
150  vector<float>::iterator it;
151  itev=events.begin()+t_ev; events.erase(itev);
152  it=masses.begin()+t_ev; masses.erase(it);
153  it=mevals.begin()+t_ev; mevals.erase(it);
154  it=me2vals.begin()+t_ev; me2vals.erase(it);
155  it=weights.begin()+t_ev; weights.erase(it);
156  }
157  }

◆ sift() [2/2]

void ExtBin::sift ( double  threshold = 0.998,
bool  use_recominustrue = false 
)
inline

Definition at line 200 of file getResolution.c.

200  {
201  if (collection.size()==0) return;
202 
203  vector<int> take_out;
204  vector<pair<float, int>> theEntries;
205  if (!use_recominustrue) sortByRecoVals(theEntries);
206  else sortByRecoMinusTrueVals(theEntries);
207  for (unsigned int im=0; im<2; im++){
208  int at99p8ev = std::floor((float(theEntries.size()))*threshold);
209  int bin=theEntries.size()-1;
210  while (bin>at99p8ev){
211  if (
212  theEntries.at(at99p8ev).first*2.<theEntries.at(bin).first
213  ) addByLowest<int>(take_out, theEntries.at(bin).second, true);
214  bin--;
215  }
216  }
217  for (int bin=take_out.size()-1; bin>=0; bin--){
218  int t_ev = take_out.at(bin);
219  cout << "Attempting to discard event at position " << t_ev << endl;
220  if (t_ev>=(int)collection.size()) cerr << "Collection size " << collection.size() << " >= " << t_ev << endl;
221  else{
222  cout << "Discarding event " << collection.at(t_ev).id << " at position " << t_ev << endl;
223  vector<SimpleEntry>::iterator it;
224  it=collection.begin()+t_ev; collection.erase(it);
225  }
226  }
227  }

◆ sortByRecoMinusTrueVals()

void ExtBin::sortByRecoMinusTrueVals ( vector< pair< float, int >> &  res)
inline

Definition at line 189 of file getResolution.c.

189  {
190  res.clear();
191  for (unsigned int ev=0; ev<collection.size(); ev++){
192  float val = collection.at(ev).recoval/collection.at(ev).trueval-1.;
193  addByLowest<float, int>(res, val, ev);
194  }
195  }

◆ sortByRecoVals()

void ExtBin::sortByRecoVals ( vector< pair< float, int >> &  res)
inline

Definition at line 196 of file getResolution.c.

196  {
197  res.clear();
198  for (unsigned int ev=0; ev<collection.size(); ev++) addByLowest<float, int>(res, collection.at(ev).recoval, ev);
199  }

Member Data Documentation

◆ binhigh

double ExtBin::binhigh

Definition at line 113 of file calcC_lintolog.c.

◆ binlow

double ExtBin::binlow

Definition at line 112 of file calcC_lintolog.c.

◆ collection

vector<SimpleEntry> ExtBin::collection

Definition at line 180 of file getResolution.c.

◆ events

vector<int> ExtBin::events

Definition at line 114 of file calcC_lintolog.c.

◆ masses

vector<float> ExtBin::masses

Definition at line 115 of file calcC_lintolog.c.

◆ me2vals

vector<float> ExtBin::me2vals

Definition at line 117 of file calcC_lintolog.c.

◆ mevals

vector<float> ExtBin::mevals

Definition at line 116 of file calcC_lintolog.c.

◆ weights

vector<float> ExtBin::weights

Definition at line 118 of file calcC_lintolog.c.


The documentation for this struct was generated from the following files:
ExtBin::collection
vector< SimpleEntry > collection
Definition: getResolution.c:180
ExtBin::masses
vector< float > masses
Definition: calcC_lintolog.c:115
ExtBin::events
vector< int > events
Definition: calcC_lintolog.c:114
modparameters::ev
real(8), parameter, public ev
Definition: mod_Parameters.F90:97
SimpleEntry
Definition: getResolution.c:51
ExtBin::me2vals
vector< float > me2vals
Definition: calcC_lintolog.c:117
ExtBin::sortByRecoVals
void sortByRecoVals(vector< pair< float, int >> &res)
Definition: getResolution.c:196
dd_global::cout
integer cout
Definition: DD_global.F90:21
ExtBin::addEvent
void addEvent(float mass, float me, float me2, float weight=1)
Definition: calcC_lintolog.c:120
ExtBin::mevals
vector< float > mevals
Definition: calcC_lintolog.c:116
ExtBin::sortByRecoMinusTrueVals
void sortByRecoMinusTrueVals(vector< pair< float, int >> &res)
Definition: getResolution.c:189
hto_masses::me
real *8, parameter me
Definition: CALLING_cpHTO.f:77
ExtBin::weights
vector< float > weights
Definition: calcC_lintolog.c:118