CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
heppy::Hemisphere Class Reference

#include <Hemisphere.h>

Public Member Functions

void ClearAllNoLists ()
 
std::vector< float > getAxis1 ()
 
std::vector< float > getAxis2 ()
 
std::vector< int > getGrouping ()
 
int GetNumLoop ()
 
 Hemisphere ()
 
 Hemisphere (std::vector< float > Px_vector, std::vector< float > Py_vector, std::vector< float > Pz_vector, std::vector< float > E_vector)
 
 Hemisphere (std::vector< float > Px_vector, std::vector< float > Py_vector, std::vector< float > Pz_vector, std::vector< float > E_vector, int seed_method, int hemisphere_association_method)
 
void RejectISRDRmax (float drmax)
 
void RejectISRPtmax (float ptmax)
 
void SetDebug (int debug)
 
void SetDRminSeed1 (float rmin)
 
void SetMethod (int seed_method, int hemisphere_association_method)
 
void SetnItermax (int niter)
 
void SetNoAssoc (int object_number)
 
void SetNoSeed (int object_number)
 
 ~Hemisphere ()
 

Private Member Functions

int Reconstruct ()
 
int RejectISR ()
 

Private Attributes

std::vector< float > Axis1
 
std::vector< float > Axis2
 
int dbg
 
float dRminSeed1
 
int hemi_meth
 
int nItermax
 
int numLoop
 
std::vector< float > Object_E
 
std::vector< float > Object_Eta
 
std::vector< int > Object_Group
 
std::vector< int > Object_Noassoc
 
std::vector< int > Object_Noseed
 
std::vector< float > Object_P
 
std::vector< float > Object_Phi
 
std::vector< float > Object_Pt
 
std::vector< float > Object_Px
 
std::vector< float > Object_Py
 
std::vector< float > Object_Pz
 
int rejectISR
 
int rejectISRDR
 
float rejectISRDRmax
 
int rejectISRPt
 
float rejectISRPtmax
 
int seed_meth
 
int status
 

Detailed Description

Definition at line 26 of file Hemisphere.h.

Constructor & Destructor Documentation

◆ Hemisphere() [1/3]

heppy::Hemisphere::Hemisphere ( )
inline

Definition at line 71 of file Hemisphere.h.

71 {};

◆ Hemisphere() [2/3]

heppy::Hemisphere::Hemisphere ( std::vector< float >  Px_vector,
std::vector< float >  Py_vector,
std::vector< float >  Pz_vector,
std::vector< float >  E_vector,
int  seed_method,
int  hemisphere_association_method 
)

Definition at line 14 of file Hemisphere.cc.

20  : Object_Px(Px_vector),
21  Object_Py(Py_vector),
22  Object_Pz(Pz_vector),
23  Object_E(E_vector),
24  seed_meth(seed_method),
25  hemi_meth(hemisphere_association_method),
26  status(0),
27  dRminSeed1(0.5),
28  nItermax(100),
29  rejectISR(0),
30  rejectISRPt(0),
31  rejectISRPtmax(10000.),
32  rejectISRDR(0),
33  rejectISRDRmax(100.),
34  dbg(0) {
35  for (int i = 0; i < (int)Object_Px.size(); i++) {
36  Object_Noseed.push_back(0);
37  Object_Noassoc.push_back(0);
38  }
39  numLoop = 0;
40  }

References mps_fire::i, createfilelist::int, numLoop, Object_Noassoc, Object_Noseed, and Object_Px.

◆ Hemisphere() [3/3]

heppy::Hemisphere::Hemisphere ( std::vector< float >  Px_vector,
std::vector< float >  Py_vector,
std::vector< float >  Pz_vector,
std::vector< float >  E_vector 
)

Definition at line 44 of file Hemisphere.cc.

48  : Object_Px(Px_vector),
49  Object_Py(Py_vector),
50  Object_Pz(Pz_vector),
51  Object_E(E_vector),
52  seed_meth(0),
53  hemi_meth(0),
54  status(0),
55  dRminSeed1(0.5),
56  nItermax(100),
57  rejectISR(0),
58  rejectISRPt(0),
59  rejectISRPtmax(10000.),
60  rejectISRDR(0),
61  rejectISRDRmax(100.),
62  dbg(0) {
63  for (int i = 0; i < (int)Object_Px.size(); i++) {
64  Object_Noseed.push_back(0);
65  Object_Noassoc.push_back(0);
66  }
67  numLoop = 0;
68  }

References mps_fire::i, createfilelist::int, numLoop, Object_Noassoc, Object_Noseed, and Object_Px.

◆ ~Hemisphere()

heppy::Hemisphere::~Hemisphere ( )
inline

Definition at line 86 of file Hemisphere.h.

86 {};

Member Function Documentation

◆ ClearAllNoLists()

void heppy::Hemisphere::ClearAllNoLists ( )
inline

Definition at line 125 of file Hemisphere.h.

125  {
126  for (int i = 0; i < (int)Object_Noseed.size(); ++i) {
127  Object_Noassoc[i] = 0;
128  Object_Noseed[i] = 0;
129  status = 0;
130  }
131  }

References mps_fire::i, createfilelist::int, Object_Noassoc, Object_Noseed, and status.

◆ getAxis1()

vector< float > heppy::Hemisphere::getAxis1 ( )

Definition at line 70 of file Hemisphere.cc.

70  {
71  if (status != 1) {
72  if (rejectISR == 0) {
73  this->Reconstruct();
74  } else {
75  this->RejectISR();
76  }
77  }
78  return Axis1;
79  }

References Axis1, Reconstruct(), RejectISR(), rejectISR, and status.

◆ getAxis2()

vector< float > heppy::Hemisphere::getAxis2 ( )

Definition at line 80 of file Hemisphere.cc.

80  {
81  if (status != 1) {
82  if (rejectISR == 0) {
83  this->Reconstruct();
84  } else {
85  this->RejectISR();
86  }
87  }
88  return Axis2;
89  }

References Axis2, Reconstruct(), RejectISR(), rejectISR, and status.

