Pluto v6.3.0
Loading...
Searching...
No Matches
inspect_phi2170.C
Go to the documentation of this file.
1
2//
3// inspect_phi2170.C
4//
5// Example analysis macro for the exotic particle plugin.
6//
7// Reads the ROOT file produced by test_phi2170.C and
8// demonstrates how to:
9//
10// - read the Pluto event tree
11// - access PParticle objects
12// - reconstruct simple invariant masses
13// - draw basic histograms
14//
17 TString infile = "phi2170_phipipi.root"
18){
19 //----------------------------------------------------------
20 // Register exotic particles (e.g. phi2170, f0_980)
21 //----------------------------------------------------------
22
23 makeDistributionManager()->Exec("exotics:init");
24
25 //----------------------------------------------------------
26 // Open ROOT file
27 //----------------------------------------------------------
28
29 TFile *f = TFile::Open(infile);
30
31 if (!f || f->IsZombie()) {
32 cout << "Cannot open " << infile << endl;
33 return;
34 }
35
36 TTree *tree = (TTree*)f->Get("data");
37
38 if (!tree) {
39 cout << "Tree \"data\" not found." << endl;
40 return;
41 }
42
43 //----------------------------------------------------------
44 // Read Pluto particle array
45 //----------------------------------------------------------
46
47 TClonesArray *particles = nullptr;
48 tree->SetBranchAddress("Particles", &particles);
49
50 //----------------------------------------------------------
51 // Retrieve particle IDs from the Pluto particle database
52 //----------------------------------------------------------
53
54 Int_t pidKp = makeStaticData()->GetParticleID("K+"); // particle ID 11
55 Int_t pidKm = makeStaticData()->GetParticleID("K-"); // particle ID 12
56 Int_t pidPip = makeStaticData()->GetParticleID("pi+"); // particle ID 8
57 Int_t pidPim = makeStaticData()->GetParticleID("pi-"); // particle ID 9
58
59 //----------------------------------------------------------
60 // Histograms
61 //----------------------------------------------------------
62
63 Double_t mKKmax = 1.08;
64
65 if (infile.Contains("KKpipi"))
66 mKKmax = 2.2;
67
68 Double_t mpipimin = 0.2;
69 if (infile.Contains("phif0"))
70 mpipimin = 0.7;
71
72 TH1D *h_mKK = new TH1D(
73 "h_mKK",
74 "K^{+}K^{-} invariant mass;M(K^{+}K^{-}) [GeV/c^{2}];Events",
75 100,0.98,mKKmax);
76
77 TH1D *h_mpipi = new TH1D(
78 "h_mpipi",
79 "#pi^{+}#pi^{-} invariant mass;M(#pi^{+}#pi^{-}) [GeV/c^{2}];Events",
80 100, mpipimin, 1.5);
81
82 TH1D *h_mKKpipi = new TH1D(
83 "h_mKKpipi",
84 "K^{+}K^{-}#pi^{+}#pi^{-} invariant mass;M(K^{+}K^{-}#pi^{+}#pi^{-}) [GeV/c^{2}];Events",
85 120, 1.8, 2.5);
86
87 //----------------------------------------------------------
88 // Event loop
89 //----------------------------------------------------------
90
91 Long64_t nev = tree->GetEntries();
92
93 cout << "Reading " << nev << " events..." << endl;
94
95 for (Long64_t iev = 0; iev < nev; iev++) {
96
97 tree->GetEntry(iev);
98
99 if (!particles) continue;
100
101 TLorentzVector kp, km, pip, pim;
102
103 bool hasKp = false;
104 bool hasKm = false;
105 bool hasPip = false;
106 bool hasPim = false;
107
108 Int_t np = particles->GetEntriesFast();
109
110 //------------------------------------------------------
111 // Loop over all particles in the event
112 //------------------------------------------------------
113
114 for (Int_t i = 0; i < np; i++) {
115
116 PParticle *p = (PParticle*)particles->At(i);
117
118 if (p->ID() == pidKp) {
119 kp = *p;
120 hasKp = true;
121 }
122 else if (p->ID() == pidKm) {
123 km = *p;
124 hasKm = true;
125 }
126 else if (p->ID() == pidPip) {
127 pip = *p;
128 hasPip = true;
129 }
130 else if (p->ID() == pidPim) {
131 pim = *p;
132 hasPim = true;
133 }
134 }
135
136 //------------------------------------------------------
137 // Fill invariant-mass histograms
138 //------------------------------------------------------
139
140 if (hasKp && hasKm) {
141
142 h_mKK->Fill((kp + km).M());
143
144 if (hasPip && hasPim) {
145
146 h_mpipi->Fill((pip + pim).M());
147
148 h_mKKpipi->Fill((kp + km + pip + pim).M());
149 }
150 }
151 }
152
153 //----------------------------------------------------------
154 // Draw histograms
155 //----------------------------------------------------------
156
157 TCanvas *c = new TCanvas("c", "phi2170 inspect", 1200, 400);
158
159 c->Divide(3,1);
160
161 c->cd(1);
162 h_mKK->Draw();
163
164 c->cd(2);
165 h_mpipi->Draw();
166
167 c->cd(3);
168 h_mKKpipi->Draw();
169
170 TString outfile = infile;
171 outfile.ReplaceAll(".root", "_inspect.pdf");
172 c->SaveAs(outfile);
173
174 cout << endl;
175 cout << "==========================================" << endl;
176 cout << "phi(2170) inspection" << endl;
177 cout << "==========================================" << endl;
178 cout << "Input file : " << infile << endl;
179 cout << "Events : " << tree->GetEntries() << endl;
180 cout << "==========================================" << endl;
181
182 cout << endl;
183 cout << endl;
184 cout << "Inspection finished." << endl;
185 cout << "Plots saved to " << outfile << endl;
186}
PDistributionManager * makeDistributionManager()
PStaticData * makeStaticData()
TFile * f
Definition analyze_g12C.C:8
new TCanvas()
Bool_t Exec(const char *command)
int GetParticleID(const char *id, int warn=1)
PChannel * c[]
PParticle * p
Definition dp_mult.C:24
void inspect_phi2170(TString infile="phi2170_phipipi.root")
int nev
PParticle * kp
PParticle * km
PParticle * pim
Definition w_dalitz.C:8