MINT2
SpinFactors4Body_FsVector.cpp
Go to the documentation of this file.
1 // author: Philippe d'Argent (p.dargent@cern.ch)
2 // status: Tu 6 May 2014
3 
4 #include "Mint/SpinFactors.h"
5 #include "Mint/DecayTree.h"
6 //#include "Mint/DecayTreeComparisons.h"
7 
8 #include "Mint/Utils.h"
10 
11 #include "Mint/ZTspin1.h"
12 #include "Mint/ZTspin2.h"
13 #include "Mint/LeviCivita.h"
14 #include "Mint/SpinSumV.h"
15 #include "Mint/SpinSumT.h"
16 #include "Mint/ZTgperp.h"
17 #include "Mint/SymmLorentzMatrix.h"
18 
19 #include "Mint/polVector.h"
20 
21 
22 using namespace std;
23 using namespace MINT;
24 
34 
38 
43 
45 
48 
51 
55 
58 
62 
65 
69 
70 
71 //==================================================================
72 //==================================================================
73 // SF 1-4
74 
76  bool debugThis=false;
77 
78  if(fsPS.size() < 4) fsPS.reserve(4);
79  for(int i=0; i< theDecay(pat).nDgtr(); i++){
80  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
81  if(dgtr->getVal().SVPAT() == "A") A = dgtr;
82  else if(dgtr->getVal().SVPAT() == "V") fsPS[0] = dgtr;
83  }
84  if(0==A || 0==fsPS[0]){
85  cout << "ERROR in SF_BtoAV0_AtoVP1_VtoP2P3::parseTree"
86  << " Didn't find A or V0 " << A.get() << ", " << fsPS[0].get() << endl;
87  return false;
88  }
89 
90  for(int i=0; i< A->nDgtr(); i++){
91  const_counted_ptr<AssociatedDecayTree> dgtr= A->getDgtrTreePtr(i);
92  if(dgtr->getVal().SVPAT() == "V") V = dgtr;
93  else if(dgtr->getVal().SVPAT() == "P") fsPS[1] = dgtr;
94  }
95  if(0==V || 0==fsPS[1]){
96  cout << "ERROR in SF_BtoAV0_AtoVP1_VtoP2P3::parseTree"
97  << " Didn't find V or P1 " << V.get() << ", " << fsPS[1].get() << endl;
98  return false;
99  }
100 
101  if(V->nDgtr() != 2){
102  cout << "ERROR in SF_BtoAV0_AtoVP1_VtoP2P3::parseTree"
103  << " V should have 2 daughters, but it says it has "
104  << V->nDgtr() << "."
105  << endl;
106  return false;
107  }
108  fsPS[2] = V->getDgtrTreePtr(0);
109  fsPS[3] = V->getDgtrTreePtr(1);
110 
112 
113  if(debugThis){
114  cout << "parsed Tree: V:\n"
115  << *V
116  << "\n A:"
117  << *A
118  << endl;
119  for(int i=0; i<4; i++){
120  cout << "fsPS[" << i << "]\n"
121  << *(fsPS[i])
122  << endl;
123  }
124  }
125  // this->printYourself();
126  return true;
127 }
128 
130  if(0==_exampleDecay){
131  // B->J/psi K1(1270); K1->K*(892) pi; K*->K pi
132  _exampleDecay = new DecayTree(521);
133  _exampleDecay->addDgtr(443, 10323)->addDgtr(211, 313)->addDgtr(321,-211);
134  }
135  return *_exampleDecay;
136 }
137 
139  return getExampleDecay();
140 }
141 
143  if(0==_exampleDecayDwave){
144  // B->J/psi K1(1270); K1->K*(892) pi; K*->K pi
145  _exampleDecayDwave = new DecayTree(521);
146  DecayTree k1(10323);
147  k1.getVal().setL(2);
148  k1.addDgtr(211, 313)->addDgtr(321,-211);
149  _exampleDecayDwave->addDgtr(443);
150  _exampleDecayDwave->addDgtr(&k1);
151  }
152  return *_exampleDecayDwave;
153 }
154 
156  return getExampleDecay();
157 }
158 
160  if(0==_exampleDecayDwaveP){
161  // B->J/psi K1(1270); K1->K*(892) pi; K*->K pi
162  _exampleDecayDwaveP = new DecayTree(521);
163  DecayTree k1(10323);
164  k1.getVal().setL(2);
165  k1.addDgtr(211, 313)->addDgtr(321,-211);
166  _exampleDecayDwaveP->addDgtr(443);
167  _exampleDecayDwaveP->addDgtr(&k1);
168  _exampleDecayDwaveP->getVal().setL(1);
169 
170  }
171  return *_exampleDecayDwaveP;
172 }
173 
175  return getExampleDecay();
176 }
177 
179  if(0==_exampleDecayDwaveD){
180  // B->J/psi K1(1270); K1->K*(892) pi; K*->K pi
181  _exampleDecayDwaveD = new DecayTree(521);
182  DecayTree k1(10323);
183  k1.getVal().setL(2);
184  k1.addDgtr(211, 313)->addDgtr(321,-211);
185  _exampleDecayDwaveD->addDgtr(443);
186  _exampleDecayDwaveD->addDgtr(&k1);
187  _exampleDecayDwaveD->getVal().setL(2);
188 
189  }
190  return *_exampleDecayDwaveD;
191 }
192 
194  return getExampleDecay();
195 }
196 
198  if(0==_exampleDecayP){
199  // B->J/psi K1(1270); K1->K*(892) pi; K*->K pi
200  _exampleDecayP = new DecayTree(521);
201  _exampleDecayP->addDgtr(443, 10323)->addDgtr(211, 313)->addDgtr(321,-211);
202  _exampleDecayP->getVal().setL(1);
203  }
204  return *_exampleDecayP;
205 }
206 
208  return getExampleDecay();
209 }
210 
212  if(0==_exampleDecayD){
213  // B->J/psi K1(1270); K1->K*(892) pi; K*->K pi
214  _exampleDecayD = new DecayTree(521);
215  _exampleDecayD->addDgtr(443, 10323)->addDgtr(211, 313)->addDgtr(321,-211);
216  _exampleDecayD->getVal().setL(2);
217  }
218  return *_exampleDecayD;
219 }
220 
222  return getExampleDecay();
223 }
224 
225 //SF 1
227  //bool debugThis = false;
228 
229  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
230 
231  double MA = mRes(A, evt);
232  double MV = mRes(V, evt);
233  double MV0 = mRes(fsPS[0], evt); // ??
234  //double MV0 = p(0, evt).M(); // ??
235  //cout << "pol in spinFactor class" << getPolarisation() << endl;
236 
237  TLorentzVector pV= p(2, evt)+p(3, evt);
238  TLorentzVector qV= p(2, evt)-p(3, evt);
239  TLorentzVector pA= pV+p(1, evt);
240 
241 
242  ZTspin1 Z(qV,pV,MV);
243  SpinSumV P(pA,MA);
244 
245  polVector e = polVector(p(0, evt),MV0,getPolarisation());
246  e.conj();
247 
248  // e.Print();
249  complex<double> sfm(P.Sandwich(e.Re(),Z),P.Sandwich(e.Im(),Z));
250  //complex<double> sfm(P.Dot(Z).Dot(e.Re()),P.Dot(Z).Dot(e.Re()));
251 
252  //cout << sfm/GeV << endl;
253  // return complex<double>(1,0);
254  return sfm/GeV;
255 }
257  // bool debugThis = false;
258 
259  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
260  os << "spin factor SF_BtoAV0_AtoVP1_VtoP2P3"
261  << "\n\t P.Sandwich(e_c,Z)"
262  << "\n\t /GeV"
263  << "\n\t parsed tree " << theDecay().oneLiner()
264  << "\n like this:" << endl;
265  this->printParsing(os);
266 }
267 
268 //SF 2
270  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
271 
272  double MA = mRes(A, evt);
273  double MV = mRes(V, evt);
274  double MV0 = mRes(fsPS[0], evt);
275 
276  TLorentzVector pV= p(2, evt)+p(3, evt);
277  TLorentzVector qV= p(2, evt)-p(3, evt);
278  TLorentzVector pA= pV+p(1, evt);
279  TLorentzVector qA= pV-p(1, evt);
280 
281  ZTspin1 ZV(qV,pV,MV);
282  ZTspin1 ZA(qA,pA,MA);
283  SpinSumV PA(pA,MA);
284  SpinSumT DA(pA,MA);
285 
286  polVector e = polVector(p(0,evt),MV0,getPolarisation());
287  e.conj();
288 
289  //complex<double> sfm(DA.Sandwich(e.Re(),ZV,qA,qA),DA.Sandwich(e.Im(),ZV,qA,qA));
290 
291  TLorentzVector tmp = ZA * (ZA.Dot(ZV)) + 1./3. * ZA.Dot(ZA) * PA.Dot(ZV);
292 
293  complex<double> sfm(tmp.Dot(e.Re()),tmp.Dot(e.Im()));
294 
295  return sfm/(GeV*GeV*GeV);
296 
297 }
299  // bool debugThis = false;
300 
301  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
302  os << "spin factor SF_BtoAV0Dwave_AtoVP1_VtoP2P3"
303  << "\n\t e_c.Dot(ZA) * ZV.Dot(qA)"
304  << "\n\t /GeV^3"
305  << "\n\t parsed tree " << theDecay().oneLiner()
306  << "\n like this:" << endl;
307  this->printParsing(os);
308 }
309 
310 
312  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
313 
314  double MA = mRes(A, evt);
315  double MV = mRes(V, evt);
316  double MV0 = mRes(fsPS[0], evt); // ??
317  //double MV0 = p(0, evt).M(); // ??
318 
319  TLorentzVector pV= p(2, evt)+p(3, evt);
320  TLorentzVector qV= p(2, evt)-p(3, evt);
321  TLorentzVector pA= pV+p(1, evt);
322  TLorentzVector qA= pV-p(1, evt);
323  TLorentzVector pB= pA+p(0, evt);
324  TLorentzVector qB= pA-p(0, evt);
325 
326  ZTspin1 LV(qV,pV,MV);
327  ZTspin1 LA(qA,pA,MA);
328  ZTspin1 LB(qB,pB,pB.M());
329  SpinSumV PA(pA,MA);
330 
331  polVector e = polVector(p(0,evt),MV0,getPolarisation());
332  e.conj();
333 
334  TLorentzVector tmp = LA * (LA.Dot(LV)) + 1./3. * LA.Dot(LA) * PA.Dot(LV);
335 
336  complex<double> sfm(LeviCivita(e.Re(),LB,pB,tmp),LeviCivita(e.Im(),LB,pB,tmp));
337  return sfm/(GeV*GeV*GeV*GeV*GeV);
338 
339 }
341  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
342  os << "spin factor SF_BtoAV0Dwave_AtoVP1_VtoP2P3_P"
343  << "\n\t parsed tree " << theDecay().oneLiner()
344  << "\n like this:" << endl;
345  this->printParsing(os);
346 }
347 
349  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
350 
351  double MA = mRes(A, evt);
352  double MV = mRes(V, evt);
353  double MV0 = mRes(fsPS[0], evt);
354 
355  TLorentzVector pV= p(2, evt)+p(3, evt);
356  TLorentzVector qV= p(2, evt)-p(3, evt);
357  TLorentzVector pA= pV+p(1, evt);
358  TLorentzVector qA= pV-p(1, evt);
359  TLorentzVector pB= pA+p(0, evt);
360  TLorentzVector qB= pA-p(0, evt);
361 
362  ZTspin1 LV(qV,pV,MV);
363  ZTspin1 LA(qA,pA,MA);
364  ZTspin1 LB(qB,pB,pB.M());
365  SpinSumV PB(pB,pB.M());
366  SpinSumV PA(pA,pA.M());
367 
368  polVector e = polVector(p(0,evt),MV0,getPolarisation());
369  e.conj();
370 
371  TLorentzVector tmp = LA * (LA.Dot(LV)) + 1./3. * LA.Dot(LA) * PA.Dot(LV);
372  TLorentzVector tmp2 = LB * (LB.Dot(tmp)) + 1./3. * LB.Dot(LB) * PB.Dot(tmp);
373 
374  complex<double> sfm(tmp2.Dot(e.Re()),tmp2.Dot(e.Im()));
375  return sfm/(GeV*GeV*GeV*GeV*GeV);
376 
377 }
379  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
380  os << "spin factor SF_BtoAV0Dwave_AtoVP1_VtoP2P3_D"
381  << "\n\t parsed tree " << theDecay().oneLiner()
382  << "\n like this:" << endl;
383  this->printParsing(os);
384 }
385 
386 
387 //SF 3
389  //bool debugThis = false;
390 
391  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
392 
393  double MA = mRes(A,evt);
394  double MV = mRes(V,evt);
395  double MV0 = mRes(fsPS[0],evt); // ??
396  //double MV0 = p(0,evt).M(); // ??
397 
398  TLorentzVector pV= p(2,evt)+p(3,evt);
399  TLorentzVector qV= p(2,evt)-p(3,evt);
400  TLorentzVector pA= pV+p(1,evt);
401  //TLorentzVector qA= pV-p(1,evt);
402  TLorentzVector pB= pA+p(0,evt);
403  TLorentzVector qB= pA-p(0,evt);
404 
405  ZTspin1 ZB(qB,pB,pB.M());
406  ZTspin1 ZV(qV,pV,MV);
407  SpinSumV PA(pA,MA);
408 
409  polVector e = polVector(p(0,evt),MV0,getPolarisation());
410  e.conj();
411 
412  TLorentzVector tmp=PA.Dot(ZV);
413  if(tmp==TLorentzVector(0,0,0,0))return 0.;
414 
415  complex<double> sfm(LeviCivita(e.Re(),tmp,ZB,pB),LeviCivita(e.Im(),tmp,ZB,pB));
416  //if(getPolarisation()==0)sfm=complex<double>(LeviCivita(e.Re(),tmp,pB,ZB),0.);
417  //else sfm=complex<double>(LeviCivita(e.Re(),tmp,ZB,pB),LeviCivita(e.Im(),tmp,ZB,pB));
418 
419 
420  return sfm/(GeV*GeV*GeV);
421 }
423  // bool debugThis = false;
424 
425  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
426  os << "spin factor SF_BtoAV0_AtoVP1_VtoP2P3_P"
427  << "\n\t LeviCivita(e_c,PA.Dot(ZV),pB,qB)"
428  << "\n\t /GeV^3"
429  << "\n\t parsed tree " << theDecay().oneLiner()
430  << "\n like this:" << endl;
431  this->printParsing(os);
432 }
433 
434 //SF 4
436  //bool debugThis = false;
437 
438  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
439 
440  double MA = mRes(A,evt);
441  double MV = mRes(V,evt);
442  double MV0 = mRes(fsPS[0],evt); // ??
443  //double MV0 = p(0,evt).M(); // ??
444  //cout << "pol in spinFactor class" << getPolarisation() << endl;
445 
446  TLorentzVector pV= p(2,evt)+p(3,evt);
447  TLorentzVector qV= p(2,evt)-p(3,evt);
448  TLorentzVector pA= pV+p(1,evt);
449  //TLorentzVector qA= pV-p(1,evt);
450  TLorentzVector pB= pA+p(0,evt);
451  TLorentzVector qB= pA-p(0,evt);
452 
453  ZTspin1 ZV(qV,pV,MV);
454  //ZTspin1 ZA(qA,pA,MA);
455  SpinSumV PA(pA,MA);
456  SpinSumT DB(pB,pB.M());
457 
458  polVector e = polVector(p(0,evt),MV0,getPolarisation());
459  e.conj();
460 
461  TLorentzVector tmp= PA.Dot(ZV);
462  complex<double> sfm(DB.Sandwich(e.Re(),tmp,qB,qB),DB.Sandwich(e.Im(),tmp,qB,qB));
463  return sfm/(GeV*GeV*GeV);
464 
465  //double tmp= ZA.Dot(ZV);
466  //complex<double> sfm(e.Re().Dot(qB),e.Im().Dot(qB));
467  //return sfm*tmp/(GeV*GeV*GeV);
468 }
470  // bool debugThis = false;
471 
472  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
473  os << "spin factor SF_BtoAV0_AtoVP1_VtoP2P3_D"
474  << "\n\t e_c.Dot(pA) * ZA.Dot(ZV)"
475  << "\n\t /GeV^3"
476  << "\n\t parsed tree " << theDecay().oneLiner()
477  << "\n like this:" << endl;
478  this->printParsing(os);
479 }
480 
481 
482 
483 //=========================================================
484 //SF 5
485 
487  if(0==_exampleDecay){
488  // B->J/Psi K1(1270); K1-> K0^*(1430) pi; K0^*->K pi
489  _exampleDecay = new DecayTree(521);
490  _exampleDecay->addDgtr(443, 10323)->addDgtr(211, 10311)->addDgtr(321,-211);
491  }
492  return *_exampleDecay;
493 }
494 
496  return getExampleDecay();
497 }
498 
500  if(0==_exampleDecayP){
501  // B->J/Psi K1(1270); K1-> K0^*(1430) pi; K0^*->K pi
502  _exampleDecayP = new DecayTree(521);
503  _exampleDecayP->addDgtr(443, 10323)->addDgtr(211, 10311)->addDgtr(321,-211);
504  _exampleDecayP->getVal().setL(1);
505  cout << _exampleDecayP << endl;
506  }
507  return *_exampleDecayP;
508 }
509 
511  return getExampleDecay();
512 }
513 
515  if(0==_exampleDecayD){
516  // B->J/Psi K1(1270); K1-> K0^*(1430) pi; K0^*->K pi
517  _exampleDecayD = new DecayTree(521);
518  _exampleDecayD->addDgtr(443, 10323)->addDgtr(211, 10311)->addDgtr(321,-211);
519  _exampleDecayD->getVal().setL(2);
520  }
521  return *_exampleDecayD;
522 }
523 
525  return getExampleDecay();
526 }
527 
529  bool debugThis=false;
530 
531  if(fsPS.size() < 4) fsPS.reserve(4);
532  for(int i=0; i< theDecay(pat).nDgtr(); i++){
533  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
534  if(dgtr->getVal().SVPAT() == "A") A = dgtr;
535  else if(dgtr->getVal().SVPAT() == "V") fsPS[0] = dgtr;
536  }
537  if(0==A || 0==fsPS[0]){
538  cout << "ERROR in SF_BtoAV0_AtoSP1_StoP2P3::parseTree"
539  << " Didn't find A or V0 " << A.get() << ", " << fsPS[0].get() << endl;
540  return false;
541  }
542 
543  for(int i=0; i< A->nDgtr(); i++){
544  const_counted_ptr<AssociatedDecayTree> dgtr= A->getDgtrTreePtr(i);
545  if(dgtr->getVal().SVPAT() == "S") S = dgtr;
546  else if(dgtr->getVal().SVPAT() == "P") fsPS[1] = dgtr;
547  }
548  if(0==S || 0==fsPS[1]){
549  cout << "ERROR in SF_BtoAV0_AtoSP1_StoP2P3::parseTree"
550  << " Didn't find S or P1 " << S.get() << ", " << fsPS[1].get() << endl;
551  return false;
552  }
553 
554  if(S->nDgtr() != 2){
555  cout << "ERROR in SF_BtoAV0_AtoSP1_StoP2P3::parseTree"
556  << " S should have 2 daughters, but it says it has "
557  << S->nDgtr() << "."
558  << endl;
559  return false;
560  }
561  fsPS[2] = S->getDgtrTreePtr(0);
562  fsPS[3] = S->getDgtrTreePtr(1);
563 
564  //normalOrder(fsPS[2], fsPS[3]);
565 
566  if(debugThis){
567  cout << "parsed Tree: A:\n"
568  << *A
569  << "\n S:"
570  << *S
571  << endl;
572  for(int i=0; i<4; i++){
573  cout << "fsPS[" << i << "]\n"
574  << *(fsPS[i])
575  << endl;
576  }
577  }
578  // this->printYourself();
579  return true;
580 }
581 
583  //bool debugThis = false;
584 
585  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
586 
587  double MA = mRes(A,evt);
588  double MV0 = mRes(fsPS[0],evt); // ??
589  //double MV0 = p(0,evt).M(); // ??
590 
591  //cout << "pol in spinFactor class" << getPolarisation() << endl;
592 
593  TLorentzVector pA= p(2,evt)+p(3,evt)+p(1,evt);
594  TLorentzVector qA= p(2,evt)+p(3,evt)-p(1,evt);
595  ZTspin1 ZA(qA,pA,MA);
596 
597  polVector e = polVector(p(0,evt),MV0,getPolarisation());
598  e.conj();
599 
600  complex<double> sfm(ZA.Dot(e.Re()),ZA.Dot(e.Im()));
601 
602  return sfm/GeV;
603 }
605  // bool debugThis = false;
606 
607  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
608  os << "spin factor SF_BtoAV0_AtoSP1_StoP2P3"
609  << "\n\t ZA.Dot(e_c)"
610  << "\n\t /GeV"
611  << "\n\t parsed tree " << theDecay().oneLiner()
612  << "\n like this:" << endl;
613  this->printParsing(os);
614 }
615 
616 
618  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
619 
620  double MA = mRes(A,evt);
621  double MV0 = mRes(fsPS[0],evt); // ??
622 
623  TLorentzVector pA= p(2,evt)+p(3,evt)+p(1,evt);
624  TLorentzVector qA= p(2,evt)+p(3,evt)-p(1,evt);
625  ZTspin1 LA(qA,pA,MA);
626 
627  TLorentzVector pB= pA+p(0,evt);
628  TLorentzVector qB= pA-p(0,evt);
629  ZTspin1 LB(qB,pB,pB.M());
630 
631  polVector e = polVector(p(0,evt),MV0,getPolarisation());
632  e.conj();
633 
634  complex<double> sfm(LeviCivita(e.Re(),LB,LA,pB),LeviCivita(e.Re(),LB,LA,pB));
635 
636  return sfm/(GeV*GeV*GeV);
637 }
639  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
640  os << "spin factor SF_BtoAV0_AtoSP1_StoP2P3_P"
641  << "\n\t parsed tree " << theDecay().oneLiner()
642  << "\n like this:" << endl;
643  this->printParsing(os);
644 }
645 
647  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
648 
649  double MA = mRes(A,evt);
650  double MV0 = mRes(fsPS[0],evt); // ??
651 
652  TLorentzVector pA= p(2,evt)+p(3,evt)+p(1,evt);
653  TLorentzVector qA= p(2,evt)+p(3,evt)-p(1,evt);
654  ZTspin1 LA(qA,pA,MA);
655 
656  TLorentzVector pB= pA+p(0,evt);
657  TLorentzVector qB= pA-p(0,evt);
658  ZTspin1 LB(qB,pB,pB.M());
659  SpinSumV PB(pB,pB.M());
660  TLorentzVector tmp= PB.Dot(LA);
661 
662  polVector e = polVector(p(0,evt),MV0,getPolarisation());
663  e.conj();
664 
665  complex<double> sfm( LB.Dot(LA) * LB.Dot(e.Re()) +1./3. * LB.Dot(LB) * tmp.Dot(e.Re()), LB.Dot(LA) * LB.Dot(e.Im()) +1./3. * LB.Dot(LB) * tmp.Dot(e.Im()) );
666 
667  return sfm/(GeV*GeV*GeV);
668 }
670  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
671  os << "spin factor SF_BtoAV0_AtoSP1_StoP2P3_P"
672  << "\n\t parsed tree " << theDecay().oneLiner()
673  << "\n like this:" << endl;
674  this->printParsing(os);
675 }
676 
677 
678 //==================================================================
679 // SF 6
680 
682  bool debugThis=false;
683 
684  if(fsPS.size() < 4) fsPS.reserve(4);
685  for(int i=0; i< theDecay(pat).nDgtr(); i++){
686  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
687  if(dgtr->getVal().SVPAT() == "V" && !(dgtr->isFinalState())) V1 = dgtr;
688  else if(dgtr->getVal().SVPAT() == "V" && dgtr->isFinalState() ) fsPS[0] = dgtr;
689  }
690  if(0==V1 || 0==fsPS[0]){
691  cout << "ERROR in SF_BtoV1V0_V1toV2P1_V2toP2P3::parseTree"
692  << " Didn't find V1 or V0 " << V1.get() << ", " << fsPS[0].get() << endl;
693  return false;
694  }
695 
696  for(int i=0; i< V1->nDgtr(); i++){
697  const_counted_ptr<AssociatedDecayTree> dgtr= V1->getDgtrTreePtr(i);
698  if(dgtr->getVal().SVPAT() == "V") V2 = dgtr;
699  else if(dgtr->getVal().SVPAT() == "P") fsPS[1] = dgtr;
700  }
701  if(0==V2 || 0==fsPS[1]){
702  cout << "ERROR in SF_BtoV1V0_V1toV2P1_V2toP2P3::parseTree"
703  << " Didn't find V2 or P1 " << V2.get() << ", " << fsPS[1].get() << endl;
704  return false;
705  }
706 
707  if(V2->nDgtr() != 2){
708  cout << "ERROR in SF_BtoV1V0_V1toV2P1_V2toP2P3::parseTree"
709  << " V2 should have 2 daughters, but it says it has "
710  << V2->nDgtr() << "."
711  << endl;
712  return false;
713  }
714  fsPS[2] = V2->getDgtrTreePtr(0);
715  fsPS[3] = V2->getDgtrTreePtr(1);
716 
717  //normalOrder(fsPS[2], fsPS[3]);
718 
719  if(debugThis){
720  cout << "parsed Tree: V1:\n"
721  << *V1
722  << "\n V2:"
723  << *V2
724  << endl;
725  for(int i=0; i<4; i++){
726  cout << "fsPS[" << i << "]\n"
727  << *(fsPS[i])
728  << endl;
729  }
730  }
731  // this->printYourself();
732  return true;
733 }
734 
736  if(0==_exampleDecay){
737  // B->J/psi K*(1410); K*->K*(892) pi; K*->K pi
738  _exampleDecay = new DecayTree(521);
739  _exampleDecay->addDgtr(443, 100323)->addDgtr(211, 313)->addDgtr(321,-211);
740  }
741  return *_exampleDecay;
742 }
743 
745  return getExampleDecay();
746 }
747 
749  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
750 
751  double MV1 = mRes(V1,evt);
752  double MV2 = mRes(V2,evt);
753  double MV0 = mRes(fsPS[0],evt);
754 
755  TLorentzVector pV2= p(2,evt)+p(3,evt);
756  TLorentzVector qV2= p(2,evt)-p(3,evt);
757  TLorentzVector pV1= pV2+p(1,evt);
758  TLorentzVector qV1= pV2-p(1,evt);
759  TLorentzVector pB= pV1+p(0,evt);
760  TLorentzVector qB= pV1-p(0,evt);
761 
762  ZTspin1 ZV1(qV1,pV1,MV1);
763  ZTspin1 ZV2(qV2,pV2,MV2);
764  SpinSumV PV1(pV1,MV1);
765 
766  polVector e = polVector(p(0,evt),MV0,getPolarisation());
767  e.conj();
768 
769  TLorentzVector tmp= PV1.Dot(ZV2);
770  if(tmp==TLorentzVector(0,0,0,0))return 0.;
771 
772  complex<double> sfm(LeviCivita(PV1.Dot(e.Re()),ZV1,pB,tmp),LeviCivita(PV1.Dot(e.Im()),ZV1,pB,tmp));
773 
774  //complex<double> sfm(LeviCivita(PV1.Dot(e.Re()),ZV1,pB).Dot(tmp),LeviCivita(PV1.Dot(e.Im()),ZV1,pB).Dot(tmp));
775  return sfm/(GeV*GeV*GeV);
776 }
778  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
779  os << "spin factor SF_BtoV1V0_V1toV2P1_V2toP2P3"
780  << "\n\t PV1.Contract(e_c),ZV2,qB,pB)"
781  << "\n\t /GeV^3"
782  << "\n\t parsed tree " << theDecay().oneLiner()
783  << "\n like this:" << endl;
784  this->printParsing(os);
785 }
786 
788  if(0==_exampleDecayP){
789  // B->J/psi K*(1410); K*->K*(892) pi; K*->K pi
790  _exampleDecayP = new DecayTree(521);
791  _exampleDecayP->addDgtr(443, 100323)->addDgtr(211, 313)->addDgtr(321,-211);
792  _exampleDecayP->getVal().setL(1);
793  }
794  return *_exampleDecayP;
795 }
796 
798  return getExampleDecay();
799 }
800 
802  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
803 
804  double MV1 = mRes(V1,evt);
805  double MV2 = mRes(V2,evt);
806  double MV0 = mRes(fsPS[0],evt);
807 
808  TLorentzVector pV2= p(2,evt)+p(3,evt);
809  TLorentzVector qV2= p(2,evt)-p(3,evt);
810  TLorentzVector pV1= pV2+p(1,evt);
811  TLorentzVector qV1= pV2-p(1,evt);
812  TLorentzVector pB= pV1+p(0,evt);
813  TLorentzVector qB= pV1-p(0,evt);
814 
815  ZTspin1 ZB(qB,pB,pB.M());
816  ZTspin1 ZV1(qV1,pV1,MV1);
817  ZTspin1 ZV2(qV2,pV2,MV2);
818  SpinSumV PV1(pV1,MV1);
819 
820  polVector e = polVector(p(0,evt),MV0,getPolarisation());
821  e.conj();
822 
823  TLorentzVector tmp = LeviCivita(ZV1,pV1,PV1.Dot(ZV2));
824 
825  complex<double> sfm(LeviCivita(e.Re(),ZB,pB,tmp),LeviCivita(e.Im(),ZB,pB,tmp));
826 
827  return sfm/(GeV*GeV*GeV*GeV*GeV);
828 }
830  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
831  os << "spin factor SF_BtoV1V0_V1toV2P1_V2toP2P3_P"
832  << "\n\t parsed tree " << theDecay().oneLiner()
833  << "\n like this:" << endl;
834  this->printParsing(os);
835 }
836 
838  if(0==_exampleDecayD){
839  // B->J/psi K*(1410); K*->K*(892) pi; K*->K pi
840  _exampleDecayD = new DecayTree(521);
841  _exampleDecayD->addDgtr(443, 100323)->addDgtr(211, 313)->addDgtr(321,-211);
842  _exampleDecayD->getVal().setL(2);
843  }
844  return *_exampleDecayD;
845 }
846 
848  return getExampleDecay();
849 }
850 
852  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
853 
854  double MV1 = mRes(V1,evt);
855  double MV2 = mRes(V2,evt);
856  double MV0 = mRes(fsPS[0],evt);
857 
858  TLorentzVector pV2= p(2,evt)+p(3,evt);
859  TLorentzVector qV2= p(2,evt)-p(3,evt);
860  TLorentzVector pV1= pV2+p(1,evt);
861  TLorentzVector qV1= pV2-p(1,evt);
862  TLorentzVector pB= pV1+p(0,evt);
863  TLorentzVector qB= pV1-p(0,evt);
864 
865  SpinSumV PB(pB,pB.M());
866  ZTspin1 ZB(qB,pB,pB.M());
867  ZTspin1 ZV1(qV1,pV1,MV1);
868  ZTspin1 ZV2(qV2,pV2,MV2);
869  SpinSumV PV1(pV1,MV1);
870 
871  polVector e = polVector(p(0,evt),MV0,getPolarisation());
872  e.conj();
873 
874  TLorentzVector tmp = PV1.Dot(LeviCivita(ZV1,pV1,PV1.Dot(ZV2)));
875 
876  complex<double> sfm(ZB.Dot(e.Re())*ZB.Dot(tmp)+ 1./3.*ZB.Dot(ZB) * (PB.Dot(tmp)).Dot(e.Re()), ZB.Dot(e.Im())*ZB.Dot(tmp)+ 1./3.*ZB.Dot(ZB) * (PB.Dot(tmp)).Dot(e.Im()));
877 
878  return sfm/(GeV*GeV*GeV*GeV*GeV);
879 }
881  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
882  os << "spin factor SF_BtoV1V0_V1toV2P1_V2toP2P3_D"
883  << "\n\t parsed tree " << theDecay().oneLiner()
884  << "\n like this:" << endl;
885  this->printParsing(os);
886 }
887 
888 
889 
890 //=========================================================
891 //SF 7-8
892 
894  bool debugThis=false;
895 
896  if(fsPS.size() < 4) fsPS.reserve(4);
897  for(int i=0; i< theDecay(pat).nDgtr(); i++){
898  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
899  if(dgtr->getVal().SVPAT() == "PT") PT = dgtr;
900  else if(dgtr->getVal().SVPAT() == "V") fsPS[0] = dgtr;
901  }
902  if(0==PT || 0==fsPS[0]){
903  cout << "ERROR in SF_BtoPseudoTV0_PseudoTtoVP1_VtoP2P3::parseTree"
904  << " Didn't find PT or V0 " << PT.get() << ", " << fsPS[0].get() << endl;
905  return false;
906  }
907 
908  for(int i=0; i< PT->nDgtr(); i++){
909  const_counted_ptr<AssociatedDecayTree> dgtr= PT->getDgtrTreePtr(i);
910  if(dgtr->getVal().SVPAT() == "V") V = dgtr;
911  else if(dgtr->getVal().SVPAT() == "P") fsPS[1] = dgtr;
912  }
913  if(0==V || 0==fsPS[1]){
914  cout << "ERROR in SF_BtoPseudoTV0_PseudoTtoVP1_VtoP2P3::parseTree"
915  << " Didn't find V or P1 " << V.get() << ", " << fsPS[1].get() << endl;
916  return false;
917  }
918 
919  if(V->nDgtr() != 2){
920  cout << "ERROR in SF_BtoPseudoTV0_PseudoTtoVP1_VtoP2P3::parseTree"
921  << " V should have 2 daughters, but it says it has "
922  << V->nDgtr() << "."
923  << endl;
924  return false;
925  }
926  fsPS[2] = V->getDgtrTreePtr(0);
927  fsPS[3] = V->getDgtrTreePtr(1);
928 
929  //normalOrder(fsPS[2], fsPS[3]);
930 
931  if(debugThis){
932  cout << "parsed Tree: V:\n"
933  << *V
934  << "\n PT:"
935  << *PT
936  << endl;
937  for(int i=0; i<4; i++){
938  cout << "fsPS[" << i << "]\n"
939  << *(fsPS[i])
940  << endl;
941  }
942  }
943  // this->printYourself();
944  return true;
945 }
946 
948  if(0==_exampleDecayP){
949  // B->J/psi K2(1580); K2->K*(892) pi; K*->K pi
950  _exampleDecayP = new DecayTree(521);
951  _exampleDecayP->addDgtr(443, 9000325)->addDgtr(211, 313)->addDgtr(321,-211);
952  }
953  return *_exampleDecayP;
954 }
955 
957  return getExampleDecay();
958 }
959 
961  if(0==_exampleDecayD){
962  // B->J/psi K2(1580); K2->K*(892) pi; K*->K pi
963  _exampleDecayD = new DecayTree(521);
964  _exampleDecayD->addDgtr(443, 9000325)->addDgtr(211, 313)->addDgtr(321,-211);
965  _exampleDecayD->getVal().setL(2);
966  }
967  return *_exampleDecayD;
968 }
969 
971  return getExampleDecay();
972 }
973 
974 
975 //SF 7
977  //bool debugThis = false;
978 
979  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
980 
981  double MT = mRes(PT,evt);
982  double MV = mRes(V,evt);
983  double MV0 = mRes(fsPS[0],evt); // ??
984  //double MV0 = p(0,evt).M(); // ??
985 
986  TLorentzVector pV= p(2,evt)+p(3,evt);
987  TLorentzVector qV= p(2,evt)-p(3,evt);
988  TLorentzVector pT= pV+p(1,evt);
989  TLorentzVector qT= pV-p(1,evt);
990  TLorentzVector qB= pT-p(0,evt);
991  TLorentzVector pB= pT+p(0,evt);
992 
993  ZTspin1 ZB(qB,pB,pB.M());
994  ZTspin1 ZV(qV,pV,MV);
995  ZTspin1 ZT(qT, pT, MT);
996  //ZTspin2 ZT_2(qT, pT, MT);
997  SpinSumT DT(pT,MT);
998  SpinSumV PT(pT,MT);
999 
1000  polVector e = polVector(p(0,evt),MV0,getPolarisation());
1001  e.conj();
1002 
1003  //TLorentzVector tmp = ZT.Contract(ZV);
1004  //complex<double> sfm(e.Re().Dot(tmp),e.Im().Dot(tmp));
1005 
1006  //complex<double> sfm(DT.Sandwich(e.Re(),qT,qT,ZV),DT.Sandwich(e.Im(),qT,qT,ZV));
1007 
1008  TLorentzVector tmp = PT.Dot(ZV);
1009  if(tmp==TLorentzVector(0,0,0,0))return 0.;
1010  complex<double> sfm(DT.Sandwich(e.Re(),ZB,ZT,tmp),DT.Sandwich(e.Im(),ZB,ZT,tmp));
1011 
1012  return sfm/(GeV*GeV*GeV);
1013 }
1015  // bool debugThis = false;
1016 
1017  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
1018  os << "spin factor SF_BtoPseudoTV0_PseudoTtoVP1_VtoP2P3_P"
1019  << "\n\t e_c.Dot(ZT.Contract(ZV))"
1020  << "\n\t /GeV^3"
1021  << "\n\t parsed tree " << theDecay().oneLiner()
1022  << "\n like this:" << endl;
1023  this->printParsing(os);
1024 }
1025 
1026 //SF 8
1028  //bool debugThis = false;
1029 
1030  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
1031 
1032  double MT = mRes(PT,evt);
1033  double MV = mRes(V,evt);
1034  double MV0 = mRes(fsPS[0],evt); // ??
1035  //double MV0 = p(0,evt).M(); // ??
1036 
1037  TLorentzVector pV= p(2,evt)+p(3,evt);
1038  TLorentzVector qV= p(2,evt)-p(3,evt);
1039  TLorentzVector pT= pV+p(1,evt);
1040  TLorentzVector qT= pV-p(1,evt);
1041  TLorentzVector pB= pT+p(0,evt);
1042  TLorentzVector qB= pT-p(0,evt);
1043 
1044  ZTspin1 ZV(qV,pV,MV);
1045  ZTspin2 ZT(qT, pT, MT);
1046 
1047  polVector e = polVector(p(0,evt),MV0,getPolarisation());
1048  e.conj();
1049 
1050  TLorentzVector tmp = ZT.Contract(ZV);
1051  if(tmp==TLorentzVector(0,0,0,0))return 0.;
1052 
1053  complex<double> sfm(LeviCivita(e.Re(),tmp,pB,qB),LeviCivita(e.Im(),tmp,pB,qB));
1054  //if(getPolarisation()==0)sfm=complex<double>(LeviCivita(e.Re(),tmp,pB,qB),0.);
1055  //else sfm=complex<double>(LeviCivita(e.Re(),tmp,pB,qB),LeviCivita(e.Im(),tmp,pB,qB));
1056 
1057  return sfm/(GeV*GeV*GeV*GeV*GeV);
1058 }
1060  // bool debugThis = false;
1061 
1062  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
1063  os << "spin factor SF_BtoPseudoTV0_PseudoTtoVP1_VtoP2P3_D"
1064  << "\n\t LeviCivita(e_c,ZT.Contract(ZV),pB,qB)"
1065  << "\n\t /GeV^5"
1066  << "\n\t parsed tree " << theDecay().oneLiner()
1067  << "\n like this:" << endl;
1068  this->printParsing(os);
1069 }
1070 
1071 
1072 //=========================================================
1073 //SF 9
1074 
1076  bool debugThis=false;
1077 
1078  if(fsPS.size() < 4) fsPS.reserve(4);
1079  for(int i=0; i< theDecay(pat).nDgtr(); i++){
1080  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
1081  if(dgtr->getVal().SVPAT() == "PT") PT = dgtr;
1082  else if(dgtr->getVal().SVPAT() == "V") fsPS[0] = dgtr;
1083  }
1084  if(0==PT || 0==fsPS[0]){
1085  cout << "ERROR in SF_BtoPseudoTV0_PseudoTtoSP1_StoP2P3::parseTree"
1086  << " Didn't find PT or V0 " << PT.get() << ", " << fsPS[0].get() << endl;
1087  return false;
1088  }
1089 
1090  for(int i=0; i< PT->nDgtr(); i++){
1091  const_counted_ptr<AssociatedDecayTree> dgtr= PT->getDgtrTreePtr(i);
1092  if(dgtr->getVal().SVPAT() == "S") S = dgtr;
1093  else if(dgtr->getVal().SVPAT() == "P") fsPS[1] = dgtr;
1094  }
1095  if(0==S || 0==fsPS[1]){
1096  cout << "ERROR in SF_BtoPseudoTV0_PseudoTtoSP1_StoP2P3::parseTree"
1097  << " Didn't find S or P1 " << S.get() << ", " << fsPS[1].get() << endl;
1098  return false;
1099  }
1100 
1101  if(S->nDgtr() != 2){
1102  cout << "ERROR in SF_BtoPseudoTV0_PseudoTtoSP1_StoP2P3::parseTree"
1103  << " S should have 2 daughters, but it says it has "
1104  << S->nDgtr() << "."
1105  << endl;
1106  return false;
1107  }
1108  fsPS[2] = S->getDgtrTreePtr(0);
1109  fsPS[3] = S->getDgtrTreePtr(1);
1110 
1111  //normalOrder(fsPS[2], fsPS[3]);
1112 
1113  if(debugThis){
1114  cout << "parsed Tree: S:\n"
1115  << *S
1116  << "\n PT:"
1117  << *PT
1118  << endl;
1119  for(int i=0; i<4; i++){
1120  cout << "fsPS[" << i << "]\n"
1121  << *(fsPS[i])
1122  << endl;
1123  }
1124  }
1125  // this->printYourself();
1126  return true;
1127 }
1128 
1130  if(0==_exampleDecayP){
1131  // B->J/psi K2(1770); K2->K f0(980); f0->pi pi
1132  _exampleDecayP = new DecayTree(521);
1133  _exampleDecayP->addDgtr(443, 10325)->addDgtr(321, 9010221)->addDgtr(211,-211);
1134  }
1135  return *_exampleDecayP;
1136 }
1137 
1139  return getExampleDecay();
1140 }
1141 
1143  //bool debugThis = false;
1144 
1145  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
1146 
1147  double MT = mRes(PT,evt);
1148  double MV0 = mRes(fsPS[0],evt); // ??
1149  //double MV0 = p(0,evt).M(); // ??
1150 
1151  TLorentzVector pT= p(2,evt)+p(3,evt)+p(1,evt);
1152  TLorentzVector qT= p(2,evt)+p(3,evt)-p(1,evt);
1153  TLorentzVector qB= pT-p(0,evt);
1154  TLorentzVector pB= pT+p(0,evt);
1155 
1156  //ZTspin2 ZT(qT, pT, MT);
1157  SpinSumT DT(pT,MT);
1158  ZTspin1 ZB(qB, pB, pB.M());
1159 
1160  polVector e = polVector(p(0,evt),MV0,getPolarisation());
1161  e.conj();
1162 
1163  //TLorentzVector tmp = ZT.Contract(qB);
1164  // complex<double> sfm(e.Re().Dot(tmp),e.Im().Dot(tmp));
1165 
1166  complex<double> sfm(DT.Sandwich(e.Re(),ZB,qT,qT),DT.Sandwich(e.Im(),ZB,qT,qT));
1167  return sfm/(GeV*GeV*GeV);
1168 }
1170  // bool debugThis = false;
1171 
1172  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
1173  os << "spin factor SF_BtoPseudoTV0_PseudoTtoSP1_StoP2P3_P"
1174  << "\n\t e_c.Dot(ZT.Contract(qB))"
1175  << "\n\t /GeV^3"
1176  << "\n\t parsed tree " << theDecay().oneLiner()
1177  << "\n like this:" << endl;
1178  this->printParsing(os);
1179 }
1180 
1181 
1182 //=========================================================
1183 //SF 10
1184 
1186  bool debugThis=false;
1187 
1188  if(fsPS.size() < 4) fsPS.reserve(4);
1189  for(int i=0; i< theDecay(pat).nDgtr(); i++){
1190  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
1191  if(dgtr->getVal().SVPAT() == "PT") PT = dgtr;
1192  else if(dgtr->getVal().SVPAT() == "V") fsPS[0] = dgtr;
1193  }
1194  if(0==PT || 0==fsPS[0]){
1195  cout << "ERROR in SF_BtoPseudoTV0_PseudoTtoTP1_TtoP2P3::parseTree"
1196  << " Didn't find PT or V0 " << PT.get() << ", " << fsPS[0].get() << endl;
1197  return false;
1198  }
1199 
1200  for(int i=0; i< PT->nDgtr(); i++){
1201  const_counted_ptr<AssociatedDecayTree> dgtr= PT->getDgtrTreePtr(i);
1202  if(dgtr->getVal().SVPAT() == "T") T = dgtr;
1203  else if(dgtr->getVal().SVPAT() == "P") fsPS[1] = dgtr;
1204  }
1205  if(0==T || 0==fsPS[1]){
1206  cout << "ERROR in SF_BtoPseudoTV0_PseudoTtoTP1_TtoP2P3::parseTree"
1207  << " Didn't find T or P1 " << T.get() << ", " << fsPS[1].get() << endl;
1208  return false;
1209  }
1210 
1211  if(T->nDgtr() != 2){
1212  cout << "ERROR in SF_BtoPseudoTV0_PseudoTtoTP1_TtoP2P3::parseTree"
1213  << " T should have 2 daughters, but it says it has "
1214  << T->nDgtr() << "."
1215  << endl;
1216  return false;
1217  }
1218  fsPS[2] = T->getDgtrTreePtr(0);
1219  fsPS[3] = T->getDgtrTreePtr(1);
1220 
1221  //normalOrder(fsPS[2], fsPS[3]);
1222 
1223  if(debugThis){
1224  cout << "parsed Tree: T:\n"
1225  << *T
1226  << "\n PT:"
1227  << *PT
1228  << endl;
1229  for(int i=0; i<4; i++){
1230  cout << "fsPS[" << i << "]\n"
1231  << *(fsPS[i])
1232  << endl;
1233  }
1234  }
1235  // this->printYourself();
1236  return true;
1237 }
1238 
1240  if(0==_exampleDecayP){
1241  // B->J/psi K2(1770); K2->K f2(1270); f2->pi pi
1242  _exampleDecayP = new DecayTree(521);
1243  _exampleDecayP->addDgtr(443, 10325)->addDgtr(321, 225)->addDgtr(211,-211);
1244  }
1245  return *_exampleDecayP;
1246 }
1247 
1249  return getExampleDecay();
1250 }
1251 
1253  //bool debugThis = false;
1254 
1255  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
1256 
1257  double MPT = mRes(PT,evt);
1258  double MT = mRes(T,evt);
1259  double MV0 = mRes(fsPS[0],evt); // ??
1260  //double MV0 = p(0,evt).M(); // ??
1261  TLorentzVector pT= p(2,evt)+p(3,evt);
1262  TLorentzVector qT= p(2,evt)-p(3,evt);
1263  TLorentzVector pPT= pT+p(1,evt);
1264  TLorentzVector qPT= pT-p(1,evt);
1265  TLorentzVector pB= pPT+p(0,evt);
1266  TLorentzVector qB= pPT-p(0,evt);
1267 
1268  SpinSumT D_PT(pPT,MPT);
1269  ZTspin1 Z_1T(qT,pT,MT);
1270  ZTspin1 Z_B(qB,pB,pB.M());
1271 
1272  // SpinSumV P_PT(pPT,MPT);
1273  //ZTgperp P_PT_matrix(pPT,MPT);
1274  //ZTspin2 ZT(qT, pT, MT);
1275 
1276  polVector e = polVector(p(0,evt),MV0,getPolarisation());
1277  e.conj();
1278 
1279  //TLorentzVector tmp= P_PT.Dot(qB);
1280  //TLorentzVector tmp2= ZT.Contract(tmp);
1281  //double tmp3= (P_PT_matrix.Contract_2(ZT))/(GeV*GeV);
1282  //complex<double> sf(P_PT.Sandwich(e.Re(),tmp2)-1./3.*(P_PT.Sandwich(e.Re(),qB)*tmp3),P_PT.Sandwich(e.Im(),tmp2)-1./3.*(P_PT.Sandwich(e.Im(),qB)*tmp3));
1283 
1284  complex<double> sf(D_PT.Sandwich(e.Re(),Z_B,Z_1T,Z_1T)+1./3.*Z_1T.Mag2()/MT/MT * D_PT.Sandwich(e.Re(),Z_B,pT,pT), D_PT.Sandwich(e.Im(),Z_B,Z_1T,Z_1T)+1./3.*Z_1T.Mag2()/MT/MT * D_PT.Sandwich(e.Im(),Z_B,pT,pT) );
1285  return sf/(GeV*GeV*GeV);
1286 }
1288  // bool debugThis = false;
1289 
1290  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
1291  os << "spin factor SF_BtoPseudoTV0_PseudoTtoTP1_TtoP2P3_P"
1292  << "\n\t e_c.Dot(ZT.Contract(qB))"
1293  << "\n\t /GeV^3"
1294  << "\n\t parsed tree " << theDecay().oneLiner()
1295  << "\n like this:" << endl;
1296  this->printParsing(os);
1297 }
1298 
1299 
1300 
1301 
1302 //=========================================================
1303 //SF 11
1304 
1306  bool debugThis=false;
1307 
1308  if(fsPS.size() < 4) fsPS.reserve(4);
1309  for(int i=0; i< theDecay(pat).nDgtr(); i++){
1310  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
1311  if(dgtr->getVal().SVPAT() == "T") T = dgtr;
1312  else if(dgtr->getVal().SVPAT() == "V") fsPS[0] = dgtr;
1313  }
1314  if(0==T || 0==fsPS[0]){
1315  cout << "ERROR in SF_BtoTV0_TtoVP1_VtoP2P3::parseTree"
1316  << " Didn't find T or V0 " << T.get() << ", " << fsPS[0].get() << endl;
1317  return false;
1318  }
1319 
1320  for(int i=0; i< T->nDgtr(); i++){
1321  const_counted_ptr<AssociatedDecayTree> dgtr= T->getDgtrTreePtr(i);
1322  if(dgtr->getVal().SVPAT() == "V") V = dgtr;
1323  else if(dgtr->getVal().SVPAT() == "P") fsPS[1] = dgtr;
1324  }
1325  if(0==V || 0==fsPS[1]){
1326  cout << "ERROR in SF_BtoTV0_TtoVP1_VtoP2P3::parseTree"
1327  << " Didn't find V or P1 " << V.get() << ", " << fsPS[1].get() << endl;
1328  return false;
1329  }
1330 
1331  if(V->nDgtr() != 2){
1332  cout << "ERROR in SF_SF_BtoTV0_TtoVP1_VtoP2P3::parseTree"
1333  << " V should have 2 daughters, but it says it has "
1334  << V->nDgtr() << "."
1335  << endl;
1336  return false;
1337  }
1338  fsPS[2] = V->getDgtrTreePtr(0);
1339  fsPS[3] = V->getDgtrTreePtr(1);
1340 
1341  //normalOrder(fsPS[2], fsPS[3]);
1342 
1343  if(debugThis){
1344  cout << "parsed Tree: V:\n"
1345  << *V
1346  << "\n T:"
1347  << *T
1348  << endl;
1349  for(int i=0; i<4; i++){
1350  cout << "fsPS[" << i << "]\n"
1351  << *(fsPS[i])
1352  << endl;
1353  }
1354  }
1355  // this->printYourself();
1356  return true;
1357 }
1358 
1360  if(0==_exampleDecayP){
1361  // B->J/psi K2*(1430); K2->K*(892) pi; K*->K pi
1362  _exampleDecayP = new DecayTree(521);
1363  _exampleDecayP->addDgtr(443, 325)->addDgtr(211, 313)->addDgtr(321,-211);
1364  }
1365  return *_exampleDecayP;
1366 }
1367 
1369  return getExampleDecay();
1370 }
1371 
1373  //bool debugThis = false;
1374 
1375  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
1376 
1377  double MT = mRes(T,evt);
1378  double MV = mRes(V,evt);
1379  double MV0 = mRes(fsPS[0],evt); // ??
1380  //double MV0 = p(0,evt).M(); // ??
1381 
1382  TLorentzVector pV= p(2,evt)+p(3,evt);
1383  TLorentzVector qV= p(2,evt)-p(3,evt);
1384  TLorentzVector pT= pV+p(1,evt);
1385  TLorentzVector qT= pV-p(1,evt);
1386  TLorentzVector pB= pT+p(0,evt);
1387  TLorentzVector qB= pT-p(0,evt);
1388 
1389  ZTspin1 ZB(qB,pB,pB.M());
1390  ZTspin1 ZV(qV,pV,MV);
1391  ZTspin1 Z_1T(qT,pT,MT);
1392  SpinSumV PT(pT,MT);
1393  //ZTspin2 ZT(qT, pT, MT);
1394 
1395  polVector e = polVector(p(0,evt),MV0,getPolarisation());
1396  e.conj();
1397 
1398  complex<double> sfm;
1399 
1400  TLorentzVector tmp0 = PT.Dot(ZV);
1401  if(tmp0==TLorentzVector(0,0,0,0))return 0.;
1402 
1403  TLorentzVector tmp1 = PT.Dot(ZB);
1404  TLorentzVector tmp2_Re = Z_1T * Z_1T.Dot(e.Re()) + 1./3. * Z_1T.Mag2() * PT.Dot(e.Re());
1405  TLorentzVector tmp2_Im = Z_1T * Z_1T.Dot(e.Im()) + 1./3. * Z_1T.Mag2() * PT.Dot(e.Im());
1406 
1407  TLorentzVector tmp3_Re = PT.Dot(e.Re());
1408  TLorentzVector tmp3_Im = PT.Dot(e.Im());
1409  TLorentzVector tmp4 = Z_1T * Z_1T.Dot(ZB) + 1./3. * Z_1T.Mag2() * PT.Dot(ZB);
1410 
1411 
1412  if(getPolarisation()==0)sfm=complex<double>(LeviCivita(pT,tmp0,tmp1,tmp2_Re)+LeviCivita(pT,tmp0,tmp4,tmp3_Re),0.);
1413  else sfm=complex<double>(LeviCivita(pT,tmp0,tmp1,tmp2_Re)+LeviCivita(pT,tmp0,tmp4,tmp3_Re),LeviCivita(pT,tmp0,tmp1,tmp2_Im)+LeviCivita(pT,tmp0,tmp4,tmp3_Im));
1414 
1415  //TLorentzVector tmp_Re = Z_1T * (Z_1T.Contract(e.Re())) - 1./3. * Z_1T.Mag2() * PT.Dot(e.Re()) ;
1416  //TLorentzVector tmp_Im = Z_1T * (Z_1T.Contract(e.Im())) - 1./3. * Z_1T.Mag2() * PT.Dot(e.Im()) ;
1417  //complex<double> sfm;
1418  //if(getPolarisation()==0)sfm=complex<double>(LeviCivita(tmp_Re,ZV,pB,qB),0.);
1419  //else sfm=complex<double>(LeviCivita(tmp_Re,ZV,pB,qB),LeviCivita(tmp_Im,ZV,pB,qB));
1420 
1421  //if(getPolarisation()==0)sfm=complex<double>(LeviCivita(ZT.Contract(e.Re()),ZV,pB,qB),0.);
1422  //else sfm=complex<double>(LeviCivita(ZT.Contract(e.Re()),ZV,pT,qT),LeviCivita(ZT.Contract(e.Im()),ZV,pT,qT));
1423 
1424 
1425  return sfm/(GeV*GeV*GeV*GeV*GeV);
1426 }
1428  // bool debugThis = false;
1429 
1430  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
1431  os << "spin factor SF_BtoTV0_TtoVP1_VtoP2P3_P"
1432  << "\n\t LeviCivita(ZT.Contract(e_c),ZV,pB,qB)"
1433  << "\n\t /GeV^5"
1434  << "\n\t parsed tree " << theDecay().oneLiner()
1435  << "\n like this:" << endl;
1436  this->printParsing(os);
1437 }
1438 
1439 //=========================================================
1440 //SF 12/13
1441 
1443  if(0==_exampleDecay){
1444  // B->psi(2S) K; psi(2S)-> J/psi pi pi (non resonant)
1445  _exampleDecay = new DecayTree(521);
1446  _exampleDecay->addDgtr(321, 100443)->addDgtr(443, 9981)->addDgtr(211,-211);
1447  }
1448  return *_exampleDecay;
1449 }
1450 
1452  return getExampleDecay();
1453 }
1454 
1456  bool debugThis=false;
1457 
1458  if(fsPS.size() < 4) fsPS.reserve(4);
1459  for(int i=0; i< theDecay(pat).nDgtr(); i++){
1460  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
1461  if(dgtr->getVal().SVPAT() == "V") V = dgtr;
1462  else if(dgtr->getVal().SVPAT() == "P") fsPS[1] = dgtr;
1463  }
1464  if(0==V || 0==fsPS[1]){
1465  cout << "ERROR in SF_BtoVP1_VtoV0S_StoP2P3::parseTree"
1466  << " Didn't find V or P1 " << V.get() << ", " << fsPS[1].get() << endl;
1467  return false;
1468  }
1469 
1470  for(int i=0; i< V->nDgtr(); i++){
1471  const_counted_ptr<AssociatedDecayTree> dgtr= V->getDgtrTreePtr(i);
1472  if(dgtr->getVal().SVPAT() == "S") S = dgtr;
1473  else if(dgtr->getVal().SVPAT() == "V") fsPS[0] = dgtr;
1474  }
1475  if(0==S || 0==fsPS[0]){
1476  cout << "ERROR in SF_BtoVP1_VtoV0S_StoP2P3::parseTree"
1477  << " Didn't find S or V0 " << S.get() << ", " << fsPS[0].get() << endl;
1478  return false;
1479  }
1480 
1481  if(S->nDgtr() != 2){
1482  cout << "ERROR in SF_BtoVP1_VtoV0S_StoP2P3::parseTree"
1483  << " S should have 2 daughters, but it says it has "
1484  << S->nDgtr() << "."
1485  << endl;
1486  return false;
1487  }
1488  fsPS[2] = S->getDgtrTreePtr(0);
1489  fsPS[3] = S->getDgtrTreePtr(1);
1490 
1491  //normalOrder(fsPS[2], fsPS[3]);
1492 
1493  if(debugThis){
1494  cout << "parsed Tree: V:\n"
1495  << *V
1496  << "\n S:"
1497  << *S
1498  << endl;
1499  for(int i=0; i<4; i++){
1500  cout << "fsPS[" << i << "]\n"
1501  << *(fsPS[i])
1502  << endl;
1503  }
1504  }
1505  // this->printYourself();
1506  return true;
1507 }
1508 
1510  //bool debugThis = false;
1511 
1512  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
1513 
1514  double MV = mRes(V,evt);
1515  double MV0 = mRes(fsPS[0],evt); // ??
1516  //double MV0 = p(0,evt).M(); // ??
1517  TLorentzVector pV= p(0,evt)+p(2,evt)+p(3,evt);
1518  TLorentzVector qV= p(2,evt)+p(3,evt)-p(0,evt);
1519  TLorentzVector qB= p(1,evt)-pV;
1520  polVector e = polVector(p(0,evt),MV0,getPolarisation());
1521  e.conj();
1522 
1523  complex<double> sfm;
1524  double scale = (p(2,evt)+p(3,evt)).M2() - 4.*mRes(fsPS[3],evt)*mRes(fsPS[3],evt);
1525  //double scale = (p(2,evt)+p(3,evt)).M2() - 4.35*mRes(fsPS[3],evt)*mRes(fsPS[3],evt); ??
1526 
1527  if(is3bodyDecay()){
1528  complex<double> tmp(qB.Dot(e.Re())*scale,qB.Dot(e.Im())*scale);
1529  sfm=tmp/(GeV*GeV*GeV);
1530  //compley<double> tmp(scale,0.);
1531  //tmp=tmp/(GeV*GeV);
1532  }
1533  else{
1534  ZTspin1 Z(qV,pV,MV);
1535  complex<double> tmp(Z.Dot(e.Re()),Z.Dot(e.Im()));
1536  sfm=tmp/(GeV);
1537  }
1538 
1539  return sfm;
1540 }
1542  // bool debugThis = false;
1543 
1544  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
1545  os << "spin factor SF_BtoVP1_VtoV0S_StoP2P3"
1546  << "\n\t Z.Dot(e_c)"
1547  << "\n\t /GeV"
1548  << "\n\t parsed tree " << theDecay().oneLiner()
1549  << "\n like this:" << endl;
1550  this->printParsing(os);
1551 }
1552 
1553 
1554 
1555 
1556 
1557 //=========================================================
1558 //SF 14
1559 
1561  if(0==_exampleDecay){
1562  // B->psi(2S) K; psi(2S)-> J/psi rho
1563  _exampleDecay = new DecayTree(521);
1564  _exampleDecay->addDgtr(321, 100443)->addDgtr(443, 113)->addDgtr(211,-211);
1565  }
1566  return *_exampleDecay;
1567 }
1568 
1570  return getExampleDecay();
1571 }
1572 
1574  bool debugThis=false;
1575 
1576  if(fsPS.size() < 4) fsPS.reserve(4);
1577  for(int i=0; i< theDecay(pat).nDgtr(); i++){
1578  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
1579  if(dgtr->getVal().SVPAT() == "V") V1 = dgtr;
1580  else if(dgtr->getVal().SVPAT() == "P") fsPS[1] = dgtr;
1581  }
1582  if(0==V1 || 0==fsPS[1]){
1583  cout << "ERROR in SF_BtoV1P1_V1toV2V0_V2toP2P3::parseTree"
1584  << " Didn't find V1 or P1 " << V1.get() << ", " << fsPS[1].get() << endl;
1585  return false;
1586  }
1587 
1588  for(int i=0; i< V1->nDgtr(); i++){
1589  const_counted_ptr<AssociatedDecayTree> dgtr= V1->getDgtrTreePtr(i);
1590  if(dgtr->getVal().SVPAT() == "V" && !(dgtr->isFinalState())) V2 = dgtr;
1591  else if(dgtr->getVal().SVPAT() == "V" && dgtr->isFinalState()) fsPS[0] = dgtr;
1592  }
1593  if(0==V2 || 0==fsPS[0]){
1594  cout << "ERROR in SF_BtoV1P1_V1toV2V0_V2toP2P3::parseTree"
1595  << " Didn't find V2 or V0 " << V2.get() << ", " << fsPS[0].get() << endl;
1596  return false;
1597  }
1598 
1599  if(V2->nDgtr() != 2){
1600  cout << "ERROR in SF_BtoV1P1_V1toV2V0_V2toP2P3::parseTree"
1601  << " V2 should have 2 daughters, but it says it has "
1602  << V2->nDgtr() << "."
1603  << endl;
1604  return false;
1605  }
1606  fsPS[2] = V2->getDgtrTreePtr(0);
1607  fsPS[3] = V2->getDgtrTreePtr(1);
1608 
1609  //normalOrder(fsPS[2], fsPS[3]);
1610 
1611  if(debugThis){
1612  cout << "parsed Tree: V1:\n"
1613  << *V1
1614  << "\n V2:"
1615  << *V2
1616  << endl;
1617  for(int i=0; i<4; i++){
1618  cout << "fsPS[" << i << "]\n"
1619  << *(fsPS[i])
1620  << endl;
1621  }
1622  }
1623  // this->printYourself();
1624  return true;
1625 }
1626 
1628  //bool debugThis = false;
1629 
1630  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
1631 
1632  double MV1 = mRes(V1,evt);
1633  double MV2 = mRes(V2,evt);
1634  double MV0 = mRes(fsPS[0],evt); // ??
1635  //double MV0 = p(0,evt).M(); // ??
1636 
1637  TLorentzVector pV2= p(2,evt)+p(3,evt);
1638  TLorentzVector qV2= p(2,evt)-p(3,evt);
1639  TLorentzVector pV1= p(0,evt)+pV2;
1640  TLorentzVector qV1= pV2-p(0,evt);
1641  TLorentzVector qB= pV1-p(1,evt);
1642  TLorentzVector pB= pV1+p(1,evt);
1643 
1644  polVector e = polVector(p(0,evt),MV0,getPolarisation());
1645  e.conj();
1646 
1647  ZTspin1 ZB(qB,pB,pB.M());
1648  ZTspin1 Z1(qV1,pV1,MV1);
1649  ZTspin1 Z2(qV2,pV2,MV2);
1650 
1651  if(getLS_S()==0){
1652  complex<double> sf(Z2.Dot(e.Re()),Z2.Dot(e.Im()));
1653  return sf*Z1.Dot(ZB)/(GeV*GeV*GeV);
1654  }
1655  else if(getLS_S()==1){
1656  SpinSumV PV1(pV1,MV1);
1657  TLorentzVector tmp= PV1.Dot(ZB);
1658  complex<double> sf(tmp.Dot(Z2)*Z1.Dot(e.Re())-tmp.Dot(e.Re())*Z1.Dot(Z2),tmp.Dot(Z2)*Z1.Dot(e.Im())-tmp.Dot(e.Im())*Z1.Dot(Z2));
1659  return sf*pV1.M2()/(GeV*GeV*GeV*GeV*GeV);
1660  }
1661  if(getLS_S()==2){
1662  SpinSumV PV1(pV1,MV1);
1663  SpinSumT DV1(pV1,MV1);
1664  TLorentzVector tmp= PV1.Dot(ZB);
1665  complex<double> sf(DV1.Sandwich(tmp,Z1,e.Re(),Z2),DV1.Sandwich(tmp,Z1,e.Im(),Z2));
1666  return sf/(GeV*GeV*GeV);
1667  }
1668  return 1;
1669 }
1671  // bool debugThis = false;
1672 
1673  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
1674  os << "spin factor SF_BtoV1P1_V1toV2V0_V2toP2P3"
1675  << "\n\t parsed tree " << theDecay().oneLiner()
1676  << "\n like this:" << endl;
1677  this->printParsing(os);
1678 }
1679 
1680 
1681 
1682 //=========================================================
1683 //SF 15/16
1684 
1686  if(0==_exampleDecay){
1687  // B->X K; X-> J/psi rho
1688  _exampleDecay = new DecayTree(521);
1689  _exampleDecay->addDgtr(321, 9983)->addDgtr(443, 113)->addDgtr(211,-211);
1690  }
1691  return *_exampleDecay;
1692 }
1693 
1695  return getExampleDecay();
1696 }
1697 
1699  bool debugThis=false;
1700 
1701  if(fsPS.size() < 4) fsPS.reserve(4);
1702  for(int i=0; i< theDecay(pat).nDgtr(); i++){
1703  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
1704  if(dgtr->getVal().SVPAT() == "A") A = dgtr;
1705  else if(dgtr->getVal().SVPAT() == "P") fsPS[1] = dgtr;
1706  }
1707  if(0==A || 0==fsPS[1]){
1708  cout << "ERROR in SF_BtoAP1_AtoVV0_VtoP2P3::parseTree"
1709  << " Didn't find A or P1 " << A.get() << ", " << fsPS[1].get() << endl;
1710  return false;
1711  }
1712 
1713  for(int i=0; i< A->nDgtr(); i++){
1714  const_counted_ptr<AssociatedDecayTree> dgtr= A->getDgtrTreePtr(i);
1715  if(dgtr->getVal().SVPAT() == "V" && !(dgtr->isFinalState())) V = dgtr;
1716  else if(dgtr->getVal().SVPAT() == "V" && dgtr->isFinalState()) fsPS[0] = dgtr;
1717  }
1718  if(0==V || 0==fsPS[0]){
1719  cout << "ERROR in SF_BtoAP1_AtoVV0_VtoP2P3::parseTree"
1720  << " Didn't find V or V0 " << V.get() << ", " << fsPS[0].get() << endl;
1721  return false;
1722  }
1723 
1724  if(V->nDgtr() != 2){
1725  cout << "ERROR in SF_BtoAP1_AtoVV0_VtoP2P3::parseTree"
1726  << " V should have 2 daughters, but it says it has "
1727  << V->nDgtr() << "."
1728  << endl;
1729  return false;
1730  }
1731  fsPS[2] = V->getDgtrTreePtr(0);
1732  fsPS[3] = V->getDgtrTreePtr(1);
1733 
1734  //normalOrder(fsPS[2], fsPS[3]);
1735 
1736  if(debugThis){
1737  cout << "parsed Tree: A:\n"
1738  << *A
1739  << "\n V:"
1740  << *V
1741  << endl;
1742  for(int i=0; i<4; i++){
1743  cout << "fsPS[" << i << "]\n"
1744  << *(fsPS[i])
1745  << endl;
1746  }
1747  }
1748  // this->printYourself();
1749  return true;
1750 }
1751 
1753  //bool debugThis = false;
1754 
1755  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
1756 
1757  double MA = mRes(A,evt);
1758  double MV = mRes(V,evt);
1759  double MV0 = mRes(fsPS[0],evt); // ??
1760  //double MV0 = p(0,evt).M(); // ??
1761 
1762  TLorentzVector pV= p(2,evt)+p(3,evt);
1763  TLorentzVector qV= p(2,evt)-p(3,evt);
1764  TLorentzVector pA= p(0,evt)+pV;
1765  //TLorentzVector qA= pV-p(0,evt);
1766  TLorentzVector qB= pA-p(1,evt);
1767  TLorentzVector pB= pA+p(1,evt);
1768  polVector e = polVector(p(0,evt),MV0,getPolarisation());
1769  e.conj();
1770 
1771  complex<double> sfm;
1772  double scale = (p(2,evt)+p(3,evt)).M2() - 4.*mRes(fsPS[3],evt)*mRes(fsPS[3],evt);
1773  //double scale = (p(2,evt)+p(3,evt)).M2() - 4.35*mRes(fsPS[3],evt)*mRes(fsPS[3],evt); ??
1774 
1775  if(is3bodyDecay()){
1776  complex<double> tmp(qB.Dot(e.Re())*scale,qB.Dot(e.Im())*scale);
1777  sfm=tmp/(GeV*GeV*GeV);
1778  //compley<double> tmp(scale,0.);
1779  //sfm=tmp/(GeV*GeV);
1780  //sfm=tmp*scale/(GeV*GeV)
1781  }
1782  else{
1783  //ZTspin1 ZA(qA,pA,MA);
1784  ZTspin1 ZV(qV,pV,MV);
1785  SpinSumV PA(pA,MA);
1786  ZTspin1 ZB(qB,pB,pB.M());
1787 
1788  if(getPolarisation()==0)sfm=complex<double>(LeviCivita(e.Re(),PA.Dot(ZB),ZV,pB),0.);
1789  else sfm=complex<double>(LeviCivita(e.Re(),PA.Dot(ZB),ZV,pA),LeviCivita(e.Im(),PA.Dot(ZB),ZV,pA));
1790  //if(getPolarisation()==0)sfm=complex<double>(LeviCivita(e.Re(),ZA,ZV,pB),0.);
1791  //else sfm=complex<double>(LeviCivita(e.Re(),ZA,ZV,pA),LeviCivita(e.Im(),ZA,ZV,pA));
1792  sfm=sfm/(GeV*GeV*GeV);
1793  }
1794  return sfm;
1795 }
1797  // bool debugThis = false;
1798 
1799  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
1800  os << "spin factor SF_BtoAP1_AtoVV0_VtoP2P3"
1801  << "\n\t parsed tree " << theDecay().oneLiner()
1802  << "\n like this:" << endl;
1803  this->printParsing(os);
1804 }
1805 
1806 
1807 
1808 //==================================================================
1809 // SF 17
1811  bool debugThis=false;
1812 
1813  if(fsPS.size() < 4) fsPS.reserve(4);
1814  for(int i=0; i< theDecay(pat).nDgtr(); i++){
1815  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
1816  if(dgtr->getVal().SVPAT() == "V" && (dgtr->getDgtrTreePtr(0)->getVal().SVPAT() == "V" ||dgtr->getDgtrTreePtr(1)->getVal().SVPAT() == "V" )) V1 = dgtr;
1817  else if(dgtr->getVal().SVPAT() == "V" && dgtr->getDgtrTreePtr(0)->getVal().SVPAT() == "P" && dgtr->getDgtrTreePtr(1)->getVal().SVPAT() == "P" ) V2 = dgtr;
1818  }
1819  if(0==V1 || 0==V2){
1820  cout << "ERROR in SF_BtoV1V2_V1toP1V0_V2toP2P3::parseTree"
1821  << " Didn't find V1 or V2 " << V1.get() << ", " << V2.get() << endl;
1822  return false;
1823  }
1824 
1825  if(V1->nDgtr() != 2){
1826  cout << "ERROR in SF_BtoV1V2_V1toP1V0_V2toP2P3::parseTree"
1827  << " V1 should have 2 daughters, but it says it has "
1828  << V1->nDgtr() << "."
1829  << endl;
1830  return false;
1831  }
1832  if(V2->nDgtr() != 2){
1833  cout << "ERROR in SF_BtoV1V2_V1toP1V0_V2toP2P3::parseTree"
1834  << " V2 should have 2 daughters, but it says it has "
1835  << V2->nDgtr() << "."
1836  << endl;
1837  return false;
1838  }
1839 
1840  for(int i=0; i< V1->nDgtr(); i++){
1841  const_counted_ptr<AssociatedDecayTree> dgtr= V1->getDgtrTreePtr(i);
1842  if(dgtr->getVal().SVPAT() == "V") fsPS[0] = dgtr;
1843  else if(dgtr->getVal().SVPAT() == "P") fsPS[1] = dgtr;
1844  }
1845 
1846  if(0==fsPS[0] || 0==fsPS[1]){
1847  cout << "ERROR in SF_BtoV1V2_V1toP1V0_V2toP2P3::parseTree"
1848  << " Didn't find V0 or P1 " << fsPS[0].get() << ", " << fsPS[1].get() << endl;
1849  return false;
1850  }
1851  fsPS[2] = V2->getDgtrTreePtr(0);
1852  fsPS[3] = V2->getDgtrTreePtr(1);
1854 
1855  if(debugThis){
1856  cout << "parsed Tree: V1:\n"
1857  << *V1
1858  << "\n A:"
1859  << *V2
1860  << endl;
1861  for(int i=0; i<4; i++){
1862  cout << "fsPS[" << i << "]\n"
1863  << *(fsPS[i])
1864  << endl;
1865  }
1866  }
1867  // this->printYourself();
1868  return true;
1869 }
1870 
1872  if(0==_exampleDecay){
1873  // B->Z(4430) K*; Z->J/psi pi; K*->K pi
1874  _exampleDecay = new DecayTree(521);
1875  DecayTree Ks(313);
1876  Ks.addDgtr(321,-211);
1877  DecayTree Z(9993);
1878  Z.addDgtr(443,211);
1879  _exampleDecay->addDgtr(&Z);
1880  _exampleDecay->addDgtr(&Ks);
1881  }
1882  return *_exampleDecay;
1883 }
1884 
1886  return getExampleDecay();
1887 }
1888 
1890  //bool debugThis = false;
1891 
1892  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
1893 
1894  double MV1 = mRes(V1, evt);
1895  double MV2 = mRes(V2, evt);
1896  double MV0 = mRes(fsPS[0], evt); // ??
1897  //double MV0 = p(0, evt).M(); // ??
1898 
1899  TLorentzVector pV2= p(2, evt)+p(3, evt);
1900  TLorentzVector qV2= p(2, evt)-p(3, evt);
1901  TLorentzVector pV1= p(1, evt)+p(0, evt);
1902  TLorentzVector qV1= p(1, evt)-p(0, evt);
1903  //TLorentzVector pB= pV1+pV2;
1904 
1905  ZTspin1 ZV1(qV1,pV1,MV1);
1906  ZTspin1 ZV2(qV2,pV2,MV2);
1907  SpinSumV PV1(pV1,MV1);
1908 
1909  polVector e = polVector(p(0, evt),MV0,getPolarisation());
1910  e.conj();
1911 
1912  TLorentzVector tmp= PV1.Dot(ZV2);
1913  //complex<double> sfm;
1914  //if(getPolarisation()==0)sfm=complex<double>(LeviCivita(e.Re(),tmp,qV1,pB),0.);
1915  //else sfm=complex<double>(LeviCivita(e.Re(),tmp,qV1,pB),LeviCivita(e.Im(),tmp,qV1,pB));
1916 
1917  complex<double> sfm;
1918  if(getPolarisation()==0)sfm=complex<double>(LeviCivita(tmp,ZV1,pV1,PV1.Dot(e.Re())),0.);
1919  else sfm=complex<double>(LeviCivita(tmp,ZV1,pV1,PV1.Dot(e.Re())),LeviCivita(tmp,ZV1,pV1,PV1.Dot(e.Im())));
1920  return sfm/(GeV*GeV*GeV);
1921 }
1923  // bool debugThis = false;
1924 
1925  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
1926  os << "spin factor SF_BtoV1V2_V1toP1V0_V2toP2P3"
1927  << "\n\t parsed tree " << theDecay().oneLiner()
1928  << "\n like this:" << endl;
1929  this->printParsing(os);
1930 }
1931 
1932 
1933 
1934 //==================================================================
1935 // SF 18
1937  bool debugThis=false;
1938 
1939  if(fsPS.size() < 4) fsPS.reserve(4);
1940  for(int i=0; i< theDecay(pat).nDgtr(); i++){
1941  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
1942  if(dgtr->getVal().SVPAT() == "A") A = dgtr;
1943  else if(dgtr->getVal().SVPAT() == "V") V = dgtr;
1944  }
1945  if(0==A || 0==V){
1946  cout << "ERROR in SF_BtoAV_AtoP1V0_VtoP2P3::parseTree"
1947  << " Didn't find A or V " << A.get() << ", " << V.get() << endl;
1948  return false;
1949  }
1950 
1951  if(V->nDgtr() != 2){
1952  cout << "ERROR in SF_BtoAV_AtoP1V0_VtoP2P3::parseTree"
1953  << " V should have 2 daughters, but it says it has "
1954  << V->nDgtr() << "."
1955  << endl;
1956  return false;
1957  }
1958  if(A->nDgtr() != 2){
1959  cout << "ERROR in SF_BtoAV_AtoP1V0_VtoP2P3::parseTree"
1960  << " A should have 2 daughters, but it says it has "
1961  << A->nDgtr() << "."
1962  << endl;
1963  return false;
1964  }
1965 
1966  for(int i=0; i< A->nDgtr(); i++){
1967  const_counted_ptr<AssociatedDecayTree> dgtr= A->getDgtrTreePtr(i);
1968  if(dgtr->getVal().SVPAT() == "V") fsPS[0] = dgtr;
1969  else if(dgtr->getVal().SVPAT() == "P") fsPS[1] = dgtr;
1970  }
1971 
1972  if(0==fsPS[0] || 0==fsPS[1]){
1973  cout << "ERROR in SF_BtoAV_AtoP1V0_VtoP2P3::parseTree"
1974  << " Didn't find V0 or P1 " << fsPS[0].get() << ", " << fsPS[1].get() << endl;
1975  return false;
1976  }
1977  fsPS[2] = V->getDgtrTreePtr(0);
1978  fsPS[3] = V->getDgtrTreePtr(1);
1980 
1981  if(debugThis){
1982  cout << "parsed Tree: V:\n"
1983  << *V
1984  << "\n A:"
1985  << *A
1986  << endl;
1987  for(int i=0; i<4; i++){
1988  cout << "fsPS[" << i << "]\n"
1989  << *(fsPS[i])
1990  << endl;
1991  }
1992  }
1993  // this->printYourself();
1994  return true;
1995 }
1996 
1997 
1999  if(0==_exampleDecay){
2000  // B->Z(4430) K*; Z->J/psi pi; K*->K pi
2001  _exampleDecay = new DecayTree(521);
2002  DecayTree Ks(313);
2003  Ks.addDgtr(321,-211);
2004  DecayTree Z(9983);
2005  Z.addDgtr(443,211);
2006  _exampleDecay->addDgtr(&Ks);
2007  _exampleDecay->addDgtr(&Z);
2008  }
2009  return *_exampleDecay;
2010 }
2011 
2013  return getExampleDecay();
2014 }
2015 
2017  //bool debugThis = false;
2018 
2019  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
2020 
2021  double MA = mRes(A, evt);
2022  double MV = mRes(V, evt);
2023  double MV0 = mRes(fsPS[0], evt); // ??
2024  //double MV0 = p(0, evt).M(); // ??
2025 
2026  TLorentzVector pV= p(2, evt)+p(3, evt);
2027  TLorentzVector qV= p(2, evt)-p(3, evt);
2028  TLorentzVector pA= p(0, evt)+p(1, evt);
2029 
2030  ZTspin1 Z(qV,pV,MV);
2031  SpinSumV P(pA,MA);
2032 
2033  polVector e = polVector(p(0, evt),MV0,getPolarisation());
2034  e.conj();
2035 
2036  complex<double> sfm(P.Sandwich(e.Re(),Z),P.Sandwich(e.Im(),Z));
2037 
2038  return sfm/GeV;
2039 }
2041  // bool debugThis = false;
2042 
2043  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
2044  os << "spin factor SF_BtoAV_AtoP1V0_VtoP2P3"
2045  << "\n\t parsed tree " << theDecay().oneLiner()
2046  << "\n like this:" << endl;
2047  this->printParsing(os);
2048 }
2049 
2051  if(0==_exampleDecayP){
2052  // B->Z(4430) K*; Z->J/psi pi; K*->K pi
2053  _exampleDecayP = new DecayTree(521);
2054  DecayTree Ks(313);
2055  Ks.addDgtr(321,-211);
2056  DecayTree Z(9983);
2057  Z.addDgtr(443,211);
2058  _exampleDecayP->addDgtr(&Ks);
2059  _exampleDecayP->addDgtr(&Z);
2060  _exampleDecayP->getVal().setL(1);
2061 
2062  }
2063  return *_exampleDecayP;
2064 }
2065 
2067  return getExampleDecay();
2068 }
2069 
2071  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
2072 
2073  double MA = mRes(A, evt);
2074  double MV = mRes(V, evt);
2075  double MV0 = mRes(fsPS[0], evt);
2076 
2077  TLorentzVector pV= p(2, evt)+p(3, evt);
2078  TLorentzVector qV= p(2, evt)-p(3, evt);
2079  TLorentzVector pA= p(0, evt)+p(1, evt);
2080  TLorentzVector pB= pA+pV;
2081  TLorentzVector qB= pA-pV;
2082 
2083  ZTspin1 LB(qB,pB,pB.M());
2084  ZTspin1 LV(qV,pV,MV);
2085  SpinSumV PA(pA,MA);
2086 
2087  polVector e = polVector(p(0, evt),MV0,getPolarisation());
2088  e.conj();
2089 
2090  complex<double> sfm(LeviCivita(LB,pB,LV,PA.Dot(e.Re())),LeviCivita(LB,pB,LV,PA.Dot(e.Im())));
2091 
2092  return sfm/(GeV*GeV*GeV);
2093 }
2095  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
2096  os << "spin factor SF_BtoAV_AtoP1V0_VtoP2P3_P"
2097  << "\n\t parsed tree " << theDecay().oneLiner()
2098  << "\n like this:" << endl;
2099  this->printParsing(os);
2100 }
2101 
2103  if(0==_exampleDecayD){
2104  // B->Z(4430) K*; Z->J/psi pi; K*->K pi
2105  _exampleDecayD = new DecayTree(521);
2106  DecayTree Ks(313);
2107  Ks.addDgtr(321,-211);
2108  DecayTree Z(9983);
2109  Z.addDgtr(443,211);
2110  _exampleDecayD->addDgtr(&Ks);
2111  _exampleDecayD->addDgtr(&Z);
2112  _exampleDecayD->getVal().setL(2);
2113 
2114  }
2115  return *_exampleDecayD;
2116 }
2117 
2119  return getExampleDecay();
2120 }
2121 
2123  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
2124 
2125  double MA = mRes(A, evt);
2126  double MV = mRes(V, evt);
2127  double MV0 = mRes(fsPS[0], evt);
2128 
2129  TLorentzVector pV= p(2, evt)+p(3, evt);
2130  TLorentzVector qV= p(2, evt)-p(3, evt);
2131  TLorentzVector pA= p(0, evt)+p(1, evt);
2132  TLorentzVector pB= pA+pV;
2133  TLorentzVector qB= pA-pV;
2134 
2135  SpinSumV PB(pB,pB.M());
2136  ZTspin1 LB(qB,pB,pB.M());
2137  ZTspin1 LV(qV,pV,MV);
2138  SpinSumV PA(pA,MA);
2139 
2140  polVector e = polVector(p(0, evt),MV0,getPolarisation());
2141  e.conj();
2142 
2143  complex<double> sfm(LB.Dot(PA.Dot(e.Re())) * LB.Dot(LV) + 1./3. * LB.Dot(LB) * PB.Dot(e.Re())*LV,
2144  LB.Dot(PA.Dot(e.Im())) * LB.Dot(LV) + 1./3. * LB.Dot(LB) * PB.Dot(e.Im())*LV);
2145 
2146  return sfm/(GeV*GeV*GeV);
2147 }
2149  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
2150  os << "spin factor SF_BtoAV_AtoP1V0_VtoP2P3_D"
2151  << "\n\t parsed tree " << theDecay().oneLiner()
2152  << "\n like this:" << endl;
2153  this->printParsing(os);
2154 }
2155 
2156 
2157 //==================================================================
2158 // SF 19
2160  bool debugThis=false;
2161 
2162  if(fsPS.size() < 4) fsPS.reserve(4);
2163  for(int i=0; i< theDecay(pat).nDgtr(); i++){
2164  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
2165  if(dgtr->getVal().SVPAT() == "A") A = dgtr;
2166  else if(dgtr->getVal().SVPAT() == "S") S = dgtr;
2167  }
2168  if(0==A || 0==S){
2169  cout << "ERROR in SF_BtoAS_AtoP1V0_StoP2P3::parseTree"
2170  << " Didn't find A or S " << A.get() << ", " << S.get() << endl;
2171  return false;
2172  }
2173 
2174  if(A->nDgtr() != 2){
2175  cout << "ERROR in SF_BtoAS_AtoP1V0_StoP2P3::parseTree"
2176  << " A should have 2 daughters, but it says it has "
2177  << A->nDgtr() << "."
2178  << endl;
2179  return false;
2180  }
2181  if(S->nDgtr() != 2){
2182  cout << "ERROR in SF_BtoAS_AtoP1V0_StoP2P3::parseTree"
2183  << " S should have 2 daughters, but it says it has "
2184  << S->nDgtr() << "."
2185  << endl;
2186  return false;
2187  }
2188 
2189  for(int i=0; i< A->nDgtr(); i++){
2190  const_counted_ptr<AssociatedDecayTree> dgtr= A->getDgtrTreePtr(i);
2191  if(dgtr->getVal().SVPAT() == "V") fsPS[0] = dgtr;
2192  else if(dgtr->getVal().SVPAT() == "P") fsPS[1] = dgtr;
2193  }
2194 
2195  if(0==fsPS[0] || 0==fsPS[1]){
2196  cout << "ERROR in SF_BtoAS_AtoP1V0_StoP2P3::parseTree"
2197  << " Didn't find V0 or P1 " << fsPS[0].get() << ", " << fsPS[1].get() << endl;
2198  return false;
2199  }
2200  fsPS[2] = S->getDgtrTreePtr(0);
2201  fsPS[3] = S->getDgtrTreePtr(1);
2203 
2204  if(debugThis){
2205  cout << "parsed Tree: A:\n"
2206  << *A
2207  << "\n S:"
2208  << *S
2209  << endl;
2210  for(int i=0; i<4; i++){
2211  cout << "fsPS[" << i << "]\n"
2212  << *(fsPS[i])
2213  << endl;
2214  }
2215  }
2216  // this->printYourself();
2217  return true;
2218 }
2219 
2220 
2222  if(0==_exampleDecay){
2223  // B->Z(4430) (K pi)_S
2224  _exampleDecay = new DecayTree(521);
2225  DecayTree K(9981);
2226  K.addDgtr(321,-211);
2227  DecayTree Z(9983);
2228  Z.addDgtr(443,211);
2229  _exampleDecay->addDgtr(&K);
2230  _exampleDecay->addDgtr(&Z);
2231  }
2232  return *_exampleDecay;
2233 }
2234 
2236  return getExampleDecay();
2237 }
2238 
2240  //bool debugThis = false;
2241 
2242  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
2243 
2244  double MA = mRes(A, evt);
2245  double MV0 = mRes(fsPS[0], evt); // ??
2246  //double MV0 = p(0, evt).M(); // ??
2247  TLorentzVector pA= p(0, evt)+p(1, evt);
2248  TLorentzVector qA= p(1, evt)-p(0, evt);
2249  ZTspin1 Z(qA,pA,MA);
2250 
2251  polVector e = polVector(p(0, evt),MV0,getPolarisation());
2252  e.conj();
2253 
2254  complex<double> sfm(Z.Dot(e.Re()),Z.Dot(e.Im()));
2255 
2256  return sfm/GeV;
2257 }
2259  // bool debugThis = false;
2260 
2261  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
2262  os << "spin factor SF_BtoAS_AtoP1V0_StoP2P3"
2263  << "\n\t parsed tree " << theDecay().oneLiner()
2264  << "\n like this:" << endl;
2265  this->printParsing(os);
2266 }
2267 
2268 
2269 //==================================================================
2270 // SF 20
2272  bool debugThis=false;
2273 
2274  if(fsPS.size() < 4) fsPS.reserve(4);
2275  for(int i=0; i< theDecay(pat).nDgtr(); i++){
2276  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
2277  if(dgtr->getVal().SVPAT() == "P") P = dgtr;
2278  else if(dgtr->getVal().SVPAT() == "S") S = dgtr;
2279  }
2280  if(0==P || 0==S){
2281  cout << "ERROR in SF_BtoPS_PtoP1V0_StoP2P3::parseTree"
2282  << " Didn't find P or S " << P.get() << ", " << S.get() << endl;
2283  return false;
2284  }
2285 
2286  if(P->nDgtr() != 2){
2287  cout << "ERROR in SF_BtoPS_PtoP1V0_StoP2P3::parseTree"
2288  << " P should have 2 daughters, but it says it has "
2289  << P->nDgtr() << "."
2290  << endl;
2291  return false;
2292  }
2293  if(S->nDgtr() != 2){
2294  cout << "ERROR in SF_BtoPS_PtoP1V0_StoP2P3::parseTree"
2295  << " S should have 2 daughters, but it says it has "
2296  << S->nDgtr() << "."
2297  << endl;
2298  return false;
2299  }
2300 
2301  for(int i=0; i< P->nDgtr(); i++){
2302  const_counted_ptr<AssociatedDecayTree> dgtr= P->getDgtrTreePtr(i);
2303  if(dgtr->getVal().SVPAT() == "V") fsPS[0] = dgtr;
2304  else if(dgtr->getVal().SVPAT() == "P") fsPS[1] = dgtr;
2305  }
2306 
2307  if(0==fsPS[0] || 0==fsPS[1]){
2308  cout << "ERROR in SF_BtoPS_PtoP1V0_StoP2P3::parseTree"
2309  << " Didn't find V0 or P1 " << fsPS[0].get() << ", " << fsPS[1].get() << endl;
2310  return false;
2311  }
2312  fsPS[2] = S->getDgtrTreePtr(0);
2313  fsPS[3] = S->getDgtrTreePtr(1);
2315 
2316  if(debugThis){
2317  cout << "parsed Tree: P:\n"
2318  << *P
2319  << "\n S:"
2320  << *S
2321  << endl;
2322  for(int i=0; i<4; i++){
2323  cout << "fsPS[" << i << "]\n"
2324  << *(fsPS[i])
2325  << endl;
2326  }
2327  }
2328  // this->printYourself();
2329  return true;
2330 }
2331 
2332 
2334  if(0==_exampleDecay){
2335  // B-> (J/psi pi)_P (K pi)_S
2336  _exampleDecay = new DecayTree(521);
2337  DecayTree S(9981);
2338  S.addDgtr(321,-211);
2339  DecayTree P(9991);
2340  P.addDgtr(443,221);
2341  _exampleDecay->addDgtr(&P);
2342  _exampleDecay->addDgtr(&S);
2343  }
2344  return *_exampleDecay;
2345 }
2346 
2348  return getExampleDecay();
2349 }
2350 
2352  //bool debugThis = false;
2353 
2354  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
2355 
2356  double M = mRes(P, evt);
2357  double MV0 = mRes(fsPS[0], evt); // ??
2358  //double MV0 = p(0, evt).M(); // ??
2359  TLorentzVector pP= p(0, evt)+p(1, evt);
2360  TLorentzVector qP= p(1, evt)-p(0, evt);
2361  ZTspin1 Z(qP,pP,M);
2362 
2363  polVector e = polVector(p(0, evt),MV0,getPolarisation());
2364  e.conj();
2365 
2366  complex<double> sfm(Z.Dot(e.Re()),Z.Dot(e.Im()));
2367 
2368  return sfm/GeV;
2369 }
2371  // bool debugThis = false;
2372 
2373  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
2374  os << "spin factor SF_BtoPS_PtoP1V0_StoP2P3"
2375  << "\n\t parsed tree " << theDecay().oneLiner()
2376  << "\n like this:" << endl;
2377  this->printParsing(os);
2378 }
2379 
2380 
2381 //==================================================================
2382 // SF 21
2384  bool debugThis=false;
2385 
2386  if(fsPS.size() < 4) fsPS.reserve(4);
2387  for(int i=0; i< theDecay(pat).nDgtr(); i++){
2388  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
2389  if(dgtr->getVal().SVPAT() == "P") P = dgtr;
2390  else if(dgtr->getVal().SVPAT() == "V") V = dgtr;
2391  }
2392  if(0==P || 0==V){
2393  cout << "ERROR in SF_BtoPV_PtoP1V0_VtoP2P3::parseTree"
2394  << " Didn't find P or S " << P.get() << ", " << V.get() << endl;
2395  return false;
2396  }
2397 
2398  if(P->nDgtr() != 2){
2399  cout << "ERROR in SF_BtoPV_PtoP1V0_VtoP2P3::parseTree"
2400  << " P should have 2 daughters, but it says it has "
2401  << P->nDgtr() << "."
2402  << endl;
2403  return false;
2404  }
2405  if(V->nDgtr() != 2){
2406  cout << "ERROR in SF_BtoPV_PtoP1V0_VtoP2P3::parseTree"
2407  << " V should have 2 daughters, but it says it has "
2408  << V->nDgtr() << "."
2409  << endl;
2410  return false;
2411  }
2412 
2413  for(int i=0; i< P->nDgtr(); i++){
2414  const_counted_ptr<AssociatedDecayTree> dgtr= P->getDgtrTreePtr(i);
2415  if(dgtr->getVal().SVPAT() == "V") fsPS[0] = dgtr;
2416  else if(dgtr->getVal().SVPAT() == "P") fsPS[1] = dgtr;
2417  }
2418 
2419  if(0==fsPS[0] || 0==fsPS[1]){
2420  cout << "ERROR in SF_BtoPV_PtoP1V0_VtoP2P3::parseTree"
2421  << " Didn't find V0 or P1 " << fsPS[0].get() << ", " << fsPS[1].get() << endl;
2422  return false;
2423  }
2424  fsPS[2] = V->getDgtrTreePtr(0);
2425  fsPS[3] = V->getDgtrTreePtr(1);
2427 
2428  if(debugThis){
2429  cout << "parsed Tree: P:\n"
2430  << *P
2431  << "\n V:"
2432  << *V
2433  << endl;
2434  for(int i=0; i<4; i++){
2435  cout << "fsPS[" << i << "]\n"
2436  << *(fsPS[i])
2437  << endl;
2438  }
2439  }
2440  // this->printYourself();
2441  return true;
2442 }
2443 
2444 
2446  if(0==_exampleDecay){
2447  // B-> Z(4239) K*
2448  _exampleDecay = new DecayTree(521);
2449  DecayTree V(313);
2450  V.addDgtr(321,-211);
2451  DecayTree P(9999996);
2452  P.addDgtr(443,221);
2453  _exampleDecay->addDgtr(&P);
2454  _exampleDecay->addDgtr(&V);
2455  }
2456  return *_exampleDecay;
2457 }
2458 
2460  return getExampleDecay();
2461 }
2462 
2464  //bool debugThis = false;
2465 
2466  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
2467 
2468  double MP = mRes(P, evt);
2469  double MV = mRes(V, evt);
2470  double MV0 = mRes(fsPS[0], evt); // ??
2471  //double MV0 = p(0, evt).M(); // ??
2472  TLorentzVector pP= p(1, evt)+p(0, evt);
2473  TLorentzVector qP= p(1, evt)-p(0, evt);
2474  TLorentzVector pV= p(2, evt)+p(3, evt);
2475  TLorentzVector qV= p(2, evt)-p(3, evt);
2476  TLorentzVector pB= pP+pV;
2477  TLorentzVector qB= pP-pV;
2478 
2479  ZTspin1 ZB(qB,pB,pB.M());
2480  ZTspin1 ZV(qV,pV,MV);
2481  ZTspin1 ZP(qP,pP,MP);
2482 
2483  polVector e = polVector(p(0, evt),MV0,getPolarisation());
2484  e.conj();
2485 
2486  double tmp= ZB.Dot(ZV);
2487  complex<double> sf(ZP.Dot(e.Re()),ZP.Dot(e.Im()));
2488  return sf*tmp/(GeV*GeV*GeV);
2489 
2490  //complex<double> sfm(pP.Dot(e.Re()),pP.Dot(e.Im()));
2491  //return sfm*ZV.Dot(qB)/(GeV*GeV*GeV);
2492 }
2494  // bool debugThis = false;
2495 
2496  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
2497  os << "spin factor SF_BtoPV_PtoP1V0_VtoP2P3"
2498  << "\n\t parsed tree " << theDecay().oneLiner()
2499  << "\n like this:" << endl;
2500  this->printParsing(os);
2501 }
2502 
2503 
2504 
2505 //==================================================================
2506 // SF 22
2508  bool debugThis=false;
2509 
2510  if(fsPS.size() < 4) fsPS.reserve(4);
2511  for(int i=0; i< theDecay(pat).nDgtr(); i++){
2512  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
2513  if(dgtr->getVal().SVPAT() == "P") P = dgtr;
2514  else if(dgtr->getVal().SVPAT() == "V") fsPS[0] = dgtr;;
2515  }
2516  if(0==P || 0==fsPS[0]){
2517  cout << "ERROR in SF_BtoPV0_PtoS_StoP2P3::parseTree"
2518  << " Didn't find P or V0 " << P.get() << ", " << fsPS[0].get() << endl;
2519  return false;
2520  }
2521 
2522 
2523  if(P->nDgtr() != 2){
2524  cout << "ERROR in SF_BtoPV0_PtoS_StoP2P3::parseTree"
2525  << " P should have 2 daughters, but it says it has "
2526  << P->nDgtr() << "."
2527  << endl;
2528  return false;
2529  }
2530 
2531  for(int i=0; i< P->nDgtr(); i++){
2532  const_counted_ptr<AssociatedDecayTree> dgtr= P->getDgtrTreePtr(i);
2533  if(dgtr->getVal().SVPAT() == "S") S = dgtr;
2534  else if(dgtr->getVal().SVPAT() == "P") fsPS[1] = dgtr;
2535  }
2536 
2537  if(S->nDgtr() != 2){
2538  cout << "ERROR in SF_BtoPV0_PtoS_StoP2P3::parseTree"
2539  << " S should have 2 daughters, but it says it has "
2540  << S->nDgtr() << "."
2541  << endl;
2542  return false;
2543  }
2544 
2545  fsPS[2] = S->getDgtrTreePtr(0);
2546  fsPS[3] = S->getDgtrTreePtr(1);
2548 
2549  if(debugThis){
2550  cout << "parsed Tree: P:\n"
2551  << *P
2552  << "\n S:"
2553  << *S
2554  << endl;
2555  for(int i=0; i<4; i++){
2556  cout << "fsPS[" << i << "]\n"
2557  << *(fsPS[i])
2558  << endl;
2559  }
2560  }
2561  // this->printYourself();
2562  return true;
2563 }
2564 
2565 
2567  if(0==_exampleDecay){
2568  // B->J/psi (K pi pi)_S
2569  _exampleDecay = new DecayTree(521);
2570  _exampleDecay->addDgtr(443, 9991)->addDgtr(321,9981)->addDgtr(211,-211);
2571  }
2572  return *_exampleDecay;
2573 }
2574 
2576  return getExampleDecay();
2577 }
2578 
2580  //bool debugThis = false;
2581 
2582  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
2583 
2584  double MV0 = mRes(fsPS[0], evt); // ??
2585  //double MV0 = p(0, evt).M(); // ??
2586  TLorentzVector pP= p(1, evt)+p(2, evt)+p(3,evt);
2587  TLorentzVector pB=pP+p(0,evt);
2588  TLorentzVector qB=pP-p(0,evt);
2589 
2590  polVector e = polVector(p(0, evt),MV0,getPolarisation());
2591  e.conj();
2592 
2593 // complex<double> sfm(pP.Dot(e.Re()),pP.Dot(e.Im()));
2594 // SpinSumV P(pP,pP.M());
2595  ZTspin1 ZB(qB,pB,pB.M());
2596 
2597  complex<double> sfm(ZB.Dot(e.Re()),ZB.Dot(e.Im()));
2598  return sfm/(GeV);
2599 }
2601  // bool debugThis = false;
2602 
2603  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
2604  os << "spin factor SF_BtoPV0_PtoS_StoP2P3"
2605  << "\n\t parsed tree " << theDecay().oneLiner()
2606  << "\n like this:" << endl;
2607  this->printParsing(os);
2608 }
2609 
2610 //
2611 
2612 //==================================================================
2613 // SF 23
2614 
2616  bool debugThis=false;
2617 
2618  if(fsPS.size() < 4) fsPS.reserve(4);
2619  for(int i=0; i< theDecay(pat).nDgtr(); i++){
2620  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
2621  if(dgtr->getVal().SVPAT() == "V") V = dgtr;
2622  else if(dgtr->getVal().SVPAT() == "P") fsPS[1] = dgtr;
2623  }
2624  if(0==V || 0==fsPS[1]){
2625  cout << "ERROR in SF_BtoVP1_VtoAP2_AtoV0P3::parseTree"
2626  << " Didn't find V or P1 " << V.get() << ", " << fsPS[1].get() << endl;
2627  return false;
2628  }
2629 
2630  for(int i=0; i< V->nDgtr(); i++){
2631  const_counted_ptr<AssociatedDecayTree> dgtr= V->getDgtrTreePtr(i);
2632  if(dgtr->getVal().SVPAT() == "A") A = dgtr;
2633  else if(dgtr->getVal().SVPAT() == "P") fsPS[2] = dgtr;
2634  }
2635  if(0==A || 0==fsPS[2]){
2636  cout << "ERROR in SF_BtoVP1_VtoAP2_AtoV0P3::parseTree"
2637  << " Didn't find A or P2 " << A.get() << ", " << fsPS[2].get() << endl;
2638  return false;
2639  }
2640 
2641  if(A->nDgtr() != 2){
2642  cout << "ERROR in SF_BtoVP1_VtoAP2_AtoV0P3::parseTree"
2643  << " A should have 2 daughters, but it says it has "
2644  << A->nDgtr() << "."
2645  << endl;
2646  return false;
2647  }
2648 
2649  for(int i=0; i< A->nDgtr(); i++){
2650  const_counted_ptr<AssociatedDecayTree> dgtr= A->getDgtrTreePtr(i);
2651  if(dgtr->getVal().SVPAT() == "V") fsPS[0] = dgtr;
2652  else if(dgtr->getVal().SVPAT() == "P") fsPS[3] = dgtr;
2653  }
2654 
2655  if(debugThis){
2656  cout << "parsed Tree: V:\n"
2657  << *V
2658  << "\n A:"
2659  << *A
2660  << endl;
2661  for(int i=0; i<4; i++){
2662  cout << "fsPS[" << i << "]\n"
2663  << *(fsPS[i])
2664  << endl;
2665  }
2666  }
2667  // this->printYourself();
2668  return true;
2669 }
2670 
2672  if(0==_exampleDecay){
2673  // B->K X(4260); X->Z pi; Z->J/psi pi
2674  _exampleDecay = new DecayTree(521);
2675  _exampleDecay->addDgtr(321, 9999992)->addDgtr(211, 9999993)->addDgtr(443,-211);
2676  }
2677  return *_exampleDecay;
2678 }
2679 
2681  return getExampleDecay();
2682 }
2683 
2685  //bool debugThis = false;
2686 
2687  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
2688 
2689  double MA = mRes(A, evt);
2690  double MV = mRes(V, evt);
2691  double MV0 = mRes(fsPS[0], evt); // ??
2692  //double MV0 = p(0, evt).M(); // ??
2693 
2694  TLorentzVector pA= p(0,evt)+p(3, evt);
2695  //TLorentzVector qA= p(0,evt)-p(3, evt);
2696  TLorentzVector pV= pA+p(2, evt);
2697  //TLorentzVector qV= pA-p(2, evt);
2698  TLorentzVector pB= pV+p(1, evt);
2699  TLorentzVector qB= pV-p(1, evt);
2700 
2701  ZTspin1 ZB(qB,pB,pB.M());
2702  SpinSumV PA(pA,MA);
2703  SpinSumV PV(pV,MV);
2704 
2705  polVector e = polVector(p(0, evt),MV0,getPolarisation());
2706  e.conj();
2707 
2708  complex<double> sfm(PV.Sandwich(PA.Dot(e.Re()),ZB),PV.Sandwich(PA.Dot(e.Im()),ZB));
2709 
2710  return sfm/GeV;
2711 }
2713  // bool debugThis = false;
2714 
2715  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
2716  os << "spin factor SF_BtoVP1_VtoAP2_AtoV0P3"
2717  << "\n\t parsed tree " << theDecay().oneLiner()
2718  << "\n like this:" << endl;
2719  this->printParsing(os);
2720 }
2721 
2722 
2723 //==================================================================
2724 // SF 24
2725 
2727  bool debugThis=false;
2728 
2729  if(fsPS.size() < 4) fsPS.reserve(4);
2730  for(int i=0; i< theDecay(pat).nDgtr(); i++){
2731  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
2732  if(dgtr->getVal().SVPAT() == "V") V = dgtr;
2733  else if(dgtr->getVal().SVPAT() == "P") fsPS[1] = dgtr;
2734  }
2735  if(0==V || 0==fsPS[1]){
2736  cout << "ERROR in SF_BtoVP1_VtoSV0_StoP2P3::parseTree"
2737  << " Didn't find V or P1 " << V.get() << ", " << fsPS[1].get() << endl;
2738  return false;
2739  }
2740 
2741  for(int i=0; i< V->nDgtr(); i++){
2742  const_counted_ptr<AssociatedDecayTree> dgtr= V->getDgtrTreePtr(i);
2743  if(dgtr->getVal().SVPAT() == "S") S = dgtr;
2744  else if(dgtr->getVal().SVPAT() == "V") fsPS[0] = dgtr;
2745  }
2746  if(0==S || 0==fsPS[0]){
2747  cout << "ERROR in SF_BtoVP1_VtoSV0_StoP2P3::parseTree"
2748  << " Didn't find S or V0 " << S.get() << ", " << fsPS[0].get() << endl;
2749  return false;
2750  }
2751 
2752  if(S->nDgtr() != 2){
2753  cout << "ERROR in SF_BtoVP1_VtoSV0_StoP2P3::parseTree"
2754  << " S should have 2 daughters, but it says it has "
2755  << S->nDgtr() << "."
2756  << endl;
2757  return false;
2758  }
2759 
2760  fsPS[2] = S->getDgtrTreePtr(0);
2761  fsPS[3] = S->getDgtrTreePtr(1);
2762 
2763  if(debugThis){
2764  cout << "parsed Tree: V:\n"
2765  << *V
2766  << "\n S:"
2767  << *S
2768  << endl;
2769  for(int i=0; i<4; i++){
2770  cout << "fsPS[" << i << "]\n"
2771  << *(fsPS[i])
2772  << endl;
2773  }
2774  }
2775  // this->printYourself();
2776  return true;
2777 }
2778 
2780  if(0==_exampleDecay){
2781  // B->K X(4260); X->f0 J/psi; f0->pi pi
2782  _exampleDecay = new DecayTree(521);
2783  _exampleDecay->addDgtr(321, 9999992)->addDgtr(443, 9010221)->addDgtr(211,-211);
2784  }
2785  return *_exampleDecay;
2786 }
2787 
2789  return getExampleDecay();
2790 }
2791 
2793  //bool debugThis = false;
2794 
2795  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
2796 
2797  double MV = mRes(V, evt);
2798  double MV0 = mRes(fsPS[0], evt); // ??
2799  //double MV0 = p(0, evt).M(); // ??
2800 
2801 
2802  TLorentzVector pV= p(0,evt)+p(2,evt)+p(3, evt);
2803  //TLorentzVector qV= pA-p(2, evt);
2804  TLorentzVector pB= pV+p(1, evt);
2805  TLorentzVector qB= pV-p(1, evt);
2806 
2807  ZTspin1 ZB(qB,pB,pB.M());
2808  SpinSumV PV(pV,MV);
2809 
2810  polVector e = polVector(p(0, evt),MV0,getPolarisation());
2811  e.conj();
2812 
2813  complex<double> sfm(PV.Sandwich(e.Re(),ZB),PV.Sandwich(e.Im(),ZB));
2814 
2815  return sfm/GeV;
2816 }
2818  // bool debugThis = false;
2819 
2820  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
2821  os << "spin factor SF_BtoVP1_VtoSV0_StoP2P3"
2822  << "\n\t parsed tree " << theDecay().oneLiner()
2823  << "\n like this:" << endl;
2824  this->printParsing(os);
2825 }
2826 
2827 
2828 
2829 
2830 //==================================================================
2831 // SF 25
2833  bool debugThis=false;
2834 
2835  if(fsPS.size() < 4) fsPS.reserve(4);
2836  for(int i=0; i< theDecay(pat).nDgtr(); i++){
2837  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
2838  if(dgtr->getVal().SVPAT() == "P") P = dgtr;
2839  else if(dgtr->getVal().SVPAT() == "V") fsPS[0] = dgtr;;
2840  }
2841  if(0==P || 0==fsPS[0]){
2842  cout << "ERROR in SF_BtoPV0_PtoP1V1_V1toP2P3::parseTree"
2843  << " Didn't find P or V0 " << P.get() << ", " << fsPS[0].get() << endl;
2844  return false;
2845  }
2846 
2847 
2848  if(P->nDgtr() != 2){
2849  cout << "ERROR in SF_BtoPV0_PtoP1V1_V1toP2P3::parseTree"
2850  << " P should have 2 daughters, but it says it has "
2851  << P->nDgtr() << "."
2852  << endl;
2853  return false;
2854  }
2855 
2856  for(int i=0; i< P->nDgtr(); i++){
2857  const_counted_ptr<AssociatedDecayTree> dgtr= P->getDgtrTreePtr(i);
2858  if(dgtr->getVal().SVPAT() == "V") V = dgtr;
2859  else if(dgtr->getVal().SVPAT() == "P") fsPS[1] = dgtr;
2860  }
2861 
2862  if(V->nDgtr() != 2){
2863  cout << "ERROR in SF_BtoPV0_PtoP1V1_V1toP2P3::parseTree"
2864  << " V should have 2 daughters, but it says it has "
2865  << V->nDgtr() << "."
2866  << endl;
2867  return false;
2868  }
2869 
2870  fsPS[2] = V->getDgtrTreePtr(0);
2871  fsPS[3] = V->getDgtrTreePtr(1);
2873 
2874  if(debugThis){
2875  cout << "parsed Tree: P:\n"
2876  << *P
2877  << "\n V:"
2878  << *V
2879  << endl;
2880  for(int i=0; i<4; i++){
2881  cout << "fsPS[" << i << "]\n"
2882  << *(fsPS[i])
2883  << endl;
2884  }
2885  }
2886  // this->printYourself();
2887  return true;
2888 }
2889 
2890 
2892  if(0==_exampleDecay){
2893  // B->J/psi (K(1460)-> K rho)
2894  _exampleDecay = new DecayTree(521);
2895  _exampleDecay->addDgtr(443, 100321)->addDgtr(321,213)->addDgtr(211,-211);
2896  }
2897  return *_exampleDecay;
2898 }
2899 
2901  return getExampleDecay();
2902 }
2903 
2905  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
2906 
2907  double MV0 = mRes(fsPS[0], evt); // ??
2908  //double MV0 = p(0, evt).M(); // ??
2909  TLorentzVector pP= p(1, evt)+p(2, evt)+p(3,evt);
2910  TLorentzVector qP= p(1, evt)-p(2, evt)-p(3,evt);
2911  ZTspin1 ZP(qP,pP,pP.M());
2912 
2913  TLorentzVector pB=pP+p(0,evt);
2914  TLorentzVector qB=pP-p(0,evt);
2915  ZTspin1 ZB(qB,pB,pB.M());
2916 
2917  TLorentzVector pV= p(2, evt)+p(3,evt);
2918  TLorentzVector qV= p(2, evt)-p(3,evt);
2919  ZTspin1 ZV(qV,pV,pV.M());
2920 
2921  polVector e = polVector(p(0, evt),MV0,getPolarisation());
2922  e.conj();
2923 
2924  double tmp = ZP.Dot(ZV);
2925 
2926  complex<double> sfm(ZB.Dot(e.Re()),ZB.Dot(e.Im()));
2927  return sfm*tmp/(GeV*GeV*GeV);
2928 }
2930  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
2931  os << "spin factor SF_BtoPV0_PtoP1V1_V1toP2P3"
2932  << "\n\t parsed tree " << theDecay().oneLiner()
2933  << "\n like this:" << endl;
2934  this->printParsing(os);
2935 }
2936 
2937 //==================================================================
2938 
2940  bool debugThis=false;
2941 
2942  if(fsPS.size() < 4) fsPS.reserve(4);
2943  for(int i=0; i< theDecay(pat).nDgtr(); i++){
2944  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
2945  if(dgtr->getVal().SVPAT() == "S") S = dgtr;
2946  else if(dgtr->getVal().SVPAT() == "P") fsPS[1] = dgtr;;
2947  }
2948  if(0==S || 0==fsPS[1]){
2949  cout << "ERROR in SF_BtoSP1_StoVV0_VtoP2P3::parseTree"
2950  << " Didn't find S or P1 " << S.get() << ", " << fsPS[1].get() << endl;
2951  return false;
2952  }
2953 
2954  if(S->nDgtr() != 2){
2955  cout << "ERROR in SF_BtoSP1_StoVV0_VtoP2P3::parseTree"
2956  << " S should have 2 daughters, but it says it has "
2957  << S->nDgtr() << "."
2958  << endl;
2959  return false;
2960  }
2961 
2962  for(int i=0; i< S->nDgtr(); i++){
2963  const_counted_ptr<AssociatedDecayTree> dgtr= S->getDgtrTreePtr(i);
2964  if(dgtr->getVal().SVPAT() == "V" && (!dgtr->isFinalState()) ) V = dgtr;
2965  else if(dgtr->getVal().SVPAT() == "V" && dgtr->isFinalState()) fsPS[0] = dgtr;
2966  }
2967 
2968  if(V->nDgtr() != 2){
2969  cout << "ERROR in SF_BtoSP1_StoVV0_VtoP2P3::parseTree"
2970  << " V should have 2 daughters, but it says it has "
2971  << V->nDgtr() << "."
2972  << endl;
2973  return false;
2974  }
2975 
2976  fsPS[2] = V->getDgtrTreePtr(0);
2977  fsPS[3] = V->getDgtrTreePtr(1);
2979 
2980  if(debugThis){
2981  cout << "parsed Tree: S:\n"
2982  << *S
2983  << "\n V:"
2984  << *V
2985  << endl;
2986  for(int i=0; i<4; i++){
2987  cout << "fsPS[" << i << "]\n"
2988  << *(fsPS[i])
2989  << endl;
2990  }
2991  }
2992  // this->printYourself();
2993  return true;
2994 }
2995 
2997  if(0==_exampleDecay){
2998  // B->K (X->psi rho)
2999  _exampleDecay = new DecayTree(521);
3000  _exampleDecay->addDgtr(321, 9010221)->addDgtr(443,213)->addDgtr(211,-211);
3001  }
3002  return *_exampleDecay;
3003 }
3004 
3006  return getExampleDecay();
3007 }
3008 
3010  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
3011 
3012  double MV0 = mRes(fsPS[0], evt); // ??
3013  TLorentzVector pV= p(2, evt)+p(3,evt);
3014  TLorentzVector qV= p(2, evt)-p(3,evt);
3015  ZTspin1 LV(qV,pV,pV.M());
3016 
3017  polVector e = polVector(p(0, evt),MV0,getPolarisation());
3018  e.conj();
3019 
3020  complex<double> sfm(LV.Dot(e.Re()),LV.Dot(e.Im()));
3021  return sfm/(GeV);
3022 }
3024  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
3025  os << "spin factor SF_BtoSP1_StoVV0_VtoP2P3"
3026  << "\n\t parsed tree " << theDecay().oneLiner()
3027  << "\n like this:" << endl;
3028  this->printParsing(os);
3029 }
3030 
3031 //==================================================================
3032 
3034  bool debugThis=false;
3035 
3036  if(fsPS.size() < 4) fsPS.reserve(4);
3037  for(int i=0; i< theDecay(pat).nDgtr(); i++){
3038  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
3039  if(dgtr->getVal().SVPAT() == "P" && (!dgtr->isFinalState())) P = dgtr;
3040  else if(dgtr->getVal().SVPAT() == "P" && dgtr->isFinalState()) fsPS[1] = dgtr;;
3041  }
3042  if(0==P || 0==fsPS[1]){
3043  cout << "ERROR in SF_BtoPP1_PtoVV0_VtoP2P3::parseTree"
3044  << " Didn't find P or P1 " << P.get() << ", " << fsPS[1].get() << endl;
3045  return false;
3046  }
3047 
3048  if(P->nDgtr() != 2){
3049  cout << "ERROR in SF_BtoPP1_PtoVV0_VtoP2P3::parseTree"
3050  << " P should have 2 daughters, but it says it has "
3051  << P->nDgtr() << "."
3052  << endl;
3053  return false;
3054  }
3055 
3056  for(int i=0; i< P->nDgtr(); i++){
3057  const_counted_ptr<AssociatedDecayTree> dgtr= P->getDgtrTreePtr(i);
3058  if(dgtr->getVal().SVPAT() == "V" && (!dgtr->isFinalState()) ) V = dgtr;
3059  else if(dgtr->getVal().SVPAT() == "V" && dgtr->isFinalState()) fsPS[0] = dgtr;
3060  }
3061 
3062  if(V->nDgtr() != 2){
3063  cout << "ERROR in SF_BtoPP1_PtoVV0_VtoP2P3::parseTree"
3064  << " V should have 2 daughters, but it says it has "
3065  << V->nDgtr() << "."
3066  << endl;
3067  return false;
3068  }
3069 
3070  fsPS[2] = V->getDgtrTreePtr(0);
3071  fsPS[3] = V->getDgtrTreePtr(1);
3073 
3074  if(debugThis){
3075  cout << "parsed Tree: P:\n"
3076  << *P
3077  << "\n V:"
3078  << *V
3079  << endl;
3080  for(int i=0; i<4; i++){
3081  cout << "fsPS[" << i << "]\n"
3082  << *(fsPS[i])
3083  << endl;
3084  }
3085  }
3086  // this->printYourself();
3087  return true;
3088 }
3089 
3091  if(0==_exampleDecay){
3092  // B->K (X->psi rho)
3093  _exampleDecay = new DecayTree(521);
3094  _exampleDecay->addDgtr(321, 331)->addDgtr(443,213)->addDgtr(211,-211);
3095  }
3096  return *_exampleDecay;
3097 }
3098 
3100  return getExampleDecay();
3101 }
3102 
3104  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
3105 
3106  double MV0 = mRes(fsPS[0], evt); // ??
3107  TLorentzVector pV= p(2, evt)+p(3,evt);
3108  TLorentzVector qV= p(2, evt)-p(3,evt);
3109  ZTspin1 LV(qV,pV,pV.M());
3110 
3111  TLorentzVector pP= pV+p(0,evt);
3112  TLorentzVector qP= pV-p(0, evt);
3113  ZTspin1 LP(qP,pP,pP.M());
3114 
3115  polVector e = polVector(p(0, evt),MV0,getPolarisation());
3116  e.conj();
3117 
3118  complex<double> sfm(LeviCivita(LP,pP,LV,e.Re()),LeviCivita(LP,pP,LV,e.Im()));
3119  return sfm/(GeV*GeV*GeV);
3120 }
3122  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
3123  os << "spin factor SF_BtoPP1_PtoVV0_VtoP2P3"
3124  << "\n\t parsed tree " << theDecay().oneLiner()
3125  << "\n like this:" << endl;
3126 }
3127 
3128 //==================================================================
3129 
3131  bool debugThis=false;
3132 
3133  if(fsPS.size() < 4) fsPS.reserve(4);
3134  for(int i=0; i< theDecay(pat).nDgtr(); i++){
3135  const_counted_ptr<AssociatedDecayTree> dgtr= theDecay(pat).getDgtrTreePtr(i);
3136  if(dgtr->getVal().SVPAT() == "V" && (!dgtr->isFinalState())) V = dgtr;
3137  else if(dgtr->getVal().SVPAT() == "P" && dgtr->isFinalState()) fsPS[1] = dgtr;
3138  }
3139  if(0== V || 0==fsPS[1]){
3140  cout << "ERROR in SF_BtoVP1_VtoTV0_TtoP2P3::parseTree"
3141  << " Didn't find V or P1 " << V.get() << ", " << fsPS[1].get() << endl;
3142  return false;
3143  }
3144 
3145  if(V->nDgtr() != 2){
3146  cout << "ERROR in SF_BtoVP1_VtoTV0_TtoP2P3::parseTree"
3147  << " V should have 2 daughters, but it says it has "
3148  << V->nDgtr() << "."
3149  << endl;
3150  return false;
3151  }
3152 
3153  for(int i=0; i< V->nDgtr(); i++){
3154  const_counted_ptr<AssociatedDecayTree> dgtr= V->getDgtrTreePtr(i);
3155  if(dgtr->getVal().SVPAT() == "T" && (!dgtr->isFinalState()) ) T = dgtr;
3156  else if(dgtr->getVal().SVPAT() == "V" && dgtr->isFinalState()) fsPS[0] = dgtr;
3157  }
3158 
3159  if(T->nDgtr() != 2){
3160  cout << "ERROR in SF_BtoVP1_VtoTV0_TtoP2P3::parseTree"
3161  << " T should have 2 daughters, but it says it has "
3162  << T->nDgtr() << "."
3163  << endl;
3164  return false;
3165  }
3166 
3167  fsPS[2] = T->getDgtrTreePtr(0);
3168  fsPS[3] = T->getDgtrTreePtr(1);
3170 
3171  if(debugThis){
3172  cout << "parsed Tree: V:\n"
3173  << *V
3174  << "\n T:"
3175  << *T
3176  << endl;
3177  for(int i=0; i<4; i++){
3178  cout << "fsPS[" << i << "]\n"
3179  << *(fsPS[i])
3180  << endl;
3181  }
3182  }
3183  // this->printYourself();
3184  return true;
3185 }
3186 
3188  if(0==_exampleDecay){
3189  // B->K (X->psi f2)
3190  _exampleDecay = new DecayTree(521);
3191  _exampleDecay->addDgtr(321, 100443)->addDgtr(443,225)->addDgtr(211,-211);
3192  }
3193  return *_exampleDecay;
3194 }
3195 
3197  return getExampleDecay();
3198 }
3199 
3201  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) parseTree(evt.eventPattern());
3202 
3203  double MV0 = mRes(fsPS[0], evt); // ??
3204  TLorentzVector pT= p(2, evt)+p(3,evt);
3205  TLorentzVector qT= p(2, evt)-p(3,evt);
3206  TLorentzVector pV= pT+p(0,evt);
3207  TLorentzVector qV= pT-p(0,evt);
3208  TLorentzVector pB= pV+p(1,evt);
3209  TLorentzVector qB= pV-p(1,evt);
3210 
3211  SpinSumV PV(pV,pV.M());
3212  SpinSumV PT(pT,pT.M());
3213  ZTspin1 LB(qB,pB,pB.M());
3214  ZTspin1 LT(qT,pT,pT.M());
3215 
3216  polVector e = polVector(p(0, evt),MV0,getPolarisation());
3217  e.conj();
3218 
3219  TLorentzVector tmp = PV.Dot(LB);
3220 
3221  complex<double> sfm( LT.Dot(tmp) * LT.Dot(e.Re()) + 1./3. * LT.Dot(LT) * (PT.Dot(tmp)).Dot(e.Re()), LT.Dot(tmp) * LT.Dot(e.Im()) + 1./3. * LT.Dot(LT) * (PT.Dot(tmp)).Dot(e.Im()));
3222  return sfm/(GeV*GeV*GeV);
3223 }
3225  if(! ( fsPS[0] && fsPS[1] && fsPS[2] && fsPS[3]) ) return;
3226  os << "spin factor SF_BtoVP1_VtoTV0_TtoP2P3"
3227  << "\n\t parsed tree " << theDecay().oneLiner()
3228  << "\n like this:" << endl;
3229 }
3230 
3231 //=========================================================
3232 //
3233 //
static const DecayTree & getExampleDecay()
virtual bool parseTree(const DalitzEventPattern &pat)
static const DecayTree & getExampleDecay()
static const DecayTree & getExampleDecay()
virtual void printYourself(std::ostream &os=std::cout) const
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual const DecayTree & exampleDecay()
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual bool parseTree(const DalitzEventPattern &pat)
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
const X * get() const
Definition: counted_ptr.h:217
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
static const DecayTree & getExampleDecay()
virtual const DecayTree & exampleDecay()
MINT::counted_ptr< DDTree< ValueType > > addDgtr(const DDTree< ValueType > *treePtr)
Definition: DDTree.h:211
virtual bool parseTree(const DalitzEventPattern &pat)
virtual bool parseTree(const DalitzEventPattern &pat)
virtual bool parseTree(const DalitzEventPattern &pat)
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual bool parseTree(const DalitzEventPattern &pat)
static const DecayTree & getExampleDecay()
virtual const DecayTree & exampleDecay()
virtual const DecayTree & exampleDecay()
virtual void printYourself(std::ostream &os=std::cout) const
virtual void printYourself(std::ostream &os=std::cout) const
static const DecayTree & getExampleDecay()
static const DecayTree & getExampleDecay()
static const DecayTree & getExampleDecay()
static const DecayTree & getExampleDecay()
virtual const DecayTree & exampleDecay()
virtual bool parseTree(const DalitzEventPattern &pat)
virtual const DecayTree & exampleDecay()
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual void printYourself(std::ostream &os=std::cout) const
virtual const DecayTree & exampleDecay()
static const DecayTree & getExampleDecay()
virtual const DecayTree & exampleDecay()
std::string SVPAT() const
TLorentzVector Dot(const TLorentzVector &rhs) const
Definition: SpinSumV.h:20
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual const DecayTree & exampleDecay()
virtual bool parseTree(const DalitzEventPattern &pat)
double Sandwich(const TLorentzVector &lhs, const TLorentzVector &rhs) const
Definition: SpinSumV.h:32
static const DecayTree & getExampleDecay()
virtual bool parseTree(const DalitzEventPattern &pat)
virtual const DecayTree & exampleDecay()
virtual void printYourself(std::ostream &os=std::cout) const
virtual const DecayTree & exampleDecay()
virtual const DecayTree & exampleDecay()
virtual void printYourself(std::ostream &os=std::cout) const
const TLorentzVector & Re() const
static const DecayTree & getExampleDecay()
virtual void printYourself(std::ostream &os=std::cout) const
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual const DecayTree & exampleDecay()
const ValueType & getVal() const
Definition: DDTree.h:102
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual const DecayTree & exampleDecay()
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual void printYourself(std::ostream &os=std::cout) const
virtual const DecayTree & exampleDecay()
bool isFinalState() const
Definition: DDTree.h:93
static const DecayTree & getExampleDecay()
virtual void printYourself(std::ostream &os=std::cout) const
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
static const DecayTree & getExampleDecay()
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual void printYourself(std::ostream &os=std::cout) const
virtual void printYourself(std::ostream &os=std::cout) const
virtual const DecayTree & exampleDecay()
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual const DecayTree & exampleDecay()
MINT::const_counted_ptr< DDTree< ValueType > > getDgtrTreePtr(int i) const
Definition: DDTree.h:114
virtual void printYourself(std::ostream &os=std::cout) const
virtual void printYourself(std::ostream &os=std::cout) const
static const DecayTree & getExampleDecay()
virtual void printYourself(std::ostream &os=std::cout) const
static const DecayTree & getExampleDecay()
static const DecayTree & getExampleDecay()
virtual const DecayTree & exampleDecay()
void setL(int l)
Definition: DecayTreeItem.h:61
static const DecayTree & getExampleDecay()
virtual bool parseTree(const DalitzEventPattern &pat)
virtual void printYourself(std::ostream &os=std::cout) const
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual const DecayTree & exampleDecay()
virtual void printYourself(std::ostream &os=std::cout) const
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
static const DecayTree & getExampleDecay()
virtual const DecayTree & exampleDecay()
virtual void printYourself(std::ostream &os=std::cout) const
virtual void printYourself(std::ostream &os=std::cout) const
virtual void printYourself(std::ostream &os=std::cout) const
static const DecayTree & getExampleDecay()
static const DecayTree & getExampleDecay()
virtual void printYourself(std::ostream &os=std::cout) const
static const DecayTree & getExampleDecay()
virtual const DecayTree & exampleDecay()
virtual const DalitzEventPattern & eventPattern() const =0
virtual bool parseTree(const DalitzEventPattern &pat)
virtual const DecayTree & exampleDecay()
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual bool parseTree(const DalitzEventPattern &pat)
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
static const DecayTree & getExampleDecay()
static const DecayTree & getExampleDecay()
static const double GeV
Definition: ZTspin1.h:9
virtual void printYourself(std::ostream &os=std::cout) const
virtual const DecayTree & exampleDecay()
virtual const DecayTree & exampleDecay()
virtual bool parseTree(const DalitzEventPattern &pat)
virtual void printYourself(std::ostream &os=std::cout) const
static const DecayTree & getExampleDecay()
virtual const DecayTree & exampleDecay()
virtual bool parseTree(const DalitzEventPattern &pat)
virtual void printYourself(std::ostream &os=std::cout) const
virtual bool parseTree(const DalitzEventPattern &pat)
const TLorentzVector & Im() const
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
static const DecayTree & getExampleDecay()
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual const DecayTree & exampleDecay()
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
double LeviCivita(const TLorentzVector &p0, const TLorentzVector &p1, const TLorentzVector &p2, const TLorentzVector &p3)
Definition: LeviCivita.h:12
int nDgtr() const
Definition: DDTree.h:96
virtual bool parseTree(const DalitzEventPattern &pat)
double Sandwich(const TLorentzVector &lm, const TLorentzVector &ln, const TLorentzVector &ra, const TLorentzVector &rb)
Definition: SpinSumT.h:19
virtual const DecayTree & exampleDecay()
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual void printYourself(std::ostream &os=std::cout) const
static const DecayTree & getExampleDecay()
virtual void printYourself(std::ostream &os=std::cout) const
virtual void printYourself(std::ostream &os=std::cout) const
virtual void printYourself(std::ostream &os=std::cout) const
static const DecayTree & getExampleDecay()
virtual bool parseTree(const DalitzEventPattern &pat)
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual bool parseTree(const DalitzEventPattern &pat)
DDTree< DecayTreeItem > DecayTree
Definition: DecayTree.h:35
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
static const DecayTree & getExampleDecay()
virtual bool parseTree(const DalitzEventPattern &pat)
virtual bool parseTree(const DalitzEventPattern &pat)
virtual bool parseTree(const DalitzEventPattern &pat)
virtual void printYourself(std::ostream &os=std::cout) const
virtual void printYourself(std::ostream &os=std::cout) const
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual void printYourself(std::ostream &os=std::cout) const
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual void printYourself(std::ostream &os=std::cout) const
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual void printYourself(std::ostream &os=std::cout) const
static const DecayTree & getExampleDecay()
virtual const DecayTree & exampleDecay()
virtual bool parseTree(const DalitzEventPattern &pat)
virtual std::complex< double > getNewVal(IDalitzEvent &evt)
virtual void printYourself(std::ostream &os=std::cout) const
virtual void printYourself(std::ostream &os=std::cout) const
virtual const DecayTree & exampleDecay()
virtual const DecayTree & exampleDecay()
TLorentzVector Contract(const TLorentzVector &vec)