◆ getGrouping()

vector< int > heppy::Hemisphere::getGrouping ( )

Definition at line 91 of file Hemisphere.cc.

91  {
92  if (status != 1) {
93  if (rejectISR == 0) {
94  this->Reconstruct();
95  } else {
96  this->RejectISR();
97  }
98  }
99  return Object_Group;
100  }

References Object_Group, Reconstruct(), RejectISR(), rejectISR, and status.

◆ GetNumLoop()

int heppy::Hemisphere::GetNumLoop ( )
inline

Definition at line 161 of file Hemisphere.h.

161 { return numLoop; }

References numLoop.

◆ Reconstruct()

int heppy::Hemisphere::Reconstruct ( )
private

Definition at line 102 of file Hemisphere.cc.

102  {
103  // Performs the actual hemisphere reconstrucion
104  //
105  // definition of the vectors used internally:
106  // Object_xxx :
107  // xxx = Px, Py, Pz, E for input values
108  // xxx = P, Pt, Eta, Phi, Group for internal use
109  // Axis1 : final hemisphere axis 1
110  // Axis2 : final hemisphere axis 2
111  // Sum1_xxx : hemisphere 1 being updated during the association iterations
112  // Sum2_xxx : hemisphere 2 being updated during the association iterations
113  // NewAxis1_xxx, NewAxis1_xxx : temporary axes for calculation in association methods 2 and 3
114 
115  numLoop = 0; // initialize numLoop for Zero
116  int vsize = (int)Object_Px.size();
117  if ((int)Object_Py.size() != vsize || (int)Object_Pz.size() != vsize) {
118  cout << "WARNING!!!!! Input vectors have different size! Fix it!" << endl;
119  return 0;
120  }
121  if (dbg > 0) {
122  // cout << " Hemisphere method, vsn = " << hemivsn << endl;
123  cout << " Hemisphere method " << endl;
124  }
125 
126  // clear some vectors if method reconstruct() is called again
127  if (!Object_P.empty()) {
128  Object_P.clear();
129  Object_Pt.clear();
130  Object_Eta.clear();
131  Object_Phi.clear();
132  Object_Group.clear();
133  Axis1.clear();
134  Axis2.clear();
135  }
136  // initialize the vectors
137  for (int j = 0; j < vsize; ++j) {
138  Object_P.push_back(0);
139  Object_Pt.push_back(0);
140  Object_Eta.push_back(0);
141  Object_Phi.push_back(0);
142  Object_Group.push_back(0);
143  }
144  for (int j = 0; j < 5; ++j) {
145  Axis1.push_back(0);
146  Axis2.push_back(0);
147  }
148 
149  // compute additional quantities for vectors Object_xxx
150  float theta;
151  for (int i = 0; i < vsize; ++i) {
153  if (Object_P[i] > Object_E[i] + 0.001) {
154  cout << "WARNING!!!!! Object " << i << " has E = " << Object_E[i] << " less than P = " << Object_P[i]
155  << " *** Fix it!" << endl;
156  return 0;
157  }
159  // protection for div by 0
160  if (fabs(Object_Pz[i]) > 0.001) {
161  theta = atan(sqrt(Object_Px[i] * Object_Px[i] + Object_Py[i] * Object_Py[i]) / Object_Pz[i]);
162  } else {
163  theta = 1.570796327;
164  }
165  if (theta < 0.) {
166  theta = theta + 3.141592654;
167  }
168  Object_Eta[i] = -log(tan(0.5 * theta));
169  Object_Phi[i] = atan2(Object_Py[i], Object_Px[i]);
170  if (dbg > 0) {
171  cout << " Object " << i << " Eta = " << Object_Eta[i] << " Phi = " << Object_Phi[i] << endl;
172  }
173  }
174 
175  if (dbg > 0) {
176  cout << endl;
177  cout << " Seeding method = " << seed_meth << endl;
178  }
179  // I_Max and J_Max are indices of the seeds in the vectors
180  int I_Max = -1;
181  int J_Max = -1;
182 
183  // determine the seeds for seed method 1
184  if (seed_meth == 1) {
185  float P_Max = 0.;
186  float DeltaRP_Max = 0.;
187 
188  // take highest momentum object as first seed
189  for (int i = 0; i < vsize; ++i) {
190  Object_Group[i] = 0;
191  //cout << "Object_Px[i] = " << Object_Px[i] << ", Object_Py[i] = " << Object_Py[i]
192  //<< ", Object_Pz[i] = " << Object_Pz[i] << " << endl;
193  if (Object_Noseed[i] == 0 && P_Max < Object_P[i]) {
194  P_Max = Object_P[i];
195  I_Max = i;
196  }
197  }
198  // if 1st seed is found, save it as initial hemisphere 1 axis
199  if (I_Max >= 0) {
200  Axis1[0] = Object_Px[I_Max] / Object_P[I_Max];
201  Axis1[1] = Object_Py[I_Max] / Object_P[I_Max];
202  Axis1[2] = Object_Pz[I_Max] / Object_P[I_Max];
203  Axis1[3] = Object_P[I_Max];
204  Axis1[4] = Object_E[I_Max];
205  } else {
206  // cout << " This is an empty event." << endl;
207  return 0;
208  }
209 
210  // take as second seed the object with largest DR*P w.r.t. the first seed
211  for (int i = 0; i < vsize; ++i) {
212  // float DeltaR = sqrt((Object_Eta[i] - Object_Eta[I_Max])*(Object_Eta[i] - Object_Eta[I_Max])
213  // + (Util::DeltaPhi(Object_Phi[i], Object_Phi[I_Max]))*(Util::DeltaPhi(Object_Phi[i], Object_Phi[I_Max])) );
214  float DeltaR =
215  sqrt((Object_Eta[i] - Object_Eta[I_Max]) * (Object_Eta[i] - Object_Eta[I_Max]) +
216  (deltaPhi(Object_Phi[i], Object_Phi[I_Max])) * (deltaPhi(Object_Phi[i], Object_Phi[I_Max])));
217  if (Object_Noseed[i] == 0 && DeltaR > dRminSeed1) {
218  float DeltaRP = DeltaR * Object_P[i];
219  if (DeltaRP > DeltaRP_Max) {
220  DeltaRP_Max = DeltaRP;
221  J_Max = i;
222  }
223  }
224  }
225  // if 2nd seed is found, save it as initial hemisphere 2 axis
226  if (J_Max >= 0) {
227  Axis2[0] = Object_Px[J_Max] / Object_P[J_Max];
228  Axis2[1] = Object_Py[J_Max] / Object_P[J_Max];
229  Axis2[2] = Object_Pz[J_Max] / Object_P[J_Max];
230  Axis2[3] = Object_P[J_Max];
231  Axis2[4] = Object_E[J_Max];
232  } else {
233  // cout << " This is a MONOJET." << endl;
234  return 0;
235  }
236  if (dbg > 0) {
237  cout << " Axis 1 is Object = " << I_Max << endl;
238  cout << " Axis 2 is Object = " << J_Max << endl;
239  }
240 
241  // determine the seeds for seed methods 2 and 3
242  } else if (seed_meth == 2 || seed_meth == 3) {
243  float Mass_Max = 0.;
244  float InvariantMass = 0.;
245 
246  // maximize the invariant mass of two objects
247  for (int i = 0; i < vsize; ++i) {
248  Object_Group[i] = 0;
249  if (Object_Noseed[i] == 0) {
250  for (int j = i + 1; j < vsize; ++j) {
251  if (Object_Noseed[j] == 0) {
252  // either the invariant mass
253  if (seed_meth == 2) {
254  InvariantMass = (Object_E[i] + Object_E[j]) * (Object_E[i] + Object_E[j]) -
255  (Object_Px[i] + Object_Px[j]) * (Object_Px[i] + Object_Px[j]) -
256  (Object_Py[i] + Object_Py[j]) * (Object_Py[i] + Object_Py[j]) -
257  (Object_Pz[i] + Object_Pz[j]) * (Object_Pz[i] + Object_Pz[j]);
258  }
259  // or the transverse mass
260  else if (seed_meth == 3) {
261  float pti = sqrt(Object_Px[i] * Object_Px[i] + Object_Py[i] * Object_Py[i]);
262  float ptj = sqrt(Object_Px[j] * Object_Px[j] + Object_Py[j] * Object_Py[j]);
263  InvariantMass = 2. * (pti * ptj - Object_Px[i] * Object_Px[j] - Object_Py[i] * Object_Py[j]);
264  }
265  if (Mass_Max < InvariantMass) {
266  Mass_Max = InvariantMass;
267  I_Max = i;
268  J_Max = j;
269  }
270  }
271  }
272  }
273  }
274 
275  // if both seeds are found, save them as initial hemisphere axes
276  if (J_Max > 0) {
277  Axis1[0] = Object_Px[I_Max] / Object_P[I_Max];
278  Axis1[1] = Object_Py[I_Max] / Object_P[I_Max];
279  Axis1[2] = Object_Pz[I_Max] / Object_P[I_Max];
280  Axis1[3] = Object_P[I_Max];
281  Axis1[4] = Object_E[I_Max];
282 
283  Axis2[0] = Object_Px[J_Max] / Object_P[J_Max];
284  Axis2[1] = Object_Py[J_Max] / Object_P[J_Max];
285  Axis2[2] = Object_Pz[J_Max] / Object_P[J_Max];
286  Axis2[3] = Object_P[J_Max];
287  Axis2[4] = Object_E[J_Max];
288  } else {
289  // cout << " This is a MONOJET." << endl;
290  return 0;
291  }
292  if (dbg > 0) {
293  cout << " Axis 1 is Object = " << I_Max << endl;
294  cout << " Axis 2 is Object = " << J_Max << endl;
295  }
296 
297  } else if (seed_meth == 4) {
298  float P_Max1 = 0.;
299  float P_Max2 = 0.;
300 
301  // take largest Pt object as first seed
302  for (int i = 0; i < vsize; ++i) {
303  Object_Group[i] = 0;
304  if (Object_Noseed[i] == 0 && P_Max1 < Object_Pt[i]) {
305  P_Max1 = Object_Pt[i];
306  I_Max = i;
307  }
308  }
309  if (I_Max < 0)
310  return 0;
311 
312  // take second largest Pt object as second seed, but require dR(seed1, seed2) > dRminSeed1
313  for (int i = 0; i < vsize; ++i) {
314  if (i == I_Max)
315  continue;
316  // float DeltaR = Util::GetDeltaR(Object_Eta[i], Object_Eta[I_Max], Object_Phi[i], Object_Phi[I_Max]);
317  float DeltaR = deltaR(Object_Eta[i], Object_Eta[I_Max], Object_Phi[i], Object_Phi[I_Max]);
318  if (Object_Noseed[i] == 0 && P_Max2 < Object_Pt[i] && DeltaR > dRminSeed1) {
319  P_Max2 = Object_Pt[i];
320  J_Max = i;
321  }
322  }
323  if (J_Max < 0)
324  return 0;
325 
326  // save first seed as initial hemisphere 1 axis
327  if (I_Max >= 0) {
328  Axis1[0] = Object_Px[I_Max] / Object_P[I_Max];
329  Axis1[1] = Object_Py[I_Max] / Object_P[I_Max];
330  Axis1[2] = Object_Pz[I_Max] / Object_P[I_Max];
331  Axis1[3] = Object_P[I_Max];
332  Axis1[4] = Object_E[I_Max];
333  }
334 
335  // save second seed as initial hemisphere 2 axis
336  if (J_Max >= 0) {
337  Axis2[0] = Object_Px[J_Max] / Object_P[J_Max];
338  Axis2[1] = Object_Py[J_Max] / Object_P[J_Max];
339  Axis2[2] = Object_Pz[J_Max] / Object_P[J_Max];
340  Axis2[3] = Object_P[J_Max];
341  Axis2[4] = Object_E[J_Max];
342  }
343 
344  if (dbg > 0) {
345  cout << " Axis 1 is Object = " << I_Max << " with Pt " << Object_Pt[I_Max] << endl;
346  cout << " Axis 2 is Object = " << J_Max << " with Pt " << Object_Pt[J_Max] << endl;
347  }
348 
349  } else if (!(seed_meth == 0 && (hemi_meth == 8 || hemi_meth == 9))) {
350  cout << "Please give a valid seeding method!" << endl;
351  return 0;
352  }
353 
354  // seeding done
355  // now do the hemisphere association
356 
357  if (dbg > 0) {
358  cout << endl;
359  cout << " Association method = " << hemi_meth << endl;
360  }
361 
362  bool I_Move = true;
363 
364  // iterate to associate all objects to hemispheres (methods 1 to 3 only)
365  // until no objects are moved from one to the other hemisphere
366  // or the maximum number of iterations is reached
367  while (I_Move && (numLoop < nItermax) && hemi_meth != 8 && hemi_meth != 9) {
368  I_Move = false;
369  numLoop++;
370  if (dbg > 0) {
371  cout << " Iteration = " << numLoop << endl;
372  }
373  if (numLoop == nItermax - 1) {
374  cout << " Hemishpere: warning - reaching max number of iterations " << endl;
375  }
376 
377  // initialize the current sums of Px, Py, Pz, E for the two hemispheres
378  float Sum1_Px = 0.;
379  float Sum1_Py = 0.;
380  float Sum1_Pz = 0.;
381  float Sum1_E = 0.;
382  float Sum2_Px = 0.;
383  float Sum2_Py = 0.;
384  float Sum2_Pz = 0.;
385  float Sum2_E = 0.;
386 
387  // associate the objects for method 1
388  if (hemi_meth == 1) {
389  for (int i = 0; i < vsize; ++i) {
390  if (Object_Noassoc[i] == 0) {
391  float P_Long1 = Object_Px[i] * Axis1[0] + Object_Py[i] * Axis1[1] + Object_Pz[i] * Axis1[2];
392  float P_Long2 = Object_Px[i] * Axis2[0] + Object_Py[i] * Axis2[1] + Object_Pz[i] * Axis2[2];
393  if (P_Long1 >= P_Long2) {
394  if (Object_Group[i] != 1) {
395  I_Move = true;
396  }
397  Object_Group[i] = 1;
398  Sum1_Px += Object_Px[i];
399  Sum1_Py += Object_Py[i];
400  Sum1_Pz += Object_Pz[i];
401  Sum1_E += Object_E[i];
402  } else {
403  if (Object_Group[i] != 2) {
404  I_Move = true;
405  }
406  Object_Group[i] = 2;
407  Sum2_Px += Object_Px[i];
408  Sum2_Py += Object_Py[i];
409  Sum2_Pz += Object_Pz[i];
410  Sum2_E += Object_E[i];
411  }
412  }
413  }
414 
415  // associate the objects for methods 2 and 3
416  } else if (hemi_meth == 2 || hemi_meth == 3) {
417  for (int i = 0; i < vsize; ++i) {
418  // add the seeds to the sums, as they remain fixed
419  if (i == I_Max) {
420  Object_Group[i] = 1;
421  Sum1_Px += Object_Px[i];
422  Sum1_Py += Object_Py[i];
423  Sum1_Pz += Object_Pz[i];
424  Sum1_E += Object_E[i];
425  } else if (i == J_Max) {
426  Object_Group[i] = 2;
427  Sum2_Px += Object_Px[i];
428  Sum2_Py += Object_Py[i];
429  Sum2_Pz += Object_Pz[i];
430  Sum2_E += Object_E[i];
431 
432  // for the other objects
433  } else {
434  if (Object_Noassoc[i] == 0) {
435  // only 1 object maximum is moved in a given iteration
436  if (!I_Move) {
437  // initialize the new hemispheres as the current ones
438  float NewAxis1_Px = Axis1[0] * Axis1[3];
439  float NewAxis1_Py = Axis1[1] * Axis1[3];
440  float NewAxis1_Pz = Axis1[2] * Axis1[3];
441  float NewAxis1_E = Axis1[4];
442  float NewAxis2_Px = Axis2[0] * Axis2[3];
443  float NewAxis2_Py = Axis2[1] * Axis2[3];
444  float NewAxis2_Pz = Axis2[2] * Axis2[3];
445  float NewAxis2_E = Axis2[4];
446  // subtract the object from its hemisphere
447  if (Object_Group[i] == 1) {
448  NewAxis1_Px = NewAxis1_Px - Object_Px[i];
449  NewAxis1_Py = NewAxis1_Py - Object_Py[i];
450  NewAxis1_Pz = NewAxis1_Pz - Object_Pz[i];
451  NewAxis1_E = NewAxis1_E - Object_E[i];
452  } else if (Object_Group[i] == 2) {
453  NewAxis2_Px = NewAxis2_Px - Object_Px[i];
454  NewAxis2_Py = NewAxis2_Py - Object_Py[i];
455  NewAxis2_Pz = NewAxis2_Pz - Object_Pz[i];
456  NewAxis2_E = NewAxis2_E - Object_E[i];
457  }
458 
459  // compute the invariant mass squared with each hemisphere (method 2)
460  float mass1 = NewAxis1_E -
461  ((Object_Px[i] * NewAxis1_Px + Object_Py[i] * NewAxis1_Py + Object_Pz[i] * NewAxis1_Pz) /
462  Object_P[i]);
463  float mass2 = NewAxis2_E -
464  ((Object_Px[i] * NewAxis2_Px + Object_Py[i] * NewAxis2_Py + Object_Pz[i] * NewAxis2_Pz) /
465  Object_P[i]);
466  // or the Lund distance (method 3)
467  if (hemi_meth == 3) {
468  mass1 *= NewAxis1_E / ((NewAxis1_E + Object_E[i]) * (NewAxis1_E + Object_E[i]));
469  mass2 *= NewAxis2_E / ((NewAxis2_E + Object_E[i]) * (NewAxis2_E + Object_E[i]));
470  }
471  // and associate the object to the best hemisphere and add it to the sum
472  if (mass1 < mass2) {
473  //if (Object_Group[i] != 1){
474  if (Object_Group[i] != 1 && Object_Group[i] != 0) {
475  I_Move = true;
476  }
477  Object_Group[i] = 1;
478  Sum1_Px += Object_Px[i];
479  Sum1_Py += Object_Py[i];
480  Sum1_Pz += Object_Pz[i];
481  Sum1_E += Object_E[i];
482  } else {
483  //if (Object_Group[i] != 2){
484  if (Object_Group[i] != 2 && Object_Group[i] != 0) {
485  I_Move = true;
486  }
487  Object_Group[i] = 2;
488  Sum2_Px += Object_Px[i];
489  Sum2_Py += Object_Py[i];
490  Sum2_Pz += Object_Pz[i];
491  Sum2_E += Object_E[i];
492  }
493 
494  // but if a previous object was moved, add all other associated objects to the sum
495  } else {
496  if (Object_Group[i] == 1) {
497  Sum1_Px += Object_Px[i];
498  Sum1_Py += Object_Py[i];
499  Sum1_Pz += Object_Pz[i];
500  Sum1_E += Object_E[i];
501  } else if (Object_Group[i] == 2) {
502  Sum2_Px += Object_Px[i];
503  Sum2_Py += Object_Py[i];
504  Sum2_Pz += Object_Pz[i];
505  Sum2_E += Object_E[i];
506  }
507  }
508  }
509  } // end loop over objects, Sum1_ and Sum2_ are now the updated hemispheres
510  }
511 
512  } else {
513  cout << "Please give a valid hemisphere association method!" << endl;
514  return 0;
515  }
516 
517  // recomputing the axes for next iteration
518 
519  Axis1[3] = sqrt(Sum1_Px * Sum1_Px + Sum1_Py * Sum1_Py + Sum1_Pz * Sum1_Pz);
520  if (Axis1[3] < 0.0001) {
521  cout << "ZERO objects in group 1! " << endl;
522  } else {
523  Axis1[0] = Sum1_Px / Axis1[3];
524  Axis1[1] = Sum1_Py / Axis1[3];
525  Axis1[2] = Sum1_Pz / Axis1[3];
526  Axis1[4] = Sum1_E;
527  }
528  Axis2[3] = sqrt(Sum2_Px * Sum2_Px + Sum2_Py * Sum2_Py + Sum2_Pz * Sum2_Pz);
529  if (Axis2[3] < 0.0001) {
530  cout << " ZERO objects in group 2! " << endl;
531  } else {
532  Axis2[0] = Sum2_Px / Axis2[3];
533  Axis2[1] = Sum2_Py / Axis2[3];
534  Axis2[2] = Sum2_Pz / Axis2[3];
535  Axis2[4] = Sum2_E;
536  }
537 
538  if (dbg > 0) {
539  cout << " Grouping = ";
540  for (int i = 0; i < vsize; i++) {
541  cout << " " << Object_Group[i];
542  }
543  cout << endl;
544  }
545 
546  if (numLoop <= 1)
547  I_Move = true;
548 
549  } // end of iteration
550 
551  // associate all objects to hemispheres for method 8
552  if (hemi_meth == 8 || hemi_meth == 9) {
553  float sumtot = 0.;
554  for (int i = 0; i < vsize; ++i) {
555  if (Object_Noassoc[i] != 0)
556  continue;
557  if (hemi_meth == 8) {
558  sumtot += Object_E[i];
559  } else
560  sumtot += Object_Pt[i];
561  }
562  float sumdiff = fabs(sumtot - 2 * Object_E[0]);
563  float sum1strt = 0.;
564  int ibest = 0, jbest = 0;
565 
566  // start by choosing object 0 in hemi 1, all others in hemi 2
567  // then add each of the other objects one by one to hemi 1
568  // then add object 1 to hemi one and add each of the others in turn, etc
569  if (vsize > 2) {
570  for (int i = 0; i < vsize - 1; ++i) {
571  if (Object_Noassoc[i] != 0)
572  continue;
573  if (hemi_meth == 8) {
574  sum1strt += Object_E[i];
575  } else {
576  sum1strt += Object_Pt[i];
577  }
578  for (int j = i + 1; j < vsize; ++j) {
579  if (Object_Noassoc[j] != 0)
580  continue;
581  float sum1_E = 0;
582  if (hemi_meth == 8) {
583  sum1_E = sum1strt + Object_E[j];
584  } else {
585  sum1_E = sum1strt + Object_Pt[j];
586  }
587  float sum2_E = sumtot - sum1_E;
588  if (sumdiff >= fabs(sum1_E - sum2_E)) {
589  sumdiff = fabs(sum1_E - sum2_E);
590  ibest = i;
591  jbest = j;
592  }
593  }
594  }
595  }
596 
597  // then store the best combination into the hemisphere axes
598  float Sum1_Px = 0, Sum1_Py = 0, Sum1_Pz = 0, Sum1_E = 0;
599  float Sum2_Px = 0, Sum2_Py = 0, Sum2_Pz = 0, Sum2_E = 0;
600  for (int i = 0; i < vsize; ++i) {
601  if (Object_Noassoc[i] != 0)
602  Object_Group[i] = 0;
603  else if (i <= ibest || i == jbest) {
604  Sum1_Px += Object_Px[i];
605  Sum1_Py += Object_Py[i];
606  Sum1_Pz += Object_Pz[i];
607  Sum1_E += Object_E[i];
608  Object_Group[i] = 1;
609  } else {
610  Sum2_Px += Object_Px[i];
611  Sum2_Py += Object_Py[i];
612  Sum2_Pz += Object_Pz[i];
613  Sum2_E += Object_E[i];
614  Object_Group[i] = 2;
615  }
616  }
617  Axis1[3] = sqrt(Sum1_Px * Sum1_Px + Sum1_Py * Sum1_Py + Sum1_Pz * Sum1_Pz);
618  Axis1[0] = Sum1_Px / Axis1[3];
619  Axis1[1] = Sum1_Py / Axis1[3];
620  Axis1[2] = Sum1_Pz / Axis1[3];
621  Axis1[4] = Sum1_E;
622  Axis2[3] = sqrt(Sum2_Px * Sum2_Px + Sum2_Py * Sum2_Py + Sum2_Pz * Sum2_Pz);
623  Axis2[0] = Sum2_Px / Axis2[3];
624  Axis2[1] = Sum2_Py / Axis2[3];
625  Axis2[2] = Sum2_Pz / Axis2[3];
626  Axis2[4] = Sum2_E;
627  }
628 
629  status = 1;
630  return 1;
631  }

