ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/IPHCalignment2/Alignment/TwoBodyDecay/src/TwoBodyDecayUncertainty.cpp
Revision: 1.1
Committed: Fri Nov 25 17:10:52 2011 UTC (13 years, 5 months ago) by econte
Branch: MAIN
CVS Tags: TBD2011, TBD_2011, HEAD
Log Message:
TwoBodyDecay modif

File Contents

# User Rev Content
1 econte 1.1 #include "Alignment/TwoBodyDecay/interface/TwoBodyDecayUncertainty.h"
2    
3    
4     std::pair<double,double> TwoBodyDecayUncertainty::errorSecondaryMomentaP()
5     {
6     double p = 0;
7     double m = 0;
8     for (unsigned int i=0;i<9;i++)
9     for (unsigned int j=0;j<9;j++)
10     {
11     double pd1=0; double pd2=0; double md1=0; double md2=0;
12     for (unsigned int k=1;k<4;k++)
13     {
14     pd1 += (finalPlus_[k][0])/p_ * (finalPlusP_[i])[k][0];
15     pd2 += (finalPlus_[k][0])/p_ * (finalPlusP_[j])[k][0];
16     md1 += (finalMinus_[k][0])/p_ * (finalMinusP_[i])[k][0];
17     md2 += (finalMinus_[k][0])/p_ * (finalMinusP_[j])[k][0];
18     }
19     p += pd1*pd2*covariance_[i][j];
20     m += md1*md2*covariance_[i][j];
21     }
22     return std::make_pair(p,m);
23     }
24    
25     std::pair<double,double> TwoBodyDecayUncertainty::errorSecondaryMomentaPT()
26     {
27     double p = 0;
28     double m = 0;
29     for (unsigned int i=0;i<9;i++)
30     for (unsigned int j=0;j<9;j++)
31     {
32     double pd1=0; double pd2=0; double md1=0; double md2=0;
33     for (unsigned int k=1;k<3;k++)
34     {
35     pd1 += (finalPlus_[k][0])/pT_ * (finalPlusP_[i])[k][0];
36     pd2 += (finalPlus_[k][0])/pT_ * (finalPlusP_[j])[k][0];
37     md1 += (finalMinus_[k][0])/pT_ * (finalMinusP_[i])[k][0];
38     md2 += (finalMinus_[k][0])/pT_ * (finalMinusP_[j])[k][0];
39     }
40     p += pd1*pd2*covariance_[i][j];
41     m += md1*md2*covariance_[i][j];
42     }
43     return std::make_pair(p,m);
44     }
45    
46     void TwoBodyDecayUncertainty::init()
47     {
48     // Computing transverse and absolute momentum
49     pT2_ = parameters_[PX]*parameters_[PX] +
50     parameters_[PY]*parameters_[PY];
51     p2_ = pT2_ + parameters_[PZ]*parameters_[PZ];
52     pT_ = sqrt( pT2_ );
53     p_ = sqrt( p2_ );
54    
55     // Calculating matrix and vector
56     RotationMatrixA();
57     RotationMatrixB();
58     LorentzMatrix();
59     Momentum();
60    
61     // Moving to lab referency
62     finalPlus_ = rotationA_ * rotationB_ * lorentz_ * momentumPlus_;
63     finalMinus_ = rotationA_ * rotationB_ * lorentz_ * momentumMinus_;
64    
65     // Momentum derivative in the lab referency
66     finalPlusP_.resize(9);
67     finalMinusP_.resize(9);
68     for (unsigned int k=0;k<9;k++)
69     {
70     finalPlusP_[k] = rotationAp_[k]*rotationB_ *lorentz_ *momentumPlus_
71     + rotationA_ *rotationBp_[k]*lorentz_ *momentumPlus_
72     + rotationA_ *rotationB_ *lorentzP_[k]*momentumPlus_
73     + rotationA_ *rotationB_ *lorentz_ *momentumPlusP_[k];
74    
75     finalMinusP_[k] = rotationAp_[k]*rotationB_ *lorentz_ *momentumMinus_
76     + rotationA_ *rotationBp_[k]*lorentz_ *momentumMinus_
77     + rotationA_ *rotationB_ *lorentzP_[k]*momentumMinus_
78     + rotationA_ *rotationB_ *lorentz_ *momentumMinusP_[k];
79     }
80     }
81    
82     void TwoBodyDecayUncertainty::RotationMatrixA()
83     {
84     // initializing rotationA_
85     rotationA_ = AlgebraicMatrix( 4, 4 );
86    
87     // calculating rotation matrix A
88     double a = parameters_[PX]/pT_;
89     double b = parameters_[PY]/pT_;
90    
91     rotationA_[0][0] = 1.;
92     rotationA_[0][1] = 0.;
93     rotationA_[0][2] = 0.;
94     rotationA_[0][3] = 0.;
95    
96     rotationA_[1][0] = 0;
97     rotationA_[1][1] = a;
98     rotationA_[1][2] = -b;
99     rotationA_[1][3] = 0;
100    
101     rotationA_[2][0] = 0;
102     rotationA_[2][1] = b;
103     rotationA_[2][2] = a;
104     rotationA_[2][3] = 0;
105    
106     rotationA_[3][0] = 0.;
107     rotationA_[3][1] = 0.;
108     rotationA_[3][2] = 0.;
109     rotationA_[3][3] = 1.;
110    
111     // initializing rotationAp_
112     rotationAp_.resize(9);
113    
114     // calculating rotation matrix Ap
115     for (unsigned int k=0;k<9;k++)
116     {
117    
118     AlgebraicMatrix rot( 4, 4);
119     double da=0;
120     double db=0;
121    
122     if (k==PX)
123     {
124     da = parameters_[PY]*parameters_[PY]/(pT_*pT_*pT_);
125     db = -parameters_[PX]*parameters_[PY]/(pT_*pT_*pT_);
126     }
127     else if (k==PY)
128     {
129     da = -parameters_[PX]*parameters_[PY]/(pT_*pT_*pT_);
130     db = parameters_[PX]*parameters_[PX]/(pT_*pT_*pT_);
131     }
132    
133     rot[0][0] = 0.;
134     rot[0][1] = 0.;
135     rot[0][2] = 0.;
136     rot[0][3] = 0.;
137    
138     rot[1][0] = 0;
139     rot[1][1] = da; //parameters_[PX]/pT;
140     rot[1][2] = -db; //-parameters_[PY]/pT;
141     rot[1][3] = 0;
142    
143     rot[2][0] = 0;
144     rot[2][1] = db; //parameters_[PY]/pT;
145     rot[2][2] = da; //parameters_[PX]/pT;
146     rot[2][3] = 0;
147    
148     rot[3][0] = 0;
149     rot[3][1] = 0.;
150     rot[3][2] = 0.;
151     rot[3][3] = 0.;
152    
153     rotationAp_[k]=rot;
154     }
155     }
156    
157    
158     void TwoBodyDecayUncertainty::RotationMatrixB()
159     {
160     // intializing rotation matrix B
161     rotationB_ = AlgebraicMatrix( 4, 4 );
162     double a = parameters_[PZ]/p_;
163     double b = pT_/p_;
164    
165     // computing rotation matrix B
166     rotationB_[0][0] = 1.;
167     rotationB_[0][1] = 0.;
168     rotationB_[0][2] = 0.;
169     rotationB_[0][3] = 0.;
170    
171     rotationB_[1][0] = 0.;
172     rotationB_[1][1] = a;
173     rotationB_[1][2] = 0.;
174     rotationB_[1][3] = b;
175    
176     rotationB_[2][0] = 0.;
177     rotationB_[2][1] = 0.;
178     rotationB_[2][2] = 1.;
179     rotationB_[2][3] = 0.;
180    
181     rotationB_[3][0] = 0.;
182     rotationB_[3][1] = -b;
183     rotationB_[3][2] = 0.;
184     rotationB_[3][3] = a;
185    
186     // initializing rotationAp_
187     rotationBp_.resize(9);
188    
189     // calculating rotation matrix Ap
190     for (unsigned int k=0;k<9;k++)
191     {
192     AlgebraicMatrix rot( 4, 4);
193     double da=0;
194     double db=0;
195    
196     if (k==PX)
197     {
198     da = -parameters_[PX]*parameters_[PZ]/(p_*p_*p_);
199     db = parameters_[PX]*parameters_[PZ]*parameters_[PZ]/(pT_*p_*p_*p_);
200     }
201     else if (k==PY)
202     {
203     da = -parameters_[PY]*parameters_[PZ]/(p_*p_*p_);
204     db = parameters_[PY]*parameters_[PZ]*parameters_[PZ]/(pT_*p_*p_*p_);
205     }
206     else if (k==PZ)
207     {
208     da = b*b/p_;
209     db = -a*b/p_;
210     }
211    
212     rot[0][0] = 0.;
213     rot[0][1] = 0.;
214     rot[0][2] = 0.;
215     rot[0][3] = 0.;
216    
217     rot[1][0] = 0;
218     rot[1][1] = da;
219     rot[1][2] = 0.;
220     rot[1][3] = db;
221    
222     rot[2][0] = 0;
223     rot[2][1] = 0.;
224     rot[2][2] = 0.;
225     rot[2][3] = 0.;
226    
227     rot[3][0] = 0;
228     rot[3][1] = -db;
229     rot[3][2] = 0.;
230     rot[3][3] = da;
231    
232     rotationBp_[k]=rot;
233     }
234     }
235    
236    
237     void TwoBodyDecayUncertainty::Momentum()
238     {
239     double alpha = sqrt(parameters_[MASS]*parameters_[MASS]-4.*m_*m_);
240    
241     // momentum Plus
242     momentumPlus_ = AlgebraicMatrix(4,1);
243     momentumMinus_ = AlgebraicMatrix(4,1);
244    
245     // computing momentum plus
246     momentumPlus_[0][0] = 0.5*parameters_[MASS];
247     momentumPlus_[1][0] = 0.5*alpha*sin(parameters_[THETA])*cos(parameters_[PHI]);
248     momentumPlus_[2][0] = 0.5*alpha*sin(parameters_[THETA])*sin(parameters_[PHI]);
249     momentumPlus_[3][0] = 0.5*alpha*cos(parameters_[THETA]);
250    
251     // initializing momentum plus
252     momentumPlusP_.resize(9);
253     momentumMinusP_.resize(9);
254    
255     // calculating rotation matrix Ap
256     for (unsigned int k=0;k<9;k++)
257     {
258     AlgebraicMatrix rot(4,1);
259    
260     if (k==THETA)
261     {
262     rot[0][0] = 0.;
263     rot[1][0] = 0.5*alpha*cos(parameters_[THETA])*cos(parameters_[PHI]);
264     rot[2][0] = 0.5*alpha*cos(parameters_[THETA])*sin(parameters_[PHI]);
265     rot[3][0] = -0.5*alpha*sin(parameters_[THETA]);
266     }
267     else if (k==PHI)
268     {
269     rot[0][0] = 0.;
270     rot[1][0] = -0.5*alpha*sin(parameters_[THETA])*sin(parameters_[PHI]);
271     rot[2][0] = 0.5*alpha*sin(parameters_[THETA])*cos(parameters_[PHI]);
272     rot[3][0] = 0.;
273     }
274     else if (k==MASS)
275     {
276     double alphap = parameters_[MASS]/alpha;
277     rot[0][0] = 0.5;
278     rot[1][0] = 0.5*alphap*sin(parameters_[THETA])*cos(parameters_[PHI]);
279     rot[2][0] = 0.5*alphap*sin(parameters_[THETA])*sin(parameters_[PHI]);
280     rot[3][0] = 0.5*alphap*cos(parameters_[THETA]);
281     }
282     else
283     {
284     rot[0][0] = 0.;
285     rot[1][0] = 0.;
286     rot[2][0] = 0.;
287     rot[3][0] = 0.;
288     }
289    
290     momentumPlusP_[k]=rot;
291     }
292    
293     momentumMinus_[0][0]=momentumPlus_[0][0];
294     for (unsigned int i=1;i<4;i++) momentumMinus_[i][0]=-momentumPlus_[i][0];
295    
296     for (unsigned int k=0;k<9;k++)
297     {
298     momentumMinusP_[k]=AlgebraicMatrix(4,1);
299     momentumMinusP_[k][0][0]=momentumPlusP_[k][0][0];
300     for (unsigned int i=1;i<4;i++) { momentumMinusP_[k][i][0]=-momentumPlusP_[k][i][0];}
301     }
302     }
303    
304    
305    
306     void TwoBodyDecayUncertainty::LorentzMatrix()
307     {
308     // initializing rotationA_
309     lorentz_ = AlgebraicMatrix( 4, 4 );
310     double a = sqrt(1+pow(p_/parameters_[MASS],2));
311     double b = p_/parameters_[MASS];
312    
313     // calculating rotation matrix A
314     lorentz_[0][0] = a;
315     lorentz_[0][1] = 0.;
316     lorentz_[0][2] = 0.;
317     lorentz_[0][3] = b;
318    
319     lorentz_[1][0] = 0;
320     lorentz_[1][1] = 1;
321     lorentz_[1][2] = 0;
322     lorentz_[1][3] = 0;
323    
324     lorentz_[2][0] = 0;
325     lorentz_[2][1] = 0;
326     lorentz_[2][2] = 1;
327     lorentz_[2][3] = 0;
328    
329     lorentz_[3][0] = b;
330     lorentz_[3][1] = 0.;
331     lorentz_[3][2] = 0.;
332     lorentz_[3][3] = a;
333    
334     // initializing lorentz_
335     lorentzP_.resize(9);
336    
337     // calculating lorentz matrix
338     for (unsigned int k=0;k<9;k++)
339     {
340     AlgebraicMatrix rot(4,4);
341     double da=0;
342     double db=0;
343    
344     if (k==PX)
345     {
346     da = parameters_[PX]/(parameters_[MASS]*parameters_[MASS]*a);
347     db = parameters_[PX]/(p_*parameters_[MASS]);
348     }
349     else if (k==PY)
350     {
351     da = parameters_[PY]/(parameters_[MASS]*parameters_[MASS]*a);
352     db = parameters_[PY]/(p_*parameters_[MASS]);
353     }
354     else if (k==PZ)
355     {
356     da = parameters_[PZ]/(parameters_[MASS]*parameters_[MASS]*a);
357     db = parameters_[PZ]/(p_*parameters_[MASS]);
358     }
359     else if (k==MASS)
360     {
361     da = -b*b/(a*parameters_[MASS]);
362     db = -b/parameters_[MASS];
363     }
364    
365     rot[0][0] = da;
366     rot[0][1] = 0.;
367     rot[0][2] = 0.;
368     rot[0][3] = db;
369    
370     rot[1][0] = 0;
371     rot[1][1] = 0;
372     rot[1][2] = 0;
373     rot[1][3] = 0;
374    
375     rot[2][0] = 0;
376     rot[2][1] = 0;
377     rot[2][2] = 0;
378     rot[2][3] = 0;
379    
380     rot[3][0] = db;
381     rot[3][1] = 0.;
382     rot[3][2] = 0.;
383     rot[3][3] = da;
384    
385     lorentzP_[k]=rot;
386    
387     }
388     }