test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Megajet.cc
Go to the documentation of this file.
2 
3 #include <vector>
4 #include <math.h>
5 #include <TLorentzVector.h>
6 
7 using namespace std;
8 
9 namespace heppy {
10 
11 // constructor specifying the association methods
12 Megajet::Megajet(vector<float> Px_vector, vector<float> Py_vector, vector<float> Pz_vector,
13  vector<float> E_vector, int megajet_association_method) :
14  Object_Px(Px_vector), Object_Py(Py_vector), Object_Pz(Pz_vector), Object_E(E_vector),
15  megajet_meth(megajet_association_method), status(0) {
16 
17  if(Object_Px.size() < 2) cout << "Error in Megajet: you should provide at least two jets to form Megajets" << endl;
18  for(int j=0; j<(int)jIN.size(); ++j) {
19  jIN.push_back(TLorentzVector(Object_Px[j],Object_Py[j],Object_Pz[j],Object_E[j]));
20  }
21 }
22 
23 // constructor without specification of the seed and association methods
24 // in this case, the latter must be given by calling SetMethod before invoking Combine()
25 Megajet::Megajet(vector<float> Px_vector, vector<float> Py_vector, vector<float> Pz_vector,
26  vector<float> E_vector) :
27  Object_Px(Px_vector), Object_Py(Py_vector), Object_Pz(Pz_vector), Object_E(E_vector),
28  status(0) {
29 
30  if(Object_Px.size() < 2) cout << "Error in Megajet: you should provide at least two jets to form Megajets" << endl;
31  for(int j=0; j<(int)jIN.size(); ++j) {
32  jIN.push_back(TLorentzVector(Object_Px[j],Object_Py[j],Object_Pz[j],Object_E[j]));
33  }
34 }
35 
36 vector<float> Megajet::getAxis1(){
37  if (status != 1) {
38  this->Combine();
39  if( megajet_meth == 1) this->CombineMinMass();
40  else if(megajet_meth == 2) this->CombineMinHT();
41  else if(megajet_meth == 3) this->CombineMinEnergyMass();
42  else if(megajet_meth == 4) this->CombineGeorgi();
43  else this->CombineMinMass();
44  }
45  if(jIN.size() > 1) {
46  Axis1[0] = jOUT[0].Px() / jOUT[0].P();
47  Axis1[1] = jOUT[0].Py() / jOUT[0].P();
48  Axis1[2] = jOUT[0].Pz() / jOUT[0].P();
49  Axis1[3] = jOUT[0].P();
50  Axis1[4] = jOUT[0].E();
51  }
52  return Axis1;
53 }
54 vector<float> Megajet::getAxis2(){
55  if (status != 1) {
56  this->Combine();
57  if( megajet_meth == 1) this->CombineMinMass();
58  else if(megajet_meth == 2) this->CombineMinHT();
59  else if(megajet_meth == 3) this->CombineMinEnergyMass();
60  else if(megajet_meth == 4) this->CombineGeorgi();
61  else this->CombineMinMass();
62  }
63  if(jIN.size() > 1) {
64  Axis2[0] = jOUT[1].Px() / jOUT[1].P();
65  Axis2[1] = jOUT[1].Py() / jOUT[1].P();
66  Axis2[2] = jOUT[1].Pz() / jOUT[1].P();
67  Axis2[3] = jOUT[1].P();
68  Axis2[4] = jOUT[1].E();
69  }
70  return Axis2;
71 }
72 
74  int N_JETS = (int)jIN.size();
75 
76  int N_comb = 1;
77  for(int i = 0; i < N_JETS; i++){
78  N_comb *= 2;
79  }
80 
81  // clear some vectors if method Combine() is called again
82  if ( !j1.empty() ) {
83  j1.clear();
84  j2.clear();
85  Axis1.clear();
86  Axis2.clear();
87  }
88 
89  for(int j = 0; j < 5; ++j){
90  Axis1.push_back(0);
91  Axis2.push_back(0);
92  }
93 
94  int j_count;
95  for(int i = 1; i < N_comb-1; i++){
96  TLorentzVector j_temp1, j_temp2;
97  int itemp = i;
98  j_count = N_comb/2;
99  int count = 0;
100  while(j_count > 0){
101  if(itemp/j_count == 1){
102  j_temp1 += jIN[count];
103  } else {
104  j_temp2 += jIN[count];
105  }
106  itemp -= j_count*(itemp/j_count);
107  j_count /= 2;
108  count++;
109  }
110 
111  j1.push_back(j_temp1);
112  j2.push_back(j_temp2);
113  }
114 }
115 
117  double M_min = -1;
118  // default value (in case none is found)
119  TLorentzVector myJ1 = TLorentzVector(0,0,0,0);
120  TLorentzVector myJ2 = TLorentzVector(0,0,0,0);
121  for(int i=0; i<(int)j1.size(); i++) {
122  double M_temp = j1[i].M2()+j2[i].M2();
123  if(M_min < 0 || M_temp < M_min){
124  M_min = M_temp;
125  myJ1 = j1[i];
126  myJ2 = j2[i];
127  }
128  }
129  // myJ1.SetPtEtaPhiM(myJ1.Pt(),myJ1.Eta(),myJ1.Phi(),0.0);
130  // myJ2.SetPtEtaPhiM(myJ2.Pt(),myJ2.Eta(),myJ2.Phi(),0.0);
131 
132  jOUT.clear();
133  if(myJ1.Pt() > myJ2.Pt()){
134  jOUT.push_back(myJ1);
135  jOUT.push_back(myJ2);
136  } else {
137  jOUT.push_back(myJ2);
138  jOUT.push_back(myJ1);
139  }
140  status=1;
141 }
142 
144  double M_min = -1;
145  // default value (in case none is found)
146  TLorentzVector myJ1 = TLorentzVector(0,0,0,0);
147  TLorentzVector myJ2 = TLorentzVector(0,0,0,0);
148  for(int i=0; i<(int)j1.size(); i++) {
149  double M_temp = j1[i].M2()/j1[i].E()+j2[i].M2()/j2[i].E();
150  if(M_min < 0 || M_temp < M_min){
151  M_min = M_temp;
152  myJ1 = j1[i];
153  myJ2 = j2[i];
154  }
155  }
156 
157  // myJ1.SetPtEtaPhiM(myJ1.Pt(),myJ1.Eta(),myJ1.Phi(),0.0);
158  // myJ2.SetPtEtaPhiM(myJ2.Pt(),myJ2.Eta(),myJ2.Phi(),0.0);
159 
160  jOUT.clear();
161  if(myJ1.Pt() > myJ2.Pt()){
162  jOUT.push_back(myJ1);
163  jOUT.push_back(myJ2);
164  } else {
165  jOUT.push_back(myJ2);
166  jOUT.push_back(myJ1);
167  }
168  status=1;
169 }
170 
172  double M_max = -10000;
173  // default value (in case none is found)
174  TLorentzVector myJ1 = TLorentzVector(0,0,0,0);
175  TLorentzVector myJ2 = TLorentzVector(0,0,0,0);
176  for(int i=0; i<(int)j1.size(); i++) {
177  int myBeta = 2;
178  double M_temp = (j1[i].E()-myBeta*j1[i].M2()/j1[i].E())+(j2[i].E()-myBeta*j2[i].M2()/j2[i].E());
179  if(M_max < -9999 || M_temp > M_max){
180  M_max = M_temp;
181  myJ1 = j1[i];
182  myJ2 = j2[i];
183  }
184  }
185 
186  // myJ1.SetPtEtaPhiM(myJ1.Pt(),myJ1.Eta(),myJ1.Phi(),0.0);
187  // myJ2.SetPtEtaPhiM(myJ2.Pt(),myJ2.Eta(),myJ2.Phi(),0.0);
188 
189  jOUT.clear();
190  if(myJ1.Pt() > myJ2.Pt()){
191  jOUT.push_back(myJ1);
192  jOUT.push_back(myJ2);
193  } else {
194  jOUT.push_back(myJ2);
195  jOUT.push_back(myJ1);
196  }
197  status=1;
198 }
199 
201  double dHT_min = 999999999999999.0;
202  // default value (in case none is found)
203  TLorentzVector myJ1 = TLorentzVector(0,0,0,0);
204  TLorentzVector myJ2 = TLorentzVector(0,0,0,0);
205  for(int i=0; i<(int)j1.size(); i++) {
206  double dHT_temp = fabs(j1[i].E()-j2[i].E());
207  if(dHT_temp < dHT_min){
208  dHT_min = dHT_temp;
209  myJ1 = j1[i];
210  myJ2 = j2[i];
211  }
212  }
213 
214  jOUT.clear();
215  if(myJ1.Pt() > myJ2.Pt()){
216  jOUT.push_back(myJ1);
217  jOUT.push_back(myJ2);
218  } else {
219  jOUT.push_back(myJ2);
220  jOUT.push_back(myJ1);
221  }
222  status=1;
223 }
224 
225 }
int i
Definition: DBlmapReader.cc:9
std::vector< float > Object_E
Definition: Megajet.h:83
void CombineGeorgi()
Combining the jets in two hemispheres by maximizing (E1-Beta*m1^2/E1 + E2-Beta*m1^2/E2) ...
Definition: Megajet.cc:171
std::vector< float > Object_Pz
Definition: Megajet.h:82
std::vector< TLorentzVector > jIN
Definition: Megajet.h:92
std::vector< float > getAxis2()
Definition: Megajet.cc:54
std::vector< float > Axis2
Definition: Megajet.h:86
void CombineMinHT()
Definition: Megajet.cc:200
std::vector< TLorentzVector > jOUT
Definition: Megajet.h:93
std::vector< TLorentzVector > j1
Definition: Megajet.h:94
std::vector< TLorentzVector > j2
Definition: Megajet.h:95
int j
Definition: DBlmapReader.cc:9
std::vector< float > Object_Py
Definition: Megajet.h:81
std::vector< float > Object_Px
Definition: Megajet.h:80
void CombineMinMass()
Definition: Megajet.cc:116
int megajet_meth
Definition: Megajet.h:89
std::vector< float > Axis1
Definition: Megajet.h:85
tuple cout
Definition: gather_cfg.py:145
std::vector< float > getAxis1()
Definition: Megajet.cc:36
tuple status
Definition: mps_update.py:57
void Combine()
Combine the jets in all the possible pairs of hemispheres.
Definition: Megajet.cc:73
void CombineMinEnergyMass()
Combining the jets in two hemispheres by minimizing m1^2/E1 + m2^2/E2.
Definition: Megajet.cc:143