References Axis1, Axis2, gather_cfg::cout, dbg, SiPixelRawToDigiRegional_cfi::deltaPhi, PbPb_ZMuSkimMuonDPG_cff::deltaR, dRminSeed1, hemi_meth, mps_fire::i, createfilelist::int, dqmiolumiharvest::j, dqm-mbProfile::log, nItermax, numLoop, Object_E, Object_Eta, Object_Group, Object_Noassoc, Object_Noseed, Object_P, Object_Phi, Object_Pt, Object_Px, Object_Py, Object_Pz, seed_meth, mathSSE::sqrt(), status, funct::tan(), and theta().

Referenced by getAxis1(), getAxis2(), getGrouping(), and RejectISR().

◆ RejectISR()

int heppy::Hemisphere::RejectISR ( )
private

Definition at line 633 of file Hemisphere.cc.

633  {
634  // tries to avoid including ISR jets into hemispheres
635  //
636 
637  // iterate to remove all ISR objects from the hemispheres
638  // until no ISR objects are found
639  // cout << " entered RejectISR() with rejectISRDR = " << rejectISRDR << endl;
640  bool I_Move = true;
641  while (I_Move) {
642  I_Move = false;
643  float valmax = 0.;
644  int imax = -1;
645 
646  // start by making a hemisphere reconstruction
647  int hemiOK = Reconstruct();
648  if (hemiOK == 0) {
649  return 0;
650  }
651 
652  // convert the axes into Px, Py, Pz, E vectors
653  float newAxis1_Px = Axis1[0] * Axis1[3];
654  float newAxis1_Py = Axis1[1] * Axis1[3];
655  float newAxis1_Pz = Axis1[2] * Axis1[3];
656  //float newAxis1_E = Axis1[4];
657  float newAxis2_Px = Axis2[0] * Axis2[3];
658  float newAxis2_Py = Axis2[1] * Axis2[3];
659  float newAxis2_Pz = Axis2[2] * Axis2[3];
660  //float newAxis2_E = Axis2[4];
661 
662  // loop over all objects associated to a hemisphere
663  int vsize = (int)Object_Px.size();
664  for (int i = 0; i < vsize; ++i) {
665  if (Object_Group[i] == 1 || Object_Group[i] == 2) {
666  // cout << " Object = " << i << ", Object_Group = " << Object_Group[i] << endl;
667 
668  // collect the hemisphere data
669  float newPx = 0.;
670  float newPy = 0.;
671  float newPz = 0.;
672  //float newE = 0.;
673  if (Object_Group[i] == 1) {
674  newPx = newAxis1_Px;
675  newPy = newAxis1_Py;
676  newPz = newAxis1_Pz;
677  //newE = newAxis1_E;
678  } else if (Object_Group[i] == 2) {
679  newPx = newAxis2_Px;
680  newPy = newAxis2_Py;
681  newPz = newAxis2_Pz;
682  //newE = newAxis2_E;
683  }
684 
685  // compute the quantities to test whether the object is ISR
686  float ptHemi = 0.;
687  float hemiEta = 0.;
688  float hemiPhi = 0.;
689  if (rejectISRPt == 1) {
690  float plHemi = (Object_Px[i] * newPx + Object_Py[i] * newPy + Object_Pz[i] * newPz) /
691  sqrt(newPx * newPx + newPy * newPy + newPz * newPz);
692  float pObjsq = Object_Px[i] * Object_Px[i] + Object_Py[i] * Object_Py[i] + Object_Pz[i] * Object_Pz[i];
693  ptHemi = sqrt(pObjsq - plHemi * plHemi);
694  if (ptHemi > valmax) {
695  valmax = ptHemi;
696  imax = i;
697  }
698  } else if (rejectISRDR == 1) {
699  float theta = 1.570796327;
700  // compute the new hemisphere eta, phi and DeltaR
701  float pdiff = fabs(newPx - Object_Px[i]) + fabs(newPy - Object_Py[i]) + fabs(newPz - Object_Pz[i]);
702  if (pdiff > 0.001) {
703  if (fabs(newPz) > 0.001) {
704  theta = atan(sqrt(newPx * newPx + newPy * newPy) / newPz);
705  }
706  if (theta < 0.) {
707  theta = theta + 3.141592654;
708  }
709  hemiEta = -log(tan(0.5 * theta));
710  hemiPhi = atan2(newPy, newPx);
711  // float DeltaR = sqrt((Object_Eta[i] - hemiEta)*(Object_Eta[i] - hemiEta)
712  // + (Util::DeltaPhi(Object_Phi[i], hemiPhi))*(Util::DeltaPhi(Object_Phi[i], hemiPhi)) );
713  float DeltaR = sqrt((Object_Eta[i] - hemiEta) * (Object_Eta[i] - hemiEta) +
714  (deltaPhi(Object_Phi[i], hemiPhi)) * (deltaPhi(Object_Phi[i], hemiPhi)));
715  // cout << " Object = " << i << ", DeltaR = " << DeltaR << endl;
716  if (DeltaR > valmax) {
717  valmax = DeltaR;
718  imax = i;
719  }
720  }
721  }
722  }
723  } // end loop over objects
724 
725  // verify whether the ISR tests are fulfilled
726  if (imax < 0) {
727  I_Move = false;
728  } else if (rejectISRPt == 1 && valmax > rejectISRPtmax) {
729  SetNoAssoc(imax);
730  I_Move = true;
731  } else if (rejectISRDR == 1 && valmax > rejectISRDRmax) {
732  SetNoAssoc(imax);
733  I_Move = true;
734  }
735 
736  } // end iteration over ISR objects
737 
738  status = 1;
739  return 1;
740  }

