FairRoot/PandaRoot
RhoEventShapes.cxx
Go to the documentation of this file.
1 #include "RhoEventShapes.h"
2 #include "RhoCandidate.h"
3 
5 
6 
7 RhoEventShapes::RhoEventShapes(RhoCandList &l, TLorentzVector cms) :
8  fnChrg(0), fnNeut(0), fN(0), fpmaxlab(0.), fpmaxcms(0.), fptmax(0.),
9  fptsumlab(0.),fneutetsumlab(0.),fneutesumlab(0.),fchrgptsumlab(0.),fchrgpsumlab(0.),
10  fptsumcms(0.),fneutetsumcms(0.),fneutesumcms(0.),fchrgptsumcms(0.),fchrgpsumcms(0.),
11  fsph(-1.), fapl(-1.), fpla(-1.), fFWready(false), fthr(-1.)
12 {
13  int i;
14 
15  // initialize more complex things
16  fThrVect.SetXYZ(0.,0.,0.);
17  fBoost=cms.BoostVector();
18  for (i=0;i<=FWMAX;++i) fFWmom[i]=0.;
19 
20 
21  double pmax=0., ptmax=0., pmaxcms=0.;
22 
23  fLabList.clear();
24  fCmsList.clear();
25 
26  for (i=0;i<l.GetLength();++i)
27  {
28  RhoCandidate* cand = l[i];
29  TLorentzVector lv(cand->P4());
30  int chrg(cand->Charge());
31 
32  fN++;
33 
34  // cache multiplicities
35  if (chrg==0) fnNeut++;
36  else fnChrg++;
37 
38  // cache unboosted 4-vectors
39  fLabList.push_back(lv);
40  // cache charges
41  fCharge.push_back(chrg);
42 
43  // sum momentum variables (lab)
44  fptsumlab += lv.Pt();
45  if (chrg==0)
46  {
47  fneutetsumlab += lv.Pt();
48  fneutesumlab += lv.E();
49  }
50  else
51  {
52  fchrgptsumlab += lv.Pt();
53  fchrgpsumlab += lv.P();
54  }
55 
56  // cache maximum momenta in lab
57  if (lv.P()>pmax) pmax=lv.P();
58  if (lv.Pt()>ptmax) ptmax=lv.Pt();
59 
60  // cache boosted vectors
61  lv.Boost(-fBoost);
62  fCmsList.push_back(lv);
63 
64  // sum momentum variables (cms)
65  fptsumcms += lv.Pt();
66  if (chrg==0)
67  {
68  fneutetsumcms += lv.Pt();
69  fneutesumcms += lv.E();
70  }
71  else
72  {
73  fchrgptsumcms += lv.Pt();
74  fchrgpsumcms += lv.P();
75  }
76 
77  // cache maximum momenta in cms
78  if (lv.P()>pmaxcms) pmaxcms=lv.P();
79  }
80 
81  fpmaxlab = pmax;
82  fptmax = ptmax;
83  fpmaxcms = pmaxcms;
84 }
85 
86 // ----------------------------
87 
89 {
90  if( fN==0 ) return;
91 
92  double stot=0, sxx=0, sxy=0, sxz=0, syy=0, syz=0, szz=0;
93  int i;
94 
95  for (i=0;i<fN;++i)
96  {
97  TVector3 v(fCmsList[i].Vect());
98 
99  sxx += v.X()*v.X(); sxy += v.X()*v.Y(); sxz += v.X()*v.Z();
100  syy += v.Y()*v.Y(); syz += v.Y()*v.Z();
101  szz += v.Z()*v.Z();
102 
103  stot += v.Mag2();
104  }
105 
106  TMatrixD sm(3,3);
107  sm(0,0) = sxx/stot; sm(0,1) = sxy/stot; sm(0,2) = sxz/stot;
108  sm(1,0) = sxy/stot; sm(1,1) = syy/stot; sm(1,2) = syz/stot;
109  sm(2,0) = sxz/stot; sm(2,1) = syz/stot; sm(2,2) = szz/stot;
110 
111  TMatrixDEigen ei(sm);
112  TMatrixD eiv=ei.GetEigenValues();
113 
114  fsph = 1.5 * (eiv(1,1) + eiv(2,2));
115  fapl = 1.5 * eiv(2,2);
116  fpla = eiv(1,1) - eiv(2,2);
117 }
118 
119 // ---------------------------------
120 
122 {
123  if (fsph<0.) ComputeSphericity();
124 
125  return fsph;
126 }
127 
128 // ---------------------------------
129 
131 {
132  if (fpla<0.) ComputeSphericity();
133 
134  return fpla;
135 }
136 
137 // ---------------------------------
138 
140 {
141  if (fapl<0.) ComputeSphericity();
142 
143  return fapl;
144 }
145 
146 // ---------------------------------------
147 // use iterative formula for thrust vector
148 //
149 // sum eps( n(j)*p_i) * p_i
150 // n(j+1) = --------------------------
151 // | '' |
152 //
153 // with eps(x)=-1 for x<0 and =+1 for x>0
154 
156 {
157  // did we already compute?
158  if (fthr>-1.) return fthr;
159 
160  TVector3 n0(0,0,0);
161  if( fN==0 ) return -1.;
162 
163  int i,j;
164  double pmax=0;
165 
166  //find starting vector as maximum momentum vector
167  for (i=0;i<fN;++i)
168  {
169  if (fCmsList[i].Vect().Mag()>pmax)
170  {
171  n0=fCmsList[i].Vect();
172  pmax=fCmsList[i].Vect().Mag();
173  }
174  }
175 
176  TVector3 nnew(0,0,0);
177 
178  // find thrust axis (10 iterations)
179  for (i=0;i<10;++i)
180  {
181  for (j=0;j<fN;++j)
182  nnew += Eps(n0,fCmsList[j].Vect()) * fCmsList[j].Vect();
183 
184  n0=nnew.Unit();
185  }
186 
187  fThrVect = n0;
188 
189  double thr=0, sum=0;
190  for (i=0;i<fN;++i)
191  {
192  thr += fabs(fThrVect.Dot(fCmsList[i].Vect()));
193  sum += fCmsList[i].Vect().Mag();
194  }
195 
196  fthr = thr/sum;
197 
198  return fthr;
199 }
200 
201 // ---------------------------------------
202 
204 {
205  if (fthr<0.) Thrust();
206 
207  return fThrVect;
208 }
209 
210 // ---------------------------------------
211 
212 double RhoEventShapes::Legendre( int l, double x )
213 {
214  if (fabs(x)>1.) return -999.;
215 
216  if (l==0) return 1.;
217 
218  double pmm = 1.;
219  double pmmp1 = x;
220 
221  if (l>1)
222  {
223  for(int ll=2; ll<=l; ll++)
224  {
225  double pll = (x * (2 * ll - 1) * pmmp1 - (ll - 1) * pmm) / (ll);
226  pmm = pmmp1;
227  pmmp1 = pll;
228  }
229  }
230  return pmmp1;
231 }
232 
233 // ---------------------------------------
234 
236 {
237  if (order>FWMAX) return -1.;
238 
239  // already computed FW moments
240  if (fFWready) return fFWmom[order];
241 
242  if( fN==0 ) return -1.;
243 
244  double s = 0.;
245  int i,j,l;
246 
247  for (i=0; i<fN-1; ++i)
248  {
249  // this candidate's 3-momentum
250  TVector3 p1(fCmsList[i].Vect());
251  double pmag1 = p1.Mag();
252 
253  // loop over other candidates, starting at the next one in the list
254 
255  for (j=i+1; j<fN; ++j)
256  {
257  // this candidate's 3-momentum
258  TVector3 p2(fCmsList[j].Vect());
259  double pmag2 = p2.Mag();
260 
261  // the cosine of the angle between the two candidates
262  double cosPhi = cos ( p1.Angle(p2) );
263 
264  // the contribution of this pair of track
265  // (note the factor 2 : the pair enters the sum twice)
266  for( l=0; l<=FWMAX; l++ )
267  fFWmom[l] += 2 * pmag1 * pmag2 * Legendre( l, cosPhi );
268 
269  }
270  // contribution of this track
271  for( l=0; l<=FWMAX; l++ )
272  fFWmom[l] += pmag1 * pmag1 * Legendre( l, 1. );
273 
274  // total energy
275  s += fCmsList[i].Energy();
276  }
277 
278  // well ...
279  if( s<=0. ) return -1.;
280  double s2=s*s;
281 
282  // normalize Fox Wolfram Moments
283  for( i=0; i<=FWMAX; i++) fFWmom[i]/=s2 ;
284 
285  fFWready = true;
286 
287  return fFWmom[order];
288 }
289 
290 
291 // ---------------------------------------
292 
294 {
295  return FoxWolfMomH(order)/FoxWolfMomH(0);
296 }
297 
298 // ---------------------------------------
299 
301 {
302  int cnt=0;
303  for (int i=0;i<fN;++i)
304  if (fLabList[i].P()>pmin) cnt++;
305 
306  return cnt;
307 }
308 
309 // ---------------------------------------
310 
312 {
313  int cnt=0;
314  for (int i=0;i<fN;++i)
315  if (fLabList[i].P()<pmax) cnt++;
316 
317  return cnt;
318 }
319 
320 // ---------------------------------------
321 
323 {
324  int cnt=0;
325  for (int i=0;i<fN;++i)
326  if (fCmsList[i].P()>pmin) cnt++;
327 
328  return cnt;
329 }
330 
331 // ---------------------------------------
332 
334 {
335  int cnt=0;
336  for (int i=0;i<fN;++i)
337  if (fCmsList[i].P()<pmax) cnt++;
338 
339  return cnt;
340 }
double fchrgptsumlab
friend F32vec4 cos(const F32vec4 &a)
Definition: P4_F32vec4.h:112
double fchrgptsumcms
int MultPminLab(double pmin)
Int_t i
Definition: run_full.C:25
TLorentzVector s
Definition: Pnd2DStar.C:50
Int_t GetLength() const
Definition: RhoCandList.h:46
std::vector< TLorentzVector > fCmsList
! List of 4-vectors in cms frame
RhoEventShapes(RhoCandList &l, TLorentzVector cms)
__m128 v
Definition: P4_F32vec4.h:4
double FoxWolfMomH(int order)
double fneutetsumcms
std::vector< int > fCharge
! List of charges of particles
void ComputeSphericity()
ClassImp(RhoEventShapes)
TLorentzVector P4() const
Definition: RhoCandidate.h:195
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
int MultPmaxCms(double pmax)
TPad * p2
Definition: hist-t7.C:117
double fneutetsumlab
double Legendre(int l, double x)
GeV c P
Double_t x
int MultPmaxLab(double pmax)
TVector3 ThrustVector()
double Eps(const TVector3 v1, const TVector3 v2)
Int_t cnt
Definition: hist-t7.C:106
Double_t Charge() const
Definition: RhoCandidate.h:184
TPad * p1
Definition: hist-t7.C:116
#define FWMAX
Definition: PndEventShape.h:7
double fFWmom[FWMAX]
std::vector< TLorentzVector > fLabList
! List of 4-vectors in lab frame
int MultPminCms(double pmin)
TMatrixT< double > TMatrixD
Definition: PndLmdDim.h:52
double FoxWolfMomR(int order)