StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
evtgenlhc_test1.cc
1 //#@# Dalitz plot for D0 --> K- pi+ pi0 decay:
2 //#@# 1: Mass(K-, pi+)
3 //#@# 2: Mass(pi+,pi0)
4 //
5 //--------------------------------------------------------------------------
6 //
7 // Environment:
8 // This software is part of the EvtGen package developed jointly
9 // for the BaBar and CLEO collaborations. If you use all or part
10 // of it, please give an appropriate acknowledgement.
11 //
12 // Copyright Information: See EvtGen/COPYRIGHT
13 // Copyright (C) 1998 Caltech, UCSB
14 //
15 // Module: testEvtGen.cc
16 //
17 // Description:
18 //
19 // This program invokes the EvtGen event generator package
20 // for testing various decay models that are implemented.
21 //
22 // Modification history:
23 //
24 // DJL/RYD Sometime long ago Module created
25 //
26 //------------------------------------------------------------------------
27 //
28 //
29 //
30 #include "EvtGenBase/EvtComplex.hh"
31 #include "EvtGenBase/EvtTensor4C.hh"
32 #include "EvtGenBase/EvtVector4C.hh"
33 #include "EvtGenBase/EvtVector4R.hh"
34 #include "EvtGenBase/EvtVectorParticle.hh"
35 #include "EvtGenBase/EvtDiracSpinor.hh"
36 #include "EvtGenBase/EvtParticle.hh"
37 #include "EvtGenBase/EvtKine.hh"
38 #include "EvtGenBase/EvtGammaMatrix.hh"
39 #include "EvtGenBase/EvtRandom.hh"
40 #include "EvtGenBase/EvtRandomEngine.hh"
41 #include "EvtGenBase/EvtDecayTable.hh"
42 #include "EvtGenBase/EvtReport.hh"
43 #include "EvtGenBase/EvtPDL.hh"
44 #include "EvtGenBase/EvtStdHep.hh"
45 #include "EvtGenBase/EvtSecondary.hh"
46 #include "EvtGenBase/EvtConst.hh"
47 #include "EvtGen/EvtGen.hh"
48 #include "EvtGenBase/EvtParticleFactory.hh"
49 #include "EvtGenBase/EvtSimpleRandomEngine.hh"
50 #include "EvtGenBase/EvtMTRandomEngine.hh"
51 #include "EvtGenBase/EvtIdSet.hh"
52 #include "EvtGenBase/EvtParser.hh"
53 
54 #include "EvtGenBase/EvtAbsRadCorr.hh"
55 #include "EvtGenBase/EvtDecayBase.hh"
56 
57 #ifdef EVTGEN_EXTERNAL
58 #include "EvtGenExternal/EvtExternalGenList.hh"
59 #endif
60 
61 #include <cstdio>
62 #include <fstream>
63 #include <sstream>
64 #include <cmath>
65 #include <string>
66 #include <vector>
67 #include <cstdlib>
68 
69 #include "TH1.h"
70 #include "TH2.h"
71 #include "TFile.h"
72 #include "TApplication.h"
73 #include "TROOT.h"
74 
75 using std::vector;
76 
77 void runFile(int nevent,char* fname,EvtGen& myGenerator);
78 void runPrint(int nevent,char* fname,EvtGen& myGenerator);
79 void runFileVpho(int nevent,char* fname,EvtGen& myGenerator);
80 void runTest1(int nevent,EvtGen& myGenerator);
81 void runTest2(int nevent,EvtGen& myGenerator);
82 void runOmega(int nevent,EvtGen& myGenerator);
83 void runChi1Kstar(int nevent,EvtGen& myGenerator);
84 void runPi0Dalitz(int nevent,EvtGen& myGenerator);
85 void runMix(int nevent,EvtGen& myGenerator);
86 void runBMix(int nevent,EvtGen& myGenerator,std::string userFile,std::string rootFile);
87 void runDDalitz(int nevent,EvtGen& myGenerator);
88 void runPiPiCPT(int nevent,EvtGen& myGenerator);
89 void runPiPiPiPi(int nevent,EvtGen& myGenerator);
90 void runD2Pi(int nevent,EvtGen& myGenerator);
91 void runJetsetTab3(int nevent,EvtGen& myGenerator);
92 void runHelAmp(int nevent,EvtGen& myGenerator,std::string userFile,std::string rootFile);
93 void runHelAmp2(int nevent,EvtGen& myGenerator);
94 void runJpsiKs(int nevent,EvtGen& myGenerator);
95 void runDump(int nevent,EvtGen& myGenerator);
96 void runD1(int nevent,EvtGen& myGenerator);
97 void runGenericCont(int nevent,EvtGen& myGenerator);
98 void runPiPiPi(int nevent,EvtGen& myGenerator);
99 void runBHadronic(int nevent,EvtGen& myGenerator);
100 void runSingleB(int nevent,EvtGen& myGenerator);
101 void runA2Pi(int nevent,EvtGen& myGenerator);
102 void runAlias();
103 void runRepeat(int nevent);
104 void runPhotos(int nevent,EvtGen& myGenerator);
105 void runTrackMult(int nevent,EvtGen& myGenerator);
106 void runGeneric(int neventOrig,EvtGen& myGenerator,
107  std::string listfile);
108 void runFinalStates(int nevent,EvtGen& myGenerator);
109 std::vector<std::string> findFinalState(EvtParticle *p);
110 void runKstarnunu(int nevent,EvtGen& myGenerator);
111 void runBsmix(int nevent,EvtGen& myGenerator);
112 void runTauTauPiPi(int nevent,EvtGen& myGenerator);
113 void runTauTauEE(int nevent,EvtGen& myGenerator);
114 void runTauTau2Pi2Pi(int nevent,EvtGen& myGenerator);
115 void runTauTau3Pi3Pi(int nevent,EvtGen& myGenerator);
116 void runJPsiKstar(int nevent,EvtGen& myGenerator,int modeInt);
117 void runSVVCPLH(int nevent,EvtGen& myGenerator);
118 void runSVSCPLH(int nevent,EvtGen& myGenerator);
119 void runSSDCP(int nevent,EvtGen& myGenerator);
120 void runKstarstargamma(int nevent,EvtGen& myGenerator);
121 void runDSTARPI(int nevent,EvtGen& myGenerator);
122 void runETACPHIPHI(int nevent,EvtGen& myGenerator);
123 void runVVPiPi(int nevent,EvtGen& myGenerator);
124 void runSVVHelAmp(int nevent,EvtGen& myGenerator);
125 void runSVVHelAmp2(int nevent,EvtGen& myGenerator);
126 void runPartWave(int nevent,EvtGen& myGenerator);
127 void runPartWave2(int nevent,EvtGen& myGenerator);
128 void runTwoBody(int nevent,EvtGen& myGenerator,std::string decfile,std::string rootFile);
129 void runPiPi(int nevent,EvtGen& myGenerator);
130 void runA1Pi(int nevent,EvtGen& myGenerator);
131 void runCPTest(int nevent,EvtGen& myGenerator);
132 void runSemic(int nevent,EvtGen& myGenerator);
133 void runKstarll(int nevent,EvtGen& myGenerator);
134 void runKll(int nevent,EvtGen& myGenerator);
135 void runHll(int nevent,EvtGen& myGenerator, char* mode);
136 void runVectorIsr(int nevent,EvtGen& myGenerator);
137 void runBsquark(int nevent,EvtGen& myGenerator);
138 void runK3gamma(int nevent,EvtGen& myGenerator);
139 void runLambda(int nevent,EvtGen& myGenerator);
140 void runBtoXsgamma(int nevent,EvtGen& myGenerator);
141 void runBtoK1273gamma(int nevent,EvtGen& myGenerator);
142 void runCheckRotBoost();
143 void runMassCheck(int nevent, EvtGen& myGenerator, int partnum);
144 void runJpsiPolarization(int nevent, EvtGen& myGenerator);
145 void runDDK(int nevent, EvtGen &myGenerator);
146 
147 int countInclusive(std::string name, EvtParticle *root,TH1F* mom=0,TH1F* mass=0 );
148 int countInclusiveParent(std::string name, EvtParticle *root,EvtIdSet setIds,
149  TH1F* mom=0);
150 int countInclusiveSubTree(std::string name, EvtParticle *root,EvtIdSet setIds,
151  TH1F* mom=0);
152 void runBaryonic(int nEvent, EvtGen& myGenerator);
153 
154 
155 int main(int argc, char* argv[]){
156 
157  // Define the random number generator
158  EvtRandomEngine* myRandomEngine = 0;
159 
160 #ifdef EVTGEN_CPP11
161  // Use the Mersenne-Twister generator (C++11 only)
162  myRandomEngine = new EvtMTRandomEngine();
163 #else
164  myRandomEngine = new EvtSimpleRandomEngine();
165 #endif
166 
167  if (!TROOT::Initialized()) {
168  static TROOT root("RooTuple", "RooTuple ROOT in EvtGen");
169  }
170  if (argc==1){
171 
172  EvtVector4R p(0.0,1.0,0.0,0.0);
173  EvtVector4R k(0.0,0.0,1.0,0.0);
174 
175  EvtTensor4C T=dual(EvtGenFunctions::directProd(p,k));
176 
177  EvtGenReport(EVTGEN_INFO,"EvtGen") << "p:"<<p<<std::endl;
178  EvtGenReport(EVTGEN_INFO,"EvtGen") << "k:"<<k<<std::endl;
179  EvtGenReport(EVTGEN_INFO,"EvtGen") << "T=dual(directProd(p,k)):"<<T<<std::endl;
180  EvtGenReport(EVTGEN_INFO,"EvtGen") << "T03:"<<T.get(0,3)<<std::endl;
181  return 1;
182  }
183 
184  EvtAbsRadCorr* radCorrEngine = 0;
185  std::list<EvtDecayBase*> extraModels;
186 
187 #ifdef EVTGEN_EXTERNAL
188  EvtExternalGenList genList;
189  radCorrEngine = genList.getPhotosModel();
190  extraModels = genList.getListOfModels();
191 #endif
192 
193  EvtGen myGenerator("../DECAY_2010.DEC", "../evt.pdl", myRandomEngine,
194  radCorrEngine, &extraModels);
195 
196  if (!strcmp(argv[1],"file")) {
197  int nevent=atoi(argv[2]);
198  runFile(nevent,argv[3],myGenerator);
199  }
200 
201  if (!strcmp(argv[1],"print")) {
202  int nevent=atoi(argv[2]);
203  runPrint(nevent,argv[3],myGenerator);
204  }
205 
206  if (!strcmp(argv[1],"filevpho")) {
207  int nevent=atoi(argv[2]);
208  runFileVpho(nevent,argv[3],myGenerator);
209  }
210 
211  if (!strcmp(argv[1],"test1")) {
212  int nevent=atoi(argv[2]);
213  runTest1(nevent,myGenerator);
214  }
215 
216  if (!strcmp(argv[1],"chi1kstar")) {
217  int nevent=atoi(argv[2]);
218  runChi1Kstar(nevent,myGenerator);
219  }
220 
221  if (!strcmp(argv[1],"test2")) {
222  int nevent=atoi(argv[2]);
223  runTest2(nevent,myGenerator);
224  }
225 
226  if (!strcmp(argv[1],"omega")) {
227  int nevent=atoi(argv[2]);
228  runOmega(nevent,myGenerator);
229  }
230 
231  if (!strcmp(argv[1],"alias")) {
232  runAlias();
233  }
234 
235  if (!strcmp(argv[1],"repeat")) {
236  int nevent=atoi(argv[2]);
237  runRepeat(nevent);
238  }
239 
240  if (!strcmp(argv[1],"photos")) {
241  int nevent=atoi(argv[2]);
242  runPhotos(nevent,myGenerator);
243  }
244 
245  if (!strcmp(argv[1],"trackmult")) {
246  int nevent=atoi(argv[2]);
247  runTrackMult(nevent,myGenerator);
248  }
249 
250  if (!strcmp(argv[1],"generic")) {
251  int nevent=atoi(argv[2]);
252  std::string listfile("");
253  if ( argc==4) listfile=argv[3];
254  runGeneric(nevent,myGenerator,listfile);
255  }
256 
257  if (!strcmp(argv[1],"finalstates")) {
258  int nevent=atoi(argv[2]);
259  runFinalStates(nevent,myGenerator);
260  }
261 
262  if (!strcmp(argv[1],"kstarnunu")) {
263  int nevent=atoi(argv[2]);
264  runKstarnunu(nevent,myGenerator);
265  }
266 
267  if (!strcmp(argv[1],"bsmix")) {
268  int nevent=atoi(argv[2]);
269  runBsmix(nevent,myGenerator);
270  }
271 
272  if (!strcmp(argv[1],"BtoXsgamma")) {
273  int nevent=atoi(argv[2]);
274  runBtoXsgamma(nevent,myGenerator);
275  }
276 
277  if (!strcmp(argv[1],"BtoK1273gamma")) {
278  int nevent=atoi(argv[2]);
279  runBtoK1273gamma(nevent,myGenerator);
280  }
281 
282  if (!strcmp(argv[1],"pi0dalitz")) {
283  int nevent=atoi(argv[2]);
284  runPi0Dalitz(nevent,myGenerator);
285  }
286 
287  if (!strcmp(argv[1],"ddalitz")) {
288  int nevent=atoi(argv[2]);
289  runDDalitz(nevent,myGenerator);
290  }
291 
292 
293  if (!strcmp(argv[1],"kstarll")) {
294  int nevent=atoi(argv[2]);
295  runKstarll(nevent, myGenerator);
296  }
297  if (!strcmp(argv[1],"kll")) {
298  int nevent=atoi(argv[2]);
299  runKll(nevent, myGenerator);
300  }
301  if (!strcmp(argv[1],"hll")) {
302  int nevent=atoi(argv[2]);
303  runHll(nevent, myGenerator, argv[3]);
304  }
305 
306  if (!strcmp(argv[1],"vectorisr")) {
307  int nevent=atoi(argv[2]);
308  runVectorIsr(nevent, myGenerator);
309  }
310 
311 
312  if (!strcmp(argv[1],"bsquark")) {
313  int nevent=atoi(argv[2]);
314  runBsquark(nevent, myGenerator);
315  }
316 
317 
318  if (!strcmp(argv[1],"k3gamma")) {
319  int nevent=atoi(argv[2]);
320  runK3gamma(nevent, myGenerator);
321  }
322 
323  if (!strcmp(argv[1],"lambda")) {
324  int nevent=atoi(argv[2]);
325  runLambda(nevent, myGenerator);
326  }
327 
328 
329  if (!strcmp(argv[1],"tautaupipi")) {
330  int nevent=atoi(argv[2]);
331  runTauTauPiPi(nevent, myGenerator);
332  }
333 
334  if (!strcmp(argv[1],"tautauee")) {
335  int nevent=atoi(argv[2]);
336  runTauTauEE(nevent, myGenerator);
337  }
338 
339  if (!strcmp(argv[1],"tautau2pi2pi")) {
340  int nevent=atoi(argv[2]);
341  runTauTau2Pi2Pi(nevent, myGenerator);
342  }
343  if (!strcmp(argv[1],"tautau3pi3pi")) {
344  int nevent=atoi(argv[2]);
345  runTauTau3Pi3Pi(nevent, myGenerator);
346  }
347 
348  if (!strcmp(argv[1],"jpsikstar")) {
349  int nevent=atoi(argv[2]);
350  int modeInt=atoi(argv[3]);
351  runJPsiKstar(nevent, myGenerator,modeInt);
352  }
353 
354 
355  if (!strcmp(argv[1],"svvcplh")) {
356  int nevent=atoi(argv[2]);
357  runSVVCPLH(nevent, myGenerator);
358  }
359 
360 
361  if (!strcmp(argv[1],"svscplh")) {
362  int nevent=atoi(argv[2]);
363  runSVSCPLH(nevent, myGenerator);
364  }
365 
366 
367  if (!strcmp(argv[1],"ssdcp")) {
368  int nevent=atoi(argv[2]);
369  runSSDCP(nevent, myGenerator);
370  }
371 
372 
373  if (!strcmp(argv[1],"kstarstargamma")) {
374  int nevent=atoi(argv[2]);
375  runKstarstargamma(nevent, myGenerator);
376  }
377 
378 
379  if (!strcmp(argv[1],"dstarpi")) {
380  int nevent=atoi(argv[2]);
381  runDSTARPI(nevent, myGenerator);
382  }
383 
384 
385  if (!strcmp(argv[1],"etacphiphi")) {
386  int nevent=atoi(argv[2]);
387  runETACPHIPHI(nevent, myGenerator);
388  }
389 
390  if (!strcmp(argv[1],"vvpipi")) {
391  int nevent=atoi(argv[2]);
392  runVVPiPi(nevent, myGenerator);
393  }
394 
395  if (!strcmp(argv[1],"svvhelamp")) {
396  int nevent=atoi(argv[2]);
397  runSVVHelAmp(nevent, myGenerator);
398  }
399 
400  if (!strcmp(argv[1],"partwave")) {
401  int nevent=atoi(argv[2]);
402  runPartWave(nevent, myGenerator);
403  }
404 
405  if (!strcmp(argv[1],"partwave2")) {
406  int nevent=atoi(argv[2]);
407  runPartWave2(nevent, myGenerator);
408  }
409 
410  if (!strcmp(argv[1],"twobody")) {
411  int nevent=atoi(argv[2]);
412  runTwoBody(nevent, myGenerator, argv[3], argv[4]);
413  }
414 
415  if (!strcmp(argv[1],"pipipi")) {
416  int nevent=atoi(argv[2]);
417  runPiPiPi(nevent, myGenerator);
418  }
419 
420  if (!strcmp(argv[1],"bhadronic")) {
421  int nevent=atoi(argv[2]);
422  runBHadronic(nevent, myGenerator);
423  }
424 
425  if (!strcmp(argv[1],"singleb")) {
426  int nevent=atoi(argv[2]);
427  runSingleB(nevent, myGenerator);
428  }
429 
430  if (!strcmp(argv[1],"pipi")) {
431  int nevent=atoi(argv[2]);
432  runPiPi(nevent, myGenerator);
433  }
434 
435  if (!strcmp(argv[1],"pipipipi")) {
436  int nevent=atoi(argv[2]);
437  runPiPiPiPi(nevent, myGenerator);
438  }
439 
440  if (!strcmp(argv[1],"a2pi")) {
441  int nevent=atoi(argv[2]);
442  runA2Pi(nevent, myGenerator);
443  }
444 
445  if (!strcmp(argv[1],"helamp")) {
446  int nevent=atoi(argv[2]);
447  runHelAmp(nevent, myGenerator, argv[3], argv[4]);
448  }
449 
450 
451  if (!strcmp(argv[1],"helamp2")) {
452  int nevent=atoi(argv[2]);
453  runHelAmp2(nevent, myGenerator);
454  }
455 
456  if (!strcmp(argv[1],"d2pi")) {
457  int nevent=atoi(argv[2]);
458  runD2Pi(nevent, myGenerator);
459  }
460 
461  if (!strcmp(argv[1],"a1pi")) {
462  int nevent=atoi(argv[2]);
463  runA1Pi(nevent, myGenerator);
464  }
465 
466  if (!strcmp(argv[1],"cptest")) {
467  int nevent=atoi(argv[2]);
468  runCPTest(nevent, myGenerator);
469  }
470 
471  if (!strcmp(argv[1],"pipicpt")) {
472  int nevent=atoi(argv[2]);
473  runPiPiCPT(nevent, myGenerator);
474  }
475 
476  if (!strcmp(argv[1],"jpsiks")) {
477  int nevent=atoi(argv[2]);
478  runJpsiKs(nevent, myGenerator);
479  }
480 
481  if (!strcmp(argv[1],"dump")) {
482  int nevent=atoi(argv[2]);
483  runDump(nevent, myGenerator);
484  }
485 
486  if (!strcmp(argv[1],"genericcont")) {
487  int nevent=atoi(argv[2]);
488  runGenericCont(nevent, myGenerator);
489  }
490 
491 
492  if (!strcmp(argv[1],"d1")) {
493  int nevent=atoi(argv[2]);
494  runD1(nevent, myGenerator);
495  }
496 
497  if (!strcmp(argv[1],"mix")) {
498  int nevent=atoi(argv[2]);
499  runMix(nevent, myGenerator);
500  }
501 
502  if (!strcmp(argv[1],"bmix")) {
503  int nevent=atoi(argv[2]);
504  runBMix(nevent, myGenerator, argv[3], argv[4]);
505  }
506 
507  if (!strcmp(argv[1],"semic")) {
508  int nevent=atoi(argv[2]);
509  runSemic(nevent,myGenerator);
510  }
511 
512  if (!strcmp(argv[1],"ddk")) {
513  int nevent=atoi(argv[2]);
514  runDDK(nevent,myGenerator);
515  }
516 
517  if (!strcmp(argv[1],"checkmass")) {
518  int nevent=atoi(argv[2]);
519  int partnum=atoi(argv[3]);
520  runMassCheck(nevent,myGenerator,partnum);
521  }
522 
523  if (!strcmp(argv[1],"jpsipolarization")) {
524  int nevent=atoi(argv[2]);
525  runJpsiPolarization(nevent,myGenerator);
526  }
527 
528  //*******************************************************
529  //test of the rotations and boosts performed in EvtGen.
530  // Added by Lange and Ryd Jan 5,2000.
531  //*******************************************************
532 
533  if (!strcmp(argv[1],"checkrotboost")) {
534  runCheckRotBoost();
535  }
536 
537  if ( !strcmp(argv[1], "baryonic") )
538  {
539  runBaryonic( atoi(argv[2]), myGenerator );
540  }
541 
542  delete myRandomEngine;
543  return 0;
544 
545 
546 }
547 
548 void runFile(int nevent,char* fname, EvtGen &myGenerator) {
549 
550  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
551 
552  int count;
553 
554  char udecay_name[100];
555 
556  strcpy(udecay_name,fname);
557 
558  myGenerator.readUDecay(udecay_name);
559 
560  count=1;
561 
562  do{
563 
564  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
565 
566  EvtParticle* root_part=EvtParticleFactory::particleFactory(UPS4,
567  p_init);
568  root_part->setVectorSpinDensity();
569 
570  myGenerator.generateDecay(root_part);
571 
572  root_part->deleteTree();
573 
574  }while (count++<nevent);
575  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
576 }
577 
578 void runPrint(int nevent,char* fname, EvtGen &myGenerator) {
579 
580  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
581 
582  int count;
583 
584  char udecay_name[100];
585 
586  strcpy(udecay_name,fname);
587 
588  myGenerator.readUDecay(udecay_name);
589 
590  count=1;
591 
592  do{
593 
594  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
595 
596  EvtParticle* root_part=EvtParticleFactory::particleFactory(UPS4,
597  p_init);
598  root_part->setVectorSpinDensity();
599 
600  myGenerator.generateDecay(root_part);
601 
602  root_part->printTree();
603 
604  root_part->deleteTree();
605 
606  }while (count++<nevent);
607  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
608 }
609 
610 void runFileVpho(int nevent,char* fname, EvtGen &myGenerator) {
611 
612  static EvtId VPHO=EvtPDL::getId(std::string("vpho"));
613  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
614 
615  int count;
616 
617  char udecay_name[100];
618 
619  strcpy(udecay_name,fname);
620 
621  myGenerator.readUDecay(udecay_name);
622 
623  count=1;
624 
625  do{
626 
627  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
628 
629  EvtParticle* root_part=EvtParticleFactory::particleFactory(VPHO,
630  p_init);
631  root_part->setVectorSpinDensity();
632 
633  myGenerator.generateDecay(root_part);
634 
635  root_part->deleteTree();
636 
637  }while (count++<nevent);
638  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
639 
640 }
641 
643 
644 void runJpsiPolarization(int nevent, EvtGen &myGenerator) {
645 
646  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
647  static EvtId JPSI=EvtPDL::getId(std::string("J/psi"));
648 
649  int count;
650 
651  myGenerator.readUDecay("exampleFiles/GENERIC.DEC");
652  myGenerator.readUDecay("exampleFiles/JPSITOLL.DEC");
653  TFile *file=new TFile("jpsipolar.root", "RECREATE");
654 
655  TH1F* coshel = new TH1F("h1","cos hel",50,-1.0,1.0);
656  TH1F* coshelHigh = new TH1F("h2","cos hel pstar gt 1.1",50,-1.0,1.0);
657  TH1F* coshelLow = new TH1F("h3","cos hel pstar lt 1.1",50,-1.0,1.0);
658 
659  count=1;
660 
661  do{
662 
663  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
664  EvtParticle* root_part=EvtParticleFactory::particleFactory(UPS4,
665  p_init);
666 
667  root_part->setVectorSpinDensity();
668  myGenerator.generateDecay(root_part);
669  EvtParticle *p = root_part;
670 
671  do{
672  EvtId type=p->getId();
673  if (p->getId()==JPSI) {
674  EvtVector4R p4psi=p->getP4Lab();
675  EvtVector4R p4Daug=p->getDaug(0)->getP4Lab();
676  double dcostheta=EvtDecayAngle(p_init,p4psi,p4Daug);
677  coshel->Fill(dcostheta);
678  if ( p4psi.d3mag() > 1.1 ) {
679  coshelHigh->Fill(dcostheta);
680  }
681  else{
682  coshelLow->Fill(dcostheta);
683  }
684  }
685  p=p->nextIter(root_part);
686  }while(p!=0);
687 
688  root_part->deleteTree();
689  }while (count++<nevent);
690 
691  file->Write(); file->Close();
692 
693  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
694 }
695 
696 
697 void runMassCheck(int nevent, EvtGen &myGenerator,
698  int partnum) {
699 
700  int count;
701  static EvtId myPart=EvtPDL::evtIdFromStdHep(partnum);
702  TFile *file=new TFile("checkmass.root", "RECREATE");
703 
704  TH1F* mass = new TH1F("h1","Mass",500,0.0,2.5);
705 
706  count=1;
707  do{
708  mass->Fill(EvtPDL::getMass(myPart));
709  }while (count++<nevent);
710  file->Write(); file->Close();
711 
712  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
713 
714 }
715 
716 void runPi0Dalitz(int nevent, EvtGen &myGenerator) {
717 
718  static EvtId PI0=EvtPDL::getId(std::string("pi0"));
719 
720  TFile *file=new TFile("pi0dalitz.root", "RECREATE");
721 
722  TH1F* q2 = new TH1F("h1","q2",50,0.0,0.02);
723 
724  int count;
725 
726 
727  myGenerator.readUDecay("exampleFiles/PI0DALITZ.DEC");
728 
729  count=1;
730 
731  do{
732 
733 
734  EvtVector4R p_init(EvtPDL::getMass(PI0),0.0,0.0,0.0);
735 
736  EvtParticle* root_part=EvtParticleFactory::particleFactory(PI0,
737  p_init);
738 
739  root_part->setDiagonalSpinDensity();
740 
741  myGenerator.generateDecay(root_part);
742 
743  EvtVector4R ep=root_part->getDaug(0)->getP4Lab();
744  EvtVector4R em=root_part->getDaug(1)->getP4Lab();
745  EvtVector4R gamma=root_part->getDaug(2)->getP4Lab();
746 
747  q2->Fill( (ep+em).mass2() );
748  // EvtGenReport(EVTGEN_INFO,"EvtGen") << ep << em << gamma <<std::endl;
749  root_part->deleteTree();
750 
751  }while (count++<nevent);
752 
753  file->Write(); file->Close();
754 
755  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
756 
757 }
758 
759 
760 
761 //*******************************************************************************
762 void runTest1(int nevent, EvtGen &myGenerator) {
763  // TFile *file=new TFile("test1.root", "RECREATE");
764  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
765 
766  // int first=0;
767  // char **second;
768  // TApplication *theApp = new TApplication("App", &first, second);
769  TFile *file = new TFile("test1.root", "RECREATE", "Example");
770  TH1F * costhetaB = new TH1F("hcosthetaB","costhetaB",50,-1.0,1.0);
771  TH1F* phiB = new TH1F("hphiB","phiB",50,-EvtConst::pi,EvtConst::pi);
772  TH1F* Elep = new TH1F("hEl","E?l!",50,0.0,2.5);
773  TH1F* q2 = new TH1F("hq2","q^2!",44,0.0,11.0);
774  TH1F* ctv = new TH1F("hctv","ctv",50,-1.0,1.0);
775  TH1F* chi_low_ctv = new TH1F("hcostv1","[h] for cos[Q]?V!\"L#0",50,0.0,EvtConst::twoPi);
776  TH1F* chi_high_ctv = new TH1F("hcostv2","[h] for cos[Q]?V!\"G#0",50,0.0,EvtConst::twoPi);
777  TH1F* dt = new TH1F("hdt","dt",50,-5.0,5.0);
778 
779 
780  int count;
781 
782  EvtVector4R p4b0,p4b0b,p4dstar,p4e,p4nu,p4d,p4pi,p4pip,p4pim;
783  char udecay_name[100];
784 
785  strcpy(udecay_name,"exampleFiles/TEST1.DEC");
786 
787  // EvtGen myGenerator(decay_name,pdttable_name,myRandomEngine);
788 
789  myGenerator.readUDecay(udecay_name);
790  double costhetaV;
791 
792  count=1;
793 
794  do{
795 
796  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
797 
798  EvtParticle* root_part=EvtParticleFactory::particleFactory(UPS4,
799  p_init);
800  root_part->setVectorSpinDensity();
801 
802  myGenerator.generateDecay(root_part);
803 
804 
805  p4b0=root_part->getDaug(0)->getP4Lab();
806  p4b0b=root_part->getDaug(1)->getP4Lab();
807 
808  p4dstar=root_part->getDaug(0)->getDaug(0)->getP4Lab();
809  p4e=root_part->getDaug(0)->getDaug(1)->getP4Lab();
810  p4nu=root_part->getDaug(0)->getDaug(2)->getP4Lab();
811 
812  p4d=root_part->getDaug(0)->getDaug(0)->getDaug(0)->getP4Lab();
813  p4pi=root_part->getDaug(0)->getDaug(0)->getDaug(1)->getP4Lab();
814 
815  p4pip=root_part->getDaug(1)->getDaug(0)->getP4Lab();
816  p4pim=root_part->getDaug(1)->getDaug(1)->getP4Lab();
817 
818 
819  costhetaB->Fill(p4b0.get(3)/p4b0.d3mag());
820  phiB->Fill(atan2(p4b0.get(1),p4b0.get(2)));
821  Elep->Fill(p4b0*p4e/p4b0.mass());
822  q2->Fill((p4e+p4nu).mass2());
823  dt->Fill(root_part->getDaug(1)->getLifetime()-root_part->getDaug(0)->getLifetime());
824  costhetaV=EvtDecayAngle(p4b0,p4d+p4pi,p4d);
825  ctv->Fill(costhetaV);
826  if (costhetaV<0.0){
827  chi_low_ctv->Fill(EvtDecayAngleChi(p4b0,p4d,p4pi,p4e,p4nu));
828  }
829  else{
830  chi_high_ctv->Fill(EvtDecayAngleChi(p4b0,p4d,p4pi,p4e,p4nu));
831  }
832 
833  root_part->deleteTree();
834 
835  }while (count++<nevent);
836  file->Write();
837  file->Close();
838  // delete theApp;
839  // hfile.write();
840 
841  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
842 }
843 
844 //*******************************************************************************
845 void runDDK(int nevent, EvtGen &myGenerator) {
846  // TFile *file=new TFile("test1.root", "RECREATE");
847  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
848 
849  int count;
850 
851  char udecay_name[100];
852 
853  strcpy(udecay_name,"exampleFiles/GENERIC.DEC");
854 
855  myGenerator.readUDecay(udecay_name);
856 
857  count=1;
858 
859  static EvtId kp=EvtPDL::getId(std::string("K+"));
860  static EvtId km=EvtPDL::getId(std::string("K-"));
861  static EvtId ks=EvtPDL::getId(std::string("K_S0"));
862  static EvtId kl=EvtPDL::getId(std::string("K_L0"));
863  static EvtId k0=EvtPDL::getId(std::string("K0"));
864  static EvtId kb=EvtPDL::getId(std::string("anti-K0"));
865 
866  static EvtId d0=EvtPDL::getId(std::string("D0"));
867  static EvtId dp=EvtPDL::getId(std::string("D+"));
868  static EvtId dm=EvtPDL::getId(std::string("D-"));
869  static EvtId db=EvtPDL::getId(std::string("anti-D0"));
870 
871  static EvtIdSet theKs(kp,km,ks,kl,k0,kb);
872  static EvtIdSet theDs(d0,dp,dm,db);
873 
874  static EvtId B0=EvtPDL::getId(std::string("B0"));
875  static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
876  static EvtId BP=EvtPDL::getId(std::string("B+"));
877  static EvtId BM=EvtPDL::getId(std::string("B-"));
878 
879  static EvtIdSet theBs(B0B,B0,BP,BM);
880 
881  int nDDK=0;
882  do{
883 
884  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
885 
886  EvtParticle* root_part=EvtParticleFactory::particleFactory(UPS4,
887  p_init);
888  root_part->setVectorSpinDensity();
889 
890  myGenerator.generateDecay(root_part);
891 
892  EvtParticle *theB01=root_part->getDaug(0);
893  EvtParticle *theB02=root_part->getDaug(1);
894 
895  int nD=0;
896  int nK=0;
897 
898  EvtParticle *p=theB01;
899  do{
900  EvtId type=p->getId();
901  EvtId typePar=p->getParent()->getId();
902  if (theDs.contains(type)) nD++;
903  if (theKs.contains(type) && theBs.contains(typePar)) nK++;
904  p=p->nextIter(theB01);
905  }while(p!=0);
906  if ( nD==2 && nK==1 ) nDDK++;
907 
908  nD=0;
909  nK=0;
910 
911  p=theB02;
912  do{
913  EvtId type=p->getId();
914  EvtId typePar=p->getParent()->getId();
915  if (theDs.contains(type)) nD++;
916  if (theKs.contains(type) && theBs.contains(typePar)) nK++;
917  p=p->nextIter(theB02);
918  }while(p!=0);
919  if ( nD==2 && nK==1 ) nDDK++;
920 
921  root_part->deleteTree();
922 
923  }while (count++<nevent);
924 
925  EvtGenReport(EVTGEN_INFO,"EvtGen") << nDDK << " " << (count-1) << " " << nDDK/float(2*(count-1)) << std::endl;
926  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
927 }
928 
929 //*******************************************************************************
930 
931 void runTest2(int nevent, EvtGen &myGenerator) {
932 
933  TFile *file=new TFile("test2.root", "RECREATE");
934  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
935  TH1F* costhetaB = new TH1F("h1","cos[Q]?B!",50,-1.0,1.0);
936  TH1F* phiB = new TH1F("h2","[f]?B!",50,-EvtConst::pi,
937  EvtConst::pi);
938 
939  TH1F* dt = new TH1F("h3","[D]t",100,-5.0,5.0);
940  TH1F* costhetaJpsi = new TH1F("h4","cos[Q]?J/[y]!",
941  50,-1.0,1.0);
942  TH1F* costhetaKstar = new TH1F("h5","cos[Q]?K*!",
943  50,-1.0,1.0);
944  TH1F* chi = new TH1F("h6","[h]",50,0.0,EvtConst::twoPi);
945  TH1F* chi1 = new TH1F("h26","[h] [D]t\"L#0",50,0.0,
946  EvtConst::twoPi);
947  TH1F* chi2 = new TH1F("h27","[h] [D]t\"G#0",50,0.0,
948  EvtConst::twoPi);
949 
950  TH1F* costhetaomega = new TH1F("h7","costhetaomega",50,-1.0,1.0);
951  TH1F* costhetaomega1 = new TH1F("h20","costhetaomega1",50,-1.0,1.0);
952  TH1F* costhetaomega2 = new TH1F("h21","costhetaomega2",50,-1.0,1.0);
953  TH1F* costhetaomega3 = new TH1F("h22","costhetaomega3",50,-1.0,1.0);
954  TH1F* omegaamp = new TH1F("h8","omegaamp",50,0.0,0.05);
955  TH1F* omegaamp1 = new TH1F("h9","omegaamp1",50,0.0,0.05);
956  TH1F* omegaamp2 = new TH1F("h10","omegaamp2",50,0.0,0.05);
957  TH1F* omegaamp3 = new TH1F("h11","omegaamp3",50,0.0,0.05);
958 
959  TH2F* chi1vscoskstarl =
960  new TH2F("h30","[h] vs. cos[Q]?J/[y]! [D]t\"L#0",
961  20,0.0,EvtConst::twoPi,20,-1.0,1.0);
962 
963  TH2F* chi1vscoskstarg =
964  new TH2F("h31","[h] vs. cos[Q]?J/[y]! [D]t\"G#0",
965  20,0.0,EvtConst::twoPi,20,-1.0,1.0);
966 
967  int count=1;
968 
969  EvtVector4R p4_b0,p4_b0b,p4_psi,p4_kstar,p4_mup,p4_mum;
970  EvtVector4R p4_kz,p4_pi0,p4_pi1,p4_pi2,p4_pi3,p4_omega;
971  EvtVector4R p4_pi1_omega,p4_pi2_omega,p4_pi3_omega;
972  char udecay_name[100];
973 
974  strcpy(udecay_name,"exampleFiles/TEST2.DEC");
975  //EvtGen myGenerator(decay_name,pdttable_name,myRandomEngine);
976  myGenerator.readUDecay(udecay_name);
977 
978  do{
979 
980  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
981 
982  EvtParticle* root_part=EvtParticleFactory::particleFactory(UPS4,
983  p_init);
984  root_part->setVectorSpinDensity();
985 
986  myGenerator.generateDecay(root_part);
987 
988  p4_b0=root_part->getDaug(0)->getP4Lab();
989  p4_b0b=root_part->getDaug(1)->getP4Lab();
990  p4_psi=root_part->getDaug(1)->getDaug(0)->getP4Lab();
991  p4_kstar=root_part->getDaug(1)->getDaug(1)->getP4Lab();
992  p4_mup=root_part->getDaug(1)->getDaug(0)->getDaug(0)->getP4Lab();
993  p4_mum=root_part->getDaug(1)->getDaug(0)->getDaug(1)->getP4Lab();
994  p4_kz=root_part->getDaug(1)->getDaug(1)->getDaug(0)->getP4Lab();
995  p4_pi0=root_part->getDaug(1)->getDaug(1)->getDaug(1)->getP4Lab();
996 
997  p4_omega=root_part->getDaug(0)->getDaug(0)->getP4Lab();
998  p4_pi1=root_part->getDaug(0)->getDaug(0)->getDaug(0)->getP4Lab();
999  p4_pi2=root_part->getDaug(0)->getDaug(0)->getDaug(1)->getP4Lab();
1000  p4_pi3=root_part->getDaug(0)->getDaug(0)->getDaug(2)->getP4Lab();
1001 
1002  //get momentum in the omega restframe
1003  p4_pi1_omega=root_part->getDaug(0)->getDaug(0)->getDaug(0)->getP4();
1004  p4_pi2_omega=root_part->getDaug(0)->getDaug(0)->getDaug(1)->getP4();
1005  p4_pi3_omega=root_part->getDaug(0)->getDaug(0)->getDaug(2)->getP4();
1006 
1007  EvtVector3R p3_perp=cross(EvtVector3R(p4_pi2_omega.get(0),
1008  p4_pi2_omega.get(1),
1009  p4_pi2_omega.get(2)),
1010  EvtVector3R(p4_pi3_omega.get(0),
1011  p4_pi3_omega.get(1),
1012  p4_pi3_omega.get(2)));
1013 
1014  EvtVector4R p4_perp(p3_perp.d3mag(),p3_perp.get(0),
1015  p3_perp.get(1),p3_perp.get(2));
1016 
1017  root_part->getDaug(0)->getDaug(0)->getDaug(0)->setP4(p4_perp);
1018 
1019  p4_perp=root_part->getDaug(0)->getDaug(0)->getDaug(0)->getP4Lab();
1020 
1021  EvtVector4R p4_perpprime=p4_omega-p4_perp;
1022 
1023  double d_omegaamp=EvtVector3R(p4_pi1_omega.get(0),
1024  p4_pi1_omega.get(1),
1025  p4_pi1_omega.get(2))*p3_perp;
1026 
1027  d_omegaamp*=d_omegaamp;
1028  d_omegaamp*=20.0;
1029 
1030  double d_dt=root_part->getDaug(1)->getLifetime()-
1031  root_part->getDaug(0)->getLifetime();
1032  double d_costhetaJpsi=EvtDecayAngle(p4_b0b,p4_mup+p4_mum,p4_mup);
1033  double d_costhetaKstar=EvtDecayAngle(p4_b0b,p4_pi0+p4_kz,p4_pi0);
1034  double d_chi=EvtDecayAngleChi(p4_b0b,p4_pi0,p4_kz,p4_mup, p4_mum );
1035  costhetaB->Fill(p4_b0.get(3)/p4_b0.d3mag());
1036  phiB->Fill(atan2(p4_b0.get(1),p4_b0.get(2)));
1037 
1038  dt->Fill(d_dt);
1039  costhetaJpsi->Fill(d_costhetaJpsi);
1040  costhetaKstar->Fill(d_costhetaKstar);
1041  chi->Fill(d_chi);
1042 
1043  if (d_dt<0.0) {
1044  chi1->Fill(d_chi);
1045  chi1vscoskstarl->Fill(d_chi,d_costhetaJpsi,1.0);
1046  }
1047 
1048  if (d_dt>0.0) {
1049  chi2->Fill(d_chi);
1050  chi1vscoskstarg->Fill(d_chi,d_costhetaJpsi,1.0);
1051  }
1052 
1053  double d_costhetaomega=EvtDecayAngle(p4_b0b,p4_perp+p4_perpprime,p4_perp);
1054 
1055 
1056  costhetaomega->Fill(d_costhetaomega);
1057  if (d_omegaamp<0.001) costhetaomega1->Fill(d_costhetaomega);
1058  if (d_omegaamp>0.02) costhetaomega2->Fill(d_costhetaomega);
1059  if (std::fabs(d_omegaamp-0.015)<0.005) costhetaomega3->Fill(d_costhetaomega);
1060 
1061  omegaamp->Fill(d_omegaamp);
1062  if (d_costhetaomega<-0.5) omegaamp1->Fill(d_omegaamp);
1063  if (d_costhetaomega>0.5) omegaamp2->Fill(d_omegaamp);
1064  if (std::fabs(d_costhetaomega)<0.5) omegaamp3->Fill(d_omegaamp);
1065 
1066  root_part->deleteTree();
1067 
1068  }while (count++<nevent);
1069 
1070  file->Write(); file->Close();
1071  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
1072 }
1073 
1074 
1075 
1076 void runOmega(int nevent, EvtGen &myGenerator) {
1077 
1078  TFile *file=new TFile("omega.root", "RECREATE");
1079  static EvtId OMEGA=EvtPDL::getId(std::string("omega"));
1080 
1081  TH2F* dalitz = new TH2F("h1","E1 vs E2",50,0.0,0.5,50,0.0,0.5);
1082 
1083  int count=1;
1084 
1085  char udecay_name[100];
1086 
1087 
1088  strcpy(udecay_name,"exampleFiles/OMEGA.DEC");
1089  myGenerator.readUDecay(udecay_name);
1090 
1091  do{
1092 
1093  EvtVector4R p_init(EvtPDL::getMeanMass(OMEGA),0.0,0.0,0.0);
1094 
1095  EvtParticle* root_part=EvtParticleFactory::particleFactory(OMEGA,
1096  p_init);
1097  //root_part->setDiagonalSpinDensity();
1098  root_part->setVectorSpinDensity();
1099 
1100  myGenerator.generateDecay(root_part);
1101 
1102 
1103  dalitz->Fill(root_part->getDaug(0)->getP4().get(0),
1104  root_part->getDaug(1)->getP4().get(0),1.0);
1105 
1106  root_part->deleteTree();
1107 
1108  }while (count++<nevent);
1109 
1110  file->Write(); file->Close();
1111  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
1112 }
1113 
1114 
1115 
1116 
1117 void runChi1Kstar(int nevent, EvtGen &myGenerator) {
1118 
1119  TFile *file=new TFile("chi1kstar.root", "RECREATE");
1120  static EvtId B0=EvtPDL::getId(std::string("B0"));
1121 
1122  TH1F* costhetaChi1 = new TH1F("h1","cos[Q]?J/[x]!",
1123  50,-1.0,1.0);
1124  TH1F* costhetaKstar = new TH1F("h2","cos[Q]?K*!",
1125  50,-1.0,1.0);
1126  TH1F* chi = new TH1F("h3","[x]",50,-EvtConst::pi,EvtConst::pi);
1127 
1128 
1129  int count=1;
1130 
1131  EvtVector4R p4_b,p4_chi,p4_kstar,p4_gamma,p4_psi,p4_k,p4_p;
1132 
1133  char udecay_name[100];
1134 
1135  strcpy(udecay_name,"exampleFiles/CHI1KSTAR.DEC");
1136 
1137  myGenerator.readUDecay(udecay_name);
1138 
1139  do{
1140 
1141  EvtVector4R p_init(EvtPDL::getMass(B0),0.0,0.0,0.0);
1142 
1143  EvtParticle* root_part=EvtParticleFactory::particleFactory(B0,
1144  p_init);
1145  myGenerator.generateDecay(root_part);
1146 
1147  p4_b=root_part->getP4Lab();
1148  p4_chi=root_part->getDaug(0)->getP4Lab();
1149  p4_kstar=root_part->getDaug(1)->getP4Lab();
1150  p4_psi=root_part->getDaug(0)->getDaug(0)->getP4Lab();
1151  p4_gamma=root_part->getDaug(0)->getDaug(1)->getP4Lab();
1152  p4_k=root_part->getDaug(1)->getDaug(0)->getP4Lab();
1153  p4_p=root_part->getDaug(1)->getDaug(1)->getP4Lab();
1154 
1155  double d_costhetaChi1=EvtDecayAngle(p4_b,p4_chi,p4_psi);
1156  double d_costhetaKstar=EvtDecayAngle(p4_b,p4_kstar,p4_k);
1157  double d_chi=EvtDecayAngleChi(p4_b,p4_k,p4_p,p4_psi, p4_gamma );
1158 
1159  if (d_chi>EvtConst::pi) d_chi-=EvtConst::twoPi;
1160 
1161 
1162 
1163  costhetaChi1->Fill(d_costhetaChi1);
1164  costhetaKstar->Fill(d_costhetaKstar);
1165  chi->Fill(d_chi);
1166 
1167  root_part->deleteTree();
1168 
1169  }while (count++<nevent);
1170 
1171  file->Write(); file->Close();
1172  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
1173 }
1174 
1175 void runAlias() {
1176 
1177  EvtId idpip=EvtPDL::getId(std::string("pi+"));
1178  EvtPDL::alias(idpip,std::string("my_pi+"));
1179  EvtId myidpip=EvtPDL::getId(std::string("my_pi+"));
1180 
1181  EvtId idpim=EvtPDL::getId(std::string("pi-"));
1182  EvtPDL::alias(idpim,std::string("my_pi-"));
1183  EvtId myidpim=EvtPDL::getId(std::string("my_pi-"));
1184 
1185  EvtId idpi0=EvtPDL::getId(std::string("pi0"));
1186  EvtPDL::alias(idpi0,std::string("my_pi0"));
1187  EvtId myidpi0=EvtPDL::getId(std::string("my_pi0"));
1188 
1189 
1190 
1191  EvtPDL::aliasChgConj(myidpip,myidpim);
1192 
1193  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Id pi+:" << idpip << std::endl;
1194  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Id pi-:" << idpim << std::endl;
1195  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Id pi0:" << idpi0 << std::endl;
1196  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Id my_pi+:" << myidpip << std::endl;
1197  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Id my_pi-:" << myidpim << std::endl;
1198  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Id my_pi0:" << myidpi0 << std::endl;
1199 
1200  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Chg conj pi+:" <<
1201  EvtPDL::chargeConj(idpip) << std::endl;
1202  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Chg conj pi-:" <<
1203  EvtPDL::chargeConj(idpim) << std::endl;
1204  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Chg conj pi0:" <<
1205  EvtPDL::chargeConj(idpi0) << std::endl;
1206  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Chg conj my_pi+:" <<
1207  EvtPDL::chargeConj(myidpip) << std::endl;
1208  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Chg conj my_pi-:" <<
1209  EvtPDL::chargeConj(myidpim) << std::endl;
1210  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Chg conj my_pi0:" <<
1211  EvtPDL::chargeConj(myidpi0) << std::endl;
1212  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
1213 }
1214 
1215 
1216 void runRepeat(int nevent) {
1217  int i;
1218 
1219  for(i=0;i<nevent;i++){
1220 
1221  EvtDecayTable::getInstance()->readDecayFile(std::string("../DECAY_2010.DEC"));
1222 
1223  }
1224  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
1225 }
1226 
1227 
1228 void runPhotos(int nevent, EvtGen &myGenerator) {
1229 
1230  static EvtId PSI=EvtPDL::getId(std::string("J/psi"));
1231 
1232  TFile *file=new TFile("photos.root", "RECREATE");
1233 
1234  TH1F* mee = new TH1F("h1","mee",60,3.0,3.12);
1235 
1236  int count=1;
1237 
1238  EvtVector4R e1,e2;
1239 
1240  char udecay_name[100];
1241  strcpy(udecay_name,"exampleFiles/PHOTOS.DEC");
1242  //EvtGen myGenerator(decay_name,pdttable_name,myRandomEngine);
1243  myGenerator.readUDecay(udecay_name);
1244 
1245  do{
1246 
1247  EvtVector4R p_init(EvtPDL::getMass(PSI),0.0,0.0,0.0);
1248 
1249  EvtParticle* root_part=EvtParticleFactory::particleFactory(PSI,
1250  p_init);
1251  root_part->setDiagonalSpinDensity();
1252 
1253  myGenerator.generateDecay(root_part);
1254 
1255  e1=root_part->getDaug(0)->getP4Lab();
1256  e2=root_part->getDaug(1)->getP4Lab();
1257 
1258  mee->Fill( (e1+e2).mass() );
1259 
1260  root_part->deleteTree();
1261 
1262  }while (count++<nevent);
1263 
1264  file->Write(); file->Close();
1265  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
1266 }
1267 
1268 void runFinalStates(int nevent, EvtGen &myGenerator) {
1269 
1270  //Parse the table of particles to find..
1271 
1272 
1273 
1274  EvtParser parser;
1275  parser.read(std::string("exampleFiles/finalstates.list"));
1276 
1277  std::vector< std::string > dList[20];
1278  int dListNum[20];
1279  std::vector< std::string > *dListItem = 0;
1280  std::string dListName[20];
1281  int ik,lk;
1282  std::string tk="";
1283  int tline=-1;
1284  std::string parent;
1285  for(ik=0;ik<parser.getNToken();ik++){
1286  lk=tline;
1287  tline=parser.getLineofToken(ik);
1288  tk=parser.getToken(ik);
1289 
1290  if ( lk!=tline&&tline>2) {
1291  if ( tline>1) {
1292  dList[tline-3]=*dListItem;
1293  dListItem=new std::vector<std::string>;
1294  dListNum[tline-3]=0;
1295  dListName[tline-2]=parser.getToken(ik);
1296  }
1297  }
1298  else{
1299  if ( tline==1 ) {
1300  //This is the parent particle name
1301  parent=parser.getToken(ik);
1302  dListItem=new std::vector<std::string>;
1303  }
1304  else{
1305  //This is one of the daughters
1306  if ( tline!=2 || (lk==tline) ) {
1307  dListItem->push_back(parser.getToken(ik));
1308  }
1309  if ( tline==2 && (lk!=tline) ) {
1310  dListName[tline-2]=parser.getToken(ik);
1311  }
1312  }
1313  }
1314  }
1315  dList[tline-2]=*dListItem;
1316  dListNum[tline-2]=0;
1317 
1318 
1319  static EvtId parId=EvtPDL::getId(parent);
1320  int count=0;
1321  do{
1322 
1323  if (count==1000*(count/1000)) {
1324  //if (count==1*(count/1)) {
1325  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Event:"<< count << std::endl;
1326  //EvtGenReport(EVTGEN_INFO,"EvtGen") << HepRandom::getTheSeed()<<std::endl;
1327  }
1328  EvtVector4R p_init(EvtPDL::getMass(parId),0.0,0.0,0.0);
1329 
1330  EvtParticle* root_part=EvtParticleFactory::particleFactory(parId,
1331  p_init);
1332  if ( parent=="Upsilon(4S)") {
1333  root_part->setVectorSpinDensity();
1334  }
1335  else{
1336  root_part->setDiagonalSpinDensity();
1337  }
1338 
1339 
1340  myGenerator.generateDecay(root_part);
1341 
1342  EvtParticle* p = root_part;
1343 
1344  std::vector<std::string> fs=findFinalState(p);
1345 
1346  int j;
1347  for(j=0; j<(tline-1); j++) {
1348  std::vector<std::string> temp=dList[j];
1349  if ( temp.size() == fs.size() ) {
1350  bool foundIt=true;
1351  unsigned int k, l;
1352  std::vector<bool> alreadyUsed(temp.size());
1353  for(k=0; k<temp.size(); k++) {
1354  bool foundThisOne=false;
1355  for(l=0; l<temp.size(); l++) {
1356  if ( k==0 ) alreadyUsed[l]=false;
1357  if ( foundThisOne||alreadyUsed[l] ) continue;
1358  if ( temp[k]==fs[l] ) {
1359  alreadyUsed[l]=true;
1360  foundThisOne=true;
1361  // EvtGenReport(EVTGEN_INFO,"EvtGen") << "found daughter " << k << " " << l << std::endl;
1362  }
1363  }
1364  if ( !foundThisOne ) foundIt=false;
1365  }
1366  if ( foundIt ) {//EvtGenReport(EVTGEN_INFO,"EvtGen") << "found a cand \n"; (histo1[j])->Fill(0.5);
1367  //EvtGenReport(EVTGEN_INFO,"EvtGen") << "found one " << j << std::endl;
1368  dListNum[j]++;}
1369  }
1370  }
1371 
1372 
1373 
1374  root_part->deleteTree();
1375  count++;
1376  }while(count<nevent);
1377  int j;
1378  for (j=0; j<(tline-1) ; j++) EvtGenReport(EVTGEN_INFO,"EvtGen") << dListName[j].c_str() << " " << j << " " << dListNum[j] << " " << count << " "<< (dListNum[j]/(1.0*count)) << std::endl;
1379 
1380  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
1381 
1382 }
1383 
1384 std::vector<std::string> findFinalState( EvtParticle *tree){
1385 
1386  EvtParticle *p=tree;
1387  std::vector<std::string> fs;
1388  static EvtId ep=EvtPDL::getId(std::string("e+"));
1389  static EvtId em=EvtPDL::getId(std::string("e-"));
1390  static EvtId kp=EvtPDL::getId(std::string("K+"));
1391  static EvtId km=EvtPDL::getId(std::string("K-"));
1392  static EvtId mup=EvtPDL::getId(std::string("mu+"));
1393  static EvtId mum=EvtPDL::getId(std::string("mu-"));
1394  static EvtId pip=EvtPDL::getId(std::string("pi+"));
1395  static EvtId pim=EvtPDL::getId(std::string("pi-"));
1396  static EvtId pi0=EvtPDL::getId(std::string("pi0"));
1397  static EvtId pr=EvtPDL::getId(std::string("p+"));
1398  static EvtId apr=EvtPDL::getId(std::string("anti-p-"));
1399  static EvtId ne=EvtPDL::getId(std::string("n0"));
1400  static EvtId ane=EvtPDL::getId(std::string("anti-n0"));
1401 
1402 
1403  do{
1404  EvtId type=p->getId();
1405 
1406  if (type==ep) fs.push_back(std::string("e+"));
1407  if (type==em) fs.push_back(std::string("e-"));
1408  if (type==mup) fs.push_back(std::string("mu+"));
1409  if (type==mum) fs.push_back(std::string("mu-"));
1410  if (type==kp) fs.push_back(std::string("K+"));
1411  if (type==km) fs.push_back(std::string("K-"));
1412  if (type==pip) fs.push_back(std::string("pi+"));
1413  if (type==pim) fs.push_back(std::string("pi-"));
1414  if (type==pi0) fs.push_back(std::string("pi0"));
1415  if (type==pr) fs.push_back(std::string("p+"));
1416  if (type==apr) fs.push_back(std::string("anti-p-"));
1417  if (type==ne) fs.push_back(std::string("n0"));
1418  if (type==ane) fs.push_back(std::string("anti-n0"));
1419 
1420  p=p->nextIter();
1421 
1422  }while(p!=0);
1423 
1424  return fs;
1425 
1426 }
1427 void runTrackMult(int nevent, EvtGen &myGenerator) {
1428 
1429  TFile *file=new TFile("trackmult.root","RECREATE");
1430 
1431  TH1F* trackAll = new TH1F("trackAll","trackAll",12,1.0,25.0);
1432  TH1F* trackNoSL = new TH1F("trackNoSL","trackNoSL",12,1.0,25.0);
1433  TH1F* track1SL = new TH1F("track1SL","track1SL",12,1.0,25.0);
1434  TH1F* track2SL = new TH1F("track2SL","track2SL",12,1.0,25.0);
1435 
1436  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
1437 
1438  static EvtId B0=EvtPDL::getId(std::string("B0"));
1439  static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
1440  static EvtId BP=EvtPDL::getId(std::string("B+"));
1441  static EvtId BM=EvtPDL::getId(std::string("B-"));
1442 
1443  //look for these tracks in generic events
1444  static EvtId ep=EvtPDL::getId(std::string("e+"));
1445  static EvtId em=EvtPDL::getId(std::string("e-"));
1446  static EvtId mup=EvtPDL::getId(std::string("mu+"));
1447  static EvtId mum=EvtPDL::getId(std::string("mu-"));
1448  static EvtId pip=EvtPDL::getId(std::string("pi+"));
1449  static EvtId pim=EvtPDL::getId(std::string("pi-"));
1450  static EvtId kp=EvtPDL::getId(std::string("K+"));
1451  static EvtId km=EvtPDL::getId(std::string("K-"));
1452  static EvtId pp=EvtPDL::getId(std::string("p+"));
1453  static EvtId pm=EvtPDL::getId(std::string("anti-p-"));
1454 
1455  static EvtIdSet theTracks(ep,em,mup,mum,pip,pim,kp,km,pp,pm);
1456  static EvtIdSet theLeptons(ep,em,mup,mum);
1457  static EvtIdSet theBs(B0,B0B,BP,BM);
1458 
1459  int count=1;
1460 
1461  EvtParticle *p;
1462 
1463  myGenerator.readUDecay("exampleFiles/GENERIC.DEC");
1464 
1465  int totTracks=0;
1466  int totTracksNoSL=0;
1467  int totTracks1SL=0;
1468  int totTracks2SL=0;
1469  int totNoSL=0;
1470  int tot1SL=0;
1471  int tot2SL=0;
1472 
1473  do{
1474 
1475  int evTracks=0;
1476 
1477  if (count==1000*(count/1000)) {
1478  EvtGenReport(EVTGEN_INFO,"EvtGen") << count << std::endl;
1479  //EvtGenReport(EVTGEN_INFO,"EvtGen") << HepRandom::getTheSeed()<<std::endl;
1480  }
1481  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
1482 
1483  EvtParticle* root_part=EvtParticleFactory::particleFactory(UPS4,
1484  p_init);
1485  root_part->setVectorSpinDensity();
1486 
1487 
1488  myGenerator.generateDecay(root_part);
1489 
1490  p=root_part;
1491 
1492  int howManySL=0;
1493 
1494  do{
1495  if (theTracks.contains(p->getId())) {
1496  totTracks+=1;
1497  evTracks+=1;
1498  }
1499  if ( theLeptons.contains(p->getId())) {
1500  if ( p->getParent() ) {
1501  if ( theBs.contains(p->getParent()->getId())) howManySL+=1;
1502  }
1503  }
1504  p=p->nextIter(root_part);
1505 
1506  }while(p!=0);
1507 
1508  //Now need to figure out which histogram to book
1509  trackAll->Fill(evTracks);
1510  if ( howManySL==0 ) {trackNoSL->Fill(evTracks); totNoSL+=1; totTracksNoSL+=evTracks;}
1511  if ( howManySL==1 ) {track1SL->Fill(evTracks); tot1SL+=1; totTracks1SL+=evTracks;}
1512  if ( howManySL==2 ) {track2SL->Fill(evTracks); tot2SL+=1; totTracks2SL+=evTracks;}
1513 
1514  root_part->deleteTree();
1515  }while (count++<nevent);
1516 
1517  double aveMulti=float(totTracks)/float(nevent);
1518  double aveMultiNoSL=float(totTracksNoSL)/float(totNoSL);
1519  double aveMulti1SL=float(totTracks1SL)/float(tot1SL);
1520  double aveMulti2SL=float(totTracks2SL)/float(tot2SL);
1521  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Your average multiplicity="<<aveMulti<<std::endl;
1522  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Your average multiplicity for no B->semileptonic events="<<aveMultiNoSL<<std::endl;
1523  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Your average multiplicity for 1 B->semileptonic events="<<aveMulti1SL<<std::endl;
1524  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Your average multiplicity for 2 B->semileptonic events="<<aveMulti2SL<<std::endl;
1525  file->Write(); file->Close();
1526  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
1527 
1528 }
1529 
1530 
1531 void runGeneric(int neventOrig, EvtGen &myGenerator,
1532  std::string listfile) {
1533 
1534  int nevent=abs(neventOrig);
1535 
1536  //Parse the table of particles to find..
1537 
1538 
1539  TFile *file=new TFile("generic.root","RECREATE");
1540 
1541  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
1542  static EvtId VPHO=EvtPDL::getId(std::string("vpho"));
1543 
1544  static EvtId B0=EvtPDL::getId(std::string("B0"));
1545  static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
1546  static EvtId BP=EvtPDL::getId(std::string("B+"));
1547  static EvtId BM=EvtPDL::getId(std::string("B-"));
1548 
1549  static EvtIdSet theBs(B0B,B0,BP,BM);
1550  static EvtIdSet theB0B(B0B);
1551  static EvtIdSet theB0(B0);
1552  static EvtIdSet theBP(BP);
1553  static EvtIdSet theBM(BM);
1554 
1555  static EvtId D0=EvtPDL::getId(std::string("D0"));
1556  static EvtId D0B=EvtPDL::getId(std::string("anti-D0"));
1557  static EvtId DP=EvtPDL::getId(std::string("D+"));
1558  static EvtId DM=EvtPDL::getId(std::string("D-"));
1559 
1560  static EvtIdSet theDs(D0B,D0,DP,DM);
1561  static EvtIdSet theD0B(D0B);
1562  static EvtIdSet theD0(D0);
1563  static EvtIdSet theDP(DP);
1564  static EvtIdSet theDM(DM);
1565 
1566  int count;
1567 
1568  int stable_list[1];
1569  stable_list[0]=-1;
1570 
1571  EvtParticle *p;
1572 
1573  char udecay_name[100];
1574 
1575  strcpy(udecay_name,"exampleFiles/GENERIC.DEC");
1576  myGenerator.readUDecay(udecay_name);
1577 
1578  if (listfile!="") {
1579  EvtParser parser;
1580  if (parser.read(listfile)!=0){
1581  EvtGenReport(EVTGEN_ERROR,"EvtGen") << "Will terminate."<<std::endl;
1582  exit(-1);
1583  }
1584 
1585 
1586  std::vector<TH1F*> histo1(parser.getNToken());
1587  std::vector<TH1F*> histo2(parser.getNToken());
1588  std::vector<TH1F*> massHisto(parser.getNToken());
1589 
1590  int ik;
1591  std::string tk,tkname;
1592  for(ik=0;ik<(parser.getNToken()/2);ik++){
1593  tk=parser.getToken(2*ik);
1594  tkname=parser.getToken(1+2*ik);
1595  histo1[ik] = new TH1F(tkname.c_str(),tkname.c_str(), 30,0.0,3.0);
1596  char *directName;
1597  directName=new char[(strlen(tkname.c_str())+8)];
1598  directName = strcpy(directName,tkname.c_str());
1599  directName = strcat(directName,"Direct");
1600  histo2[ik] = new TH1F(directName,directName,
1601  30,0.0,3.0);
1602  delete directName;
1603 
1604  char *massName;
1605  massName=new char[(strlen(tkname.c_str())+4)];
1606  massName = strcpy(massName,tkname.c_str());
1607  massName = strcat(massName,"Mass");
1608  massHisto[ik] = new TH1F(massName,massName, 3000,0.0,5.0);
1609  delete massName;
1610  }
1611 
1612  count=1;
1613  std::vector<int> temp(parser.getNToken()/2,0);
1614  std::vector<int> tempB(parser.getNToken()/2,0);
1615  std::vector<int> tempB0B(parser.getNToken()/2,0);
1616  std::vector<int> tempB0(parser.getNToken()/2,0);
1617  std::vector<int> tempBP(parser.getNToken()/2,0);
1618  std::vector<int> tempBM(parser.getNToken()/2,0);
1619  std::vector<int> tempD(parser.getNToken()/2,0);
1620  std::vector<int> tempD0B(parser.getNToken()/2,0);
1621  std::vector<int> tempD0(parser.getNToken()/2,0);
1622  std::vector<int> tempDP(parser.getNToken()/2,0);
1623  std::vector<int> tempDM(parser.getNToken()/2,0);
1624 
1625  do{
1626  //EvtGenReport(EVTGEN_INFO,"EvtGen") << "new event\n";
1627  if (count==1000*(count/1000)) {
1628  EvtGenReport(EVTGEN_INFO,"EvtGen") << count << std::endl;
1629  //EvtGenReport(EVTGEN_INFO,"EvtGen") << HepRandom::getTheSeed()<<std::endl;
1630  }
1631  EvtVector4R p_init(sqrt(EvtPDL::getMass(UPS4)*EvtPDL::getMass(UPS4)+5.9*5.9),0.0,0.0,5.9);
1632 
1633  EvtParticle* root_part=0;
1634  if ( neventOrig > 0 ) {
1635  root_part=EvtParticleFactory::particleFactory(UPS4,p_init);
1636  }
1637  else{
1638  root_part=EvtParticleFactory::particleFactory(VPHO, p_init);
1639  }
1640 
1641  root_part->setVectorSpinDensity();
1642 
1643  myGenerator.generateDecay(root_part);
1644 
1645  p=root_part;
1646 
1647  //EvtStdHep stdhep;
1648  //stdhep.init();
1649  //root_part->makeStdHep(stdhep);
1650  //EvtGenReport(EVTGEN_INFO,"EvtGen") <<stdhep<<std::endl;
1651  //EvtGenReport(EVTGEN_INFO,"EvtGen") <<secondary<<std::endl;
1652  std::string token;
1653  int itok;
1654  for(itok=0;itok<(parser.getNToken()/2);itok++){
1655 
1656  token=parser.getToken(2*itok);
1657  //temp[itok]+=countInclusive(token,root_part);
1658  temp[itok]+=countInclusive(token,root_part,histo1[itok],massHisto[itok]);
1659  tempB[itok]+=countInclusiveParent(token,root_part,theBs,histo2[itok]);
1660  tempB0[itok]+=countInclusiveSubTree(token,root_part,theB0);
1661  tempB0B[itok]+=countInclusiveSubTree(token,root_part,theB0B);
1662  tempBP[itok]+=countInclusiveSubTree(token,root_part,theBP);
1663  tempBM[itok]+=countInclusiveSubTree(token,root_part,theBM);
1664  // tempD[itok]+=countInclusiveParent(token,root_part,theDs);
1665  // tempD0[itok]+=countInclusiveSubTree(token,root_part,theD0);
1666  // tempD0B[itok]+=countInclusiveSubTree(token,root_part,theD0B);
1667  // tempDP[itok]+=countInclusiveSubTree(token,root_part,theDP);
1668  // tempDM[itok]+=countInclusiveSubTree(token,root_part,theDM);
1669 
1670 
1671  }
1672 
1673  // numd0+=countInclusive("D0",root_part);
1674  // numd0b+=countInclusive("anti-D0",root_part);
1675  // numdp+=countInclusive("D+",root_part);
1676  // numdm+=countInclusive("D-",root_part);
1677 
1678  // root_part->printTree();
1679  root_part->deleteTree();
1680  }while (count++<nevent);
1681 
1682  int itok;
1683  std::string token;
1684  for(itok=0;itok<(parser.getNToken()/2);itok++){
1685 
1686  token=parser.getToken(2*itok);
1687  float br=0.5*float(temp[itok])/float(nevent);
1688  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Found "<<temp[itok]<<" "<<token.c_str()
1689  << " in " << nevent << " events. Average number of "
1690  << token.c_str()<<" per B meson="<<br<<std::endl;
1691 
1692  br=0.5*float(tempB[itok])/float(nevent);
1693  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Found "<<tempB[itok]<<" "<<token.c_str()
1694  << " produced directly in decays of B mesons avg. br.fr.="
1695  <<br<<std::endl;
1696  br=2.0*float(tempB0[itok])/float(nevent);
1697  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Found "<<tempB0[itok]<<" "<<token.c_str()
1698  << " in decay tree of B0, br.fr.="<<br<<std::endl;
1699  br=2.0*float(tempB0B[itok])/float(nevent);
1700  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Found "<<tempB0B[itok]<<" "<<token.c_str()
1701  << " in decay tree of anti-B0, br.fr.="<<br<<std::endl;
1702  br=2.0*float(tempBP[itok])/float(nevent);
1703  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Found "<<tempBP[itok]<<" "<<token.c_str()
1704  << " in decay tree of B+, br.fr.="<<br<<std::endl;
1705  br=2.0*float(tempBM[itok])/float(nevent);
1706  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Found "<<tempBM[itok]<<" "<<token.c_str()
1707  << " in decay tree of B-, br.fr.="<<br<<std::endl;
1708 
1709  // br=0.5*float(tempD[itok])/float(numd0+numd0b+numdm+numdp);
1710  // EvtGenReport(EVTGEN_INFO,"EvtGen") << "Found "<<tempD[itok]<<" "<<token
1711  // << " produced directly in decays of D mesons avg. br.fr.="
1712  // <<br<<std::endl;
1713  // br=2.0*float(tempD0[itok])/float(numd0);
1714  // EvtGenReport(EVTGEN_INFO,"EvtGen") << "Found "<<tempD0[itok]<<" "<<token
1715  // << " in decay of D0, br.fr.="<<br<<std::endl;
1716  // br=2.0*float(tempD0B[itok])/float(numd0b);
1717  // EvtGenReport(EVTGEN_INFO,"EvtGen") << "Found "<<tempD0B[itok]<<" "<<token
1718  // << " in decay of anti-D0, br.fr.="<<br<<std::endl;
1719  // br=2.0*float(tempDP[itok])/float(numdp);
1720  // EvtGenReport(EVTGEN_INFO,"EvtGen") << "Found "<<tempDP[itok]<<" "<<token
1721  // << " in decay of D+, br.fr.="<<br<<std::endl;
1722  // br=2.0*float(tempDM[itok])/float(numdm);
1723  // EvtGenReport(EVTGEN_INFO,"EvtGen") << "Found "<<tempDM[itok]<<" "<<token
1724  // << " in decay of D-, br.fr.="<<br<<std::endl;
1725  EvtGenReport(EVTGEN_INFO,"EvtGen") << "*******************************************\n";
1726  }
1727  }
1728  else{
1729  count=1;
1730  do{
1731 
1732  if (count==1000*(count/1000)) {
1733  EvtGenReport(EVTGEN_INFO,"EvtGen") << count << std::endl;
1734  //EvtGenReport(EVTGEN_INFO,"EvtGen") << HepRandom::getTheSeed()<<std::endl;
1735  }
1736  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
1737 
1738 
1739  EvtParticle *root_part=0;
1740  if ( neventOrig > 0 ) {
1741  root_part=EvtParticleFactory::particleFactory(UPS4,p_init);
1742  }
1743  else{
1744  root_part=EvtParticleFactory::particleFactory(VPHO, p_init);
1745  }
1746 
1747  root_part->setVectorSpinDensity();
1748 
1749 
1750  myGenerator.generateDecay(root_part);
1751 
1752  p=root_part;
1753 
1754  root_part->deleteTree();
1755 
1756  }while (count++<nevent);
1757 
1758 
1759  }
1760  file->Write(); file->Close();
1761 
1762  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
1763 
1764 }
1765 
1766 void runKstarnunu(int nevent, EvtGen &myGenerator) {
1767 
1768  static EvtId B0=EvtPDL::getId(std::string("B0"));
1769  static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
1770 
1771  TFile *file=new TFile("kstarnunu.root", "RECREATE");
1772 
1773  TH1F* q2 = new TH1F("h1","q2",
1774  50,0.0,25.0);
1775  TH1F* enu = new TH1F("h2","Neutrino energy",
1776  50,0.0,5.0);
1777  TH1F* x = new TH1F("h3","Total neutrino energy/B mass",
1778  50,0.5,0.9);
1779 
1780 
1781  int count;
1782 
1783  EvtVector4R kstar,nu,nub;
1784  char udecay_name[100];
1785 
1786  strcpy(udecay_name,"exampleFiles/KSTARNUNU.DEC");
1787  //EvtGen myGenerator(decay_name,pdttable_name,myRandomEngine);
1788  myGenerator.readUDecay(udecay_name);
1789 
1790  count=1;
1791 
1792  do{
1793 
1794  EvtVector4R p_init(EvtPDL::getMass(B0),0.0,0.0,0.0);
1795 
1796  EvtParticle* root_part=EvtParticleFactory::particleFactory(B0,
1797  p_init);
1798  root_part->setDiagonalSpinDensity();
1799 
1800  myGenerator.generateDecay(root_part);
1801 
1802  kstar=root_part->getDaug(0)->getP4Lab();
1803  nu=root_part->getDaug(1)->getP4Lab();
1804  nub=root_part->getDaug(2)->getP4Lab();
1805 
1806  q2->Fill( (nu+nub).mass2() );
1807  enu->Fill( nu.get(0) );
1808  x->Fill( (nu.get(0)+nub.get(0))/root_part->mass() );
1809 
1810  root_part->deleteTree();
1811 
1812  }while (count++<nevent);
1813 
1814  file->Write(); file->Close();
1815  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
1816 }
1817 
1818 void runBsmix(int nevent, EvtGen &myGenerator) {
1819 
1820  static EvtId BS0=EvtPDL::getId(std::string("B_s0"));
1821  static EvtId BSB=EvtPDL::getId(std::string("anti-B_s0"));
1822 
1823  TFile *file=new TFile("bsmix.root", "RECREATE");
1824 
1825  TH1F* tmix = new TH1F("h1","tmix (mm)",100,0.0,5.0);
1826  TH1F* tnomix = new TH1F("h2","tnomix (mm)",100,0.0,5.0);
1827 
1828 
1829  int count;
1830 
1831  char udecay_name[100];
1832  strcpy(udecay_name,"exampleFiles/BSMIX.DEC");
1833  //EvtGen myGenerator(decay_name,pdttable_name,myRandomEngine);
1834  myGenerator.readUDecay(udecay_name);
1835 
1836  count=1;
1837 
1838  do{
1839 
1840  EvtVector4R p_init(EvtPDL::getMass(BS0),0.0,0.0,0.0);
1841 
1842  EvtParticle* root_part=EvtParticleFactory::particleFactory(BS0,
1843  p_init);
1844  root_part->setDiagonalSpinDensity();
1845 
1846  myGenerator.generateDecay(root_part);
1847 
1848  double t=root_part->getLifetime();
1849  int mix=0;
1850 
1851  if (root_part->getNDaug()==1){
1852  if (root_part->getDaug(0)->getId()==BSB){
1853  mix=1;
1854  }
1855  }
1856 
1857  if (mix==0) tnomix->Fill(t);
1858  if (mix==1) tmix->Fill(t);
1859 
1860  root_part->deleteTree();
1861 
1862  }while (count++<nevent);
1863 
1864  file->Write(); file->Close();
1865  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
1866 
1867 }
1868 
1869 void runSemic(int nevent, EvtGen &myGenerator) {
1870 
1871  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
1872  static EvtId VPHO=EvtPDL::getId(std::string("vpho"));
1873  static EvtId GAMM=EvtPDL::getId(std::string("gamma"));
1874  static EvtId PSI=EvtPDL::getId(std::string("J/psi"));
1875  static EvtId B0=EvtPDL::getId(std::string("B0"));
1876  static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
1877  static EvtId BS0=EvtPDL::getId(std::string("B_s0"));
1878  static EvtId BSB=EvtPDL::getId(std::string("anti-B_s0"));
1879 
1880  static EvtId PI0=EvtPDL::getId(std::string("pi0"));
1881  static EvtId PIP=EvtPDL::getId(std::string("pi+"));
1882  static EvtId PIM=EvtPDL::getId(std::string("pi-"));
1883 
1884  static EvtId EP=EvtPDL::getId(std::string("e+"));
1885  static EvtId KP=EvtPDL::getId(std::string("K+"));
1886  static EvtId MUP=EvtPDL::getId(std::string("mu+"));
1887  static EvtId EM=EvtPDL::getId(std::string("e-"));
1888  static EvtId KM=EvtPDL::getId(std::string("K-"));
1889  static EvtId MUM=EvtPDL::getId(std::string("mu-"));
1890 
1891  static EvtId DST0=EvtPDL::getId(std::string("D*0"));
1892  static EvtId DSTB=EvtPDL::getId(std::string("anti-D*0"));
1893  static EvtId DSTP=EvtPDL::getId(std::string("D*+"));
1894  static EvtId DSTM=EvtPDL::getId(std::string("D*-"));
1895  static EvtId D0=EvtPDL::getId(std::string("D0"));
1896  static EvtId D0B=EvtPDL::getId(std::string("anti-D0"));
1897  static EvtId DP=EvtPDL::getId(std::string("D+"));
1898  static EvtId DM=EvtPDL::getId(std::string("D-"));
1899 
1900  static EvtId K0L=EvtPDL::getId(std::string("K_L0"));
1901 
1902  static EvtId D1P1P=EvtPDL::getId(std::string("D_1+"));
1903  static EvtId D1P1N=EvtPDL::getId(std::string("D_1-"));
1904  static EvtId D1P10=EvtPDL::getId(std::string("D_10"));
1905  static EvtId D1P1B=EvtPDL::getId(std::string("anti-D_10"));
1906 
1907  static EvtId D3P2P=EvtPDL::getId(std::string("D_2*+"));
1908  static EvtId D3P2N=EvtPDL::getId(std::string("D_2*-"));
1909  static EvtId D3P20=EvtPDL::getId(std::string("D_2*0"));
1910  static EvtId D3P2B=EvtPDL::getId(std::string("anti-D_2*0"));
1911 
1912  static EvtId D3P1P=EvtPDL::getId(std::string("D'_1+"));
1913  static EvtId D3P1N=EvtPDL::getId(std::string("D'_1-"));
1914  static EvtId D3P10=EvtPDL::getId(std::string("D'_10"));
1915  static EvtId D3P1B=EvtPDL::getId(std::string("anti-D'_10"));
1916 
1917  static EvtId D3P0P=EvtPDL::getId(std::string("D_0*+"));
1918  static EvtId D3P0N=EvtPDL::getId(std::string("D_0*-"));
1919  static EvtId D3P00=EvtPDL::getId(std::string("D_0*0"));
1920  static EvtId D3P0B=EvtPDL::getId(std::string("anti-D_0*0"));
1921 
1922  static EvtId D21S0P=EvtPDL::getId(std::string("D(2S)+"));
1923  static EvtId D21S0N=EvtPDL::getId(std::string("D(2S)-"));
1924  static EvtId D21S00=EvtPDL::getId(std::string("D(2S)0"));
1925  static EvtId D21S0B=EvtPDL::getId(std::string("anti-D(2S)0"));
1926 
1927  static EvtId D23S1P=EvtPDL::getId(std::string("D*(2S)+"));
1928  static EvtId D23S1N=EvtPDL::getId(std::string("D*(2S)-"));
1929  static EvtId D23S10=EvtPDL::getId(std::string("D*(2S)0"));
1930  static EvtId D23S1B=EvtPDL::getId(std::string("anti-D*(2S)0"));
1931 
1932  static EvtIdSet radExitDstar(D23S1P,D23S1N,D23S10,D23S1B);
1933 
1934 
1935  TFile *file=new TFile("semic.root", "RECREATE");
1936 
1937  TH1F* Dpe_q2 = new TH1F("h11","q2 for B0B ->D+ e- nu",50,0.0,12.0);
1938  TH1F* Dpe_elep = new TH1F("h12","Elep for B0B ->D+ e- nu",50,0.0,2.5);
1939  TH1F* Dme_q2 = new TH1F("h13","q2 for B0 ->D- e+ nu",50,0.0,12.0);
1940  TH1F* Dme_elep = new TH1F("h14","Elep for B0 ->D- e+ nu",50,0.0,2.5);
1941  TH1F* D0e_q2 = new TH1F("h15","q2 for B- ->D0 e- nu",50,0.0,12.0);
1942  TH1F* D0e_elep = new TH1F("h16","Elep for B- ->D0 e- nu",50,0.0,2.5);
1943  TH1F* D0Be_q2 = new TH1F("h17","q2 for B+ ->D0B e+ nu",50,0.0,12.0);
1944  TH1F* D0Be_elep = new TH1F("h18","Elep for B+ ->D0B e+ nu",50,0.0,2.5);
1945 
1946  TH1F* Dstpe_q2 = new TH1F("h21","q2 for B0B ->D*+ e- nu",50,0.0,12.0);
1947  TH1F* Dstpe_elep = new TH1F("h22","Elep for B0B ->D*+ e- nu",50,0.0,2.5);
1948  TH1F* Dstme_q2 = new TH1F("h23","q2 for B0 ->D*- e+ nu",50,0.0,12.0);
1949  TH1F* Dstme_elep = new TH1F("h24","Elep for B0 ->D*- e+ nu",50,0.0,2.5);
1950  TH1F* Dst0e_q2 = new TH1F("h25","q2 for B- ->D*0 e- nu",50,0.0,12.0);
1951  TH1F* Dst0e_elep = new TH1F("h26","Elep for B*- ->D*0 e- nu",50,0.0,2.5);
1952  TH1F* Dst0Be_q2 = new TH1F("h27","q2 for B+ ->D*0B e+ nu",50,0.0,12.0);
1953  TH1F* Dst0Be_elep = new TH1F("h28","Elep for B+ ->D*0B e+ nu",50,0.0,2.5);
1954 
1955  TH1F* D1P1pe_q2 = new TH1F("h31","q2 for B0B ->1P1+ e- nu",50,0.0,12.0);
1956  TH1F* D1P1pe_elep = new TH1F("h32","Elep for B0B ->1P1+ e- nu",50,0.0,2.5);
1957  TH1F* D1P1me_q2 = new TH1F("h33","q2 for B0 ->1P1- e+ nu",50,0.0,12.0);
1958  TH1F* D1P1me_elep = new TH1F("h34","Elep for B0 ->1P1- e+ nu",50,0.0,2.5);
1959  TH1F* D1P10e_q2 = new TH1F("h35","q2 for B- ->1P10 e- nu",50,0.0,12.0);
1960  TH1F* D1P10e_elep = new TH1F("h36","Elep for B*- ->1P10 e- nu",50,0.0,2.5);
1961  TH1F* D1P10Be_q2 = new TH1F("h37","q2 for B+ ->1P1B e+ nu",50,0.0,12.0);
1962  TH1F* D1P10Be_elep = new TH1F("h38","Elep for B+ ->1P1B e+ nu",50,0.0,2.5);
1963 
1964  TH1F* D3P0pe_q2 = new TH1F("h41","q2 for B0B ->3P0+ e- nu",50,0.0,12.0);
1965  TH1F* D3P0pe_elep = new TH1F("h42","Elep for B0B ->3P0+ e- nu",50,0.0,2.5);
1966  TH1F* D3P0me_q2 = new TH1F("h43","q2 for B0 ->3P0- e+ nu",50,0.0,12.0);
1967  TH1F* D3P0me_elep = new TH1F("h44","Elep for B0 ->3P0- e+ nu",50,0.0,2.5);
1968  TH1F* D3P00e_q2 = new TH1F("h45","q2 for B- ->3P00 e- nu",50,0.0,12.0);
1969  TH1F* D3P00e_elep = new TH1F("h46","Elep for B*- ->3P00 e- nu",50,0.0,2.5);
1970  TH1F* D3P00Be_q2 = new TH1F("h47","q2 for B+ ->3P0B e+ nu",50,0.0,12.0);
1971  TH1F* D3P00Be_elep = new TH1F("h48","Elep for B+ ->3P0B e+ nu",50,0.0,2.5);
1972 
1973  TH1F* D3P1pe_q2 = new TH1F("h51","q2 for B0B ->3P1+ e- nu",50,0.0,12.0);
1974  TH1F* D3P1pe_elep = new TH1F("h52","Elep for B0B ->3P1+ e- nu",50,0.0,2.5);
1975  TH1F* D3P1me_q2 = new TH1F("h53","q2 for B0 ->3P1- e+ nu",50,0.0,12.0);
1976  TH1F* D3P1me_elep = new TH1F("h54","Elep for B0 ->3P1- e+ nu",50,0.0,2.5);
1977  TH1F* D3P10e_q2 = new TH1F("h55","q2 for B- ->3P10 e- nu",50,0.0,12.0);
1978  TH1F* D3P10e_elep = new TH1F("h56","Elep for B*- ->3P10 e- nu",50,0.0,2.5);
1979  TH1F* D3P10Be_q2 = new TH1F("h57","q2 for B+ ->3P1B e+ nu",50,0.0,12.0);
1980  TH1F* D3P10Be_elep = new TH1F("h58","Elep for B+ ->3P1B e+ nu",50,0.0,2.5);
1981 
1982  TH1F* D3P2pe_q2 = new TH1F("h61","q2 for B0B ->3P2+ e- nu",50,0.0,12.0);
1983  TH1F* D3P2pe_elep = new TH1F("h62","Elep for B0B ->3P2+ e- nu",50,0.0,2.5);
1984  TH1F* D3P2me_q2 = new TH1F("h63","q2 for B0 ->3P2- e+ nu",50,0.0,12.0);
1985  TH1F* D3P2me_elep = new TH1F("h64","Elep for B0 ->3P2- e+ nu",50,0.0,2.5);
1986  TH1F* D3P20e_q2 = new TH1F("h65","q2 for B- ->3P20 e- nu",50,0.0,12.0);
1987  TH1F* D3P20e_elep = new TH1F("h66","Elep for B*- ->3P20 e- nu",50,0.0,2.5);
1988  TH1F* D3P20Be_q2 = new TH1F("h67","q2 for B+ ->3P2B e+ nu",50,0.0,12.0);
1989  TH1F* D3P20Be_elep = new TH1F("h68","Elep for B+ ->3P2B e+ nu",50,0.0,2.5);
1990 
1991 
1992  TH1F* phiL = new TH1F("h69","phi",50,-3.1416,3.1416);
1993 
1994 
1995  int count;
1996 
1997  char udecay_name[100];
1998  strcpy(udecay_name,"exampleFiles/SEMIC.DEC");
1999  //EvtGen myGenerator(decay_name,pdttable_name,myRandomEngine);
2000  myGenerator.readUDecay(udecay_name);
2001 
2002  count=1;
2003 
2004  do{
2005 
2006  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
2007 
2008  EvtParticle* root_part=EvtParticleFactory::particleFactory(UPS4,
2009  p_init);
2010  root_part->setVectorSpinDensity();
2011 
2012  myGenerator.generateDecay(root_part);
2013 
2014  int i;
2015 
2016  for (i=0;i<2;i++){
2017 
2018  EvtId meson=root_part->getDaug(i)->getDaug(0)->getId();
2019  EvtId lepton=root_part->getDaug(i)->getDaug(1)->getId();
2020  EvtVector4R lep=root_part->getDaug(i)->getDaug(1)->getP4Lab();
2021  phiL->Fill(atan2(lep.get(1),lep.get(2)));
2022  EvtVector4R nu=root_part->getDaug(i)->getDaug(2)->getP4Lab();
2023  double q2=(lep+nu).mass2();
2024  double elep=root_part->getDaug(i)->getDaug(1)->getP4().get(0);
2025  if (meson==DP&&lepton==EM){
2026  Dpe_q2->Fill(q2);
2027  Dpe_elep->Fill(elep);
2028  }
2029  if (meson==DM&&lepton==EP){
2030  Dme_q2->Fill(q2);
2031  Dme_elep->Fill(elep);
2032  }
2033  if (meson==D0&&lepton==EM){
2034  D0e_q2->Fill(q2);
2035  D0e_elep->Fill(elep);
2036  }
2037  if (meson==D0B&&lepton==EP){
2038  D0Be_q2->Fill(q2);
2039  D0Be_elep->Fill(elep);
2040  }
2041 
2042 
2043  if (meson==DSTP&&lepton==EM){
2044  Dstpe_q2->Fill(q2);
2045  Dstpe_elep->Fill(elep);
2046  }
2047  if (meson==DSTM&&lepton==EP){
2048  Dstme_q2->Fill(q2);
2049  Dstme_elep->Fill(elep);
2050  }
2051  if (meson==DST0&&lepton==EM){
2052  Dst0e_q2->Fill(q2);
2053  Dst0e_elep->Fill(elep);
2054  }
2055  if (meson==DSTB&&lepton==EP){
2056  Dst0Be_q2->Fill(q2);
2057  Dst0Be_elep->Fill(elep);
2058  }
2059 
2060 
2061  if (meson==D1P1P&&lepton==EM){
2062  D1P1pe_q2->Fill(q2);
2063  D1P1pe_elep->Fill(elep);
2064  }
2065  if (meson==D1P1N&&lepton==EP){
2066  D1P1me_q2->Fill(q2);
2067  D1P1me_elep->Fill(elep);
2068  }
2069  if (meson==D1P10&&lepton==EM){
2070  D1P10e_q2->Fill(q2);
2071  D1P10e_elep->Fill(elep);
2072  }
2073  if (meson==D1P1B&&lepton==EP){
2074  D1P10Be_q2->Fill(q2);
2075  D1P10Be_elep->Fill(elep);
2076  }
2077 
2078  if (meson==D3P0P&&lepton==EM){
2079  D3P0pe_q2->Fill(q2);
2080  D3P0pe_elep->Fill(elep);
2081  }
2082  if (meson==D3P0N&&lepton==EP){
2083  D3P0me_q2->Fill(q2);
2084  D3P0me_elep->Fill(elep);
2085  }
2086  if (meson==D3P00&&lepton==EM){
2087  D3P00e_q2->Fill(q2);
2088  D3P00e_elep->Fill(elep);
2089  }
2090  if (meson==D3P0B&&lepton==EP){
2091  D3P00Be_q2->Fill(q2);
2092  D3P00Be_elep->Fill(elep);
2093  }
2094 
2095  if (meson==D3P1P&&lepton==EM){
2096  D3P1pe_q2->Fill(q2);
2097  D3P1pe_elep->Fill(elep);
2098  }
2099  if (meson==D3P1N&&lepton==EP){
2100  D3P1me_q2->Fill(q2);
2101  D3P1me_elep->Fill(elep);
2102  }
2103  if (meson==D3P10&&lepton==EM){
2104  D3P10e_q2->Fill(q2);
2105  D3P10e_elep->Fill(elep);
2106  }
2107  if (meson==D3P1B&&lepton==EP){
2108  D3P10Be_q2->Fill(q2);
2109  D3P10Be_elep->Fill(elep);
2110  }
2111 
2112  if (meson==D3P2P&&lepton==EM){
2113  D3P2pe_q2->Fill(q2);
2114  D3P2pe_elep->Fill(elep);
2115  }
2116  if (meson==D3P2N&&lepton==EP){
2117  D3P2me_q2->Fill(q2);
2118  D3P2me_elep->Fill(elep);
2119  }
2120  if (meson==D3P20&&lepton==EM){
2121  D3P20e_q2->Fill(q2);
2122  D3P20e_elep->Fill(elep);
2123  }
2124  if (meson==D3P2B&&lepton==EP){
2125  D3P20Be_q2->Fill(q2);
2126  D3P20Be_elep->Fill(elep);
2127  }
2128 
2129 
2130  }
2131 
2132  root_part->deleteTree();
2133 
2134  }while (count++<nevent);
2135 
2136  file->Write(); file->Close();
2137  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
2138 }
2139 
2140 
2141 void runKstarll(int nevent, EvtGen &myGenerator) {
2142  TFile *file=new TFile("kstkmm.root", "RECREATE");
2143 
2144  TH2F* _dalitz = new TH2F("h1","q^2! vs Elep",
2145  70,0.0,3.5,60,0.0,30.0);
2146 
2147 
2148  TH1F* _ctl = new TH1F("h2","ctl",50,-1.0,1.0);
2149 
2150 
2151  TH1F* _q2 = new TH1F("h3","q2",50,0.0,25.0);
2152 
2153  TH1F* _q2low = new TH1F("h4","q2 (low)",
2154  50,0.0,1.0);
2155  TH1F* _q2lowlow = new TH1F("h5","q2 (lowlow)",
2156  50,0.0,0.00001);
2157 
2158  TH1F* _phi = new TH1F("h6","phi",50,-EvtConst::pi,EvtConst::pi);
2159 
2160  TH1F* _chi = new TH1F("h7","chi",50,0.0,EvtConst::twoPi);
2161 
2162  TH1F* _chictl = new TH1F("h8","chictl",50,0.0,EvtConst::twoPi);
2163 
2164 
2165  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
2166  static EvtId B0=EvtPDL::getId(std::string("B0"));
2167 
2168  int count=1;
2169 
2170  EvtVector4R kstar,l1,l2;
2171  EvtVector4R k,pi,b;
2172 
2173  char udecay_name[100];
2174  strcpy(udecay_name,"exampleFiles/KSTARLL.DEC");
2175  //EvtGen myGenerator(decay_name,pdttable_name,myRandomEngine);
2176 
2177  myGenerator.readUDecay(udecay_name);
2178 
2179  std::vector<double> q2low(5);
2180  std::vector<double> q2high(5);
2181  std::vector<int> counts(5);
2182 
2183  //kee
2184  //int n=4;
2185  //q2low[0]=0.0; q2high[0]=4.5;
2186  //q2low[1]=4.5; q2high[1]=8.41;
2187  //q2low[2]=10.24; q2high[2]=12.96;
2188  //q2low[3]=14.06; q2high[3]=30.0;
2189 
2190  //kmm
2191  //int n=4;
2192  //q2low[0]=0.0; q2high[0]=4.5;
2193  //q2low[1]=4.5; q2high[1]=9.0;
2194  //q2low[2]=10.24; q2high[2]=12.96;
2195  //q2low[3]=14.06; q2high[3]=30.0;
2196 
2197  //K*ee
2198  int n=5;
2199  q2low[0]=0.0; q2high[0]=0.1;
2200  q2low[1]=0.1; q2high[1]=4.5;
2201  q2low[2]=4.5; q2high[2]=8.41;
2202  q2low[3]=10.24; q2high[3]=12.96;
2203  q2low[4]=14.06; q2high[4]=30.0;
2204 
2205  //K*mm
2206  //int n=5;
2207  //q2low[0]=0.0; q2high[0]=0.1;
2208  //q2low[1]=0.1; q2high[1]=4.5;
2209  //q2low[2]=4.5; q2high[2]=9.0;
2210  //q2low[3]=10.24; q2high[3]=12.96;
2211  //q2low[4]=14.06; q2high[4]=30.0;
2212 
2213  do{
2214 
2215 
2216  EvtVector4R p_init(EvtPDL::getMass(B0),0.0,0.0,0.0);
2217 
2218  EvtParticle* root_part=EvtParticleFactory::particleFactory(B0,
2219  p_init);
2220  root_part->setDiagonalSpinDensity();
2221 
2222  myGenerator.generateDecay(root_part);
2223 
2224  // root_part->printTree();
2225  //root_part->getDaug(0)->printTree();
2226  //root_part->getDaug(1)->printTree();
2227  //root_part->getDaug(2)->printTree();
2228 
2229  kstar=root_part->getDaug(0)->getP4Lab();
2230  l1=root_part->getDaug(1)->getP4Lab();
2231  l2=root_part->getDaug(2)->getP4Lab();
2232 
2233  b=root_part->getP4();
2234  k=root_part->getDaug(0)->getDaug(0)->getP4Lab();
2235  pi=root_part->getDaug(0)->getDaug(1)->getP4Lab();
2236 
2237  double qsq=(l1+l2).mass2();
2238 
2239  for (int j=0;j<n;j++){
2240  if (qsq>q2low[j]&&qsq<q2high[j]) counts[j]++;
2241  }
2242 
2243  _q2->Fill( (l1+l2).mass2() );
2244  _q2low->Fill( (l1+l2).mass2() );
2245  _q2lowlow->Fill( (l1+l2).mass2() );
2246 
2247  _ctl->Fill(EvtDecayAngle((l1+l2+kstar),(l1+l2),l1));
2248 
2249  _dalitz->Fill(l1.get(0),(l1+l2).mass2(),1.0);
2250 
2251  root_part->deleteTree();
2252 
2253  _phi->Fill(atan2(l1.get(1),l1.get(2)));
2254 
2255  _chi->Fill(EvtDecayAngleChi(b,k,pi,l1,l2));
2256 
2257  if (EvtDecayAngle((l1+l2+kstar),(l1+l2),l1)>0){
2258  _chictl->Fill(EvtDecayAngleChi(b,k,pi,l1,l2));
2259  }
2260  EvtGenReport(EVTGEN_INFO,"EvtGen") << "count:"<<count<<" "<<(l1+l2).mass2()<<std::endl;
2261 
2262  }while (count++<nevent);
2263 
2264  for (int j=0;j<n;j++){
2265  std::cout << "["<<q2low[j]<<".."<<q2high[j]<<"]="<<counts[j]<<std::endl;
2266  }
2267 
2268  file->Write(); file->Close();
2269  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
2270 
2271 }
2272 
2273 void runKll(int nevent, EvtGen &myGenerator) {
2274  TFile *file=new TFile("ksem.root", "RECREATE");
2275 
2276  TH2F* _dalitz = new TH2F("h1","q^2! vs Elep",
2277  70,0.0,3.5,60,0.0,30.0);
2278 
2279 
2280  TH1F* _ctl = new TH1F("h2","ctl",50,-1.0,1.0);
2281 
2282 
2283  TH1F* _q2 = new TH1F("h3","q2",50,0.0,25.0);
2284 
2285  TH1F* _q2low = new TH1F("h4","q2 (low)",
2286  50,0.0,1.0);
2287  TH1F* _q2lowlow = new TH1F("h5","q2 (lowlow)",
2288  50,0.0,0.00001);
2289 
2290  TH1F* _phi = new TH1F("h6","phi",50,-EvtConst::pi,EvtConst::pi);
2291 
2292  // TH1F* _chi = new TH1F("h7","chi",50,0.0,EvtConst::twoPi);
2293 
2294  // TH1F* _chictl = new TH1F("h8","chictl",50,0.0,EvtConst::twoPi);
2295 
2296 
2297  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
2298  static EvtId B0=EvtPDL::getId(std::string("B0"));
2299 
2300  int count=1;
2301 
2302  EvtVector4R k,l1,l2;
2303 
2304  char udecay_name[100];
2305  strcpy(udecay_name,"exampleFiles/KLL.DEC");
2306  //EvtGen myGenerator(decay_name,pdttable_name,myRandomEngine);
2307 
2308  myGenerator.readUDecay(udecay_name);
2309 
2310  std::vector<double> q2low(5);
2311  std::vector<double> q2high(5);
2312  std::vector<int> counts(5);
2313 
2314  //kee
2315  // int n=4;
2316  //q2low[0]=0.0; q2high[0]=4.5;
2317  //q2low[1]=4.5; q2high[1]=8.41;
2318  //q2low[2]=10.24; q2high[2]=12.96;
2319  //q2low[3]=14.06; q2high[3]=30.0;
2320 
2321  //kmm
2322  int n=4;
2323  q2low[0]=0.0; q2high[0]=4.5;
2324  q2low[1]=4.5; q2high[1]=9.0;
2325  q2low[2]=10.24; q2high[2]=12.96;
2326  q2low[3]=14.06; q2high[3]=30.0;
2327 
2328  //K*ee
2329  //int n=5;
2330  //q2low[0]=0.0; q2high[0]=0.1;
2331  //q2low[1]=0.1; q2high[1]=4.5;
2332  //q2low[2]=4.5; q2high[2]=8.41;
2333  //q2low[3]=10.24; q2high[3]=12.96;
2334  //q2low[4]=14.06; q2high[4]=30.0;
2335 
2336  //K*mm
2337  //int n=5;
2338  //q2low[0]=0.0; q2high[0]=0.1;
2339  //q2low[1]=0.1; q2high[1]=4.5;
2340  //q2low[2]=4.5; q2high[2]=9.0;
2341  //q2low[3]=10.24; q2high[3]=12.96;
2342  //q2low[4]=14.06; q2high[4]=30.0;
2343 
2344  do{
2345 
2346 
2347  EvtVector4R p_init(EvtPDL::getMass(B0),0.0,0.0,0.0);
2348 
2349  EvtParticle* root_part=EvtParticleFactory::particleFactory(B0,
2350  p_init);
2351  root_part->setDiagonalSpinDensity();
2352 
2353  myGenerator.generateDecay(root_part);
2354 
2355  // root_part->printTree();
2356  //root_part->getDaug(0)->printTree();
2357  //root_part->getDaug(1)->printTree();
2358  //root_part->getDaug(2)->printTree();
2359 
2360  k=root_part->getDaug(0)->getP4Lab();
2361  l1=root_part->getDaug(1)->getP4Lab();
2362  l2=root_part->getDaug(2)->getP4Lab();
2363 
2364  //b=root_part->getP4();
2365  // k=root_part->getDaug(0)->getDaug(0)->getP4Lab();
2366  // pi=root_part->getDaug(0)->getDaug(1)->getP4Lab();
2367 
2368  double qsq=(l1+l2).mass2();
2369 
2370  for (int j=0;j<n;j++){
2371  if (qsq>q2low[j]&&qsq<q2high[j]) counts[j]++;
2372  }
2373 
2374  _q2->Fill( (l1+l2).mass2() );
2375  _q2low->Fill( (l1+l2).mass2() );
2376  _q2lowlow->Fill( (l1+l2).mass2() );
2377 
2378  _ctl->Fill(EvtDecayAngle((l1+l2+k),(l1+l2),l1));
2379 
2380  _dalitz->Fill(l1.get(0),(l1+l2).mass2(),1.0);
2381 
2382  root_part->deleteTree();
2383 
2384  _phi->Fill(atan2(l1.get(1),l1.get(2)));
2385 
2386  //_chi->Fill(EvtDecayAngleChi(b,k,pi,l1,l2));
2387 
2388  //if (EvtDecayAngle((l1+l2+kstar),(l1+l2),l1)>0){
2389  // _chictl->Fill(EvtDecayAngleChi(b,k,pi,l1,l2));
2390  // }
2391  EvtGenReport(EVTGEN_INFO,"EvtGen") << "count:"<<count<<" "<<(l1+l2).mass2()<<std::endl;
2392 
2393  }while (count++<nevent);
2394 
2395  for (int j=0;j<n;j++){
2396  std::cout << "["<<q2low[j]<<".."<<q2high[j]<<"]="<<counts[j]<<std::endl;
2397  }
2398 
2399  file->Write(); file->Close();
2400  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
2401 
2402 }
2403 
2404 
2405 void runHll(int nevent, EvtGen &myGenerator, char* mode) {
2406  TString modename = mode;
2407  TString filename;
2408  filename = modename;
2409  filename = filename + "_nnlo.root";
2410  TFile *file=new TFile(filename, "RECREATE");
2411  TString decname;
2412  decname += modename;
2413  decname.ToUpper();
2414  decname = "exampleFiles/" + decname + ".DEC";
2415  char udecay_name[100];
2416  strcpy(udecay_name,decname);
2417 
2418  TH2F* _dalitz = new TH2F("h1","q^2! vs Elep",
2419  70,0.0,3.5,60,0.0,30.0);
2420 
2421 
2422  TH1F* _ctl = new TH1F("h2","ctl",50,-1.0,1.0);
2423 
2424 
2425  TH1F* _q2 = new TH1F("h3","q2",50,0.0,25.0);
2426 
2427  TH1F* _q2low = new TH1F("h4","q2 (low)",
2428  50,0.0,1.0);
2429  TH1F* _q2lowlow = new TH1F("h5","q2 (lowlow)",
2430  50,0.0,0.00001);
2431 
2432  TH1F* _phi = new TH1F("h6","phi",50,-EvtConst::pi,EvtConst::pi);
2433 
2434  TH1F* _chi = new TH1F("h7","chi",50,0.0,EvtConst::twoPi);
2435 
2436  TH1F* _chictl = new TH1F("h8","chictl",50,0.0,EvtConst::twoPi);
2437 
2438  EvtId B;
2439  if (modename == "kee" || modename == "kmm" ||
2440  modename == "kstksee" || modename == "kstksmm" ||
2441  modename == "piee" || modename == "pimm" ||
2442  modename == "rhoee" || modename == "rhomm")
2443  {
2444  B=EvtPDL::getId(std::string("B+"));
2445  }
2446  else
2447  {
2448  B=EvtPDL::getId(std::string("B0"));
2449  }
2450  int count = 1;
2451 
2452  EvtVector4R b,h,l1,l2;
2453  EvtVector4R hdaug1,hdaug2;
2454 
2455  myGenerator.readUDecay(udecay_name);
2456 
2457  std::vector<double> q2low(7);
2458  std::vector<double> q2high(7);
2459  std::vector<int> counts(7);
2460  int n;
2461  if (modename == "kee" || modename == "ksee" ||
2462  modename == "piee" || modename == "pi0ee" ||
2463  modename == "etaee" || modename == "etapee")
2464  {
2465  //kee
2466  n = 6;
2467  q2low[0] = 0.0; q2high[0] = 4.5;
2468  q2low[1] = 4.5; q2high[1] = 8.41;
2469  q2low[2] = 8.41; q2high[2] = 10.24;
2470  q2low[3] = 10.24; q2high[3] = 12.96;
2471  q2low[4] = 12.96; q2high[4] = 14.06;
2472  q2low[5] = 14.06; q2high[5] = 30.0;
2473  }
2474  else if (modename == "kmm" || modename == "ksmm" ||
2475  modename == "pimm" || modename == "pi0mm" ||
2476  modename == "etamm" || modename == "etapmm")
2477  {
2478  //kmm
2479  n = 6;
2480  q2low[0] = 0.0; q2high[0] = 4.5;
2481  q2low[1] = 4.5; q2high[1] = 9.0;
2482  q2low[2] = 9.0; q2high[2] = 10.24;
2483  q2low[3] = 10.24; q2high[3] = 12.96;
2484  q2low[4] = 12.96; q2high[4] = 14.06;
2485  q2low[5] = 14.06; q2high[5] = 30.0;
2486  }
2487  else if (modename == "kstkee" || modename == "kstksee" ||
2488  modename == "rhoee" || modename == "rho0ee" || modename == "omegaee")
2489  {
2490  //K*ee
2491  n = 7;
2492  q2low[0] = 0.0; q2high[0] = 0.1;
2493  q2low[1] = 0.1; q2high[1] = 4.5;
2494  q2low[2] = 4.5; q2high[2] = 8.41;
2495  q2low[3] = 8.41; q2high[3] = 10.24;
2496  q2low[4] = 10.24; q2high[4] = 12.96;
2497  q2low[5] = 12.96; q2high[5] = 14.06;
2498  q2low[6] = 14.06; q2high[6] = 30.0;
2499  }
2500  else if (modename == "kstkmm" || modename == "kstksmm" ||
2501  modename == "rhomm" || modename == "rho0mm" || modename == "omegamm")
2502  {
2503  //K*mm
2504  n = 7;
2505  q2low[0] = 0.0; q2high[0] = 0.1;
2506  q2low[1] = 0.1; q2high[1] = 4.5;
2507  q2low[2] = 4.5; q2high[2] = 9.0;
2508  q2low[3] = 9.0; q2high[3] = 10.24;
2509  q2low[4] = 10.24; q2high[4] = 12.96;
2510  q2low[5] = 12.96; q2high[5] = 14.06;
2511  q2low[6] = 14.06; q2high[6] = 30.0;
2512  }
2513  float q2binlow[n+1];
2514  for (int i = 0; i < n; i++)
2515  {
2516  q2binlow[i] = q2low[i];
2517  }
2518  q2binlow[n] = 30.0;
2519 
2520  TH1F* _q2var = new TH1F("h9", "q2var", n, q2binlow);
2521 
2522  do
2523  {
2524  EvtVector4R p_init(EvtPDL::getMass(B),0.0,0.0,0.0);
2525  EvtParticle* root_part = EvtParticleFactory::particleFactory(B,p_init);
2526  root_part->setDiagonalSpinDensity();
2527  myGenerator.generateDecay(root_part);
2528 
2529  // root_part->printTree();
2530  //root_part->getDaug(0)->printTree();
2531  //root_part->getDaug(1)->printTree();
2532  //root_part->getDaug(2)->printTree();
2533 
2534  h = root_part->getDaug(0)->getP4Lab();
2535  l1 = root_part->getDaug(1)->getP4Lab();
2536  l2 = root_part->getDaug(2)->getP4Lab();
2537  double qsq=(l1+l2).mass2();
2538 
2539  for (int j = 0 ; j < n; j++)
2540  {
2541  if (qsq > q2low[j] && qsq < q2high[j]) counts[j]++;
2542  }
2543 
2544  _q2->Fill( (l1+l2).mass2() );
2545  _q2var->Fill( (l1+l2).mass2() );
2546  _q2low->Fill( (l1+l2).mass2() );
2547  _q2lowlow->Fill( (l1+l2).mass2() );
2548 
2549  _ctl->Fill(EvtDecayAngle((l1+l2+h),(l1+l2),l1));
2550 
2551  _dalitz->Fill(l1.get(0),(l1+l2).mass2(),1.0);
2552 
2553  _phi->Fill(atan2(l1.get(1),l1.get(2)));
2554 
2555  if (modename == "kstkee" || modename == "kstkmm" ||
2556  modename == "kstksee" || modename == "kstksmm" ||
2557  modename == "rhoee" || modename == "rhomm" ||
2558  modename == "rho0ee" || modename == "rho0mm")
2559  {
2560  b = root_part->getP4();
2561  hdaug1 = root_part->getDaug(0)->getDaug(0)->getP4Lab();
2562  hdaug2 = root_part->getDaug(0)->getDaug(1)->getP4Lab();
2563  _chi->Fill(EvtDecayAngleChi(b,hdaug1,hdaug2,l1,l2));
2564  if (EvtDecayAngle((l1+l2+h),(l1+l2),l1) > 0)
2565  {
2566  _chictl->Fill(EvtDecayAngleChi(b,hdaug1,hdaug2,l1,l2));
2567  }
2568  }
2569  if (count % 1000 == 0)
2570  {
2571  EvtGenReport(EVTGEN_INFO,"EvtGen") << "count:"<<count<<" "<<(l1+l2).mass2()<<std::endl;
2572  }
2573  root_part->deleteTree();
2574  }
2575  while (count++ < nevent);
2576 
2577  for (int j = 0;j < n; j++)
2578  {
2579  std::cout << "[" << q2low[j] << ".." << q2high[j] << "] = " << counts[j] << std::endl;
2580  }
2581  file->Write();
2582  file->Close();
2583  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
2584 }
2585 
2586 void runVectorIsr(int nevent, EvtGen &myGenerator) {
2587 
2588  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
2589  static EvtId VPHO=EvtPDL::getId(std::string("vpho"));
2590 
2591  TFile *file=new TFile("vectorisr.root", "RECREATE");
2592 
2593  TH1F* cosv = new TH1F("h1","Cos vector in e+e- frame",
2594  50,-1.0,1.0);
2595 
2596  TH1F* cosd1 = new TH1F("h2","Cos helang 1st dau of vector",
2597  50,-1.0,1.0);
2598 
2599  TH1F* cosd1d1 = new TH1F("h3","Cos helang 1st dau of 1st dau",
2600  50,-1.0,1.0);
2601 
2602  TH1F* cosd2d1 = new TH1F("h4","Cos helang 1st dau of 2nd dau",
2603  50,-1.0,1.0);
2604 
2605  TH2F* d1vsd1d1 = new TH2F("h5","Cos helangs d1 vs d1d1",
2606  20,-1.0,1.0,20,-1.0,1.0);
2607 
2608  TH2F* d2vsd2d1 = new TH2F("h6","Cos helangs d2 vs d2d1",
2609  20,-1.0,1.0,20,-1.0,1.0);
2610 
2611  TH2F* d1d1vsd2d1 = new TH2F("h7","Cos helangs d1d1 vs d2d1",
2612  20,-1.0,1.0,20,-1.0,1.0);
2613 
2614  TH1F* chidd = new TH1F("h8","Chi - angle between decay planes",
2615  60,0.,360.0);
2616 
2617  TH2F* chi12vsd1d1 = new TH2F("h9","Chi 1-2 vs d1d1",
2618  30,0.,360.0,20,-1.0,1.0);
2619 
2620  TH2F* chi12vsd2d1 = new TH2F("h10","Chi 1-2 vs d2d1",
2621  30,0.,360.0,20,-1.0,1.0);
2622 
2623  TH2F* chi21vsd1d1 = new TH2F("h11","Chi 2-1 vs d1d1",
2624  30,0.,360.0,20,-1.0,1.0);
2625 
2626  TH2F* chi21vsd2d1 = new TH2F("h12","Chi 2-1 vs d2d1",
2627  30,0.,360.0,20,-1.0,1.0);
2628 
2629  int count=1;
2630  char udecay_name[100];
2631  EvtVector4R cm, v, d1, d2, d1d1, d1d2, d2d1, d2d2;
2632 
2633  strcpy(udecay_name,"exampleFiles/VECTORISR.DEC");
2634  myGenerator.readUDecay(udecay_name);
2635 
2636  do{
2637  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
2638 
2639  EvtParticle* root_part=EvtParticleFactory::particleFactory(VPHO,
2640  p_init);
2641 
2642  root_part->setVectorSpinDensity();
2643 
2644  myGenerator.generateDecay(root_part);
2645  cm=root_part->getP4Lab();
2646  v=root_part->getDaug(0)->getP4Lab();
2647 
2648  d1=root_part->getDaug(0)->getDaug(0)->getP4Lab();
2649  d2=root_part->getDaug(0)->getDaug(1)->getP4Lab();
2650 
2651  cosv->Fill(v.get(3)/v.d3mag());
2652 
2653  double cosdecayd1=EvtDecayAngle(cm,v,d1);
2654  double cosdecayd2=EvtDecayAngle(cm,v,d2);
2655  cosd1->Fill(cosdecayd1);
2656 
2657  // now get daughters of the daughters
2658  //
2659  // first daughter of first daughter
2660  if (root_part->getDaug(0)->getDaug(0)->getNDaug()>=2){
2661  d1d1=root_part->getDaug(0)->getDaug(0)->getDaug(0)->getP4Lab();
2662  double cosdecayd1d1=EvtDecayAngle(v,d1,d1d1);
2663  cosd1d1->Fill(cosdecayd1d1);
2664  d1vsd1d1->Fill(cosdecayd1,cosdecayd1d1,1.0);
2665  }
2666 
2667  // first daughter of second daughter
2668  if (root_part->getDaug(0)->getDaug(1)->getNDaug()>=2){
2669  d2d1=root_part->getDaug(0)->getDaug(1)->getDaug(0)->getP4Lab();
2670  double cosdecayd2d1=EvtDecayAngle(v,d2,d2d1);
2671  cosd2d1->Fill(cosdecayd2d1);
2672  d2vsd2d1->Fill(cosdecayd2,cosdecayd2d1,1.0);
2673 
2674  if (root_part->getDaug(0)->getDaug(0)->getNDaug()>=2){
2675  d1d1=root_part->getDaug(0)->getDaug(0)->getDaug(0)->getP4Lab();
2676  double cosdecayd1d1=EvtDecayAngle(v,d1,d1d1);
2677  d1d1vsd2d1->Fill(cosdecayd1d1,cosdecayd2d1,1.0);
2678 
2679  //second daughters of daughters 1 and 2
2680  d1d2=root_part->getDaug(0)->getDaug(0)->getDaug(1)->getP4Lab();
2681  d2d2=root_part->getDaug(0)->getDaug(1)->getDaug(1)->getP4Lab();
2682  double chi21=57.29578*EvtDecayAngleChi(v,d2d1,d2d2,d1d1,d1d2);
2683  double chi12=57.29578*EvtDecayAngleChi(v,d1d1,d1d2,d2d1,d2d2);
2684  chidd->Fill(chi12);
2685 
2686  chi12vsd1d1->Fill(chi12,cosdecayd1d1,1.0);
2687  chi12vsd2d1->Fill(chi12,cosdecayd2d1,1.0);
2688 
2689  chi21vsd1d1->Fill(chi21,cosdecayd1d1,1.0);
2690  chi21vsd2d1->Fill(chi21,cosdecayd2d1,1.0);
2691 
2692  }
2693 
2694  }
2695  root_part->deleteTree();
2696 
2697  }while (count++<nevent);
2698 
2699  file->Write(); file->Close();
2700  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
2701 
2702 }
2703 
2704 
2705 void runBsquark(int nevent, EvtGen &myGenerator) {
2706 
2707  static EvtId VPHO=EvtPDL::getId(std::string("vpho"));
2708  static EvtId B0=EvtPDL::getId(std::string("B0"));
2709  static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
2710 
2711  TFile *file=new TFile("bsquark.root", "RECREATE");
2712 
2713  TH1F* elep = new TH1F("h1","Elep",50,0.0,1.5);
2714 
2715  TH1F* q2 = new TH1F("h2","q2",50,0.0,3.0);
2716 
2717  TH2F* dalitz=new TH2F("h3","q2 vs. Elep",50,0.0,1.5,50,0.0,3.0);
2718 
2719  TH1F* elepbar = new TH1F("h11","Elep bar",
2720  50,0.0,1.5);
2721 
2722  TH1F* q2bar = new TH1F("h12","q2 bar",
2723  50,0.0,3.0);
2724 
2725  TH2F* dalitzbar=new TH2F("h13","q2 vs. Elep bar",50,0.0,1.5,50,0.0,3.0);
2726 
2727  int count=1;
2728  char udecay_name[100];
2729  EvtVector4R cm, v, d1, d2, d1d1, d1d2, d2d1, d2d2;
2730 
2731  strcpy(udecay_name,"exampleFiles/BSQUARK.DEC");
2732  myGenerator.readUDecay(udecay_name);
2733 
2734  do{
2735  EvtVector4R p_init(10.55,0.0,0.0,0.0);
2736 
2737  EvtParticle* root_part=EvtParticleFactory::particleFactory(VPHO,
2738  p_init);
2739 
2740  root_part->setVectorSpinDensity();
2741 
2742  myGenerator.generateDecay(root_part);
2743 
2744  EvtParticle* p=root_part->nextIter();
2745 
2746  while (p) {
2747 
2748  if (p->getId()==B0) {
2749 
2750  EvtParticle *dstar=p->getDaug(0);
2751  EvtParticle *lepton=p->getDaug(1);
2752  EvtParticle *sneutrino=p->getDaug(2);
2753 
2754  EvtVector4R p4dstar=dstar->getP4();
2755  EvtVector4R p4lepton=lepton->getP4();
2756  EvtVector4R p4sneutrino=sneutrino->getP4();
2757 
2758  elep->Fill(p4lepton.get(0));
2759  q2->Fill((p4lepton+p4sneutrino).mass2());
2760 
2761  dalitz->Fill(p4lepton.get(0),(p4lepton+p4sneutrino).mass2(),1.0);
2762 
2763  }
2764 
2765  if (p->getId()==B0B) {
2766 
2767  EvtParticle *dstar=p->getDaug(0);
2768  EvtParticle *lepton=p->getDaug(1);
2769  EvtParticle *sneutrino=p->getDaug(2);
2770 
2771  EvtVector4R p4dstar=dstar->getP4();
2772  EvtVector4R p4lepton=lepton->getP4();
2773  EvtVector4R p4sneutrino=sneutrino->getP4();
2774 
2775  elepbar->Fill(p4lepton.get(0));
2776  q2bar->Fill((p4lepton+p4sneutrino).mass2());
2777 
2778  dalitzbar->Fill(p4lepton.get(0),(p4lepton+p4sneutrino).mass2(),1.0);
2779 
2780  }
2781 
2782  p=p->nextIter();
2783 
2784  }
2785 
2786  root_part->deleteTree();
2787 
2788  }while (count++<nevent);
2789 
2790  file->Write(); file->Close();
2791  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
2792 
2793 }
2794 
2795 
2796 void runK3gamma(int nevent, EvtGen &myGenerator) {
2797 
2798  static EvtId B0=EvtPDL::getId(std::string("B0"));
2799 
2800  TFile *file=new TFile("k3gamma.root", "RECREATE");
2801 
2802  TH1F* costheta = new TH1F("h1","cosTheta", 100,-1.0,1.0);
2803 
2804 
2805  int count=1;
2806  char udecay_name[100];
2807  EvtVector4R cm, v, d1, d2, d1d1, d1d2, d2d1, d2d2;
2808 
2809  strcpy(udecay_name,"exampleFiles/K3GAMMA.DEC");
2810  myGenerator.readUDecay(udecay_name);
2811 
2812  do{
2813  EvtVector4R p_init(EvtPDL::getMass(B0),0.0,0.0,0.0);
2814 
2815  EvtParticle* root_part=EvtParticleFactory::particleFactory(B0,p_init);
2816 
2817  root_part->setDiagonalSpinDensity();
2818 
2819  myGenerator.generateDecay(root_part);
2820 
2821  EvtParticle *k3=root_part->getDaug(0);
2822  EvtParticle *k=k3->getDaug(0);
2823 
2824  EvtVector4R p4b=root_part->getP4Lab();
2825  EvtVector4R p4k3=k3->getP4Lab();
2826  EvtVector4R p4k=k->getP4Lab();
2827 
2828  costheta->Fill(EvtDecayAngle(p4b,p4k3,p4k));
2829 
2830  root_part->deleteTree();
2831 
2832  }while (count++<nevent);
2833 
2834  file->Write(); file->Close();
2835  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
2836 
2837 }
2838 
2839 
2840 void runLambda(int nevent, EvtGen &myGenerator) {
2841 
2842  static EvtId LAMBDA=EvtPDL::getId(std::string("Lambda0"));
2843 
2844  TFile *file=new TFile("lambda.root", "RECREATE");
2845 
2846  TH1F* costheta = new TH1F("h1","cosTheta",100,-1.0,1.0);
2847 
2848 
2849  int count=1;
2850  char udecay_name[100];
2851  EvtVector4R cm, v, d1, d2, d1d1, d1d2, d2d1, d2d2;
2852 
2853  strcpy(udecay_name,"exampleFiles/LAMBDA.DEC");
2854  myGenerator.readUDecay(udecay_name);
2855 
2856  do{
2857  EvtVector4R p_init(EvtPDL::getMass(LAMBDA),0.0,0.0,0.0);
2858 
2859  EvtParticle* root_part=EvtParticleFactory::particleFactory(LAMBDA,p_init);
2860 
2861  EvtSpinDensity rho;
2862 
2863  rho.setDim(2);
2864  rho.set(0,0,1.0);
2865  rho.set(0,1,0.0);
2866  rho.set(1,0,0.0);
2867  rho.set(1,1,0.0);
2868 
2869  root_part->setSpinDensityForwardHelicityBasis(rho);
2870 
2871  myGenerator.generateDecay(root_part);
2872 
2873  EvtParticle *p=root_part->getDaug(0);
2874 
2875  EvtVector4R p4lambda=root_part->getP4Lab();
2876  EvtVector4R p4p=p->getP4Lab();
2877 
2878  costheta->Fill(p4p.get(3)/p4p.d3mag());
2879 
2880  root_part->deleteTree();
2881 
2882  }while (count++<nevent);
2883 
2884  file->Write(); file->Close();
2885  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
2886 
2887 }
2888 
2889 
2890 
2891 void runTauTauPiPi(int nevent, EvtGen &myGenerator) {
2892 
2893  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
2894  static EvtId VPHO=EvtPDL::getId(std::string("vpho"));
2895  TFile *file=new TFile("tautaupipi.root", "RECREATE");
2896 
2897  TH1F* cospi1 = new TH1F("h1","cos theta pi1", 50,-1.0,1.0);
2898  TH1F* cospi2 = new TH1F("h2","cos theta pi2", 50,-1.0,1.0);
2899  TH1F* costheta = new TH1F("h3","cos theta", 50,-1.0,1.0);
2900 
2901  std::ofstream outmix;
2902  outmix.open("tautaupipi.dat");
2903 
2904  int count=1;
2905 
2906  EvtVector4R tau1,tau2,pi1,pi2;
2907  char udecay_name[100];
2908 
2909  strcpy(udecay_name,"exampleFiles/TAUTAUPIPI.DEC");
2910  myGenerator.readUDecay(udecay_name);
2911 
2912  do{
2913 
2914  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
2915 
2916  EvtParticle* root_part=EvtParticleFactory::particleFactory(VPHO,
2917  p_init);
2918  root_part->setVectorSpinDensity();
2919 
2920  myGenerator.generateDecay(root_part);
2921 
2922  tau1=root_part->getDaug(0)->getP4Lab();
2923  tau2=root_part->getDaug(1)->getP4Lab();
2924 
2925  pi1=root_part->getDaug(0)->getDaug(0)->getP4Lab();
2926  pi2=root_part->getDaug(1)->getDaug(0)->getP4Lab();
2927 
2928  cospi1->Fill( EvtDecayAngle(tau1+tau2,tau1,pi1) );
2929  cospi2->Fill( EvtDecayAngle(tau1+tau2,tau2,pi2) );
2930  costheta->Fill(tau1.get(3)/tau1.d3mag());
2931 
2932  root_part->deleteTree();
2933 
2934  }while (count++<nevent);
2935 
2936  file->Write(); file->Close();
2937 
2938  outmix.close();
2939  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
2940 
2941 }
2942 
2943 void runTauTauEE(int nevent, EvtGen &myGenerator) {
2944 
2945  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
2946  static EvtId VPHO=EvtPDL::getId(std::string("vpho"));
2947  TFile *file=new TFile("tautauee.root", "RECREATE");
2948 
2949  TH1F* e1 = new TH1F("h1","e1",55,0.0,5.5);
2950  TH1F* e2 = new TH1F("h2","e2",55,0.0,5.5);
2951  TH2F* e1vse2 = new TH2F("h3","e1 vs e2",55,0.0,5.5,
2952  55,0.0,5.5);
2953 
2954  int count=1;
2955  char udecay_name[100];
2956 
2957  strcpy(udecay_name,"exampleFiles/TAUTAUEE.DEC");
2958  myGenerator.readUDecay(udecay_name);
2959 
2960  do{
2961 
2962  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
2963 
2964  EvtParticle* root_part=EvtParticleFactory::particleFactory(VPHO, p_init);
2965  root_part->setVectorSpinDensity();
2966 
2967  myGenerator.generateDecay(root_part);
2968 
2969  e1->Fill(root_part->getDaug(0)->getDaug(0)->getP4Lab().get(0));
2970  e2->Fill(root_part->getDaug(1)->getDaug(0)->getP4Lab().get(0));
2971  e1vse2->Fill(root_part->getDaug(0)->getDaug(0)->getP4Lab().get(0),
2972  root_part->getDaug(1)->getDaug(0)->getP4Lab().get(0),1.0);
2973 
2974  root_part->deleteTree();
2975 
2976  }while (count++<nevent);
2977 
2978  file->Write(); file->Close();
2979  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
2980 
2981 }
2982 
2983 void runTauTau2Pi2Pi(int nevent, EvtGen &myGenerator) {
2984 
2985  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
2986  static EvtId VPHO=EvtPDL::getId(std::string("vpho"));
2987  TFile *file=new TFile("tautau2pi2pi.root", "RECREATE");
2988 
2989  TH1F* e1 = new TH1F("h1","mrho",200,0.0,2.0);
2990  TH1F* e2 = new TH1F("h2","coshel",200,-1.0,1.0);
2991 
2992  int count=1;
2993  char udecay_name[100];
2994 
2995  strcpy(udecay_name,"exampleFiles/TAUTAU2PI2PI.DEC");
2996  myGenerator.readUDecay(udecay_name);
2997 
2998  do{
2999 
3000  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
3001 
3002  EvtParticle* root_part=EvtParticleFactory::particleFactory(VPHO, p_init);
3003  root_part->setVectorSpinDensity();
3004 
3005  myGenerator.generateDecay(root_part);
3006 
3007  EvtVector4R p4tau =root_part->getDaug(0)->getP4();
3008  EvtVector4R p4rho =root_part->getDaug(0)->getDaug(0)->getP4()
3009  + root_part->getDaug(0)->getDaug(1)->getP4();
3010  EvtVector4R p4pi = root_part->getDaug(0)->getDaug(0)->getP4();
3011 
3012  e1->Fill(p4rho.mass());
3013  double dcostheta=EvtDecayAngle(p4tau,p4rho,p4pi);
3014  e2->Fill(dcostheta);
3015 
3016  p4tau =root_part->getDaug(1)->getP4();
3017  p4rho =root_part->getDaug(1)->getDaug(0)->getP4()
3018  + root_part->getDaug(1)->getDaug(1)->getP4();
3019  p4pi = root_part->getDaug(1)->getDaug(0)->getP4();
3020 
3021  e1->Fill(p4rho.mass());
3022  dcostheta=EvtDecayAngle(p4tau,p4rho,p4pi);
3023  e2->Fill(dcostheta);
3024 
3025  root_part->deleteTree();
3026 
3027  }while (count++<nevent);
3028 
3029  file->Write(); file->Close();
3030  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
3031 
3032 }
3033 
3034 void runTauTau3Pi3Pi(int nevent, EvtGen &myGenerator) {
3035 
3036  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
3037  static EvtId VPHO=EvtPDL::getId(std::string("vpho"));
3038  TFile *file=new TFile("tautau3pi3pi.root", "RECREATE");
3039 
3040  TH1F* e1 = new TH1F("h1","a1",200,0.0,2.0);
3041 
3042  int count=1;
3043  char udecay_name[100];
3044 
3045  strcpy(udecay_name,"exampleFiles/TAUTAU3PI3PI.DEC");
3046  myGenerator.readUDecay(udecay_name);
3047 
3048  do{
3049 
3050  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
3051 
3052  EvtParticle* root_part=EvtParticleFactory::particleFactory(VPHO, p_init);
3053  root_part->setVectorSpinDensity();
3054 
3055  myGenerator.generateDecay(root_part);
3056 
3057  EvtVector4R p4tau =root_part->getDaug(0)->getP4();
3058  EvtVector4R p4a1 =root_part->getDaug(0)->getDaug(0)->getP4()
3059  + root_part->getDaug(0)->getDaug(1)->getP4()
3060  + root_part->getDaug(0)->getDaug(2)->getP4();
3061 
3062  e1->Fill(p4a1.mass());
3063 
3064  p4tau =root_part->getDaug(1)->getP4();
3065  p4a1 =root_part->getDaug(1)->getDaug(0)->getP4()
3066  + root_part->getDaug(1)->getDaug(1)->getP4()
3067  + root_part->getDaug(1)->getDaug(2)->getP4();
3068 
3069  e1->Fill(p4a1.mass());
3070 
3071  root_part->deleteTree();
3072 
3073  }while (count++<nevent);
3074 
3075  file->Write(); file->Close();
3076  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
3077 
3078 }
3079 
3080 
3081 void runJPsiKstar(int nevent, EvtGen &myGenerator, int modeInt) {
3082 
3083  std::ofstream outmix;
3084  outmix.open("jpsikstar.dat");
3085 
3086  int count=1;
3087 
3088  char udecay_name[100];
3089  if (modeInt==0) strcpy(udecay_name,"exampleFiles/JPSIKSTAR.DEC");
3090  if (modeInt==1) strcpy(udecay_name,"exampleFiles/JPSIKSTAR1.DEC");
3091  if (modeInt==2) strcpy(udecay_name,"exampleFiles/JPSIKSTAR2.DEC");
3092  if (modeInt==3) strcpy(udecay_name,"exampleFiles/JPSIKSTAR3.DEC");
3093  if (modeInt==4) strcpy(udecay_name,"exampleFiles/JPSIKSTAR4.DEC");
3094 
3095  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
3096  static EvtId VPHO=EvtPDL::getId(std::string("vpho"));
3097  static EvtId GAMM=EvtPDL::getId(std::string("gamma"));
3098  static EvtId B0=EvtPDL::getId(std::string("B0"));
3099  static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
3100 
3101  myGenerator.readUDecay(udecay_name);
3102 
3103  do{
3104 
3105  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
3106 
3107  EvtParticle* root_part=EvtParticleFactory::particleFactory(UPS4,
3108  p_init);
3109  root_part->setVectorSpinDensity();
3110 
3111  myGenerator.generateDecay(root_part);
3112 
3113  EvtParticle *btag,*bcp;
3114 
3115  if (root_part->getDaug(0)->getNDaug()==3){
3116  btag=root_part->getDaug(0);
3117  bcp=root_part->getDaug(1);
3118  }
3119  else{
3120  bcp=root_part->getDaug(0);
3121  btag=root_part->getDaug(1);
3122  }
3123 
3124  EvtId tag;
3125 
3126  if (btag->getId()==B0B){
3127  tag=B0;
3128  }
3129  else{
3130  tag=B0B;
3131  }
3132 
3133  EvtParticle *p_b,*p_psi,*p_kstar,*p_pi0,*p_kz,*p_ep,*p_em;
3134  EvtVector4R p4_b,p4_psi,p4_kstar,p4_pi0,p4_kz,p4_ep,p4_em;
3135 
3136  p_b=bcp;
3137 
3138  p_psi=p_b->getDaug(0);
3139  p_kstar=p_b->getDaug(1);
3140 
3141  p_pi0=p_kstar->getDaug(0);
3142  p_kz=p_kstar->getDaug(1);
3143 
3144  p_ep=p_psi->getDaug(0);
3145  p_em=p_psi->getDaug(1);
3146 
3147  p4_b=p_b->getP4Lab();
3148  p4_psi=p_psi->getP4Lab();
3149  p4_kstar=p_kstar->getP4Lab();
3150  p4_pi0=p_pi0->getP4Lab();
3151  p4_kz=p_kz->getP4Lab();
3152  p4_ep=p_ep->getP4Lab();
3153  p4_em=p_em->getP4Lab();
3154 
3155  outmix << tag.getId() << " ";
3156  outmix << root_part->getDaug(0)->getLifetime() << " ";
3157  outmix << root_part->getDaug(1)->getLifetime() << " ";
3158  outmix << EvtDecayAngle(p4_b,p4_ep+p4_em,p4_ep) << " " ;
3159  outmix << EvtDecayAngle(p4_b,p4_pi0+p4_kz,p4_pi0) << " " ;
3160  outmix << EvtDecayAngleChi(p4_b,p4_pi0,p4_kz,
3161  p4_ep, p4_em ) << "\n" ;
3162 
3163  root_part->deleteTree();
3164 
3165  }while (count++<10000);
3166 
3167  outmix.close();
3168  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
3169 }
3170 
3171 
3172 void runSVVCPLH(int nevent, EvtGen &myGenerator) {
3173 
3174  TFile *file=new TFile("svvcplh.root", "RECREATE");
3175 
3176  TH1F* t = new TH1F("h1","t",50,0.0,5.0);
3177  TH1F* cospsi = new TH1F("h2","cos theta e+",50,-1.0,1.0);
3178  TH1F* cosphi = new TH1F("h3","cos theta k+",50,-1.0,1.0);
3179  TH1F* chi = new TH1F("h4","chi",50,0.0,2.0*EvtConst::pi);
3180 
3181  int count=1;
3182 
3183  char udecay_name[100];
3184  strcpy(udecay_name,"exampleFiles/SVVCPLH.DEC");
3185  myGenerator.readUDecay(udecay_name);
3186 
3187  static EvtId BS0=EvtPDL::getId(std::string("B_s0"));
3188  static EvtId BSB=EvtPDL::getId(std::string("anti-B_s0"));
3189 
3190  do{
3191  EvtVector4R p_init(EvtPDL::getMass(BS0),0.0,0.0,0.0);
3192 
3193  EvtParticle* root_part=EvtParticleFactory::particleFactory(BS0,
3194  p_init);
3195  root_part->setDiagonalSpinDensity();
3196 
3197  myGenerator.generateDecay(root_part);
3198 
3199  EvtParticle *p_b,*p_psi,*p_phi,*p_kp,*p_km,*p_ep,*p_em;
3200  EvtVector4R p4_b,p4_psi,p4_phi,p4_kp,p4_km,p4_ep,p4_em;
3201 
3202  p_b=root_part;
3203 
3204  if (p_b->getNDaug()==1) p_b=p_b->getDaug(0);
3205 
3206  p_psi=p_b->getDaug(0);
3207  p_phi=p_b->getDaug(1);
3208 
3209  p_kp=p_phi->getDaug(0);
3210  p_km=p_phi->getDaug(1);
3211 
3212  p_ep=p_psi->getDaug(0);
3213  p_em=p_psi->getDaug(1);
3214 
3215  p4_b=p_b->getP4Lab();
3216  p4_psi=p_psi->getP4Lab();
3217  p4_phi=p_phi->getP4Lab();
3218  p4_kp=p_kp->getP4Lab();
3219  p4_km=p_km->getP4Lab();
3220  p4_ep=p_ep->getP4Lab();
3221  p4_em=p_em->getP4Lab();
3222 
3223  t->Fill(root_part->getLifetime());
3224  cospsi->Fill(EvtDecayAngle(p4_b,p4_ep+p4_em,p4_ep));
3225  cosphi->Fill(EvtDecayAngle(p4_b,p4_kp+p4_km,p4_kp));
3226  chi->Fill(EvtDecayAngleChi(p4_b,p4_kp,p4_km,
3227  p4_ep, p4_em ));
3228 
3229  root_part->deleteTree();
3230 
3231  }while (count++<nevent);
3232 
3233  file->Write(); file->Close();
3234  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
3235 
3236 }
3237 
3238 
3239 void runSVSCPLH(int nevent, EvtGen &myGenerator) {
3240 
3241  TFile *file=new TFile("svscplh.root", "RECREATE");
3242 
3243  TH1F* t = new TH1F("h1","t",200,-5.0,5.0);
3244  TH1F* tB0tag = new TH1F("h2","dt B0 tag (ps)",200,-15.0,15.0);
3245  TH1F* tB0Btag = new TH1F("h3","dt B0B tag (ps)",200,-15.0,15.0);
3246  TH1F* ctheta = new TH1F("h4","costheta",50,-1.0,1.0);
3247 
3248  int count=1;
3249 
3250  char udecay_name[100];
3251  strcpy(udecay_name,"exampleFiles/SVSCPLH.DEC");
3252  myGenerator.readUDecay(udecay_name);
3253 
3254 
3255  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
3256  static EvtId B0=EvtPDL::getId(std::string("B0"));
3257  static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
3258 
3259  std::ofstream outmix;
3260  outmix.open("svscplh.dat");
3261 
3262  do{
3263 
3264  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
3265 
3266  EvtParticle* root_part=EvtParticleFactory::particleFactory(UPS4,
3267  p_init);
3268  root_part->setVectorSpinDensity();
3269 
3270  myGenerator.generateDecay(root_part);
3271 
3272 
3273  EvtParticle *p_tag,*p_cp,*p_jpsi,*p_ep;
3274  EvtVector4R p4_tag,p4_cp,p4_jpsi,p4_ep;
3275 
3276  p_tag=root_part->getDaug(0);
3277  p_cp=root_part->getDaug(1);
3278 
3279  p_jpsi=p_cp->getDaug(0);
3280  p_ep=p_jpsi->getDaug(0);
3281 
3282  p4_tag=p_tag->getP4Lab();
3283  p4_cp=p_cp->getP4Lab();
3284  p4_jpsi=p_jpsi->getP4Lab();
3285  p4_ep=p_ep->getP4Lab();
3286 
3287 
3288  double dt=p_cp->getLifetime()-p_tag->getLifetime();
3289  dt=dt/(1e-12*3e11);
3290 
3291  t->Fill(dt);
3292 
3293  if (p_tag->getId()==B0){
3294  tB0tag->Fill(dt);
3295  outmix << dt << " 1"<<std::endl;
3296  }
3297  if (p_tag->getId()==B0B){
3298  tB0Btag->Fill(dt);
3299  outmix << dt << " -1"<<std::endl;
3300  }
3301  ctheta->Fill(EvtDecayAngle(p4_cp,p4_jpsi,p4_ep));
3302 
3303 
3304  root_part->deleteTree();
3305 
3306  }while (count++<nevent);
3307 
3308  file->Write(); file->Close();
3309  outmix.close();
3310  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
3311 }
3312 
3313 
3314 void runSSDCP(int nevent, EvtGen &myGenerator) {
3315 
3316  TFile *file=new TFile("ssdcp.root", "RECREATE");
3317 
3318  TH1F* t = new TH1F("h1","dt",100,-15.0,15.0);
3319  TH1F* tB0tag = new TH1F("h2","dt B0 tag (ps)",100,-15.0,15.0);
3320  TH1F* tB0Btag = new TH1F("h3","dt B0B tag (ps)",100,-15.0,15.0);
3321 
3322  int count=1;
3323 
3324  char udecay_name[100];
3325  strcpy(udecay_name,"exampleFiles/SSDCP.DEC");
3326  myGenerator.readUDecay(udecay_name);
3327 
3328 
3329  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
3330  static EvtId B0=EvtPDL::getId(std::string("B0"));
3331  static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
3332 
3333  std::ofstream outmix;
3334 
3335  do{
3336 
3337  EvtVector4R pinit(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
3338 
3339  EvtParticle *root_part=EvtParticleFactory::particleFactory(UPS4,pinit);
3340 
3341  root_part->setVectorSpinDensity();
3342 
3343  myGenerator.generateDecay(root_part);
3344 
3345 
3346  EvtParticle *p_tag,*p_cp,*p_jpsi;
3347  EvtVector4R p4_tag,p4_cp,p4_jpsi,p4_ep;
3348 
3349  p_tag=root_part->getDaug(0);
3350  p_cp=root_part->getDaug(1);
3351 
3352  p_jpsi=p_cp->getDaug(0);
3353  //p_ep=p_jpsi->getDaug(0);
3354 
3355  p4_tag=p_tag->getP4Lab();
3356  p4_cp=p_cp->getP4Lab();
3357  p4_jpsi=p_jpsi->getP4Lab();
3358  //p4_ep=p_ep->getP4Lab();
3359 
3360 
3361  double dt=p_cp->getLifetime()-p_tag->getLifetime();
3362  dt=dt/(1e-12*EvtConst::c);
3363 
3364  t->Fill(dt);
3365 
3366  if (p_tag->getId()==B0){
3367  tB0tag->Fill(dt);
3368  }
3369  if (p_tag->getId()==B0B){
3370  tB0Btag->Fill(dt);
3371  }
3372 
3373  root_part->deleteTree();
3374 
3375  }while (count++<nevent);
3376 
3377  file->Write(); file->Close();
3378  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
3379 
3380 }
3381 
3382 void runKstarstargamma(int nevent, EvtGen &myGenerator) {
3383 
3384  TFile *file=new TFile("kstarstargamma.root", "RECREATE");
3385 
3386  TH1F* m = new TH1F("h1","mkpi",100,0.5,2.5);
3387 
3388  TH1F* ctheta = new TH1F("h2","ctheta",100,-1.0,1.0);
3389 
3390  int count=1;
3391 
3392  myGenerator.readUDecay("exampleFiles/KSTARSTARGAMMA.DEC");
3393 
3394 
3395  static EvtId B0=EvtPDL::getId(std::string("B0"));
3396 
3397  std::ofstream outmix;
3398 
3399  do{
3400 
3401  EvtVector4R pinit(EvtPDL::getMass(B0),0.0,0.0,0.0);
3402 
3403  EvtParticle* root_part=EvtParticleFactory::particleFactory(B0,pinit);
3404 
3405  root_part->setDiagonalSpinDensity();
3406 
3407  myGenerator.generateDecay(root_part);
3408 
3409  EvtParticle *p_kaon,*p_pion;
3410  EvtVector4R p4_kaon,p4_pion;
3411 
3412  p_kaon=root_part->getDaug(0);
3413  p_pion=root_part->getDaug(1);
3414 
3415 
3416  p4_kaon=p_kaon->getP4Lab();
3417  p4_pion=p_pion->getP4Lab();
3418 
3419 
3420  m->Fill((p4_kaon+p4_pion).mass());
3421 
3422  ctheta->Fill(EvtDecayAngle(pinit,p4_kaon+p4_pion,p4_kaon));
3423 
3424  //EvtGenReport(EVTGEN_INFO,"EvtGen") << "ctheta:"<<EvtDecayAngle(pinit,p4_kaon+p4_pion,p4_kaon)<<std::endl;
3425 
3426  root_part->deleteTree();
3427 
3428  }while (count++<nevent);
3429 
3430  file->Write(); file->Close();
3431  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
3432 
3433 }
3434 
3435 
3436 void runDSTARPI(int nevent, EvtGen &myGenerator) {
3437 
3438  TFile *file=new TFile("dstarpi.root", "RECREATE");
3439 
3440  TH1F* t = new TH1F("h1","dt",100,-15.0,15.0);
3441  TH1F* tB0tagpip = new TH1F("h2","dt B0 tag pi+ (ps)",100,-15.0,15.0);
3442  TH1F* tB0Btagpip = new TH1F("h3","dt B0B tag pi+(ps)",100,-15.0,15.0);
3443  TH1F* tB0tagpim = new TH1F("h4","dt B0 tag pi- (ps)",100,-15.0,15.0);
3444  TH1F* tB0Btagpim = new TH1F("h5","dt B0B tag pi- (ps)",100,-15.0,15.0);
3445 
3446  int count=1;
3447 
3448  myGenerator.readUDecay("exampleFiles/DSTARPI.DEC");
3449 
3450  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
3451  static EvtId B0=EvtPDL::getId(std::string("B0"));
3452  static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
3453  static EvtId PIP=EvtPDL::getId(std::string("pi+"));
3454  static EvtId PIM=EvtPDL::getId(std::string("pi-"));
3455 
3456  std::ofstream outmix;
3457 
3458  do{
3459 
3460  EvtVector4R pinit(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
3461 
3462  EvtParticle* root_part=EvtParticleFactory::particleFactory(UPS4,pinit);
3463 
3464  root_part->setVectorSpinDensity();
3465 
3466  myGenerator.generateDecay(root_part);
3467 
3468 
3469  EvtParticle *p_tag,*p_cp,*p_dstar,*p_pi;
3470 
3471  p_tag=root_part->getDaug(0);
3472  p_cp=root_part->getDaug(1);
3473 
3474  p_dstar=p_cp->getDaug(1);
3475  p_pi=p_cp->getDaug(0);
3476 
3477  double dt=p_cp->getLifetime()-p_tag->getLifetime();
3478  dt=dt/(1e-12*EvtConst::c);
3479 
3480  t->Fill(dt);
3481 
3482  if (p_tag->getId()==B0){
3483  if (p_pi->getId()==PIP) tB0tagpip->Fill(dt);
3484  if (p_pi->getId()==PIM) tB0tagpim->Fill(dt);
3485  }
3486  if (p_tag->getId()==B0B){
3487  if (p_pi->getId()==PIP) tB0Btagpip->Fill(dt);
3488  if (p_pi->getId()==PIM) tB0Btagpim->Fill(dt);
3489  }
3490 
3491  root_part->deleteTree();
3492 
3493  }while (count++<nevent);
3494 
3495  file->Write(); file->Close();
3496  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
3497 
3498 }
3499 
3500 
3501 
3502 void runETACPHIPHI(int nevent, EvtGen &myGenerator) {
3503 
3504  TFile *file=new TFile("etacphiphi.root", "RECREATE");
3505 
3506  TH2F* cosphi12 = new TH2F("h1","cos phi1 vs phi2",
3507  50,-1.0,1.0,50,-1.0,1.0);
3508  TH1F* cosphi1 = new TH1F("h2","cos phi1",50,-1.0,1.0);
3509  TH1F* cosphi2 = new TH1F("h3","cos phi2",50,-1.0,1.0);
3510  TH1F* chi = new TH1F("h4","chi",50,0.0,2.0*EvtConst::pi);
3511 
3512  int count=1;
3513 
3514  char udecay_name[100];
3515  strcpy(udecay_name,"exampleFiles/ETACPHIPHI.DEC");
3516  myGenerator.readUDecay(udecay_name);
3517 
3518  static EvtId ETAC=EvtPDL::getId(std::string("eta_c"));
3519 
3520  do{
3521  EvtVector4R p_init(EvtPDL::getMass(ETAC),0.0,0.0,0.0);
3522 
3523  EvtParticle* root_part=EvtParticleFactory::particleFactory(ETAC,
3524  p_init);
3525  root_part->setDiagonalSpinDensity();
3526 
3527  myGenerator.generateDecay(root_part);
3528 
3529  EvtParticle *p_etac,*p_phi1,*p_phi2,*p_kp1,*p_km1,*p_kp2,*p_km2;
3530  EvtVector4R p4_etac,p4_phi1,p4_phi2,p4_kp1,p4_km1,p4_kp2,p4_km2;
3531 
3532  p_etac=root_part;
3533 
3534 
3535  p_phi1=p_etac->getDaug(0);
3536  p_phi2=p_etac->getDaug(1);
3537 
3538  p_kp1=p_phi1->getDaug(0);
3539  p_km1=p_phi1->getDaug(1);
3540 
3541  p_kp2=p_phi2->getDaug(0);
3542  p_km2=p_phi2->getDaug(1);
3543 
3544  p4_etac=p_etac->getP4Lab();
3545  p4_phi1=p_phi1->getP4Lab();
3546  p4_phi2=p_phi2->getP4Lab();
3547  p4_kp1=p_kp1->getP4Lab();
3548  p4_km1=p_km1->getP4Lab();
3549  p4_kp2=p_kp2->getP4Lab();
3550  p4_km2=p_km2->getP4Lab();
3551 
3552 
3553  cosphi12->Fill(EvtDecayAngle(p4_etac,p4_phi1,p4_kp1),
3554  EvtDecayAngle(p4_etac,p4_phi2,p4_kp2),1.0);
3555 
3556  cosphi1->Fill(EvtDecayAngle(p4_etac,p4_phi1,p4_kp1));
3557  cosphi2->Fill(EvtDecayAngle(p4_etac,p4_phi2,p4_kp2));
3558  chi->Fill(EvtDecayAngleChi(p4_etac,p4_kp1,p4_km1,
3559  p4_kp2, p4_km2));
3560 
3561  root_part->deleteTree();
3562 
3563  }while (count++<nevent);
3564 
3565  file->Write(); file->Close();
3566  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
3567 
3568 }
3569 
3570 
3571 
3572 
3573 
3574 
3575 void runVVPiPi(int nevent, EvtGen &myGenerator) {
3576  TFile *file=new TFile("vvpipi.root", "RECREATE");
3577 
3578  TH1F* cospsi = new TH1F("h1","cos theta J/psi ",50,-1.0,1.0);
3579  TH1F* cose = new TH1F("h2","cos theta e+ ",50,-1.0,1.0);
3580  TH1F* mpipi = new TH1F("h3","m pipi ",50,0.0,1.0);
3581  TH2F* cosevspsi = new TH2F("h4","cos theta e+vs cos thete J/psi ",
3582  25,-1.0,1.0,25,-1.0,1.0);
3583  TH1F* cose1 = new TH1F("h5","cos theta e+ 1 ",50,-1.0,1.0);
3584  TH1F* cose2 = new TH1F("h6","cos theta e+ 2 ",50,-1.0,1.0);
3585 
3586 
3587  int count=1;
3588 
3589  char udecay_name[100];
3590  strcpy(udecay_name,"exampleFiles/VVPIPI.DEC");
3591  myGenerator.readUDecay(udecay_name);
3592 
3593  static EvtId B0=EvtPDL::getId(std::string("B0"));
3594  static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
3595 
3596  do{
3597  EvtVector4R p_init(EvtPDL::getMass(B0),0.0,0.0,0.0);
3598 
3599  EvtParticle* root_part=EvtParticleFactory::particleFactory(B0,
3600  p_init);
3601  root_part->setDiagonalSpinDensity();
3602 
3603  myGenerator.generateDecay(root_part);
3604 
3605  EvtParticle *p_b,*p_psip,*p_psi,*p_ep,*p_pi1,*p_pi2;
3606  EvtVector4R p4_b,p4_psip,p4_psi,p4_ep,p4_pi1,p4_pi2;
3607 
3608  p_b=root_part;
3609 
3610  p_psip=p_b->getDaug(0);
3611  p_psi=p_psip->getDaug(0);
3612  p_pi1=p_psip->getDaug(1);
3613  p_pi2=p_psip->getDaug(2);
3614  p_ep=p_psi->getDaug(0);
3615 
3616  p4_b=p_b->getP4Lab();
3617  p4_psip=p_psip->getP4Lab();
3618  p4_psi=p_psi->getP4Lab();
3619  p4_pi1=p_pi1->getP4Lab();
3620  p4_pi2=p_pi2->getP4Lab();
3621  p4_ep=p_ep->getP4Lab();
3622 
3623  cospsi->Fill(EvtDecayAngle(p4_b,p4_psip,p4_psi));
3624  cose->Fill(EvtDecayAngle(p4_psip,p4_psi,p4_ep));
3625  mpipi->Fill((p4_pi1+p4_pi2).mass());
3626  cosevspsi->Fill(EvtDecayAngle(p4_b,p4_psip,p4_psi),
3627  EvtDecayAngle(p4_psip,p4_psi,p4_ep),1.0);
3628  if (std::fabs(EvtDecayAngle(p4_b,p4_psip,p4_psi))>0.95){
3629  cose1->Fill(EvtDecayAngle(p4_psip,p4_psi,p4_ep));
3630  }
3631  if (std::fabs(EvtDecayAngle(p4_b,p4_psip,p4_psi))<0.05){
3632  cose2->Fill(EvtDecayAngle(p4_psip,p4_psi,p4_ep));
3633  }
3634 
3635  root_part->deleteTree();
3636 
3637  }while (count++<nevent);
3638 
3639  file->Write(); file->Close();
3640  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
3641 }
3642 
3643 
3644 void runSVVHelAmp(int nevent, EvtGen &myGenerator) {
3645  TFile *file=new TFile("svvhelamp.root", "RECREATE");
3646 
3647  TH1F* cospip = new TH1F("h1","cos theta pi+",
3648  50,-1.0,1.0);
3649  TH1F* cospim = new TH1F("h2","cos theta pi-",
3650  50,-1.0,1.0);
3651  TH1F* chi = new TH1F("h3","chi pi+ to pi- in D+ direction",
3652  50,0.0,EvtConst::twoPi);
3653  TH1F* chicospipp = new TH1F("h4","chi pi+ to pi- in D+ direction (cospip>0)",
3654  50,0.0,EvtConst::twoPi);
3655  TH1F* chicospipn = new TH1F("h5","chi pi+ to pi- in D+ direction (cospip<0",
3656  50,0.0,EvtConst::twoPi);
3657 
3658  TH1F* chipp = new TH1F("h6","chi pi+ to pi- in D+ direction (cospip>0,cospim>0)",
3659  50,0.0,EvtConst::twoPi);
3660 
3661  TH1F* chipn = new TH1F("h7","chi pi+ to pi- in D+ direction (cospip>0,cospim<0)",
3662  50,0.0,EvtConst::twoPi);
3663 
3664  TH1F* chinp = new TH1F("h8","chi pi+ to pi- in D+ direction (cospip<0,cospim>0)",
3665  50,0.0,EvtConst::twoPi);
3666 
3667  TH1F* chinn = new TH1F("h9","chi pi+ to pi- in D+ direction (cospip<0,cospim<0)",
3668  50,0.0,EvtConst::twoPi);
3669 
3670 
3671  TH1F* chinnnn = new TH1F("h10","chi pi+ to pi- in D+ direction (cospip<-0.5,cospim<-0.5)",
3672  50,0.0,EvtConst::twoPi);
3673 
3674  int count=1;
3675 
3676  char udecay_name[100];
3677  strcpy(udecay_name,"exampleFiles/SVVHELAMP.DEC");
3678  myGenerator.readUDecay(udecay_name);
3679 
3680  static EvtId B0=EvtPDL::getId(std::string("B0"));
3681  static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
3682 
3683  do{
3684  EvtVector4R p_init(EvtPDL::getMass(B0),0.0,0.0,0.0);
3685 
3686  EvtParticle* root_part=EvtParticleFactory::particleFactory(B0,
3687  p_init);
3688  root_part->setDiagonalSpinDensity();
3689 
3690  myGenerator.generateDecay(root_part);
3691 
3692  EvtParticle *p_b,*p_dstp,*p_dstm,*p_pip,*p_pim,*p_d0,*p_d0b;
3693  EvtVector4R p4_b,p4_dstp,p4_dstm,p4_pip,p4_pim,p4_d0,p4_d0b;
3694 
3695  p_b=root_part;
3696 
3697  p_dstp=p_b->getDaug(0);
3698  p_dstm=p_b->getDaug(1);
3699 
3700  p_pip=p_dstp->getDaug(1);
3701  p_pim=p_dstm->getDaug(1);
3702 
3703  p_d0=p_dstp->getDaug(0);
3704  p_d0b=p_dstm->getDaug(0);
3705 
3706  p4_b=p_b->getP4Lab();
3707  p4_dstp=p_dstp->getP4Lab();
3708  p4_dstm=p_dstm->getP4Lab();
3709  p4_pip=p_pip->getP4Lab();
3710  p4_pim=p_pim->getP4Lab();
3711  p4_d0=p_d0->getP4Lab();
3712  p4_d0b=p_d0b->getP4Lab();
3713 
3714  double costhpip=EvtDecayAngle(p4_b,p4_pip+p4_d0,p4_pip);
3715  double costhpim=EvtDecayAngle(p4_b,p4_pim+p4_d0b,p4_pim);
3716  double chiang=EvtDecayAngleChi(p4_b,p4_pip,p4_d0,p4_pim,p4_d0b);
3717 
3718  cospip->Fill( costhpip );
3719  cospim->Fill( costhpim );
3720  chi->Fill( chiang );
3721  if (costhpip>0) chicospipp->Fill( chiang );
3722  if (costhpip<0) chicospipn->Fill( chiang );
3723 
3724  if (costhpip>0 && costhpim>0) chipp->Fill( chiang );
3725  if (costhpip>0 && costhpim<0) chipn->Fill( chiang );
3726  if (costhpip<0 && costhpim>0) chinp->Fill( chiang );
3727  if (costhpip<0 && costhpim<0) chinn->Fill( chiang );
3728  if (costhpip<-0.5 && costhpim<-0.5) chinnnn->Fill( chiang );
3729  root_part->deleteTree();
3730 
3731  }while (count++<nevent);
3732 
3733  file->Write(); file->Close();
3734  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
3735 }
3736 
3737 
3738 void runPartWave(int nevent, EvtGen &myGenerator) {
3739 
3740  TFile *file=new TFile("partwave.root", "RECREATE");
3741 
3742  TH1F* cospip = new TH1F("h1","cos theta pi+",
3743  50,-1.0,1.0);
3744  TH1F* cospim = new TH1F("h2","cos theta pi-",
3745  50,-1.0,1.0);
3746  TH1F* chi = new TH1F("h3","chi pi+ to pi- in D+ direction",
3747  50,0.0,EvtConst::twoPi);
3748  TH1F* chicospipp = new TH1F("h4","chi pi+ to pi- in D+ direction (cospip>0)",
3749  50,0.0,EvtConst::twoPi);
3750  TH1F* chicospipn = new TH1F("h5","chi pi+ to pi- in D+ direction (cospip<0",
3751  50,0.0,EvtConst::twoPi);
3752 
3753  TH1F* chipp = new TH1F("h6","chi pi+ to pi- in D+ direction (cospip>0,cospim>0)",
3754  50,0.0,EvtConst::twoPi);
3755 
3756  TH1F* chipn = new TH1F("h7","chi pi+ to pi- in D+ direction (cospip>0,cospim<0)",
3757  50,0.0,EvtConst::twoPi);
3758 
3759  TH1F* chinp = new TH1F("h8","chi pi+ to pi- in D+ direction (cospip<0,cospim>0)",
3760  50,0.0,EvtConst::twoPi);
3761 
3762  TH1F* chinn = new TH1F("h9","chi pi+ to pi- in D+ direction (cospip<0,cospim<0)",
3763  50,0.0,EvtConst::twoPi);
3764 
3765 
3766  TH1F* chinnnn = new TH1F("h10","chi pi+ to pi- in D+ direction (cospip<-0.5,cospim<-0.5)",
3767  50,0.0,EvtConst::twoPi);
3768 
3769  int count=1;
3770 
3771  char udecay_name[100];
3772  strcpy(udecay_name,"exampleFiles/PARTWAVE.DEC");
3773  myGenerator.readUDecay(udecay_name);
3774 
3775  static EvtId B0=EvtPDL::getId(std::string("B0"));
3776  static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
3777 
3778  do{
3779  EvtVector4R p_init(EvtPDL::getMass(B0),0.0,0.0,0.0);
3780 
3781  EvtParticle* root_part=EvtParticleFactory::particleFactory(B0,
3782  p_init);
3783  root_part->setDiagonalSpinDensity();
3784 
3785  myGenerator.generateDecay(root_part);
3786 
3787  EvtParticle *p_b,*p_dstp,*p_dstm,*p_pip,*p_pim,*p_d0,*p_d0b;
3788  EvtVector4R p4_b,p4_dstp,p4_dstm,p4_pip,p4_pim,p4_d0,p4_d0b;
3789 
3790  p_b=root_part;
3791 
3792  p_dstp=p_b->getDaug(0);
3793  p_dstm=p_b->getDaug(1);
3794 
3795  p_pip=p_dstp->getDaug(1);
3796  p_pim=p_dstm->getDaug(1);
3797 
3798  p_d0=p_dstp->getDaug(0);
3799  p_d0b=p_dstm->getDaug(0);
3800 
3801  p4_b=p_b->getP4Lab();
3802  p4_dstp=p_dstp->getP4Lab();
3803  p4_dstm=p_dstm->getP4Lab();
3804  p4_pip=p_pip->getP4Lab();
3805  p4_pim=p_pim->getP4Lab();
3806  p4_d0=p_d0->getP4Lab();
3807  p4_d0b=p_d0b->getP4Lab();
3808 
3809  double costhpip=EvtDecayAngle(p4_b,p4_pip+p4_d0,p4_pip);
3810  double costhpim=EvtDecayAngle(p4_b,p4_pim+p4_d0b,p4_pim);
3811  double chiang=EvtDecayAngleChi(p4_b,p4_pip,p4_d0,p4_pim,p4_d0b);
3812 
3813  cospip->Fill( costhpip );
3814  cospim->Fill( costhpim );
3815  chi->Fill( chiang );
3816  if (costhpip>0) chicospipp->Fill( chiang );
3817  if (costhpip<0) chicospipn->Fill( chiang );
3818 
3819  if (costhpip>0 && costhpim>0) chipp->Fill( chiang );
3820  if (costhpip>0 && costhpim<0) chipn->Fill( chiang );
3821  if (costhpip<0 && costhpim>0) chinp->Fill( chiang );
3822  if (costhpip<0 && costhpim<0) chinn->Fill( chiang );
3823  if (costhpip<-0.5 && costhpim<-0.5) chinnnn->Fill( chiang );
3824  root_part->deleteTree();
3825 
3826  }while (count++<nevent);
3827 
3828  file->Write(); file->Close();
3829  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
3830 }
3831 
3832 void runPartWave2(int nevent, EvtGen &myGenerator) {
3833 
3834  TFile file("partwave2.root", "RECREATE");
3835 
3836  TH1F* cthetapi = new TH1F("h1","cos theta pi",
3837  50,-1.0,1.0);
3838 
3839  TH1F* cthetapi2 = new TH1F("h2","cos theta pi (|cosrho|<0.1)",
3840  50,-1.0,1.0);
3841 
3842 
3843  TH1F* cthetan = new TH1F("h3","cos thetan",
3844  50,-1.0,1.0);
3845 
3846 
3847  //TH1F* cthetan2 = new TH1F("h4","cos thetan costhetapi>0 ",
3848  // 50,-1.0,1.0);
3849 
3850  TH1F* cthetarho = new TH1F("h4","cos thetarho ",
3851  50,-1.0,1.0);
3852  int count=1;
3853 
3854  char udecay_name[100];
3855  strcpy(udecay_name,"exampleFiles/PARTWAVE2.DEC");
3856  myGenerator.readUDecay(udecay_name);
3857 
3858  static EvtId JPSI=EvtPDL::getId(std::string("J/psi"));
3859  static EvtId B0=EvtPDL::getId(std::string("B0"));
3860 
3861  do{
3862  EvtVector4R p_init(EvtPDL::getMass(B0),0.0,0.0,0.0);
3863 
3864  EvtParticle* root_part=EvtParticleFactory::particleFactory(B0,
3865  p_init);
3866  root_part->setDiagonalSpinDensity();
3867 
3868  myGenerator.generateDecay(root_part);
3869 
3870  EvtParticle *p_b,*p_jpsi,*p_rho,*p_pi1,*p_pi2;
3871  EvtVector4R p4_b,p4_jpsi,p4_rho,p4_pi1,p4_pi2;
3872 
3873  p_b=root_part;
3874 
3875  p_jpsi=root_part->getDaug(0);
3876 
3877  p_rho=0;
3878 
3879  if (p_jpsi->getDaug(0)->getNDaug()==2){
3880  p_rho=p_jpsi->getDaug(0);
3881  }
3882 
3883  if (p_jpsi->getDaug(1)->getNDaug()==2){
3884  p_rho=p_jpsi->getDaug(1);
3885  }
3886 
3887  assert(p_rho!=0);
3888 
3889  p_pi1=p_rho->getDaug(0);
3890  p_pi2=p_rho->getDaug(1);
3891 
3892  p4_b=p_b->getP4Lab();
3893  p4_jpsi=p_jpsi->getP4Lab();
3894  p4_rho=p_rho->getP4Lab();
3895  p4_pi1=p_pi1->getP4Lab();
3896  p4_pi2=p_pi2->getP4Lab();
3897 
3898  double costhetan=EvtDecayPlaneNormalAngle(p4_b,p4_jpsi,p4_pi1,p4_pi2);
3899 
3900  //EvtGenReport(EVTGEN_INFO,"EvtGen") << "costhetan:"<<costhetan<<std::endl;
3901 
3902  cthetan->Fill( costhetan );
3903 
3904  double costhpi=EvtDecayAngle(p4_jpsi,p4_rho,p4_pi1);
3905 
3906  double costhrho=EvtDecayAngle(p4_b,p4_jpsi,p4_rho);
3907 
3908  //EvtGenReport(EVTGEN_INFO,"EvtGen") << "costhetarho:"<<costhrho<<std::endl;
3909 
3910  cthetarho->Fill( costhrho );
3911 
3912  //if (((p4_rho.get(3)/p4_rho.d3mag()))<-0.95) cthetan2->Fill( costhetan );
3913 
3914  cthetapi->Fill( costhpi );
3915 
3916  if ((p4_rho.get(3)/p4_rho.d3mag())>0.9) {
3917  cthetapi2->Fill( costhpi );
3918  }
3919 
3920  root_part->deleteTree();
3921 
3922  }while (count++<nevent);
3923 
3924  file.Write(); file.Close();
3925  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
3926 
3927 }
3928 
3929 void runTwoBody(int nevent, EvtGen &myGenerator, std::string decFile,
3930  std::string rootFile) {
3931 
3932  TFile *file=new TFile(rootFile.c_str(), "RECREATE");
3933 
3934  int count=0;
3935 
3936  myGenerator.readUDecay(decFile.c_str());
3937 
3938  static EvtId B0=EvtPDL::getId(std::string("B0"));
3939 
3940  vector<TH1F*> histograms;
3941 
3942  do{
3943  EvtVector4R p_init(EvtPDL::getMass(B0),0.0,0.0,0.0);
3944 
3945  EvtParticle* root_part=EvtParticleFactory::particleFactory(B0,
3946  p_init);
3947  root_part->setDiagonalSpinDensity();
3948 
3949  myGenerator.generateDecay(root_part);
3950 
3951  //root_part->printTree();
3952 
3953  myGenerator.generateDecay(root_part);
3954  int nhist=0;
3955 
3956  EvtParticle* p=root_part;
3957 
3958  do {
3959 
3960  int nDaug=p->getNDaug();
3961 
3962  if (!(nDaug==0||nDaug==2)) {
3963  EvtGenReport(EVTGEN_INFO,"EvtGen") << "nDaug="<<nDaug<<" but can only handle 0 or 2!"<<std::endl;
3964  abort();
3965  }
3966 
3967  if (nDaug==2){
3968  if (p->getParent()==0){
3969  EvtVector4R p4=p->getDaug(0)->getP4();
3970  double ctheta=p4.get(3)/p4.d3mag();
3971  double phi=atan2(p4.get(2),p4.get(1));
3972  if (count==0){
3973  histograms.push_back(new TH1F("h1","cos theta",50,-1.0,1.0));
3974  histograms.push_back(new TH1F("h2","phi",50,-EvtConst::pi
3975  ,EvtConst::pi));
3976  }
3977  histograms[nhist++]->Fill(ctheta);
3978  histograms[nhist++]->Fill(phi);
3979  }
3980  else{
3981  double ctheta=EvtDecayAngle(p->getParent()->getP4Lab(),
3982  p->getP4Lab(),
3983  p->getDaug(0)->getP4Lab());
3984  if (count==0){
3985 // char* tmp=new char[10];
3986 // std::ostrstream strm(tmp,9);
3987 // strm << (nhist+1) << '\0'<< std::endl;
3988 // histograms.push_back(new TH1F(TString("h")+tmp,TString("cos theta")+tmp,50,-1.0,1.0));
3989  std::ostringstream strm;
3990  strm << (nhist+1);
3991  histograms.push_back( new TH1F(TString("h") + strm.str(),
3992  TString("cos theta") + strm.str(),
3993  50,-1.0,1.0) );
3994  }
3995  histograms[nhist++]->Fill(ctheta);
3996  if (p->getDaug(0)->getNDaug()==2) {
3997  double costhetan=EvtDecayPlaneNormalAngle(p->getParent()->getP4Lab(),
3998  p->getP4Lab(),
3999  p->getDaug(0)->getDaug(0)->getP4Lab(),
4000  p->getDaug(0)->getDaug(1)->getP4Lab());
4001  if (count==0){
4002 // char* tmp=new char[10];
4003 // std::ostrstream strm(tmp,9);
4004 // strm << (nhist+1) << '\0'<< std::endl;
4005 // histograms.push_back(new TH1F(TString("h")+tmp,TString("cos thetan")+tmp,50,-1.0,1.0));
4006  std::ostringstream strm;
4007  strm << (nhist+1);
4008  histograms.push_back( new TH1F(TString("h") + strm.str(),
4009  TString("cos theta") + strm.str(),
4010  50,-1.0,1.0) );
4011  }
4012  histograms[nhist++]->Fill(costhetan);
4013  }
4014  if (p->getDaug(1)->getNDaug()==2) {
4015  double costhetan=EvtDecayPlaneNormalAngle(p->getParent()->getP4Lab(),
4016  p->getP4Lab(),
4017  p->getDaug(1)->getDaug(0)->getP4Lab(),
4018  p->getDaug(1)->getDaug(1)->getP4Lab());
4019  if (count==0){
4020 // char* tmp=new char[10];
4021 // std::ostrstream strm(tmp,9);
4022 // strm << (nhist+1) << '\0'<< std::endl;
4023 // histograms.push_back(new TH1F(TString("h")+tmp,TString("cos thetan")+tmp,50,-1.0,1.0));
4024  std::ostringstream strm;
4025  strm << (nhist+1);
4026  histograms.push_back( new TH1F(TString("h") + strm.str(),
4027  TString("cos theta") + strm.str(),
4028  50,-1.0,1.0) );
4029  }
4030  histograms[nhist++]->Fill(costhetan);
4031  }
4032  }
4033  }
4034 
4035  p=p->nextIter(root_part);
4036 
4037  }while(p!=0);
4038 
4039  root_part->deleteTree();
4040 
4041  }while (count++<nevent);
4042 
4043  file->Write(); file->Close();
4044  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
4045 }
4046 
4047 
4048 void runPiPi(int nevent, EvtGen &myGenerator) {
4049  std::ofstream outmix;
4050  outmix.open("pipi.dat");
4051 
4052  TFile *file=new TFile("pipi.root", "RECREATE");
4053 
4054  TH1F* tB0Hist = new TH1F("h1","dt in B->pipi with B0 tag",50,-5.0,5.0);
4055  TH1F* tB0BHist = new TH1F("h2","dt in B->pipi with B0B tag",50,-5.0,5.0);
4056 
4057  TH1F* tB0 = new TH1F("h3","t in B->pipi for B0 tag",25,0.0,5.0);
4058  TH1F* tB0B = new TH1F("h4","t in B->pipi for B0B tag",25,0.0,5.0);
4059 
4060  char udecay_name[100];
4061  strcpy(udecay_name,"exampleFiles/PIPI.DEC");
4062  //EvtGen myGenerator(decay_name,pdttable_name,myRandomEngine);
4063  myGenerator.readUDecay(udecay_name);
4064 
4065  EvtParticle *bcp,*btag;
4066 
4067  int count=1;
4068 
4069  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
4070  static EvtId VPHO=EvtPDL::getId(std::string("vpho"));
4071  static EvtId GAMM=EvtPDL::getId(std::string("gamma"));
4072  static EvtId B0=EvtPDL::getId(std::string("B0"));
4073  static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
4074 
4075  do{
4076  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
4077 
4078  EvtParticle* root_part=EvtParticleFactory::particleFactory(UPS4,
4079  p_init);
4080  root_part->setVectorSpinDensity();
4081 
4082  myGenerator.generateDecay(root_part);
4083 
4084  if (root_part->getDaug(0)->getNDaug()==3){
4085  btag=root_part->getDaug(0);
4086  bcp=root_part->getDaug(1);
4087  }
4088  else{
4089  bcp=root_part->getDaug(0);
4090  btag=root_part->getDaug(1);
4091  }
4092 
4093  EvtId tag; //cp tag
4094 
4095  if (btag->getId()==B0B){
4096  tag=B0;
4097  }
4098  else{tag=B0B;
4099  }
4100 
4101  // int a1=bcp->getDaug(0)->getId();
4102 
4103  if (tag==B0) tB0Hist->Fill( bcp->getLifetime() - btag->getLifetime() );
4104  if (tag==B0) tB0->Fill( btag->getLifetime() );
4105  if (tag==B0B) tB0BHist->Fill( bcp->getLifetime() - btag->getLifetime() );
4106  if (tag==B0B) tB0B->Fill( btag->getLifetime() );
4107 
4108  outmix << bcp->getLifetime() << " " <<
4109  btag->getLifetime() << " " << tag.getId() << std::endl;
4110 
4111  root_part->deleteTree();
4112 
4113  }while (count++<nevent);
4114 
4115  outmix.close();
4116  file->Write(); file->Close();
4117  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
4118 }
4119 
4120 void runA1Pi(int nevent, EvtGen &myGenerator) {
4121 
4122  std::ofstream outmix;
4123  outmix.open("a1pi.dat");
4124 
4125  int count=1;
4126 
4127  char udecay_name[100];
4128  strcpy(udecay_name,"exampleFiles/A1PI.DEC");
4129  myGenerator.readUDecay(udecay_name);
4130 
4131  EvtParticle *bcp,*btag;
4132  EvtParticle *a1,*rho0,*pi1,*pi2,*pi3,*pi4;
4133  EvtVector4R p4bcp,p4a1,p4rho0,p4pi1,p4pi2,p4pi3,p4pi4;
4134  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
4135  static EvtId B0=EvtPDL::getId(std::string("B0"));
4136  static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
4137 
4138  do{
4139  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
4140 
4141  EvtParticle* root_part=EvtParticleFactory::particleFactory(UPS4,
4142  p_init);
4143  root_part->setVectorSpinDensity();
4144  myGenerator.generateDecay(root_part);
4145 
4146  if (root_part->getDaug(0)->getNDaug()==3){
4147  btag=root_part->getDaug(0);
4148  bcp=root_part->getDaug(1);
4149  }
4150  else{
4151  bcp=root_part->getDaug(0);
4152  btag=root_part->getDaug(1);
4153  }
4154 
4155  a1=bcp->getDaug(0);
4156  pi1=bcp->getDaug(1);
4157 
4158  rho0=a1->getDaug(0);
4159  pi2=a1->getDaug(1);
4160 
4161  pi3=rho0->getDaug(0);
4162  pi4=rho0->getDaug(1);
4163 
4164  p4bcp=bcp->getP4Lab();
4165  p4a1=a1->getP4Lab();
4166  p4pi1=pi1->getP4Lab();
4167 
4168  p4rho0=rho0->getP4Lab();
4169  p4pi2=pi2->getP4Lab();
4170 
4171  p4pi3=pi3->getP4Lab();
4172  p4pi4=pi4->getP4Lab();
4173 
4174  EvtId tag; //cp tag
4175 
4176  if (btag->getId()==B0B){
4177  tag=B0;
4178  }
4179  else{
4180  tag=B0B;
4181  }
4182 
4183  outmix << bcp->getLifetime() << " " <<
4184  btag->getLifetime() << " " <<
4185  EvtDecayAngle(p4bcp,p4rho0+p4pi2,p4rho0) << " "<<
4186  EvtDecayAngle(p4a1,p4pi3+p4pi4,p4pi3) << " "<<
4187  EvtPDL::getStdHep(tag) << std::endl;
4188 
4189  root_part->deleteTree();
4190 
4191  }while (count++<1000);
4192 
4193  outmix.close();
4194  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
4195 }
4196 
4197 void runCPTest(int nevent, EvtGen &myGenerator) {
4198 
4199  std::ofstream outmix;
4200  outmix.open("cptest.dat");
4201 
4202  int count=1;
4203 
4204  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
4205  static EvtId B0=EvtPDL::getId(std::string("B0"));
4206  static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
4207 
4208  char udecay_name[100];
4209  strcpy(udecay_name,"exampleFiles/CPTEST.DEC");
4210  //EvtGen myGenerator(decay_name,pdttable_name,myRandomEngine);
4211  myGenerator.readUDecay(udecay_name);
4212 
4213  EvtParticle *bcp,*btag;
4214 
4215  do{
4216 
4217  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
4218 
4219  EvtParticle* root_part=EvtParticleFactory::particleFactory(UPS4,
4220  p_init);
4221  root_part->setVectorSpinDensity();
4222 
4223  myGenerator.generateDecay(root_part);
4224 
4225  if (root_part->getDaug(0)->getNDaug()==3){
4226  btag=root_part->getDaug(0);
4227  bcp=root_part->getDaug(1);
4228  }
4229  else{
4230  bcp=root_part->getDaug(0);
4231  btag=root_part->getDaug(1);
4232  }
4233 
4234  EvtId tag; //cp tag
4235 
4236  if (btag->getId()==B0B){
4237  tag=B0;
4238  }
4239  else{
4240  tag=B0B;
4241  }
4242 
4243  outmix << bcp->getLifetime() << " " <<
4244  btag->getLifetime() << " " << tag.getId() << std::endl;
4245 
4246  root_part->deleteTree();
4247 
4248  }while (count++<nevent);
4249 
4250  outmix.close();
4251  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
4252 
4253 }
4254 
4255 
4256 void runBtoXsgamma(int nevent, EvtGen &myGenerator) {
4257 
4258  static EvtId UPS4 = EvtPDL::getId(std::string("Upsilon(4S)"));
4259  TFile *file=new TFile("BtoXsgamma.root", "RECREATE");
4260 
4261  int count=1;
4262 
4263  EvtParticle* root_part;
4264  EvtVectorParticle *vector_part;
4265 
4266  char udecay_name[100];
4267  strcpy(udecay_name,"exampleFiles/BTOXSGAMMA.DEC");
4268 
4269  myGenerator.readUDecay(udecay_name);
4270 
4271  // Plot kinematics for b->s,gamma
4272  int strangeid,antistrangeid;
4273  int Bmulti,bId1a,bId1b,bId2a,bId2b,b1Id,b2Id;
4274  do{
4275  vector_part = new EvtVectorParticle;
4276  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
4277 
4278  vector_part->init(UPS4,p_init);
4279 
4280  root_part = (EvtParticle *)vector_part;
4281  root_part->setVectorSpinDensity();
4282 
4283  myGenerator.generateDecay(root_part);
4284 
4285  EvtParticle *B1 = root_part->getDaug(0);
4286  Bmulti= B1->getNDaug();
4287  if (Bmulti==1) B1 = B1->getDaug(0);
4288  EvtId BId1a = B1->getDaug(0)->getId();
4289  bId1a = EvtPDL::getStdHep(BId1a);
4290  EvtId BId1b = B1->getDaug(1)->getId();
4291  bId1b = EvtPDL::getStdHep(BId1b);
4292 
4293  if (Bmulti==1) EvtGenReport(EVTGEN_INFO,"EvtGen") << "B1" << " bId1a=" << bId1a << " bId1b=" << bId1b << " ndaug=" << B1->getNDaug() << " Bid=" << EvtPDL::getStdHep(B1->getId()) << std::endl;
4294 
4295  EvtParticle *B2 = root_part->getDaug(1);
4296  Bmulti= B2->getNDaug();
4297  if (Bmulti==1) B2 = B2->getDaug(0); // B has a daughter which is a string
4298  EvtId BId2a = B2->getDaug(0)->getId();
4299  bId2a = EvtPDL::getStdHep(BId2a);
4300  EvtId BId2b = B2->getDaug(1)->getId();
4301  bId2b = EvtPDL::getStdHep(BId2b);
4302 
4303  if (Bmulti==1) EvtGenReport(EVTGEN_INFO,"EvtGen") << "B2" << " bId2a=" << bId2a << " bId2b=" << bId2b << " ndaug=" << B2->getNDaug() << " Bid=" << EvtPDL::getStdHep(B2->getId()) << std::endl;
4304 
4305  EvtId B1Id = B1->getId();
4306  b1Id = EvtPDL::getStdHep(B1Id);
4307  EvtId B2Id = B2->getId();
4308  b2Id = EvtPDL::getStdHep(B2Id);
4309 
4310  strangeid=0;
4311  antistrangeid=0;
4312  if ((b1Id == 511) || (b1Id == -511) || (b2Id == 511) || (b2Id == -511)) {
4313  strangeid=30343; antistrangeid=-30343;
4314  } else if ((b1Id == 521) || (b1Id == -521) || (b2Id == 521) || (b2Id == -521)) {
4315  strangeid=30353; antistrangeid=-30353;
4316  } else if ((b1Id == 531) || (b1Id == -531) || (b2Id == 531) || (b2Id == -531)) {
4317  strangeid=30363; antistrangeid=-30363;
4318  }
4319  EvtGenReport(EVTGEN_INFO,"EvtGen") << "bId1a "<<bId1a<<" bId1b "<<bId1b<<" bId2a "<<bId2a<<" bId2b "<<bId2b<<" for event "<<count<<std::endl;
4320 
4321  EvtParticle *Bpeng = 0;
4322  int bnum=0;
4323  int pengcount=0;
4324  if (((bId1a == strangeid) && (bId1b == 22)) || ((bId1a == antistrangeid) && (bId1b == 22))|| ((bId1b == strangeid) && (bId1a == 22)) || ((bId1b == antistrangeid) && (bId1a == 22))) {
4325  Bpeng = B1;
4326  bnum=1;
4327  pengcount++;
4328  }
4329  if (((bId2a == strangeid) && (bId2b == 22)) || ((bId2a == antistrangeid) && (bId2b == 22)) || ((bId2b == strangeid) && (bId2a == 22)) || ((bId2b == antistrangeid) && (bId2a == 22))) {
4330  Bpeng = B2;
4331  bnum=2;
4332  pengcount++;
4333  }
4334  if (pengcount == 0) {
4335  Bpeng=B1;
4336  EvtGenReport(EVTGEN_INFO,"EvtGen") << "No penguin decay for event "<<count<<std::endl;
4337  bnum=0;
4338  } else if (pengcount == 2) {
4339  Bpeng=B1;
4340  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Two penguin decays in event "<<count<<std::endl;
4341  bnum=0;
4342  }
4343  Bmulti = Bpeng->getNDaug();
4344  EvtParticle *Xs = Bpeng->getDaug(0);
4345  EvtParticle *gam = Bpeng->getDaug(1);
4346 
4347  EvtVector4R p4Xs = Xs->getP4Lab();
4348 
4349  EvtId BId = Bpeng->getId();
4350 
4351  EvtId XsId = Xs->getId();
4352  int Xsmulti = Xs->getNDaug();
4353  EvtId gamId = gam->getId();
4354 
4355  //int bId = EvtPDL::getStdHep(BId);
4356  //int XId = EvtPDL::getStdHep(XsId);
4357  //int gId = EvtPDL::getStdHep(gamId);
4358 
4359  //float XsMass = p4Xs.mass();
4360  //double gmass = p4gam.mass();
4361  //double genergy = p4gam.get(0);
4362 
4363 // debug stuff: EvtGenReport(EVTGEN_INFO,"EvtGen") << "bnum=" << bnum << " pengcount=" << pengcount << " bId=" << bId << " Bmulti=" << Bmulti << " XsId=" << XId << " gId=" << gId << std::endl;
4364 
4365  //need to change this to root...I don't have the energy now
4366  //tuple->column("bnum", bnum);
4367  //tuple->column("pengcount", pengcount);
4368  //tuple->column("bId", bId);
4369  //tuple->column("Bmulti", Bmulti);
4370  //tuple->column("XsId", XId);
4371  //tuple->column("gId", gId);
4372  //tuple->column("XsMass", XsMass);
4373  //tuple->column("Xsmulti", Xsmulti, 0,"Xs", HTRange<int>(0,200));
4374  //tuple->column("gmass", gmass);
4375  //tuple->column("genergy", genergy);
4376  //HTValOrderedVector<int> XDaugId, XDaugNephewId;
4377  //HTValOrderedVector<float> XsDaugMass, XsDaugNephewMass;
4378  int nTot(0);
4379  for(int i=0;i<Xsmulti;i++){
4380  EvtParticle *XsDaug = Xs->getDaug(i);
4381  EvtVector4R p4XsDaug = XsDaug->getP4Lab();
4382  EvtId XsDaugId = XsDaug->getId();
4383  //XDaugId.push_back(EvtPDL::getStdHep(XsDaugId));
4384  //XsDaugMass.push_back( p4XsDaug.mass());
4385 
4386  int Daumulti = XsDaug->getNDaug();
4387  if(abs(EvtPDL::getStdHep(XsDaugId))==321||EvtPDL::getStdHep(XsDaugId)==310||EvtPDL::getStdHep(XsDaugId)==111||abs(EvtPDL::getStdHep(XsDaugId))==211||Daumulti==0){
4388  nTot++;
4389  EvtVector4R p4XsDaugNephew = XsDaug->getP4Lab();
4390  EvtId XsDaugNephewId =XsDaug->getId() ;
4391  //XDaugNephewId.push_back(EvtPDL::getStdHep(XsDaugId));
4392  //XsDaugNephewMass.push_back( p4XsDaug.mass());
4393 
4394  }else if(Daumulti!=0){
4395 
4396  for(int k=0;k<Daumulti;k++){
4397  EvtParticle *XsDaugNephew = XsDaug->getDaug(k);
4398  EvtId XsDaugNephewId = XsDaugNephew->getId();
4399  int Nephmulti = XsDaugNephew->getNDaug();
4400 
4401  if(Nephmulti==0||abs(EvtPDL::getStdHep(XsDaugNephewId))==321||EvtPDL::getStdHep(XsDaugNephewId)==310||EvtPDL::getStdHep(XsDaugNephewId)==111||abs(EvtPDL::getStdHep(XsDaugNephewId))==211) {
4402  nTot++;
4403  EvtVector4R p4XsDaugNephew = XsDaugNephew->getP4Lab();
4404  //XDaugNephewId.push_back(EvtPDL::getStdHep(XsDaugNephewId));
4405  //XsDaugNephewMass.push_back( p4XsDaugNephew.mass());
4406  }else{
4407  for(int g=0;g<Nephmulti;g++){
4408  nTot++;
4409  EvtParticle *XsDaugNephewNephew = XsDaugNephew->getDaug(g);
4410  EvtVector4R p4XsDaugNephewNephew = XsDaugNephewNephew->getP4Lab();
4411  EvtId XsDaugNephewNephewId = XsDaugNephewNephew->getId();
4412  //XDaugNephewId.push_back(EvtPDL::getStdHep(XsDaugNephewNephewId));
4413  //XsDaugNephewMass.push_back( p4XsDaugNephewNephew.mass());
4414  }
4415  }
4416  }
4417  }
4418  }
4419  //tuple->column("XsDaugId", XDaugId,"Xsmulti", 0, "Xs");
4420  //tuple->column("XsDaugMass", XsDaugMass,"Xsmulti", 0, "Xs");
4421 
4422  //tuple->column("nTot", nTot, 0,"nTot", HTRange<int>(0,200));
4423  //tuple->column("XsDaugNephewId", XDaugNephewId,"nTot", 0, "nTot");
4424  //tuple->column("XsDaugNephewMass", XsDaugNephewMass,"nTot", 0, "nTot");
4425 
4426  //tuple->dumpData();
4427 
4428  root_part->deleteTree();
4429 
4430  }while (count++<nevent);
4431 
4432  file->Write(); file->Close();
4433 
4434  EvtGenReport(EVTGEN_INFO,"EvtGen")<<"End EvtGen. Ran on "<<nevent<<" events."<<std::endl;
4435  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
4436 
4437 }
4438 
4439 void runBtoK1273gamma(int nevent, EvtGen &myGenerator) {
4440 
4441  static EvtId UPS4 = EvtPDL::getId(std::string("Upsilon(4S)"));
4442  TFile *file=new TFile("BtoK1273gamma.root", "RECREATE");
4443  //HepTuple *tuple = hfile.ntuple("BtoK1273gamma", 1);
4444 
4445  int count=1;
4446 
4447  EvtParticle *root_part;
4448  EvtVectorParticle *vector_part;
4449 
4450  char udecay_name[100];
4451  strcpy(udecay_name,"exampleFiles/BTOK1273GAMMA.DEC");
4452 
4453  myGenerator.readUDecay(udecay_name);
4454 
4455  // Plot kinematics for b->s,gamma
4456  int strangeid,antistrangeid;
4457  int Bmulti,bId1a,bId1b,bId2a,bId2b,b1Id,b2Id;
4458  do{
4459  vector_part = new EvtVectorParticle;
4460  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
4461 
4462  vector_part->init(UPS4,p_init);
4463 
4464  root_part = (EvtParticle *)vector_part;
4465  root_part->setVectorSpinDensity();
4466 
4467  myGenerator.generateDecay(root_part);
4468 
4469  EvtParticle *B1 = root_part->getDaug(0);
4470  Bmulti= B1->getNDaug();
4471  if (Bmulti==1) B1 = B1->getDaug(0);
4472  EvtId BId1a = B1->getDaug(0)->getId();
4473  bId1a = EvtPDL::getStdHep(BId1a);
4474  EvtId BId1b = B1->getDaug(1)->getId();
4475  bId1b = EvtPDL::getStdHep(BId1b);
4476 
4477  if (Bmulti==1) EvtGenReport(EVTGEN_INFO,"EvtGen") << "B1" << " bId1a=" << bId1a << " bId1b=" << bId1b << " ndaug=" << B1->getNDaug() << " Bid=" << EvtPDL::getStdHep(B1->getId()) << std::endl;
4478 
4479  EvtParticle *B2 = root_part->getDaug(1);
4480  Bmulti= B2->getNDaug();
4481  if (Bmulti==1) B2 = B2->getDaug(0); // B has a daughter which is a string
4482  EvtId BId2a = B2->getDaug(0)->getId();
4483  bId2a = EvtPDL::getStdHep(BId2a);
4484  EvtId BId2b = B2->getDaug(1)->getId();
4485  bId2b = EvtPDL::getStdHep(BId2b);
4486 
4487  if (Bmulti==1) EvtGenReport(EVTGEN_INFO,"EvtGen") << "B2" << " bId2a=" << bId2a << " bId2b=" << bId2b << " ndaug=" << B2->getNDaug() << " Bid=" << EvtPDL::getStdHep(B2->getId()) << std::endl;
4488 
4489  EvtId B1Id = B1->getId();
4490  b1Id = EvtPDL::getStdHep(B1Id);
4491  EvtId B2Id = B2->getId();
4492  b2Id = EvtPDL::getStdHep(B2Id);
4493 
4494  strangeid=0;
4495  antistrangeid=0;
4496  if ((b1Id == 511) || (b1Id == -511) || (b2Id == 511) || (b2Id == -511)) {
4497  strangeid=10313; antistrangeid=-10313;
4498  } else if ((b1Id == 521) || (b1Id == -521) || (b2Id == 521) || (b2Id == -521)) {
4499  strangeid=10323; antistrangeid=-10323;
4500  }
4501  EvtGenReport(EVTGEN_INFO,"EvtGen") << "bId1a "<<bId1a<<" bId1b "<<bId1b<<" bId2a "<<bId2a<<" bId2b "<<bId2b<<" for event "<<count<<std::endl;
4502 
4503  EvtParticle *Bpeng = 0;
4504  int bnum=0;
4505  int pengcount=0;
4506  if (((bId1a == strangeid) && (bId1b == 22)) || ((bId1a == antistrangeid) && (bId1b == 22))|| ((bId1b == strangeid) && (bId1a == 22)) || ((bId1b == antistrangeid) && (bId1a == 22))) {
4507  Bpeng = B1;
4508  bnum=1;
4509  pengcount++;
4510  }
4511  if (((bId2a == strangeid) && (bId2b == 22)) || ((bId2a == antistrangeid) && (bId2b == 22)) || ((bId2b == strangeid) && (bId2a == 22)) || ((bId2b == antistrangeid) && (bId2a == 22))) {
4512  Bpeng = B2;
4513  bnum=2;
4514  pengcount++;
4515  }
4516  if (pengcount == 0) {
4517  Bpeng=B1;
4518  EvtGenReport(EVTGEN_INFO,"EvtGen") << "No penguin decay for event "<<count<<std::endl;
4519  bnum=0;
4520  } else if (pengcount == 2) {
4521  Bpeng=B1;
4522  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Two penguin decays in event "<<count<<std::endl;
4523  bnum=0;
4524  }
4525  Bmulti = Bpeng->getNDaug();
4526  EvtParticle *Ks = Bpeng->getDaug(0);
4527  //EvtParticle *gam = Bpeng->getDaug(1);
4528 
4529  EvtVector4R p4Ks = Ks->getP4Lab();
4530  //const EvtVector4R& p4gam = gam->getP4(); // gamma 4-mom in parent's rest frame
4531 
4532  //EvtId BId = Bpeng->getId();
4533 
4534  //EvtId KsId = Ks->getId();
4535  int Ksmulti = Ks->getNDaug();
4536  //EvtId gamId = gam->getId();
4537 
4538  //int bId = EvtPDL::getStdHep(BId);
4539  //int XId = EvtPDL::getStdHep(KsId);
4540  //int gId = EvtPDL::getStdHep(gamId);
4541 
4542  //double KsMass = p4Ks.mass();
4543  //double gmass = p4gam.mass();
4544  //double genergy = p4gam.get(0);
4545 
4546 // debug stuff: EvtGenReport(EVTGEN_INFO,"EvtGen") << "bnum=" << bnum << " pengcount=" << pengcount << " bId=" << bId << " Bmulti=" << Bmulti << " KsId=" << XId << " gId=" << gId << std::endl;
4547 
4548  //tuple->column("bnum", bnum);
4549  //tuple->column("pengcount", pengcount);
4550  //tuple->column("bId", bId);
4551  //tuple->column("Bmulti", Bmulti);
4552  //tuple->column("KsId", XId);
4553  //tuple->column("gId", gId);
4554  //tuple->column("KsMass", KsMass);
4555  //tuple->column("Ksmulti", Ksmulti);
4556  //tuple->column("gmass", gmass);
4557  //tuple->column("genergy", genergy);
4558 
4559  for(int i=0;i<Ksmulti;i++){
4560  EvtParticle *KsDaug = Ks->getDaug(i);
4561  EvtVector4R p4KsDaug = KsDaug->getP4Lab();
4562  EvtId KsDaugId = KsDaug->getId();
4563  //int XDaugId = EvtPDL::getStdHep(KsDaugId);
4564  //double KsDaugMass = p4KsDaug.mass();
4565  //tuple->column("KsDaugId", XDaugId);
4566  //tuple->column("KsDaugMass", KsDaugMass);
4567  }
4568 
4569  //tuple->dumpData();
4570 
4571  root_part->deleteTree();
4572 
4573  }while (count++<nevent);
4574 
4575  file->Write(); file->Close();
4576 
4577  EvtGenReport(EVTGEN_INFO,"EvtGen")<<"End EvtGen. Ran on "<<nevent<<" events."<<std::endl;
4578  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
4579 
4580 }
4581 
4582 
4583 void runCheckRotBoost(){
4584 
4585  EvtDiracSpinor sp1,sp2;
4586  //Generate ryd/lange random spinors.
4587  sp1.set(EvtComplex(1.0,-2.0),
4588  EvtComplex(3.0,1.0),
4589  EvtComplex(-4.5,0.5),
4590  EvtComplex(0.2,-0.5));
4591  sp2.set(EvtComplex(0.1,-1.0),
4592  EvtComplex(1.2,-0.5),
4593  EvtComplex(3.6,1.8),
4594  EvtComplex(-0.2,-0.6));
4595 
4596  EvtComplex s=EvtLeptonSCurrent(sp1,sp2);
4597  EvtComplex p=EvtLeptonPCurrent(sp1,sp2);
4598  EvtVector4C a=EvtLeptonACurrent(sp1,sp2);
4599  EvtVector4C v=EvtLeptonVCurrent(sp1,sp2);
4600  EvtVector4C va=EvtLeptonVACurrent(sp1,sp2);
4601  EvtTensor4C t=EvtLeptonTCurrent(sp1,sp2);
4602 
4603  //start with boosts...
4604  EvtVector4R ranBoost(2.0,0.4,-0.8,0.3);
4605 
4606  EvtDiracSpinor sp1Boost=boostTo(sp1,ranBoost);
4607  EvtDiracSpinor sp2Boost=boostTo(sp2,ranBoost);
4608 
4609  EvtComplex sBoost=EvtLeptonSCurrent(sp1Boost,sp2Boost);
4610  EvtComplex pBoost=EvtLeptonPCurrent(sp1Boost,sp2Boost);
4611  EvtVector4C aBoost=EvtLeptonACurrent(sp1Boost,sp2Boost);
4612  EvtVector4C vBoost=EvtLeptonVCurrent(sp1Boost,sp2Boost);
4613  EvtVector4C vaBoost=EvtLeptonVACurrent(sp1Boost,sp2Boost);
4614  EvtTensor4C tBoost=EvtLeptonTCurrent(sp1Boost,sp2Boost);
4615 
4616  EvtVector4C aDirBoost=boostTo(a,ranBoost);
4617  EvtVector4C vDirBoost=boostTo(v,ranBoost);
4618  EvtVector4C vaDirBoost=boostTo(va,ranBoost);
4619  EvtTensor4C tDirBoost(t);
4620  tDirBoost.applyBoostTo(ranBoost);
4621 
4622  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Comparing after doing a random boost"<<std::endl;
4623  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Scalar "<<s<<" "<<sBoost<<s-sBoost<<std::endl;
4624  EvtGenReport(EVTGEN_INFO,"EvtGen") << "PseudoScalar "<<p<<" "<<pBoost<<p-pBoost<<std::endl;
4625  EvtGenReport(EVTGEN_INFO,"EvtGen") << "AxialVector "<<aDirBoost<<" "<<aBoost<<aDirBoost-aBoost<<std::endl;
4626  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Vector "<<vDirBoost<<" "<<vBoost<<vDirBoost-vBoost<<std::endl;
4627  EvtGenReport(EVTGEN_INFO,"EvtGen") << "V-A "<<vaDirBoost<<" "<<vaBoost<<vaDirBoost-vaBoost<<std::endl;
4628  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Tensor "<<tDirBoost<<" "<<tBoost<<tDirBoost-tBoost<<std::endl;
4629  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Done comparing after doing a random boost"<<std::endl;
4630 
4631  //Now do rotations...
4632 
4633  //start with boosts...
4634  double alpha=0.4;
4635  double beta=-0.61;
4636  double gamma=3.0;
4637 
4638  EvtDiracSpinor sp1Rot=rotateEuler(sp1,alpha,beta,gamma);
4639  EvtDiracSpinor sp2Rot=rotateEuler(sp2,alpha,beta,gamma);
4640 
4641  EvtComplex sRot=EvtLeptonSCurrent(sp1Rot,sp2Rot);
4642  EvtComplex pRot=EvtLeptonPCurrent(sp1Rot,sp2Rot);
4643  EvtVector4C aRot=EvtLeptonACurrent(sp1Rot,sp2Rot);
4644  EvtVector4C vRot=EvtLeptonVCurrent(sp1Rot,sp2Rot);
4645  EvtVector4C vaRot=EvtLeptonVACurrent(sp1Rot,sp2Rot);
4646  EvtTensor4C tRot=EvtLeptonTCurrent(sp1Rot,sp2Rot);
4647 
4648  EvtVector4C aDirRot(a);
4649  EvtVector4C vDirRot(v);
4650  EvtVector4C vaDirRot(va);
4651  EvtTensor4C tDirRot(t);
4652  aDirRot.applyRotateEuler(alpha,beta,gamma);
4653  vDirRot.applyRotateEuler(alpha,beta,gamma);
4654  vaDirRot.applyRotateEuler(alpha,beta,gamma);
4655  tDirRot.applyRotateEuler(alpha,beta,gamma);
4656 
4657  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Comparing after doing a random rotation"<<std::endl;
4658  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Scalar "<<s<<" "<<sRot<<s-sRot<<std::endl;
4659  EvtGenReport(EVTGEN_INFO,"EvtGen") << "PseudoScalar "<<p<<" "<<pRot<<p-pRot<<std::endl;
4660  EvtGenReport(EVTGEN_INFO,"EvtGen") << "AxialVector "<<aDirRot<<" "<<aRot<<aDirRot-aRot<<std::endl;
4661  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Vector "<<vDirRot<<" "<<vRot<<vDirRot-vRot<<std::endl;
4662  EvtGenReport(EVTGEN_INFO,"EvtGen") << "V-A "<<vaDirRot<<" "<<vaRot<<vaDirRot-vaRot<<std::endl;
4663  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Tensor "<<tDirRot<<" "<<tRot<<tDirRot-tRot<<std::endl;
4664  EvtGenReport(EVTGEN_INFO,"EvtGen") << "Done comparing after doing a random rotation"<<std::endl;
4665  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
4666 
4667 }
4668 
4669 int countInclusive(std::string name, EvtParticle *root_part,TH1F* mom, TH1F* mass){
4670 
4671  EvtParticle *p = root_part;
4672  int temp=0;
4673  EvtId searchFor=EvtPDL::getId(name);
4674 
4675  do{
4676  EvtId type=p->getId();
4677  if (type==searchFor) {
4678  temp+=1;
4679  if ( mom) mom->Fill(p->getP4Lab().d3mag());
4680  if ( mass) mass->Fill(p->mass());
4681  //if ( theBs.contains(p->getParent()->getId()) ) {
4682  //dirPsimom->Fill(p->getP4Lab().d3mag());
4683  //}
4684  //EvtGenReport(EVTGEN_INFO,"EvtGen") << "LANGE " << p->getP4Lab().d3mag() << " " << p->getP4Lab().get(3)/p->getP4Lab().d3mag() << std::endl;
4685  }
4686 
4687  p=p->nextIter(root_part);
4688 
4689  }while(p!=0);
4690 
4691  return temp;
4692 }
4693 
4694 int countInclusiveSubTree(std::string name, EvtParticle *root_part,
4695  EvtIdSet setIds,
4696  TH1F* mom) {
4697 
4698  int temp=0;
4699  EvtParticle *p=root_part;
4700  do{
4701  if ( setIds.contains(p->getId()) ) {
4702  temp+=countInclusive(name,p);
4703 
4704  }
4705 
4706  //p->printTree();
4707  p=p->nextIter(root_part);
4708 
4709  }while(p!=0);
4710  //EvtGenReport(EVTGEN_INFO,"EvtGen") << "done"<<std::endl;
4711  return temp;
4712 }
4713 
4714 
4715 
4716 
4717 int countInclusiveParent(std::string name, EvtParticle *root_part,
4718  EvtIdSet setIds,
4719  TH1F* mom) {
4720 
4721 
4722  EvtParticle *p = root_part;
4723  int temp=0;
4724 
4725  EvtId searchFor=EvtPDL::getId(name);
4726 
4727  do{
4728  EvtId type=p->getId();
4729  if (type==searchFor) {
4730  if ( p->getParent() ) {
4731  if ( setIds.contains(p->getParent()->getId()) ) {
4732  temp+=1;
4733  if ( mom) mom->Fill(p->getP4Lab().d3mag());
4734  }
4735  }
4736  }
4737 
4738 
4739  p=p->nextIter(root_part);
4740  }while(p!=0);
4741 
4742  return temp;
4743 
4744 }
4745 
4746 
4747 void runBMix(int nevent,EvtGen &myGenerator,std::string userFile,std::string rootFile) {
4748 
4749  TFile *file=new TFile(rootFile.c_str(), "RECREATE");
4750 
4751  TH1F* b0_b0 = new TH1F("h1","dt B0-B0",100,-15.0,15.0);
4752  TH1F* b0b_b0b = new TH1F("h2","dt B0B-B0B",100,-15.0,15.0);
4753  TH1F* b0b_b0 = new TH1F("h3","dt B0B-B0",100,-15.0,15.0);
4754  TH1F* b0_b0b = new TH1F("h4","dt B0-B0B",100,-15.0,15.0);
4755 
4756  int count=1;
4757 
4758  myGenerator.readUDecay(userFile.c_str());
4759 
4760  EvtId b0=EvtPDL::getId("B0");
4761  EvtId b0b=EvtPDL::getId("anti-B0");
4762 
4763  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
4764 
4765  std::ofstream outmix;
4766  TString outFileName(rootFile);
4767  outFileName.ReplaceAll(".root", ".dat");
4768  outmix.open(outFileName.Data());
4769 
4770  do{
4771  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
4772 
4773  EvtParticle *root_part=EvtParticleFactory::particleFactory(UPS4,
4774  p_init);
4775  root_part->setVectorSpinDensity();
4776 
4777  myGenerator.generateDecay(root_part);
4778 
4779  EvtId id1=root_part->getDaug(0)->getId();
4780  EvtId id2=root_part->getDaug(1)->getId();
4781 
4782  double t1=root_part->getDaug(0)->getLifetime();
4783  double t2=root_part->getDaug(1)->getLifetime();
4784 
4785  double dt=(t1-t2)/(1e-12*3e11);
4786 
4787  if (id1==b0&&id2==b0) { b0_b0->Fill(dt); outmix << dt << " 1"<<std::endl;}
4788  if (id1==b0b&&id2==b0b) {b0b_b0b->Fill(dt); outmix << dt << " 2"<<std::endl;}
4789  if (id1==b0b&&id2==b0) {b0b_b0->Fill(dt); outmix << dt << " 0"<<std::endl;}
4790  if (id1==b0&&id2==b0b) {b0_b0b->Fill(dt); outmix << dt << " 0"<<std::endl;}
4791 
4792  root_part->deleteTree();
4793 
4794  }while (count++<nevent);
4795 
4796  file->Write(); file->Close();
4797  outmix.close();
4798 
4799  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
4800 
4801 }
4802 
4803 
4804 
4805 
4806 void runDDalitz(int nevent, EvtGen &myGenerator) {
4807 
4808  TFile *file=new TFile("ddalitz.root", "RECREATE");
4809 
4810  TH2F* dalitz = new TH2F("h1","m^2!?[K-[p]+! vs m^2!?[K-[p]0!",
4811  70,0.0,3.5,70,0.0,3.5);
4812  TH2F* dalitz2 = new TH2F("h5","m^2!([p]^-![p]^0!) vs m^2!([K-[p]+!",
4813  100,0.0,3.5,100,0.0,2.0);
4814 
4815  TH1F* m12=new TH1F("h2","m?[K-[p]+!",100,0.0,3.0);
4816  TH1F* m13=new TH1F("h3","m?[K-[p]0!",100,0.0,3.0);
4817  TH1F* m23=new TH1F("h4","m?[[p]+[p]0!",100,0.0,2.0);
4818 
4819 
4820  int count;
4821 
4822  myGenerator.readUDecay("exampleFiles/DDALITZ.DEC");
4823  count=1;
4824 
4825  static EvtId D0=EvtPDL::getId(std::string("D0"));
4826 
4827  std::ofstream outmix;
4828  outmix.open("ddalitz.dat");
4829 
4830 
4831  do{
4832 
4833  EvtVector4R p_init(EvtPDL::getMass(D0),0.0,0.0,0.0);
4834 
4835  EvtParticle *root_part=EvtParticleFactory::particleFactory(D0,
4836  p_init);
4837  root_part->setDiagonalSpinDensity();
4838 
4839  myGenerator.generateDecay(root_part);
4840 
4841  EvtVector4R p1=root_part->getDaug(0)->getP4Lab();
4842  EvtVector4R p2=root_part->getDaug(1)->getP4Lab();
4843  EvtVector4R p3=root_part->getDaug(2)->getP4Lab();
4844 
4845  dalitz->Fill((p1+p2).mass2(),(p1+p3).mass2(),1.0);
4846  dalitz2->Fill((p1+p2).mass2(),(p2+p3).mass2(),1.0);
4847 
4848  m12->Fill((p1+p2).mass2());
4849  m13->Fill((p1+p3).mass2());
4850  m23->Fill((p2+p3).mass2());
4851  outmix << (p1+p2).mass2() << " "<<(p2+p3).mass2()<<" "<<(p1+p3).mass2()<<std::endl;
4852  root_part->deleteTree();
4853 
4854  if(count == nevent-1) {
4855  std::ofstream testi("testi.dat");
4856  double val = m12->GetMean();
4857  double errval = m12->GetMeanError();
4858  testi << "evtgenlhc_test1 1 " << val << " " << errval << std::endl;
4859 
4860  val = m23->GetMean();
4861  errval = m23->GetMeanError();
4862  testi << "evtgenlhc_test1 2 " << val << " " << errval << std::endl;
4863  }
4864 
4865  }while (count++<nevent);
4866 
4867  file->Write(); file->Close();
4868  outmix.close();
4869  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
4870 
4871 }
4872 
4873 
4874 void runPiPiPi(int nevent, EvtGen &myGenerator) {
4875 
4876  std::ofstream outmix;
4877  outmix.open("pipipi.dat");
4878 
4879  int count;
4880  EvtVector4R p4pip,p4pim,p4pi0;
4881 
4882  myGenerator.readUDecay("exampleFiles/PIPIPI.DEC");
4883 
4884  count=1;
4885 
4886  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
4887 
4888 
4889  do{
4890 
4891  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
4892 
4893  EvtParticle *root_part=EvtParticleFactory::particleFactory(UPS4,
4894  p_init);
4895  root_part->setVectorSpinDensity();
4896 
4897  myGenerator.generateDecay(root_part);
4898 
4899  p4pip=root_part->getDaug(0)->getDaug(0)->getP4Lab();
4900  p4pim=root_part->getDaug(0)->getDaug(1)->getP4Lab();
4901  p4pi0=root_part->getDaug(0)->getDaug(2)->getP4Lab();
4902 
4903  outmix << root_part->getDaug(0)->getLifetime() << " " <<
4904  root_part->getDaug(1)->getLifetime()<< " ";
4905  outmix << (p4pip+p4pim).mass2()<<" "<<
4906  (p4pip+p4pi0).mass2()<<std::endl;
4907 
4908  root_part->deleteTree();
4909 
4910  }while (count++<10000);
4911 
4912  outmix.close();
4913  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
4914 
4915 }
4916 
4917 
4918 void runBHadronic(int nevent, EvtGen &myGenerator) {
4919 
4920  std::ofstream outmix;
4921  outmix.open("bhadronic.dat");
4922 
4923  int count;
4924 
4925  myGenerator.readUDecay("exampleFiles/BHADRONIC.DEC");
4926 
4927  static EvtId B0=EvtPDL::getId(std::string("B0"));
4928 
4929  count=1;
4930 
4931  do{
4932 
4933 
4934  EvtVector4R p_init(EvtPDL::getMass(B0),0.0,0.0,0.0);
4935 
4936  EvtParticle *root_part=EvtParticleFactory::particleFactory(B0,
4937  p_init);
4938  root_part->setDiagonalSpinDensity();
4939 
4940  myGenerator.generateDecay(root_part);
4941 
4942  EvtParticle *p;
4943 
4944  // root_part->printTree();
4945 
4946  p=root_part;
4947 
4948  do{
4949 
4950  outmix << p->getId().getId()<<" "<< p->getP4Lab().d3mag() << std::endl;
4951  p=p->nextIter();
4952 
4953  }while(p!=0);
4954 
4955  root_part->deleteTree();
4956 
4957  }while (count++<nevent);
4958 
4959  outmix.close();
4960  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
4961 
4962 }
4963 
4964 void runSingleB(int nevent, EvtGen &myGenerator) {
4965 
4966  int count;
4967 
4968  static EvtId B0=EvtPDL::getId(std::string("B0"));
4969 
4970  count=1;
4971 
4972  do{
4973  EvtVector4R p_init(EvtPDL::getMass(B0),0.0,0.0,0.0);
4974 
4975  EvtParticle *root_part=EvtParticleFactory::particleFactory(B0,
4976  p_init);
4977  root_part->setDiagonalSpinDensity();
4978 
4979  myGenerator.generateDecay(root_part);
4980 
4981 
4982  root_part->deleteTree();
4983 
4984  }while (count++<nevent);
4985 
4986  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
4987 
4988 }
4989 
4990 
4991 
4992 void runPiPiPiPi(int nevent, EvtGen &myGenerator) {
4993 
4994  std::ofstream outmix;
4995  outmix.open("pipipipi.dat");
4996 
4997  int count;
4998 
4999  EvtVector4R p4pi1,p4pi2,p4pi3,p4pi4;
5000 
5001 
5002  myGenerator.readUDecay("exampleFiles/PIPIPIPI.DEC");
5003 
5004  count=1;
5005 
5006  EvtParticle *bcp,*btag;
5007 
5008  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
5009  static EvtId B0=EvtPDL::getId(std::string("B0"));
5010  static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
5011 
5012  do{
5013 
5014 
5015  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
5016 
5017  EvtParticle *root_part=EvtParticleFactory::particleFactory(UPS4,
5018  p_init);
5019  root_part->setVectorSpinDensity();
5020 
5021  myGenerator.generateDecay(root_part);
5022 
5023  if (root_part->getDaug(0)->getNDaug()==3){
5024  btag=root_part->getDaug(0);
5025  bcp=root_part->getDaug(1);
5026  }
5027  else{
5028  bcp=root_part->getDaug(0);
5029  btag=root_part->getDaug(1);
5030  }
5031 
5032  EvtId tag; //cp tag
5033 
5034  if (btag->getId()==B0B){
5035  tag=B0;
5036  }
5037  else{
5038  tag=B0B;
5039  }
5040 
5041  p4pi1=bcp->getDaug(0)->getP4Lab();
5042  p4pi2=bcp->getDaug(1)->getP4Lab();
5043  p4pi3=bcp->getDaug(2)->getP4Lab();
5044  p4pi4=bcp->getDaug(3)->getP4Lab();
5045 
5046  EvtVector4R p4bcp,p4rho0,p4a2;
5047 
5048  p4rho0=p4pi1+p4pi2;
5049  p4a2=p4rho0+p4pi3;
5050  p4bcp=p4a2+p4pi4;
5051 
5052  outmix << bcp->getLifetime() << " " <<
5053  btag->getLifetime() << " " << tag.getId() <<" "
5054  << (p4pi1+p4pi2+p4pi3).mass() << " " <<
5055  (p4pi1+p4pi2).mass() << " " <<
5056  EvtDecayAngle(p4bcp,p4rho0+p4pi3,p4rho0) << " "<<
5057  EvtDecayAngle(p4a2,p4pi1+p4pi2,p4pi1) << std::endl;
5058 
5059  root_part->deleteTree();
5060 
5061  EvtGenReport(EVTGEN_INFO,"EvtGen") << "count:"<<count<<std::endl;
5062 
5063  }while (count++<1000);
5064 
5065  outmix.close();
5066  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
5067 
5068 }
5069 
5070 void runA2Pi(int nevent, EvtGen &myGenerator) {
5071 
5072  std::ofstream outmix;
5073  outmix.open("a2pi.dat");
5074 
5075  int count;
5076 
5077  myGenerator.readUDecay("exampleFiles/A2PI.DEC");
5078 
5079  EvtParticle *bcp,*btag;
5080  EvtParticle *a2,*rho0,*pi1,*pi2,*pi3,*pi4;
5081  EvtVector4R p4bcp,p4a2,p4rho0,p4pi1,p4pi2,p4pi3,p4pi4;
5082 
5083  count=1;
5084 
5085  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
5086  static EvtId B0=EvtPDL::getId(std::string("B0"));
5087  static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
5088 
5089  do{
5090 
5091 
5092  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
5093 
5094  EvtParticle *root_part=EvtParticleFactory::particleFactory(UPS4,
5095  p_init);
5096  root_part->setVectorSpinDensity();
5097 
5098  myGenerator.generateDecay(root_part);
5099 
5100  if (root_part->getDaug(0)->getNDaug()==3){
5101  btag=root_part->getDaug(0);
5102  bcp=root_part->getDaug(1);
5103  }
5104  else{
5105  bcp=root_part->getDaug(0);
5106  btag=root_part->getDaug(1);
5107  }
5108 
5109  a2=bcp->getDaug(0);
5110  pi1=bcp->getDaug(1);
5111 
5112  rho0=a2->getDaug(0);
5113  pi2=a2->getDaug(1);
5114 
5115  pi3=rho0->getDaug(0);
5116  pi4=rho0->getDaug(1);
5117 
5118  p4bcp=bcp->getP4Lab();
5119  p4a2=a2->getP4Lab();
5120  p4pi1=pi1->getP4Lab();
5121 
5122  p4rho0=rho0->getP4Lab();
5123  p4pi2=pi2->getP4Lab();
5124 
5125  p4pi3=pi3->getP4Lab();
5126  p4pi4=pi4->getP4Lab();
5127 
5128  EvtId tag; //cp tag
5129 
5130  if (btag->getId()==B0B){
5131  tag=B0;
5132  }
5133  else{
5134  tag=B0B;
5135  }
5136 
5137 
5138  outmix << bcp->getLifetime() << " " <<
5139  btag->getLifetime() << " " <<
5140  EvtDecayAngle(p4bcp,p4rho0+p4pi2,p4rho0) << " "<<
5141  EvtDecayAngle(p4a2,p4pi3+p4pi4,p4pi3) << " "<<
5142  EvtPDL::getStdHep(tag) << std::endl;
5143 
5144  root_part->deleteTree();
5145 
5146  }while (count++<1000);
5147 
5148  outmix.close();
5149 
5150  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
5151 
5152 }
5153 
5154 
5155 void runHelAmp(int nevent, EvtGen &myGenerator, std::string userFile,
5156  std::string rootFile) {
5157 
5158  TFile *file=new TFile(rootFile.c_str(), "RECREATE");
5159 
5160  TH1F* costheta = new TH1F("h1","costheta",100,-1.0,1.0);
5161  TH1F* costheta2 = new TH1F("h2","costheta2",100,-1.0,1.0);
5162 
5163  int count;
5164 
5165  myGenerator.readUDecay(userFile.c_str());
5166 
5167  count=1;
5168 
5169  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
5170 
5171 
5172  do{
5173 
5174  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
5175 
5176  EvtParticle *root_part=EvtParticleFactory::particleFactory(UPS4,
5177  p_init);
5178  root_part->setVectorSpinDensity();
5179 
5180  myGenerator.generateDecay(root_part);
5181 
5182  EvtVector4R d14=root_part->getDaug(0)->getP4Lab();
5183  double c=d14.get(3)/d14.d3mag();
5184  costheta->Fill(c);
5185 
5186  EvtVector4R p=root_part->getP4Lab();
5187  EvtVector4R q=root_part->getDaug(0)->getP4Lab();
5188  EvtVector4R d=root_part->getDaug(0)->getDaug(0)->getP4Lab();
5189 
5190  costheta2->Fill(EvtDecayAngle(p,q,d));
5191 
5192  root_part->deleteTree();
5193 
5194  }while (count++<nevent);
5195 
5196 
5197  file->Write(); file->Close();
5198  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
5199 
5200 }
5201 
5202 void runHelAmp2(int nevent, EvtGen &myGenerator) {
5203 
5204  TFile *file=new TFile("helamp2.root", "RECREATE");
5205 
5206  TH1F* costheta = new TH1F("h1","costheta",100,-1.0,1.0);
5207 
5208  int count;
5209 
5210  myGenerator.readUDecay("exampleFiles/HELAMP2.DEC");
5211 
5212  count=1;
5213 
5214  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
5215 
5216 
5217  do{
5218 
5219  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
5220 
5221  EvtParticle *root_part=EvtParticleFactory::particleFactory(UPS4,
5222  p_init);
5223  root_part->setVectorSpinDensity();
5224 
5225  myGenerator.generateDecay(root_part);
5226 
5227 
5228  EvtVector4R p=root_part->getDaug(0)->getDaug(0)->getP4Lab();
5229  EvtVector4R q=root_part->getDaug(0)->getDaug(0)->getDaug(0)->getP4Lab();
5230  EvtVector4R d=root_part->getDaug(0)->getDaug(0)->getDaug(0)->getDaug(0)->getP4Lab();
5231 
5232  costheta->Fill(EvtDecayAngle(p,q,d));
5233 
5234  root_part->deleteTree();
5235 
5236  }while (count++<nevent);
5237 
5238 
5239  file->Write(); file->Close();
5240  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
5241 
5242 }
5243 
5244 void runD2Pi(int nevent, EvtGen &myGenerator) {
5245 
5246  TFile *file=new TFile("d2pi.root", "RECREATE");
5247 
5248  TH1F* cospi = new TH1F("h1","cos[Q]?[p]!",50,-1.0,1.0);
5249  TH1F* ptpi = new TH1F("h2","Pt of pion",50,0.0,1.5);
5250  TH1F* ppi = new TH1F("h3","P?[p]! in [Y](4S) rest frame",50,0.0,1.5);
5251 
5252  int count;
5253 
5254  myGenerator.readUDecay("exampleFiles/D2PI.DEC");
5255 
5256  EvtParticle *b;
5257  EvtParticle *d2,*pi;
5258 
5259  EvtVector4R p4b,p4d2,p4pi;
5260 
5261  count=1;
5262 
5263  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
5264 
5265 
5266  do{
5267 
5268 
5269  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
5270 
5271  EvtParticle *root_part=EvtParticleFactory::particleFactory(UPS4,
5272  p_init);
5273  root_part->setVectorSpinDensity();
5274 
5275  myGenerator.generateDecay(root_part);
5276 
5277  b=root_part->getDaug(0);
5278 
5279  d2=b->getDaug(0);
5280 
5281  pi=d2->getDaug(1);
5282 
5283  p4b=b->getP4Lab();
5284  p4d2=d2->getP4Lab();
5285  p4pi=pi->getP4Lab();
5286 
5287 
5288  cospi->Fill(EvtDecayAngle(p4b,p4d2,p4pi));
5289  ptpi->Fill(sqrt(p4pi.get(2)*p4pi.get(2)+p4pi.get(3)*p4pi.get(3)));
5290  ppi->Fill(p4pi.d3mag());
5291 
5292 
5293  root_part->deleteTree();
5294 
5295  }while (count++<nevent);
5296 
5297  file->Write(); file->Close();
5298  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
5299 
5300 }
5301 
5302 
5303 void runPiPiCPT(int nevent, EvtGen &myGenerator) {
5304 
5305  std::ofstream outmix;
5306  outmix.open("pipicpt.dat");
5307 
5308  int count;
5309 
5310  myGenerator.readUDecay("exampleFiles/PIPICPT.DEC");
5311 
5312  EvtParticle *bcp,*btag;
5313 
5314  count=1;
5315 
5316  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
5317  static EvtId B0=EvtPDL::getId(std::string("B0"));
5318  static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
5319 
5320 
5321  do{
5322 
5323 
5324  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
5325 
5326  EvtParticle *root_part=EvtParticleFactory::particleFactory(UPS4,
5327  p_init);
5328  root_part->setVectorSpinDensity();
5329 
5330  myGenerator.generateDecay(root_part);
5331 
5332  if (root_part->getDaug(0)->getNDaug()==3){
5333  btag=root_part->getDaug(0);
5334  bcp=root_part->getDaug(1);
5335  }
5336  else{
5337  bcp=root_part->getDaug(0);
5338  btag=root_part->getDaug(1);
5339  }
5340 
5341  EvtId tag; //cp tag
5342 
5343  if (btag->getId()==B0B){
5344  tag=B0;
5345  }
5346  else{
5347  tag=B0B;
5348  }
5349 
5350  outmix << bcp->getLifetime() << " " <<
5351  btag->getLifetime() << " " << tag.getId() << std::endl;
5352 
5353  root_part->deleteTree();
5354 
5355  }while (count++<10000);
5356 
5357  outmix.close();
5358  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
5359 
5360 }
5361 
5362 
5363 void runJpsiKs(int nevent, EvtGen &myGenerator) {
5364 
5365  std::ofstream outmix;
5366  outmix.open("jpsiks.dat");
5367 
5368  int count;
5369 
5370  myGenerator.readUDecay("exampleFiles/JPSIKS.DEC");
5371 
5372  EvtParticle *bcp,*btag;
5373 
5374  count=1;
5375 
5376  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
5377  static EvtId B0=EvtPDL::getId(std::string("B0"));
5378  static EvtId B0B=EvtPDL::getId(std::string("anti-B0"));
5379 
5380 
5381  do{
5382 
5383  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
5384 
5385  EvtParticle *root_part=EvtParticleFactory::particleFactory(UPS4,
5386  p_init);
5387  root_part->setVectorSpinDensity();
5388 
5389  myGenerator.generateDecay(root_part);
5390 
5391  if (root_part->getDaug(0)->getNDaug()==3){
5392  btag=root_part->getDaug(0);
5393  bcp=root_part->getDaug(1);
5394  }
5395  else{
5396  bcp=root_part->getDaug(0);
5397  btag=root_part->getDaug(1);
5398  }
5399 
5400  EvtId tag; //cp tag
5401 
5402  if (btag->getId()==B0B){
5403  tag=B0;
5404  }
5405  else{
5406  tag=B0B;
5407  }
5408 
5409  outmix << bcp->getLifetime() << " " <<
5410  btag->getLifetime() << " " << tag.getId() << std::endl;
5411 
5412  root_part->deleteTree();
5413 
5414  }while (count++<10000);
5415 
5416  outmix.close();
5417  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
5418 
5419 }
5420 
5421 void runDump(int nevent, EvtGen &myGenerator) {
5422 
5423  int count;
5424 
5425 
5426  int stable_list[1];
5427  stable_list[0]=-1;
5428 
5429 
5430  std::ofstream outmix;
5431  outmix.open("dump.dat");
5432 
5433  EvtParticle *p;
5434 
5435  myGenerator.readUDecay("exampleFiles/DUMP.DEC");
5436 
5437  count=1;
5438 
5439  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
5440 
5441  static EvtId PI0=EvtPDL::getId(std::string("pi0"));
5442  static EvtId PIP=EvtPDL::getId(std::string("pi+"));
5443  static EvtId PIM=EvtPDL::getId(std::string("pi-"));
5444 
5445  static EvtId EP=EvtPDL::getId(std::string("e+"));
5446  static EvtId KP=EvtPDL::getId(std::string("K+"));
5447  static EvtId MUP=EvtPDL::getId(std::string("mu+"));
5448  static EvtId EM=EvtPDL::getId(std::string("e-"));
5449  static EvtId KM=EvtPDL::getId(std::string("K-"));
5450  static EvtId MUM=EvtPDL::getId(std::string("mu-"));
5451  static EvtId GAMM=EvtPDL::getId(std::string("gamma"));
5452  static EvtId K0L=EvtPDL::getId(std::string("K_L0"));
5453 
5454  do{
5455 
5456 
5457  if (count==100*(count/100)) {
5458  EvtGenReport(EVTGEN_INFO,"EvtGen") << count << std::endl;
5459  }
5460  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
5461 
5462  EvtParticle *root_part=EvtParticleFactory::particleFactory(UPS4,
5463  p_init);
5464  root_part->setVectorSpinDensity();
5465 
5466  myGenerator.generateDecay(root_part);
5467 
5468  p=root_part;
5469 
5470  EvtParticle *otherb=root_part->getDaug(1);
5471 
5472  EvtGenReport(EVTGEN_INFO,"EvtGen") <<"Event:"<<count<<std::endl;
5473  root_part->printTree();
5474 
5475  outmix << "B"
5476  <<" "<<otherb->getP4Lab().get(0)
5477  <<" "<<otherb->getP4Lab().get(1)
5478  <<" "<<otherb->getP4Lab().get(2)
5479  <<" "<<otherb->getP4Lab().get(3)<<std::endl;
5480 
5481  do{
5482 
5483 
5484  if (p->getId()==PIP||
5485  p->getId()==EP||
5486  p->getId()==KP||
5487  p->getId()==MUP){
5488  outmix << "chg +1"
5489  <<" "<<p->getP4Lab().get(1)
5490  <<" "<<p->getP4Lab().get(2)
5491  <<" "<<p->getP4Lab().get(3)<<std::endl;
5492  }
5493 
5494  if (p->getId()==PIM||
5495  p->getId()==EM||
5496  p->getId()==KM||
5497  p->getId()==MUM){
5498  outmix << "chg -1"
5499  <<" "<<p->getP4Lab().get(1)
5500  <<" "<<p->getP4Lab().get(2)
5501  <<" "<<p->getP4Lab().get(3)<<std::endl;
5502  }
5503 
5504  if (p->getId()==GAMM||
5505  p->getId()==K0L){
5506  outmix << "neu"
5507  <<" "<<p->getP4Lab().get(1)
5508  <<" "<<p->getP4Lab().get(2)
5509  <<" "<<p->getP4Lab().get(3)<<std::endl;
5510  }
5511 
5512 
5513  p=p->nextIter();
5514 
5515  }while(p!=0);
5516 
5517  outmix << "event"<<std::endl;
5518 
5519  root_part->deleteTree();
5520 
5521  }while (count++<nevent);
5522 
5523  outmix.close();
5524  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
5525 
5526 
5527 }
5528 
5529 void runGenericCont(int nevent, EvtGen &myGenerator) {
5530 
5531  int count;
5532 
5533  std::ofstream outmix;
5534  outmix.open("genericcont.dat");
5535 
5536  EvtParticle *p;
5537 
5538  myGenerator.readUDecay("exampleFiles/GENERIC.DEC");
5539 
5540  count=1;
5541 
5542  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
5543  static EvtId VPHO=EvtPDL::getId(std::string("vpho"));
5544 
5545  do{
5546 
5547  if (count==1000*(count/1000)) {
5548  EvtGenReport(EVTGEN_DEBUG,"EvtGen") << count << std::endl;
5549 
5550  }
5551 
5552  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
5553 
5554  EvtParticle *root_part=EvtParticleFactory::particleFactory(VPHO,
5555  p_init);
5556  root_part->setVectorSpinDensity();
5557 
5558  myGenerator.generateDecay(root_part);
5559 
5560  p=root_part;
5561 
5562  do{
5563 
5564  outmix << p->getId().getId()<<" "<< p->getP4Lab().d3mag() << std::endl;
5565 
5566  p=p->nextIter();
5567 
5568  }while(p!=0);
5569 
5570  //root_part->printTree();
5571 
5572  root_part->deleteTree();
5573 
5574  }while (count++<nevent);
5575 
5576  outmix.close();
5577 
5578  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
5579 
5580 }
5581 
5582 
5583 void runD1(int nevent, EvtGen &myGenerator) {
5584 
5585  std::ofstream outmix;
5586  outmix.open("d1.dat");
5587 
5588  int count=1;
5589 
5590  myGenerator.readUDecay("exampleFiles/D1.DEC");
5591 
5592  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
5593 
5594  do{
5595  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
5596  EvtParticle *root_part=EvtParticleFactory::particleFactory(UPS4,
5597  p_init);
5598  root_part->setVectorSpinDensity();
5599 
5600  myGenerator.generateDecay(root_part);
5601 
5602  EvtParticle *p_b,*p_d1,*p_e,*p_nu,*p_pi1,*p_dstar,*p_pi2,*p_d;
5603  EvtVector4R p4_b,p4_d1,p4_e,p4_nu,p4_pi1,p4_dstar,p4_pi2,p4_d;
5604 
5605  // code for analyzing B->D1 e nu ; D1 -> D* pi ; D* -> D pi
5606 
5607  p_b=root_part->getDaug(1);
5608 
5609  p_d1=p_b->getDaug(0);
5610  p_e=p_b->getDaug(1);
5611  p_nu=p_b->getDaug(2);
5612 
5613  p_dstar=p_d1->getDaug(0);
5614  p_pi1=p_d1->getDaug(1);
5615 
5616  p_d=p_dstar->getDaug(0);
5617  p_pi2=p_dstar->getDaug(1);
5618 
5619  p4_b=p_b->getP4Lab();
5620  p4_d1=p_d1->getP4Lab();
5621  p4_e=p_e->getP4Lab();
5622  p4_nu=p_nu->getP4Lab();
5623  p4_dstar=p_dstar->getP4Lab();
5624  p4_pi1=p_pi1->getP4Lab();
5625  p4_pi2=p_pi2->getP4Lab();
5626  p4_d=p_d->getP4Lab();
5627 
5628  outmix << p4_e.get(0)<<" ";
5629  outmix << (p4_e+p4_nu)*(p4_e+p4_nu)<<" ";
5630  outmix << EvtDecayAngle(p4_b,p4_e+p4_nu,p4_e) << " " ;
5631  outmix << EvtDecayAngle(p4_b,p4_dstar+p4_pi1,p4_dstar) << " " ;
5632  outmix << EvtDecayAngle(p4_d1,p4_d+p4_pi2,p4_d) << " " ;
5633  outmix << EvtDecayAngleChi(p4_b,p4_e,p4_nu,
5634  p4_dstar, p4_pi1 ) << "\n" ;
5635 
5636  root_part->deleteTree();
5637 
5638  EvtGenReport(EVTGEN_DEBUG,"EvtGen") << "count:"<<count<<std::endl;
5639 
5640  }while (count++<nevent);
5641 
5642  outmix.close();
5643  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
5644 
5645 }
5646 
5647 
5648 void runMix(int nevent, EvtGen &myGenerator) {
5649 
5650  std::ofstream outmix;
5651  outmix.open("mix.dat");
5652 
5653  int count=1;
5654 
5655  myGenerator.readUDecay("exampleFiles/MIX.DEC");
5656 
5657  static EvtId UPS4=EvtPDL::getId(std::string("Upsilon(4S)"));
5658 
5659 
5660  do{
5661  EvtVector4R p_init(EvtPDL::getMass(UPS4),0.0,0.0,0.0);
5662  EvtParticle *root_part=EvtParticleFactory::particleFactory(UPS4,
5663  p_init);
5664  root_part->setVectorSpinDensity();
5665 
5666  myGenerator.generateDecay(root_part);
5667 
5668  outmix << root_part->getDaug(0)->getId().getId() << " ";
5669  outmix << root_part->getDaug(0)->getLifetime() << " ";
5670  outmix << root_part->getDaug(1)->getId().getId() << " ";
5671  outmix << root_part->getDaug(1)->getLifetime() << "\n";
5672 
5673  root_part->deleteTree();
5674 
5675  }while (count++<10000);
5676 
5677  outmix.close();
5678  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
5679 
5680 }
5681 
5682 
5683 void runBaryonic(int nEvent, EvtGen& myGenerator)
5684 {
5685  TFile* f = new TFile("baryonic.root", "RECREATE");
5686  TH1D* q2Hist = new TH1D("q2Hist", "q square", 50, 0.0, 25.00);
5687 
5688  EvtId BMINUS = EvtPDL::getId("B-");
5689  EvtVector4R p_init(EvtPDL::getMass(BMINUS), 0.0, 0.0, 0.0);
5690  EvtParticle* root_part;
5691  myGenerator.readUDecay("exampleFiles/BARYONIC.DEC");
5692 
5693  EvtVector4R l;
5694  EvtVector4R p;
5695  EvtVector4R g;
5696  EvtVector4R sum;
5697 
5698  for (int i=0; i<nEvent; ++i)
5699  {
5700  root_part = EvtParticleFactory::particleFactory(BMINUS, p_init);
5701  root_part->setDiagonalSpinDensity();
5702  myGenerator.generateDecay(root_part);
5703  l = root_part->getDaug(0)->getP4Lab(); // lambda momentum
5704  p = root_part->getDaug(1)->getP4Lab(); // pBar momentum
5705  g = root_part->getDaug(2)->getP4Lab(); // gamma momentum
5706  sum = p+g;
5707  q2Hist->Fill( sum.mass2() );
5708  root_part->deleteTree();
5709  }
5710  f->Write();
5711  f->Close();
5712  EvtGenReport(EVTGEN_INFO,"EvtGen") << "SUCCESS\n";
5713 
5714 }
double mass() const
const EvtVector4R & getP4() const
EvtParticle * getDaug(int i)
EvtVector4R getP4Lab() const
size_t getNDaug() const
Definition: EvtId.hh:27
Definition: EvtGen.hh:46
EvtParticle * getParent() const
void deleteTree()
void setP4(const EvtVector4R &p4)
Definition: EvtParticle.hh:273
EvtId getId() const
void setSpinDensityForwardHelicityBasis(const EvtSpinDensity &rho)
double getLifetime()
void setDiagonalSpinDensity()
void printTree() const
EvtParticle * nextIter(EvtParticle *rootOfTree=0)
void setVectorSpinDensity()