References Axis1, Axis2, SiPixelRawToDigiRegional_cfi::deltaPhi, electronAnalyzer_cfi::DeltaR, mps_fire::i, createfilelist::int, dqm-mbProfile::log, Object_Eta, Object_Group, Object_Phi, Object_Px, Object_Py, Object_Pz, Reconstruct(), rejectISRDR, rejectISRDRmax, rejectISRPt, rejectISRPtmax, SetNoAssoc(), mathSSE::sqrt(), status, funct::tan(), and theta().

Referenced by getAxis1(), getAxis2(), and getGrouping().

◆ RejectISRDRmax()

void heppy::Hemisphere::RejectISRDRmax ( float  drmax)
inline

Definition at line 151 of file Hemisphere.h.

151  {
152  rejectISRDRmax = drmax;
153  rejectISRDR = 1;
154  rejectISRPt = 0;
155  rejectISR = 1;
156  status = 0;
157  }

References rejectISR, rejectISRDR, rejectISRDRmax, rejectISRPt, and status.

◆ RejectISRPtmax()

void heppy::Hemisphere::RejectISRPtmax ( float  ptmax)
inline

Definition at line 142 of file Hemisphere.h.

142  {
144  rejectISRPt = 1;
145  rejectISRDR = 0;
146  rejectISR = 1;
147  status = 0;
148  }

