2 // The class definition in esdV0.h has been generated automatically
3 // by the ROOT utility TTree::MakeSelector(). This class is derived
4 // from the ROOT class TSelector. For more information on the TSelector
5 // framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual.
7 // The following methods are defined in this file:
8 // Begin(): called everytime a loop on the tree starts,
9 // a convenient place to create your histograms.
10 // SlaveBegin(): called after Begin(), when on PROOF called only on the
12 // Process(): called for each event, in this function you decide what
13 // to read and fill your histograms.
14 // SlaveTerminate: called at the end of the loop on the tree, when on PROOF
15 // called only on the slave servers.
16 // Terminate(): called at the end of the loop on the tree,
17 // a convenient place to draw/fit your histograms.
19 // To use this file, try the following session on your Tree T:
21 // Root > T->Process("esdV0.C")
22 // Root > T->Process("esdV0.C","some options")
23 // Root > T->Process("esdV0.C+")
32 esdV0::esdV0(TTree *) :
38 fHistMassAntiLambda(0),
39 fHistMassLambdaVsProb(0),
40 fHistMassLambdaCut(0),
41 fHistMassAntiLambdaCut(0)
43 // Constructor. Initialization of pointers
47 // Remove all pointers
51 // histograms are in the output list and deleted when the output
52 // list is deleted by the TSelector dtor
55 void esdV0::Begin(TTree *)
57 // The Begin() function is called at the start of the query.
58 // When running with PROOF Begin() is only called on the client.
59 // The tree argument is deprecated (on PROOF 0 is passed).
61 TString option = GetOption();
64 void esdV0::SlaveBegin(TTree * tree)
66 // The SlaveBegin() function is called after the Begin() function.
67 // When running with PROOF SlaveBegin() is called on each slave server.
68 // The tree argument is deprecated (on PROOF 0 is passed).
72 TString option = GetOption();
74 // Create histograms on each slave server
75 fHistMassK0 = new TH1F("hMassK0", "K^{0} candidates", 100, 0.4, 0.6);
76 fHistMassK0->GetXaxis()->SetTitle("M(#pi^{+}#pi^{-}) [GeV/c^{2}]");
77 fHistMassK0->SetOption("E");
78 fHistMassK0->SetMarkerStyle(kFullCircle);
79 fHistMassK0->SetStats(kFALSE);
81 fHistMassLambda = new TH1F("hMassLambda", "#Lambda^{0} candidates", 75, 1.05, 1.2);
82 fHistMassLambda->GetXaxis()->SetTitle("M(p#pi^{-}) [GeV/c^{2}]");
83 fHistMassLambda->SetOption("E");
84 fHistMassLambda->SetMarkerStyle(kFullCircle);
85 fHistMassLambda->SetMarkerColor(kRed);
86 fHistMassLambda->SetFillColor(4);
87 fHistMassLambda->SetStats(kFALSE);
89 fHistMassAntiLambda = new TH1F("hMassAntiLambda", "#bar{#Lambda}^{0} candidates", 75, 1.05, 1.2);
90 fHistMassAntiLambda->GetXaxis()->SetTitle("M(#bar{p}#pi^{+}) [GeV/c^{2}]");
91 fHistMassAntiLambda->SetOption("E");
92 fHistMassAntiLambda->SetMarkerStyle(kFullCircle);
93 fHistMassAntiLambda->SetMarkerColor(kRed);
94 fHistMassAntiLambda->SetFillColor(4);
95 fHistMassAntiLambda->SetStats(kFALSE);
97 fHistMassLambdaVsProb = new TH2F("hMassLambdaVsProb", "#Lambda^{0} and #bar{#Lambda}^{0} candidates", 21, -2.5, 102.5, 75, 1.05, 1.2);
98 fHistMassLambdaVsProb->GetXaxis()->SetTitle("prob(p) [%]");
99 fHistMassLambdaVsProb->GetYaxis()->SetTitle("M(p#pi) [GeV/c^{2}]");
100 fHistMassLambdaVsProb->SetOption("BOX");
101 fHistMassLambdaVsProb->SetFillStyle(0);
102 fHistMassLambdaVsProb->SetStats(kFALSE);
104 fHistMassLambdaCut = new TH1F("hMassLambdaCut", "#Lambda^{0} candidates", 75, 1.05, 1.2);
105 fHistMassLambdaCut->GetXaxis()->SetTitle("M(p#pi^{-}) [GeV/c^{2}]");
106 fHistMassLambdaCut->SetOption("E");
107 fHistMassLambdaCut->SetMarkerStyle(kFullCircle);
108 fHistMassLambdaCut->SetMarkerColor(kRed);
109 fHistMassLambdaCut->SetStats(kFALSE);
111 fHistMassAntiLambdaCut = new TH1F("hMassAntiLambdaCut", "#bar{#Lambda}^{0} candidates", 75, 1.05, 1.2);
112 fHistMassAntiLambdaCut->GetXaxis()->SetTitle("M(#bar{p}#pi^{+}) [GeV/c^{2}]");
113 fHistMassAntiLambdaCut->SetOption("E");
114 fHistMassAntiLambdaCut->SetMarkerStyle(kFullCircle);
115 fHistMassAntiLambdaCut->SetMarkerColor(kRed);
116 fHistMassAntiLambdaCut->SetStats(kFALSE);
119 void esdV0::Init(TTree *tree)
121 // The Init() function is called when the selector needs to initialize
122 // a new tree or chain. Typically here the branch addresses of the tree
123 // will be set. It is normaly not necessary to make changes to the
124 // generated code, but the routine can be extended by the user if needed.
125 // Init() will be called many times when running with PROOF.
127 // Set branch addresses
128 if (tree == 0) return;
131 fChain->SetBranchAddress("ESD",&fESD);
134 Bool_t esdV0::Notify()
136 // The Notify() function is called when a new file is opened. This
137 // can be either for a new TTree in a TChain or when when a new TTree
138 // is started when using PROOF. Typically here the branch pointers
139 // will be retrieved. It is normaly not necessary to make changes
140 // to the generated code, but the routine can be extended by the
147 Bool_t esdV0::Process(Long64_t entry)
149 // The Process() function is called for each entry in the tree (or possibly
150 // keyed object in the case of PROOF) to be processed. The entry argument
151 // specifies which entry in the currently loaded tree is to be processed.
152 // It can be passed to either TTree::GetEntry() or TBranch::GetEntry()
153 // to read either all or the required parts of the data. When processing
154 // keyed objects with PROOF, the object is already loaded and is available
155 // via the fObject pointer.
157 // This function should contain the "body" of the analysis. It can contain
158 // simple or elaborate selection criteria, run algorithms on the data
159 // of the event and typically fill histograms.
161 // WARNING when a selector is used with a TChain, you must use
162 // the pointer to the current TTree to call GetEntry(entry).
163 // The entry is always the local entry number in the current tree.
164 // Assuming that fChain is the pointer to the TChain being processed,
165 // use fChain->GetEntry(entry).
167 fChain->GetEntry(entry);
169 if (!fESD) return kFALSE;
171 Int_t nv0s = fESD->GetNumberOfV0s();
174 Double_t pPrior[5] = {0, 0, 0.85, 0.1, 0.05};
176 Double_t pSum, pNorm;
177 for (Int_t iV0 = 0; iV0 < fESD->GetNumberOfV0s(); iV0++) {
178 AliESDv0* v0 = fESD->GetV0(iV0);
181 fHistMassK0->Fill(v0->GetEffMass());
183 v0->ChangeMassHypothesis(kLambda0);
184 mass = v0->GetEffMass();
185 fESD->GetTrack(v0->GetPindex())->GetESDpid(p);
187 for (Int_t i = 0; i < AliPID::kSPECIES; i++) pSum += p[i] * pPrior[i];
188 if (pSum <= 0) pSum = 1.;
189 pNorm = p[AliPID::kProton] * pPrior[AliPID::kProton] / pSum;
190 fHistMassLambdaVsProb->Fill(100.*pNorm, mass);
191 if (pNorm > 0.1) fHistMassLambda->Fill(mass);
193 v0->ChangeMassHypothesis(kLambda0Bar);
194 mass = v0->GetEffMass();
195 fESD->GetTrack(v0->GetNindex())->GetESDpid(p);
197 for (Int_t i = 0; i < AliPID::kSPECIES; i++) pSum += p[i] * pPrior[i];
198 if (pSum <= 0) pSum = 1.;
199 pNorm = p[AliPID::kProton] * pPrior[AliPID::kProton] / pSum;
200 fHistMassLambdaVsProb->Fill(100.*pNorm, mass);
201 if (pNorm > 0.1) fHistMassAntiLambda->Fill(mass);
210 void esdV0::SlaveTerminate()
212 // The SlaveTerminate() function is called after all entries or objects
213 // have been processed. When running with PROOF SlaveTerminate() is called
214 // on each slave server.
216 // Add the histograms to the output on each slave server
217 fOutput->Add(fHistMassK0);
218 fOutput->Add(fHistMassLambda);
219 fOutput->Add(fHistMassAntiLambda);
220 fOutput->Add(fHistMassLambdaVsProb);
221 fOutput->Add(fHistMassLambdaCut);
222 fOutput->Add(fHistMassAntiLambdaCut);
225 void esdV0::Terminate()
227 // The Terminate() function is the last function to be called during
228 // a query. It always runs on the client, it can be used to present
229 // the results graphically or save the results to file.
231 fHistMassK0 = dynamic_cast<TH1F*>(fOutput->FindObject("hMassK0"));
232 fHistMassLambda = dynamic_cast<TH1F*>(fOutput->FindObject("hMassLambda"));
233 fHistMassAntiLambda = dynamic_cast<TH1F*>(fOutput->FindObject("hMassAntiLambda"));
234 fHistMassLambdaVsProb = dynamic_cast<TH2F*>(fOutput->FindObject("hMassLambdaVsProb"));
235 fHistMassLambdaCut = dynamic_cast<TH1F*>(fOutput->FindObject("hMassLambdaCut"));
236 fHistMassAntiLambdaCut = dynamic_cast<TH1F*>(fOutput->FindObject("hMassAntiLambdaCut"));
238 TFile* file = TFile::Open("V0.root", "RECREATE");
239 fHistMassK0->Write();
240 fHistMassLambda->Write();
241 fHistMassAntiLambda->Write();
242 fHistMassLambdaVsProb->Write();
243 fHistMassLambdaCut->Write();
244 fHistMassAntiLambdaCut->Write();
248 if (!gROOT->IsBatch())
250 TCanvas *c1 = new TCanvas("c1","V0s",10,10,610,610);
251 c1->SetFillColor(10);
252 c1->SetHighLightColor(10);
256 fHistMassK0->DrawCopy("E");
257 fHistMassK0->Fit("gaus","q","",0.49,0.51);
258 TVirtualPad* pad = (TVirtualPad*)c1->cd(2);
261 fHistMassLambda->DrawCopy("E");
263 fHistMassAntiLambda->DrawCopy("E");