StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PlotKspimumu.C
1 TCanvas* theCanvas = new TCanvas("theCanvas", "", 900, 500);
2 gROOT->SetStyle("Plain");
3 theCanvas->UseCurrentStyle();
4 
5 void PlotKspimumu() {
6 
7  // K0s -> pi0 mu+ mu-
8 
9  TFile* theFile = TFile::Open("Kspimumu.root", "read");
10  TTree* theTree = dynamic_cast<TTree*>(theFile->Get("Data"));
11 
12  int eventId, PDGId, dVtx, daug;
13  double E, px, py, pz, EL, pxL, pyL, pzL;
14  theTree->SetBranchAddress("eventId", &eventId);
15  theTree->SetBranchAddress("PDGId", &PDGId);
16  theTree->SetBranchAddress("dVtx", &dVtx);
17  theTree->SetBranchAddress("daug", &daug);
18  //theTree->SetBranchAddress("E", &E);
19  //theTree->SetBranchAddress("px", &px);
20  //theTree->SetBranchAddress("py", &py);
21  //theTree->SetBranchAddress("pz", &pz);
22  theTree->SetBranchAddress("EL", &EL);
23  theTree->SetBranchAddress("pxL", &pxL);
24  theTree->SetBranchAddress("pyL", &pyL);
25  theTree->SetBranchAddress("pzL", &pzL);
26 
27  int nEntries = theTree->GetEntries();
28  int i(0);
29 
30  int oldEvent(0);
31 
32  int maxEvent = theTree->GetMaximum("eventId");
33 
34  // Mass of mu+ mu- pair
35  TH1D* mHist = new TH1D("mHist", "", 40, 0.2, 0.4);
36  mHist->SetDirectory(0);
37  mHist->SetXTitle("M_mumu (GeV/c^{2})");
38 
39  // cosHelicity of mu-
40  TH1D* cHist = new TH1D("cHist", "", 40, -1.0, 1.0);
41  cHist->SetDirectory(0);
42  cHist->SetXTitle("cosHel");
43 
44  TLorentzVector mumP4, mupP4, twoMuP4, pi0P4;
45  int mumId(13), mupId(-13), pi0Id(111);
46  //int K0sId(310);
47 
48  bool gotMum(false), gotMup(false), gotPi0(false);
49 
50  for (i = 0; i < nEntries; i++) {
51 
52  theTree->GetEntry(i);
53 
54  if (i%100000 == 0) {cout<<"Event = "<<nEntries-i<<endl;}
55 
56  if (gotMum && gotMup && gotPi0) {
57 
58  // Store the mass and cosHelicity values
59  twoMuP4 = mumP4 + mupP4;
60  mHist->Fill(twoMuP4.M());
61 
62  double cosHel = cosHelicity(mumP4, twoMuP4, pi0P4);
63  cHist->Fill(cosHel);
64 
65  zeroVector(mumP4); gotMum = false;
66  zeroVector(mupP4); gotMup = false;
67  zeroVector(pi0P4); gotPi0 = false;
68  zeroVector(twoMuP4);
69 
70  }
71 
72  TLorentzVector p4(pxL, pyL, pzL, EL);
73 
74  if (PDGId == mumId) {
75  mumP4.SetPx(pxL); mumP4.SetPy(pyL); mumP4.SetPz(pzL); mumP4.SetE(EL);
76  gotMum = true;
77  } else if (PDGId == mupId) {
78  mupP4.SetPx(pxL); mupP4.SetPy(pyL); mupP4.SetPz(pzL); mupP4.SetE(EL);
79  gotMup = true;
80  } else if (PDGId == pi0Id) {
81  pi0P4.SetPx(pxL); pi0P4.SetPy(pyL); pi0P4.SetPz(pzL); pi0P4.SetE(EL);
82  gotPi0 = true;
83  }
84 
85  }
86 
87  // For last event
88  if (gotMum && gotMup && gotPi0) {
89 
90  // Store the mass and cosHelicity values
91  twoMuP4 = mumP4 + mupP4;
92  mHist->Fill(twoMuP4.M());
93 
94  double cosHel = cosHelicity(mumP4, twoMuP4, pi0P4);
95  cHist->Fill(cosHel);
96  }
97 
98  theCanvas->cd();
99  theCanvas->Divide(2,1);
100  theCanvas->cd(1);
101  mHist->Draw();
102  theCanvas->cd(2);
103  cHist->SetMinimum(0.0);
104  cHist->Draw();
105  theCanvas->Print("Plots_Kspimumu.png");
106 
107 }
108 
109 double cosHelicity(TLorentzVector particle, TLorentzVector parent,
110  TLorentzVector grandparent) {
111 
112  TVector3 boosttoparent = -(parent.BoostVector());
113 
114  particle.Boost(boosttoparent);
115  grandparent.Boost(boosttoparent);
116 
117  TVector3 particle3 = particle.Vect();
118  TVector3 grandparent3 = grandparent.Vect();
119  double numerator = particle3.Dot(grandparent3);
120  double denominator = (particle3.Mag())*(grandparent3.Mag());
121  double temp = numerator/denominator;
122 
123  return temp;
124 
125 }
126 
127 void zeroVector(TLorentzVector vect) {
128 
129  vect.SetX(0.0);
130  vect.SetY(0.0);
131  vect.SetZ(0.0);
132  vect.SetT(0.0);
133 
134 }