References muonTiming_cfi::ptmax, rejectISR, rejectISRDR, rejectISRPt, rejectISRPtmax, and status.

◆ SetDebug()

void heppy::Hemisphere::SetDebug ( int  debug)
inline

Definition at line 160 of file Hemisphere.h.

160 { dbg = debug; }

References dbg, and debug.

◆ SetDRminSeed1()

void heppy::Hemisphere::SetDRminSeed1 ( float  rmin)
inline

Definition at line 135 of file Hemisphere.h.

135 { dRminSeed1 = rmin; }

References dRminSeed1.

◆ SetMethod()

void heppy::Hemisphere::SetMethod ( int  seed_method,
int  hemisphere_association_method 
)
inline

Definition at line 102 of file Hemisphere.h.

102  {
103  seed_meth = seed_method;
104  hemi_meth = hemisphere_association_method;
105  status = 0;
106  }

References hemi_meth, seed_meth, and status.

◆ SetnItermax()

void heppy::Hemisphere::SetnItermax ( int  niter)
inline

Definition at line 139 of file Hemisphere.h.

139 { nItermax = niter; }

References nItermax.

◆ SetNoAssoc()

void heppy::Hemisphere::SetNoAssoc ( int  object_number)
inline

Definition at line 117 of file Hemisphere.h.

117  {
118  Object_Noassoc[object_number] = 1;
119  Object_Noseed[object_number] = 1;
120  status = 0;
121  }

References Object_Noassoc, Object_Noseed, and status.

Referenced by RejectISR().

◆ SetNoSeed()

void heppy::Hemisphere::SetNoSeed ( int  object_number)
inline

Definition at line 110 of file Hemisphere.h.

110  {
111  Object_Noseed[object_number] = 1;
112  status = 0;
113  }

References Object_Noseed, and status.

Member Data Documentation

◆ Axis1

std::vector<float> heppy::Hemisphere::Axis1
private

Definition at line 180 of file Hemisphere.h.

Referenced by getAxis1(), Reconstruct(), and RejectISR().

◆ Axis2

std::vector<float> heppy::Hemisphere::Axis2
private

Definition at line 181 of file Hemisphere.h.

Referenced by getAxis2(), Reconstruct(), and RejectISR().

◆ dbg

int heppy::Hemisphere::dbg
private

Definition at line 194 of file Hemisphere.h.

Referenced by Reconstruct(), and SetDebug().

◆ dRminSeed1

float heppy::Hemisphere::dRminSeed1
private

Definition at line 187 of file Hemisphere.h.

Referenced by Reconstruct(), and SetDRminSeed1().

◆ hemi_meth

int heppy::Hemisphere::hemi_meth
private

Definition at line 185 of file Hemisphere.h.

Referenced by Reconstruct(), and SetMethod().

◆ nItermax

int heppy::Hemisphere::nItermax
private

Definition at line 188 of file Hemisphere.h.

Referenced by Reconstruct(), and SetnItermax().

◆ numLoop

int heppy::Hemisphere::numLoop
private

Definition at line 195 of file Hemisphere.h.

Referenced by GetNumLoop(), Hemisphere(), and Reconstruct().

◆ Object_E

std::vector<float> heppy::Hemisphere::Object_E
private

Definition at line 173 of file Hemisphere.h.

Referenced by Reconstruct().

◆ Object_Eta

std::vector<float> heppy::Hemisphere::Object_Eta
private

Definition at line 175 of file Hemisphere.h.

Referenced by Reconstruct(), and RejectISR().

◆ Object_Group

std::vector<int> heppy::Hemisphere::Object_Group
private

Definition at line 176 of file Hemisphere.h.

Referenced by getGrouping(), Reconstruct(), and RejectISR().

◆ Object_Noassoc

std::vector<int> heppy::Hemisphere::Object_Noassoc
private

Definition at line 178 of file Hemisphere.h.

Referenced by ClearAllNoLists(), Hemisphere(), Reconstruct(), and SetNoAssoc().

◆ Object_Noseed

std::vector<int> heppy::Hemisphere::Object_Noseed
private

Definition at line 177 of file Hemisphere.h.

Referenced by ClearAllNoLists(), Hemisphere(), Reconstruct(), SetNoAssoc(), and SetNoSeed().

◆ Object_P

std::vector<float> heppy::Hemisphere::Object_P
private

Definition at line 171 of file Hemisphere.h.

Referenced by Reconstruct().

◆ Object_Phi

std::vector<float> heppy::Hemisphere::Object_Phi
private

Definition at line 174 of file Hemisphere.h.

Referenced by Reconstruct(), and RejectISR().

◆ Object_Pt

std::vector<float> heppy::Hemisphere::Object_Pt
private

Definition at line 172 of file Hemisphere.h.

Referenced by Reconstruct().

◆ Object_Px

std::vector<float> heppy::Hemisphere::Object_Px
private

Definition at line 168 of file Hemisphere.h.

Referenced by Hemisphere(), Reconstruct(), and RejectISR().

◆ Object_Py

std::vector<float> heppy::Hemisphere::Object_Py
private

Definition at line 169 of file Hemisphere.h.

Referenced by Reconstruct(), and RejectISR().

◆ Object_Pz

std::vector<float> heppy::Hemisphere::Object_Pz
private

Definition at line 170 of file Hemisphere.h.

Referenced by Reconstruct(), and RejectISR().

◆ rejectISR

int heppy::Hemisphere::rejectISR
private

Definition at line 189 of file Hemisphere.h.

Referenced by getAxis1(), getAxis2(), getGrouping(), RejectISRDRmax(), and RejectISRPtmax().

◆ rejectISRDR

int heppy::Hemisphere::rejectISRDR
private

Definition at line 192 of file Hemisphere.h.

Referenced by RejectISR(), RejectISRDRmax(), and RejectISRPtmax().

◆ rejectISRDRmax

float heppy::Hemisphere::rejectISRDRmax
private

Definition at line 193 of file Hemisphere.h.

Referenced by RejectISR(), and RejectISRDRmax().

◆ rejectISRPt

int heppy::Hemisphere::rejectISRPt
private

Definition at line 190 of file Hemisphere.h.

Referenced by RejectISR(), RejectISRDRmax(), and RejectISRPtmax().

◆ rejectISRPtmax

float heppy::Hemisphere::rejectISRPtmax
private

Definition at line 191 of file Hemisphere.h.

Referenced by RejectISR(), and RejectISRPtmax().

◆ seed_meth

int heppy::Hemisphere::seed_meth
private

Definition at line 184 of file Hemisphere.h.

Referenced by Reconstruct(), and SetMethod().

◆ status

int heppy::Hemisphere::status
private
mps_fire.i
i
Definition: mps_fire.py:355
heppy::Hemisphere::dRminSeed1
float dRminSeed1
Definition: Hemisphere.h:187
heppy::Hemisphere::rejectISRDRmax
float rejectISRDRmax
Definition: Hemisphere.h:193
heppy::Hemisphere::Object_Pz
std::vector< float > Object_Pz
Definition: Hemisphere.h:170
heppy::Hemisphere::Object_P
std::vector< float > Object_P
Definition: Hemisphere.h:171
gather_cfg.cout
cout
Definition: gather_cfg.py:144
heppy::Hemisphere::Object_Noseed
std::vector< int > Object_Noseed
Definition: Hemisphere.h:177
heppy::Hemisphere::hemi_meth
int hemi_meth
Definition: Hemisphere.h:185
heppy::Hemisphere::Object_Group
std::vector< int > Object_Group
Definition: Hemisphere.h:176
heppy::Hemisphere::Object_Py
std::vector< float > Object_Py
Definition: Hemisphere.h:169
heppy::Hemisphere::rejectISRDR
int rejectISRDR
Definition: Hemisphere.h:192
heppy::Hemisphere::numLoop
int numLoop
Definition: Hemisphere.h:195
heppy::Hemisphere::Axis1
std::vector< float > Axis1
Definition: Hemisphere.h:180
debug
#define debug
Definition: HDRShower.cc:19
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
heppy::Hemisphere::Object_Eta
std::vector< float > Object_Eta
Definition: Hemisphere.h:175
heppy::Hemisphere::Axis2
std::vector< float > Axis2
Definition: Hemisphere.h:181
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
heppy::Hemisphere::nItermax
int nItermax
Definition: Hemisphere.h:188
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
heppy::Hemisphere::seed_meth
int seed_meth
Definition: Hemisphere.h:184
heppy::Hemisphere::rejectISR
int rejectISR
Definition: Hemisphere.h:189
heppy::Hemisphere::dbg
int dbg
Definition: Hemisphere.h:194
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
DeltaR
Definition: DeltaR.py:1
heppy::Hemisphere::Object_Px
std::vector< float > Object_Px
Definition: Hemisphere.h:168
heppy::Hemisphere::Object_Noassoc
std::vector< int > Object_Noassoc
Definition: Hemisphere.h:178
heppy::Hemisphere::Object_Phi
std::vector< float > Object_Phi
Definition: Hemisphere.h:174
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
createfilelist.int
int
Definition: createfilelist.py:10
electronAnalyzer_cfi.DeltaR
DeltaR
Definition: electronAnalyzer_cfi.py:33
muonTiming_cfi.ptmax
ptmax
Definition: muonTiming_cfi.py:22
heppy::Hemisphere::Object_Pt
std::vector< float > Object_Pt
Definition: Hemisphere.h:172
InvariantMass
Definition: InvariantMass.h:6
heppy::Hemisphere::RejectISR
int RejectISR()
Definition: Hemisphere.cc:633
heppy::Hemisphere::SetNoAssoc
void SetNoAssoc(int object_number)
Definition: Hemisphere.h:117
heppy::Hemisphere::Reconstruct
int Reconstruct()
Definition: Hemisphere.cc:102
heppy::Hemisphere::Object_E
std::vector< float > Object_E
Definition: Hemisphere.h:173
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
heppy::Hemisphere::rejectISRPtmax
float rejectISRPtmax
Definition: Hemisphere.h:191
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
heppy::Hemisphere::rejectISRPt
int rejectISRPt
Definition: Hemisphere.h:190
heppy::Hemisphere::status
int status
Definition: Hemisphere.h:186